Table of Contents

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

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 a fresh StringDType() (NumPy's new_stringdtype_instance(NULL, 1)).

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

Always NoView (a conversion is never a view).

Returns

NPY_CASTING

The cast's fixed safety.