Quantity class¶
(Shortest import: from brian2 import Quantity)
-
class
brian2.units.fundamentalunits.
Quantity
[source]¶ Bases:
numpy.ndarray
A number with an associated physical dimension. In most cases, it is not necessary to create a Quantity object by hand, instead use multiplication and division of numbers with the constant unit names
second
,kilogram
, etc.Attributes
dim
dimensions
The physical dimensions of this quantity. is_dimensionless
Whether this is a dimensionless quantity. Methods
all
([axis, out, keepdims, where])Returns True if all elements evaluate to True. any
([axis, out, keepdims, where])Returns True if any of the elements of a
evaluate to True.argmax
([axis, out, keepdims])Return indices of the maximum values along the given axis. argmin
([axis, out, keepdims])Return indices of the minimum values along the given axis. argsort
([axis, kind, order])Returns the indices that would sort this array. clip
([min, max, out])Return an array whose values are limited to [min, max]
.cumprod
([axis, dtype, out])Return the cumulative product of the elements along the given axis. cumsum
([axis, dtype, out])Return the cumulative sum of the elements along the given axis. diagonal
([offset, axis1, axis2])Return specified diagonals. dot
(other, **kwds)fill
(value)Fill the array with a scalar value. get_best_unit
(*regs)Return the best unit for this Quantity
.has_same_dimensions
(other)Return whether this object has the same dimensions as another. in_best_unit
([precision, python_code])Represent the quantity in the “best” unit. in_unit
(u[, precision, python_code])Represent the quantity in a given unit. item
(*args)Overwritten to assure that the returned element retains its unit. max
([axis, out, keepdims, initial, where])Return the maximum along a given axis. mean
([axis, dtype, out, keepdims, where])Returns the average of the array elements along given axis. min
([axis, out, keepdims, initial, where])Return the minimum along a given axis. nonzero
()Return the indices of the elements that are non-zero. prod
([axis, dtype, out, keepdims, initial, …])Return the product of the array elements over the given axis ptp
([axis, out, keepdims])Peak to peak (maximum - minimum) value along a given axis. put
(indices, values[, mode])Set a.flat[n] = values[n]
for alln
in indices.ravel
([order])Return a flattened array. round
([decimals, out])Return a
with each element rounded to the given number of decimals.searchsorted
(v[, side, sorter])Find indices where elements of v should be inserted in a to maintain order. std
([axis, dtype, out, ddof, keepdims, where])Returns the standard deviation of the array elements along given axis. sum
([axis, dtype, out, keepdims, initial, where])Return the sum of the array elements over the given axis. tolist
()Convert the array into a list. trace
([offset, axis1, axis2, dtype, out])Return the sum along diagonals of the array. var
([axis, dtype, out, ddof, keepdims, where])Returns the variance of the array elements, along given axis. with_dimensions
(value, *args, **keywords)Create a Quantity
object with dim.Details
-
dim
¶
-
dimensions
¶ The physical dimensions of this quantity.
-
is_dimensionless
¶ Whether this is a dimensionless quantity.
-
all
(axis=None, out=None, keepdims=False, *, where=True)¶ Returns True if all elements evaluate to True.
Refer to
numpy.all
for full documentation.
-
any
(axis=None, out=None, keepdims=False, *, where=True)¶ Returns True if any of the elements of
a
evaluate to True.Refer to
numpy.any
for full documentation.
-
argmax
(axis=None, out=None, *, keepdims=False)¶ Return indices of the maximum values along the given axis.
Refer to
numpy.argmax
for full documentation.
-
argmin
(axis=None, out=None, *, keepdims=False)¶ Return indices of the minimum values along the given axis.
Refer to
numpy.argmin
for detailed documentation.
-
argsort
(axis=-1, kind=None, order=None)¶ Returns the indices that would sort this array.
Refer to
numpy.argsort
for full documentation.
-
clip
(min=None, max=None, out=None, **kwargs)[source]¶ Return an array whose values are limited to
[min, max]
. One of max or min must be given.Refer to
numpy.clip
for full documentation.
-
cumprod
(axis=None, dtype=None, out=None)[source]¶ Return the cumulative product of the elements along the given axis.
Refer to
numpy.cumprod
for full documentation.
-
cumsum
(axis=None, dtype=None, out=None)¶ Return the cumulative sum of the elements along the given axis.
Refer to
numpy.cumsum
for full documentation.
-
diagonal
(offset=0, axis1=0, axis2=1)¶ Return specified diagonals. In NumPy 1.9 the returned array is a read-only view instead of a copy as in previous NumPy versions. In a future version the read-only restriction will be removed.
Refer to
numpy.diagonal()
for full documentation.
-
in_best_unit
(precision=None, python_code=False, *regs)[source]¶ Represent the quantity in the “best” unit.
-
in_unit
(u, precision=None, python_code=False)[source]¶ Represent the quantity in a given unit. If
python_code
isTrue
, this will return valid python code, i.e. a string like5.0 * um ** 2
instead of5.0 um^2
-
max
(axis=None, out=None, keepdims=False, initial=<no value>, where=True)¶ Return the maximum along a given axis.
Refer to
numpy.amax
for full documentation.
-
mean
(axis=None, dtype=None, out=None, keepdims=False, *, where=True)¶ Returns the average of the array elements along given axis.
Refer to
numpy.mean
for full documentation.
-
min
(axis=None, out=None, keepdims=False, initial=<no value>, where=True)¶ Return the minimum along a given axis.
Refer to
numpy.amin
for full documentation.
-
nonzero
()¶ Return the indices of the elements that are non-zero.
Refer to
numpy.nonzero
for full documentation.
-
prod
(axis=None, dtype=None, out=None, keepdims=False, initial=1, where=True)[source]¶ Return the product of the array elements over the given axis
Refer to
numpy.prod
for full documentation.
-
ptp
(axis=None, out=None, keepdims=False)¶ Peak to peak (maximum - minimum) value along a given axis.
Refer to
numpy.ptp
for full documentation.
-
put
(indices, values, mode='raise')[source]¶ Set
a.flat[n] = values[n]
for alln
in indices.Refer to
numpy.put
for full documentation.
-
ravel
([order])[source]¶ Return a flattened array.
Refer to
numpy.ravel
for full documentation.
-
round
(decimals=0, out=None)¶ Return
a
with each element rounded to the given number of decimals.Refer to
numpy.around
for full documentation.
-
searchsorted
(v, side='left', sorter=None)[source]¶ Find indices where elements of v should be inserted in a to maintain order.
For full documentation, see
numpy.searchsorted
-
std
(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True)¶ Returns the standard deviation of the array elements along given axis.
Refer to
numpy.std
for full documentation.
-
sum
(axis=None, dtype=None, out=None, keepdims=False, initial=0, where=True)¶ Return the sum of the array elements over the given axis.
Refer to
numpy.sum
for full documentation.
-
trace
(offset=0, axis1=0, axis2=1, dtype=None, out=None)¶ Return the sum along diagonals of the array.
Refer to
numpy.trace
for full documentation.
-