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 bug with trap id is None #810

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

KulaginVladimir
Copy link
Collaborator

Proposed changes

This is the fix for #804.

Also, several tests were updated, since the missing ids are now assigned during Simulation.initialise().

Types of changes

What types of changes does your code introduce to FESTIM?

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactoring
  • Documentation Update (if none of the other choices apply)
  • 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
  • I have added necessary documentation (if appropriate)

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.55%. Comparing base (02f79ad) to head (ed00bf0).
Report is 114 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #810   +/-   ##
=======================================
  Coverage   99.55%   99.55%           
=======================================
  Files          61       61           
  Lines        2705     2707    +2     
=======================================
+ Hits         2693     2695    +2     
  Misses         12       12           

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

@KulaginVladimir KulaginVladimir added the bug Something isn't working label Jul 11, 2024
@KulaginVladimir KulaginVladimir linked an issue Jul 11, 2024 that may be closed by this pull request
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!

It's a bit annoying that we have to add id= to all these tests... We'll probably have to sit down and discuss a proper implementation for this.

The only reason why we need id for traps are for exports, boundary conditions, sources. Right?

my_bc = DirichletBC(value=2, field=1)

But we could do something similar to what we do on the fenicsx branch:

my_trap = F.Trap(....)

my_export = F.TotalVolume(..., field=my_trap)

@KulaginVladimir
Copy link
Collaborator Author

I agree.

However, I think that keeping ids to use for traps is fine, but they shouldn't be available for the users. I mean that trap.id should be a unique attribute related to the actual index of a trap in the traps list. For an easier access to specific traps, I suppose other attributes (like trap label or tag) or approaches (as you mentioned above) would be better.

@RemDelaporteMathurin
Copy link
Collaborator

I mean that trap.id should be a unique attribute related to the actual index of a trap in the traps list.

In that case you don't need to have .id as an attribute of the trap itself since you can just do self.traps.index(trap) to have the index of a specific trap.

the id attribute as an int is just used for creating the functionspace, and here we can just do

for id, trap in enumerate(self.traps, 1):

Just like we already do in this new method

@KulaginVladimir
Copy link
Collaborator Author

oh, yes. I just meant that, personally, I find convinient to define export for (and then access) traps with their ids. Though it might be a matter of taste.

@RemDelaporteMathurin
Copy link
Collaborator

oh, yes. I just meant that, personally, I find convinient to define export for (and then access) traps with their ids. Though it might be a matter of taste.

Right, so i think we need to make a different between the index of the traps in the list (only used for constructing the function space) and the tag/name of the trap that is a user-friendly way of referring to it.

We can have users refer to a trap in for example exports by either using the actual trap object, or its name, or its index in the trap list.
We remove the id as a user-defined argument and just have it for convenience as an attribute (maybe).
Then we simply have to forbid users to use digits-only names.

Anyway we can merge this PR and ship the discussion elswehere

@KulaginVladimir KulaginVladimir merged commit 84e7861 into festim-dev:main Jul 12, 2024
6 checks passed
@KulaginVladimir KulaginVladimir deleted the traps-ids-bug branch July 26, 2024 19: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.

[BUG] trap id is None if append is used
2 participants