arkouda.numpy.imports

Attributes

Classes

False_

bool(value=False, /)

ScalarType

Built-in immutable sequence.

True_

bool(value=False, /)

byte

Signed integer type, compatible with C char.

bytes_

A byte string.

cdouble

Complex number type composed of two double-precision floating-point numbers,

clongdouble

Complex number type composed of two extended-precision floating-point numbers.

csingle

Complex number type composed of two single-precision floating-point numbers.

datetime64

If created from a 64-bit integer, it represents an offset from 1970-01-01T00:00:00.

double

Double-precision floating-point number type, compatible with Python float and C double.

finfo

finfo(dtype)

flexible

Abstract base class of all scalar types without predefined length.

floating

Abstract base class of all floating-point scalar types.

half

Half-precision floating-point number type.

iinfo

iinfo(type)

inexact

Abstract base class of all numeric scalar types with a (potentially)

intc

Signed integer type, compatible with C int.

integer

Abstract base class of all integer scalar types.

intp

Signed integer type, compatible with C long.

longdouble

Extended-precision floating-point number type, compatible with C long double

longlong

Signed integer type, compatible with C long long.

number

Abstract base class of all numeric scalar types.

sctypeDict

dict() -> new empty dictionary

short

Signed integer type, compatible with C short.

signedinteger

Abstract base class of all signed integer scalar types.

single

Single-precision floating-point number type, compatible with C float.

timedelta64

A timedelta stored as a 64-bit integer.

ubyte

Unsigned integer type, compatible with C unsigned char.

uint

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit systems.

uintc

Unsigned integer type, compatible with C unsigned int.

uintp

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit systems.

ulonglong

Unsigned integer type, compatible with C unsigned long long.

unsignedinteger

Abstract base class of all unsigned integer scalar types.

ushort

Unsigned integer type, compatible with C unsigned short.

void

np.void(length_or_data, /, dtype=None)

Functions

base_repr(number[, base, padding])

Return a string representation of a number in the given base system.

binary_repr(num[, width])

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

format_float_positional(x[, precision, unique, ...])

Format a floating-point scalar as a decimal string in positional notation.

format_float_scientific(x[, precision, unique, trim, ...])

Format a floating-point scalar as a decimal string in scientific notation.

isscalar(element)

Returns True if the type of element is a scalar type.

issubdtype(arg1, arg2)

Returns True if first argument is a typecode lower/equal in type hierarchy.

typename(char)

Return a description for the given data type code.

Module Contents

class arkouda.numpy.imports.False_

Bases: numpy.generic

bool(value=False, /) –

Boolean type (True or False), stored as a byte.

Warning

The bool type is not a subclass of the int_ type (the bool is not even a number type). This is different than Python’s default implementation of bool as a sub-class of int.

Character code:

'?'

class arkouda.numpy.imports.ScalarType

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

class arkouda.numpy.imports.True_

Bases: numpy.generic

bool(value=False, /) –

Boolean type (True or False), stored as a byte.

Warning

The bool type is not a subclass of the int_ type (the bool is not even a number type). This is different than Python’s default implementation of bool as a sub-class of int.

Character code:

'?'

arkouda.numpy.imports.base_repr(number, base=2, padding=0)

Return a string representation of a number in the given base system.

Parameters:
  • number (int) – The value to convert. Positive and negative values are handled.

  • base (int, optional) – Convert number to the base number system. The valid range is 2-36, the default value is 2.

  • padding (int, optional) – Number of zeros padded on the left. Default is 0 (no padding).

Returns:

out – String representation of number in base system.

Return type:

str

See also

binary_repr

Faster version of base_repr for base 2.

Examples

>>> import numpy as np
>>> np.base_repr(5)
'101'
>>> np.base_repr(6, 5)
'11'
>>> np.base_repr(7, base=5, padding=3)
'00012'
>>> np.base_repr(10, base=16)
'A'
>>> np.base_repr(32, base=16)
'20'
arkouda.numpy.imports.binary_repr(num, width=None)

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

For negative numbers, if width is not given, a minus sign is added to the front. If width is given, the two’s complement of the number is returned, with respect to that width.

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:
  • num (int) – Only an integer decimal number can be used.

  • width (int, optional) – The length of the returned string if num is positive, or the length of the two’s complement if num is negative, provided that width is at least a sufficient number of bits for num to be represented in the designated form. If the width value is insufficient, an error is raised.

Returns:

bin – Binary representation of num or two’s complement of num.

Return type:

str

See also

base_repr

Return a string representation of a number in the given base system.

bin

Python’s built-in binary representation generator of an integer.

Notes

binary_repr is equivalent to using base_repr with base 2, but about 25x faster.

References

Examples

