Defines common utilities objects that don’t fall in any specific category.
Decorator for handling Numpy errors.
Parameters: | **kwargs (**) – Keywords arguments. |
---|---|
Return type: | object |
References
[1] | Kienzle, P., Patel, N., & Krycka, J. (2011). refl1d.numpyerrors - Refl1D v0.6.19 documentation. Retrieved January 30, 2015, from http://www.reflectometry.org/danse/docs/refl1d/_modules/refl1d/numpyerrors.html |
Examples
>>> import numpy
>>> @handle_numpy_errors(all='ignore')
... def f():
... 1 / numpy.zeros(3)
>>> f()
Decorator for ignoring Python warnings.
Parameters: | function (object) – Object to decorate. |
---|---|
Return type: | object |
Examples
>>> @ignore_python_warnings
... def f():
... warnings.warn('This is an ignored warning!')
>>> f()
Returns a batch generator from given iterable.
Parameters: |
|
---|---|
Returns: | Is string_like variable. |
Return type: | bool |
Examples
>>> batch(tuple(range(10)))
<generator object batch at 0x...>
Returns if OpenImageIO is installed and available.
Parameters: | raise_exception (bool) – Raise exception if OpenImageIO is unavailable. |
---|---|
Returns: | Is OpenImageIO installed. |
Return type: | bool |
Raises: | ImportError – If OpenImageIO is not installed. |
Returns if scipy is installed and available.
Parameters: | raise_exception (bool) – Raise exception if scipy is unavailable. |
---|---|
Returns: | Is scipy installed. |
Return type: | bool |
Raises: | ImportError – If scipy is not installed. |
Returns if given \(x\) variable is iterable.
Parameters: | x (object) – Variable to check the iterability. |
---|---|
Returns: | \(x\) variable iterability. |
Return type: | bool |
Examples
>>> is_iterable([1, 2, 3])
True
>>> is_iterable(1)
False
Returns if given data is a string_like variable.
Parameters: | data (object) – Data to test. |
---|---|
Returns: | Is string_like variable. |
Return type: | bool |
Examples
>>> is_string('I`m a string!')
True
>>> is_string(['I`m a string!'])
False
Returns if given \(x\) variable is a number.
Parameters: | x (object) – Variable to check. |
---|---|
Returns: | Is \(x\) variable a number. |
Return type: | bool |
See also
Examples
>>> is_numeric(1)
True
>>> is_numeric((1,))
False
Returns if given \(x\) variable is an integer under given threshold.
Parameters: | x (object) – Variable to check. |
---|---|
Returns: | Is \(x\) variable an integer. |
Return type: | bool |
Notes
See also
Examples
>>> is_integer(1)
True
>>> is_integer(1.01)
False