The numerical value of this quantity in the units given by unit. If a
Quantity or sequence of them (or any other valid object with a
unit attribute), creates a new Quantity object, converting to
unit units as needed. If a string, it is converted to a number or
Quantity, depending on whether a unit is present.

An object that represents the unit associated with the input value.
Must be an UnitBase object or a string parseable by
the units package.

dtype:~numpy.dtype, optional

The dtype of the resulting Numpy array or scalar that will
hold the value. If not provided, it is determined from the input,
except that any input that cannot represent float (integer and bool)
is converted to float.

copy:bool, optional

If True (default), then the value is copied. Otherwise, a copy will
only be made if __array__ returns a copy, if value is a nested
sequence, or if a copy is needed to satisfy an explicitly given
dtype. (The False option is intended mostly for internal use,
to speed up initialization where a copy is known to have been made.
Use with care.)

order:{‘C’, ‘F’, ‘A’}, optional

Specify the order of the array. As in array. This parameter
is ignored if the input is a Quantity and copy=False.

subok:bool, optional

If False (default), the returned array will be forced to be a
Quantity. Otherwise, Quantity subclasses will be passed through,
or a subclass appropriate for the unit will be used (such as
Dex for u.dex(u.AA)).

ndmin:int, optional

Specifies the minimum number of dimensions that the resulting array
should have. Ones will be pre-pended to the shape as needed to meet
this requirement. This parameter is ignored if the input is a
Quantity and copy=False.

Raises:

TypeError

If the value provided is not a Python numeric type.

TypeError

If the unit provided is not either a Unit
object or a parseable string unit.

True if the value of this quantity is a scalar, or False if it
is an array-like object.

Note

This is subtly different from numpy.isscalar in that
numpy.isscalar returns False for a zero-dimensional array
(e.g. np.array(1)), while this is True for quantities,
since quantities cannot represent true numpy scalars.

The bases to decompose into. When not provided,
decomposes down to any irreducible units. When provided,
the decomposed result will only contain the given units.
This will raises a UnitsError if it’s not possible
to do so.

Object that defines the index or indices before which values is
inserted.

values:array-like

Values to insert. If the type of values is different
from that of quantity, values is converted to the matching type.
values should be shaped so that it can be broadcast appropriately
The unit of values must be consistent with this quantity.

axis:int, optional

Axis along which to insert values. If axis is None then
the quantity array is flattened before insertion.

Copy an element of an array to a standard Python scalar and return it.

Parameters:

*args:Arguments (variable number and type)

none: in this case, the method only works for arrays
with one element (a.size==1), which element is
copied into a standard Python scalar object and returned.

int_type: this argument is interpreted as a flat index into
the array, specifying which element to copy and return.

tuple of int_types: functions as does a single int_type argument,
except that the argument is interpreted as an nd-index into the
array.

Returns:

z:Standard Python scalar object

A copy of the specified element of the array as a suitable
Python scalar

Notes

When the data type of a is longdouble or clongdouble, item() returns
a scalar array object because there is no available Python scalar that
would not lose information. Void arrays return a buffer object for item(),
unless fields are defined, in which case a tuple is returned.

item is very similar to a[args], except, instead of an array scalar,
a standard Python scalar is returned. This can be useful for speeding up
access to elements of the array and doing arithmetic on elements of the
array using Python’s optimized math.

Insert scalar into an array (scalar is cast to array’s dtype, if possible)

There must be at least 1 argument, and define the last argument
as item. Then, a.itemset(*args) is equivalent to but faster
than a[args]=item. The item should be a scalar value and args
must select a single item in the array a.

Parameters:

*args:Arguments

If one argument: a scalar, only used in case a is of size 1.
If two arguments: the last argument is the value to be set
and must be a scalar, the first argument specifies a single array
element location. It is either an int or a tuple.

Notes

Compared to indexing syntax, itemset provides some speed increase
for placing a scalar into a particular location in an ndarray,
if you must do this. However, generally this is discouraged:
among other problems, it complicates the appearance of the code.
Also, when using itemset (and item) inside a loop, be sure
to assign the methods to a local variable to avoid the attribute
look-up at each loop iteration.

An object that represents the unit to convert to. Must be
an UnitBase object or a string parseable
by the units package.

equivalencies:list of equivalence pairs, optional

A list of equivalence pairs to try if the units are not
directly convertible. See Equivalencies.
If not provided or [], class default equivalencies will be used
(none for Quantity, but may be set for subclasses)
If None, no equivalencies will be applied at all, not even any
set globally or within a context.

The unit in which the value should be given. If not given or None,
use the current unit.

equivalencies:list of equivalence pairs, optional

A list of equivalence pairs to try if the units are not directly
convertible (see Equivalencies). If not provided or
[], class default equivalencies will be used (none for
Quantity, but may be set for subclasses).
If None, no equivalencies will be applied at all, not even any
set globally or within a context.

Data is always written in ‘C’ order, independent of the order of a.
The data produced by this method can be recovered using the function
fromfile().

Parameters:

fid:file or str

An open file object, or a string containing a filename.

sep:str

Separator between array items for text output.
If “” (empty), a binary file is written, equivalent to
file.write(a.tobytes()).

format:str

Format string for text file output.
Each entry in the array is formatted to text by first converting
it to the closest Python type, and then using “format” % item.

Notes

This is a convenience function for quick storage of array data.
Information on endianness and precision is lost, so this method is not a
good choice for files intended to archive data or transport data between
machines with different endianness. Some of these problems can be overcome
by outputting the data as text files, at the expense of speed and file
size.

When fid is a file object, array contents are directly written to the
file, bypassing the file object’s write method. As a result, tofile
cannot be used with files objects supporting compression (e.g., GzipFile)
or file-like objects that do not support fileno() (e.g., BytesIO).

Constructs Python bytes showing a copy of the raw contents of
data memory. The bytes object can be produced in either ‘C’ or ‘Fortran’,
or ‘Any’ order (the default is ‘C’-order). ‘Any’ order means C-order
unless the F_CONTIGUOUS flag in the array is set, in which case it
means ‘Fortran’ order.

This function is a compatibility alias for tobytes. Despite its name it returns bytes not strings.

Parameters:

order:{‘C’, ‘F’, None}, optional

Order of the data for multidimensional arrays:
C, Fortran, or the same as for the original array.