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: add support for setting up derived fields from lambdas #3440

Merged

Conversation

neutrinoceros
Copy link
Member

PR Summary

This is an alternative fix to #3434, and supersedes #3438.
The solution tried here was suggested by @forrestglines. It's not clear to me why the problematic check was ever necessary but it's
been here for 8yrs so my hypothesis is that it may have become inappropriate in Python 3 ?
I'm doubting this would break anything since there doesn't seem to be a single use case of lambdas in derived fields in the code base/docs/tests. On the other hand, the test I'm adding here fails on the main branch (as reported in #3434).

@neutrinoceros neutrinoceros added bug api-consistency naming conventions, code deduplication, informative error messages, code smells... labels Jul 15, 2021
@neutrinoceros neutrinoceros linked an issue Jul 15, 2021 that may be closed by this pull request
@neutrinoceros neutrinoceros marked this pull request as ready for review July 15, 2021 23:27
Copy link
Member

@matthewturk matthewturk left a comment

Choose a reason for hiding this comment

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

I think this is good.

@@ -250,10 +250,7 @@ def get_dependencies(self, *args, **kwargs):
This returns a list of names of fields that this field depends on.
"""
e = FieldDetector(*args, **kwargs)
if self._function.__name__ == "<lambda>":
Copy link
Member

Choose a reason for hiding this comment

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

So I've done some thinking, and I think this comes from waaaay back in the day when we may have used lambdas to represent on-disk fields.

@neutrinoceros
Copy link
Member Author

Thanks Matt, now I'm much more confident in calling this a plain bug fix :)

@neutrinoceros
Copy link
Member Author

@jzuhone , @matthewturk , anyone in particular that you would like to take a look a this too or is it good for merging ?

@matthewturk matthewturk merged commit c5f6641 into yt-project:main Jul 18, 2021
@neutrinoceros neutrinoceros deleted the derived_fields_from_lambda branch July 18, 2021 16:05
@neutrinoceros neutrinoceros mentioned this pull request Oct 12, 2021
42 tasks
@matthewturk
Copy link
Member

@meeseeksdev backport to yt-4.0.x

meeseeksmachine pushed a commit to meeseeksmachine/yt that referenced this pull request Oct 15, 2021
neutrinoceros added a commit that referenced this pull request Oct 16, 2021
…0-on-yt-4.0.x

Backport PR #3440 on branch yt-4.0.x (FIX: add support for setting up derived fields from lambdas)
@neutrinoceros neutrinoceros changed the title FIX: add support for setting up derived fields from lambdas BUG: add support for setting up derived fields from lambdas Jan 20, 2022
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating derived fields with lambda functions
3 participants