nums.numpy.api.generated module

nums.numpy.api.generated.abs(x, out=None, where=True, **kwargs)[source]

Calculate the absolute value element-wise.

nps.abs is a shorthand for this function.

This docstring was copied from numpy.abs.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

absolute – A BlockArray containing the absolute value of each element in x. For complex input, a + ib, the absolute value is \(\sqrt{ a^2 + b^2 }\).

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> x = nps.array([-1.2, 1.2])  
>>> nps.absolute(x).get()  
array([ 1.2,  1.2])
>>> nps.absolute(nps.array([1.2 + 1j])).get()  
array([1.56204994])
nums.numpy.api.generated.absolute(x, out=None, where=True, **kwargs)[source]

Calculate the absolute value element-wise.

nps.abs is a shorthand for this function.

This docstring was copied from numpy.absolute.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

absolute – A BlockArray containing the absolute value of each element in x. For complex input, a + ib, the absolute value is \(\sqrt{ a^2 + b^2 }\).

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> x = nps.array([-1.2, 1.2])  
>>> nps.absolute(x).get()  
array([ 1.2,  1.2])
>>> nps.absolute(nps.array(1.2 + 1j)).get()  
array(1.56204994)
nums.numpy.api.generated.add(x1, x2, out=None, where=True, **kwargs)[source]

Add arguments element-wise.

This docstring was copied from numpy.add.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – The arrays to be added. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – The arrays to be added. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

add – The sum of x1 and x2, element-wise.

Return type

BlockArray or scalar

Notes

Equivalent to x1 + x2 in terms of array broadcasting.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.add(nps.array(1.0), nps.array(4.0)).get()  
array(5.)
>>> x1 = nps.arange(9.0).reshape((3, 3))  
>>> x2 = nps.arange(3.0)  
>>> nps.add(x1, x2).get()  
array([[  0.,   2.,   4.],
       [  3.,   5.,   7.],
       [  6.,   8.,  10.]])
nums.numpy.api.generated.arccos(x, out=None, where=True, **kwargs)[source]

Trigonometric inverse cosine, element-wise.

The inverse of cos so that, if y = cos(x), then x = arccos(y).

This docstring was copied from numpy.arccos.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – x-coordinate on the unit circle. For real arguments, the domain is [-1, 1].

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

angle – The angle of the ray intersecting the unit circle at the given x-coordinate in radians [0, pi].

Return type

BlockArray

See also

cos, arctan, arcsin, emath.arccos

Notes

arccos is a multivalued function: for each x there are infinitely many numbers z such that cos(z) = x. The convention is to return the angle z whose real part lies in [0, pi].

For real-valued input data types, arccos always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.

For complex-valued input, arccos is a complex analytic function that has branch cuts [-inf, -1] and [1, inf] and is continuous from above on the former and from below on the latter.

The inverse cos is also known as acos or cos^-1.

References

M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 79. http://www.math.sfu.ca/~cbm/aands/

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

We expect the arccos of 1 to be 0, and of -1 to be pi:

>>> nps.arccos(nps.array([1, -1])).get()  
array([ 0.        ,  3.14159265])
nums.numpy.api.generated.arccosh(x, out=None, where=True, **kwargs)[source]

Inverse hyperbolic cosine, element-wise.

This docstring was copied from numpy.arccosh.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

arccosh – Array of the same shape as x.

Return type

BlockArray

See also

cosh, arcsinh, sinh, arctanh, tanh

Notes

arccosh is a multivalued function: for each x there are infinitely many numbers z such that cosh(z) = x. The convention is to return the z whose imaginary part lies in [-pi, pi] and the real part in [0, inf].

For real-valued input data types, arccosh always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.

For complex-valued input, arccosh is a complex analytical function that has a branch cut [-inf, 1] and is continuous from above on it.

References

1

M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 86. http://www.math.sfu.ca/~cbm/aands/

2

Wikipedia, “Inverse hyperbolic function”, https://en.wikipedia.org/wiki/Arccosh

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.arccosh(nps.array([nps.e, 10.0])).get()  
array([ 1.65745445,  2.99322285])
>>> nps.arccosh(nps.array(1)).get()  
array(0.0)
nums.numpy.api.generated.arcsin(x, out=None, where=True, **kwargs)[source]

Inverse sine, element-wise.

This docstring was copied from numpy.arcsin.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – y-coordinate on the unit circle.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

angle – The inverse sine of each element in x, in radians and in the closed interval [-pi/2, pi/2].

Return type

BlockArray

See also

sin, cos, arccos, tan, arctan, arctan2, emath.arcsin

Notes

arcsin is a multivalued function: for each x there are infinitely many numbers z such that \(sin(z) = x\). The convention is to return the angle z whose real part lies in [-pi/2, pi/2].

For real-valued input data types, arcsin always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.

For complex-valued input, arcsin is a complex analytic function that has, by convention, the branch cuts [-inf, -1] and [1, inf] and is continuous from above on the former and from below on the latter.

The inverse sine is also known as asin or sin^{-1}.

References

Abramowitz, M. and Stegun, I. A., Handbook of Mathematical Functions, 10th printing, New York: Dover, 1964, pp. 79ff. http://www.math.sfu.ca/~cbm/aands/

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.arcsin(nps.array(1)).get()     # pi/2  
array(1.57079633)
>>> nps.arcsin(nps.array(-1)).get()    # -pi/2  
array(-1.57079633)
>>> nps.arcsin(nps.array(0)).get()  
array(0.)
nums.numpy.api.generated.arcsinh(x, out=None, where=True, **kwargs)[source]

Inverse hyperbolic sine element-wise.

This docstring was copied from numpy.arcsinh.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Array of the same shape as x.

Return type

BlockArray or scalar

Notes

arcsinh is a multivalued function: for each x there are infinitely many numbers z such that sinh(z) = x. The convention is to return the z whose imaginary part lies in [-pi/2, pi/2].

For real-valued input data types, arcsinh always returns real output. For each value that cannot be expressed as a real number or infinity, it returns nan and sets the invalid floating point error flag.

For complex-valued input, arccos is a complex analytical function that has branch cuts [1j, infj] and [-1j, -infj] and is continuous from the right on the former and from the left on the latter.

The inverse hyperbolic sine is also known as asinh or sinh^-1.

References

1

M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 86. http://www.math.sfu.ca/~cbm/aands/

2

Wikipedia, “Inverse hyperbolic function”, https://en.wikipedia.org/wiki/Arcsinh

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.arcsinh(nps.array([nps.e, 10.0])).get()  
array([ 1.72538256,  2.99822295])
nums.numpy.api.generated.arctan(x, out=None, where=True, **kwargs)[source]

Trigonometric inverse tangent, element-wise.

The inverse of tan, so that if y = tan(x) then x = arctan(y).

This docstring was copied from numpy.arctan.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) –

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Out has the same shape as x. Its real part is in [-pi/2, pi/2] (arctan(+/-inf) returns +/-pi/2).

Return type

BlockArray or scalar

See also

arctan2

The “four quadrant” arctan of the angle formed by (x, y) and the positive x-axis.

angle

Argument of complex values.

Notes

arctan is a multi-valued function: for each x there are infinitely many numbers z such that tan(z) = x. The convention is to return the angle z whose real part lies in [-pi/2, pi/2].

For real-valued input data types, arctan always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.

For complex-valued input, arctan is a complex analytic function that has [1j, infj] and [-1j, -infj] as branch cuts, and is continuous from the left on the former and from the right on the latter.

The inverse tangent is also known as atan or tan^{-1}.

References

Abramowitz, M. and Stegun, I. A., Handbook of Mathematical Functions, 10th printing, New York: Dover, 1964, pp. 79. http://www.math.sfu.ca/~cbm/aands/

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

We expect the arctan of 0 to be 0, and of 1 to be pi/4:

>>> nps.arctan(nps.array([0, 1])).get()  
array([ 0.        ,  0.78539816])
>>> nps.pi/4  
0.78539816339744828
nums.numpy.api.generated.arctan2(x1, x2, out=None, where=True, **kwargs)[source]

Element-wise arc tangent of x1/x2 choosing the quadrant correctly.

This docstring was copied from numpy.arctan2.

Some inconsistencies with the NumS version may exist.

The quadrant (i.e., branch) is chosen so that arctan2(x1, x2) is the signed angle in radians between the ray ending at the origin and passing through the point (1,0), and the ray ending at the origin and passing through the point (x2, x1). (Note the role reversal: the “y-coordinate” is the first function parameter, the “x-coordinate” is the second.) By IEEE convention, this function is defined for x2 = +/-0 and for either or both of x1 and x2 = +/-inf (see Notes for specific values).

This function is not defined for complex-valued arguments; for the so-called argument of complex values, use angle.

Parameters
  • x1 (BlockArray, real-valued) – y-coordinates.

  • x2 (BlockArray, real-valued) – x-coordinates. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

angle – Array of angles in radians, in the range [-pi, pi].

Return type

BlockArray

See also

arctan, tan, angle

Notes

arctan2 is identical to the atan2 function of the underlying C library. The following special values are defined in the C standard: [1]_

x1

x2

arctan2(x1,x2)

+/- 0

+0

+/- 0

+/- 0

-0

+/- pi

> 0

+/-inf

+0 / +pi

< 0

+/-inf

-0 / -pi

+/-inf

+inf

+/- (pi/4)

+/-inf

-inf

+/- (3*pi/4)

Note that +0 and -0 are distinct floating point numbers, as are +inf and -inf.

References

1

ISO/IEC standard 9899:1999, “Programming language C.”

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

Consider four points in different quadrants:

>>> x = nps.array([-1, +1, +1, -1])  
>>> y = nps.array([-1, -1, +1, +1])  
>>> (nps.arctan2(y, x) * 180 / nps.pi).get()  
array([-135.,  -45.,   45.,  135.])

Note the order of the parameters. arctan2 is defined also when x2 = 0 and at several other special points, obtaining values in the range [-pi, pi]:

>>> nps.arctan2(nps.array([1., -1.]), nps.array([0., 0.])).get()  
array([ 1.57079633, -1.57079633])
>>> nps.arctan2(nps.array([0., 0., nps.inf]),
...     nps.array([+0., -0., nps.inf])).get()  
array([ 0.        ,  3.14159265,  0.78539816])
nums.numpy.api.generated.arctanh(x, out=None, where=True, **kwargs)[source]

Inverse hyperbolic tangent element-wise.

This docstring was copied from numpy.arctanh.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Array of the same shape as x.

Return type

BlockArray or scalar

Notes

arctanh is a multivalued function: for each x there are infinitely many numbers z such that tanh(z) = x. The convention is to return the z whose imaginary part lies in [-pi/2, pi/2].

For real-valued input data types, arctanh always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.

For complex-valued input, arctanh is a complex analytical function that has branch cuts [-1, -inf] and [1, inf] and is continuous from above on the former and from below on the latter.

The inverse hyperbolic tangent is also known as atanh or tanh^-1.

References

1

M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 86. http://www.math.sfu.ca/~cbm/aands/

2

Wikipedia, “Inverse hyperbolic function”, https://en.wikipedia.org/wiki/Arctanh

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.arctanh(nps.array([0, -0.5])).get()  
array([ 0.        , -0.54930614])
nums.numpy.api.generated.bitwise_and(x1, x2, out=None, where=True, **kwargs)[source]

Compute the bit-wise AND of two arrays element-wise.

This docstring was copied from numpy.bitwise_and.

Some inconsistencies with the NumS version may exist.

Computes the bit-wise AND of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator &.

Parameters
  • x1 (BlockArray) – Only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Result.

Return type

BlockArray or scalar

See also

logical_and, bitwise_or, bitwise_xor

binary_repr

Return the binary representation of the input number as a string.

Examples

The The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

number 13 is represented by 00001101. Likewise, 17 is represented by 00010001. The bit-wise AND of 13 and 17 is therefore 000000001, or 1:

>>> nps.bitwise_and(nps.array(13), nps.array(17)).get()  
array(1)
>>> nps.bitwise_and(nps.array([2,5,255]), nps.array([3,14,16])).get()  
array([ 2,  4, 16])
>>> nps.bitwise_and(nps.array([True, True]), nps.array([False, True])).get()  
array([False,  True])
nums.numpy.api.generated.bitwise_not(x, out=None, where=True, **kwargs)[source]

Compute bit-wise inversion, or bit-wise NOT, element-wise.

This docstring was copied from numpy.bitwise_not.

Some inconsistencies with the NumS version may exist.

Computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator ~.

For signed integer inputs, the two’s complement is returned. In a two’s-complement system negative numbers are represented by the two’s complement of the absolute value. This is the most common method of representing signed integers on computers [1]_. A N-bit two’s-complement system can represent every integer in the range \(-2^{N-1}\) to \(+2^{N-1}-1\).

Parameters
  • x (BlockArray) – Only integer and boolean types are handled.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Result.

Return type

BlockArray or scalar

See also

bitwise_and, bitwise_or, bitwise_xor, logical_not

binary_repr

Return the binary representation of the input number as a string.

References

1

Wikipedia, “Two’s complement”, https://en.wikipedia.org/wiki/Two’s_complement

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

We’ve seen that 13 is represented by 00001101. The invert or bit-wise NOT of 13 is then:

>>> x = nps.invert(nps.array(13, dtype=nps.uint8))  
>>> x.get()  
array(242, dtype=uint8)

The result depends on the bit-width:

>>> x = nps.invert(nps.array(13, dtype=nps.uint16)).get()  
>>> x  
65522
>>> nps.binary_repr(x, width=16).get()  
'1111111111110010'

When using signed integer types the result is the two’s complement of the result for the unsigned type:

>>> nps.invert(nps.array([13], dtype=nps.int8)).get()  
array([-14], dtype=int8)
>>> nps.binary_repr(-14, width=8).get()  
'11110010'

Booleans are accepted as well:

>>> nps.invert(nps.array([True, False])).get()  
array([False,  True])
nums.numpy.api.generated.bitwise_or(x1, x2, out=None, where=True, **kwargs)[source]

Compute the bit-wise OR of two arrays element-wise.

This docstring was copied from numpy.bitwise_or.

Some inconsistencies with the NumS version may exist.

Computes the bit-wise OR of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator |.

Parameters
  • x1 (BlockArray) – Only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Result.

Return type

BlockArray

See also

logical_or, bitwise_and, bitwise_xor

binary_repr

Return the binary representation of the input number as a string.

Examples

The The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

number 13 has the binaray representation 00001101. Likewise, 16 is represented by 00010000. The bit-wise OR of 13 and 16 is then 000111011, or 29:

>>> nps.bitwise_or(nps.array(13), nps.array(16)).get()  
array(29)
>>> nps.bitwise_or(nps.array([2, 5, 255]), nps.array([4, 4, 4])).get()  
array([  6,   5, 255])
>>> (nps.array([2, 5, 255]) | nps.array([4, 4, 4])).get()  
array([  6,   5, 255])
>>> nps.bitwise_or(nps.array([True, True]), nps.array([False, True])).get()  
array([ True,  True])
nums.numpy.api.generated.bitwise_xor(x1, x2, out=None, where=True, **kwargs)[source]

Compute the bit-wise XOR of two arrays element-wise.

This docstring was copied from numpy.bitwise_xor.

Some inconsistencies with the NumS version may exist.

Computes the bit-wise XOR of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator ^.

Parameters
  • x1 (BlockArray) – Only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Result.

Return type

BlockArray

See also

logical_xor, bitwise_and, bitwise_or

binary_repr

Return the binary representation of the input number as a string.

Examples

The The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

number 13 is represented by 00001101. Likewise, 17 is represented by 00010001. The bit-wise XOR of 13 and 17 is therefore 00011100, or 28:

>>> nps.bitwise_xor(nps.array(13), nps.array(17)).get()  
nps.array(28)
>>> nps.bitwise_xor(nps.array([31,3]), nps.array([5,6])).get()  
array([26,  5])
>>> nps.bitwise_xor(nps.array([True, True]), nps.array([False, True])).get()  
array([ True, False])
nums.numpy.api.generated.cbrt(x, out=None, where=True, **kwargs)[source]

Return the cube-root of an array, element-wise.

This docstring was copied from numpy.cbrt.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – The values whose cube-roots are required.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – An array of the same shape as x, containing the cube cube-root of each element in x. If out was provided, y is a reference to it.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.cbrt(nps.array([1,8,27])).get()  
array([ 1.,  2.,  3.])
nums.numpy.api.generated.ceil(x, out=None, where=True, **kwargs)[source]

Return the ceiling of the input, element-wise.

This docstring was copied from numpy.ceil.

Some inconsistencies with the NumS version may exist.

The ceil of the scalar x is the smallest integer i, such that i >= x. It is often denoted as :math:`lceil x

ceil`.

xBlockArray

Input data.

outBlockArray, None, or optional

A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

whereBlockArray, optional

This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

**kwargs

For other keyword-only arguments, see the ufunc docs.

yBlockArray or scalar

The ceiling of each element in x, with float dtype.

floor, trunc, rint

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> a = nps.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])  
>>> nps.ceil(a).get()  
array([-1., -1., -0.,  1.,  2.,  2.,  2.])
Return type

BlockArray

nums.numpy.api.generated.conj(x, out=None, where=True, **kwargs)[source]

Return the complex conjugate, element-wise.

This docstring was copied from numpy.conj.

Some inconsistencies with the NumS version may exist.

The complex conjugate of a complex number is obtained by changing the sign of its imaginary part.

Parameters
  • x (BlockArray) – Input value.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The complex conjugate of x, with same dtype as y.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.conjugate(nps.array(1+2j)).get()  
array(1.-2.j)
nums.numpy.api.generated.conjugate(x, out=None, where=True, **kwargs)[source]

Return the complex conjugate, element-wise.

This docstring was copied from numpy.conjugate.

Some inconsistencies with the NumS version may exist.

The complex conjugate of a complex number is obtained by changing the sign of its imaginary part.

Parameters
  • x (BlockArray) – Input value.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The complex conjugate of x, with same dtype as y.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.conjugate(nps.array(1+2j)).get()  
array(1.-2.j)
nums.numpy.api.generated.copysign(x1, x2, out=None, where=True, **kwargs)[source]

Change the sign of x1 to that of x2, element-wise.

This docstring was copied from numpy.copysign.

Some inconsistencies with the NumS version may exist.

If x2 is a scalar, its sign will be copied to all elements of x1.

Parameters
  • x1 (BlockArray) – Values to change the sign of.

  • x2 (BlockArray) – The sign of x2 is copied to x1. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – The values of x1 with the sign of x2.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.copysign(nps.array(1.3), nps.array(-1)).get()  
array(-1.3)
>>> (1/nps.copysign(nps.array(0), nps.array(1))).get()  
array(inf)
>>> (1/nps.copysign(nps.array(0), nps.array(-1))).get()  
array(-inf)
nums.numpy.api.generated.cos(x, out=None, where=True, **kwargs)[source]

Cosine element-wise.

This docstring was copied from numpy.cos.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array in radians.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The corresponding cosine values.

Return type

BlockArray

Notes

If out is provided, the function writes the result into it, and returns a reference to out. (See Examples)

References

M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions. New York, NY: Dover, 1972.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.cos(nps.array([0, nps.pi/2, nps.pi])).get()  
array([  1.00000000e+00,   6.12303177e-17,  -1.00000000e+00])
nums.numpy.api.generated.cosh(x, out=None, where=True, **kwargs)[source]

Hyperbolic cosine, element-wise.

This docstring was copied from numpy.cosh.

Some inconsistencies with the NumS version may exist.

Equivalent to 1/2 * (nps.exp(x) + nps.exp(-x)) and nps.cos(1j*x).get().

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Output array of same shape as x.

Return type

BlockArray or scalar

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.cosh(nps.array(0)).get()  
array(1.)
nums.numpy.api.generated.deg2rad(x, out=None, where=True, **kwargs)[source]

Convert angles from degrees to radians.

This docstring was copied from numpy.deg2rad.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Angles in degrees.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The corresponding angle in radians.

Return type

BlockArray

See also

rad2deg

Convert angles from radians to degrees.

unwrap

Remove large jumps in angle by wrapping.

Notes

deg2rad(x) is x * pi / 180.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.deg2rad(nps.array(180)).get()  
array(3.14159265)
nums.numpy.api.generated.degrees(x, out=None, where=True, **kwargs)[source]

Convert angles from radians to degrees.

This docstring was copied from numpy.degrees.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array in radians.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The corresponding degree values; if out was supplied this is a reference to it.

Return type

BlockArray of floats

See also

rad2deg

equivalent function

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

Convert a radian array to degrees

>>> rad = nps.arange(12.) *nps.pi/6  
>>> nps.degrees(rad).get()  
array([   0.,   30.,   60.,   90.,  120.,  150.,  180.,  210.,  240.,
        270.,  300.,  330.])
>>> out = nps.zeros((rad.shape))  
>>> r = nps.degrees(rad, out)  
>>> nps.all(r == out).get()  
array(True)
nums.numpy.api.generated.divide(x1, x2, out=None, where=True, **kwargs)[source]

Returns a true division of the inputs, element-wise.

This docstring was copied from numpy.divide.

Some inconsistencies with the NumS version may exist.

Instead of the Python traditional ‘floor division’, this returns a true division. True division adjusts the output type to present the best answer, regardless of input types.

Parameters
  • x1 (BlockArray) – Dividend array.

  • x2 (BlockArray) – Divisor array. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out

Return type

BlockArray or scalar

Notes

In Python, // is the floor division operator and / the true division operator. The true_divide(x1, x2) function is equivalent to true division in Python.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> x = nps.arange(5)  
>>> nps.true_divide(x, nps.array(4)).get()  
array([ 0.  ,  0.25,  0.5 ,  0.75,  1.  ])
>>> (x/4).get()  
array([ 0.  ,  0.25,  0.5 ,  0.75,  1.  ])
nums.numpy.api.generated.equal(x1, x2, out=None, where=True, **kwargs)[source]

Return (x1 == x2) element-wise.

This docstring was copied from numpy.equal.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.equal(nps.array([0, 1, 3]), nps.arange(3)).get()  
array([ True,  True, False])

What is compared are values, not types. So an int (1) and an array of length one can evaluate as True:

>>> nps.equal(nps.array(1), nps.ones(1)).get()  
array([ True])
nums.numpy.api.generated.exp(x, out=None, where=True, **kwargs)[source]

Calculate the exponential of all elements in the input array.

This docstring was copied from numpy.exp.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input values.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Output array, element-wise exponential of x.

Return type

BlockArray or scalar

See also

expm1

Calculate exp(x) - 1 for all elements in the array.

exp2

Calculate 2**x for all elements in the array.

Notes

The irrational number e is also known as Euler’s number. It is approximately 2.718281, and is the base of the natural logarithm, ln (this means that, if \(x = \ln y = \log_e y\), then \(e^x = y\). For real input, exp(x) is always positive.

For complex arguments, x = a + ib, we can write \(e^x = e^a e^{ib}\). The first term, \(e^a\), is already known (it is the real argument, described above). The second term, \(e^{ib}\), is \(\cos b + i \sin b\), a function with magnitude 1 and a periodic phase.

References

1

Wikipedia, “Exponential function”, https://en.wikipedia.org/wiki/Exponential_function

2

M. Abramovitz and I. A. Stegun, “Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables,” Dover, 1964, p. 69, http://www.math.sfu.ca/~cbm/aands/page_69.htm

nums.numpy.api.generated.exp2(x, out=None, where=True, **kwargs)[source]

Calculate 2**p for all p in the input array.

This docstring was copied from numpy.exp2.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input values.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Element-wise 2 to the power x.

Return type

BlockArray or scalar

See also

power

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.exp2(nps.array([2, 3])).get()  
array([ 4.,  8.])
nums.numpy.api.generated.expm1(x, out=None, where=True, **kwargs)[source]

Calculate exp(x) - 1 for all elements in the array.

This docstring was copied from numpy.expm1.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input values.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Element-wise exponential minus one: out = exp(x) - 1.

Return type

BlockArray or scalar

See also

log1p

log(1 + x), the inverse of expm1.

Notes

This function provides greater precision than exp(x) - 1 for small values of x.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

The true value of exp(1e-10) - 1 is 1.00000000005e-10 to about 32 significant digits. This example shows the superiority of expm1 in this case.

>>> nps.expm1(nps.array(1e-10)).get()  
array(1.e-10)
>>> nps.exp(nps.array(1e-10)).get() - 1  
1.000000082740371e-10
nums.numpy.api.generated.fabs(x, out=None, where=True, **kwargs)[source]

Compute the absolute values element-wise.

This docstring was copied from numpy.fabs.

Some inconsistencies with the NumS version may exist.

This function returns the absolute values (positive magnitude) of the data in x. Complex values are not handled, use absolute to find the absolute values of complex data.

Parameters
  • x (BlockArray) – The array of numbers for which the absolute values are required. If x is a scalar, the result y will also be a scalar.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The absolute values of x, the returned values are always floats.

Return type

BlockArray or scalar

See also

absolute

Absolute values including complex types.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.fabs(nps.array(-1)).get()  
array(1.)
>>> nps.fabs(nps.array([-1.2, 1.2])).get()  
array([ 1.2,  1.2])
nums.numpy.api.generated.float_power(x1, x2, out=None, where=True, **kwargs)[source]

First array elements raised to powers from second array, element-wise.

This docstring was copied from numpy.float_power.

Some inconsistencies with the NumS version may exist.

Raise each base in x1 to the positionally-corresponding power in x2. x1 and x2 must be broadcastable to the same shape. This differs from the power function in that integers, float16, and float32 are promoted to floats with a minimum precision of float64 so that the result is always inexact. The intent is that the function will return a usable result for negative powers and seldom overflow for positive powers.

Parameters
  • x1 (BlockArray) – The bases.

  • x2 (BlockArray) – The exponents. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The bases in x1 raised to the exponents in x2.

Return type

BlockArray

See also

power

power function that preserves type

nums.numpy.api.generated.floor(x, out=None, where=True, **kwargs)[source]

Return the floor of the input, element-wise.

This docstring was copied from numpy.floor.

Some inconsistencies with the NumS version may exist.

The floor of the scalar x is the largest integer i, such that i <= x. It is often denoted as :math:`lfloor x

floor`.

xBlockArray

Input data.

outBlockArray, None, or optional

A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

whereBlockArray, optional

This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

**kwargs

For other keyword-only arguments, see the ufunc docs.

yBlockArray or scalar

The floor of each element in x.

ceil, trunc, rint

Some spreadsheet programs calculate the “floor-towards-zero”, in other words floor(-2.5) == -2. NumPy instead uses the definition of floor where floor(-2.5) == -3.

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> a = nps.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])  
>>> nps.floor(a).get()  
array([-2., -2., -1.,  0.,  1.,  1.,  2.])
Return type

BlockArray

nums.numpy.api.generated.floor_divide(x1, x2, out=None, where=True, **kwargs)[source]

Return the largest integer smaller or equal to the division of the inputs. It is equivalent to the Python // operator and pairs with the Python % (remainder), function so that a = a % b + b * (a // b) up to roundoff.

This docstring was copied from numpy.floor_divide.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Numerator.

  • x2 (BlockArray) – Denominator. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – y = floor(x1/x2)

Return type

BlockArray

See also

remainder

Remainder complementary to floor_divide.

divmod

Simultaneous floor division and remainder.

divide

Standard division.

floor

Round a number to the nearest integer toward minus infinity.

ceil

Round a number to the nearest integer toward infinity.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.floor_divide(nps.array(7),nps.array(3)).get()  
nps.array(2)
>>> nps.floor_divide(nps.array([1., 2., 3., 4.]), nps.array(2.5)).get()  
array([ 0.,  0.,  1.,  1.])
nums.numpy.api.generated.fmax(x1, x2, out=None, where=True, **kwargs)[source]

Element-wise maximum of array elements.

This docstring was copied from numpy.fmax.

Some inconsistencies with the NumS version may exist.

Compare two arrays and returns a new array containing the element-wise maxima. If one of the elements being compared is a NaN, then the non-nan element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are ignored when possible.

Parameters
  • x1 (BlockArray) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The maximum of x1 and x2, element-wise.

Return type

BlockArray

See also

fmin

Element-wise minimum of two arrays, ignores NaNs.

maximum

Element-wise maximum of two arrays, propagates NaNs.

amax

The maximum value of an array along a given axis, propagates NaNs.

nanmax

The maximum value of an array along a given axis, ignores NaNs.

minimum, amin, nanmin

Notes

The fmax is equivalent to nps.where(x1 >= x2, x1, x2).get() when neither x1 nor x2 are NaNs, but it is faster and does proper broadcasting.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.fmax(nps.array([2, 3, 4]), nps.array([1, 5, 2])).get()  
array([ 2.,  5.,  4.])
>>> nps.fmax(nps.eye(2), nps.array([0.5, 2])).get()  
array([[ 1. ,  2. ],
       [ 0.5,  2. ]])
>>> nps.fmax(nps.array([nps.nan, 0, nps.nan]),
...     nps.array([0, nps.nan, nps.nan])).get()  
array([ 0.,  0., nan])
nums.numpy.api.generated.fmin(x1, x2, out=None, where=True, **kwargs)[source]

Element-wise minimum of array elements.

This docstring was copied from numpy.fmin.

Some inconsistencies with the NumS version may exist.

Compare two arrays and returns a new array containing the element-wise minima. If one of the elements being compared is a NaN, then the non-nan element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are ignored when possible.

Parameters
  • x1 (BlockArray) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The minimum of x1 and x2, element-wise.

Return type

BlockArray

See also

fmax

Element-wise maximum of two arrays, ignores NaNs.

minimum

Element-wise minimum of two arrays, propagates NaNs.

amin

The minimum value of an array along a given axis, propagates NaNs.

nanmin

The minimum value of an array along a given axis, ignores NaNs.

maximum, amax, nanmax

Notes

The fmin is equivalent to nps.where(x1 <= x2, x1, x2).get() when neither x1 nor x2 are NaNs, but it is faster and does proper broadcasting.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.fmin(nps.array([2, 3, 4]), nps.array([1, 5, 2])).get()  
array([1, 3, 2])
>>> nps.fmin(nps.eye(2), nps.array([0.5, 2])).get()  
array([[ 0.5,  0. ],
       [ 0. ,  1. ]])
>>> nps.fmin(nps.array([nps.nan, 0, nps.nan]),
...     nps.array([0, nps.nan, nps.nan])).get()  
array([ 0.,  0., nan])
nums.numpy.api.generated.fmod(x1, x2, out=None, where=True, **kwargs)[source]

Return the element-wise remainder of division.

This docstring was copied from numpy.fmod.

Some inconsistencies with the NumS version may exist.

This is the NumPy implementation of the C library function fmod, the remainder has the same sign as the dividend x1. It is equivalent to the Matlab(TM) rem function and should not be confused with the Python modulus operator x1 % x2.

Parameters
  • x1 (BlockArray) – Dividend.

  • x2 (BlockArray) – Divisor. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The remainder of the division of x1 by x2.

Return type

BlockArray

See also

remainder

Equivalent to the Python % operator.

divide

Notes

The result of the modulo operation for negative dividend and divisors is bound by conventions. For fmod, the sign of result is the sign of the dividend, while for remainder the sign of the result is the sign of the divisor. The fmod function is equivalent to the Matlab(TM) rem function.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.fmod(nps.array([-3, -2, -1, 1, 2, 3]), nps.array(2)).get()  
array([-1,  0, -1,  1,  0,  1])
>>> nps.remainder(nps.array([-3, -2, -1, 1, 2, 3]), nps.array(2)).get()  
array([1, 0, 1, 1, 0, 1])
>>> nps.fmod(nps.array([5, 3]), nps.array([2, 2.])).get()  
array([ 1.,  1.])
>>> a = nps.arange(-3, 3).reshape(3, 2)  
>>> a.get()  
array([[-3, -2],
       [-1,  0],
       [ 1,  2]])
>>> nps.fmod(a, nps.array([2,2])).get()  
array([[-1,  0],
       [-1,  0],
       [ 1,  0]])
nums.numpy.api.generated.gcd(x1, x2, out=None, where=True, **kwargs)[source]

Returns the greatest common divisor of |x1| and |x2|

This docstring was copied from numpy.gcd.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray, int) – Arrays of values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray, int) – Arrays of values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The greatest common divisor of the absolute value of the inputs

Return type

BlockArray

See also

lcm

The lowest common multiple

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.gcd(nps.array(12), nps.array(20)).get()  
array(4)
>>> nps.gcd(nps.arange(6), nps.array(20)).get()  
array([20,  1,  2,  1,  4,  5])
nums.numpy.api.generated.greater(x1, x2, out=None, where=True, **kwargs)[source]

Return the truth value of (x1 > x2) element-wise.

This docstring was copied from numpy.greater.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.greater(nps.array([4,2]),nps.array([2,2])).get()  
array([ True, False])

If the inputs are BlockArray, then nps.greater is equivalent to ‘>’.

>>> a = nps.array([4,2])  
>>> b = nps.array([2,2])  
>>> (a > b).get()  
array([ True, False])
nums.numpy.api.generated.greater_equal(x1, x2, out=None, where=True, **kwargs)[source]

Return the truth value of (x1 >= x2) element-wise.

This docstring was copied from numpy.greater_equal.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed.

Return type

BlockArray of bool

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.greater_equal(nps.array([4, 2, 1]), nps.array([2, 2, 2])).get()  
array([ True, True, False])
nums.numpy.api.generated.heaviside(x1, x2, out=None, where=True, **kwargs)[source]

Compute the Heaviside step function.

This docstring was copied from numpy.heaviside.

Some inconsistencies with the NumS version may exist.

The Heaviside step function is defined as:

                      0   if x1 < 0
heaviside(x1, x2) =  x2   if x1 == 0
                      1   if x1 > 0

where x2 is often taken to be 0.5, but 0 and 1 are also sometimes used.

Parameters
  • x1 (BlockArray) – Input values.

  • x2 (BlockArray) – The value of the function when x1 is 0. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – The output array, element-wise Heaviside step function of x1.

Return type

BlockArray

References

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.heaviside(nps.array([-1.5, 0, 2.0]), nps.array(0.5)).get()  
array([ 0. ,  0.5,  1. ])
>>> nps.heaviside(nps.array([-1.5, 0, 2.0]), nps.array(1)).get()  
array([ 0.,  1.,  1.])
nums.numpy.api.generated.hypot(x1, x2, out=None, where=True, **kwargs)[source]

Given the “legs” of a right triangle, return its hypotenuse.

This docstring was copied from numpy.hypot.

Some inconsistencies with the NumS version may exist.

Equivalent to sqrt(x1**2 + x2**2), element-wise. If x1 or x2 is scalar_like (i.e., unambiguously cast-able to a scalar type), it is broadcast for use with each element of the other argument. (See Examples)

Parameters
  • x1 (BlockArray) – Leg of the triangle(s). If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Leg of the triangle(s). If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

z – The hypotenuse of the triangle(s).

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.hypot(3*nps.ones((3, 3)), 4*nps.ones((3, 3))).get()  
array([[ 5.,  5.,  5.],
       [ 5.,  5.,  5.],
       [ 5.,  5.,  5.]])

Example showing broadcast of scalar_like argument:

>>> nps.hypot(3*nps.ones((3, 3)), nps.array([4])).get()  
array([[ 5.,  5.,  5.],
       [ 5.,  5.,  5.],
       [ 5.,  5.,  5.]])
nums.numpy.api.generated.invert(x, out=None, where=True, **kwargs)[source]

Compute bit-wise inversion, or bit-wise NOT, element-wise.

This docstring was copied from numpy.invert.

Some inconsistencies with the NumS version may exist.

Computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator ~.

For signed integer inputs, the two’s complement is returned. In a two’s-complement system negative numbers are represented by the two’s complement of the absolute value. This is the most common method of representing signed integers on computers [1]_. A N-bit two’s-complement system can represent every integer in the range \(-2^{N-1}\) to \(+2^{N-1}-1\).

Parameters
  • x (BlockArray) – Only integer and boolean types are handled.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Result.

Return type

BlockArray or scalar

See also

bitwise_and, bitwise_or, bitwise_xor, logical_not

binary_repr

Return the binary representation of the input number as a string.

References

1

Wikipedia, “Two’s complement”, https://en.wikipedia.org/wiki/Two’s_complement

Examples

We’vThe doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

e seen that 13 is represented by 00001101. The invert or bit-wise NOT of 13 is then:

>>> x = nps.invert(nps.array(13, dtype=nps.uint8))  
>>> x.get()  
array(242, dtype=uint8)

When using signed integer types the result is the two’s complement of the result for the unsigned type:

>>> nps.invert(nps.array([13], dtype=nps.int8)).get()  
array([-14], dtype=int8)

Booleans are accepted as well:

>>> nps.invert(nps.array([True, False])).get()  
array([False,  True])
nums.numpy.api.generated.isfinite(x, out=None, where=True, **kwargs)[source]

Test element-wise for finiteness (not infinity or not Not a Number).

This docstring was copied from numpy.isfinite.

