add test script for compare module
This commit is contained in:
parent
67be0c6762
commit
6ff9d2cb04
5 changed files with 30 additions and 7 deletions
|
|
@ -43,6 +43,10 @@ The `fft` sub-module implements the fast Fourier transform, and its inverse for
|
|||
|
||||
The `filter` sub-module implements one-dimensional convolution.
|
||||
|
||||
### compare
|
||||
|
||||
The `compare` sub-module contains the implementation of the `minimum`, `maximum`, and `clip` functions.
|
||||
|
||||
### extras
|
||||
|
||||
The `extras` sub-module is meant as a user-extendable module, and currently implements the `spectrogram` function of `scipy`.
|
||||
|
|
|
|||
|
|
@ -3498,7 +3498,7 @@ Returns the minimum of two arrays, or two scalars, or an array, and a
|
|||
scalar. Partial broadcasting is implemented. If the arrays are of
|
||||
different ``dtype``, the output is upcast as in `Binary
|
||||
operators <#Binary-operators>`__. If both inputs are scalars, a scalar
|
||||
is returned.
|
||||
is returned. Only positional arguments are implemented.
|
||||
|
||||
maximum
|
||||
-------
|
||||
|
|
@ -3510,7 +3510,7 @@ Returns the maximum of two arrays, or two scalars, or an array, and a
|
|||
scalar. Partial broadcasting is implemented. If the arrays are of
|
||||
different ``dtype``, the output is upcast as in `Binary
|
||||
operators <#Binary-operators>`__. If both inputs are scalars, a scalar
|
||||
is returned.
|
||||
is returned. Only positional arguments are implemented.
|
||||
|
||||
.. code::
|
||||
|
||||
|
|
|
|||
|
|
@ -120,11 +120,11 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 21,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2020-04-09T10:36:52.750907Z",
|
||||
"start_time": "2020-04-09T10:36:44.638753Z"
|
||||
"end_time": "2020-04-21T20:40:41.618721Z",
|
||||
"start_time": "2020-04-21T20:40:38.313434Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
|
|
@ -4894,13 +4894,13 @@
|
|||
"\n",
|
||||
"`numpy`: https://docs.scipy.org/doc/numpy/reference/generated/numpy.minimum.html\n",
|
||||
"\n",
|
||||
"Returns the minimum of two arrays, or two scalars, or an array, and a scalar. Partial broadcasting is implemented. If the arrays are of different `dtype`, the output is upcast as in [Binary operators](#Binary-operators). If both inputs are scalars, a scalar is returned. \n",
|
||||
"Returns the minimum of two arrays, or two scalars, or an array, and a scalar. Partial broadcasting is implemented. If the arrays are of different `dtype`, the output is upcast as in [Binary operators](#Binary-operators). If both inputs are scalars, a scalar is returned. Only positional arguments are implemented.\n",
|
||||
"\n",
|
||||
"## maximum\n",
|
||||
"\n",
|
||||
"`numpy`: https://docs.scipy.org/doc/numpy/reference/generated/numpy.maximum.html\n",
|
||||
"\n",
|
||||
"Returns the maximum of two arrays, or two scalars, or an array, and a scalar. Partial broadcasting is implemented. If the arrays are of different `dtype`, the output is upcast as in [Binary operators](#Binary-operators). If both inputs are scalars, a scalar is returned."
|
||||
"Returns the maximum of two arrays, or two scalars, or an array, and a scalar. Partial broadcasting is implemented. If the arrays are of different `dtype`, the output is upcast as in [Binary operators](#Binary-operators). If both inputs are scalars, a scalar is returned. Only positional arguments are implemented."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
14
tests/compare.py
Normal file
14
tests/compare.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import ulab
|
||||
from ulab import compare
|
||||
|
||||
a = ulab.array([1, 2, 3, 4, 5], dtype=ulab.uint8)
|
||||
b = ulab.array([5, 4, 3, 2, 1], dtype=ulab.float)
|
||||
print(compare.minimum(a, b))
|
||||
print(compare.maximum(a, b))
|
||||
print(compare.maximum(1, 5.5))
|
||||
|
||||
a = ulab.array(range(9), dtype=ulab.uint8)
|
||||
print(compare.clip(a, 3, 7))
|
||||
|
||||
b = 3 * ulab.ones(len(a), dtype=ulab.float)
|
||||
print(compare.clip(a, b, 7))
|
||||
5
tests/compare.py.exp
Normal file
5
tests/compare.py.exp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
array([1.0, 2.0, 3.0, 2.0, 1.0], dtype=float)
|
||||
array([5.0, 4.0, 3.0, 4.0, 5.0], dtype=float)
|
||||
5.5
|
||||
array([3, 3, 3, 3, 4, 5, 6, 7, 7], dtype=uint8)
|
||||
array([3.0, 3.0, 3.0, 3.0, 4.0, 5.0, 6.0, 7.0, 7.0], dtype=float)
|
||||
Loading…
Reference in a new issue