Runtime verification and automated testing for scientific code
Paranoid Scientist is a Python module which allows runtime verification of entry and exit conditions for Python functions using a novel type system which prioritizes the interpretation of types over their representation. It is intended for scientific software. More specifically, it provides the following:
- A novel type system, which emphasizes the meaning of the type instead of the data structure of the type.
- Verification of arbitrary entry and exit conditions, including more complex expressions with universal quantification.
- Automated testing of individual functions to determine, before execution of the program, whether functions conform to their specification.
- A simple and clear function decorator notation
- Python 3.5 or above
- Optional: Numpy (for Numpy types support)
All code is available under the MIT license. See LICENSE.txt for more information. Code is copyright 2018 Max Shinn. The logo is copyright 2018 Anastasia Ershova.
What types are included by default?
- Numeric types:
- Numeric: Any real number, plus inf/-inf/nan.
- ExtendedReal: Any real number plus inf/-inf.
- Number: Any real number.
- Integer: An integer.
- Natural0: A natural number including 0.
- Natural1: A natural number starting with 1.
- Range(x,y): A number in the interval [x,y].
- RangeClosedOpen(x,y): A number in the interval [x,y).
- RangeOpenClosed(x,y): A number in the interval (x,y].
- RangeOpen(x,y): A number in the range (x,y).
- Positive0: A positive number or zero.
- Positive: A positive number excluding zero.
- NDArray(d=None, t=None): A Numpy NDArray. Optionally, require
it to have
ddimensions. Optionally, require elements of the array to be of type
t(which can be any Paranoid type).
- Unchecked(t=None): Do not check the type for this element.
Optionally, a Paranoid type
tcan be passed as a type to generate during automated testing (to allow testing of functions of unchecked type).
- Constant(v): Can only be the value
- Self: A special type to use inside classes for the
- Nothing: Can only be None.
- Function: Any Python function.
- Boolean: Either True or False.
- And(t1, t2, ...): Any number of Paranoid types may be passed as arguments. Require a value to satisfy all of these types.
- Or(t1, t2, ...): Any number of Paranoid types may be passed as arguments. Require a value to satisfy at least one of these types.
- Not(t): Can be anything other than the Paranoid type
- Unchecked(t=None): Do not check the type for this element. Optionally, a Paranoid type
- Set(els): The argument
elsshould be a list of accepted values. This is equivalent to an enum. For example, Set([0, 1, 2, 3]) accepts only these four numbers.
- List(t): A Python list with elements of Paranoid type
- Dict(k, v): A Python dictionary where keys have Paranoid type
kand values have Paranoid type
- Set(els): The argument
- String: Any string.
- Identifier: Any non-empty string containing only alpha-numeric characters plus underscores and hyphens.
- Alphanumeric: Any non-empty alphanumeric string.
- Latin: Any non-empty string with Latin characters only.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size paranoid_scientist-0.2.1-py3-none-any.whl (25.5 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size paranoid-scientist-0.2.1.tar.gz (19.2 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for paranoid_scientist-0.2.1-py3-none-any.whl