Some inconsistencies with the NumS version may exist.

The result is returned as a boolean array.

Parameters
  • x (BlockArray) – Input values.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – True where x is not positive infinity, negative infinity, or NaN; false otherwise.

Return type

BlockArray, bool

See also

isinf, isneginf, isposinf, isnan

Notes

Not a Number, positive infinity and negative infinity are considered to be non-finite.

NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Also that positive infinity is not equivalent to negative infinity. But infinity is equivalent to positive infinity. Errors result if the second argument is also supplied when x is a scalar input, or if first and second arguments have different shapes.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.isfinite(nps.array(1)).get()  
array(True)
>>> nps.isfinite(nps.array(0)).get()  
array(True)
>>> nps.isfinite(nps.array(nps.nan)).get()  
array(False)
>>> nps.isfinite(nps.array(nps.inf)).get()  
array(False)
>>> nps.isfinite(nps.array(nps.NINF)).get()  
array(False)
>>> x = nps.array([-nps.inf, 0., nps.inf])  
>>> y = nps.array([2, 2, 2])  
>>> nps.isfinite(x, y).get()  
array([0, 1, 0])
>>> y.get()  
array([0, 1, 0])
nums.numpy.api.generated.isinf(x, out=None, where=True, **kwargs)[source]

Test element-wise for positive or negative infinity.

This docstring was copied from numpy.isinf.

Some inconsistencies with the NumS version may exist.

Returns a boolean array of the same shape as x, True where x == +/-inf, otherwise False.

Parameters
  • x (BlockArray) – Input values

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – True where x is positive or negative infinity, false otherwise.

Return type

boolean BlockArray

See also

isneginf, isposinf, isnan, isfinite

Notes

NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754).

Errors result if the second argument is supplied when the first argument is a scalar, or if the first and second arguments have different shapes.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.isinf(nps.array(nps.inf)).get()  
array(True)
>>> nps.isinf(nps.array(nps.nan)).get()  
array(False)
>>> nps.isinf(nps.array(nps.NINF)).get()  
array(True)
>>> nps.isinf(nps.array([nps.inf, -nps.inf, 1.0, nps.nan])).get()  
array([ True,  True, False, False])
>>> x = nps.array([-nps.inf, 0., nps.inf])  
>>> y = nps.array([2, 2, 2])  
>>> nps.isinf(x, y).get()  
array([1, 0, 1])
>>> y.get()  
array([1, 0, 1])
nums.numpy.api.generated.isnan(x, out=None, where=True, **kwargs)[source]

Test element-wise for NaN and return result as a boolean array.

This docstring was copied from numpy.isnan.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – True where x is NaN, false otherwise.

Return type

BlockArray or bool

See also

isinf, isneginf, isposinf, isfinite, isnat

Notes

NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get(). # doctest: +SKIP

>>> nps.isnan(nps.array(nps.nan)).get()
array(True)
>>> nps.isnan(nps.array(nps.inf)).get()  
array(False)
nums.numpy.api.generated.lcm(x1, x2, out=None, where=True, **kwargs)[source]

This docstring was copied from numpy.lcm.

Some inconsistencies with the NumS version may exist.

Returns the lowest common multiple of |x1| and |x2|

Parameters
  • x1 (BlockArray, int) – Arrays of values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray, int) – Arrays of values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

Returns

y – The lowest common multiple of the absolute value of the inputs

Return type

BlockArray

See also

gcd

The greatest common divisor

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.lcm(nps.array(12), nps.array(20)).get()  
array(60)
>>> nps.lcm(nps.arange(6), nps.array(20)).get()  
array([ 0, 20, 20, 60, 20, 20])
nums.numpy.api.generated.ldexp(x1, x2, out=None, where=True, **kwargs)[source]

Returns x1 * 2**x2, element-wise.

This docstring was copied from numpy.ldexp.

Some inconsistencies with the NumS version may exist.

The mantissas x1 and twos exponents x2 are used to construct floating point numbers x1 * 2**x2.

Parameters
  • x1 (BlockArray) – Array of multipliers.

  • x2 (BlockArray, int) – Array of twos exponents. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The result of x1 * 2**x2.

Return type

BlockArray

See also

frexp

Return (y1, y2) from x = y1 * 2**y2, inverse to ldexp.

Notes

Complex dtypes are not supported, they will raise a TypeError.

ldexp is useful as the inverse of frexp, if used by itself it is more clear to simply use the expression x1 * 2**x2.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> x = nps.arange(6)  
>>> nps.ldexp(*nps.frexp(x)).get()  
array([ 0.,  1.,  2.,  3.,  4.,  5.])
nums.numpy.api.generated.left_shift(x1, x2, out=None, where=True, **kwargs)[source]

Shift the bits of an integer to the left.

This docstring was copied from numpy.left_shift.

Some inconsistencies with the NumS version may exist.

Bits are shifted to the left by appending x2 0s at the right of x1. Since the internal representation of numbers is in binary format, this operation is equivalent to multiplying x1 by 2**x2.

Parameters
  • x1 (BlockArray of integer type) – Input values.

  • x2 (BlockArray of integer type) – Number of zeros to append to x1. Has to be non-negative. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Return x1 with bits shifted x2 times to the left.

Return type

array of integer type

See also

right_shift

Shift the bits of an integer to the right.

binary_repr

Return the binary representation of the input number as a string.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.left_shift(nps.array(5), nps.array(2)).get()  
array(20)

Note that the dtype of the second argument may change the dtype of the result and can lead to unexpected results in some cases (see Casting Rules):

>>> a = nps.left_shift(nps.array(255, dtype=nps.uint8),
...     nps.array(1)) # Expect 254  
>>> print(a, type(a)) # Unexpected result due to upcasting  
510 <class 'nums.core.array.blockarray.BlockArray'>
nums.numpy.api.generated.less(x1, x2, out=None, where=True, **kwargs)[source]

Return the truth value of (x1 < x2) element-wise.

This docstring was copied from numpy.less.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.less(nps.array([1, 2]), nps.array([2, 2])).get()  
array([ True, False])
nums.numpy.api.generated.less_equal(x1, x2, out=None, where=True, **kwargs)[source]

Return the truth value of (x1 =< x2) element-wise.

This docstring was copied from numpy.less_equal.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.less_equal(nps.array([4, 2, 1]), nps.array([2, 2, 2])).get()  
array([False,  True,  True])
nums.numpy.api.generated.log(x, out=None, where=True, **kwargs)[source]

Natural logarithm, element-wise.

This docstring was copied from numpy.log.

Some inconsistencies with the NumS version may exist.

The natural logarithm log is the inverse of the exponential function, so that log(exp(x)) = x. The natural logarithm is logarithm in base e.

Parameters
  • x (BlockArray) – Input value.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The natural logarithm of x, element-wise.

Return type

BlockArray

See also

log10, log2, log1p

Notes

Logarithm is a multivalued function: for each x there is an infinite number of z such that exp(z) = x. The convention is to return the z whose imaginary part lies in [-pi, pi].

For real-valued input data types, log always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.

For complex-valued input, log is a complex analytical function that has a branch cut [-inf, 0] and is continuous from above on it. log handles the floating-point negative zero as an infinitesimal negative number, conforming to the C99 standard.

References

1

M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 67. http://www.math.sfu.ca/~cbm/aands/

2

Wikipedia, “Logarithm”. https://en.wikipedia.org/wiki/Logarithm

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.log(nps.array([1, nps.e, nps.e**2, 0])).get()  
array([  0.,   1.,   2., -Inf])
nums.numpy.api.generated.log10(x, out=None, where=True, **kwargs)[source]

Return the base 10 logarithm of the input array, element-wise.

This docstring was copied from numpy.log10.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input values.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The logarithm to the base 10 of x, element-wise. NaNs are returned where x is negative.

Return type

BlockArray

Notes

Logarithm is a multivalued function: for each x there is an infinite number of z such that 10**z = x. The convention is to return the z whose imaginary part lies in [-pi, pi].

For real-valued input data types, log10 always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.

For complex-valued input, log10 is a complex analytical function that has a branch cut [-inf, 0] and is continuous from above on it. log10 handles the floating-point negative zero as an infinitesimal negative number, conforming to the C99 standard.

References

1

M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 67. http://www.math.sfu.ca/~cbm/aands/

2

Wikipedia, “Logarithm”. https://en.wikipedia.org/wiki/Logarithm

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.log10(nps.array([1e-15, -3.])).get()  
array([-15.,  nan])
nums.numpy.api.generated.log1p(x, out=None, where=True, **kwargs)[source]

Return the natural logarithm of one plus the input array, element-wise.

This docstring was copied from numpy.log1p.

Some inconsistencies with the NumS version may exist.

Calculates log(1 + x).

Parameters
  • x (BlockArray) – Input values.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – Natural logarithm of 1 + x, element-wise.

Return type

BlockArray

See also

expm1

exp(x) - 1, the inverse of log1p.

Notes

For real-valued input, log1p is accurate also for x so small that 1 + x == 1 in floating-point accuracy.

Logarithm is a multivalued function: for each x there is an infinite number of z such that exp(z) = 1 + x. The convention is to return the z whose imaginary part lies in [-pi, pi].

For real-valued input data types, log1p always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.

For complex-valued input, log1p is a complex analytical function that has a branch cut [-inf, -1] and is continuous from above on it. log1p handles the floating-point negative zero as an infinitesimal negative number, conforming to the C99 standard.

