LBNL-ETA / MSWH

Multiscale Solar Water Heating
Other
10 stars 11 forks source link

pandas >v1.0 causes test failure #11

Closed brynpickering closed 4 years ago

brynpickering commented 4 years ago

On a fresh install of MSWH, using the README instructions, The mswh.system.tests.test_models.SystemTests.test_solar_electric test fails with the following error trace:

Traceback (most recent call last):
  File "/path/to/MSWH/mswh/system/tests/test_models.py", line 834, in test_solar_electric
    self.r['p_el_res_use']]],
  File "/path/to/conda-env/lib/python3.6/site-packages/pandas/core/indexing.py", line 873, in __getitem__
    return self._getitem_tuple(key)
  File "/path/to/conda-env/lib/python3.6/site-packages/pandas/core/indexing.py", line 1055, in _getitem_tuple
    return self._getitem_tuple_same_dim(tup)
  File "/path/to/conda-env/lib/python3.6/site-packages/pandas/core/indexing.py", line 750, in _getitem_tuple_same_dim
    retval = getattr(retval, self.name)._getitem_axis(key, axis=i)
  File "/path/to/conda-env/lib/python3.6/site-packages/pandas/core/indexing.py", line 1099, in _getitem_axis
    return self._getitem_iterable(key, axis=axis)
  File "/path/to/conda-env/lib/python3.6/site-packages/pandas/core/indexing.py", line 1037, in _getitem_iterable
    keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
  File "/path/to/conda-env/lib/python3.6/site-packages/pandas/core/indexing.py", line 1254, in _get_listlike_indexer
    self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing)
  File "/path/to/conda-env/lib/python3.6/site-packages/pandas/core/indexing.py", line 1316, in _validate_read_indexer
    "Passing list-likes to .loc or [] with any missing labels "
KeyError: "Passing list-likes to .loc or [] with any missing labels is no longer supported. The following labels were missing: Index(['Tank Balancing Error (Heat Rate)'], dtype='object'). See https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike"

This requires either pinning pandas in your requirements to stay below version 1.0, or updating the code to handle >=v1.0. pandas v1.x has been out for a while now, so I would suggest pinning to >v1.x and updating code accordingly.

Note: this issue comes to you as part of my wider JOSS review

milicag commented 4 years ago

As we use this code in a few analyses and have the code profiled to a satisfactory speed, I would prefer to simply limit the pandas package version and leave the pandas update to a different time in case we use it for a new project. I hope this is not a problem on your end.

brynpickering commented 4 years ago

Yep, no issue with that!

milicag commented 4 years ago

Thank you! I plan to address issues you create over the weekend sometime, just so you can set expectations.

milicag commented 4 years ago

This was actually an issue with a deprecated label, that stayed in @hannesb0 models as I did some updates after he was done with his Master Thesis research. I've tested with the latest pandas and numpy and no edits were needed, so no need to limit versions for now!

milicag commented 4 years ago

In fact, I started using a more descriptive label instead:

            'q_ovrcool_tank': 'Tank Overcool (Heat Rate)',

As computers do not really know the 2nd law of thermodynamics and I am willing to partially forgive it occasionally, I use the above variable to perform the appropriate accounting and reporting.

milicag commented 4 years ago

Updated to python 3.8.