Skip to content

Ensure that with_ works for all immutable objects#694

Merged
sdrave merged 30 commits intomasterfrom
ensure_with
May 31, 2019
Merged

Ensure that with_ works for all immutable objects#694
sdrave merged 30 commits intomasterfrom
ensure_with

Conversation

@sdrave
Copy link
Member

@sdrave sdrave commented May 29, 2019

This rather large PR adds some code to ImmutableMeta.__call__ which checks if all __init__ arguments of an immutable class are available as attributes of the generated object. This is necessary for with_ to work correctly.

All other commits in this PR fix various classes for which this condition is not satisfied. In some cases some attributes are renamed (from _foo to foo) and many missing attributes are added. Some refactoring happened along the way:

  • UnstructuredTriangleGrid now has a factory method from_vertices which will be usually used to instantiate the grid.
  • GmshGrid has been removed. Instead an UnstructuredTriangleGrid is instantiated directly.
  • BoundaryInfoFromIndicators is now GenericBoundaryInfo with a from_indicators factory method.
  • GmshBoundaryInfo has been removed. Instead, GenericBoundaryInfo is used.
  • SubgridBoundaryInfo has been removed. Instead, GenericBoundaryInfo is used.

One main motivation for #549 was to ensure that with_ always works. Since dataclasses do not really seem to work for us, this PR can be seen as a step towards a similar goal. (Another PR will follow to get rid of some of the boilerplate code in __init__.)

sdrave added 28 commits May 29, 2019 10:48
 _domain, _num_intervals, _identify_left_right -> domain, num_intervals, identify_left_right
_mapping, _adjoint_mapping -> mapping, adjoint_mapping
…_ args

and add parent_entities attribute to make with_ work
…aryInfo

The refactored class is more flexible to use an compatible with with_.
and use generic classes instead.
@sdrave sdrave added this to the 2019.2 milestone May 29, 2019
@sdrave sdrave requested review from pmli and renefritze May 29, 2019 14:29
@sdrave sdrave mentioned this pull request May 29, 2019
@sdrave sdrave merged commit 8ac6c56 into master May 31, 2019
@sdrave sdrave deleted the ensure_with branch May 31, 2019 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants