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

Fix map_array_container on non-ArrayContainers #90

Merged
merged 2 commits into from
Sep 22, 2021

Conversation

alexfikl
Copy link
Collaborator

@alexfikl alexfikl commented Sep 21, 2021

map_array_container was using try ... except to check if an object is serializable, but it was only catching TypeError, not NotImplementedError thrown by serialize_container. That basically made it try to deserialize floats and other non-array container objects.

The try ... except was introduced in #31, seemingly for some performance reasons (?), so I went ahead and used the same pattern in several other places.

@thomasgibson as this is (now, vaguely) related to inducer/grudge#154.

arraycontext/container/traversal.py Outdated Show resolved Hide resolved
Comment on lines 268 to 270
except NotImplementedError:
raise ValueError(
f"Non-array container type has no key: {type(ary).__name__}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we may want to distinguish between ValueError and NotImplementedError. Also, I'm not sure if we necessarily need to catch exceptions if we do proper error handling further down

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not quite sure I follow what the suggestion is. Can you elaborate a bit? This code should be the same as before, it just uses try .. except instead of is_array_container.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@alexfikl I think the discussion in this thread #90 (comment) settles this!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it! 😁

Thanks a lot for taking a look and sparking a discussion! Always appreciated!

@inducer
Copy link
Owner

inducer commented Sep 22, 2021

LGTM! I'll go ahead and merge, since I don't think there are any total dealbreakers in here. If there are lingering concerns (@thomasgibson?), please bump them to an issue.

@inducer inducer enabled auto-merge (rebase) September 22, 2021 22:01
@inducer inducer merged commit ac8d9d2 into inducer:main Sep 22, 2021
@alexfikl alexfikl deleted the map-container-scalars branch September 22, 2021 23:04
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.

3 participants