Skip to content

fixes deprecation warning - #697

Open
tomjemmett wants to merge 3 commits into
mainfrom
fix_deprecation_warning
Open

tomjemmett wants to merge 3 commits into
mainfrom
fix_deprecation_warning

Conversation

@tomjemmett

Copy link
Copy Markdown
Member

copy argument is deprectated in pandas 3.0

copy argument is deprectated in pandas 3.0
@tomjemmett
tomjemmett requested a review from a team as a code owner October 16, 2026 09:36
Copilot AI balanced review requested due to automatic review settings October 16, 2026 09:36
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6409eed) to head (8323164).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #697   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines         1216      1216           
  Branches        61        61           
=========================================
  Hits          1216      1216           

☔ View full report in Codecov by Harness.
📢 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.

@github-actions

Copy link
Copy Markdown

✅ A new build is available.

You can use the following to use pull the image into your local environment:

docker pull ghcr.io/the-strategy-unit/nhp_model:pr-697

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The newly added test converts between differing dtypes, so it always copies regardless of the copy argument and therefore fails to guard the intended behavior change, and it carries an unused mocker fixture.

1 open finding
What changed in this PR

This PR removes the deprecated copy=False keyword argument from .astype() calls across the model package. In pandas 3.0 the copy argument to astype is deprecated (Copy-on-Write makes it a no-op), so dropping it silences the deprecation warning while preserving behavior (the default copy=True is equally safe, and all dtype-changing conversions allocate new arrays anyway). A new unit test is added to document the non-mutation assumption.

Changes:

  • Removed copy=False from .astype() calls in model, inpatients, outpatients, aae, activity_resampling, results, and run modules.
  • Simplified a test fixture to build the array via np.array(..., dtype=np.float64) instead of .astype(..., copy=False).
  • Added test_pandas_astype_copies_to_prevent_mutation asserting the original Series is not mutated after astype.
File Description
tests/​unit/​nhp/​model/​test_activity_resampling.py Simplifies fixture dtype construction; adds a new test for astype non-mutation (test does not actually exercise the copy=False removal).
src/​nhp/​model/​run.py Drops copy=False from the pandas DataFrame astype used when printing step counts.
src/​nhp/​model/​results.py Drops copy=False from the SDEC patch value column cast.
src/​nhp/​model/​outpatients.py Drops copy=False from the NumPy counts cast.
src/​nhp/​model/​model.py Drops copy=False from several NumPy/pandas casts (years, merge cols, sampling).
src/​nhp/​model/​inpatients.py Drops copy=False from counts/sampling/LOSR casts while preserving np.int32 for speldur.
src/​nhp/​model/​activity_resampling.py Drops copy=False from the merged factor cast.
src/​nhp/​model/​aae.py Drops copy=False from the arrivals counts cast.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/unit/nhp/model/test_activity_resampling.py Outdated
was added by copilot, isn't useful

This branch has not been deployed

No deployments
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.

2 participants