>>> import numpy as np
>>> np.binary_repr(3)
'11'
>>> np.binary_repr(-3)
'-11'
>>> np.binary_repr(3, width=4)
'0011'

The two’s complement is returned when the input number is negative and width is specified:

>>> np.binary_repr(-3, width=3)
'101'
>>> np.binary_repr(-3, width=5)
'11101'
class arkouda.numpy.imports.byte

Bases: numpy.signedinteger

Signed integer type, compatible with C char.

Character code:

'b'

Canonical name:

numpy.byte

Alias on this platform (Linux x86_64):

numpy.int8: 8-bit signed integer (-128 to 127).

bit_count(/)

int8.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.int8(127).bit_count()
7
>>> np.int8(-127).bit_count()
7
class arkouda.numpy.imports.bytes_

A byte string.

When used in arrays, this type strips trailing null bytes.

Character code:

'S'

T(*args, **kwargs)

Scalar attribute identical to ndarray.T.

all(/, axis=None, out=None, keepdims=False, *, where=True)

Scalar method identical to ndarray.all.

any(/, axis=None, out=None, keepdims=False, *, where=True)

Scalar method identical to ndarray.any.

argmax(/, axis=None, out=None, *, keepdims=False)

Scalar method identical to ndarray.argmax.

argmin(/, axis=None, out=None, *, keepdims=False)

Scalar method identical to ndarray.argmin.

argsort(/, axis=-1, kind=None, order=None, *, stable=None)

Scalar method identical to ndarray.argsort.

astype(/, dtype, order='K', casting='unsafe', subok=True, copy=True)

Scalar method identical to ndarray.astype.

base(*args, **kwargs)

Scalar attribute identical to ndarray.base.

byteswap(/, inplace=False)

Scalar method identical to ndarray.byteswap.

choose(/, choices, out=None, mode='raise')

Scalar method identical to ndarray.choose.

clip(/, min=None, max=None, out=None, **kwargs)

Scalar method identical to ndarray.clip.

compress(/, condition, axis=None, out=None)

Scalar method identical to ndarray.compress.

conj(/)

Scalar method identical to ndarray.conj.

conjugate(/)

Scalar method identical to ndarray.conjugate.

copy(/, order='C')

Scalar method identical to ndarray.copy.

cumprod(/, axis=None, dtype=None, out=None)

Scalar method identical to ndarray.cumprod.

cumsum(/, axis=None, dtype=None, out=None)

Scalar method identical to ndarray.cumsum.

data(*args, **kwargs)

Pointer to start of data.

device(*args, **kwargs)
diagonal(/, offset=0, axis1=0, axis2=1)

Scalar method identical to ndarray.diagonal.

dtype(*args, **kwargs)

Get array data-descriptor.

dump(/, file)

Scalar method identical to ndarray.dump.

dumps(/)

Scalar method identical to ndarray.dumps.

fill(/, value)

Scalar method identical to ndarray.fill.

flags(*args, **kwargs)

The integer value of flags.

flat(*args, **kwargs)

A 1-D view of the scalar.

flatten(/, order='C')

Scalar method identical to ndarray.flatten.

getfield(/, dtype, offset=0)

Scalar method identical to ndarray.getfield.

imag(*args, **kwargs)

The imaginary part of the scalar.

item(/, *args)

Scalar method identical to ndarray.item.

itemsize(*args, **kwargs)

The length of one element in bytes.

max(/, axis=None, out=None, **kwargs)

Scalar method identical to ndarray.max.

mean(/, axis=None, dtype=None, out=None, **kwargs)

Scalar method identical to ndarray.mean.

min(/, axis=None, out=None, **kwargs)

Scalar method identical to ndarray.min.

nbytes(*args, **kwargs)
ndim(*args, **kwargs)

The number of array dimensions.

nonzero(/)

Scalar method identical to ndarray.nonzero.

prod(/, axis=None, dtype=None, out=None, **kwargs)

Scalar method identical to ndarray.prod.

put(indices, values, /, mode='raise')

Scalar method identical to ndarray.put.

ravel(/, order='C')

Scalar method identical to ndarray.ravel.

real(*args, **kwargs)

The real part of the scalar.

repeat(repeats, /, axis=None)

Scalar method identical to ndarray.repeat.

reshape(/, *shape, order='C', copy=None)

Scalar method identical to ndarray.reshape.

resize(/, *new_shape, refcheck=True)

Scalar method identical to ndarray.resize.

round(/, decimals=0, out=None)

Scalar method identical to ndarray.round.

searchsorted(v, /, side='left', sorter=None)

Scalar method identical to ndarray.searchsorted.

setfield(val, /, dtype, offset=0)

Scalar method identical to ndarray.setfield.

setflags(/, *, write=None, align=None, uic=None)

Scalar method identical to ndarray.setflags.

shape(*args, **kwargs)

Tuple of array dimensions.

size(*args, **kwargs)

The number of elements in the gentype.

sort(/, axis=-1, kind=None, order=None, *, stable=None)

Scalar method identical to ndarray.sort.

squeeze(/, axis=None)

Scalar method identical to ndarray.squeeze.

std(/, axis=None, dtype=None, out=None, ddof=0, **kwargs)

Scalar method identical to ndarray.std.

strides(*args, **kwargs)

Tuple of bytes steps in each dimension.

sum(/, axis=None, dtype=None, out=None, **kwargs)

Scalar method identical to ndarray.sum.

swapaxes(axis1, axis2, /)

Scalar method identical to ndarray.swapaxes.

take(indices, /, axis=None, out=None, mode='raise')

Scalar method identical to ndarray.take.

to_device(device, /, *, stream=None)

Scalar method identical to ndarray.to_device.

tobytes(/, order='C')

Scalar method identical to ndarray.tobytes.

tofile(fid, /, sep='', format='%s')

Scalar method identical to ndarray.tofile.

tolist(/)

Scalar method identical to ndarray.tolist.

trace(/, offset=0, axis1=0, axis2=1, dtype=None, out=None)

Scalar method identical to ndarray.trace.

transpose(/, *axes)

Scalar method identical to ndarray.transpose.

var(/, axis=None, dtype=None, out=None, ddof=0, **kwargs)

Scalar method identical to ndarray.var.

view(/, *args, **kwargs)

Scalar method identical to ndarray.view.

class arkouda.numpy.imports.cdouble

Bases: numpy.complexfloating

Complex number type composed of two double-precision floating-point numbers, compatible with Python complex.

Character code:

'D'

Canonical name:

numpy.cdouble

Alias on this platform (Linux x86_64):

numpy.complex128: Complex number type composed of 2 64-bit-precision floating-point numbers.

class arkouda.numpy.imports.clongdouble

Bases: numpy.complexfloating

Complex number type composed of two extended-precision floating-point numbers.

Character code:

'G'

Alias on this platform (Linux x86_64):

numpy.complex256: Complex number type composed of 2 128-bit extended-precision floating-point numbers.

class arkouda.numpy.imports.csingle

Bases: numpy.complexfloating

Complex number type composed of two single-precision floating-point numbers.

Character code:

'F'

Canonical name:

numpy.csingle

Alias on this platform (Linux x86_64):

numpy.complex64: Complex number type composed of 2 32-bit-precision floating-point numbers.

class arkouda.numpy.imports.datetime64

Bases: numpy.generic

If created from a 64-bit integer, it represents an offset from 1970-01-01T00:00:00. If created from string, the string can be in ISO 8601 date or datetime format.

When parsing a string to create a datetime object, if the string contains a trailing timezone (A ‘Z’ or a timezone offset), the timezone will be dropped and a User Warning is given.

Datetime64 objects should be considered to be UTC and therefore have an offset of +0000.

>>> np.datetime64(10, 'Y')
np.datetime64('1980')
>>> np.datetime64('1980', 'Y')
np.datetime64('1980')
>>> np.datetime64(10, 'D')
np.datetime64('1970-01-11')

See arrays.datetime for more information.

Character code:

'M'

class arkouda.numpy.imports.double

Bases: numpy.floating

Double-precision floating-point number type, compatible with Python float and C double.

Character code:

'd'

Canonical name:

numpy.double

Alias on this platform (Linux x86_64):

numpy.float64: 64-bit precision floating-point number type: sign bit, 11 bits exponent, 52 bits mantissa.

as_integer_ratio(/)

double.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.double(10.0).as_integer_ratio()
(10, 1)
>>> np.double(0.0).as_integer_ratio()
(0, 1)
>>> np.double(-.25).as_integer_ratio()
(-1, 4)
fromhex(string, /)

Create a floating-point number from a hexadecimal string.

>>> float.fromhex('0x1.ffffp10')
2047.984375
>>> float.fromhex('-0x1p-1074')
-5e-324
hex(/)

Return a hexadecimal representation of a floating-point number.

>>> (-0.1).hex()
'-0x1.999999999999ap-4'
>>> 3.14159.hex()
'0x1.921f9f01b866ep+1'
is_integer(/)

double.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

Examples

>>> np.double(-2.0).is_integer()
True
>>> np.double(3.2).is_integer()
False
arkouda.numpy.imports.e: float
arkouda.numpy.imports.euler_gamma: float
class arkouda.numpy.imports.finfo

finfo(dtype)

Machine limits for floating point types.

bits

The number of bits occupied by the type.

Type:

int

dtype

Returns the dtype for which finfo returns information. For complex input, the returned dtype is the associated float* dtype for its real and complex components.

Type:

dtype

eps

The difference between 1.0 and the next smallest representable float larger than 1.0. For example, for 64-bit binary floats in the IEEE-754 standard, eps = 2**-52, approximately 2.22e-16.

Type:

float

epsneg[source]

The difference between 1.0 and the next smallest representable float less than 1.0. For example, for 64-bit binary floats in the IEEE-754 standard, epsneg = 2**-53, approximately 1.11e-16.

Type:

float

iexp[source]

The number of bits in the exponent portion of the floating point representation.

Type:

int

machep[source]

The exponent that yields eps.

Type:

int

max

The largest representable number.

Type:

floating point number of the appropriate type

maxexp

The smallest positive power of the base (2) that causes overflow. Corresponds to the C standard MAX_EXP.

Type:

int

min

The smallest representable number, typically -max.

Type:

floating point number of the appropriate type

minexp

The most negative power of the base (2) consistent with there being no leading 0’s in the mantissa. Corresponds to the C standard MIN_EXP - 1.

Type:

int

negep[source]

The exponent that yields epsneg.

Type:

int

nexp[source]

The number of bits in the exponent including its sign and bias.

Type:

int

nmant

The number of explicit bits in the mantissa (excluding the implicit leading bit for normalized numbers).

Type:

int

precision

The approximate number of decimal digits to which this kind of float is precise.

Type:

int

resolution[source]

The approximate decimal resolution of this type, i.e., 10**-precision.

Type:

floating point number of the appropriate type

tiny[source]

An alias for smallest_normal, kept for backwards compatibility.

Type:

float

smallest_normal

The smallest positive floating point number with 1 as leading bit in the mantissa following IEEE-754 (see Notes).

Type:

float

smallest_subnormal

The smallest positive floating point number with 0 as leading bit in the mantissa following IEEE-754.

Type:

float

Parameters:

dtype (float, dtype, or instance) – Kind of floating point or complex floating point data-type about which to get information.

See also

iinfo

The equivalent for integer data types.

spacing

The distance between a value and the nearest adjacent number

nextafter

The next floating point value after x1 towards x2

Notes

For developers of NumPy: do not instantiate this at the module level. The initial calculation of these parameters is expensive and negatively impacts import times. These objects are cached, so calling finfo() repeatedly inside your functions is not a problem.

Note that smallest_normal is not actually the smallest positive representable value in a NumPy floating point type. As in the IEEE-754 standard [1]_, NumPy floating point types make use of subnormal numbers to fill the gap between 0 and smallest_normal. However, subnormal numbers may have significantly reduced precision [2].

For longdouble, the representation varies across platforms. On most platforms it is IEEE 754 binary128 (quad precision) or binary64-extended (80-bit extended precision). On PowerPC systems, it may use the IBM double-double format (a pair of float64 values), which has special characteristics for precision and range.

This function can also be used for complex data types as well. If used, the output will be the same as the corresponding real float type (e.g. numpy.finfo(numpy.csingle) is the same as numpy.finfo(numpy.single)). However, the output is true for the real and imaginary components.

References

Examples

>>> import numpy as np
>>> np.finfo(np.float64).dtype
dtype('float64')
>>> np.finfo(np.complex64).dtype
dtype('float32')
epsneg(*args, **kwargs)[source]
iexp(*args, **kwargs)[source]
machep(*args, **kwargs)[source]
negep(*args, **kwargs)[source]
nexp(*args, **kwargs)[source]
resolution(*args, **kwargs)[source]
tiny(*args, **kwargs)[source]

Return the value for tiny, alias of smallest_normal.

Returns:

tiny – Value for the smallest normal, alias of smallest_normal.

Return type:

float

Warns:

UserWarning – If the calculated value for the smallest normal is requested for double-double.

class arkouda.numpy.imports.flexible

Bases: numpy.generic

Abstract base class of all scalar types without predefined length. The actual size of these types depends on the specific numpy.dtype instantiation.

class arkouda.numpy.imports.floating

Bases: numpy.inexact

Abstract base class of all floating-point scalar types.

arkouda.numpy.imports.format_float_positional(x, precision=None, unique=True, fractional=True, trim='k', sign=False, pad_left=None, pad_right=None, min_digits=None)

Format a floating-point scalar as a decimal string in positional notation.

Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the “Dragon4” algorithm.

Parameters:
  • x (python float or numpy floating scalar) – Value to format.

  • precision (non-negative integer or None, optional) – Maximum number of digits to print. May be None if unique is True, but must be an integer if unique is False.

  • unique (boolean, optional) – If True, use a digit-generation strategy which gives the shortest representation which uniquely identifies the floating-point number from other values of the same type, by judicious rounding. If precision is given fewer digits than necessary can be printed, or if min_digits is given more can be printed, in which cases the last digit is rounded with unbiased rounding. If False, digits are generated as if printing an infinite-precision value and stopping after precision digits, rounding the remaining value with unbiased rounding

  • fractional (boolean, optional) – If True, the cutoffs of precision and min_digits refer to the total number of digits after the decimal point, including leading zeros. If False, precision and min_digits refer to the total number of significant digits, before or after the decimal point, ignoring leading zeros.

  • trim (one of 'k', '.', '0', '-', optional) –

    Controls post-processing trimming of trailing digits, as follows:

    • ’k’ : keep trailing zeros, keep decimal point (no trimming)

    • ’.’ : trim all trailing zeros, leave decimal point

    • ’0’ : trim all but the zero before the decimal point. Insert the zero if it is missing.

    • ’-’ : trim trailing zeros and any trailing decimal point

  • sign (boolean, optional) – Whether to show the sign for positive values.

  • pad_left (non-negative integer, optional) – Pad the left side of the string with whitespace until at least that many characters are to the left of the decimal point.

  • pad_right (non-negative integer, optional) – Pad the right side of the string with whitespace until at least that many characters are to the right of the decimal point.

  • min_digits (non-negative integer or None, optional) –

    Minimum number of digits to print. Only has an effect if unique=True in which case additional digits past those necessary to uniquely identify the value may be printed, rounding the last additional digit.

    Added in version 1.21.0.

Returns:

rep – The string representation of the floating point value

Return type:

string

Examples

>>> import numpy as np
>>> np.format_float_positional(np.float32(np.pi))
'3.1415927'
>>> np.format_float_positional(np.float16(np.pi))
'3.14'
>>> np.format_float_positional(np.float16(0.3))
'0.3'
>>> np.format_float_positional(np.float16(0.3), unique=False, precision=10)
'0.3000488281'
arkouda.numpy.imports.format_float_scientific(x, precision=None, unique=True, trim='k', sign=False, pad_left=None, exp_digits=None, min_digits=None)

Format a floating-point scalar as a decimal string in scientific notation.

Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the “Dragon4” algorithm.

Parameters:
  • x (python float or numpy floating scalar) – Value to format.

  • precision (non-negative integer or None, optional) – Maximum number of digits to print. May be None if unique is True, but must be an integer if unique is False.

  • unique (boolean, optional) – If True, use a digit-generation strategy which gives the shortest representation which uniquely identifies the floating-point number from other values of the same type, by judicious rounding. If precision is given fewer digits than necessary can be printed. If min_digits is given more can be printed, in which cases the last digit is rounded with unbiased rounding. If False, digits are generated as if printing an infinite-precision value and stopping after precision digits, rounding the remaining value with unbiased rounding

  • trim (one of 'k', '.', '0', '-', optional) –

    Controls post-processing trimming of trailing digits, as follows:

    • ’k’ : keep trailing zeros, keep decimal point (no trimming)

    • ’.’ : trim all trailing zeros, leave decimal point

    • ’0’ : trim all but the zero before the decimal point. Insert the zero if it is missing.

    • ’-’ : trim trailing zeros and any trailing decimal point

  • sign (boolean, optional) – Whether to show the sign for positive values.

  • pad_left (non-negative integer, optional) – Pad the left side of the string with whitespace until at least that many characters are to the left of the decimal point.

  • exp_digits (non-negative integer, optional) – Pad the exponent with zeros until it contains at least this many digits. If omitted, the exponent will be at least 2 digits.

  • min_digits (non-negative integer or None, optional) –

    Minimum number of digits to print. This only has an effect for unique=True. In that case more digits than necessary to uniquely identify the value may be printed and rounded unbiased.

    Added in version 1.21.0.

Returns:

rep – The string representation of the floating point value

Return type:

string

Examples

>>> import numpy as np
>>> np.format_float_scientific(np.float32(np.pi))
'3.1415927e+00'
>>> s = np.float32(1.23e24)
>>> np.format_float_scientific(s, unique=False, precision=15)
'1.230000071797338e+24'
>>> np.format_float_scientific(s, exp_digits=4)
'1.23e+0024'
class arkouda.numpy.imports.half

Bases: numpy.floating

Half-precision floating-point number type.

Character code:

'e'

Canonical name:

numpy.half

Alias on this platform (Linux x86_64):

numpy.float16: 16-bit-precision floating-point number type: sign bit, 5 bits exponent, 10 bits mantissa.

as_integer_ratio(/)

half.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.half(10.0).as_integer_ratio()
(10, 1)
>>> np.half(0.0).as_integer_ratio()
(0, 1)
>>> np.half(-.25).as_integer_ratio()
(-1, 4)
is_integer(/)

half.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

Examples

>>> np.half(-2.0).is_integer()
True
>>> np.half(3.2).is_integer()
False
class arkouda.numpy.imports.iinfo

iinfo(type)

Machine limits for integer types.

bits

The number of bits occupied by the type.

Type:

int

dtype

Returns the dtype for which iinfo returns information.

Type:

dtype

min

The smallest integer expressible by the type.

Type:

int

max

The largest integer expressible by the type.

Type:

int

Parameters:

int_type (integer type, dtype, or instance) – The kind of integer data type to get information about.

See also

finfo

The equivalent for floating point data types.

Examples

With types:

>>> import numpy as np
>>> ii16 = np.iinfo(np.int16)
>>> ii16.min
-32768
>>> ii16.max
32767
>>> ii32 = np.iinfo(np.int32)
>>> ii32.min
-2147483648
>>> ii32.max
2147483647

With instances:

>>> ii32 = np.iinfo(np.int32(10))
>>> ii32.min
-2147483648
>>> ii32.max
2147483647
property max

Maximum value of given dtype.

property min

Minimum value of given dtype.

class arkouda.numpy.imports.inexact

Bases: numpy.number

Abstract base class of all numeric scalar types with a (potentially) inexact representation of the values in its range, such as floating-point numbers.

arkouda.numpy.imports.inf: float
class arkouda.numpy.imports.intc

Bases: numpy.signedinteger

Signed integer type, compatible with C int.

Character code:

'i'

Canonical name:

numpy.intc

Alias on this platform (Linux x86_64):

numpy.int32: 32-bit signed integer (-2_147_483_648 to 2_147_483_647).

bit_count(/)

int32.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.int32(127).bit_count()
7
>>> np.int32(-127).bit_count()
7
class arkouda.numpy.imports.integer

Bases: numpy.number

Abstract base class of all integer scalar types.

denominator(*args, **kwargs)

denominator of value (1)

is_integer(/)

integer.is_integer() -> bool

Return True if the number is finite with integral value.

Added in version 1.22.

Examples

>>> import numpy as np
>>> np.int64(-2).is_integer()
True
>>> np.uint32(5).is_integer()
True
numerator(*args, **kwargs)

numerator of value (the value itself)

class arkouda.numpy.imports.intp

Bases: numpy.signedinteger

Signed integer type, compatible with C long.

Character code:

'l'

Canonical name:

numpy.long

Alias on this platform (Linux x86_64):

numpy.int64: 64-bit signed integer (-9_223_372_036_854_775_808 to 9_223_372_036_854_775_807).

Alias on this platform (Linux x86_64):

numpy.intp: Signed integer large enough to fit pointer, compatible with C intptr_t.

bit_count(/)

int64.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.int64(127).bit_count()
7
>>> np.int64(-127).bit_count()
7
arkouda.numpy.imports.isscalar(element)

Returns True if the type of element is a scalar type.

Parameters:

element (any) – Input argument, can be of any type and shape.

Returns:

val – True if element is a scalar type, False if it is not.

Return type:

bool

See also

ndim

Get the number of dimensions of an array

Notes

If you need a stricter way to identify a numerical scalar, use isinstance(x, numbers.Number), as that returns False for most non-numerical elements such as strings.

In most cases np.ndim(x) == 0 should be used instead of this function, as that will also return true for 0d arrays. This is how numpy overloads functions in the style of the dx arguments to gradient and the bins argument to histogram. Some key differences:

x

isscalar(x)

np.ndim(x) == 0

PEP 3141 numeric objects (including builtins)

True

True

builtin string and buffer objects

True

True

other builtin objects, like pathlib.Path, Exception, the result of re.compile

False

True

third-party objects like matplotlib.figure.Figure

False

True

zero-dimensional numpy arrays

False

True

other numpy arrays

False

False

list, tuple, and other sequence objects

False

False

Examples

>>> import numpy as np
>>> np.isscalar(3.1)
True
>>> np.isscalar(np.array(3.1))
False
>>> np.isscalar([3.1])
False
>>> np.isscalar(False)
True
>>> np.isscalar('numpy')
True

NumPy supports PEP 3141 numbers:

>>> from fractions import Fraction
>>> np.isscalar(Fraction(5, 17))
True
>>> from numbers import Number
>>> np.isscalar(Number())
True
arkouda.numpy.imports.issubdtype(arg1, arg2)

Returns True if first argument is a typecode lower/equal in type hierarchy.

This is like the builtin issubclass(), but for dtypes.

Parameters:
  • arg1 (dtype_like) – dtype or object coercible to one

  • arg2 (dtype_like) – dtype or object coercible to one

Returns:

out

Return type:

bool

See also

arrays.scalars

Overview of the numpy type hierarchy.

Examples

issubdtype can be used to check the type of arrays:

