Repository navigation
Fix metadata schemas on assert_equals - #3246
Conversation
e3e6854 to
5ecaec1
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3246 +/- ##
==========================================
- Coverage 89.61% 89.60% -0.01%
==========================================
Files 28 28
Lines 31983 31987 +4
Branches 5888 5890 +2
==========================================
+ Hits 28660 28663 +3
Misses 1888 1888
- Partials 1435 1436 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
jeromekelleher
left a comment
There was a problem hiding this comment.
Logic makes sense, but tests seem dodgy?
|
|
||
| def test_degenerate_metadata_schema(self, table_5row): | ||
| if hasattr(table_5row, "metadata_schema"): | ||
| table_5row.clear() |
There was a problem hiding this comment.
Not sure we should be mutating the global fixture here? Better to copy first then clear?
Also, why are we checking if the fixture has a metadata_schema?
There was a problem hiding this comment.
The default scope for a fixture is function so each test gets a fresh instance.
We're checking for the schema as this test suite is run against all tables, which includes ProvenanceTable.
| t1.assert_equals(t2, ignore_reference_sequence=True) | ||
|
|
||
| def test_degenerate_metadata_schema(self, t1, t2): | ||
| t1._ll_object.metadata_schema = ( |
There was a problem hiding this comment.
Likewise on mutating parameters?
There was a problem hiding this comment.
Again, the instance is per-test.
jeromekelleher
left a comment
There was a problem hiding this comment.
LGTM, thanks for clarifications!
| # differ when the decoded schema is the same | ||
| if ( | ||
| not ignore_metadata | ||
| and self.ll_table.metadata_schema != other.ll_table.metadata_schema |
There was a problem hiding this comment.
I know it has this above but just to make it totally clear that this is exactly what we're testing for here
| and self.ll_table.metadata_schema != other.ll_table.metadata_schema | |
| and self.metadata_schema == other.metadata_schema | |
| and self.ll_table.metadata_schema != other.ll_table.metadata_schema |
| # differ when the decoded schema is the same | ||
| if ( | ||
| not ignore_metadata | ||
| and self._ll_object.metadata_schema != other._ll_object.metadata_schema |
There was a problem hiding this comment.
| and self._ll_object.metadata_schema != other._ll_object.metadata_schema | |
| and self.metadata_schema == other.metadata_schema | |
| and self._ll_object.metadata_schema != other._ll_object.metadata_schema |
There was a problem hiding this comment.
Hm, interesting - I was going to go the more pedantic route of having assert_equals fail if the bytes were different. I guess this is better; however, it means that the C function and the python function do different things, so that should be documented on the C side?
Edit: However, if you agree that #3249 is a bug, then probably we should go the other route and make the python agree with the C code.
|
I think the C and Python do differ here. Ideally, the C code would know that two JSON strings are equivalent, but we don't want to bring JSON parsing code into the C library, so it has to make a comprimise of comparing at the byte level. I think changing the Python to be pedantic isn't actually helpful to the user as the byte-level difference has no meaning to any of the tskit code. |
5ecaec1 to
6aaaa8a
Compare
6aaaa8a to
559837c
Compare
Fixes #3244