References

1

M. Abramowitz and I.A. Stegun, “Handbook of Mathematical Functions”, 10th printing, 1964, pp. 67. http://www.math.sfu.ca/~cbm/aands/

2

Wikipedia, “Logarithm”. https://en.wikipedia.org/wiki/Logarithm

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.log1p(nps.array(1e-99)).get()  
array(1.e-99)
>>> nps.log(nps.array(1 + 1e-99)).get()  
array(0.)
nums.numpy.api.generated.log2(x, out=None, where=True, **kwargs)[source]

Base-2 logarithm of x.

This docstring was copied from numpy.log2.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input values.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – Base-2 logarithm of x.

Return type

BlockArray

See also

log, log10, log1p

Notes

Logarithm is a multivalued function: for each x there is an infinite number of z such that 2**z = x. The convention is to return the z whose imaginary part lies in [-pi, pi].

For real-valued input data types, log2 always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.

For complex-valued input, log2 is a complex analytical function that has a branch cut [-inf, 0] and is continuous from above on it. log2 handles the floating-point negative zero as an infinitesimal negative number, conforming to the C99 standard.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> x = nps.array([0, 1, 2, 2**4])  
>>> nps.log2(x).get()  
array([-Inf,   0.,   1.,   4.])
>>> xi = nps.array([0+1.j, 1, 2+0.j, 4.j])  
>>> nps.log2(xi).get()  
array([ 0.+2.26618007j,  0.+0.j        ,  1.+0.j        ,  2.+2.26618007j])
nums.numpy.api.generated.logaddexp(x1, x2, out=None, where=True, **kwargs)[source]

Logarithm of the sum of exponentiations of the inputs.

This docstring was copied from numpy.logaddexp.

Some inconsistencies with the NumS version may exist.

Calculates log(exp(x1) + exp(x2)). This function is useful in statistics where the calculated probabilities of events may be so small as to exceed the range of normal floating point numbers. In such cases the logarithm of the calculated probability is stored. This function allows adding probabilities stored in such a fashion.

Parameters
  • x1 (BlockArray) – Input values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Input values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

result – Logarithm of exp(x1) + exp(x2).

Return type

BlockArray

See also

logaddexp2

Logarithm of the sum of exponentiations of inputs in base 2.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> prob1 = nps.log(nps.array(1e-50))  
>>> prob2 = nps.log(nps.array(2.5e-50))  
>>> prob12 = nps.logaddexp(prob1, prob2)  
>>> prob12.get()  
array(-113.87649168)
>>> nps.exp(prob12).get()  
array(3.5e-50)
nums.numpy.api.generated.logaddexp2(x1, x2, out=None, where=True, **kwargs)[source]

Logarithm of the sum of exponentiations of the inputs in base-2.

This docstring was copied from numpy.logaddexp2.

Some inconsistencies with the NumS version may exist.

Calculates log2(2**x1 + 2**x2). This function is useful in machine learning when the calculated probabilities of events may be so small as to exceed the range of normal floating point numbers. In such cases the base-2 logarithm of the calculated probability can be used instead. This function allows adding probabilities stored in such a fashion.

Parameters
  • x1 (BlockArray) – Input values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Input values. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

result – Base-2 logarithm of 2**x1 + 2**x2.

Return type

BlockArray

See also

logaddexp

Logarithm of the sum of exponentiations of the inputs.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get(). >>> prob1 = nps.log(nps.array(1e-50)) # doctest: +SKIP >>> prob2 = nps.log(nps.array(2.5e-50)) # doctest: +SKIP >>> prob12 = nps.logaddexp2(prob1, prob2) # doctest: +SKIP >>> prob1.get(), prob2.get(), prob12.get() # doctest: +SKIP (array(-115.12925465), array(-114.21296392), array(-113.59955523)) >>> 2**prob12 # doctest: +SKIP array(6.35515844e-35)

nums.numpy.api.generated.logical_and(x1, x2, out=None, where=True, **kwargs)[source]

Compute the truth value of x1 AND x2 element-wise.

This docstring was copied from numpy.logical_and.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – Boolean result of the logical AND operation applied to the elements of x1 and x2; the shape is determined by broadcasting.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.logical_and(nps.array(True), nps.array(False)).get()  
array(False)
>>> nps.logical_and(nps.array([True, False]), nps.array([False, False])).get()  
array([False, False])
>>> x = nps.arange(5)  
>>> nps.logical_and(x>1, x<4).get()  
array([False, False,  True,  True, False])
nums.numpy.api.generated.logical_not(x, out=None, where=True, **kwargs)[source]

Compute the truth value of NOT x element-wise.

This docstring was copied from numpy.logical_not.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Logical NOT is applied to the elements of x.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – Boolean result with the same shape as x of the NOT operation on elements of x.

Return type

BlockArray of bool

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.logical_not(nps.array(3)).get()  
array(False)
>>> nps.logical_not(nps.array([True, False, 0, 1])).get()  
array([False,  True,  True, False])
>>> x = nps.arange(5)  
>>> nps.logical_not(x<3).get()  
array([False, False, False,  True,  True])
nums.numpy.api.generated.logical_or(x1, x2, out=None, where=True, **kwargs)[source]

Compute the truth value of x1 OR x2 element-wise.

This docstring was copied from numpy.logical_or.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Logical OR is applied to the elements of x1 and x2. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Logical OR is applied to the elements of x1 and x2. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – Boolean result of the logical OR operation applied to the elements of x1 and x2; the shape is determined by broadcasting.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.logical_or(nps.array(True), nps.array(False)).get()  
array(True)
>>> nps.logical_or(nps.array([True, False]), nps.array([False, False])).get()  
array([ True, False])
>>> x = nps.arange(5)  
>>> nps.logical_or(x < 1, x > 3).get()  
array([ True, False, False, False,  True])
nums.numpy.api.generated.logical_xor(x1, x2, out=None, where=True, **kwargs)[source]

Compute the truth value of x1 XOR x2, element-wise.

This docstring was copied from numpy.logical_xor.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Logical XOR is applied to the elements of x1 and x2. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Logical XOR is applied to the elements of x1 and x2. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – Boolean result of the logical XOR operation applied to the elements of x1 and x2; the shape is determined by broadcasting.

Return type

BlockArray of bool

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.logical_xor(nps.array(True), nps.array(False)).get()  
array(True)
>>> nps.logical_xor(nps.array([True, True, False, False]),
...     nps.array([True, False, True, False])).get()  
array([False,  True,  True, False])
>>> x = nps.arange(5)  
>>> nps.logical_xor(x < 1, x > 3).get()  
array([ True, False, False, False,  True])
nums.numpy.api.generated.maximum(x1, x2, out=None, where=True, **kwargs)[source]

Element-wise maximum of array elements.

This docstring was copied from numpy.maximum.

Some inconsistencies with the NumS version may exist.

Compare two arrays and returns a new array containing the element-wise maxima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are propagated.

Parameters
  • x1 (BlockArray) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The maximum of x1 and x2, element-wise.

Return type

BlockArray

See also

minimum

Element-wise minimum of two arrays, propagates NaNs.

fmax

Element-wise maximum of two arrays, ignores NaNs.

amax

The maximum value of an array along a given axis, propagates NaNs.

nanmax

The maximum value of an array along a given axis, ignores NaNs.

fmin, amin, nanmin

Notes

The maximum is equivalent to nps.where(x1 >= x2, x1, x2).get() when neither x1 nor x2 are nans, but it is faster and does proper broadcasting.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.maximum(nps.array([2, 3, 4]), nps.array([1, 5, 2])).get()  
array([2, 5, 4])
>>> nps.maximum(nps.eye(2), nps.array([0.5, 2])).get() # broadcasting  
array([[ 1. ,  2. ],
       [ 0.5,  2. ]])
>>> nps.maximum(nps.array([nps.nan, 0, nps.nan]),
...     nps.array([0, nps.nan, nps.nan])).get()  
array([nan, nan, nan])
>>> nps.maximum(nps.array(nps.Inf), nps.array(1)).get()  
arrray(inf)
nums.numpy.api.generated.minimum(x1, x2, out=None, where=True, **kwargs)[source]

Element-wise minimum of array elements.

This docstring was copied from numpy.minimum.

Some inconsistencies with the NumS version may exist.

Compare two arrays and returns a new array containing the element-wise minima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are propagated.

Parameters
  • x1 (BlockArray) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – The arrays holding the elements to be compared. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The minimum of x1 and x2, element-wise.

Return type

BlockArray

See also

maximum

Element-wise maximum of two arrays, propagates NaNs.

fmin

Element-wise minimum of two arrays, ignores NaNs.

amin

The minimum value of an array along a given axis, propagates NaNs.

nanmin

The minimum value of an array along a given axis, ignores NaNs.

fmax, amax, nanmax

Notes

The minimum is equivalent to nps.where(x1 <= x2, x1, x2).get() when neither x1 nor x2 are NaNs, but it is faster and does proper broadcasting.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.minimum(nps.array([2, 3, 4]), nps.array([1, 5, 2])).get()  
array([1, 3, 2])
>>> nps.minimum(nps.eye(2), nps.array([0.5, 2])).get() # broadcasting  
array([[ 0.5,  0. ],
       [ 0. ,  1. ]])
>>> nps.minimum(nps.array([nps.nan, 0, nps.nan]),
...     nps.array([0, nps.nan, nps.nan])).get()  
array([nan, nan, nan])
>>> nps.minimum(nps.array(-nps.Inf), nps.array(1)).get()  
array(-inf)
nums.numpy.api.generated.mod(x1, x2, out=None, where=True, **kwargs)[source]

