Skip to content

defaults.py AttributeError: __repr__ references self.region.s  #173

@pjhoberman

Description

@pjhoberman

It looks like the __repr__ function in defaults.py is referencing an attribute that no longer exists. Steps to reproduce below. Likely fix is just refactoring the return to use self.region.susceptible instead of self.region.s

from src.penn_chime.defaults import Constants, Regions, RateLos
delaware = 564696
chester = 519293
montgomery = 826075
bucks = 628341
philly = 1581000
DEFAULTS = Constants(
    # EDIT YOUR DEFAULTS HERE
    region=Regions(
        delaware=delaware,
        chester=chester,
        montgomery=montgomery,
        bucks=bucks,
        philly=philly),
    current_hospitalized=6,
    doubling_time=6,
    known_infected=157,
    n_days=60,
    market_share=0.15,
    relative_contact_rate=0,
    hospitalized=RateLos(0.05, 7),
    icu=RateLos(0.02, 9),
    ventilated=RateLos(0.01, 10),
)
DEFAULTS
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/formatters.py", line 224, in catch_format_error
    r = method(self, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/formatters.py", line 702, in __call__
    printer.pretty(obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/lib/pretty.py", line 394, in pretty
    return _repr_pprint(obj, self, cycle)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/lib/pretty.py", line 684, in _repr_pprint
    output = repr(obj)
  File "/Users/pjhoberman/Projects/chime/src/penn_chime/defaults.py", line 56, in __repr__
    return f"Constants(susceptible_default: {self.region.s}, known_infected: {self.known_infected})"
AttributeError: 'Regions' object has no attribute 's'
Out[5]: In[6]: DEFAULTS.n_days
Out[6]: 60
DEFAULTS.known_infected
Out[7]: 157

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions