Skip to content

More unit test improvements #73

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

Merged
merged 36 commits into from
Sep 21, 2024
Merged

More unit test improvements #73

merged 36 commits into from
Sep 21, 2024

Conversation

mikeingold
Copy link
Collaborator

@mikeingold mikeingold commented Sep 16, 2024

Complete

  • Added new style of tests for Ring, Rope, Segment
  • Added tests to improve code coverage from 84% to 91%
  • Added tests where argument FP is Float32 or BigFloat, discovered issues leading to:

Future Work (Other PR's)

  • Add a method for manual tracking of which combinations of integral argument types have tests implemented
  • Re-consider whether argument FP should be a kwarg, i.e. integral(f, geometry, settings; FP=BigFloat)

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.93%. Comparing base (8813827) to head (9a4a23e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #73      +/-   ##
==========================================
+ Coverage   83.85%   90.93%   +7.08%     
==========================================
  Files           7        7              
  Lines         353      353              
==========================================
+ Hits          296      321      +25     
+ Misses         57       32      -25     

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

@mikeingold mikeingold marked this pull request as ready for review September 20, 2024 16:52
@mikeingold
Copy link
Collaborator Author

@JoshuaLampert do you have time for a review?

@JoshuaLampert
Copy link
Member

Not right now, but tomorrow I should find a couple of minutes.

Copy link
Member

@JoshuaLampert JoshuaLampert left a comment

Choose a reason for hiding this comment

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

Looks mostly good to me. I left some minor comments and questions below.
I see a lot of commits in the PR, which indicates to me that you don't run the tests locally (?). While that's of course totally fine, it might still be more convenient and probably faster to run the tests during development locally, such that CI doesn't need to be triggered each time again to get some response. To make this more convenient we could think about integrating tests with TestItems.jl and TestItemRunner.jl, which can be used to run only certain test items locally individually without needing to run the whole test workflow (this assumes you develop within VSCode). This makes the development of tests much easier and faster. Meshes.jl integrated this recently and I also played around with it recently. I really like the workflow and can recommend it. If you agree that this is also worth implementing in MeshIntegrals.jl, I can also set up a PR for that. Now that I finished writing this, I just saw you also mention TestItems.jl in #67 😅

mikeingold and others added 2 commits September 20, 2024 16:34
Co-authored-by: Joshua Lampert <[email protected]>
Co-authored-by: Joshua Lampert <[email protected]>
@mikeingold
Copy link
Collaborator Author

I see a lot of commits in the PR, which indicates to me that you don't run the tests locally (?). While that's of course totally fine, it might still be more convenient and probably faster to run the tests during development locally, such that CI doesn't need to be triggered each time again to get some response.

I try not to dev this way, but I've been away from my workstation a lot lately and had to push these commits from GitHub's browser file editor 😅.

If you agree that this is also worth implementing in MeshIntegrals.jl, I can also set up a PR for that. Now that I finished writing this, I just saw you also mention TestItems.jl in #67 😅

I'm definitely interested in implementing TestItems.jl soon but was planning to get all of the tests updated first. At some point earlier this year I came up with a scheme for trying to generate @tests on all valid combinations {integral function name, integrand output type, Meshes.Geometry sub-type, IntegrationAlgorithm}. It sounded like a good idea in principle, and provided a big boost in test coverage at a time, but: it relies on Meshes.measure as a benchmark, only covers cases with unit integrand (p -> one(T)), tends to bloat the test run-times with some potentially-redundant coverage, and tended to slightly obscure what actually went wrong when a test might fail. My plan has been to transition toward a style of tests more like what Meshes uses, i.e. modular blocks of concrete tests with analytic solutions.

One of the things I am conflicted about conceptually, though, is how to manage true test coverage this way. For example, pretty much any individual call of the form integral(f, geometry, ::HAdaptiveCubature) now relies on the same method, so one applicable @test is enough to satisfy CodeCov for it. The note in the Future Work block above references a thought I had to manually populate some kind of table-like data structure, with entries in each appropriate @testset to indicate which combinations are exercised. It isn't the most elegant solution, though, so I'm all ears if you have other ideas.

@mikeingold
Copy link
Collaborator Author

mikeingold commented Sep 20, 2024

I've noticed periodic issues where the macOS CI alone will error and it's usually something odd not related to the actual package, so I was about to re-run the failing test, but I noticed that this one has a really odd error being thrown seemingly out of Meshes.

This function (inside another function in utils.jl) generates a parametric call (::Ball{3})(rho, theta, phi)

https://github.com/mikeingold/MeshIntegrals.jl/blob/8349dbc64a42712ef151d929337c65ec5e07a848/src/utils.jl#L29-L35

which at this line in Meshes.jl for some reason generates an error trying to convert to an Int

https://github.com/JuliaGeometry/Meshes.jl/blob/c8b2b936808a2b0810bf1c0130a077deb2a10d3c/src/geometries/primitives/ball.jl#L62C3-L62C30

Edit: just pinged Julio on Zulip

@JoshuaLampert
Copy link
Member

I've seen this error already before in a completely different context here (also only on Mac):
JoshuaLampert/DispersiveShallowWater.jl/actions/runs/10811172112/job/29990016675?pr=150#step:7:8511
This is indeed very weird, but not related to anything we should worry too much about, I think.

@JoshuaLampert
Copy link
Member

I'm definitely interested in implementing TestItems.jl soon but was planning to get all of the tests updated first.

I see, but I think having TestItems.jl running might make the development of the new tests more convenient. Thus, I would think implementing TestItems.jl first and updating the remaining tests after that might be worth considering (assuming, of course, that you use your workstation in future PRs again because otherwise TestItems.jl doesn't make anything more convenient 😅).

@mikeingold
Copy link
Collaborator Author

I've seen this error already before in a completely different context here (also only on Mac): JoshuaLampert/DispersiveShallowWater.jl/actions/runs/10811172112/job/29990016675?pr=150#step:7:8511 This is indeed very weird, but not related to anything we should worry too much about, I think.

Interesting. I wonder if this is some obscure bug in Base. Looks like your example triggers here.

https://github.com/JuliaLang/julia/blob/911e02558d0c145a192facd28808b68e157aa5af/base/special/trig.jl#L841

@mikeingold
Copy link
Collaborator Author

I'm definitely interested in implementing TestItems.jl soon but was planning to get all of the tests updated first.

I see, but I think having TestItems.jl running might make the development of the new tests more convenient. Thus, I would think implementing TestItems.jl first and updating the remaining tests after that might be worth considering (assuming, of course, that you use your workstation in future PRs again because otherwise TestItems.jl doesn't make anything more convenient 😅).

That was just the order-of-events I was planning to work personally. If you're up for implementing TestItems once this PR is merged, I'm all for it.

@mikeingold
Copy link
Collaborator Author

I think all reviews have now been addressed. Let me know if I'm missing anything.

@JoshuaLampert
Copy link
Member

Interesting. I wonder if this is some obscure bug in Base. Looks like your example triggers here.

JuliaLang/julia@911e025/base/special/trig.jl#L841

Yes, might be.

@JoshuaLampert
Copy link
Member

LGTM!

@JoshuaLampert JoshuaLampert merged commit 4e517fc into main Sep 21, 2024
13 checks passed
@JoshuaLampert JoshuaLampert deleted the more-tests branch September 21, 2024 20:10
mikeingold added a commit that referenced this pull request Sep 22, 2024
* Add new tests for Segment

* Bump patch version

* Add test verbose and showtimings

* Complete TODO action

* Add tests for alternate FP types

* Fix typo and add more alt FP test coverage

* Fix typo

* Bugfix

* Bugfix - missing N for Gauss-Legendre rules

* Bugfix - missing unit exponents

* Mark type tests broken, named f32, increase GL rule N

* Fix typo

* Reduce N for GL rules, add looser atol's for F32 results

* Tweak tolerances

* Split tests into new set [skip ci]

* Implement new tests for Rope

* Bugfix

* Math correction

* Add new tests for Ring

* Bugfixes

* Bugfix

* Remove Ring from old tests

* Bugfix

* Reorganize alt FP tests

* Fix atol value, abstract testset with a loop

* Remove unnecessary begin

* Abstract FP type, split aliases into separate set

* Update types

* Add BigFloat tests

* Conditional broken statement

* Enhance integral docstring, add sub-FP64 warning

* Improved argument explanation



* Drop an explicit showtimings



* Remove redundant showtimings

* Add a type-dependent atol

* Add note about BigFloat

---------

Co-authored-by: Joshua Lampert <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants