PolyArray¶
- class PolyArray¶
A NumPy-like multidimensional array of polynomials. Supports indexing, slicing, broadcast-compatible arithmetic, and utility methods for building optimization expressions.
Methods
Return a copy of the array.
Deprecated alias of
evaluate().Return a diagonal extracted from the array.
Evaluate each element by substituting variable values.
Fill all elements with a single polynomial or scalar value.
Return a flattened 1D copy of the array.
Return the indices of non-zero elements.
Return a flattened 1D view when possible.
Repeat elements of the array.
Return a reshaped view of the array.
Roll array elements along an axis.
Substitute variables in all elements of the array.
Sum array elements over the specified axis or axes.
Return a view with two axes swapped.
Take elements from the array along an axis.
Convert the polynomial array to nested Python lists.
Convert the polynomial array to a NumPy
float64ndarray.Alias of
to_list().Alias of
to_numpy().Permute axes and return a transposed view.
Return a view of the same underlying data.
Attributes
A transposed view of the array.
A 1D view of the array.
The number of dimensions of the array.
The shape of the array.
The total number of elements in the array.
- class Iterator¶
- __init__(*args, **kwargs)¶
- __nb_signature__ = 'class Iterator(typing.Generic[__Dim])'¶
- __add__(self, arg: Poly | float | int, /) PolyArray[_Dim]¶
- __add__(self, arg: list | ndarray, /) PolyArray[Dim]
- __add__(self, arg: PolyArray[Dim]) PolyArray[Dim]
Perform element-wise arithmetic between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
Overload 1.
- Args:
arg (amplify.Poly | float | int)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
Overload 3.
- Args:
arg (amplify.PolyArray[Dim])
- Returns:
amplify.PolyArray[Dim]:
- __and__(self, arg: Poly | bool, /) PolyArray[_Dim]¶
- __and__(self, arg: list | ndarray[dtype=bool], /) PolyArray[Dim]
- __and__(self, arg: PolyArray[Dim]) PolyArray[Dim]
Perform an element-wise logical operation between two polynomial arrays, or between a polynomial array and a boolean, using broadcasting rules. This is meaningful only for polynomials that take values 0 or 1.
Overload 1.
- Args:
arg (amplify.Poly | bool)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
Overload 3.
- Args:
arg (amplify.PolyArray[Dim])
- Returns:
amplify.PolyArray[Dim]:
- __bool__(self) bool¶
Cast a polynomial array to a number. This is valid only when the array has exactly one element and that element is a constant polynomial.
- 戻り値の型:
- __copy__(self) PolyArray[_Dim]¶
Copy the array.
Each polynomial in the array is copied as well. Equivalent to
copy().- 戻り値の型:
PolyArray[_Dim]
- __deepcopy__(self, arg: dict, /) PolyArray[_Dim]¶
Copy the array.
Each polynomial in the array is copied as well. Equivalent to
copy().
- __eq__(self, arg: PolyArray | Poly | float | int | list | ndarray, /) numpy.ndarray[dtype=bool]¶
Perform element-wise comparisons between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
- __float__(self) float¶
Cast a polynomial array to a number. This is valid only when the array has exactly one element and that element is a constant polynomial.
- 戻り値の型:
- __getitem__(self: PolyArray[Dim], arg: tuple | slice | EllipsisType | int | None) PolyArray[Dim]¶
Return a polynomial or a polynomial subarray.
Supports indexing with integers, slices, ellipsis, and newaxis. Advanced indexing with arrays of indices is not supported.
- パラメータ:
arg (tuple | slice | EllipsisType | int | None) -- An index specified as an integer, slice, ellipsis, or newaxis.
- 戻り値:
Selected element or slice, depending on the index.
- 戻り値の型:
- 例外:
IndexError -- If any index is out of bounds.
TypeError -- If index type is invalid.
サンプル
from amplify import VariableGenerator, newaxis q = VariableGenerator().array("Binary", (3, 4)) print(q[1, 2]) # Output: Poly(q_{1,2}) print(q[0]) # Output: PolyArray([q_{0,0}, q_{0,1}, q_{0,2}, q_{0,3}]) print(q[:, 0]) # Output: PolyArray([q_{0,0}, q_{1,0}, q_{2,0}]) print(q[..., 0]) # Output: PolyArray([q_{0,0}, q_{1,0}, q_{2,0}]) print(q[1, newaxis]) # Output: PolyArray([[q_{1,0}, q_{1,1}, q_{1,2}, q_{1,3}]])
- __iadd__(self, arg: Poly | float | int, /) PolyArray[_Dim]¶
- __iadd__(self, arg: list | ndarray, /) PolyArray[_Dim]
- __iadd__(self: PolyArray[Dim], arg: PolyArray[__Dim]) PolyArray[Dim]
Perform element-wise arithmetic in place between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
Overload 1.
- Args:
arg (amplify.Poly | float | int)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[_Dim]:
Overload 3.
- Args:
self (amplify.PolyArray[Dim])
arg (amplify.PolyArray[__Dim])
- Returns:
amplify.PolyArray[Dim]:
- __iand__(self, arg: Poly | bool, /) PolyArray[_Dim]¶
- __iand__(self, arg: list | ndarray[dtype=bool], /) PolyArray[_Dim]
- __iand__(self: PolyArray[Dim], arg: PolyArray[__Dim]) PolyArray[Dim]
Perform an element-wise logical operation in place between two polynomial arrays, or between a polynomial array and a boolean, using broadcasting rules. This is meaningful only for polynomials that take values 0 or 1.
Overload 1.
- Args:
arg (amplify.Poly | bool)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[_Dim]:
Overload 3.
- Args:
self (amplify.PolyArray[Dim])
arg (amplify.PolyArray[__Dim])
- Returns:
amplify.PolyArray[Dim]:
- __imul__(self, arg: Poly | float | int, /) PolyArray[_Dim]¶
- __imul__(self, arg: list | ndarray, /) PolyArray[_Dim]
- __imul__(self: PolyArray[Dim], arg: PolyArray[__Dim]) PolyArray[Dim]
Perform element-wise arithmetic in place between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
Overload 1.
- Args:
arg (amplify.Poly | float | int)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[_Dim]:
Overload 3.
- Args:
self (amplify.PolyArray[Dim])
arg (amplify.PolyArray[__Dim])
- Returns:
amplify.PolyArray[Dim]:
- __index__(self) int¶
Cast a polynomial array to a number. This is valid only when the array has exactly one element and that element is a constant polynomial.
- 戻り値の型:
- __int__(self) int¶
Cast a polynomial array to a number. This is valid only when the array has exactly one element and that element is a constant polynomial.
- 戻り値の型:
- __invert__(self) PolyArray[_Dim]¶
Perform an element-wise arithmetic operation.
- 戻り値の型:
PolyArray[_Dim]
- __ior__(self, arg: Poly | bool, /) PolyArray[_Dim]¶
- __ior__(self, arg: list | ndarray[dtype=bool], /) PolyArray[_Dim]
- __ior__(self: PolyArray[Dim], arg: PolyArray[__Dim]) PolyArray[Dim]
Perform an element-wise logical operation in place between two polynomial arrays, or between a polynomial array and a boolean, using broadcasting rules. This is meaningful only for polynomials that take values 0 or 1.
Overload 1.
- Args:
arg (amplify.Poly | bool)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[_Dim]:
Overload 3.
- Args:
self (amplify.PolyArray[Dim])
arg (amplify.PolyArray[__Dim])
- Returns:
amplify.PolyArray[Dim]:
- __isub__(self, arg: Poly | float | int, /) PolyArray[_Dim]¶
- __isub__(self, arg: list | ndarray, /) PolyArray[_Dim]
- __isub__(self: PolyArray[Dim], arg: PolyArray[__Dim]) PolyArray[Dim]
Perform element-wise arithmetic in place between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
Overload 1.
- Args:
arg (amplify.Poly | float | int)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[_Dim]:
Overload 3.
- Args:
self (amplify.PolyArray[Dim])
arg (amplify.PolyArray[__Dim])
- Returns:
amplify.PolyArray[Dim]:
- __iter__(self) Iterator[_Dim]¶
Iterate over the first axis of the polynomial array.
If the array has one or fewer dimensions, each yielded item is a polynomial. If the array has two or more dimensions, each yielded item is a subarray with one fewer dimension.
- 戻り値の型:
Iterator[_Dim]
- __ixor__(self, arg: Poly | bool, /) PolyArray[_Dim]¶
- __ixor__(self, arg: list | ndarray[dtype=bool], /) PolyArray[_Dim]
- __ixor__(self: PolyArray[Dim], arg: PolyArray[__Dim]) PolyArray[Dim]
Perform an element-wise logical operation in place between two polynomial arrays, or between a polynomial array and a boolean, using broadcasting rules. This is meaningful only for polynomials that take values 0 or 1.
Overload 1.
- Args:
arg (amplify.Poly | bool)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[_Dim]:
Overload 3.
- Args:
self (amplify.PolyArray[Dim])
arg (amplify.PolyArray[__Dim])
- Returns:
amplify.PolyArray[Dim]:
- __matmul__(self, arg: PolyArray | ndarray, /) Poly | PolyArray[Dim]¶
Perform matrix multiplication on two polynomial arrays. For arrays with three or more dimensions, the last two dimensions are treated as matrices and the remaining dimensions as batch dimensions. Broadcasting is applied to the batch dimensions.
- __mul__(self, arg: Poly | float | int, /) PolyArray[_Dim]¶
- __mul__(self, arg: list | ndarray, /) PolyArray[Dim]
- __mul__(self, arg: PolyArray[Dim]) PolyArray[Dim]
Perform element-wise arithmetic between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
Overload 1.
- Args:
arg (amplify.Poly | float | int)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
Overload 3.
- Args:
arg (amplify.PolyArray[Dim])
- Returns:
amplify.PolyArray[Dim]:
- __ne__(self, arg: PolyArray | Poly | float | int | list | ndarray, /) numpy.ndarray[dtype=bool]¶
Perform element-wise comparisons between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
- __or__(self, arg: Poly | bool, /) PolyArray[_Dim]¶
- __or__(self, arg: list | ndarray[dtype=bool], /) PolyArray[Dim]
- __or__(self, arg: PolyArray[Dim]) PolyArray[Dim]
Perform an element-wise logical operation between two polynomial arrays, or between a polynomial array and a boolean, using broadcasting rules. This is meaningful only for polynomials that take values 0 or 1.
Overload 1.
- Args:
arg (amplify.Poly | bool)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
Overload 3.
- Args:
arg (amplify.PolyArray[Dim])
- Returns:
amplify.PolyArray[Dim]:
- __radd__(self, arg: Poly | float | int, /) PolyArray[_Dim]¶
- __radd__(self, arg: list | ndarray, /) PolyArray[Dim]
Perform element-wise arithmetic between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
Overload 1.
- Args:
arg (amplify.Poly | float | int)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
- __rand__(self, arg: Poly | bool, /) PolyArray[_Dim]¶
- __rand__(self, arg: list | ndarray[dtype=bool], /) PolyArray[Dim]
Perform an element-wise logical operation between two polynomial arrays, or between a polynomial array and a boolean, using broadcasting rules. This is meaningful only for polynomials that take values 0 or 1.
Overload 1.
- Args:
arg (amplify.Poly | bool)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
- __rmatmul__(self, arg: NDArray | PolyArray) Poly | PolyArray[Dim]¶
Perform matrix multiplication on two polynomial arrays. For arrays with three or more dimensions, the last two dimensions are treated as matrices and the remaining dimensions as batch dimensions. Broadcasting is applied to the batch dimensions.
- __rmul__(self, arg: Poly | float | int, /) PolyArray[_Dim]¶
- __rmul__(self, arg: list | ndarray, /) PolyArray[Dim]
Perform element-wise arithmetic between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
Overload 1.
- Args:
arg (amplify.Poly | float | int)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
- __ror__(self, arg: Poly | bool, /) PolyArray[_Dim]¶
- __ror__(self, arg: list | ndarray[dtype=bool], /) PolyArray[Dim]
Perform an element-wise logical operation between two polynomial arrays, or between a polynomial array and a boolean, using broadcasting rules. This is meaningful only for polynomials that take values 0 or 1.
Overload 1.
- Args:
arg (amplify.Poly | bool)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
- __rsub__(self, arg: Poly | float | int, /) PolyArray[_Dim]¶
- __rsub__(self, arg: list | ndarray, /) PolyArray[Dim]
Perform element-wise arithmetic between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
Overload 1.
- Args:
arg (amplify.Poly | float | int)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
- __rxor__(self, arg: Poly | bool, /) PolyArray[_Dim]¶
- __rxor__(self, arg: list | ndarray[dtype=bool], /) PolyArray[Dim]
Perform an element-wise logical operation between two polynomial arrays, or between a polynomial array and a boolean, using broadcasting rules. This is meaningful only for polynomials that take values 0 or 1.
Overload 1.
- Args:
arg (amplify.Poly | bool)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
- __setitem__(
- self,
- arg: tuple | slice | EllipsisType | int | None,
- value: Poly | float | int | list | ndarray | PolyArray,
Assign a polynomial or a polynomial subarray.
Supports indexing with integers, slices, ellipsis, and newaxis. Advanced indexing with arrays of indices is not supported.
- パラメータ:
- 例外:
IndexError -- If any index is out of bounds.
TypeError -- If index type is invalid or value shape is incompatible.
- __sub__(self, arg: Poly | float | int, /) PolyArray[_Dim]¶
- __sub__(self, arg: list | ndarray, /) PolyArray[Dim]
- __sub__(self, arg: PolyArray[Dim]) PolyArray[Dim]
Perform element-wise arithmetic between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
Overload 1.
- Args:
arg (amplify.Poly | float | int)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
Overload 3.
- Args:
arg (amplify.PolyArray[Dim])
- Returns:
amplify.PolyArray[Dim]:
- __truediv__(self, arg: float | int, /) PolyArray[_Dim]¶
- __truediv__(self, arg: list | ndarray, /) PolyArray[Dim]
Perform element-wise arithmetic between two polynomial arrays, or between a polynomial array and a scalar, using broadcasting rules.
Overload 1.
- Args:
arg (float | int)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
- __xor__(self, arg: Poly | bool, /) PolyArray[_Dim]¶
- __xor__(self, arg: list | ndarray[dtype=bool], /) PolyArray[Dim]
- __xor__(self, arg: PolyArray[Dim]) PolyArray[Dim]
Perform an element-wise logical operation between two polynomial arrays, or between a polynomial array and a boolean, using broadcasting rules. This is meaningful only for polynomials that take values 0 or 1.
Overload 1.
- Args:
arg (amplify.Poly | bool)
- Returns:
amplify.PolyArray[_Dim]:
Overload 2.
- Args:
arg (list | ndarray)
- Returns:
amplify.PolyArray[Dim]:
Overload 3.
- Args:
arg (amplify.PolyArray[Dim])
- Returns:
amplify.PolyArray[Dim]:
- copy(self) PolyArray[_Dim]¶
Return a copy of the array.
Each polynomial in the array is copied as well.
- 戻り値:
Copy of the array.
- 戻り値の型:
PolyArray[_Dim]
- decode(self, values: Values) numpy.ndarray[dtype=float64]¶
- decode(self, values: Values, default: float) numpy.ndarray[dtype=float64]
- decode(self, values: Values, default: None) PolyArray[_Dim]
Deprecated alias of
evaluate().This method is deprecated since Amplify v1.0.0 and will be removed in a future version.
Overload 1.
- Args:
values (amplify.Values): Values from optimization results, such as
result.best.values.
- Returns:
numpy.ndarray: Evaluated numeric values with the same shape.
Overload 2.
- Args:
values (amplify.Values): Values from optimization results, such as
result.best.values.default (float): The default numeric value used for variables not present in
values.
- Returns:
numpy.ndarray: Evaluated numeric values with the same shape.
Overload 3.
- Args:
values (amplify.Values): Values from optimization results, such as
result.best.values.default (None): Set to
Noneto keep unassigned variables symbolic.
- Returns:
amplify.PolyArray[_Dim]: Array with substitutions applied.
- diagonal(self: PolyArray[Dim], offset: int = 0, axis1: int = 0, axis2: int = 1) PolyArray[Dim]¶
Return a diagonal extracted from the array.
Take the diagonal along
axis1andaxis2with optionaloffset. Unlike NumPy, return a copy.
- evaluate(self, values: Values) numpy.ndarray[dtype=float64]¶
- evaluate(self, values: Values, default: float) numpy.ndarray[dtype=float64]
- evaluate(self, values: Values, default: None) PolyArray[_Dim]
Evaluate each element by substituting variable values.
Pass optimization result values to get a NumPy array with the same shape. The behavior for unassigned variables can be controlled by
default.When
default=None, keep variables not present invaluessymbolic and return aPolyArray.Overload 1.
- Args:
values (amplify.Values): Values from optimization results, such as
result.best.values.
- Returns:
numpy.ndarray: Evaluated numeric values with the same shape.
Overload 2.
- Args:
values (amplify.Values): Values from optimization results, such as
result.best.values.default (float): The default numeric value used for variables not present in
values.
- Returns:
numpy.ndarray: Evaluated numeric values with the same shape.
Overload 3.
- Args:
values (amplify.Values): Values from optimization results, such as
result.best.values.default (None): Set to
Noneto keep unassigned variables symbolic.
- Returns:
amplify.PolyArray[_Dim]: Array with substitutions applied.
- fill(self, value: Poly | float | int) None¶
Fill all elements with a single polynomial or scalar value.
- nonzero(self) tuple[numpy.ndarray[dtype=uint64], ...]¶
Return the indices of non-zero elements.
- repeat(self, repeats: int | list[int], axis: None = None) PolyArray[Dim1]¶
- repeat(self, repeats: int | list[int], axis: int) PolyArray[_Dim]
Repeat elements of the array.
When
axisisNone, repetitions are applied to the flattened array, and a 1D array is returned.Overload 1.
- Args:
repeats (int | list[int]): The number of repetitions for each element, or a list of repetitions.
axis (None): Axis along which to repeat. If
None, the array is repeated as a flattened array. Defaults toNone.
- Returns:
amplify.PolyArray[Dim1]: Array with repeated elements.
- Raises:
ValueError: If repeats contains negative values, axis is out of bounds, or shapes are incompatible. TypeError: If repeats is not an integer or list of integers.
Overload 2.
- Args:
repeats (int | list[int]): The number of repetitions for each element, or a list of repetitions.
axis (int): Axis along which to repeat. If
None, the array is repeated as a flattened array.
- Returns:
amplify.PolyArray[_Dim]: Array with repeated elements.
- Raises:
ValueError: If repeats contains negative values, axis is out of bounds, or shapes are incompatible. TypeError: If repeats is not an integer or list of integers.
- reshape(self, shape: int | tuple[int, ...]) PolyArray[Dim]¶
- reshape(self, *shape: int) PolyArray[Dim]
Return a reshaped view of the array.
The new shape must be compatible with the current size. At most one
-1is allowed to infer an unknown dimension.Overload 1.
- Args:
shape (int | tuple[int, ...]): The new shape specified as a tuple.
- Returns:
amplify.PolyArray[Dim]: Reshaped array.
- Raises:
ValueError: If shape is incompatible with current size. TypeError: If shape is not int/tuple of ints.
Overload 2.
- Args:
*shape (int): The new shape given as one integer for each axis.
- Returns:
amplify.PolyArray[Dim]: Reshaped array.
- Raises:
ValueError: If shape is incompatible with current size. TypeError: If shape is not int/tuple of ints.
- roll(self, shift: int, axis: int | None = None) PolyArray[_Dim]¶
Roll array elements along an axis.
If
axisisNone, the array is rolled in flattened order. Unlike NumPy,rollis provided as a method, and cannot roll multiple axes simultaneously.- パラメータ:
- 戻り値:
Array with rolled elements.
- 戻り値の型:
PolyArray[_Dim]
- 例外:
ValueError -- If axis is out of bounds.
- sum(self, axis: None = None) Poly¶
- sum(self, axis: int | tuple[int, ...]) Poly | PolyArray[Dim]
Sum array elements over the specified axis or axes.
Without
axis, all elements are summed into a single polynomial. Withaxis, the output type depends on the reduced dimensions.Overload 1.
- Args:
axis (None): The axis or axes to reduce. Defaults to
None.
- Returns:
amplify.Poly: Summation result. Shape depends on
axis.
Overload 2.
- Args:
axis (int | tuple[int, ...]): The axis or axes to reduce.
- Returns:
Poly | PolyArray[Dim]: Summation result. Shape depends on
axis.
- swapaxes(self, axis1: int, axis2: int) PolyArray[_Dim]¶
Return a view with two axes swapped.
- パラメータ:
- 戻り値:
Array with the two axes swapped.
- 戻り値の型:
PolyArray[_Dim]
- 例外:
ValueError -- If either axis is out of bounds.
- take(self: PolyArray[Dim], indices: int | list[int], axis: int | None = None) PolyArray[Dim]¶
Take elements from the array along an axis.
If
axisisNone, indices are interpreted on the flattened array. Elements are always copied, even when a view could be returned.- パラメータ:
- 戻り値:
Selected elements. Shape depends on
indicesandaxis.- 戻り値の型:
- 例外:
IndexError -- If any index is out of bounds.
ValueError -- If axis is out of bounds.
TypeError -- If indices is not int or list of ints.
- to_list(self) list¶
Convert the polynomial array to nested Python lists.
For 0D arrays, return the scalar polynomial itself.
- 戻り値:
Nested representation of elements, or the scalar polynomial itself for 0D arrays.
- 戻り値の型:
- to_numpy(self) numpy.ndarray[dtype=float64]¶
Convert the polynomial array to a NumPy
float64ndarray.- 戻り値:
Converted NumPy array.
- 戻り値の型:
- tolist(self) list¶
Alias of
to_list().- 戻り値:
Nested representation of elements, or the scalar polynomial itself for 0D arrays.
- 戻り値の型:
- tonumpy(self) numpy.ndarray[dtype=float64]¶
Alias of
to_numpy().- 戻り値:
Converted NumPy array.
- 戻り値の型:
- transpose(self, axes: tuple[int, ...] | None = None) PolyArray[_Dim]¶
- transpose(self, *axes: int) PolyArray[_Dim]
Permute axes and return a transposed view.
If
axesis not specified, the axis order is reversed. Negative axes are supported and are normalized using the array dimension.Overload 1.
- Args:
axes (tuple[int, ...] | None): Axis permutation. If
None, the axis order is reversed. Defaults toNone.
- Returns:
amplify.PolyArray[_Dim]: Array with permuted axes.
- Raises:
ValueError: If any axis is out of bounds or permutation is invalid. TypeError: If axes is not a tuple of integers.
Overload 2.
- Args:
*axes (int): Axis permutation specified as positional arguments.
- Returns:
amplify.PolyArray[_Dim]: Array with permuted axes.
- Raises:
ValueError: If any axis is out of bounds or permutation is invalid. TypeError: If axes is not a tuple of integers.
- view(self) PolyArray[_Dim]¶
Return a view of the same underlying data.
- 戻り値:
View of the same underlying data.
- 戻り値の型:
PolyArray[_Dim]
- property T¶
A transposed view of the array.
Equivalent to
transpose()with default axis order.- 戻り値の型:
PolyArray[_Dim]
- __nb_signature__ = 'class PolyArray(typing.Generic[_Dim])'¶
- property shape¶
The shape of the array.
Read this property to get the current shape as a tuple. Set this property to reshape the array in-place if the requested shape is compatible with the current size.