Class VStringToVStringCastingImpl
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
NumPy's StringDType → StringDType cast (string_to_string_resolve_descriptors in
stringdtype/casts.cpp): no casting at all between descriptors, except from a descriptor WITH a missing-data
object to one WITHOUT, which is UNSAFE (the missing values have nowhere to go).
public sealed class VStringToVStringCastingImpl : CastingImpl
- Inheritance
-
VStringToVStringCastingImpl
- Inherited Members
Remarks
The method's minimal safety is unsafe (the spec's level), so np.can_cast always resolves the
descriptors for the stricter rules — which is how can_cast(T, T, 'no') is True while
can_cast(StringDType(na_object=None), StringDType(), 'safe') is False. NumPy allows a view only between
descriptors that share a string allocator (the same descriptor object); NumSharp's allocator belongs to the
buffer, so the same object is the test here too.
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 the source's own parameters
when it is absent — NumPy's stringdtype_finalize_descr).
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.
viewOffsetlong0 when both loop descriptors are the same object (a view is legal), else NoView.
Returns
- NPY_CASTING
unsafefrom an NA-holding descriptor to one without, elsenocasting.