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

Fix warnings #609

Merged
merged 1 commit into from
Mar 28, 2022
Merged

Fix warnings #609

merged 1 commit into from
Mar 28, 2022

Conversation

rouille
Copy link
Collaborator

@rouille rouille commented Mar 28, 2022

Pull Request doc

Purpose

Fix warnings raised by our test suite. Went from 130 warnings down to 7.

What the code is doing

Most warnings come from pandas. These were:

* FutureWarning: Passing a set as an indexer is deprecated and will raise in a future version. Use a list instead
* FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
* SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame
* FutureWarning: Passing method to Int64Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead.

Remaining warnings come from from third party packages and a user warning, see below:

.tox/pytest-local/lib/python3.9/site-packages/pypsa/descriptors.py:31
  /Users/brdo/CEM/PowerSimData/.tox/pytest-local/lib/python3.9/site-packages/pypsa/descriptors.py:31: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _nx_version = StrictVersion(nx.__version__)

.tox/pytest-local/lib/python3.9/site-packages/pypsa/linopf.py:37
  /Users/brdo/CEM/PowerSimData/.tox/pytest-local/lib/python3.9/site-packages/pypsa/linopf.py:37: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    pd_version = LooseVersion(pd.__version__)

.tox/pytest-local/lib/python3.9/site-packages/setuptools/_distutils/version.py:351
  /Users/brdo/CEM/PowerSimData/.tox/pytest-local/lib/python3.9/site-packages/setuptools/_distutils/version.py:351: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    other = LooseVersion(other)

powersimdata/design/investment/tests/test_investment_costs.py::test_calculate_gen_inv_costs_not_summed
  /Users/brdo/CEM/PowerSimData/powersimdata/design/investment/investment_costs.py:471: UserWarning: No cost data available for Nuclear for Advanced cost case, using Moderate cost case data instead
    warnings.warn(

powersimdata/input/tests/test_export_to_pypsa.py::test_export_grid_to_pypsa
powersimdata/input/tests/test_export_to_pypsa.py::test_export_grid_to_pypsa
powersimdata/input/tests/test_export_to_pypsa.py::test_export_grid_to_pypsa
  /Users/brdo/CEM/PowerSimData/.tox/pytest-local/lib/python3.9/site-packages/pypsa/components.py:701: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
    new_df = cls_df.append(obj_df, sort=False)

-- Docs: https://docs.pytest.org/en/stable/warnings.html

Testing

Run tox successfully

Where to look

Several modules are concerned. No major refactoring, only converting set to list, etc. The largest change is using get_indexer() in place of get_loc().

Usage Example/Visuals

N/A

Time estimate

5 min

@rouille rouille added the refactor Code that is being refactored label Mar 28, 2022
@rouille rouille self-assigned this Mar 28, 2022
@BainanXia
Copy link
Collaborator

What happens with the linter?

@jenhagg
Copy link
Collaborator

jenhagg commented Mar 28, 2022

What happens with the linter?

It's installing a newer version of click which it seems black isn't compatible with. Aaaand it's fixed by black 20 minutes ago https://github.com/psf/black/releases/tag/22.3.0

Copy link
Collaborator

@BainanXia BainanXia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code that is being refactored
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants