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

F.Traps and F.DerivedQuantities -> subclasses of list #697

Conversation

KulaginVladimir
Copy link
Collaborator

@KulaginVladimir KulaginVladimir commented Feb 4, 2024

Proposed changes

This PR modifies F.Traps and F.DerivedQuantities to be subclasses of list following #494.

An attempt was made to add a check that:

  • a list is passed to F.Materials / F.Exports / F.Traps / F.DerivedQuantities
  • the passed list contains F.Material / F.Export / F.Trap / F.DerivedQuantity

Additionally, a .materials / .exports / .traps / .derived_quantities property is temporarly added to F.Materials / F.Exports / F.Traps / F.DerivedQuantities to minimize a breaking change, as privately discussed with @RemDelaporteMathurin.

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 Feb 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a484d8d) 99.44% compared to head (0d68ce5) 99.47%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #697      +/-   ##
==========================================
+ Coverage   99.44%   99.47%   +0.02%     
==========================================
  Files          58       58              
  Lines        2176     2280     +104     
==========================================
+ Hits         2164     2268     +104     
  Misses         12       12              

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

@KulaginVladimir KulaginVladimir marked this pull request as ready for review February 4, 2024 09:58
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.

@KulaginVladimir thanks for this! almost there!

I'm just realising that having the property for .traps (for instance) doesn't break the api if users do:

print(my_traps.traps[2])

but users can't do

my_traps.traps.append(...)

Can you please add a setter/getter in addition to the @Property please?

festim/concentration/traps/traps.py Outdated Show resolved Hide resolved
festim/concentration/traps/traps.py Outdated Show resolved Hide resolved
festim/concentration/traps/traps.py Outdated Show resolved Hide resolved
festim/exports/derived_quantities/derived_quantities.py Outdated Show resolved Hide resolved
festim/materials/materials.py Outdated Show resolved Hide resolved
test/unit/test_exports/test_exports.py Outdated Show resolved Hide resolved
test/unit/test_materials.py Show resolved Hide resolved
festim/exports/exports.py Outdated Show resolved Hide resolved
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 @KulaginVladimir the code is much cleaner now!

@RemDelaporteMathurin RemDelaporteMathurin merged commit 49d18e8 into festim-dev:main Feb 6, 2024
5 checks passed
@KulaginVladimir KulaginVladimir deleted the DerQuant_list-and-Traps_list branch February 8, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Materials, Exports, DerivedQuantities, ... should be a subclass of list
2 participants