>>> ints = np.array([1, 2, 3], dtype=np.int32)
>>> np.issubdtype(ints.dtype, np.integer)
True
>>> np.issubdtype(ints.dtype, np.floating)
False
>>> floats = np.array([1, 2, 3], dtype=np.float32)
>>> np.issubdtype(floats.dtype, np.integer)
False
>>> np.issubdtype(floats.dtype, np.floating)
True

Similar types of different sizes are not subdtypes of each other:

>>> np.issubdtype(np.float64, np.float32)
False
>>> np.issubdtype(np.float32, np.float64)
False

but both are subtypes of floating:

>>> np.issubdtype(np.float64, np.floating)
True
>>> np.issubdtype(np.float32, np.floating)
True

For convenience, dtype-like objects are allowed too:

>>> np.issubdtype('S1', np.bytes_)
True
>>> np.issubdtype('i4', np.signedinteger)
True
class arkouda.numpy.imports.longdouble

Bases: numpy.floating

Extended-precision floating-point number type, compatible with C long double but not necessarily with IEEE 754 quadruple-precision.

Character code:

'g'

Alias on this platform (Linux x86_64):

numpy.float128: 128-bit extended-precision floating-point number type.

as_integer_ratio(/)

longdouble.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.longdouble(10.0).as_integer_ratio()
(10, 1)
>>> np.longdouble(0.0).as_integer_ratio()
(0, 1)
>>> np.longdouble(-.25).as_integer_ratio()
(-1, 4)
is_integer(/)

longdouble.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

Examples

>>> np.longdouble(-2.0).is_integer()
True
>>> np.longdouble(3.2).is_integer()
False
class arkouda.numpy.imports.longlong

Bases: numpy.signedinteger

Signed integer type, compatible with C long long.

Character code:

'q'

bit_count(/)

longlong.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.longlong(127).bit_count()
7
>>> np.longlong(-127).bit_count()
7
arkouda.numpy.imports.nan: float
arkouda.numpy.imports.newaxis: None
class arkouda.numpy.imports.number

Bases: numpy.generic

Abstract base class of all numeric scalar types.

arkouda.numpy.imports.pi: float
class arkouda.numpy.imports.sctypeDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

clear()

Remove all items from the dict.

copy()

Return a shallow copy of the dict.

