Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Glasscat tests #152

Merged
merged 16 commits into from
May 5, 2021
Merged

Glasscat tests #152

merged 16 commits into from
May 5, 2021

Conversation

alfredclwong
Copy link
Collaborator

@alfredclwong alfredclwong commented Apr 28, 2021

Improve GlassCat test coverage and introduce wrappedalloc macro to avoid issues with counting allocations in global scope.

@alfredclwong alfredclwong self-assigned this Apr 28, 2021
@codecov-commenter
Copy link

codecov-commenter commented Apr 28, 2021

Codecov Report

Merging #152 (9f2a7d5) into main (e0204ee) will increase coverage by 2.59%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #152      +/-   ##
==========================================
+ Coverage   53.66%   56.25%   +2.59%     
==========================================
  Files          66       66              
  Lines        6472     6332     -140     
==========================================
+ Hits         3473     3562      +89     
+ Misses       2999     2770     -229     
Impacted Files Coverage Δ
src/GlassCat/GlassCat.jl 100.00% <ø> (ø)
src/GlassCat/GlassTypes.jl 43.33% <ø> (+34.46%) ⬆️
src/Optical/OpticalSystem.jl 35.89% <0.00%> (-0.33%) ⬇️
src/GlassCat/runtime.jl 100.00% <0.00%> (ø)
src/GlassCat/utilities.jl 64.90% <0.00%> (+0.95%) ⬆️
src/GlassCat/Air.jl 100.00% <0.00%> (+55.55%) ⬆️
src/GlassCat/search.jl 100.00% <0.00%> (+100.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0204ee...9f2a7d5. Read the comment docs.

@alfredclwong alfredclwong added the testing Adding missing tests or correcting existing tests label Apr 28, 2021
@@ -338,170 +338,3 @@ function info(io::IO, glass::Glass)
end

info(g::AbstractGlass) = info(stdout, g)

Copy link
Contributor

Choose a reason for hiding this comment

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

is the docstring function being permanently deleted or did you just move it somewhere? Even though we're not using it much now it seems to be functioning ok. Other people might find it useful for making tools to analyze glasses. Is it necessary to remove it?

Copy link
Collaborator Author

@alfredclwong alfredclwong Apr 29, 2021

Choose a reason for hiding this comment

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

I took it out because it seemed like duplicate code (I can't remember where from), it was unused, and it was lowering our test coverage.


Just had a look and it seems to be essentially the same as info() above but without the padding. We should really have a third function to handle the data extraction such that info() and docstring() only need to handle the string formatting.

The other thing that confused me was that we weren't even using docstring() to generate the docstrings for GlassCat - we had an abbreviated version seen in generate.jl > glassinfo_to_docstring. This is essentially a triple duplicate - what do you think we should keep?

Copy link
Collaborator

@friggog friggog Apr 29, 2021

Choose a reason for hiding this comment

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

Just had a look and it seems to be essentially the same as info() above but without the padding

This is basically what it did - just printed the same stuff as info with correct formatting for documentation generation - I don't see much need for it if we don't have glass docs any more.

I think glass catalog jl files get written with short form information for tooltips in VS Code, this function was used specifically for long form information for use in generation of the documentation website

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@BrianGun you can have the final say - if you want to keep the code then feel free to git revert d3197a2

@alfredclwong alfredclwong marked this pull request as ready for review April 30, 2021 09:54
@alfredclwong alfredclwong changed the title [WIP] Glasscat tests Glasscat tests Apr 30, 2021
@alfredclwong alfredclwong requested a review from BrianGun April 30, 2021 12:13
test/testsets/GlassCat.jl Show resolved Hide resolved
test/testsets/GlassCat.jl Outdated Show resolved Hide resolved
test/testsets/GlassCat.jl Show resolved Hide resolved

# TODO @test glassnames()

# !! TODO !! for some reason uncommenting this test causes the alloc tests at L145-146 to fail
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is super weird... Have you tried defining it differently? e.g. define a separate filter function

Copy link
Collaborator Author

@alfredclwong alfredclwong May 4, 2021

Choose a reason for hiding this comment

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

i'll try that out this morning as well as anything else i can think of.

edit: i doubt changing the filter function will do anything - x -> false still causes failures. i'm now trying to comment out bits of findglass to see if that's causing the issue

might be worth asking for outside help with this one. @BrianGun have you got any ideas?

Copy link
Collaborator Author

@alfredclwong alfredclwong May 4, 2021

Choose a reason for hiding this comment

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

After some digging i've found that the issue is caused by calling a function which takes another function as an argument, such as function findglass(condition::Function). Even if findglass does absolutely nothing, this still causes the issue.

We need to fix the allocations test call to run within a local scope to avoid allocations from accessing variables. https://discourse.julialang.org/t/using-allocated-to-track-memory-allocations/4617/5

I'll add the wrappedallocs macro from https://github.com/JuliaAlgebra/TypedPolynomials.jl/blob/master/test/runtests.jl to our runtests.jl. We should use this to preemptively "fix" any other benchmarks we are running.

@alfredclwong alfredclwong enabled auto-merge (squash) May 5, 2021 11:13
@alfredclwong alfredclwong requested a review from friggog May 5, 2021 11:57
@alfredclwong
Copy link
Collaborator Author

@BrianGun I think these changes are ready for approval, if you're happy with them. The wrapped allocations fix is worth a read for future reference.

@alfredclwong alfredclwong merged commit bdefffe into main May 5, 2021
@alfredclwong alfredclwong deleted the glasscat-tests branch May 5, 2021 16:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
testing Adding missing tests or correcting existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants