Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jmenglund committed Feb 2, 2019
2 parents a982e54 + a5dcc65 commit 4a0e22f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Tracking changes in pandas-validation between versions.
See also https://github.com/jmenglund/pandas-validation/releases.


## 0.3.2 ##

This is a patch release that fixes an issue with validating numbers with `min_value=0`
or `max_value=0`.

Released: 2019-02-02

[View commits](https://github.com/jmenglund/pandas-validation/compare/v0.3.1...v0.3.2)


## 0.3.1 ##

This is a patch release with a few fixes to the documentation.
Expand Down
13 changes: 6 additions & 7 deletions pandasvalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ def validate_datetime(
masks['isnull'] = converted.isnull()
if unique:
masks['nonunique'] = converted.duplicated() & converted.notnull()
if min_datetime:
if min_datetime is not None:
masks['too_low'] = converted.dropna() < min_datetime
if max_datetime:
if max_datetime is not None:
masks['too_high'] = converted.dropna() > max_datetime

msg_list = _get_error_messages(masks, error_info)
Expand Down Expand Up @@ -291,7 +291,6 @@ def validate_numeric(
Kind of data object to return; 'mask_series', 'mask_frame'
or 'values'. Default: None.
"""

error_info = {
'nonconvertible': 'Value(s) not converted to datetime set as NaT',
'isnull': 'NaN value(s)',
Expand All @@ -315,9 +314,9 @@ def validate_numeric(
noninteger_dropped = (
converted.dropna() != converted.dropna().apply(int))
masks['noninteger'] = pandas.Series(noninteger_dropped, series.index)
if min_value:
if min_value is not None:
masks['too_low'] = converted.dropna() < min_value
if max_value:
if max_value is not None:
masks['too_high'] = converted.dropna() > max_value

msg_list = _get_error_messages(masks, error_info)
Expand Down Expand Up @@ -402,10 +401,10 @@ def validate_string(
masks['isnull'] = converted.isnull()
if unique:
masks['nonunique'] = converted.duplicated() & converted.notnull()
if min_length:
if min_length is not None:
too_short_dropped = converted.dropna().apply(len) < min_length
masks['too_short'] = pandas.Series(too_short_dropped, series.index)
if max_length:
if max_length is not None:
too_long_dropped = converted.dropna().apply(len) > max_length
masks['too_long'] = pandas.Series(too_long_dropped, series.index)
if case:
Expand Down
2 changes: 1 addition & 1 deletion release-checklist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Things to remember when making a new release of pandas-validation.

.. code-block:: none
$ python setup.py sdist bdist_wheel
$ python setup.py sdist bdist_wheel --universal
$ twine upload dist/*
#. Create the new release in GitHub.
Expand Down
8 changes: 4 additions & 4 deletions test_pandasvalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def test_validation(self):

class TestValidateNumber():

numeric_as_strings = pandas.Series(['1', '1', '2.3', numpy.nan])
numeric = pandas.Series([1, 1, 2.3, numpy.nan])
numeric_as_strings = pandas.Series(['-1', '-1', '2.3', numpy.nan])
numeric = pandas.Series([-1, -1, 2.3, numpy.nan])

def test_validation(self):

Expand All @@ -195,10 +195,10 @@ def test_validation(self):
ValidationWarning, validate_numeric, self.numeric, integer=True)

pytest.warns(
ValidationWarning, validate_numeric, self.numeric, min_value=2)
ValidationWarning, validate_numeric, self.numeric, min_value=0)

pytest.warns(
ValidationWarning, validate_numeric, self.numeric, max_value=2)
ValidationWarning, validate_numeric, self.numeric, max_value=0)


class TestValidateString():
Expand Down

0 comments on commit 4a0e22f

Please sign in to comment.