Skip to content

Conversation

@hhy2022
Copy link
Contributor

@hhy2022 hhy2022 commented Nov 17, 2025

Proposed changes

Fix Profile1DExport storing identical profiles by appending view instead of copy

This PR fixes a bug in Profile1DExport where profile data were stored as views of the same underlying array rather than independent copies. As a result, all exported profiles at different timesteps ended up containing identical values, which corresponding to the last computed timestep, regardless of the requested export times.

This bug was discussed in Issue #1046
Fixes #1046.

Types of changes

What types of changes does your code introduce to FESTIM?

  • Bugfix (non-breaking change which fixes an issue)
  • New tests

Checklist

  • Black formatted
  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works

Further comments

This fix is small but crucial for all workflows relying on Profile1DExport, including:

  • Transient diffusion problems
  • Post-processing using stored spatial profiles
  • Validation tasks requiring comparison between profiles at different times

@RemDelaporteMathurin
Copy link
Collaborator

@hhy2022 there seem to be some conflicts with your PR. Let me know if you need help resolving them

Copy link
Collaborator

@RemDelaporteMathurin RemDelaporteMathurin 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 this quick fix @hhy2022 !

You need to resolve the conflicts with the fenicsx branch and then make sure your test is 1) really testing something and catching the bug (ie. failing without your fix, with an assert) 2) encapsulated inside a python function

Copy link
Collaborator

Choose a reason for hiding this comment

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

Tests need to be inside functions:

def test_profile1dexport():
    ...
    ...
    assert profile.data[1] != profile.data[0]

@hhy2022
Copy link
Contributor Author

hhy2022 commented Nov 17, 2025

Thanks for this quick fix @hhy2022 !

You need to resolve the conflicts with the fenicsx branch and then make sure your test is 1) really testing something and catching the bug (ie. failing without your fix, with an assert) 2) encapsulated inside a python function

Thank you for your guidance. This issue first appeared when I was working with the v2.0-beta release for the V-V book. I updated to the latest fenicsx branch and confirmed that the issue has already been fixed.
I will try to use the latest version from the fenicsx branch in V-V report.

@hhy2022 hhy2022 closed this Nov 17, 2025
@hhy2022 hhy2022 deleted the fix-profile1Dexport-copy-bug branch November 17, 2025 18:25
@hhy2022 hhy2022 restored the fix-profile1Dexport-copy-bug branch November 17, 2025 18:27
@hhy2022 hhy2022 reopened this Nov 17, 2025
@hhy2022
Copy link
Contributor Author

hhy2022 commented Nov 18, 2025

Closing since it was fixed by #1042

@hhy2022 hhy2022 closed this Nov 18, 2025
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.

[BUG]FESTIM v2.0b Profile1DExport stores identical profiles at different times (missing .copy(), always appending the same array view)

3 participants