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

Address warnings + remove warning suppression #69

Merged
merged 4 commits into from
May 12, 2024
Merged

Conversation

twallema
Copy link
Owner

  • I have checked to ensure there aren't other open Pull Requests for the same update/change
  • I have updated the documentation accordingly.

Describe your fixes/additions/changes

In the tutorials, warnings were suppressed using the following code:

# Suppress warnings
import warnings
warnings.filterwarnings("ignore")

However, suppressing warnings is undesirable. So I've gone through all the unit tests and tutorials, removed any warning suppression, and addressed one warning that popped up. In ~/influenza_1718/calibration.py,

data = pd.read_csv(os.path.join(os.path.dirname(__file__),'data/interim/data_influenza_1718_format.csv'), index_col=[0,1], parse_dates=True)

was changed into,

data = pd.read_csv(os.path.join(os.path.dirname(__file__),'data/interim/data_influenza_1718_format.csv'), index_col=[0,1], parse_dates=True, date_format='%Y-%m-%d')

because pandas threw a warning that it had trouble parsing the dates. Only two warnings that don't require further attention remain (listing them here for bookkeeping purposes):

  1. In the SIR workflow_tutorial.py, when printing the autocorrelation of the MCMC sampler, this yields a divide by zero/overflow warning (see below). I looked in the emcee code to study the error, and it is caused by the first autocorrelation being zero. Idk why this is zero tho, played with the perturbation on the initial estimate, etc. Chains don't go out of bounds, really weird but it's only present in this tutorial so I'm leaving it like this.
/home/twallema/anaconda3/envs/PYSODM/lib/python3.12/site-packages/emcee/autocorr.py:38: RuntimeWarning: invalid value encountered in divide
  acf /= acf[0]
  1. In the test_ODE.py unit test, a model is tested with a "square" state of dimensions 'age_groups' x 'age_groups' and this yields the following warning:
 src/tests/test_ODE.py::test_SIR_SI_state_shapes
  /home/twallema/anaconda3/envs/PYSODM/lib/python3.12/site-packages/xarray/namedarray/core.py:496: UserWarning: Duplicate dimension names present: dimensions {'age_group'} appear more than once in dims=('time', 'age_group', 'age_group'). We do not yet support duplicate dimension names, but we do allow initial construction of the object. We recommend you rename the dims immediately to become distinct, as most xarray functionality is likely to fail silently if you do not. To rename the dimensions you will need to set the ``.dims`` attribute of each variable, ``e.g. var.dims=('x0', 'x1')``.
    warnings.warn(

@twallema twallema merged commit 035d025 into master May 12, 2024
3 checks passed
@twallema twallema deleted the silence-warnings branch May 12, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant