File: typing.rst

package info (click to toggle)
python-pint 0.25.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 1,940 kB
  • sloc: python: 20,487; makefile: 149
file content (21 lines) | stat: -rw-r--r-- 535 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.. _typing:

Wrapping and checking functions
===============================

Type Annotations
----------------

Pint's Quantity class supports type annotations, which can be used to specify the type of
the magnitude (e.g., float, int, np.ndarray)


.. doctest::

    >>> import numpy as np
    >>> import pint
    >>> def my_scalar_func(x: pint.Quantity[float]) -> pint.Quantity[float]:
    ...     pass
    >>> def my_array_func(x: pint.Quantity[np.ndarray[(3, ), int]]) -> pint.Quantity[np.ndarray[(3, ), int]]:
    ...     pass
##