fromkeys(iterable, value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items()

Return a set-like object providing a view on the dict’s items.

keys()

Return a set-like object providing a view on the dict’s keys.

pop(*args, **kwargs)

D.pop(k[,d]) -> v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update(*args, **kwargs)

D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Return an object providing a view on the dict’s values.

class arkouda.numpy.imports.short

Bases: numpy.signedinteger

Signed integer type, compatible with C short.

Character code:

'h'

Canonical name:

numpy.short

Alias on this platform (Linux x86_64):

numpy.int16: 16-bit signed integer (-32_768 to 32_767).

bit_count(/)

int16.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.int16(127).bit_count()
7
>>> np.int16(-127).bit_count()
7
class arkouda.numpy.imports.signedinteger

Bases: numpy.integer

Abstract base class of all signed integer scalar types.

class arkouda.numpy.imports.single

Bases: numpy.floating

Single-precision floating-point number type, compatible with C float.

Character code:

'f'

Canonical name:

numpy.single

Alias on this platform (Linux x86_64):

numpy.float32: 32-bit-precision floating-point number type: sign bit, 8 bits exponent, 23 bits mantissa.

as_integer_ratio(/)

single.as_integer_ratio() -> (int, int)

Return a pair of integers, whose ratio is exactly equal to the original floating point number, and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.

>>> np.single(10.0).as_integer_ratio()
(10, 1)
>>> np.single(0.0).as_integer_ratio()
(0, 1)
>>> np.single(-.25).as_integer_ratio()
(-1, 4)
is_integer(/)

single.is_integer() -> bool

Return True if the floating point number is finite with integral value, and False otherwise.

Added in version 1.22.

Examples

>>> np.single(-2.0).is_integer()
True
>>> np.single(3.2).is_integer()
False
class arkouda.numpy.imports.timedelta64

Bases: numpy.signedinteger

A timedelta stored as a 64-bit integer.

See arrays.datetime for more information.

Character code:

'm'

arkouda.numpy.imports.typename(char)

Return a description for the given data type code.

Parameters:

char (str) – Data type code.

Returns:

out – Description of the input data type code.

Return type:

str

See also

dtype

Examples

>>> import numpy as np
>>> typechars = ['S1', '?', 'B', 'D', 'G', 'F', 'I', 'H', 'L', 'O', 'Q',
...              'S', 'U', 'V', 'b', 'd', 'g', 'f', 'i', 'h', 'l', 'q']
>>> for typechar in typechars:
...     print(typechar, ' : ', np.typename(typechar))
...
S1  :  character
?  :  bool
B  :  unsigned char
D  :  complex double precision
G  :  complex long double precision
F  :  complex single precision
I  :  unsigned integer
H  :  unsigned short
L  :  unsigned long integer
O  :  object
Q  :  unsigned long long integer
S  :  string
U  :  unicode
V  :  void
b  :  signed char
d  :  double precision
g  :  long precision
f  :  single precision
i  :  integer
h  :  short
l  :  long integer
q  :  long long integer
class arkouda.numpy.imports.ubyte

Bases: numpy.unsignedinteger

Unsigned integer type, compatible with C unsigned char.

Character code:

'B'

Canonical name:

numpy.ubyte

Alias on this platform (Linux x86_64):

numpy.uint8: 8-bit unsigned integer (0 to 255).

bit_count(/)

uint8.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.uint8(127).bit_count()
7
class arkouda.numpy.imports.uint

Bases: numpy.unsignedinteger

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit systems.

Character code:

'L'

Canonical name:

numpy.uint

Alias on this platform (Linux x86_64):

numpy.uint64: 64-bit unsigned integer (0 to 18_446_744_073_709_551_615).

Alias on this platform (Linux x86_64):

numpy.uintp: Unsigned integer large enough to fit pointer, compatible with C uintptr_t.

bit_count(/)

uint64.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.uint64(127).bit_count()
7
class arkouda.numpy.imports.uintc

Bases: numpy.unsignedinteger

Unsigned integer type, compatible with C unsigned int.

Character code:

'I'

Canonical name:

numpy.uintc

Alias on this platform (Linux x86_64):

numpy.uint32: 32-bit unsigned integer (0 to 4_294_967_295).

bit_count(/)

uint32.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.uint32(127).bit_count()
7
class arkouda.numpy.imports.uintp

Bases: numpy.unsignedinteger

Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit systems.

Character code:

'L'

Canonical name:

numpy.uint

Alias on this platform (Linux x86_64):

numpy.uint64: 64-bit unsigned integer (0 to 18_446_744_073_709_551_615).

Alias on this platform (Linux x86_64):

numpy.uintp: Unsigned integer large enough to fit pointer, compatible with C uintptr_t.

bit_count(/)

uint64.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.uint64(127).bit_count()
7
class arkouda.numpy.imports.ulonglong

Bases: numpy.unsignedinteger

Unsigned integer type, compatible with C unsigned long long.

Character code:

'Q'

bit_count(/)

ulonglong.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.ulonglong(127).bit_count()
7
class arkouda.numpy.imports.unsignedinteger

Bases: numpy.integer

Abstract base class of all unsigned integer scalar types.

class arkouda.numpy.imports.ushort

Bases: numpy.unsignedinteger

Unsigned integer type, compatible with C unsigned short.

Character code:

'H'

Canonical name:

numpy.ushort

Alias on this platform (Linux x86_64):

numpy.uint16: 16-bit unsigned integer (0 to 65_535).

bit_count(/)

uint16.bit_count() -> int

Computes the number of 1-bits in the absolute value of the input. Analogous to the builtin int.bit_count or popcount in C++.

Examples

>>> np.uint16(127).bit_count()
7
class arkouda.numpy.imports.void

Bases: numpy.flexible

np.void(length_or_data, /, dtype=None)

Create a new structured or unstructured void scalar.

Parameters:
  • length_or_data (int, array-like, bytes-like, object) – One of multiple meanings (see notes). The length or bytes data of an unstructured void. Or alternatively, the data to be stored in the new scalar when dtype is provided. This can be an array-like, in which case an array may be returned.

  • dtype (dtype, optional) –

    If provided the dtype of the new scalar. This dtype must be “void” dtype (i.e. a structured or unstructured void, see also defining-structured-types).

    Added in version 1.24.

Notes

For historical reasons and because void scalars can represent both arbitrary byte data and structured dtypes, the void constructor has three calling conventions:

  1. np.void(5) creates a dtype="V5" scalar filled with five

    \0 bytes. The 5 can be a Python or NumPy integer.

  2. np.void(b"bytes-like") creates a void scalar from the byte string.

    The dtype itemsize will match the byte string length, here "V10".

  3. When a dtype= is passed the call is roughly the same as an

    array creation. However, a void scalar rather than array is returned.

Please see the examples which show all three different conventions.

Examples

>>> np.void(5)
np.void(b'\x00\x00\x00\x00\x00')
>>> np.void(b'abcd')
np.void(b'\x61\x62\x63\x64')
>>> np.void((3.2, b'eggs'), dtype="d,S5")
np.void((3.2, b'eggs'), dtype=[('f0', '<f8'), ('f1', 'S5')])
>>> np.void(3, dtype=[('x', np.int8), ('y', np.int8)])
np.void((3, 3), dtype=[('x', 'i1'), ('y', 'i1')])
Character code:

'V'