exponential_moving_average returns an incorrect second value when window_size=1
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 88/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- fintech-quant
Línea de trabajo
Empieza en financial/exponential_moving_average.py y ejecuta la reproducción reportada con window_size=1. Comprueba la rama de inicialización alrededor de i <= window_size y el doctest existente como contexto. La tarea estará terminada cuando exponential_moving_average devuelva [10.0, 20.0, 30.0] para esa entrada, manteniendo el comportamiento existente de window_size=3.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Repository commit
7f81fcd68c195ce71534de09d1b69d2b61665902
Python version (python --version)
Python 3.14.7
Dependencies version (pip freeze)
No third-party dependencies are required for this reproduction; the function uses only the Python standard library.
Expected behavior
For window_size=1, the documented smoothing factor is:
alpha = 2 / (1 + window_size) = 1
Therefore, the documented recurrence should return each input value unchanged.
For input [10.0, 20.0, 30.0], the expected output is:
[10.0, 20.0, 30.0]
Actual behavior
The function returns [10.0, 15.0, 30.0], so the second value is incorrect.
Reproduction from the repository root:
from financial.exponential_moving_average import exponential_moving_average
actual = list(
exponential_moving_average(iter([10.0, 20.0, 30.0]), window_size=1)
)
print(actual)
# [10.0, 15.0, 30.0]
assert actual == [10.0, 20.0, 30.0]
# AssertionError
The initialization branch uses if i <= window_size. At i=1 and window_size=1, it calculates (moving_average + stock_price) * 0.5, producing 15.0 instead of applying alpha=1.
The existing doctest uses window_size=3 and passes, but does not cover this case.
The unmodified source file at the reported commit was tested with Python 3.14.7.
- Lenguaje dominante
- Python
- Estrellas
- 225k
- Forks
- 51.1k
- Merge medio
- 16 h 12 min
- PR fusionados (30 d)
- 180
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TheAlgorithms/Python
-
enhancement good first issue hacktoberfest tracking issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
TheAlgorithms/Python#15234 · 91 comentarios ·
Los mantenedores suelen responder en 1 día
-
TheAlgorithms/python_maintainers: Call for help in preparing for Hacktoberfest 2026Posiblemente ocupada @AnupKumarPanwar la tomó hace 13 días. Abiertohelp wanted
TheAlgorithms/Python#15351 · 2 asignados ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
TheAlgorithms/Python#15337 · 14 comentarios ·
Los mantenedores suelen responder en 1 día
-
Open Pull Request File MapAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
TheAlgorithms/Python#15310 · 23 comentarios ·
Los mantenedores suelen responder en 1 día
-
hacktoberfest help wanted tracking issue
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
TheAlgorithms/Python#15187 · 8 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de TheAlgorithms/Python
Issues similares
-
bug server
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
sportsdataverse/sportsdataverse-py#641 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
googleapis/google-cloud-python#18532 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día