Skip to content

Conversation

@benjeffery
Copy link
Member

@benjeffery benjeffery commented Nov 12, 2021

WIP - Looking into this I think we just do it.

@benjeffery
Copy link
Member Author

WIP, but probably useful to check I am heading in the right direction.

@codecov
Copy link

codecov bot commented Nov 17, 2021

Codecov Report

Merging #1911 (5f9f994) into main (194bea4) will decrease coverage by 0.03%.
The diff coverage is 85.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1911      +/-   ##
==========================================
- Coverage   93.36%   93.32%   -0.04%     
==========================================
  Files          27       27              
  Lines       25058    25186     +128     
  Branches     1107     1107              
==========================================
+ Hits        23395    23505     +110     
- Misses       1629     1647      +18     
  Partials       34       34              
Flag Coverage Δ
c-tests 92.32% <85.93%> (-0.07%) ⬇️
lwt-tests 89.14% <ø> (ø)
python-c-tests 71.61% <ø> (ø)
python-tests 98.80% <ø> (ø)

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

Impacted Files Coverage Δ
c/tskit/tables.c 90.18% <85.93%> (-0.09%) ⬇️

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 194bea4...5f9f994. Read the comment docs.

@benjeffery benjeffery force-pushed the ref_seq branch 2 times, most recently from d7b522e to ae8cb62 Compare November 22, 2021 16:56
@benjeffery benjeffery marked this pull request as ready for review November 22, 2021 16:58
@benjeffery
Copy link
Member Author

I think this is worth you looking at now @jeromekelleher

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 - some suggestions for moving things around so that most of the code is in the tsk_reference_sequence_t class, except for the table dump/load methods. These need to be in the table_collection class because we need only create a reference_sequence object if there is data to be loaded.

@benjeffery benjeffery force-pushed the ref_seq branch 2 times, most recently from 1686d6b to 68c7963 Compare November 25, 2021 01:08
@benjeffery
Copy link
Member Author

Ok, after a very annoying double free I think this is ready to be looked at again.

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.

Keeping track of whether the reference sequence is NULL or not is tricky and tedious, so I wonder if it would be simpler if we kept a state variable instead and embedded the reference_sequence_t struct in the table collection.

But let's merge this first - there's a few minor changes to make which hopefully make things follow the current idioms a bit better.

c/tskit/tables.c Outdated
tsk_safe_free(self->url);
tsk_safe_free(self->metadata);
tsk_safe_free(self->metadata_schema);
tsk_safe_free(self);
Copy link
Member

Choose a reason for hiding this comment

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

I see why you've done this but I think it'll just confuse us in the long term making this object a special case. It also rules out using a common idiom

tsk_reference_sequence_t tmp;
ret  = tsk_reference_sequence_init(&tmp);
tsk_reference_sequence_free(&tmp);

tsk_safe_free(self);
return 0;
}

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
int
tskreference_sequence_init(tsk_reference_sequence_t *self)
{
tskmemset(self, sizeof(*self));
return 0
}

}

tsk_reference_sequence_equals(const tsk_reference_sequence_t *self,
const tsk_reference_sequence_t *other, tsk_flags_t options)
{
return (
Copy link
Member

Choose a reason for hiding this comment

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

This is a pretty big nested expression - maybe break it up to make it easier to read?

if (self == NULL && other == NULL) {
     return true;
}
/* If one or the other is NULL they are not equal */
if (self == NULL != other == NULL) {
     return false;
}
return (self->data_length == other->data_length ...)

@benjeffery benjeffery force-pushed the ref_seq branch 2 times, most recently from d347bda to 1857803 Compare November 25, 2021 12:39
@benjeffery
Copy link
Member Author

embedded the reference_sequence_t struct in the table collection.

That's how I originally had it!

I've addressed the comments, working on the python side now.

@jeromekelleher
Copy link
Member

I've addressed the comments, working on the python side now.

How about get this merged in first? There's some errors in circleic

@benjeffery
Copy link
Member Author

There's some errors in circleic

Fixed!

@mergify mergify bot merged commit dd9fab0 into tskit-dev:main Nov 25, 2021
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