Table of Contents

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

context ArrayMethodContext

The resolved descriptors and the StringDType sides' allocators (NumSharp.ArrayMethodContext.Allocators).

aligned bool

Unused: the loop reads and writes unaligned cells and elements.

strides long[]

Unused: the loop takes the strides of each call.

flags NDArrayMethodFlags

Receives the method's flags.

Returns

NDInnerLoopFunc

The loop: [0] the source run, [1] the destination run, byte strides.

Exceptions

ArgumentException

A StringDType side 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

givenDescrs DType[]

The source descriptor and the optional destination descriptor.

loopDescrs DType[]

Receives the loop descriptors.

viewOffset long

0 when both loop descriptors are the same object (a view is legal), else NoView.

Returns

NPY_CASTING

unsafe from an NA-holding descriptor to one without, else no casting.