Skip to content

Commit

Permalink
fix(hfbcat): Re-initialise class variables (#86)
Browse files Browse the repository at this point in the history
Because it subclasses from FluxCatalog, by default will inherit
the class variables from FluxCatalog, but that's where FluxCatalog
stores the catalogs it loads at import time.  (Which seems like a
weird, an un-Pythonic, effect of importing a module.)

The side effect is that all the FluxCatalog catalogs end up in the
HFBCatalog as well, which I suspect is not intended.  So here's
a fix to re-initialise these class variables to nothing, so that the
FluxCatalog catalogs don't pollute the HFBCatalog.

Now, only the catalogue(s) loaded explicitly into HFBCatalog will
exist in it.
  • Loading branch information
ketiltrout authored Aug 21, 2024
1 parent f9dfc4b commit f07166d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ch_util/fluxcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def _deriv_fit_func(x, *param):

class MetaFluxCatalog(type):
"""Metaclass for FluxCatalog. Defines magic methods
for the class that can act on and provice access to the
for the class that can act on and provide access to the
catalog of all astronomical sources.
"""

Expand Down Expand Up @@ -444,7 +444,7 @@ def __init__(
if alt_name in self._alternate_name_lookup:
alt_source = self._alternate_name_lookup[alt_name]
warnings.warn(
f"The alternate name {alt_name} is already "
f"The alternate name {alt_name} for {self.name} is already "
f"held by the source {alt_source}."
)
else:
Expand Down
4 changes: 4 additions & 0 deletions ch_util/hfbcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class HFBCatalog(FluxCatalog):
"freq_abs",
]

_entries = {}
_collections = {}
_alternate_name_lookup = {}

def __init__(
self,
name,
Expand Down

0 comments on commit f07166d

Please sign in to comment.