Skip to content

Commit ca488dc

Browse files
authored
Nano-Utils 0.2.0 (#3)
* Added new NumPy-specific functions: ``as_nd_array()``, ``array_combinations()`` & ``fill_diagonal_blocks()``. * Expanded the ``typing_utils`` module with a number of, previously missing, objects. * Added the ``EMPTY_CONTAINER`` constaint. * Added the ``VersionInfo`` namedtuple and the ``raise_if()`` & ``split_dict()`` functions. * Added the ``version_info`` attribute to the package.
1 parent 41875b9 commit ca488dc

File tree

15 files changed

+595
-47
lines changed

15 files changed

+595
-47
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ jobs:
2727
python-version: ${{ matrix.python-version }}
2828

2929
- name: Install dependencies
30-
run: pip install -e .[test]
30+
run: |
31+
pip install -e .[test]
32+
pip install git+https://github.com/numpy/numpy-stubs@master
3133
3234
- name: Python info
3335
run: |

CHANGELOG.rst

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

88

9+
0.2.0
10+
*****
11+
* Added new NumPy-specific functions: ``as_nd_array()``, ``array_combinations()`` & ``fill_diagonal_blocks()``.
12+
* Expanded the ``typing_utils`` module with a number of, previously missing, objects.
13+
* Added the ``EMPTY_CONTAINER`` constaint.
14+
* Added the ``VersionInfo`` namedtuple and the ``raise_if()`` & ``split_dict()`` functions.
15+
* Added the ``version_info`` attribute to the package.
16+
17+
918
0.1.1
1019
*****
1120
* Updated the badges.

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
################
23-
Nano-Utils 0.1.1
23+
Nano-Utils 0.2.0
2424
################
2525
Utility functions used throughout the various nlesc-nano repositories.
2626

codecov.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 0
6+
patch:
7+
default:
8+
target: 0

docs/0_documentation.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ API
55
2_empty.rst
66
3_schema.rst
77
4_typing.rst
8+
5_numpy.rst

docs/5_numpy.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nanoutils.numpy_utils
2+
=====================
3+
.. automodule:: nanoutils.numpy_utils

docs/conf.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@
181181

182182
# Example configuration for intersphinx: refer to the Python standard library.
183183
intersphinx_mapping = {
184-
'python': ('https://docs.python.org/3/', None)
184+
'python': ('https://docs.python.org/3/', None),
185+
'numpy': ('https://numpy.org/doc/stable/', None)
185186
}
186187

187188

@@ -220,3 +221,10 @@
220221
# False to use the .. rubric:: directive instead.
221222
# Defaults to False.
222223
napoleon_use_admonition_for_references = True
224+
225+
226+
# A string of reStructuredText that will be included at the end of every source file that is read.
227+
# This is a possible place to add substitutions that should be available in every file (another being rst_prolog).
228+
rst_epilog = """
229+
.. _semantic: https://semver.org/
230+
"""

nanoutils/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@
44

55
from .__version__ import __version__
66

7-
from . import typing_utils, empty, utils, schema
7+
from . import typing_utils, empty, utils, numpy_utils, schema
88
from .typing_utils import *
99
from .empty import *
1010
from .utils import *
11+
from .numpy_utils import *
1112
from .schema import (
1213
Default, Formatter, supports_float, supports_int,
1314
isinstance_factory, issubclass_factory, import_factory
1415
)
1516

1617
__author__ = 'B. F. van Beek'
1718
__email__ = '[email protected]'
18-
__version__ = __version__
19+
version_info = VersionInfo.from_str(__version__)
1920

2021
__all__ = []
2122
__all__ += typing_utils.__all__
2223
__all__ += empty.__all__
2324
__all__ += utils.__all__
25+
__all__ += numpy_utils.__all__
2426
__all__ += schema.__all__

nanoutils/__version__.py

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

3-
__version__ = '0.1.1'
3+
__version__ = '0.2.0'

nanoutils/empty.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,58 @@
11
"""A module with empty (immutable) iterables.
22
3-
can be used as default arguments for functions.
3+
Can be used as default arguments for functions.
44
55
Index
66
-----
77
===================================== =================================================
8-
:data:`~nanoutils.EMPTY_SEQUENCE` An empty :class:`~collections.abc.Sequence`.
9-
:data:`~nanoutils.EMPTY_MAPPING` An empty :class:`~collections.abc.Mapping`.
8+
:data:`~nanoutils.EMPTY_CONTAINER` An empty :class:`~collections.abc.Container`.
109
:data:`~nanoutils.EMPTY_COLLECTION` An empty :class:`~collections.abc.Collection`.
1110
:data:`~nanoutils.EMPTY_SET` An empty :class:`~collections.abc.Set`.
11+
:data:`~nanoutils.EMPTY_SEQUENCE` An empty :class:`~collections.abc.Sequence`.
12+
:data:`~nanoutils.EMPTY_MAPPING` An empty :class:`~collections.abc.Mapping`.
1213
===================================== =================================================
1314
1415
API
1516
---
1617
.. currentmodule:: nanoutils
17-
.. data:: EMPTY_SEQUENCE
18-
:value: ()
19-
20-
An empty :class:`~collections.abc.Sequence`.
21-
22-
.. data:: EMPTY_MAPPING
23-
:value: mappingproxy({})
18+
.. data:: EMPTY_CONTAINER
19+
:type: Container
20+
:value: frozenset()
2421
25-
An empty :class:`~collections.abc.Mapping`.
22+
An empty :class:`~collections.abc.Container`.
2623
2724
.. data:: EMPTY_COLLECTION
25+
:type: Collection
2826
:value: frozenset()
2927
3028
An empty :class:`~collections.abc.Collection`.
3129
3230
.. data:: EMPTY_SET
31+
:type: Set
3332
:value: frozenset()
3433
3534
An empty :class:`~collections.abc.Set`.
3635
37-
""" # noqa: E501
36+
.. data:: EMPTY_SEQUENCE
37+
:type: Sequence
38+
:value: ()
39+
40+
An empty :class:`~collections.abc.Sequence`.
41+
42+
.. data:: EMPTY_MAPPING
43+
:type: Mapping
44+
:value: mappingproxy({})
45+
46+
An empty :class:`~collections.abc.Mapping`.
47+
48+
"""
3849

3950
from types import MappingProxyType
40-
from typing import Mapping, Collection, Sequence, AbstractSet
51+
from typing import Mapping, Collection, Sequence, AbstractSet, Container
4152

42-
__all__ = ['EMPTY_SEQUENCE', 'EMPTY_MAPPING', 'EMPTY_COLLECTION', 'EMPTY_SET']
53+
__all__ = [
54+
'EMPTY_SEQUENCE', 'EMPTY_MAPPING', 'EMPTY_COLLECTION', 'EMPTY_SET', 'EMPTY_CONTAINER'
55+
]
4356

4457
#: An empty :class:`~collections.abc.Sequence`.
4558
EMPTY_SEQUENCE: Sequence = ()
@@ -52,3 +65,6 @@
5265

5366
#: An empty :class:`~collections.abc.Set`.
5467
EMPTY_SET: AbstractSet = frozenset()
68+
69+
#: An empty :class:`~collections.abc.Container`.
70+
EMPTY_CONTAINER: Container = frozenset()

0 commit comments

Comments
 (0)