-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Check that values for "nrows" and "chunksize" are valid #15774
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor comments
pandas/io/parsers.py
Outdated
an integer OR float that can SAFELY be cast to an integer | ||
without losing accuracy. Raises a ValueError if that is | ||
not the case. | ||
""" | ||
msg = "'nrows' must be an integer" | ||
msg = "'%s' must be an integer >=%s" % (name, min_val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use "{}".format(...) string formatting, ideally with named parameters
pandas/io/parsers.py
Outdated
""" | ||
Checks whether the 'nrows' parameter for parsing is either | ||
Checks whether the 'name' parameter for parsing is either | ||
an integer OR float that can SAFELY be cast to an integer | ||
without losing accuracy. Raises a ValueError if that is | ||
not the case. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a Parameters section to the doc-string.
@@ -402,6 +405,18 @@ def test_read_chunksize(self): | |||
tm.assert_frame_equal(chunks[1], df[2:4]) | |||
tm.assert_frame_equal(chunks[2], df[4:]) | |||
|
|||
# with invalid chunksize value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a test for nrows that is negative? and same for chunsize?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, there is a test for nrows=-1
and one for chunksize=0
... which is already "too negative". So yes, there are tests for the positivity check.
Looks good! Currently, |
lgtm. I c you did that. ok ping on green. |
Codecov Report
@@ Coverage Diff @@
## master #15774 +/- ##
==========================================
- Coverage 91.01% 90.99% -0.02%
==========================================
Files 143 143
Lines 49384 49384
==========================================
- Hits 44947 44939 -8
- Misses 4437 4445 +8
Continue to review full report at Codecov.
|
@toobaz Thanks! |
You're welcome! |
git diff master --name-only -- '*.py' | flake8 --diff