BUG: ensure YTSlice.coord has units#5000
Merged
jzuhone merged 1 commit intoyt-project:mainfrom Sep 25, 2024
Merged
Conversation
Member
|
random github markdown tip of the day: Traceback (most recent call last):
File "/Users/chavlin/.pyenv/versions/yt_dev/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3548, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-76bca84cf85c>", line 6, in <module>
print(frb["gas", "density"])
File "/Users/chavlin/src/yt_/yt_dev/yt/yt/visualization/fixed_resolution.py", line 209, in __getitem__
return self.get_image(item)
File "/Users/chavlin/src/yt_/yt_dev/yt/yt/visualization/fixed_resolution.py", line 213, in get_image
self._generate_image_and_mask(key)
File "/Users/chavlin/src/yt_/yt_dev/yt/yt/visualization/fixed_resolution.py", line 179, in _generate_image_and_mask
buff, mask = self.ds.coordinates.pixelize(
File "/Users/chavlin/src/yt_/yt_dev/yt/yt/geometry/coordinates/cartesian_coordinates.py", line 238, in pixelize
buff, mask = self._ortho_pixelize(
File "/Users/chavlin/src/yt_/yt_dev/yt/yt/geometry/coordinates/cartesian_coordinates.py", line 554, in _ortho_pixelize
data_source.coord.to("code_length").v,
AttributeError: 'float' object has no attribute 'to' |
neutrinoceros
approved these changes
Sep 24, 2024
Member
neutrinoceros
left a comment
There was a problem hiding this comment.
This looks fine to me unfortunately it seems I cannot compile yt these days (I assume because I'm being too aggressive with upgrading my system dependencies), so I'm not able to verify that your test captures the problem. Nonetheless it seems trivial enough that I can approve to give you the option of self-merging here.
| """Validates if the passed argument is a float value. | ||
|
|
||
| Raises an exception if `obj` is a single float value | ||
| Raises an exception if `obj` is not a single float value |
Contributor
Author
It's not a critical fix, so I'll let it hang out for now and self merge at the end of the day if no one else jumps in. |
jzuhone
approved these changes
Sep 25, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Found that for sph data, calling
ds.slice(axis, center).to_frb(...)[field]would error if thecenterargument was a plain float. For other dataset types (and other data objects), a plain float is assumed to be in units ofcode_length. Easiest fix is to ensure thatYTSlice.coordattribute is a unyt object, following the other data objects.Here's the stack trace from the error on main:
PR Checklist
[ ] New features are documented, with docstrings and narrative docsN/A