Skip to content

BUG: Fix np.quantile([Fraction(2,1)], 0.5) (#24711)#25756

Merged
charris merged 1 commit intonumpy:maintenance/1.26.xfrom
charris:backport-24711
Feb 3, 2024
Merged

BUG: Fix np.quantile([Fraction(2,1)], 0.5) (#24711)#25756
charris merged 1 commit intonumpy:maintenance/1.26.xfrom
charris:backport-24711

Conversation

@charris
Copy link
Copy Markdown
Member

@charris charris commented Feb 3, 2024

Backport of #24711.

On main:

import numpy as np
from fractions import Fraction
arr = np.array([Fraction(1, 1), Fraction(2, 1), Fraction(3, 1)])
np.quantile(arr, 0) # output: Fraction(1, 1)
np.quantile(arr, Fraction(1, 2)) # output: Fraction(2, 1)
np.quantile(arr, 0.5) # raises an error

In this PR we update the np.quantile to handle the case np.quantile(arr, 0.5) as well.

Also see #24592

  • BUG: Fix np.quantile([Fraction(2,1)], 0.5)

  • address review comments

  • pass type instead of dtype instance

* BUG: Fix np.quantile([Fraction(2,1)], 0.5)

* address review comments

* pass type instead of dtype instance
@charris charris added this to the 1.26.4 release milestone Feb 3, 2024
@charris charris merged commit ce89a0a into numpy:maintenance/1.26.x Feb 3, 2024
@charris charris deleted the backport-24711 branch February 3, 2024 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants