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

Avoid inplace sort of input of lmom_ratios #18

Merged
merged 2 commits into from
Jul 25, 2024
Merged

Avoid inplace sort of input of lmom_ratios #18

merged 2 commits into from
Jul 25, 2024

Conversation

aulemahal
Copy link
Contributor

  • lmoments3.lmom_ratios was applying in-place sorting to its input (x.sort()), changed it to copy : x = np.sort(x).
  • Modified defaults of LmomDistrMixin.lmom_fit to avoid [].
  • Added an assert in lmom_ratios test.

Fixes #15 and OpenHydrology/lmoments3#2.

The issue only happens when np.asarray(x, dtype=np.float64) encounters an object it does not need to cast as an array, i.e. an array of dtype float64. In all other cases there's an implicit copy.

@aulemahal aulemahal requested a review from Zeitsperre July 25, 2024 15:04
Copy link
Contributor

@Zeitsperre Zeitsperre left a comment

Choose a reason for hiding this comment

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

Ah yes, the dangers of initializing variables in the call signature. LGTM

@aulemahal aulemahal merged commit e3f8de3 into main Jul 25, 2024
7 checks passed
@aulemahal aulemahal deleted the fix-15 branch July 25, 2024 17:18
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.

lmom_fit changes original data sorting it
2 participants