Beispiel #1
0
def test_matplotlib_support():
    with pytest.raises(KeyError):
        _matplotlib.units.registry[unyt_array]
    matplotlib_support.enable()
    assert isinstance(_matplotlib.units.registry[unyt_array], unyt_arrayConverter)
    matplotlib_support.disable()
    assert unyt_array not in _matplotlib.units.registry.keys()
    assert unyt_quantity not in _matplotlib.units.registry.keys()
    # test as a callable
    matplotlib_support()
    assert isinstance(_matplotlib.units.registry[unyt_array], unyt_arrayConverter)
Beispiel #2
0
"""LabVIEW's waveform data type in Python"""
from numbers import Number
import numpy as np
from unyt import matplotlib_support, unyt_array

matplotlib_support()
matplotlib_support.label_style = "/"


class WaveformDT(np.lib.mixins.NDArrayOperatorsMixin):
    """Python implementation of LabVIEW's waveform data type

    LabVIEW's waveform data type has three required attributes: t0, dt, and Y.
    Additional attributes can be set and are included in the returned WaveformDT.
    WaveformDT has the function to_xy() that will generate the x-axis array from the
    t0, dt and number of samples in the Y array.

    Attributes:
        Y (array-like): data
        dt (float): wf_increment
        t0 (float or datetime): wf_start_time

    Example:

        >>> data = WaveformDT([1,2,3], 1, 0)
        >>> x, y = data.to_xy()
        >>> x
        array([0., 1., 2.])
        >>> y
        array([1, 2, 3])
Beispiel #3
0
"""SI unit system package"""
import unyt
from unit_system.quantity import Quantity
from unit_system.predefined_units import predefined_units
from unit_system.version import __version__

unyt.matplotlib_support()
unyt.matplotlib_support.label_style = "/"
globals().update(predefined_units)
__all__ = ["Quantity"] + list(predefined_units.keys())