PyContracts is a Python package that allows to declare constraints on function parameters and return values. Contracts can be specified using Python3 annotations, or inside a docstring. PyContracts supports a basic type system, variables binding, arithmetic constraints, and has several specialized contracts and an extension API.
I was curious for the numpy part of the library if you had considered anything like abstracting over lists of dimensions?
Would love to be able to write something like this:
@contract
def batch_matrix_multiply(a, b):
''' Multiplies two batches fo matrices together.
:param a: The first tensor, must end in MxN.
:type a: array[*xMxN],M>0,N>0
:param b: The second tensor, must end in NxP
:type b: array[*xNxP],P>0
:rtype: array[*xMxP]
'''
I was curious for the numpy part of the library if you had considered anything like abstracting over lists of dimensions?
Would love to be able to write something like this: