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

DataSet.get_data bugs with start/end arguments #1386

Merged
merged 12 commits into from
Nov 19, 2018

Conversation

astafan8
Copy link
Contributor

@astafan8 astafan8 commented Nov 16, 2018

Fixes #1384.

There are two bugs in the underlying get_data function of sqlite_base.py:

  • 0 are treated as None
  • sql query has a typo in the where clause for start for the case where both start and end are not None

This PR fixes both.

Note that the current behavior suggests a 1-based indexing (unlike python 0-based), with both start and end indexes being included into retuned data. This behavior is captured by the test suite.

Ideally, the very same test should be done for get_data from sqlite_base.py but did not make it to this PR in order to avoid code duplication.

Note that get_data from sqlite_base.py was also refactored to reduce the possibility for bugs like the ones mentioned above. In case it made the function less readable, the refactoring can be reverted.

@codecov
Copy link

codecov bot commented Nov 16, 2018

Codecov Report

Merging #1386 into master will increase coverage by 0.06%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1386      +/-   ##
==========================================
+ Coverage   73.38%   73.45%   +0.06%     
==========================================
  Files          79       79              
  Lines        9282     9283       +1     
==========================================
+ Hits         6812     6819       +7     
+ Misses       2470     2464       -6

@astafan8 astafan8 changed the title [WIP] DataSet.get_data bugs DataSet.get_data bugs with start/end arguments Nov 19, 2018
@astafan8
Copy link
Contributor Author

@QCoDeS/core ready for review.

Copy link
Contributor

@WilliamHPNielsen WilliamHPNielsen left a comment

Choose a reason for hiding this comment

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

I think this looks good. I have the feeling that the test could be written without the mechanisms that almost (but not quite, which is important here) duplicate the existing fixtures, but after discussions with @astafan8, I feel that such a rewrite would probably be too much work for too little actual gain.

The non-test part looks like a clear improvement.

Copy link
Collaborator

@jenshnielsen jenshnielsen 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, left a few small comments

@jenshnielsen jenshnielsen merged commit bebb6d5 into microsoft:master Nov 19, 2018
giulioungaretti pushed a commit that referenced this pull request Nov 19, 2018
Merge: bb07fa0 a573667
Author: Jens Hedegaard Nielsen <[email protected]>

    Merge pull request #1386 from astafan8/bug/get_data_selected_rows
@astafan8 astafan8 deleted the bug/get_data_selected_rows branch November 19, 2018 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataSet.get_data: retrieving parts of dataset - actual start value depends on end
3 participants