Class np.AxisConcatenator
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
public abstract class np.AxisConcatenator
- Inheritance
-
np.AxisConcatenator
- Derived
- Inherited Members
Remarks
Port of NumPy 2.x numpy.lib.index_tricks.AxisConcatenator. See np.RClass
for the full usage documentation.
How Python's a[1:5:2] is spelled in C#. C# has no slice literal, so a slice is
written as a string: np.r_["1:5:2"]. Strings do double duty here, exactly as in NumPy,
and are told apart by a colon — a string containing ':' is a slice expression, a
string without one is a NumPy special directive ("r", "c", "-1",
"0,2", "1,2,0"). The two grammars are disjoint in NumPy too — a directive never
contains a colon because Python's own syntax supplies the slices — so every NumPy expression
transcribes verbatim. A slice string may hold several comma-separated slices
(np.r_["1:3, 5:8"] ≙ np.r_[1:3, 5:8]), and a Slice or
Slice[] object works too (so np.s_[…] composes).
Weak scalars (NEP50). NumPy distinguishes a Python literal (5, weak — adopts the
other operand's dtype) from a NumPy scalar (np.int64(5), strong). C# has no such split,
so NumSharp maps it by type: bool / the eight integer primitives / float /
double / Complex are weak (the C# literal is the Python literal),
while char, Half and decimal — which have no Python literal — plus
every NDArray (including 0-d) are strong. To force a strong scalar, wrap
it: np.r_[int8Array, NDArray.Scalar(1L)] yields int64 where np.r_[int8Array, 1L]
yields int8. As in NumPy, a weak integer that does not fit the resolved dtype raises
OverflowException rather than wrapping.
Divergence — no bmat branch. NumPy routes a single bare string key into
matrixlib.bmat, which resolves the words in it against the CALLER'S Python frame
(sys._getframe().f_back) as variable names. C# has no equivalent, and the branch raises
NameError for every string literal anyway (np.r_['1 2; 3 4'] → "name '1' is not
defined"), so NumSharp gives a lone string the same reading as any other entry.
Fields
_axis
Axis to concatenate along (NumPy's axis).
protected readonly int _axis
Field Value
_matrix
Whether the result is coerced to a 2-D "matrix" (NumPy's matrix).
protected readonly bool _matrix
Field Value
_ndmin
Minimum dimensionality forced onto each entry (NumPy's ndmin).
protected readonly int _ndmin
Field Value
_trans1d
Where upgraded entries put their original last axis (NumPy's trans1d).
protected readonly int _trans1d
Field Value
Properties
Count
NumPy's len, which is 0 for these objects.
public int Count { get; }
Property Value
this[object[]]
Expands the index expression and concatenates the pieces.
public NDArray this[params object[] key] { get; }
Parameters
keyobject[]Slice-expression strings, special-directive strings, Slice objects, NDArrays, C# scalars, arrays and collections — in any mix.