Up to date
This page is up to date for NumDot stable.
If you still find outdated information, please open an issue.
NumPy, xtensor, and NumDot
NumDot attempts to recreate NumPy-like behavior, and uses xtensor under the hood. While most things are consistent across all three libraries, differences exist.
Fundamental Comparison
NumDot functions always return tensors, to avoid accidentally promoting dtypes. NumPy returned types like
np.float32can be used like primitive numbers.NumDot does not overload operators like
+and*, due to a gdscript limitation.NumDot does not support subscripts (
a[start:stop:step], due to a gdscript limitation. Instead, usea.get(nd.range(start, stop, step).NumPy supports keyword arguments. NumDot only supports ordered arguments, due to a gdscript limitation.
xtensoroperations are lazy views. NumPy and NumDot operations evaluate immediately, with the exception of strideable views.
Function Cheat Sheet
NumPy |
xtensor |
NumDot |
Notes |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
xt::view(a, { 0 })a(0) |
a.get(0)a.get_int(0)a.get_float(0) |
Create a view, or return an element of the tensor. |
|
xt::view(a, { 0 }) = ba(0) = b |
a.set(b, 0) |
Update a slice of a tensor. |
|
|
|
Select all elements. |
|
|
|
Insert new axis. |
|
|
|
Ellipsis stands in for all other dimensions. |
|
|
|
Select elements starting at index 2. |
|
|
|
Select elements ending at index 2. |
|
|
|
Select elements starting at index 2, ending at index 4. |
|
|
|
Select every second element, starting at index 2, ending at index 4. |
a + bnp.add(a, b) |
|
|
|
a - bnp.subtract(a, b) |
|
|
|
a * bnp.multiply(a, b) |
|
|
|
a / bnp.divide(a, b) |
|
|
|
|
|
|
Analogous for all trig functions. |
np.degreesnp.deg2rad |
|
|
|
np.radiansnp.rad2deg |
|
|
Haven't found what you need? Try nd!