Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing dependency on pyyaml #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ classifiers = [
"License :: CeCILL-C Free Software License Agreement (CECILL-C)",
]
dependencies = [
"pyyaml",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Du coup matplotlib aussi non?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De manière optionnelle oui. Mais tout code qui ferait appel à bronx pour ces fonctions matplotlib utiliserait déjà matplotlib, donc c'est moins indispensable.
Pour pyyaml c'est simplement qu'un
from bronx.datagrip.misc import read_dict_in_CSV
dans epygram lève une ModuleNotFoundError: No module named 'yaml'

]
dynamic = ["version"]

Expand Down
2 changes: 2 additions & 0 deletions src/bronx/graphics/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def set_figax(figure=None, ax=None,
using pyplot.subplots(), in which case any argument can be additionally
passed through subplots_kw.
"""
import matplotlib.pyplot
plt = matplotlib.pyplot
if ax is not None and figure is None:
figure = ax.figure
Expand Down Expand Up @@ -52,6 +53,7 @@ def set_nice_time_axis(axis, xy,
:param datefmt: format for date
:param tickslabelsrotation: angle in degrees, anti-clockwise order
"""
import matplotlib.pyplot
mdates = matplotlib.dates
plt = matplotlib.pyplot

Expand Down
14 changes: 14 additions & 0 deletions src/bronx/syntax/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,17 @@ def secured_getattr(self, key):
else:
return func(self, key)
return secured_getattr


@nicedeco
def init_before(mtd):
"""
Decorator for methods: call method self._actual_init()
before actually calling method if not self.initialized.
"""
def initialized(self, *args, **kwargs):
if not self._initialized:
self._actual_init()
return mtd(self, *args, **kwargs)
return initialized

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce décorateur est-t-il utilisé pour des méthodes de classes définies dans bronx?

J'ai du mal à comprendre le besoin d'utiliser une autre fonction d'initialisation _actual_init plutot que __init__ -- ça me parait étrange. En tous cas, si ce décorateur reste dans bronx, il faudrait à mon avis que la docstring donne un exemple, ou a minima explique pourquoi il est utile.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L'idée c'est de faire une "delayed init", en n'initialisant certaines choses (typiquement, lire un fichier de définitions GRIB) que lorsqu'on en a réellement besoin.
En fait je n'en ai réellement besoin que dans certaines classes d'epygram, donc je peux l'y garder, mais je pensais que ça pouvait être utile par ailleurs (et que la docstring était assez explicite).