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

:extrema fails if all values are equal #43

Closed
SimonWoods opened this issue Sep 14, 2020 · 2 comments
Closed

:extrema fails if all values are equal #43

SimonWoods opened this issue Sep 14, 2020 · 2 comments

Comments

@SimonWoods
Copy link

If all array values are equal, using get with the :extrema option gives an error.

get(colorschemes[:sunset], fill(0.3,20,20), :extrema)

ERROR: InexactError: trunc(Int64, NaN)

It would be nice if this edge case was handled.

@cormullion
Copy link
Member

Hi Simon (I remember your amazing contributions to the Mathematica Stack Exchange?)...

Looks like the problem is with remap here

so:

remap(x, 0.3, 0.3, 1, 10)
2-element Array{Float64,1}:
 NaN
 NaN

I suppose it could be fixed by inserting

iszero(first(rangescale) - last(rangescale)) && error("Empty rangescale: $(rangescale)")

at the start of that function, without too much of a penalty...

@SimonWoods
Copy link
Author

Hi Cormullion, yes that's me. I haven't been active there for a while, most of my hobby programming is in Julia these days.

I'd argue for get to still return an image (albeit a boring one) when the array values are all equal. Maybe use the midpoint of the colour scheme?

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

No branches or pull requests

2 participants