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

BUG: fix a crash with certain combinations of kwargs for adding dimensionless derived fields to datasets #4638

Merged

Conversation

neutrinoceros
Copy link
Member

@neutrinoceros neutrinoceros commented Aug 19, 2023

close #4636
Opening as a draft with just the tests, patch incoming.

@neutrinoceros neutrinoceros added bug api-consistency naming conventions, code deduplication, informative error messages, code smells... labels Aug 19, 2023
@neutrinoceros neutrinoceros added this to the 4.2.2 milestone Aug 19, 2023
@neutrinoceros neutrinoceros force-pushed the hotfix_dimensionless_field branch 2 times, most recently from f94e701 to 509041a Compare August 19, 2023 17:59
@neutrinoceros neutrinoceros marked this pull request as ready for review August 19, 2023 18:58
@neutrinoceros neutrinoceros force-pushed the hotfix_dimensionless_field branch from 509041a to 8866d24 Compare August 20, 2023 16:16
@neutrinoceros neutrinoceros force-pushed the hotfix_dimensionless_field branch from 8866d24 to 46025f2 Compare August 20, 2023 16:35
@@ -266,7 +277,7 @@ def _generate_fields(self, fields_to_generate):
fi.name,
sunits or "dimensionless",
)
elif fi.dimensions != dimensions:
elif not dimensions_compare_equal(fi.dimensions, dimensions):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the right thing to do. However, I will note that there's the possibility that this will add on a non-negligible amount of time to dataset instantiation during field detection. I think that is unlikely, but it is a possibility.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep it in mind.
I also want to note that field detection is time-consuming already: in tests that create a small dataset and immediately throw it away, it's adds a couple hundreds ms to each test. I think it'd be a good idea to make it lazy in the future.

@neutrinoceros neutrinoceros merged commit 484d63a into yt-project:main Aug 22, 2023
@neutrinoceros neutrinoceros deleted the hotfix_dimensionless_field branch August 22, 2023 17:51
meeseeksmachine pushed a commit to meeseeksmachine/yt that referenced this pull request Aug 22, 2023
…ns of kwargs for adding dimensionless derived fields to datasets
@matthewturk
Copy link
Member

I've thought about this, and I can't yet convince myself that losing the full list of available fields is the right trade-off.

@neutrinoceros
Copy link
Member Author

Who said anything about loosing it ? What I'm suggesting is just to only evaluate it when and if requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-consistency naming conventions, code deduplication, informative error messages, code smells... bug units
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 is not treated as dimensionless
3 participants