AndreaCensi / contracts

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.
http://andreacensi.github.io/contracts/
Other
399 stars 61 forks source link

enable number-like contracts for numpy.number instances #8

Closed braingram closed 9 years ago

braingram commented 12 years ago

Very small change to allow number-like contracts (e.g. '=3,>0|<=0') with instances of numpy.number (numpy.int64, numpy.float64, numpy.uint8, etc...).

import contracts
import numpy
v = numpy.arange(1)[0]  # type(v) == numpy.int64 etc...
c = '=0'
contracts.check(c, v)
AndreaCensi commented 9 years ago

This wasn't merged but some time along the way it was implemented. Thanks!