Skip to content

Conversation

@EdCaunt
Copy link
Contributor

@EdCaunt EdCaunt commented Aug 6, 2024

No description provided.

@EdCaunt EdCaunt requested a review from FabioLuporini August 6, 2024 13:37
# If dimensions have been replaced, then it is necessary to set `function`
# to None. It is also necessary to remove halo and padding kwargs so that
# they are rebuilt with the new dimensions
if function is not None and function.dimensions != dimensions:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sorry but no we cannot allow that it doesn't matter if it's for internals, this need to go through a __new__ not _rebuild

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But _rebuild() is a __new__ with some extra convenience around it?

@codecov
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.04%. Comparing base (f923ebe) to head (74ed7a6).
Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2438      +/-   ##
==========================================
+ Coverage   87.02%   87.04%   +0.01%     
==========================================
  Files         236      237       +1     
  Lines       44938    44998      +60     
  Branches     8369     8372       +3     
==========================================
+ Hits        39107    39167      +60     
  Misses       5102     5102              
  Partials      729      729              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mloubout mloubout added the API api (symbolics, types, ...) label Aug 9, 2024

# Don't want to reinitialise array if DataReference used as allocator;
# create a no-op intialiser to avoid overwriting the original array.
if isinstance(self._allocator, DataReference):
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be made part of the if-elif-else cascade below?

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, several branches in the cascade use initialiser which means it needs to be set here to avoid code duplication. Keeping it here also results in more readable code.

assert np.all(f.data_with_halo == g.data_with_halo)
# Check that it was incremented by two
check += 2
assert np.all(f.data == check)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why you need that "check" array you always know analytical result.
set np.arange to some constant and just check np.all(f.data, a + n)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can do that, but it's just more code for the same result. The halo isn't updated, so either you need to skip numbers, or just add to the centre of the array. Either way, it's more code whilst making it less immediately understandable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also the amount of skipping changes depending on the MPI config, since there will be different halos


# Don't want to reinitialise array if DataReference used as allocator;
# create a no-op intialiser to avoid overwriting the original array.
if isinstance(self._allocator, DataReference):
Copy link
Contributor

Choose a reason for hiding this comment

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

agreed

@mloubout mloubout merged commit 40b081e into master Aug 21, 2024
@mloubout mloubout deleted the func_rebuild branch August 21, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API api (symbolics, types, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants