Skip to content

Broadening the unit tests#37

Merged
michaeldenes merged 16 commits intomainfrom
adding_new_tests
Jun 7, 2024
Merged

Broadening the unit tests#37
michaeldenes merged 16 commits intomainfrom
adding_new_tests

Conversation

@michaeldenes
Copy link
Member

This PR is to include unit tests for all of the functions in the constructors, and tests for all of the kernels.

@codecov-commenter
Copy link

codecov-commenter commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.14%. Comparing base (c9deffc) to head (7e8006b).

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #37       +/-   ##
===========================================
+ Coverage   15.43%   66.14%   +50.70%     
===========================================
  Files           6        8        +2     
  Lines         473      700      +227     
===========================================
+ Hits           73      463      +390     
+ Misses        400      237      -163     
Flag Coverage Δ
unit-tests 66.14% <100.00%> (+50.70%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Member

@erikvansebille erikvansebille left a comment

Choose a reason for hiding this comment

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

Great set of unit tests! See below some comments

def test_advection_only(use_3D):
settings_file = 'tests/test_data/test_settings.json'
settings = pp.utils.load_settings(settings_file)
settings = pp.utils.download_plasticparcels_dataset('NEMO0083', settings, 'input_data')
Copy link
Member

Choose a reason for hiding this comment

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

Why is this call to download_plasticparcels_dataset needed, if the NEMO-data are not used? See also in the other examples

Copy link
Member Author

Choose a reason for hiding this comment

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

In some of the test functions this can be removed, but in the cases where Stokes/Wind is used (and kernels = pp.constructors.create_kernel(...)), then the unbeaching kernel is included in that list. I'll remove this call to download_plasticparcels_dataset for the cases where the unbeaching kernel is not invoked.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I've just realised, we use it in the make_standard_particleset call, which creates the particleset used to test the advection.
I thought this would be easier, since the particleset requires a number of variables used by the different kernels. So I can't remove this from each of the tests without writing a new function for particleset creation.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, in the spirit of modularisation it may then be better to split it up into different functions at some point? Perhaps in a later PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, a class for PlasticParticle would be a cleaner approach, so that users can still use the parcels.ParticleSet.from_list() approach, with their own release locations.

@michaeldenes michaeldenes marked this pull request as ready for review June 7, 2024 07:22
@michaeldenes michaeldenes merged commit 5269406 into main Jun 7, 2024
@michaeldenes michaeldenes deleted the adding_new_tests branch June 7, 2024 11:07
michaeldenes added a commit that referenced this pull request Jun 7, 2024
Merge pull request #37 from OceanParcels/adding_new_tests
@michaeldenes michaeldenes mentioned this pull request Dec 4, 2024
fanqi203 pushed a commit to fanqi203/plasticparcels that referenced this pull request Jul 8, 2025
fanqi203 pushed a commit to fanqi203/plasticparcels that referenced this pull request Jul 8, 2025
Merge pull request Parcels-code#37 from OceanParcels/adding_new_tests
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.

3 participants