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

Fix Scalar and Endpoint equality #56

Merged
merged 2 commits into from
Oct 25, 2018
Merged

Fix Scalar and Endpoint equality #56

merged 2 commits into from
Oct 25, 2018

Conversation

fchorney
Copy link
Member

This fixes the "==" issue in #54
Also adds the Left/Right consts.

  • Added == functions for (left,left), (right,right), (scalar,left),
    (scalar, right), (left, scalar), (right, scalar)
  • Added isequal functions for (left,left) and (right,right)
  • Changed some functions to not be repetitions of previous code such as
    Left == Right code will just call Right == Left instead of redefining
    the same code within both functions.
  • Added First = Left, and Last = Right shortcuts.
  • Added some more Scalar tests because why not

- Added == functions for (left,left), (right,right), (scalar,left),
(scalar, right), (left, scalar), (right, scalar)
- Added isequal functions for (left,left) and (right,right)
- Changed some functions to not be repetitions of previous code such as
Left == Right code will just call Right == Left instead of redefining
the same code within both functions.
- Added First = Left, and Last = Right shortcuts.
- Added some more Scalar tests because why not
@fchorney fchorney requested a review from omus as a code owner October 25, 2018 18:15
src/endpoint.jl Outdated
function Base.:(==)(a::RightEndpoint, b::RightEndpoint)
a.endpoint == b.endpoint && a.included == b.included
end

Copy link
Collaborator

Choose a reason for hiding this comment

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

Both of these are covered by falling back to Base.:(==)(a::Endpoint, b::Endpoint)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thats what I wanted to assume, but I was getting these weird issues where it seemed like it wasnt. Perhaps I was somewhat misunderstanding what I was doing. Tests definitely seem to run fine without them as they are falling back as you mentioned.

src/endpoint.jl Outdated
end

function Base.:(==)(a::RightEndpoint, b)
b == a
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can just use Endpoint here:

function Base.:(==)(a, b::Endpoint)
    a == b.endpoint && b.included
end

function Base.:(==)(a::Endpoint, b)
    b == a
end

I assume the one-liner versions of these look out of place?

Copy link
Collaborator

Choose a reason for hiding this comment

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

These should probably be moved to the end with the isless(::Any, ::Endpoint) definitions. Since the logic behind scalar-endpoint and endpoint-endpoint comparisons is rather different I think it makes sense to group by this way instead of by operator.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, that makes sense. I suppose some of these could be one liners, but then the question is if we want it to be consistently long versions for the entire thing, or mixed, or make them all one liners. Some are little long though

src/endpoint.jl Outdated

function Base.isequal(a::RightEndpoint, b::RightEndpoint)
isequal(a.endpoint, b.endpoint) && isequal(a.included, b.included)
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fall back covers this

src/endpoint.jl Outdated
@@ -6,6 +6,8 @@ const Right = Direction{:Right}()
const Beginning = Left
const Ending = Right

const First = Left
const Last = Right
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would save this for another PR.

@codecov
Copy link

codecov bot commented Oct 25, 2018

Codecov Report

Merging #56 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #56      +/-   ##
==========================================
+ Coverage   98.26%   98.27%   +0.01%     
==========================================
  Files           6        6              
  Lines         230      232       +2     
==========================================
+ Hits          226      228       +2     
  Misses          4        4
Impacted Files Coverage Δ
src/endpoint.jl 100% <100%> (ø) ⬆️

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 6f5b07a...5ac0cf5. Read the comment docs.

- Potentially had some weird environment thing where it seemed like some
comparisons weren't falling back to their Endpoint versions. Possibly I
was doing something weird as the tests all work fine without those extra
comparison functions I made.
- Moved all the scalar comparison functions to the bottom of the file,
and made them all one liners as they are all relatively small.
- Removed the First/Last thing as it isn't really needed for this PR.
@omus omus merged commit e6711a0 into master Oct 25, 2018
@omus omus deleted the fc/fix-endpoint-coparisons branch October 25, 2018 21:31
@omus omus mentioned this pull request Oct 29, 2018
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.

2 participants