fit_annuli: plots=None renders all panels (can't disable via None) and leaks Matplotlib figures in loops
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- matplotlib, numpy, python
- Área
- data-visualization
Línea de trabajo
Start in eddy/rotationmap.py at fit_annuli around line 534, then inspect plot_velocity_profiles, plot_model, and plot_model_residual around the referenced plotting code. Run the 30-call reproduction and compare plots=None, plots=[], and the documented options. Done means the plots argument behavior, figure lifecycle, and docstring agree without accumulating open figures.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
In rotationmap.fit_annuli, the plots argument defaults to None, but None is
interpreted as "plot all panels" rather than "plot nothing". To suppress plotting you
have to pass plots=[], which is neither documented nor obvious. Because the plotting
helpers open figures without closing them, calling fit_annuli in a loop (e.g. a
Monte-Carlo over many maps) leaks a figure per call — triggering matplotlib's
More than 20 figures have been opened warning and growing memory unbounded.
Version
eddy 3.1.0, eddy/rotationmap.py.
Where
# eddy/rotationmap.py, fit_annuli, ~L534
plots = ['profiles', 'model', 'residual'] if plots is None else plots
plots = np.atleast_1d(plots)
if 'profiles' in plots:
self.plot_velocity_profiles(rpnts=rpnts, velo=velo, dvelo=dvelo)
if 'model' in plots:
self.plot_model(model=model)
if 'residual' in plots:
self.plot_model_residual(model=model)
Each of plot_velocity_profiles / plot_model / plot_model_residual does
fig, ax = plt.subplots() (e.g. rotationmap.py:2321) and never closes the figure.
Reproduce
import matplotlib.pyplot as plt
# rmap = some rotationmap / momentmap with a fittable map
for i in range(30):
rmap.fit_annuli(x0=0, y0=0, inc=inc, PA=PA, rbins=rbins,
fit_vrad=True, fix_vlsr=vlsr, returns='residual') # plots=None
print(len(plt.get_fignums())) # ~90 open figures (3 per call); RuntimeWarning fires at 20
Expected vs. actual
- Expected:
plots=None(the default) produces no plots — the conventional meaning of
an optionalplots/plotkwarg — and repeated calls do not accumulate figures. - Actual:
plots=Nonerenders all three panels every call, and the figures are never
closed, so a loop leaks figures and eventually warns / risks OOM.
Secondary: docstring mismatch
The docstring says:
plots (Optional[list]): Plots to generate after the fitting. Can be either of'model'
and'residual'. Default is both.
But the code default is three panels including 'profiles', and 'profiles' is a
valid (undocumented) option.
Suggested fix (your call)
- Treat a falsy
plots(None/[]/False) as no plots; if plot-by-default is
wanted, use an explicit default list instead of theNonesentinel. - Close the figures after drawing (or return them) so loop callers don't leak — or gate
plotting behind an explicitplot=True. - Update the docstring to list
'profiles'and state the actual default.
Workaround
Pass plots=[] to suppress plotting.
- Lenguaje dominante
- Python
- Estrellas
- 23
- Forks
- 11
- Merge medio
- 28 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin 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 PlanetFormationLab/eddy
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
PlanetFormationLab/eddy#36 ·
-
StructureFunction2DStack.fit_spiral / calculate_modal_power has no per-annulus fault toleranceAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 78/100
PlanetFormationLab/eddy#39 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
PlanetFormationLab/eddy#34 ·
-
vlsr prior is too narrowAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
PlanetFormationLab/eddy#33 · 2 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
PlanetFormationLab/eddy#32 ·
Todos los issues de PlanetFormationLab/eddy
Issues similares
-
python triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
microsoft/semantic-kernel#14590 ·
Los mantenedores suelen responder en 3 días
-
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 85/100
pinterest/pymemcache#662 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Medio día Aptitud para principiantes 62/100
gnocchixyz/gnocchi#1527 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
tenstorrent/tt-model-manager#181 ·
Los mantenedores suelen responder en 1 día