Class AnyToVStringCastingImpl
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
NumPy's casts INTO StringDType from another class (any_to_string_resolve_descriptors<safety>): the
destination is the given descriptor or a fresh StringDType(), and the safety is fixed per source class —
safe from numbers, bool and the datetime pair, same_kind from U and S.
public sealed class AnyToVStringCastingImpl : CastingImpl
- Inheritance
-
AnyToVStringCastingImpl
- Inherited Members
Remarks
Two levels per cast, as NumPy registers them: the method's MINIMAL safety (casting,
the spec's level, which np.can_cast checks first) and the safety resolve_descriptors(DType[], DType[], out long) returns.
They differ for bool: the spec says same_kind, the resolver safe, so can_cast(bool, T, 'safe')
is True only after the resolver runs.
Methods
get_strided_loop(ArrayMethodContext, bool, long[], out NDArrayMethodFlags)
The cast's strided loop (Get(CastingImpl, ArrayMethodContext, out NDArrayMethodFlags)): NumPy's stringdtype/casts.cpp loop of the
pair, the allocators of both sides locked per call.
public override NDInnerLoopFunc get_strided_loop(ArrayMethodContext context, bool aligned, long[] strides, out NDArrayMethodFlags flags)
Parameters
contextArrayMethodContextThe resolved descriptors and the
StringDTypesides' allocators (NumSharp.ArrayMethodContext.Allocators).alignedboolUnused: the loop reads and writes unaligned cells and elements.
strideslong[]Unused: the loop takes the strides of each call.
flagsNDArrayMethodFlagsReceives the method's flags.
Returns
- NDInnerLoopFunc
The loop: [0] the source run, [1] the destination run, byte strides.
Exceptions
- ArgumentException
A
StringDTypeside without its allocator in the context.- NotSupportedException
The other class has no storage (datetime64 / timedelta64 before Stage C).
resolve_descriptors(DType[], DType[], out long)
Resolves the loop descriptors: the source as given, the destination as given or a fresh StringDType()
(NumPy's new_stringdtype_instance(NULL, 1)).
public override NPY_CASTING resolve_descriptors(DType[] givenDescrs, DType[] loopDescrs, out long viewOffset)
Parameters
givenDescrsDType[]The source descriptor and the optional destination descriptor.
loopDescrsDType[]Receives the loop descriptors.
viewOffsetlongAlways NoView (a conversion is never a view).
Returns
- NPY_CASTING
The cast's fixed safety.