Skip to content

Commit 5052b4e

Browse files
authored
AssertionLib 0.3.0 (#22)
* 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.
1 parent 063543c commit 5052b4e

21 files changed

+223
-292
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Python package
4+
name: Build
55

66
on:
77
push:
@@ -24,26 +24,26 @@ jobs:
2424
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
2525
uses: actions/setup-python@v1
2626
with:
27-
os: ${{ matrix.os }}
28-
python-version: ${{ matrix.python-version }}
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Install dependencies
30+
run: |
31+
pip install -e .[test]
32+
pip install git+https://github.com/numpy/numpy-stubs@master
2933
3034
- name: Python info
3135
run: |
3236
which python
3337
python --version
3438
35-
- name: Install dependencies
36-
run: |
37-
pip install -e .[test]
38-
pip install git+https://github.com/numpy/numpy-stubs@master
39+
- name: Installed packages
40+
run: pip list
3941

4042
- name: Test with pytest
41-
run: |
42-
pytest assertionlib
43-
pytest tests
43+
run: pytest
4444

4545
- name: Run codecov
4646
uses: codecov/codecov-action@v1
4747
with:
48-
file: ./coverage.xml
49-
name: codecov-umbrella
48+
file: ./coverage.xml
49+
name: codecov-umbrella

.readthedocs.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Build documentation in the docs/ directory with Sphinx
9+
sphinx:
10+
configuration: docs/conf.py
11+
12+
# Optionally build your docs in additional formats such as PDF
13+
formats: all
14+
15+
# Optionally set the version of Python and requirements required to build your docs
16+
python:
17+
install:
18+
- method: pip
19+
path: .
20+
extra_requirements:
21+
- docs

.travis.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ Change Log
55
All notable changes to this project will be documented in this file.
66
This project adheres to `Semantic Versioning <http://semver.org/>`_.
77

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

917
2.3.2
1018
*****

CITATION.cff

Lines changed: 0 additions & 22 deletions
This file was deleted.

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
This product includes AssertionLib, software developed by Bas van Beek
1+
This product includes AssertionLib, software developed by B. F. van Beek
22
.

README.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
:target: https://assertionlib.readthedocs.io/en/latest/
33
.. image:: https://badge.fury.io/py/AssertionLib.svg
44
:target: https://badge.fury.io/py/AssertionLib
5-
.. image:: https://travis-ci.org/nlesc-nano/AssertionLib.svg?branch=master
6-
:target: https://travis-ci.org/nlesc-nano/AssertionLib
75
.. image:: https://github.com/nlesc-nano/AssertionLib/workflows/Python%20package/badge.svg
86
:target: https://github.com/nlesc-nano/AssertionLib/actions
97
.. image:: https://codecov.io/gh/nlesc-nano/AssertionLib/branch/master/graph/badge.svg
@@ -22,32 +20,27 @@
2220

2321

2422
##################
25-
AssertionLib 2.3.2
23+
AssertionLib 3.0.0
2624
##################
27-
2825
A package for performing assertions and providing informative exception messages.
2926

3027

3128
Installation
3229
************
33-
34-
AssertionLib has no external dependencies and can be installed as following:
35-
3630
* PyPi: ``pip install AssertionLib``
3731
* GitHub: ``pip install git+https://github.com/nlesc-nano/AssertionLib``
3832

3933

4034
Usage
4135
*****
42-
4336
A comprehensive overview of all available assertion methods is
4437
provided in the documentation_.
4538
A few examples of some basic assertion:
4639

4740
.. code:: python
4841
49-
>>> from assertionlib import assertion
5042
>>> import numpy as np
43+
>>> from assertionlib import assertion
5144
5245
# Assert the output of specific callables
5346
>>> assertion.eq(5, 5) # 5 == 5
@@ -65,7 +58,7 @@ A few examples of some basic assertion:
6558
# Apply post-processing before conducting the assertion
6659
>>> ar_large = np.ones(10)
6760
>>> ar_small = np.zeros(10)
68-
>>> assertion.gt(ar_large, ar_small, post_process=all) # all(ar_large > ar_small)
61+
>>> assertion.gt(ar_large, ar_small, post_process=np.all) # all(ar_large > ar_small)
6962
7063
# Perform an assertion which will raise an AssertionError
7164
>>> assertion.eq(5, 6, message='Fancy custom error message') # 5 == 6
@@ -126,6 +119,11 @@ during/before the assertion process:
126119
...
127120
TypeError: object of type 'int' has no len()
128121
122+
123+
.. code:: python
124+
125+
>>> from assertionlib import assertion
126+
129127
>>> assertion.len(5, exception=TypeError) # i.e. len(5) should raise a TypeError
130128
>>> assertion.len([5], exception=TypeError)
131129
Traceback (most recent call last):
@@ -143,10 +141,9 @@ method and adding it to an instance with ``AssertionManager.add_to_instance()``:
143141

144142
.. code:: python
145143
146-
>>> from typing import Any
147144
>>> from assertionlib import assertion
148145
149-
>>> def my_fancy_func(a: Any) -> bool:
146+
>>> def my_fancy_func(a: object) -> bool:
150147
... return False
151148
152149
# Approach #1, supply to-be asserted callable to assertion.assert_()
@@ -160,6 +157,11 @@ method and adding it to an instance with ``AssertionManager.add_to_instance()``:
160157
output: bool = False
161158
a: int = 5
162159
160+
161+
.. code:: python
162+
163+
>>> from assertionlib import assertion
164+
163165
# Approach #2, permanantly add a new bound method using assertion.add_to_instance()
164166
>>> assertion.add_to_instance(my_fancy_func)
165167
>>> assertion.my_fancy_func(5)

assertionlib/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
"""AssertionLib."""
22

3+
import os
34
from .__version__ import __version__
45

56
from .ndrepr import NDRepr, aNDRepr
67
from .manager import assertion, AssertionManager
78
from .dataclass import AbstractDataClass
89
from .functions import load_readme
910

10-
__doc__ = load_readme()
11-
del load_readme
11+
_README = os.path.join(__path__[0], 'README.rst') # type: ignore
12+
__doc__ = load_readme(_README, encoding='utf-8')
13+
14+
del _README, load_readme, os
1215

1316
__author__ = "B. F. van Beek"
1417
__email__ = '[email protected]'

assertionlib/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""The AssertionLib version."""
22

3-
__version__ = '2.3.2'
3+
__version__ = '3.0.0'

0 commit comments

Comments
 (0)