-
-
Notifications
You must be signed in to change notification settings - Fork 9
Collapse testsets #77
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2c7d29f
Update error messages in fixtures
cmcaine 154e5a9
Add fixtures to test collapsing behaviour
cmcaine c3b5396
Report fewer results
cmcaine a7b986f
Report test_code for passing tests
cmcaine 1dc0d4e
Test that number of reported failures is limited
cmcaine 748f9f3
Revert "Update error messages in fixtures"
cmcaine 07df7d2
CI and dev tests now ignore all but first line of error messages
cmcaine 201bc23
Copy extra files in CI
cmcaine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import Base: ==, +, -, *, /, abs, conj, exp, imag, real, zero, promote_rule | ||
|
|
||
| struct ComplexNumber{T <: Real} <: Number | ||
| a::T | ||
| b::T | ||
| end | ||
|
|
||
| function ComplexNumber(a::T, b::U) where {T <: Real, U <: Real} | ||
| V = promote_type(T, U) | ||
| ComplexNumber{V}(V(a), V(b)) | ||
| end | ||
|
|
||
| # This makes isapprox work and is needed for Bonus 2. | ||
| ComplexNumber{T}(a::Real) where T = ComplexNumber{T}(T(a), zero(T)) | ||
|
|
||
| # Convert ComplexNumber{U} to ComplexNumber{T}, required for Bonus 2. | ||
| ComplexNumber{T}(a::ComplexNumber) where T = ComplexNumber{T}(T(a.a), T(a.b)) | ||
|
|
||
| # You can make isapprox work without defining the constructor above if you | ||
| # define zero and real | ||
| zero(::Type{ComplexNumber{T}}) where T = ComplexNumber(zero(T), zero(T)) | ||
| zero(x::ComplexNumber{T}) where T = ComplexNumber(zero(T), zero(T)) | ||
|
|
||
| real(::Type{ComplexNumber{T}}) where T = T | ||
| real(x::ComplexNumber) = x.a | ||
|
|
||
| imag(::Type{ComplexNumber{T}}) where T = T | ||
| imag(x::ComplexNumber) = x.b | ||
|
|
||
| # Default structural equality method uses ===, but we will often contain | ||
| # floats, which must be compared with == | ||
| ==(x::ComplexNumber, y::ComplexNumber) = x.a == y.a && x.b == y.b | ||
|
|
||
| conj(x::ComplexNumber) = ComplexNumber(x.a, -x.b) | ||
| abs(x::ComplexNumber) = sqrt(x.a * x.a + x.b * x.b) | ||
|
|
||
| -(x::ComplexNumber) = ComplexNumber(-x.a, -x.b) | ||
| +(x::ComplexNumber, y::ComplexNumber) = ComplexNumber(x.a + y.a, x.b + y.b) | ||
| -(x::ComplexNumber, y::ComplexNumber) = x + -y | ||
|
|
||
| *(x::ComplexNumber, y::ComplexNumber) = ComplexNumber(x.a * y.a - x.b * y.b, | ||
| x.b * y.a + x.a * y.b) | ||
|
|
||
| /(x::ComplexNumber, y::ComplexNumber) = ComplexNumber((x.a * y.a + x.b * y.b) / (y.a^2 + y.b^2), | ||
| (x.b * y.a - x.a * y.b) / (y.a^2 + y.b^2)) | ||
|
|
||
| # Bonus 1: exp | ||
|
|
||
| # Promotion rule makes mixed Real/Complex mathematical operations work | ||
|
|
||
| # Commenting this out makes some of the tests fail, which is useful for testing the test runner :) | ||
| # promote_rule(::Type{T}, ::Type{ComplexNumber{U}}) where {T <: Real, U} = ComplexNumber{promote_type(T, U)} | ||
| exp(x::ComplexNumber) = ℯ^x.a * ComplexNumber(cos(x.b), sin(x.b)) | ||
|
|
||
| # Bonus 2: jm unit | ||
|
|
||
| # Better to use false here because we need that strong multiplicative zero | ||
| # to make `0 + NaN * jm === ComplexNumber(0, NaN)` | ||
| const jm = ComplexNumber(false, true) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, this only affects CI, not the end result on the website?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it affects a local run of the tests with pkg, too. But in any case, doesn't affect the website. Just got tired of the fixtures changing because of path differences and so on.