Skip to content

Conversation

@benjeffery
Copy link
Member

Fixes #2063

@benjeffery benjeffery force-pushed the refseq_eq branch 2 times, most recently from 3a5408b to 3054a47 Compare January 10, 2022 14:05
@benjeffery benjeffery marked this pull request as ready for review January 10, 2022 14:05
@codecov
Copy link

codecov bot commented Jan 10, 2022

Codecov Report

Merging #2085 (e0409d2) into main (295a92d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2085   +/-   ##
=======================================
  Coverage   93.38%   93.39%           
=======================================
  Files          27       27           
  Lines       25561    25569    +8     
  Branches     1159     1159           
=======================================
+ Hits        23870    23879    +9     
  Misses       1660     1660           
+ Partials       31       30    -1     
Flag Coverage Δ
c-tests 92.38% <ø> (ø)
lwt-tests 89.05% <ø> (ø)
python-c-tests 72.13% <25.00%> (-0.03%) ⬇️
python-tests 98.89% <100.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
python/tskit/tables.py 98.88% <100.00%> (+0.11%) ⬆️

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 295a92d...e0409d2. Read the comment docs.

Copy link
Member

@jeromekelleher jeromekelleher left a comment

Choose a reason for hiding this comment

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

Looks good, a few comments.

What do we do with the relationship between assert_equals and equals elsewhere?


class TestAssertEquals:
class TestEquals:
def test_success_self(self, ts_fixture):
Copy link
Member

Choose a reason for hiding this comment

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

I guess we should rename the rest of the methods here to reflect the change in the class name. "success" doesn't make sense any more.

("metadata_schema", tskit.MetadataSchema(None)),
],
)
def test_fails_different(self, ts_fixture, attr, val):
Copy link
Member

Choose a reason for hiding this comment

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

This test doesn't really make sense any more - it doesn't "fail" now because we're not doing asserts. It's also too complicated IMO - we should be aiming to "test one thing" in these tests, and that one thing should be reflected in the name.

So, I think it'd be better if we split this into two tests, one for different_not_equal and different_but_ignore or something? As a rule, I think doing parametrize and using ifs on the values should be an anti-pattern.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

def nbytes(self) -> int:
return len(self._ll_object.metadata) + len(self._ll_object.metadata_schema)

def equals(self, other):
Copy link
Member

Choose a reason for hiding this comment

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

Might as well include the -> bool annotation

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

def nbytes(self) -> int:
return len(self._ll_object.metadata) + len(self._ll_object.metadata_schema)

def equals(self, other):
Copy link
Member

Choose a reason for hiding this comment

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

Should we use

try:
    self.assert_equals(...)
    return True
except AssertionError:
    return False

here so that we're not defining equality twice? I think we've done that elsewhere in non-performance critical cases?

def __eq__(self, other):
return self.equals(other)

def equals(self, other, ignore_metadata=False, ignore_url=False):
Copy link
Member

Choose a reason for hiding this comment

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

What's the motivation for ignore_url here? I don't think there's much point in adding this in yet if we don't have a specific application because we might end up having to row-back on it when we do start using the URL field.

Copy link
Member Author

Choose a reason for hiding this comment

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

As it is similar to metadata a put it in, but yeah makes sense to wait till we work out what it is doing.

@benjeffery
Copy link
Member Author

What do we do with the relationship between assert_equals and equals elsewhere?

In almost all the others we are calling a low-level method in equals. Where we don't I think you're right that it makes sense to call assert_equals.

@benjeffery
Copy link
Member Author

@jeromekelleher comments addressed! Thanks.

Copy link
Member

@jeromekelleher jeromekelleher left a comment

Choose a reason for hiding this comment

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

LGTM! One thing to clear up before merging.

def nbytes(self) -> int:
return len(self._ll_object.metadata) + len(self._ll_object.metadata_schema)

def equals(self, other) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we're not calling this any more -simplest to just delete it I guess?

@mergify mergify bot merged commit 747df7f into tskit-dev:main Jan 11, 2022
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.

Implement __eq__ for ReferenceSequence

2 participants