Skip to content

Commit

Permalink
AssertionLib 0.3.0 (#22)
Browse files Browse the repository at this point in the history
* Added Nano-Utils as a dependency; moved a number of functions there.
* Removed `requirements.txt` in favor of `.readthedocs.yml`.
* Removed travis tests in favor of GitHub Actions.
* Removed `CITATION.cff` in favor of Zenodo.
  • Loading branch information
BvB93 authored Jun 6, 2020
1 parent 063543c commit 5052b4e
Show file tree
Hide file tree
Showing 21 changed files with 223 additions and 292 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package
name: Build

on:
push:
Expand All @@ -24,26 +24,26 @@ jobs:
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v1
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install -e .[test]
pip install git+https://github.com/numpy/numpy-stubs@master
- name: Python info
run: |
which python
python --version
- name: Install dependencies
run: |
pip install -e .[test]
pip install git+https://github.com/numpy/numpy-stubs@master
- name: Installed packages
run: pip list

- name: Test with pytest
run: |
pytest assertionlib
pytest tests
run: pytest

- name: Run codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
name: codecov-umbrella
file: ./coverage.xml
name: codecov-umbrella
21 changes: 21 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
install:
- method: pip
path: .
extra_requirements:
- docs
51 changes: 0 additions & 51 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Change Log
All notable changes to this project will be documented in this file.
This project adheres to `Semantic Versioning <http://semver.org/>`_.

3.0.0
*****
* Added `Nano-Utils <https://github.com/nlesc-nano/Nano-Utils>`_ as a dependency;
moved a number of functions there.
* Removed `requirements.txt` in favor of `.readthedocs.yml`.
* Removed travis tests in favor of GitHub Actions.
* Removed `CITATION.cff` in favor of Zenodo.


2.3.2
*****
Expand Down
22 changes: 0 additions & 22 deletions CITATION.cff

This file was deleted.

2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This product includes AssertionLib, software developed by Bas van Beek
This product includes AssertionLib, software developed by B. F. van Beek
.
26 changes: 14 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
:target: https://assertionlib.readthedocs.io/en/latest/
.. image:: https://badge.fury.io/py/AssertionLib.svg
:target: https://badge.fury.io/py/AssertionLib
.. image:: https://travis-ci.org/nlesc-nano/AssertionLib.svg?branch=master
:target: https://travis-ci.org/nlesc-nano/AssertionLib
.. image:: https://github.com/nlesc-nano/AssertionLib/workflows/Python%20package/badge.svg
:target: https://github.com/nlesc-nano/AssertionLib/actions
.. image:: https://codecov.io/gh/nlesc-nano/AssertionLib/branch/master/graph/badge.svg
Expand All @@ -22,32 +20,27 @@


##################
AssertionLib 2.3.2
AssertionLib 3.0.0
##################

A package for performing assertions and providing informative exception messages.


Installation
************

AssertionLib has no external dependencies and can be installed as following:

* PyPi: ``pip install AssertionLib``
* GitHub: ``pip install git+https://github.com/nlesc-nano/AssertionLib``


Usage
*****

A comprehensive overview of all available assertion methods is
provided in the documentation_.
A few examples of some basic assertion:

.. code:: python
>>> from assertionlib import assertion
>>> import numpy as np
>>> from assertionlib import assertion
# Assert the output of specific callables
>>> assertion.eq(5, 5) # 5 == 5
Expand All @@ -65,7 +58,7 @@ A few examples of some basic assertion:
# Apply post-processing before conducting the assertion
>>> ar_large = np.ones(10)
>>> ar_small = np.zeros(10)
>>> assertion.gt(ar_large, ar_small, post_process=all) # all(ar_large > ar_small)
>>> assertion.gt(ar_large, ar_small, post_process=np.all) # all(ar_large > ar_small)
# Perform an assertion which will raise an AssertionError
>>> assertion.eq(5, 6, message='Fancy custom error message') # 5 == 6
Expand Down Expand Up @@ -126,6 +119,11 @@ during/before the assertion process:
...
TypeError: object of type 'int' has no len()
.. code:: python
>>> from assertionlib import assertion
>>> assertion.len(5, exception=TypeError) # i.e. len(5) should raise a TypeError
>>> assertion.len([5], exception=TypeError)
Traceback (most recent call last):
Expand All @@ -143,10 +141,9 @@ method and adding it to an instance with ``AssertionManager.add_to_instance()``:

.. code:: python
>>> from typing import Any
>>> from assertionlib import assertion
>>> def my_fancy_func(a: Any) -> bool:
>>> def my_fancy_func(a: object) -> bool:
... return False
# Approach #1, supply to-be asserted callable to assertion.assert_()
Expand All @@ -160,6 +157,11 @@ method and adding it to an instance with ``AssertionManager.add_to_instance()``:
output: bool = False
a: int = 5
.. code:: python
>>> from assertionlib import assertion
# Approach #2, permanantly add a new bound method using assertion.add_to_instance()
>>> assertion.add_to_instance(my_fancy_func)
>>> assertion.my_fancy_func(5)
Expand Down
7 changes: 5 additions & 2 deletions assertionlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
"""AssertionLib."""

import os
from .__version__ import __version__

from .ndrepr import NDRepr, aNDRepr
from .manager import assertion, AssertionManager
from .dataclass import AbstractDataClass
from .functions import load_readme

__doc__ = load_readme()
del load_readme
_README = os.path.join(__path__[0], 'README.rst') # type: ignore
__doc__ = load_readme(_README, encoding='utf-8')

del _README, load_readme, os

__author__ = "B. F. van Beek"
__email__ = '[email protected]'
Expand Down
2 changes: 1 addition & 1 deletion assertionlib/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""The AssertionLib version."""

__version__ = '2.3.2'
__version__ = '3.0.0'
Loading

0 comments on commit 5052b4e

Please sign in to comment.