Return element-wise remainder of division.

This docstring was copied from numpy.mod.

Some inconsistencies with the NumS version may exist.

Computes the remainder complementary to the floor_divide function. It is equivalent to the Python modulus operator``x1 % x2`` and has the same sign as the divisor x2. The MATLAB function equivalent to nps.remainder is mod.

Parameters
  • x1 (BlockArray) – Dividend array.

  • x2 (BlockArray) – Divisor array. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The element-wise remainder of the quotient floor_divide(x1, x2).

Return type

BlockArray

See also

floor_divide

Equivalent of Python // operator.

divmod

Simultaneous floor division and remainder.

fmod

Equivalent of the MATLAB rem function.

divide, floor

Notes

Returns 0 when x2 is 0 and both x1 and x2 are (arrays of) integers. mod is an alias of remainder.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.remainder(nps.array([4, 7]), nps.array([2, 3])).get()  
array([0, 1])
>>> nps.remainder(nps.arange(7), nps.array(5)).get()  
array([0, 1, 2, 3, 4, 0, 1])
nums.numpy.api.generated.multiply(x1, x2, out=None, where=True, **kwargs)[source]

Multiply arguments element-wise.

This docstring was copied from numpy.multiply.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Input arrays to be multiplied. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Input arrays to be multiplied. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The product of x1 and x2, element-wise.

Return type

BlockArray

Notes

Equivalent to x1 * x2 in terms of array broadcasting.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.multiply(nps.array(2.0), nps.array(4.0)).get()  
array(8.)
>>> x1 = nps.arange(9.0).reshape((3, 3))  
>>> x2 = nps.arange(3.0)  
>>> nps.multiply(x1, x2).get()  
array([[  0.,   1.,   4.],
       [  0.,   4.,  10.],
       [  0.,   7.,  16.]])
nums.numpy.api.generated.negative(x, out=None, where=True, **kwargs)[source]

Numerical negative, element-wise.

This docstring was copied from numpy.negative.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray or scalar) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – Returned array or scalar: y = -x.

Return type

BlockArray or scalar

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.negative(nps.array([1.,-1.])).get()  
array([-1.,  1.])
nums.numpy.api.generated.nextafter(x1, x2, out=None, where=True, **kwargs)[source]

Return the next floating-point value after x1 towards x2, element-wise.

This docstring was copied from numpy.nextafter.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – Values to find the next representable value of.

  • x2 (BlockArray) – The direction where to look for the next representable value of x1. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – The next representable values of x1 in the direction of x2.

Return type

BlockArray

nums.numpy.api.generated.not_equal(x1, x2, out=None, where=True, **kwargs)[source]

This docstring was copied from numpy.not_equal.

Some inconsistencies with the NumS version may exist.

Return (x1 != x2) element-wise.

Parameters
  • x1 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed.

Return type

BlockArray

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.not_equal(nps.array([1.,2.]), nps.array([1., 3.])).get()  
array([False,  True])
nums.numpy.api.generated.positive(x, out=None, where=True, **kwargs)[source]

Numerical positive, element-wise.

This docstring was copied from numpy.positive.

Some inconsistencies with the NumS version may exist.

Parameters

x (BlockArray) – Input array.

Returns

y – Returned array: y = +x.

Return type

BlockArray

Notes

Equivalent to x.copy(), but only defined for types that support arithmetic.

nums.numpy.api.generated.power(x1, x2, out=None, where=True, **kwargs)[source]

First array elements raised to powers from second array, element-wise.

This docstring was copied from numpy.power.

Some inconsistencies with the NumS version may exist.

Raise each base in x1 to the positionally-corresponding power in x2. x1 and x2 must be broadcastable to the same shape. Note that an integer type raised to a negative integer power will raise a ValueError.

Parameters
  • x1 (BlockArray) – The bases.

  • x2 (BlockArray) – The exponents. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The bases in x1 raised to the exponents in x2.

Return type

BlockArray

See also

float_power

power function that promotes integers to float

nums.numpy.api.generated.rad2deg(x, out=None, where=True, **kwargs)[source]

Convert angles from radians to degrees.

This docstring was copied from numpy.rad2deg.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Angle in radians.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The corresponding angle in degrees.

Return type

BlockArray

See also

deg2rad

Convert angles from degrees to radians.

unwrap

Remove large jumps in angle by wrapping.

Notes

rad2deg(x) is 180 * x / pi.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.rad2deg(nps.array(nps.pi/2)).get()  
array(90.)
nums.numpy.api.generated.radians(x, out=None, where=True, **kwargs)[source]

Convert angles from degrees to radians.

This docstring was copied from numpy.radians.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array in degrees.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The corresponding radian values.

Return type

BlockArray

See also

deg2rad

equivalent function

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

Convert a degree array to radians

>>> deg = nps.arange(12.) * 30.  
>>> nps.radians(deg).get()  
array([ 0.        ,  0.52359878,  1.04719755,  1.57079633,  2.0943951 ,
        2.61799388,  3.14159265,  3.66519143,  4.1887902 ,  4.71238898,
        5.23598776,  5.75958653])
>>> out = nps.zeros((deg.shape))  
>>> ret = nps.radians(deg, out)  
>>> ret is out  
True
nums.numpy.api.generated.reciprocal(x, out=None, where=True, **kwargs)[source]

Return the reciprocal of the argument, element-wise.

This docstring was copied from numpy.reciprocal.

Some inconsistencies with the NumS version may exist.

Calculates 1/x.

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – Return array.

Return type

BlockArray

Notes

Note

This function is not designed to work with integers.

For integer arguments with absolute value larger than 1 the result is always zero because of the way Python handles integer division. For integer zero the result is an overflow.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.reciprocal(nps.array(2.)).get()  
array(0.5)
>>> nps.reciprocal(nps.array([1, 2., 3.33])).get()  
array([ 1.       ,  0.5      ,  0.3003003])
nums.numpy.api.generated.remainder(x1, x2, out=None, where=True, **kwargs)[source]

Return element-wise remainder of division.

This docstring was copied from numpy.remainder.

Some inconsistencies with the NumS version may exist.

Computes the remainder complementary to the floor_divide function. It is equivalent to the Python modulus operator``x1 % x2`` and has the same sign as the divisor x2. The MATLAB function equivalent to nps.remainder is mod.

Parameters
  • x1 (BlockArray) – Dividend array.

  • x2 (BlockArray) – Divisor array. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The element-wise remainder of the quotient floor_divide(x1, x2).

Return type

BlockArray

See also

floor_divide

Equivalent of Python // operator.

divmod

Simultaneous floor division and remainder.

fmod

Equivalent of the MATLAB rem function.

divide, floor

Notes

Returns 0 when x2 is 0 and both x1 and x2 are (arrays of) integers. mod is an alias of remainder.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.remainder(nps.array([4, 7]), nps.array([2, 3])).get()  
array([0, 1])
>>> nps.remainder(nps.arange(7), nps.array(5)).get()  
array([0, 1, 2, 3, 4, 0, 1])
nums.numpy.api.generated.right_shift(x1, x2, out=None, where=True, **kwargs)[source]

Shift the bits of an integer to the right.

This docstring was copied from numpy.right_shift.

Some inconsistencies with the NumS version may exist.

Bits are shifted to the right x2. Because the internal representation of numbers is in binary format, this operation is equivalent to dividing x1 by 2**x2.

Parameters
  • x1 (BlockArray, int) – Input values.

  • x2 (BlockArray, int) – Number of bits to remove at the right of x1. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Return x1 with bits shifted x2 times to the right.

Return type

BlockArray

See also

left_shift

Shift the bits of an integer to the left.

binary_repr

Return the binary representation of the input number as a string.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.right_shift(nps.array(10), nps.array(1)).get()  
5
nums.numpy.api.generated.rint(x, out=None, where=True, **kwargs)[source]

Round elements of the array to the nearest integer.

This docstring was copied from numpy.rint.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Output array is same shape and type as x.

Return type

BlockArray

See also

ceil, floor, trunc

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> a = nps.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])  
>>> nps.rint(a).get()  
array([-2., -2., -0.,  0.,  2.,  2.,  2.])
nums.numpy.api.generated.sign(x, out=None, where=True, **kwargs)[source]

Returns an element-wise indication of the sign of a number.

This docstring was copied from numpy.sign.

Some inconsistencies with the NumS version may exist.

The sign function returns -1 if x < 0, 0 if x==0, 1 if x > 0. nan is returned for nan inputs.

For complex inputs, the sign function returns sign(x.real) + 0j if x.real != 0 else sign(x.imag) + 0j.

complex(nan, 0) is returned for complex nan inputs.

Parameters
  • x (BlockArray) – Input values.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The sign of x.

Return type

BlockArray

Notes

There is more than one definition of sign in common use for complex numbers. The definition used here is equivalent to \(x/\sqrt{x*x}\) which is different from a common alternative, \(x/|x|\).

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.sign(nps.array([-5., 4.5])).get()  
array([-1.,  1.])
>>> nps.sign(nps.array(0)).get()  
array(0)
>>> nps.sign(nps.array(5-2j)).get()  
array(1.+0.j)
nums.numpy.api.generated.signbit(x, out=None, where=True, **kwargs)[source]

Returns element-wise True where signbit is set (less than zero).

