Class VStringToNumberCastingImpl
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
NumPy's casts from StringDType to numbers, bool and the datetime pair (string_to_int / _float /
_bool / _datetime_timedelta_resolve_descriptors): the destination is the given descriptor or the class
default, and the resolved safety is always unsafe (parsing can fail or lose a missing value).
public sealed class VStringToNumberCastingImpl : CastingImpl
- Inheritance
-
VStringToNumberCastingImpl
- Inherited Members
Remarks
The minimal safety is the spec's: unsafe for numbers and the datetime pair, same_kind for bool —
which is why can_cast(T, bool, 'same_kind') is True although the resolver says unsafe. A datetime
destination needs a unit: NumPy refuses an absent descriptor with
Casting from StringDType to datetimes without a unit is not currently supported.
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 destination as given, or the class's default descriptor (a datetime destination must be given).
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.
Returns
- NPY_CASTING
unsafe.
Exceptions
- TypeError
A datetime64 / timedelta64 destination without a descriptor (NumPy's
Casting from StringDType to datetimes without a unit is not currently supported).