Skip to content
Snippets Groups Projects

make BudgetItem.freq a property

Merged Kevin Kuns requested to merge kevin.kuns/pygwinc:BudgetItem-freq into master
3 unresolved threads
3 files
+ 57
8
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 3
3
@@ -44,8 +44,8 @@ def freq_from_spec(spec=None):
return spec
elif spec is None:
spec = DEFAULT_FREQ
fspec = spec.split(':')
try:
fspec = spec.split(':')
if len(fspec) == 2:
fspec = fspec[0], DEFAULT_FREQ.split(':')[1], fspec[1]
return np.logspace(
@@ -53,7 +53,7 @@ def freq_from_spec(spec=None):
np.log10(float(fspec[2])),
int(fspec[1]),
)
except (ValueError, IndexError):
except (ValueError, IndexError, AttributeError):
    • how do you think an AttributeError would be raised here? this should only ever be called on strings, and I don't think any of their attributes are relevant to the parsing here.

      • Author Maintainer

        If spec is not np.ndarray and is not None, then spec is not a string when entering the try block. spec.split(':') raises an AttributeError in this case. This was also previously the case and I fixed it this way when updating the rest of the frequency specification. This could also be solved by adding an else case after the case that spec is None. Open to other suggestions.

      • Please register or sign in to reply
Please register or sign in to reply
raise InvalidFrequencySpec(f'Improper frequency specification: {spec}')
@@ -154,7 +154,7 @@ def load_budget(name_or_path, freq=None, bname=None):
mod, modpath = load_module(modname)
Budget = getattr(mod, bname)
if freq is None:
freq = getattr(Budget, 'freq', None)
freq = getattr(Budget, '_freq', None)
freq = freq_from_spec(freq)
ifopath = os.path.join(modpath, 'ifo.yaml')
if not ifo and os.path.exists(ifopath):
Loading