Skip to content

Conversation

ddundo
Copy link
Member

@ddundo ddundo commented Mar 14, 2025

The CI in #291 fails since meshes are now iterable (not our change). So in this PR I just changed isinstance(meshes, Iterable) to isinstance(meshes, list).

This will anyway get refactored in #239 to always require a list of meshes, since

if not isinstance(meshes, Iterable):
    meshes = [Mesh(meshes) for subinterval in self.subintervals]

will not be possible to do since MeshSeq will be completely separated from TimePartitions, so there won't be a self.subintervals attribute anymore.

@ddundo ddundo marked this pull request as ready for review March 14, 2025 13:55
@ddundo ddundo requested a review from jwallwork23 March 14, 2025 13:55
@ddundo ddundo self-assigned this Mar 14, 2025
@ddundo ddundo added the bug Something isn't working label Mar 14, 2025
Copy link
Member

@jwallwork23 jwallwork23 left a comment

Choose a reason for hiding this comment

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

Thanks for spotting this. I have a suggestion.

"""
# TODO #122: Refactor to use the set method
if not isinstance(meshes, Iterable):
if not isinstance(meshes, list):
Copy link
Member

Choose a reason for hiding this comment

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

How about we allow tuple to cover more possible cases?

Suggested change
if not isinstance(meshes, list):
if not isinstance(meshes, (list, tuple)):

Copy link
Member Author

@ddundo ddundo Mar 18, 2025

Choose a reason for hiding this comment

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

I committed this but I'm not sure we should allow tuples. In adaptor functions in demos we have mesh_seq[i] = adapt(mesh_seq[i], metric), so we need a mutable object to be able to reassign meshes, right?

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 tested this and we indeed get an error:

  File "/home/firedrake/goalie/demos/burgers-hessian.py", line 145, in adaptor
    mesh_seq[i] = adapt(mesh_seq[i], metric)
    ~~~~~~~~^^^
  File "/home/firedrake/goalie/goalie/mesh_seq.py", line 130, in __setitem__
    self.meshes[subinterval] = mesh
    ~~~~~~~~~~~^^^^^^^^^^^^^
TypeError: 'tuple' object does not support item assignment

So I reverted this. Am I missing something? Sorry if I am!

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes, I always forget about this. Thanks.

@ddundo ddundo force-pushed the fix_iterable_mesh branch from f23b790 to 90ae934 Compare March 18, 2025 19:13
@ddundo ddundo requested a review from jwallwork23 March 18, 2025 19:28
@ddundo
Copy link
Member Author

ddundo commented Mar 18, 2025

Thanks @jwallwork23. Please see the comment. Also had to fix a new linting error

if len(adjoint_error.keys()) != 1:
raise ValueError("Inconsistent input for 'adjoint_error' and 'test_space'.")
test_space = {key: test_space for key in adjoint_error}
test_space = dict.fromkeys(adjoint_error, test_space)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for fixing this. I spotted it in the weekly CI outputs but hadn't got round to it.

"""
# TODO #122: Refactor to use the set method
if not isinstance(meshes, Iterable):
if not isinstance(meshes, list):
Copy link
Member

Choose a reason for hiding this comment

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

Ah yes, I always forget about this. Thanks.

@ddundo ddundo merged commit 6796a6c into pip_install_docker Mar 19, 2025
1 check passed
@ddundo ddundo deleted the fix_iterable_mesh branch March 19, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants