yt-project / yt

Main yt repository
http://yt-project.org
Other
454 stars 272 forks source link

Incorrect parameter sanitation to np.logspace #4928

Closed yohad closed 3 weeks ago

yohad commented 3 weeks ago

Bug report

Bug summary

In function b2t in frontends/art/io.py, the call to np.logspace passes the third argument without validating it is an integer.

Code for reproduction When loading my database I get n=100.0 when trying to load ("stars", "particle_creation_time")

Version Information

installed yt from conda-forge

welcome[bot] commented 3 weeks ago

Hi, and welcome to yt! Thanks for opening your first issue. We have an issue template that helps us to gather relevant information to help diagnosing and fixing the issue.

neutrinoceros commented 3 weeks ago

Thanks for reporting ! Indeed, np.logspace's third argument doesn't accept float values, which means the default value we use in the following function is broken

https://github.com/yt-project/yt/blob/e9ba8aca6c262085afc7926541881136bd4c426c/yt/frontends/art/io.py#L630-L638

There are a couple ways we can address this, but there's precedent in just converting to int on the fly in this situation in the very same module: https://github.com/yt-project/yt/blob/e9ba8aca6c262085afc7926541881136bd4c426c/yt/frontends/art/io.py#L592

So I'll open a PR to do just that.