IAMconsortium / pyam

Analysis & visualization of energy & climate scenarios
https://pyam-iamc.readthedocs.io/
Apache License 2.0
236 stars 120 forks source link

replacing deprecated in1d, using ravel for scalars #882

Open quant12345 opened 1 month ago

quant12345 commented 1 month ago

Please confirm that this PR has done the following:

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.in1dis 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.]]
codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.