Skip to content

Commit

Permalink
Merge pull request #10 from jmenglund/return_type
Browse files Browse the repository at this point in the history
Argument "return_type" to replace "return_values"
  • Loading branch information
jmenglund authored Jan 3, 2018
2 parents c7b16ef + cc7b637 commit ea1953f
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 199 deletions.
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ branches:
only:
- master

before_install:
- pip install coverage
install:
- pip install .
- pip install pycodestyle
- pip install pytest
- pip install pytest-pep8
- pip install coverage

script:
- py.test pandasvalidation.py --pep8
- coverage run -m py.test
- coverage report --include pandasvalidation.py -m
- pycodestyle pandasvalidation.py test_pandasvalidation.py setup.py
- coverage run -m pytest test_pandasvalidation.py
- coverage report -m pandasvalidation.py

after_success:
- codecov
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ Tracking changes in pandas-validation between versions.
See also https://github.com/jmenglund/pandas-validation/releases.


## 0.3.0 ##

This minor release contains the following changes:

* The validation functions now has a `return_type` argument that gives
the user control of the output. This replaces the `return_values` argument.
* When returning values, the validation functions now filter out all invalid
values.
* A few tests have been added to `test_pandasvalidation.py`. The code now has
full test coverage.
* Updates to the documentation.
* Removed use of the deprecated `pandas.tslib`

Released: 2018-01-03

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


## 0.2.0 ##

This minor release contains the following changes:
Expand Down
34 changes: 25 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,35 @@ can also be installed using git:
Running the tests
-----------------

Testing is carried out with `pytest <http://pytest.org>`_. The following
example shows how you can run the test suite and generate a coverage report
with `coverage <https://coverage.readthedocs.io/>`_:
Testing is carried out with `pytest <https://docs.pytest.org/>`_:

.. code-block::
$ py.test -v --pep8 pandasvalidation.py
$ coverage run -m py.test
$ coverage report --include pandasvalidation.py -m
$ pytest -v test_pandasvalidation.py
Test coverage can be calculated with `Coverage.py
<https://coverage.readthedocs.io/>`_ using the following commands:

.. code-block::
$ coverage run -m pytest
$ coverage report -m pandasvalidation.py
The code follow style conventions in `PEP8
<https://www.python.org/dev/peps/pep-0008/>`_, which can be checked
with `pycodestyle <http://pycodestyle.pycqa.org>`_:

.. code-block::
$ pycodestyle pandasvalidation.py test_pandasvalidation.py setup.py
Building the documentation
--------------------------

The documentation can be built with `Sphinx <http://www.sphinx-doc.org>`_:
The documentation can be built with `Sphinx <http://www.sphinx-doc.org>`_
and the `Read the Docs Sphinx Theme
<https://sphinx-rtd-theme.readthedocs.io>`_:

.. code-block::
Expand All @@ -59,13 +73,15 @@ The documentation can be built with `Sphinx <http://www.sphinx-doc.org>`_:
License
-------

pandas-validation is distributed under the `MIT license <https://opensource.org/licenses/MIT>`_.
pandas-validation is distributed under the `MIT license
<https://opensource.org/licenses/MIT>`_.


Author
------

Markus Englund, `orcid.org/0000-0003-1688-7112 <http://orcid.org/0000-0003-1688-7112>`_
Markus Englund, `orcid.org/0000-0003-1688-7112
<http://orcid.org/0000-0003-1688-7112>`_


.. |Build-Status| image:: https://api.travis-ci.org/jmenglund/pandas-validation.svg?branch=master
Expand Down
86 changes: 43 additions & 43 deletions docs/source/pandas-validation/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ know more, I suggest that you have a look at the :ref:`API reference<api>`.

The code examples below assume that you first do the following imports:

.. code-block:: pycon
.. code-block:: python
>>> import numpy as np
>>> import pandas as pd
>>> import pandasvalidation as pv
import numpy as np
import pandas as pd
import pandasvalidation as pv
.. _validate-dates:
Expand All @@ -37,18 +37,18 @@ pandas Series will be returned with the values converted to the datetime
data type.


.. code-block:: pycon
.. code-block:: python
>>> s1 = pandas.Series(
... ['2014', '2014-01-07', '2014-02-28', np.nan],
... name='My dates')
>>> pv.validate_datetime(
... s1,
... nullable=False,
... unique=True,
... min_datetime='2014-01-05',
... max_datetime='2014-02-15',
... return_values=False)
s1 = pd.Series(
['2014', '2014-01-07', '2014-02-28', np.nan],
name='My dates')
pv.validate_datetime(
s1,
nullable=False,
unique=True,
min_datetime='2014-01-05',
max_datetime='2014-02-15',
return_type=None)
.. _validate-numbers:
Expand All @@ -61,19 +61,19 @@ Like in the example above, warnings will indicate invalid values to the user.
If `return_values` is set to ``True``, a pandas Series will be returned with
the values converted to a numeric data type.

.. code-block:: pycon
.. code-block:: python
>>> s2 = pandas.Series(
... [1, '1', '2.3', np.nan],
... name='My numeric values')
>>> pv.validate_numeric(
... s2,
... nullable=False,
... unique=True,
... integer=True,
... min_value=2,
... max_value=2,
... return_values=False)
s2 = pd.Series(
[1, '1', '2.3', np.nan],
name='My numeric values')
pv.validate_numeric(
s2,
nullable=False,
unique=True,
integer=True,
min_value=2,
max_value=2,
return_type=None)
.. _validate-strings:
Expand All @@ -87,19 +87,19 @@ warnings then issued if there are invalid values. If `return_values` is
set to ``True``, a pandas Series will be returned with the values rendered
as strings.

.. code-block:: pycon
>>> s3 = pandas.Series(
... [1, 1, 'ab\n', 'a b', 'Ab', 'AB', np.nan],
... name='My strings')
>>> pv.validate_string(
... s3,
... nullable=False,
... unique=True,
... min_length=2,
... max_length=2,
... case='lower',
... newlines=False,
... trailing_whitespace=False,
... whitespace=False,
... return_values=False)
.. code-block:: python
s3 = pd.Series(
[1, 1, 'ab\n', 'a b', 'Ab', 'AB', np.nan],
name='My strings')
pv.validate_string(
s3,
nullable=False,
unique=True,
min_length=2,
max_length=2,
case='lower',
newlines=False,
trailing_whitespace=False,
whitespace=False,
return_type=False)
Loading

0 comments on commit ea1953f

Please sign in to comment.