Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
FIX: Handle uint8 indices properly for colormap lookups#24970
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -715,16 +715,17 @@ def __call__(self, X, alpha=None, bytes=False): | ||
| if not xa.dtype.isnative: | ||
| xa = xa.byteswap().newbyteorder() # Native byteorder is faster. | ||
| if xa.dtype.kind == "f": | ||
| xa *= self.N | ||
| # Negative values are out of range, but astype(int) would | ||
| # truncate them towards zero. | ||
| xa[xa < 0] = -1 | ||
| # xa == 1 (== N after multiplication) is not out of range. | ||
| xa[xa == self.N] = self.N - 1 | ||
| # Avoid converting large positive values to negative integers. | ||
| np.clip(xa, -1, self.N, out=xa) | ||
| with np.errstate(invalid="ignore"): | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Is the errstate even still needed? AFAICT casting nan to int doesn't trigger an "invalid" error. ContributorAuthor
| ||
| # We need this cast for unsigned ints as well as floats | ||
| xa = xa.astype(int) | ||
| # Set the over-range indices before the under-range; | ||
| # otherwise the under-range values get converted to over-range. | ||
| xa[xa > self.N - 1] = self._i_over | ||