ashander / ftprime

Forward-time simulation of the msprime data structure (for development)
2 stars 1 forks source link

Expanded unit tests for argrecorder #23

Closed ashander closed 7 years ago

ashander commented 7 years ago

closes #17

codecov-io commented 7 years ago

Codecov Report

Merging #23 into master will increase coverage by 6.96%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #23      +/-   ##
==========================================
+ Coverage    92.4%   99.36%   +6.96%     
==========================================
  Files           3        3              
  Lines         158      158              
==========================================
+ Hits          146      157      +11     
+ Misses         12        1      -11
Flag Coverage Δ
#unit 63.92% <ø> (+29.74%) :arrow_up:
Impacted Files Coverage Δ
ftprime/argrecorder.py 98.96% <0%> (+11.34%) :arrow_up:

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 dbe1b7b...a782e48. Read the comment docs.

ashander commented 7 years ago

OK, that makes sense! But wait I thought the wf example looks like this too before running add_samples. Will double check

On Fri, Apr 21, 2017 at 4:02 PM, Peter Ralph notifications@github.com wrote:

@petrelharp commented on this pull request.

In tests/unit/test_arg_recorder.py https://github.com/ashander/ftprime/pull/23#discussion_r112790973:

  • def test_sample_table(self):
  • +class TestARGrecorderGoodSampledPopulation():

  • def setup_method(self):
  • '''setup for all tests in class'''
  • self.arg = ARGrecorder()
  • self.arg.add_individual(2, time=3.0)
  • self.arg.add_individual(3, time=3.0)
  • self.arg.add_individual(4, time=1.0)
  • self.arg.add_record(left=0.5, right=1.0, parent=3, children=(4, ))
  • self.arg.add_record(left=0.0, right=0.5, parent=2, children=(4, ))
  • self.arg.add_individual(1, time=0.0)
  • self.arg.add_individual(0, time=0.0)
  • self.samples = [3, 4]
  • self.arg.add_samples(samples=self.samples, length=1.0)

Oh, I see. Your setup is in error - samples must have IDs that are 0..nsamples-1; but you've already added individuals 0 and 1, without specifying that they are samples, and so when add_samples tries to add these IDs, nothing happens. If you'd left off lines 155 and 156, then add_samples would have added individuals 0 and 1, and properly flagged them as samples.

So, there's no samples, so the output nodetable of samples is empty.

To avoid this, we should put an 'else:' statement at https://github.com/ashander/ftprime/blob/master/ftprime/argrecorder.py#L37 that raises some kind of error saying the individual already exists.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ashander/ftprime/pull/23#discussion_r112790973, or mute the thread https://github.com/notifications/unsubscribe-auth/AAfLOLTqgAgzX9f5T_QKV0GiIdlYgPtwks5ryTWTgaJpZM4NDumE .