Table of Contents

Class VStringToFixedWidthCastingImpl

Namespace
NumSharp
Assembly
NumSharp.dll

NumPy's casts from StringDType to the fixed-width string classes (string_to_fixed_width_resolve_descriptors): same_kind, and only to a SIZED destination — there is no way to know the width the strings need.

public sealed class VStringToFixedWidthCastingImpl : CastingImpl
Inheritance
VStringToFixedWidthCastingImpl
Inherited Members

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 destination must be given (a sized U / S).

public override NPY_CASTING resolve_descriptors(DType[] givenDescrs, DType[] loopDescrs, out long viewOffset)

Parameters

givenDescrs DType[]

The source descriptor and the destination descriptor.

loopDescrs DType[]

Receives the loop descriptors.

viewOffset long

Always NoView.

Returns

NPY_CASTING

same_kind.

Exceptions

TypeError

No destination descriptor: NumPy's Casting from StringDType to a fixed-width dtype with an unspecified size is not currently supported, specify an explicit size for the output dtype instead. (astype('U') reports it as cannot cast dtype StringDType() to <class 'numpy.dtypes.StrDType'>., the wrapper of CastDescrToDType(DType, DTypeMeta)).