Array(*arguments, **keyword_arguments)
Source¶
Values of one type in one or several dimensions, wrapping a numpy array.
An Array never changes: every operation returns a new Array.
- Create it with
from_list,from_numpy,filled,from_range,from_spacing,from_date_partsorrandom. - Combine it with
+,-,*,/,//,%,**, and booleans with&,|,~. - Select values with
select,check,takeandreplace. - Compute with
computeandapply. - Rearrange it with
reshape,transpose,flatten,sortandunique. - Read it with
shape,dtype,to_list,to_value,to_numpyandis_equal. - Change the type of its values with
convert.
Calling ndp.Array(...), comparisons, brackets, for, in, len, bool and @ are refused
with RefusedOperationError, which names the method to use instead.
Added in version 0.1.0
Examples:
import numdaplot as ndp
prices = ndp.Array.from_list([12.5, 8.0, 30.0])
prices
# Array([12.5, 8. , 30. ], dtype=FLOAT64)
prices.shape
# Shape(dimensions=[3])
prices.dtype
# <Type.FLOAT64: 10>
Creation¶
from_list(values, dtype=None)
Source¶
Create an Array from a Python list, or from nested lists for several dimensions.
The type is guessed when omitted: integers give INT64, decimals or a mix of integers and
decimals give FLOAT64, then BOOL, TEXT, DATE, DATETIME and DURATION.
None is a missing value, only accepted for decimals, texts, dates, datetimes and durations.
Added in version 0.1.0
Parameters:
-
values(NestedValues)The values, a
NestedValuessuch as[1, 2, 3],["Paris", None]or[[1, 2], [3, 4]]. Nested lists must form a regular block. -
dtype(Type | None, default:None)The type to store the values as, guessed from the values when omitted. Required when no value is present.
Returns:
-
SelfA new Array.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IrregularListErrorWhen nested lists do not form a regular block.
-
IncompatibleTypesErrorWhen the values mix several kinds of types, such as numbers and texts.
-
MissingTypeErrorWhen
dtypeis omitted and no value is present. -
UnsupportedMissingErrorWhen a value is missing and the type cannot hold missing values.
-
ValueConversionErrorWhen the values cannot be stored as
dtypewithout losing information. -
TimeOverflowErrorWhen a datetime is outside 1677 to 2262, or a duration beyond about 292 years.
-
UnsupportedTypeError
Examples:
from_numpy(values)
Source¶
Create an Array from a copy of a numpy array; changing the numpy array never changes the Array.
Added in version 0.1.0
Parameters:
-
values(numpy.typing.NDArray[Any])
Returns:
-
SelfA new Array.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
UnsupportedTypeErrorWhen numdaplot has no equivalent type, for example complex numbers or other Python objects.
-
TimeOverflowErrorWhen a duration in microseconds is beyond about 292 years, which
DURATIONcannot hold.
Examples:
filled(shape, value, dtype=None)
Source¶
Create an Array of a shape, with the same value everywhere.
Added in version 0.1.0
Parameters:
-
shape(Shape)The shape of the Array.
-
value(ScalarValue)The repeated value, a
ScalarValuesuch as0,"Paris"orTrue. -
dtype(Type | None, default:None)The type to store the value as, guessed from the value when omitted.
Returns:
-
SelfA new Array.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ValueConversionErrorWhen the value cannot be stored as
dtypewithout losing information. -
TimeOverflowErrorWhen a datetime is outside 1677 to 2262, or a duration beyond about 292 years.
Examples:
from_range(sequence)
Source¶
Create a one-dimensional Array of the numbers of a regular sequence.
Unlike the Python range, the stop is included by default.
Added in version 0.1.0
Parameters:
-
sequence(Range)
Returns:
-
SelfA new Array of integers when the start and the step are integers, of decimals otherwise.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
Examples:
from_date_parts(parts)
Source¶
Create an Array of dates from their year, their month and their day, such as three columns of a file.
Added in version 0.1.0
Parameters:
-
parts(DateParts)The year, the month and the day of each date, Arrays of whole numbers of the same shape.
Returns:
-
SelfA new
DATEArray of the shape of the parts. A date is missing where one of its parts is missing.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ValueConversionErrorAt the first part that is not a whole number, such as the day 3.5, then at the first year, month and day that form no date, such as the 31st of February, a month 13 or a year outside 1 to 9999.
Examples:
import numdaplot as ndp
accidents = ndp.Table.from_arrays(
{
"jour": ndp.Array.from_list([14, 25]),
"mois": ndp.Array.from_list([7, 12]),
"an": ndp.Array.from_list([2025, 2025]),
}
)
years = accidents.column("an")
parts = ndp.DateParts(year=years, month=accidents.column("mois"), day=accidents.column("jour"))
ndp.Array.from_date_parts(parts)
# Array(['2025-07-14', '2025-12-25'], dtype=DATE)
from_spacing(spacing)
Source¶
Create a one-dimensional Array of evenly spaced decimals.
Added in version 0.1.0
Parameters:
-
spacing(Spacing)The bounds, the count of values and whether each bound is among them.
Returns:
-
SelfA new
FLOAT64Array ofcountvalues.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
Examples:
random(distribution, shape, seed=None)
Source¶
Create an Array of values drawn at random from a distribution.
Added in version 0.1.0
Parameters:
-
distribution(Uniform | Normal | RandomIntegers)The
Distributionfollowed by the values, such asndp.Uniform(low=0, high=10): seeDistributionfor every distribution. -
shape(Shape)The shape of the Array.
-
seed(int | None, default:None)A number, at least 0, giving the same values at each call. Different values at each call when omitted.
Returns:
-
SelfA new
FLOAT64Array forUniformandNormal,INT64forRandomIntegers.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
InvalidSeedErrorWhen
seedis lower than 0.
Examples:
Information¶
Conversion and comparison¶
to_list()
Source¶
Return the values as a Python list, with one nested list per row for several dimensions.
This is the way to loop over the values: for value in array.to_list().
Added in version 0.1.0
Returns:
-
list[Any]Python values,
datetime.timefor times of day. A missing date, datetime, duration or time of day becomesNone, a missing decimalnan.
Examples:
to_value()
Source¶
Return the single value of an Array holding exactly one value, as a Python value.
Added in version 0.1.0
Returns:
-
AnyThe value,
Nonefor a missing date, datetime or duration.
Raises:
-
NotSingleValueErrorWhen the Array does not hold exactly one value.
Examples:
to_numpy()
Source¶
Return a numpy copy of the values; changing it never changes the Array.
Added in version 0.1.0
Returns:
-
numpy.typing.NDArrayA writable copy of the values. Texts use
StringDTypewith NaN as missing value. Times of day are Pythondatetime.timeobjects, None where missing, as numpy has no type for them.
Examples:
is_equal(equality)
Source¶
Return whether this Array and another one have the same shape and the same values.
Two missing values at the same position are equal.
Added in version 0.1.0
Parameters:
-
equality(Equality)The other Array, and whether the types must also be the same.
Returns:
-
boolTrue when both Arrays are equal.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
Examples:
Type change¶
convert(conversion)
Source¶
Return the values converted to another type, in the same shape, missing values staying missing.
Added in version 0.2.0
Parameters:
-
conversion(ArrayConversion)The new type, and the date format or the rule reading numbers as booleans. Accepted: between number types, between numbers and booleans, from numbers, booleans, dates, datetimes, durations and times of day to texts, from texts to numbers, booleans (
"true"or"false"in any case), dates, datetimes or times of day, between dates and datetimes, and from datetimes to times of day.
Returns:
-
SelfA new Array, a copy when the values already have the type.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the conversion is not accepted, such as a boolean to a date.
-
InvalidConversionErrorWhen the format or the boolean rule does not apply to the conversion.
-
ValueConversionErrorAt the first value that cannot be stored in the new type, such as
"abc"read as a number, 2.5 stored as an integer, 3 read as a boolean withZERO_ONE, or"31/02/2026"read as a date. -
TimeOverflowErrorWhen a value converted to
DATETIMEis outside 1677 to 2262. -
UnsupportedMissingErrorWhen integers or booleans would hold a missing value, which an Array cannot hold: convert integers to
FLOAT64instead.
Examples:
Selection¶
select(rule)
Source¶
Return the values satisfying a rule, in one dimension.
Added in version 0.1.0
Parameters:
-
rule(Rule)A
Rule, such asndp.Greater(10)orndp.IsIn(["Paris"]): seeRulefor every rule. A missing value only satisfiesIsMissing.
Returns:
-
SelfA new one-dimensional Array, in reading order.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the rule does not apply to the type of the values.
Examples:
check(rule)
Source¶
Return whether each value satisfies a rule, keeping the shape.
Combine several checks with &, | and ~.
Added in version 0.1.0
Parameters:
-
rule(Rule)A
Rule, such asndp.Greater(10)orndp.IsIn(["Paris"]): seeRulefor every rule. A missing value only satisfiesIsMissing.
Returns:
-
SelfA new
BOOLArray of the same shape.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the rule does not apply to the type of the values.
Examples:
take(region)
Source¶
Return the values of a region of a one- or two-dimensional Array.
A row or a column chosen with Index keeps its dimension: one row of a two-dimensional
Array is still two-dimensional. Use to_value to read a single value.
Added in version 0.1.0
Parameters:
-
region(Region)The rows and the columns to take, every one of a dimension when omitted. Negative positions count from the end.
Returns:
-
SelfA new Array with as many dimensions as this one.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
DimensionErrorWhen the Array has more than two dimensions, or columns are given for a one-dimensional Array.
-
RefusedOperationErrorWhen columns are given as names, which only a Table has.
-
InvalidPositionErrorWhen a position is not a whole number inside its dimension.
Examples:
replace(replacement)
Source¶
Return a new Array whose region is replaced; this Array does not change.
Added in version 0.1.0
Parameters:
-
replacement(Replacement)The region, and a single value or an Array of exactly the shape of the region.
Returns:
-
SelfA new Array of the same shape and type.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ShapeMismatchErrorWhen an Array of new values does not have the shape of the region.
-
ValueConversionErrorWhen the new values cannot be stored in the type of the Array without losing information.
-
TimeOverflowErrorWhen a datetime is outside 1677 to 2262, or a duration beyond about 292 years.
-
(DimensionError, RefusedOperationError, InvalidPositionError)When the region does not fit the Array, as in
take.
Examples:
Calculation¶
compute(statistic, axis=None)
Source¶
Return a statistic of the values, ignoring missing values unless Count or Share is set to include them.
Added in version 0.1.0
Parameters:
-
statistic(Statistic)A
Statistic, such asndp.Mean()orndp.Quantile(0.9): seeStatisticfor every statistic. -
axis(Axis | None, default:None)EACH_ROWfor one result per row,EACH_COLUMNfor one per column, only for a two-dimensional Array. A single result for the whole Array when omitted.
Returns:
-
SelfA new Array: one value when
axisis omitted, read it withto_value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the statistic does not apply to the type of the values, such as the mean of texts.
-
DimensionErrorWhen an axis is given for an Array that is not two-dimensional.
-
EmptyArrayErrorWhen the statistic needs a value, such as
Mean, and the whole Array, or a row or column, has no present value. -
IntegerOverflowErrorWhen the
Sumof integers does not fit their type.
Warns:
-
CalculationWarningWhen a result on decimals becomes an infinite value or NaN.
Examples:
apply(function)
Source¶
Return a math function, a time function or a value mapping applied to each value.
Changed in version 0.2.0
Accepts a ValueMapping keeping the values it does not list, with others=Unmatched.KEEP, and raises
ValueConversionError when a ValueMapping gives a number that does not fit the number type of the
values. The math functions giving decimals give FLOAT64 for integers of any size. A ValueMapping
giving only missing values keeps the type of the values.
Version history (1)
Added in version 0.1.0
Parameters:
-
function(MathFunction | TimeFunction | ValueMapping)A
MathFunction, such asndp.SquareRoot(), applied to numbers, or aTimeFunction, such asndp.DatePart(unit=ndp.DatePartUnit.MONTH), applied to dates, datetimes, durations or numbers as each one states: seeMathFunctionandTimeFunctionfor every function. Or aValueMappinggiving a new value to listed values, such as codes replaced by labels.
Returns:
-
SelfA new Array of the same shape. Missing values stay missing.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the function does not apply to the type of the values, or a
ValueMappingwithUnmatched.KEEPgives new values of another family than the kept values, such as texts among numbers. -
OutOfDomainErrorWhen a value is outside the domain of a math function, such as the square root of -1.
-
UnmatchedValueErrorWhen a value has no
ValueChangein aValueMappingwhoseothersisUnmatched.ERROR. -
UnsupportedMissingErrorWhen a
ValueMappinggives integers or booleans and a missing value. -
ValueConversionErrorWhen a
ValueMappinggives a number that does not fit the number type of the values.
Warns:
-
CalculationWarningWhen a result of a math function becomes an infinite value or NaN.
Examples:
from datetime import date
import numdaplot as ndp
ndp.Array.from_list([1, 4, 9]).apply(ndp.SquareRoot())
# Array([1., 2., 3.], dtype=FLOAT64)
ndp.Array.from_list([date(2026, 3, 14)]).apply(ndp.DatePart(unit=ndp.DatePartUnit.MONTH))
# Array([3.], dtype=FLOAT64)
sexes = ndp.ValueMapping(changes=[ndp.ValueChange(1, "M"), ndp.ValueChange(2, "F")])
ndp.Array.from_list([2, 1]).apply(sexes)
# Array(['F', 'M'], dtype=TEXT)
Layout¶
reshape(shape)
Source¶
Return the same values arranged in another shape, in reading order.
Added in version 0.1.0
Parameters:
-
shape(Shape)The new shape, holding exactly as many values as the Array.
Returns:
-
SelfA new Array.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ShapeMismatchErrorWhen the new shape holds another number of values.
Examples:
transpose()
Source¶
Return the Array with its rows turned into columns.
A one-dimensional Array stays the same. With more dimensions, their order is reversed.
Added in version 0.1.0
Returns:
-
SelfA new Array.
Examples:
sort(sorting=None, axis=None)
Source¶
Return the values sorted inside each row, or inside each column.
Added in version 0.1.0
Parameters:
-
sorting(ArraySorting | None, default:None)The order and the place of missing values, the default
ArraySortingwhen omitted. -
axis(Axis | None, default:None)Axis.EACH_ROWsorts the values inside each row,Axis.EACH_COLUMNinside each column. An axis only applies to a two-dimensional Array. When omitted, each row is sorted, which sorts a one-dimensional Array as a whole.
Returns:
-
SelfA new Array of the same shape.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
DimensionErrorWhen an axis is given for an Array that is not two-dimensional.
Examples:
Arithmetic operators¶
__add__(other)
Source¶
Return the sum of each value and another operand, written array + other.
Two Arrays are combined value by value. Two Arrays of different shapes are stretched to match,
as in numpy, with a BroadcastWarning. The result follows the numpy type rules.
Added in version 0.1.0
Parameters:
-
other(Self | ScalarValue)An Array or a
ScalarValue, such as10or2.5.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ShapeMismatchErrorWhen the shapes of two Arrays cannot be combined.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
IntegerOverflowErrorWhen a result does not fit its integer type, which refuses to wrap around to a wrong number.
-
TimeOverflowErrorWhen a date or a datetime leaves 1677 to 2262, a duration exceeds about 292 years, or a time of day moves past midnight.
Examples:
__sub__(other)
Source¶
Return the difference of each value and another operand, written array - other.
Two Arrays are combined value by value. Two Arrays of different shapes are stretched to match,
as in numpy, with a BroadcastWarning. The result follows the numpy type rules.
Added in version 0.1.0
Parameters:
-
other(Self | ScalarValue)An Array or a
ScalarValue, such as10or2.5.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ShapeMismatchErrorWhen the shapes of two Arrays cannot be combined.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
IntegerOverflowErrorWhen a result does not fit its integer type, which refuses to wrap around to a wrong number.
-
TimeOverflowErrorWhen a date or a datetime leaves 1677 to 2262, a duration exceeds about 292 years, or a time of day moves past midnight.
Examples:
__mul__(other)
Source¶
Return the product of each value and another operand, written array * other.
Two Arrays are combined value by value. Two Arrays of different shapes are stretched to match,
as in numpy, with a BroadcastWarning. The result follows the numpy type rules.
Added in version 0.1.0
Parameters:
-
other(Self | ScalarValue)An Array or a
ScalarValue, such as10or2.5.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ShapeMismatchErrorWhen the shapes of two Arrays cannot be combined.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
IntegerOverflowErrorWhen a result does not fit its integer type, which refuses to wrap around to a wrong number.
-
TimeOverflowErrorWhen a date or a datetime leaves 1677 to 2262, or a duration exceeds about 292 years.
Examples:
__truediv__(other)
Source¶
Return the quotient of each value and another operand, written array / other.
Two Arrays are combined value by value. Two Arrays of different shapes are stretched to match,
as in numpy, with a BroadcastWarning. The result follows the numpy type rules.
Added in version 0.1.0
Parameters:
-
other(Self | ScalarValue)An Array or a
ScalarValue, such as10or2.5.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ShapeMismatchErrorWhen the shapes of two Arrays cannot be combined.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
TimeOverflowErrorWhen a date or a datetime leaves 1677 to 2262, or a duration exceeds about 292 years.
Examples:
__floordiv__(other)
Source¶
Return the whole quotient of each value and another operand, written array // other.
Two Arrays are combined value by value. Two Arrays of different shapes are stretched to match,
as in numpy, with a BroadcastWarning. The result follows the numpy type rules.
Added in version 0.1.0
Parameters:
-
other(Self | ScalarValue)An Array or a
ScalarValue, such as10or2.5.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ShapeMismatchErrorWhen the shapes of two Arrays cannot be combined.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
OutOfDomainErrorWhen integers are divided by 0: convert them to
FLOAT64first. -
IntegerOverflowErrorWhen a result does not fit its integer type, which refuses to wrap around to a wrong number.
Examples:
__mod__(other)
Source¶
Return the remainder of each value and another operand, written array % other.
Two Arrays are combined value by value. Two Arrays of different shapes are stretched to match,
as in numpy, with a BroadcastWarning. The result follows the numpy type rules.
Added in version 0.1.0
Parameters:
-
other(Self | ScalarValue)An Array or a
ScalarValue, such as10or2.5.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ShapeMismatchErrorWhen the shapes of two Arrays cannot be combined.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
OutOfDomainErrorWhen integers are divided by 0: convert them to
FLOAT64first.
Examples:
__pow__(other)
Source¶
Return the power of each value and another operand, written array ** other.
Two Arrays are combined value by value. Two Arrays of different shapes are stretched to match,
as in numpy, with a BroadcastWarning. The result follows the numpy type rules.
Added in version 0.1.0
Parameters:
-
other(Self | ScalarValue)An Array or a
ScalarValue, such as10or2.5.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
ShapeMismatchErrorWhen the shapes of two Arrays cannot be combined.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
OutOfDomainErrorWhen integers are raised to a negative power: convert them to
FLOAT64first. -
IntegerOverflowErrorWhen a result does not fit its integer type, which refuses to wrap around to a wrong number.
Examples:
__neg__()
Source¶
Return the opposite of each value, written -array.
Added in version 0.1.0
Returns:
-
SelfA new Array.
Raises:
-
IncompatibleTypesErrorWhen the values have no opposite, such as texts or booleans.
-
IntegerOverflowErrorWhen an integer has no opposite in its type, such as any positive
UINT8.
Examples:
Arithmetic operators with a value on the left¶
__radd__(other)
Source¶
Return the sum of a single value and each value, written value + array.
Added in version 0.1.0
Parameters:
-
other(ScalarValue)A
ScalarValue, such as10or2.5, on the left of the operator.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
IntegerOverflowErrorWhen a result does not fit its integer type, which refuses to wrap around to a wrong number.
-
TimeOverflowErrorWhen a date or a datetime leaves 1677 to 2262, a duration exceeds about 292 years, or a time of day moves past midnight.
Examples:
__rsub__(other)
Source¶
Return the difference of a single value and each value, written value - array.
Added in version 0.1.0
Parameters:
-
other(ScalarValue)A
ScalarValue, such as10or2.5, on the left of the operator.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
IntegerOverflowErrorWhen a result does not fit its integer type, which refuses to wrap around to a wrong number.
-
TimeOverflowErrorWhen a date or a datetime leaves 1677 to 2262, a duration exceeds about 292 years, or a time of day moves past midnight.
Examples:
__rmul__(other)
Source¶
Return the product of a single value and each value, written value * array.
Added in version 0.1.0
Parameters:
-
other(ScalarValue)A
ScalarValue, such as10or2.5, on the left of the operator.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
IntegerOverflowErrorWhen a result does not fit its integer type, which refuses to wrap around to a wrong number.
-
TimeOverflowErrorWhen a date or a datetime leaves 1677 to 2262, or a duration exceeds about 292 years.
Examples:
__rtruediv__(other)
Source¶
Return the quotient of a single value and each value, written value / array.
Added in version 0.1.0
Parameters:
-
other(ScalarValue)A
ScalarValue, such as10or2.5, on the left of the operator.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
Examples:
__rfloordiv__(other)
Source¶
Return the whole quotient of a single value and each value, written value // array.
Added in version 0.1.0
Parameters:
-
other(ScalarValue)A
ScalarValue, such as10or2.5, on the left of the operator.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
OutOfDomainErrorWhen integers are divided by 0: convert them to
FLOAT64first. -
IntegerOverflowErrorWhen a result does not fit its integer type, which refuses to wrap around to a wrong number.
Examples:
__rmod__(other)
Source¶
Return the remainder of a single value and each value, written value % array.
Added in version 0.1.0
Parameters:
-
other(ScalarValue)A
ScalarValue, such as10or2.5, on the left of the operator.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
OutOfDomainErrorWhen integers are divided by 0: convert them to
FLOAT64first.
Examples:
__rpow__(other)
Source¶
Return the power of a single value and each value, written value ** array.
Added in version 0.1.0
Parameters:
-
other(ScalarValue)A
ScalarValue, such as10or2.5, on the left of the operator.
Returns:
-
SelfA new Array.
Warns:
-
CalculationWarningWhen values of decimals become NaN or an infinite value.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen the operation does not apply to the types, such as a number and a text.
-
OutOfDomainErrorWhen integers are raised to a negative power: convert them to
FLOAT64first. -
IntegerOverflowErrorWhen a result does not fit its integer type, which refuses to wrap around to a wrong number.
Examples:
Logical operators¶
__and__(other)
Source¶
Return True where both operands are True, written array & other.
Added in version 0.1.0
Parameters:
-
other(Self | bool)A
BOOLArray or a boolean.
Returns:
-
SelfA new
BOOLArray.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen an operand is not a boolean.
Examples:
__rand__(other)
Source¶
Return True where both operands are True, written value & array.
Added in version 0.1.0
Parameters:
-
other(bool)A boolean.
Returns:
-
SelfA new
BOOLArray.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen an operand is not a boolean.
Examples:
__or__(other)
Source¶
Return True where at least one operand is True, written array | other.
Added in version 0.1.0
Parameters:
-
other(Self | bool)A
BOOLArray or a boolean.
Returns:
-
SelfA new
BOOLArray.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen an operand is not a boolean.
Examples:
__ror__(other)
Source¶
Return True where at least one operand is True, written value | array.
Added in version 0.1.0
Parameters:
-
other(bool)A boolean.
Returns:
-
SelfA new
BOOLArray.
Raises:
-
InvalidTypeErrorWhen an argument is not of the type its annotation names.
-
IncompatibleTypesErrorWhen an operand is not a boolean.
Examples:
__invert__()
Source¶
Return True where the value is False, and False where it is True, written ~array.
Added in version 0.1.0
Returns:
-
SelfA new
BOOLArray.
Raises:
-
IncompatibleTypesErrorWhen the values are not booleans.
Examples:
Display¶
Refused operations¶
__eq__(other)
Source¶
Refuse array == other; use is_equal or check(ndp.Equal(...)).
Added in version 0.1.0
Parameters:
-
other(object)Any value.
Raises:
-
RefusedOperationErrorAlways.
__ne__(other)
Source¶
Refuse array != other; use is_equal or check(ndp.NotEqual(...)).
Added in version 0.1.0
Parameters:
-
other(object)Any value.
Raises:
-
RefusedOperationErrorAlways.
__lt__(other)
Source¶
Refuse array < other; use select or check with ndp.Less.
Added in version 0.1.0
Parameters:
-
other(object)Any value.
Raises:
-
RefusedOperationErrorAlways.
Examples:
__le__(other)
Source¶
Refuse array <= other; use select or check with ndp.LessOrEqual.
Added in version 0.1.0
Parameters:
-
other(object)Any value.
Raises:
-
RefusedOperationErrorAlways.
__gt__(other)
Source¶
Refuse array > other; use select or check with ndp.Greater.
Added in version 0.1.0
Parameters:
-
other(object)Any value.
Raises:
-
RefusedOperationErrorAlways.
__ge__(other)
Source¶
Refuse array >= other; use select or check with ndp.GreaterOrEqual.
Added in version 0.1.0
Parameters:
-
other(object)Any value.
Raises:
-
RefusedOperationErrorAlways.
__getitem__(key)
Source¶
Refuse array[...]; use take, select or check.
Added in version 0.1.0
Parameters:
-
key(object)Any value.
Raises:
-
RefusedOperationErrorAlways.
__setitem__(key, value)
Source¶
Refuse array[...] = value; use replace, which returns a new Array.
Added in version 0.1.0
Parameters:
-
key(object)Any value.
-
value(object)Any value.
Raises:
-
RefusedOperationErrorAlways.
__iter__()
Source¶
Refuse for value in array; iterate over array.to_list() instead.
Added in version 0.1.0
Raises:
-
RefusedOperationErrorAlways.
Examples:
__contains__(value)
Source¶
Refuse value in array; use check with ndp.Equal or ndp.IsIn.
Added in version 0.1.0
Parameters:
-
value(object)Any value.
Raises:
-
RefusedOperationErrorAlways.
__len__()
Source¶
Refuse len(array); read the shape attribute instead.
Added in version 0.1.0
Raises:
-
RefusedOperationErrorAlways.
__bool__()
Source¶
Refuse if array: and bool(array), whose meaning would be unclear.
Added in version 0.1.0
Raises:
-
RefusedOperationErrorAlways.
__matmul__(other)
Source¶
Refuse array @ other; numdaplot has no linear algebra.
Added in version 0.1.0
Parameters:
-
other(object)Any value.
Raises:
-
RefusedOperationErrorAlways.
__rmatmul__(other)
Source¶
Refuse other @ array; numdaplot has no linear algebra.
Added in version 0.1.0
Parameters:
-
other(object)Any value.
Raises:
-
RefusedOperationErrorAlways.