Skip to content

Commit

Permalink
Nano-Utils 0.2.0 (#3)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
BvB93 authored Jun 3, 2020
1 parent 41875b9 commit ca488dc
Show file tree
Hide file tree
Showing 15 changed files with 595 additions and 47 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install -e .[test]
run: |
pip install -e .[test]
pip install git+https://github.com/numpy/numpy-stubs@master
- name: Python info
run: |
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ All notable changes to this project will be documented in this file.
This project adheres to `Semantic Versioning <http://semver.org/>`_.


0.2.0
*****
* 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.


0.1.1
*****
* Updated the badges.
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


################
Nano-Utils 0.1.1
Nano-Utils 0.2.0
################
Utility functions used throughout the various nlesc-nano repositories.

Expand Down
8 changes: 8 additions & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coverage:
status:
project:
default:
target: 0
patch:
default:
target: 0
1 change: 1 addition & 0 deletions docs/0_documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ API
2_empty.rst
3_schema.rst
4_typing.rst
5_numpy.rst
3 changes: 3 additions & 0 deletions docs/5_numpy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nanoutils.numpy_utils
=====================
.. automodule:: nanoutils.numpy_utils
10 changes: 9 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None)
'python': ('https://docs.python.org/3/', None),
'numpy': ('https://numpy.org/doc/stable/', None)
}


Expand Down Expand Up @@ -220,3 +221,10 @@
# False to use the .. rubric:: directive instead.
# Defaults to False.
napoleon_use_admonition_for_references = True


# A string of reStructuredText that will be included at the end of every source file that is read.
# This is a possible place to add substitutions that should be available in every file (another being rst_prolog).
rst_epilog = """
.. _semantic: https://semver.org/
"""
6 changes: 4 additions & 2 deletions nanoutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@

from .__version__ import __version__

from . import typing_utils, empty, utils, schema
from . import typing_utils, empty, utils, numpy_utils, schema
from .typing_utils import *
from .empty import *
from .utils import *
from .numpy_utils import *
from .schema import (
Default, Formatter, supports_float, supports_int,
isinstance_factory, issubclass_factory, import_factory
)

__author__ = 'B. F. van Beek'
__email__ = '[email protected]'
__version__ = __version__
version_info = VersionInfo.from_str(__version__)

__all__ = []
__all__ += typing_utils.__all__
__all__ += empty.__all__
__all__ += utils.__all__
__all__ += numpy_utils.__all__
__all__ += schema.__all__
2 changes: 1 addition & 1 deletion nanoutils/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""The Nano-Utils version."""

__version__ = '0.1.1'
__version__ = '0.2.0'
44 changes: 30 additions & 14 deletions nanoutils/empty.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,58 @@
"""A module with empty (immutable) iterables.
can be used as default arguments for functions.
Can be used as default arguments for functions.
Index
-----
===================================== =================================================
:data:`~nanoutils.EMPTY_SEQUENCE` An empty :class:`~collections.abc.Sequence`.
:data:`~nanoutils.EMPTY_MAPPING` An empty :class:`~collections.abc.Mapping`.
:data:`~nanoutils.EMPTY_CONTAINER` An empty :class:`~collections.abc.Container`.
:data:`~nanoutils.EMPTY_COLLECTION` An empty :class:`~collections.abc.Collection`.
:data:`~nanoutils.EMPTY_SET` An empty :class:`~collections.abc.Set`.
:data:`~nanoutils.EMPTY_SEQUENCE` An empty :class:`~collections.abc.Sequence`.
:data:`~nanoutils.EMPTY_MAPPING` An empty :class:`~collections.abc.Mapping`.
===================================== =================================================
API
---
.. currentmodule:: nanoutils
.. data:: EMPTY_SEQUENCE
:value: ()
An empty :class:`~collections.abc.Sequence`.
.. data:: EMPTY_MAPPING
:value: mappingproxy({})
.. data:: EMPTY_CONTAINER
:type: Container
:value: frozenset()
An empty :class:`~collections.abc.Mapping`.
An empty :class:`~collections.abc.Container`.
.. data:: EMPTY_COLLECTION
:type: Collection
:value: frozenset()
An empty :class:`~collections.abc.Collection`.
.. data:: EMPTY_SET
:type: Set
:value: frozenset()
An empty :class:`~collections.abc.Set`.
""" # noqa: E501
.. data:: EMPTY_SEQUENCE
:type: Sequence
:value: ()
An empty :class:`~collections.abc.Sequence`.
.. data:: EMPTY_MAPPING
:type: Mapping
:value: mappingproxy({})
An empty :class:`~collections.abc.Mapping`.
"""

from types import MappingProxyType
from typing import Mapping, Collection, Sequence, AbstractSet
from typing import Mapping, Collection, Sequence, AbstractSet, Container

__all__ = ['EMPTY_SEQUENCE', 'EMPTY_MAPPING', 'EMPTY_COLLECTION', 'EMPTY_SET']
__all__ = [
'EMPTY_SEQUENCE', 'EMPTY_MAPPING', 'EMPTY_COLLECTION', 'EMPTY_SET', 'EMPTY_CONTAINER'
]

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

#: An empty :class:`~collections.abc.Set`.
EMPTY_SET: AbstractSet = frozenset()

#: An empty :class:`~collections.abc.Container`.
EMPTY_CONTAINER: Container = frozenset()
Loading

0 comments on commit ca488dc

Please sign in to comment.