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

replacing deprecated in1d, using ravel for scalars #882

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

quant12345
Copy link
Contributor

@quant12345 quant12345 commented Oct 8, 2024

Please confirm that this PR has done the following:

  • Tests Added
  • Documentation Added
  • Name of contributors Added to AUTHORS.rst
  • Description in RELEASE_NOTES.md Added

Description of PR

Removes the warnings:

D:\a\pyam\pyam\pyam\plotting.py:230: DeprecationWarning: `in1d` is deprecated. Use `np.isin` instead.
    overlap_idx = np.in1d(values, list(PYAM_COLORS.keys()))

tests to check isin:
pytest tests/test_plotting.py::test_line_plot_cmap_color_arg
pytest tests/test_plotting.py::test_line_color
pytest tests/test_plotting.py::test_line_PYAM_COLORS
pytest tests/test_plotting.py::test_line_color_fill_between
pytest tests/test_plotting.py::test_line_color_fill_between_interpolate
pytest tests/test_plotting.py::test_line_color_final_ranges
pytest tests/test_plotting.py::test_line_filter_title
pytest tests/test_plotting.py::test_line_update_rc
pytest tests/test_plotting.py::test_scatter_variables_with_meta_color

  D:\a\pyam\pyam\pyam\timeseries.py:133: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    return [y + 1 for y in map(int, years)]
tests to check scalar:
pytest tests/test_timeseries.py::test_cross_treshold
pytest tests/test_timeseries.py::test_cross_treshold_from_below
pytest tests/test_timeseries.py::test_cross_treshold_from_above
  1. np.in1d is replaced by np.isin.

  2. To get scalar values ​​during iteration I made the years array flat having applied ravel().
    The years values ​​have an extra dimension, which is why there is a warning:

[[2006.]
 [2010.]]

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.0%. Comparing base (ddbb88e) to head (71ab0e8).
Report is 33 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #882   +/-   ##
=====================================
  Coverage   95.0%   95.0%           
=====================================
  Files         64      64           
  Lines       6134    6216   +82     
=====================================
+ Hits        5828    5910   +82     
  Misses       306     306           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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