Skip to content

Conversation

@larsevj
Copy link
Collaborator

@larsevj larsevj commented Sep 4, 2025

Should fix the following warnings from the tests:

  /opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/site-packages/subscript/summaryplot/summaryplot.py:452: 
MatplotlibDeprecationWarning: The plot_date function was deprecated in Matplotlib 3.9 and will be removed in 3.11. 
Use plot instead.
    pyplot.plot_date(firstsummary.dates, values, "k.", label=sumlabel)
  /opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/site-packages/subscript/fmuobs/writers.py:299: 
FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed in a future version. 
To retain the old behavior, explicitly call `result.infer_objects(copy=False)`. 
To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
    .replace(["NaT", "NaN", "nan"], np.nan)

@codecov-commenter
Copy link

codecov-commenter commented Sep 4, 2025

Codecov Report

❌ Patch coverage is 84.37500% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.16%. Comparing base (a199b2e) to head (701e4f4).

Files with missing lines Patch % Lines
src/subscript/summaryplot/summaryplot.py 82.75% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #806   +/-   ##
=======================================
  Coverage   85.16%   85.16%           
=======================================
  Files          49       49           
  Lines        7544     7544           
=======================================
  Hits         6425     6425           
  Misses       1119     1119           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@larsevj larsevj force-pushed the fix_warnings branch 3 times, most recently from 5c39c35 to 1906fcb Compare September 8, 2025 12:41
@larsevj larsevj marked this pull request as draft September 8, 2025 12:47
@larsevj larsevj force-pushed the fix_warnings branch 3 times, most recently from 3343cd0 to 29bd051 Compare September 8, 2025 13:26
@larsevj larsevj force-pushed the fix_warnings branch 3 times, most recently from 22bc552 to 559e20c Compare September 8, 2025 14:10
- Fixes:
"FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed in a future version.
To retain the old behavior, explicitly call `result.infer_objects(copy=False)`.
To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
    .replace(["NaT", "NaN", "nan"], np.nan)"
@larsevj larsevj marked this pull request as ready for review September 10, 2025 07:45
@larsevj larsevj requested a review from a team September 10, 2025 07:49
@rnyb rnyb requested a review from Copilot September 10, 2025 08:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes deprecation warnings from matplotlib and pandas in the test suite by updating deprecated function calls to their modern equivalents.

  • Replaces deprecated matplotlib.pyplot.plot_date() with plt.plot() throughout the summaryplot module
  • Updates pandas replace() usage to suppress future downcasting warnings with explicit options
  • Adds test infrastructure for matplotlib image comparison testing

Reviewed Changes

Copilot reviewed 7 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_summaryplot.py Adds matplotlib image comparison test function and imports
tests/test_ofmvol2csv.py Suppresses pandas date parsing warnings in test
src/subscript/summaryplot/summaryplot.py Replaces deprecated matplotlib functions and standardizes pyplot imports
src/subscript/fmuobs/writers.py Updates pandas replace() to use explicit downcasting options
pyproject.toml Adds pytest-mpl dependency for matplotlib testing
.github/workflows/subscript.yml Updates CI to use uv package manager and enable matplotlib tests
.github/workflows/codecov.yml Updates CI to use uv package manager
Comments suppressed due to low confidence (1)

src/subscript/summaryplot/summaryplot.py:490

  • [nitpick] The format string parameter should be passed as fmt keyword argument for clarity when other keyword arguments are present. Consider changing line 485 to fmt=\"-\", to maintain consistency with matplotlib's API conventions.
                plt.plot(
                    summaryfile.dates,
                    values,
                    "-",
                    color=cycledcolor,
                    label=sumlabel,
                    linewidth=1.5,
                    alpha=alpha,
                )

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rnyb
Copy link
Collaborator

rnyb commented Sep 10, 2025

Not sure if it is an irrelevant question , but should we consider using webp instead of png for figures? Or maybe that is not possible for usage in tests?

@larsevj
Copy link
Collaborator Author

larsevj commented Sep 10, 2025

Not sure if it is an irrelevant question , but should we consider using webp instead of png for figures? Or maybe that is not possible for usage in tests?

I suspect that pytest-mpl only supports the png format. If one prefers to not commit the image files, then they do support hash-checking instead https://pytest-mpl.readthedocs.io/en/stable/hash_mode.html , but this will make it a bit more difficult to visually compare the results.

@rnyb
Copy link
Collaborator

rnyb commented Sep 10, 2025

Not sure if it is an irrelevant question , but should we consider using webp instead of png for figures? Or maybe that is not possible for usage in tests?

I suspect that pytest-mpl only supports the png format. If one prefers to not commit the image files, then they do support hash-checking instead https://pytest-mpl.readthedocs.io/en/stable/hash_mode.html , but this will make it a bit more difficult to visually compare the results.

Let's keep it as is then.

Copy link
Collaborator

@rnyb rnyb left a comment

Choose a reason for hiding this comment

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

LGTM

@larsevj larsevj merged commit 809fd41 into main Sep 10, 2025
4 checks passed
@larsevj larsevj deleted the fix_warnings branch October 3, 2025 08:53
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.

4 participants