-
Notifications
You must be signed in to change notification settings - Fork 21
switch to numpy>=2
#716
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
base: main
Are you sure you want to change the base?
switch to numpy>=2
#716
Conversation
|
@copilot why is |
…ger (#721) * Initial plan * Fix numpy>=2 compatibility in cdoTimeAverager - Add explicit float64 dtype casting for time_bnds arrays - Replace Python sum() with np.sum() with explicit dtype parameter - Ensures consistent numerical results across numpy 1.x and 2.x - Addresses issue #711 regarding CDO producing different answers with numpy>=2 NumPy 2.0 changed type promotion rules (NEP 50), which can cause subtle numerical differences. This fix ensures consistent dtype handling by: 1. Explicitly casting time_bnds to float64 after reading from NetCDF 2. Using np.sum() with dtype=np.float64 instead of Python's sum() All CDO-related tests pass with these changes. Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com> * Optimize moveaxis operation in cdoTimeAverager - Store result of np.moveaxis to avoid redundant computation - Fix trailing whitespace issue - Improves performance by eliminating duplicate transpose operation Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com> * Remove redundant copy operations in cdoTimeAverager - Remove unnecessary [:].copy() calls on array slices - Subtraction operation already creates a new array - Further improves performance while maintaining correctness Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com> * Update pull_request branch filter to '**' * Update pull_request trigger branch filter * Remove main branch trigger from build_conda workflow Remove 'main' branch trigger from pull request events. * Fix numpy>=2 compatibility in frepytoolsTimeAverager - Add explicit float64 dtype casting for time_bnds arrays - Replace Python sum() with numpy.sum() with explicit dtype parameter - Optimize moveaxis operation to avoid redundant computation - Ensures consistent numerical results across numpy 1.x and 2.x The frepytools answer was indeed changing with numpy>=2 due to the same type promotion issues as CDO. This fix ensures both CDO and frepytools produce consistent results. Fixes the test_compare_unwgt_fre_cli_to_unwgt_cdo test failure. Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com> * Improve comments in frepytoolsTimeAverager - Consolidate multi-line comment to be more concise - Remove redundant comment - Code review feedback addressed Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
|
@copilot prototype a matrix approach for the pipeline scanning python version(s) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #716 +/- ##
==========================================
+ Coverage 82.76% 82.77% +0.01%
==========================================
Files 68 68
Lines 4525 4529 +4
==========================================
+ Hits 3745 3749 +4
Misses 780 780
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
#722) * Initial plan * Add matrix testing strategy for Python and numpy versions Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com> * Simplify matrix to Python versions only, make Python 3.14 non-blocking Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com> * Update conda environment workflow to exclude Python 3.14 Removed Python 3.14 from the testing matrix and related checks. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
|
not that i think it's 100% necessary, but backwards compatibility with |
numpy v2 compatibility, fixes for NEP 50 type promotion changes. nothing too wild.
what this does
numpy==1.26.4→numpy>=2inenvironment.ymlandmeta.yamlcdoTimeAverager,frepytoolsTimeAverager) caused by numpy 2.0's new type promotion rulesfloat64dtype casting and replaces Python'ssum()withnumpy.sum()for consistent results across numpy versionsPython :: 3.11classifier frompyproject.tomlbuild_condaandcreate_test_conda_envTLDR
copilot agent helped with the heavy lifting on the time averager fixes (#721, #722). the core change is straightforward - just switching the numpy pin - but NEP 50 broke some subtle numerical behavior that needed explicit dtype handling to preserve consistent answers.