This docstring was copied from numpy.signbit.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – The input value(s).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

result – Output array, or reference to out if that was supplied.

Return type

BlockArray of bool

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.signbit(nps.array(-1.2)).get()  
array(True)
>>> nps.signbit(nps.array([1, -2.3, 2.1])).get()  
array([False,  True, False])
nums.numpy.api.generated.sin(x, out=None, where=True, **kwargs)[source]

Trigonometric sine, element-wise.

This docstring was copied from numpy.sin.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Angle, in radians (\(2 \pi\) rad equals 360 degrees).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The sine of each element of x.

Return type

BlockArray

See also

arcsin, sinh, cos

Notes

The sine is one of the fundamental functions of trigonometry (the mathematical study of triangles). Consider a circle of radius 1 centered on the origin. A ray comes in from the \(+x\) axis, makes an angle at the origin (measured counter-clockwise from that axis), and departs from the origin. The \(y\) coordinate of the outgoing ray’s intersection with the unit circle is the sine of that angle. It ranges from -1 for \(x=3\pi / 2\) to +1 for \(\pi / 2.\) The function has zeroes where the angle is a multiple of \(\pi\). Sines of angles between \(\pi\) and \(2\pi\) are negative. The numerous properties of the sine and related functions are included in any standard trigonometry text.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

Print sine of one angle:

>>> nps.sin(nps.array(nps.pi/2.)).get()  
array(1.)

Print sines of an array of angles given in degrees:

>>> nps.sin(nps.array((0., 30., 45., 60., 90.)) * nps.pi / 180. ).get()  
array([ 0.        ,  0.5       ,  0.70710678,  0.8660254 ,  1.        ])
nums.numpy.api.generated.sinh(x, out=None, where=True, **kwargs)[source]

Hyperbolic sine, element-wise.

This docstring was copied from numpy.sinh.

Some inconsistencies with the NumS version may exist.

Equivalent to 1/2 * (nps.exp(x) - nps.exp(-x)).get() or -1j * nps.sin(1j*x).get().

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The corresponding hyperbolic sine values.

Return type

BlockArray

Notes

If out is provided, the function writes the result into it, and returns a reference to out. (See Examples)

References

M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions. New York, NY: Dover, 1972, pg. 83.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.sinh(nps.array(0)).get()  
nps.array(0.)
>>> nps.sinh(nps.array(nps.pi*1j/2)).get()  
array(0.+1.j)
>>> nps.sinh(nps.array(nps.pi*1j)).get() # (exact value is 0)  
array(0.+1.2246468e-16j)
>>> # Discrepancy due to vagaries of floating point arithmetic.
>>> # Example of providing the optional output parameter
>>> out1 = nps.array([0], dtype='d')  
>>> out2 = nps.sinh(nps.array([0.1]), out1)  
>>> out2 is out1  
True
nums.numpy.api.generated.spacing(x, out=None, where=True, **kwargs)[source]

Return the distance between x and the nearest adjacent number.

This docstring was copied from numpy.spacing.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Values to find the spacing of.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – The spacing of values of x.

Return type

BlockArray or scalar

nums.numpy.api.generated.sqrt(x, out=None, where=True, **kwargs)[source]

Return the non-negative square-root of an array, element-wise.

This docstring was copied from numpy.sqrt.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – The values whose square-roots are required.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – An array of the same shape as x, containing the positive square-root of each element in x. If any element in x is complex, a complex array is returned (and the square-roots of negative reals are calculated). If all of the elements in x are real, so is y, with negative elements returning nan. If out was provided, y is a reference to it.

Return type

BlockArray

Notes

sqrt has–consistent with common convention–as its branch cut the real “interval” [-inf, 0), and is continuous from above on it. A branch cut is a curve in the complex plane across which a given complex function fails to be continuous.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.sqrt(nps.array([1,4,9])).get()  
array([ 1.,  2.,  3.])
>>> nps.sqrt(nps.array([4, -1, -3+4J])).get()  
array([ 2.+0.j,  0.+1.j,  1.+2.j])
>>> nps.sqrt(nps.array([4, -1, nps.inf])).get()  
array([ 2., nan, inf])
nums.numpy.api.generated.square(x, out=None, where=True, **kwargs)[source]

Return the element-wise square of the input.

This docstring was copied from numpy.square.

Some inconsistencies with the NumS version may exist.

Parameters
  • x (BlockArray) – Input data.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out – Element-wise x*x, of the same shape and dtype as x.

Return type

BlockArray or scalar

See also

sqrt, power

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.square(nps.array([-1j, 1])).get()  
array([-1.-0.j,  1.+0.j])
nums.numpy.api.generated.subtract(x1, x2, out=None, where=True, **kwargs)[source]

Subtract arguments, element-wise.

This docstring was copied from numpy.subtract.

Some inconsistencies with the NumS version may exist.

Parameters
  • x1 (BlockArray) – The arrays to be subtracted from each other. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • x2 (BlockArray) – The arrays to be subtracted from each other. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The difference of x1 and x2, element-wise.

Return type

BlockArray

Notes

Equivalent to x1 - x2 in terms of array broadcasting.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.subtract(nps.array(1.0), nps.array(4.0)).get()  
array(-3.)
>>> x1 = nps.arange(9.0).reshape((3, 3))  
>>> x2 = nps.arange(3.0)  
>>> nps.subtract(x1, x2).get()  
array([[ 0.,  0.,  0.],
       [ 3.,  3.,  3.],
       [ 6.,  6.,  6.]])
nums.numpy.api.generated.tan(x, out=None, where=True, **kwargs)[source]

Compute tangent element-wise.

This docstring was copied from numpy.tan.

Some inconsistencies with the NumS version may exist.

Equivalent to nps.sin(x)/nps.cos(x).get() element-wise.

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The corresponding tangent values.

Return type

BlockArray

Notes

If out is provided, the function writes the result into it, and returns a reference to out. (See Examples)

References

M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions. New York, NY: Dover, 1972.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> from math import pi  
>>> nps.tan(nps.array([-pi,pi/2,pi])).get()  
array([  1.22460635e-16,   1.63317787e+16,  -1.22460635e-16])
>>>
>>> # Example of providing the optional output parameter illustrating
>>> # that what is returned is a reference to said parameter
>>> out1 = nps.array([0], dtype='d')  
>>> out2 = nps.cos(nps.array([0.1]), out1)  
>>> out2 is out1  
True
nums.numpy.api.generated.tanh(x, out=None, where=True, **kwargs)[source]

Compute hyperbolic tangent element-wise.

This docstring was copied from numpy.tanh.

Some inconsistencies with the NumS version may exist.

Equivalent to nps.sinh(x)/nps.cosh(x) or -1j * nps.tan(1j*x).get().

Parameters
  • x (BlockArray) – Input array.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The corresponding hyperbolic tangent values.

Return type

BlockArray

Notes

If out is provided, the function writes the result into it, and returns a reference to out. (See Examples)

References

1

M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions. New York, NY: Dover, 1972, pg. 83. http://www.math.sfu.ca/~cbm/aands/

2

Wikipedia, “Hyperbolic function”, https://en.wikipedia.org/wiki/Hyperbolic_function

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> nps.tanh(nps.array([0, nps.pi*1j, nps.pi*1j/2])).get()  
array([ 0. +0.00000000e+00j,  0. -1.22460635e-16j,  0. +1.63317787e+16j])
>>> # Example of providing the optional output parameter illustrating
>>> # that what is returned is a reference to said parameter
>>> out1 = nps.array([0], dtype='d')  
>>> out2 = nps.tanh(nps.array([0.1]), out1)  
>>> out2 is out1  
True
nums.numpy.api.generated.true_divide(x1, x2, out=None, where=True, **kwargs)[source]

Returns a true division of the inputs, element-wise.

This docstring was copied from numpy.true_divide.

Some inconsistencies with the NumS version may exist.

Instead of the Python traditional ‘floor division’, this returns a true division. True division adjusts the output type to present the best answer, regardless of input types.

Parameters
  • x1 (BlockArray) – Dividend array.

  • x2 (BlockArray) – Divisor array. If x1.shape != x2.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

out

Return type

BlockArray

Notes

In Python, // is the floor division operator and / the true division operator. The true_divide(x1, x2) function is equivalent to true division in Python.

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> x = nps.arange(5)  
>>> nps.true_divide(x, nps.array(4)).get()  
array([ 0.  ,  0.25,  0.5 ,  0.75,  1.  ])
>>> (x/4).get()  
array([ 0.  ,  0.25,  0.5 ,  0.75,  1.  ])
nums.numpy.api.generated.trunc(x, out=None, where=True, **kwargs)[source]

Return the truncated value of the input, element-wise.

This docstring was copied from numpy.trunc.

Some inconsistencies with the NumS version may exist.

The truncated value of the scalar x is the nearest integer i which is closer to zero than x is. In short, the fractional part of the signed number x is discarded.

Parameters
  • x (BlockArray) – Input data.

  • out (BlockArray, None, or optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

  • where (BlockArray, optional) – This condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

  • **kwargs – For other keyword-only arguments, see the ufunc docs.

Returns

y – The truncated value of each element in x.

Return type

BlockArray

See also

ceil, floor, rint

Examples

The doctests shown below are copied from NumPy. They won’t show the correct result until you operate get().

>>> a = nps.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])  
>>> nps.trunc(a).get()  
array([-1., -1., -0.,  0.,  1.,  1.,  2.])