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

[bugfix] fix io chunking for chained cut regions #2234

Merged
merged 3 commits into from Apr 11, 2019

Conversation

brittonsmith
Copy link
Member

@brittonsmith brittonsmith commented Apr 10, 2019

PR Summary

This closes Issue #2233.

When chained cut regions do io chunking, only the conditionals of the last cut region are applied. Conditionals from parent cut regions are ignored. This only shows up when calculating derived quantities.

The solution implemented here changes how cut regions derived from other cut regions are initialized. Instead of creating a chain of objects that rely on each's parent, we add the conditionals from the parent cut region and create the new one from the parent's base object. Anecdotally, this also appears to speed up field access as we're only applying conditionals once.

PR Checklist

  • Code passes flake8 checker
  • Adds a test for any bugs fixed. Adds tests for new features.

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.

minor initialization order change

if isinstance(data_source, YTCutRegion):
self.__init__(
data_source.base_object,
data_source.conditionals + conditionals,
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 ensure_list(conditionals) needs to happen before this

Copy link
Member Author

Choose a reason for hiding this comment

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

Totally right!

if isinstance(data_source, YTCutRegion):
self.__init__(
data_source.base_object,
data_source.conditionals + conditionals,
Copy link
Member

Choose a reason for hiding this comment

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

Calling __init__ inside of __init__ is a little weird to me. Is it possible to set data_source and conditionals in this if block and then set up the instance using the existing logic below?

Also I realize this is how it is already, but a straightforward cleanup would be to deprecate (with a visible warning) passing base_object in and to call the attribute data_source instead of base_object.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this can probably be simplified like that. I'll give it a go.

@ngoldbaum ngoldbaum merged commit 542a03c into yt-project:master Apr 11, 2019
@brittonsmith brittonsmith deleted the chainofbools branch April 11, 2019 03:19
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

Successfully merging this pull request may close these issues.

None yet

3 participants