Class CharModule
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
The numpy.char module surface, reachable as char: NumPy's legacy vectorized string
operations. Its own functions are the comparisons that strip trailing whitespace (equal(object, object),
not_equal(object, object), less(object, object), less_equal(object, object), greater(object, object),
greater_equal(object, object), compare_chararrays(object, object, object, bool)), multiply(object, object)
(its ValueError rule), partition(object, object) / rpartition(object, object) (the three parts stacked on a new last
axis), the object path (split(object, object, object), rsplit(object, object, object), splitlines(object, object),
join(object, object)) and the chararray constructors (chararray(Shape, long, bool, object, long, long[], char),
array(object, long?, bool, bool?, char?), asarray(object, long?, bool?, char?)); the others ARE np.strings' functions (NumPy re-exports
the same function objects), so they answer exactly as np.strings does, over S, U and
StringDType text.
[ModuleName("np.char")]
public sealed class CharModule
- Inheritance
-
CharModule
- Inherited Members
Remarks
Arguments are array_likes (object), read as Python objects. An NDArray is used as it
is; a C# string is NumPy's str (a 0-d U array); a byte[] is NumPy's
bytes (a 0-d S array) and a byte[][] / any IEnumerable<byte[]> a list of
bytes (an S array); a string[] or an object[] of text is a list of str; a C# number or bool
is NumPy's Python scalar. Unlike np.strings (whose byte[] is a uint8 array, the
general NDArray conversion), a byte[] here is text, because text is all these parameters
can mean.
Python's NotImplemented is null. NumPy's comparisons answer NotImplemented for an
S operand against a U one (the class check of _umath_strings_richcompare); the C# functions
return null there.
Python's None has no array form. NumPy reads None as an object array; NumSharp has no object
dtype, so a null array argument is an ArgumentNullException where NumPy raises its
no-string / no-loop error. The object path (split(object, object, object), rsplit(object, object, object), splitlines(object, object),
join(object, object)) is the exception: it models NumPy's object arrays, so there a null
argument IS Python's None — NumPy's string operation on non-string array as the text argument,
can only join an iterable as join's sequence, whitespace as split's separator.
The Char dtype. The module converts implicitly to the Char dtype descriptor
(implicit operator DType(CharModule)), the meaning np.@char had before the module existed.
Methods
ToString()
Python's repr() of the module object.
public override string ToString()
Returns
- string
<module 'numpy.char'>.
add(object, object, NDArray, NDArray, DType)
NumPy's np.char.add(x1, x2): element-wise string concatenation. In NumPy 2.4.2 it IS the np.add
ufunc (np.char.add is np.strings.add is np.add), so two strings of one class concatenate at width
width(x1) + width(x2) with every rule of add(NDArray, NDArray, NDArray, NDArray, DType).
public NDArray add(object x1, object x2, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
x1objectThe first operand (an array or a text array_like; see the class remarks).
x2objectThe second operand.
outNDArrayAn output to write into and return, or null.
whereNDArrayA bool mask: only elements where it is True are computed, or null.
dtypeDTypeNumPy's
dtype=(the string add promoter ignores it for two strings of one class).
Returns
- NDArray
The concatenation, or
out.
Remarks
A NEP 55 StringDType operand computes through np.add's StringDType loop (with a
StringDType or U partner; NumPy's NA rules and its incompatible-NA TypeError apply).
Exceptions
- ArgumentNullException
An operand is null.
- TypeError
A bytes / str mix (
ufunc 'add' cannot use operands with types …), a string and a number (NumPy's no-loop text), or a result wider than 2^31 - 1 bytes.- ArgumentException
outcannot receive the result, or the operands do not broadcast without/where.- IncorrectShapeException
The two operands do not broadcast.
array(object, long?, bool, bool?, char?)
NumPy's np.char.array(obj, itemsize=None, copy=True, unicode=None, order=None): a chararray from a string,
bytes, a list of them, a string array or a number array (whose numbers become their text).
public NDCharArray array(object obj, long? itemsize = null, bool copy = true, bool? unicode = null, char? order = null)
Parameters
objobjectWhat to convert (see the class remarks for the C# argument map): a string —
itemsizedefaults to its length and every element is set to the WHOLE string (array("abcdef", itemsize: 2)is['ab', 'ab', 'ab'], NumPy's behaviour, not its documentation's chunks); abyte[]— chunked intoitemsize-byte elements, a READ-ONLY view of the bytes; anS/UNDArray — viewed, or copied (seecopy); any other array — its elements as their text, the longest one setting the width (a float32 / float16 by the double's repr,0.10000000149011612; an empty axis ends the shape astolist()does:(0, 3)gives(0,)); a list, a number, a bool ornull(None) — throughnp.asarray/ its text.itemsizelong?The element width in characters, or
nullto discover it.0is NumPy's unsized request (a string array keeps its width, a number array casts at the dtype's fixed width).copyboolfalseshares the memory of anSarray (aUarray is always copied: NumPy compares the itemsize in characters with the array's in BYTES) and returns a chararray argument ITSELF.unicodebool?trueforU,falseforS,nullto follow the input (a number array then becomesS). AnSarray withunicode: trueandcopy: falsestaysS, as in NumPy.orderchar?'C','F','A'or'K'(either case), ornull.
Returns
- NDCharArray
The chararray. NumPy 2.4.2 returns a PLAIN ndarray when
orderis given for a string array (itsnp.asarraystep drops the subclass); the C# result is a chararray with NumPy's data, layout and flags.
Remarks
Exceptions
- DivideByZeroException
A string or bytes
objwith an itemsize of 0 (its own length 0 included): NumPy'slen(obj) // itemsizeraisesZeroDivisionError(integer division or modulo by zero).- ValueError
A negative or too large
itemsize(invalid itemsize in generic type tuple), an unknown order, or a ragged list (NumPy's inhomogeneous-shape text).- UnicodeEncodeError
Non-ASCII text into
S.- UnicodeDecodeError
Non-ASCII bytes into
U.- TypeError
A
byte[]withunicode: trueholds fewer bytes than theUelements need (buffer is too small for requested array).- NotSupportedException
A string chararray of width 0 would result, or an element NumPy converts as an object (an object array input).
asarray(object, long?, bool?, char?)
NumPy's np.char.asarray(obj, itemsize=None, unicode=None, order=None): array(object, long?, bool, bool?, char?) with
copy: false — an S array is shared (a chararray argument is returned ITSELF), a U array is
still copied (NumPy's itemsize comparison of characters with bytes).
public NDCharArray asarray(object obj, long? itemsize = null, bool? unicode = null, char? order = null)
Parameters
objobjectWhat to convert (see array(object, long?, bool, bool?, char?)).
itemsizelong?The element width in characters, or
nullto discover it.unicodebool?trueforU,falseforS,nullto follow the input.orderchar?'C','F','A'or'K', ornull.
Returns
- NDCharArray
The chararray (see array(object, long?, bool, bool?, char?) for the order quirk).
Remarks
Exceptions
- DivideByZeroException
A string or bytes
objwith an itemsize of 0.- ValueError
A negative or too large
itemsize, an unknown order, or a ragged list.- UnicodeEncodeError
Non-ASCII text into
S.- UnicodeDecodeError
Non-ASCII bytes into
U.- TypeError
A
byte[]withunicode: trueholds fewer bytes than the elements need.- NotSupportedException
A string chararray of width 0 would result.
capitalize(object)
NumPy's np.char.capitalize(a), which IS capitalize(NDArray): each element's first
character in titlecase and the rest lowered (CPython 3.8+'s str.capitalize: 'džemal' becomes
'Džemal'); bytes.capitalize uppercases the first byte and lowers the other ASCII letters. The text
is the stored one, a chararray's trailing whitespace included.
public NDArray capitalize(object a)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: abyte[]is Python bytes).
Returns
- NDArray
A fresh C-ordered PLAIN array of
a's dtype (a chararray operand too: NumPy'snp.asarraydrops the class), 0-d for a scalar. AnS/Uresult keeps the element width, so a mapping that grows is cut.
Exceptions
- ArgumentNullException
ais null (see the class remarks).- TypeError
ais not text (string operation on non-string array); aStringDTypeNA whose NA object is not a str.- SystemError
A
Uelement holding a code unit past U+10FFFF.- NotSupportedException
ahas no NumSharp array form.
center(object, object, object)
NumPy's np.char.center(a, width, fillchar=' '), which IS center(NDArray, NDArray, NDArray): each element
centered in a string of width characters, padded with fillchar. An
element longer than the width is unchanged.
public NDArray center(object a, object width, object fillchar = null)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like.widthobjectThe widths: an integer array or a C# integer, broadcast. A float, a bool or text is NumPy's TypeError.
fillcharobjectThe fill characters, each exactly one character long, broadcast; null is NumPy's default
' '. Astrfill beside anSoperand is cast to bytes (ASCII only), abytesfill beside aUoperand to text.
Returns
- NDArray
A fresh array:
a's class at the widest result width forS/U, laid out likea; aStringDTypearray forStringDType. A chararrayagives a chararray view of the result (NumPy'schararray.array_wrap).
Exceptions
- ArgumentNullException
aorwidthis null.- TypeError
widthis not an integer array (unsupported type float64 for operand 'width'); a fill that is not one character (The fill character must be exactly one character long); a non-text operand; no common dtype or no loop for the classes; a uint64 width (NumPy'sdata type 'U6.0' not understood).- ValueError
An empty broadcast (
zero-size array to reduction operation maximum which has no identity); aStringDTypeNA its rule refuses; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).- UnicodeEncodeError
A non-ASCII fill for an
Soperand.- IncorrectShapeException
The operands do not broadcast.
- OverflowException
A
StringDTyperesult pastsys.maxsizebytes.
chararray(Shape, long, bool, object, long, long[], char)
NumPy's np.char.chararray(shape, itemsize=1, unicode=False, buffer=None, offset=0, strides=None, order='C'):
a new chararray of itemsize-character S (or U) elements. Without a buffer the
memory is np.empty's (a U chararray reads empty strings, an S one holds whatever the
allocator recycled).
public NDCharArray chararray(Shape shape, long itemsize = 1, bool unicode = false, object buffer = null, long offset = 0, long[] strides = null, char order = 'C')
Parameters
shapeShapeThe dimensions (an int, a
long[]or a tuple converts).itemsizelongThe element width in characters. NumPy's
(dtype, itemsize)tuple accepts 0 to2^31 - 1forSand to2^29 - 1forU.unicodebooltrueforU(str),falseforS(bytes).bufferobjectnullfor new memory. A C# string is NumPy's str FILLER: every element is set to it (truncated to the width; anSchararray encodes it ASCII), andoffset/stridesare ignored. Any other buffer is viewed without copying, exactly as ndarray(Shape, DType, object, long, long[], char) views it: abyte[]/Memory<byte>writable (NumPy'sbytearray), aReadOnlyMemory<byte>read-only (NumPy'sbytes), an NDArray through its bytes.offsetlongThe BYTE offset of the first element in
buffer.strideslong[]The BYTE strides over
buffer, ornullfororder's.orderchar'C'or'F'(either case;'A'/'K'are C).
Returns
- NDCharArray
The new chararray: it owns its memory without a buffer or with a string filler, and views the buffer otherwise.
Remarks
Exceptions
- ValueError
itemsizeis negative or too large (invalid itemsize in generic type tuple), a negative dimension (negative dimensions are not allowed), or an unknown order.- NotSupportedException
itemsizeis 0: NumPy builds a zero-widthS0/U0array, which NumSharp's fixed-width string buffers cannot hold.- UnicodeEncodeError
A string filler with a non-ASCII character into an
Schararray.- TypeError
A buffer that is too small (
buffer is too small for requested array) or not a bytes-like object.
compare_chararrays(object, object, object, bool)
NumPy's np.char.compare_chararrays(a1, a2, cmp, rstrip): the element-wise comparison cmp
of two string arrays of one class, each element first stripped of its trailing NULs and ASCII whitespace when
rstrip is true.
public NDArray compare_chararrays(object a1, object a2, object cmp, bool rstrip)
Parameters
a1objectThe first operand (an
S/Uarray or a text array_like; see the class remarks).a2objectThe second operand, of the same class.
cmpobjectThe comparison, as NumPy's
s#argument reads it: a string (Python'sstr, read as its UTF-8 bytes) or abyte[](Python'sbytes,"=="u8.ToArray()), whose bytes must be==,!=,<,<=,>or>=.rstripboolTrue to strip each element's trailing NULs and ASCII whitespace before comparing.
Returns
- NDArray
The bool result of the broadcast shape (a 0-d array for two scalars), or null — NumPy's
NotImplemented— for anSoperand against aUone.
Remarks
One overload, NumPy's signature: NumPy's cmp is a str or a read-only bytes-like object, two cases
of one object parameter. NumPy's order, all probed: cmp is checked first (so a
bad cmp wins over operands that are not text or do not broadcast), then both operands must be
S / U (a NEP 55 StringDType array is not), then a class mix answers
NotImplemented (before the broadcast), then the broadcast.
Exceptions
- TypeError
cmpis neither text nor bytes (a bytes-like object is required, not 'NoneType'for null, the Python type's name otherwise); or an operand is notS/Utext (comparison of non-string arrays).- UnicodeEncodeError
cmpholds a lone surrogate, which UTF-8 cannot encode (CPython's'utf-8' codec can't encode character '\ud800' in position 0: surrogates not allowed).- ValueError
cmpis not one of the six comparisons:comparison must be '==', '!=', '<', '>', '<=', '>='.- ArgumentNullException
An operand is null.
- IncorrectShapeException
The operands do not broadcast.
count(object, object, object, object)
NumPy's np.char.count(a, sub, start=0, end=None), which IS count(NDArray, NDArray, NDArray, NDArray): the number of
non-overlapping occurrences of sub in each element's a[start:end], counted greedily
from the left; an empty substring occurs len + 1 times in the range.
public NDArray count(object a, object sub, object start = null, object end = null)
Parameters
aobjectThe searched strings: an
S/U/StringDTypearray or a text array_like.subobjectThe substrings, broadcast: the same class as
a(aUone beside aStringDTypea, or the reverse, is cast toStringDType; abytesone besideUor a number has no loop).startobjectThe range starts in slice notation (negative counts from the end), any integer dtype, broadcast; null is NumPy's default 0.
endobjectThe range ends in slice notation, broadcast; null is NumPy's
None(the whole string).
Returns
- NDArray
A plain int64 array of the broadcast shape (0-d for scalar operands); a chararray operand still gives a plain array.
Exceptions
- ArgumentNullException
aorsubis null.- TypeError
No loop for the operand classes (an
Sarray with astrsubstring, a number substring: NumPy's no-loop text); twoStringDTypeoperands with different NA objects.- TypeError
start/endcannot reach int64 by a same_kind cast (a float or text:Cannot cast ufunc 'count' input 2 from dtype('float64') to dtype('int64') with casting rule 'same_kind').- OverflowException
A start / end literal past int64.
- IncorrectShapeException
The operands do not broadcast.
- ValueError
A
StringDTypeNA whose NA object is not a string; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).
decode(object, object, object)
NumPy's np.char.decode(a, encoding=None, errors=None), which IS decode(NDArray, object, object):
CPython's bytes.decode(encoding, errors) per element of an S array, the results as a U
array. An element is its bytes without the trailing NULs, a chararray's trailing whitespace included.
public NDArray decode(object a, object encoding = null, object errors = null)
Parameters
aobjectThe bytes: an
Sarray or a bytes array_like (see the class remarks: abyte[]is Python bytes, a list ofbyte[]anSarray).encodingobjectThe codec name, or null for UTF-8 (the codecs of decode(NDArray, object, object)); broadcast against
a.errorsobjectThe error handler, or null for
strict("ignore","replace","backslashreplace","surrogateescape","surrogatepass";"xmlcharrefreplace"and"namereplace"are CPython's TypeError at the first error); ignored whenencodingis null. Broadcast likeencoding.
Returns
- NDArray
A fresh C-ordered PLAIN
Uarray over the broadcast shape (a chararray operand too), as wide as the longest decoding (at least 1), 0-d for a scalar; an emptyU1array when the broadcast is empty.
Exceptions
- ArgumentNullException
ais null (see the class remarks).- AttributeError
aisUorStringDType:type object 'str' has no attribute 'decode'.- TypeError
ais not text; an argument that is not a str;xmlcharrefreplace/namereplaceat an error (don't know how to handle UnicodeDecodeError in error callback).- ValueError
An argument holding a NUL; a ragged argument list.
- UnicodeDecodeError
Bytes the codec cannot decode under
strict, or a handler that re-raises it.- UnicodeEncodeError
A surrogate in an argument.
- UnicodeError
The
undefinedcodec over a non-empty element.- LookupError
An unknown or non-text codec; an unknown handler name at the first error.
- IncorrectShapeException
The operands do not broadcast.
- NotSupportedException
A Python codec NumSharp does not implement; an argument with no NumSharp array form.
encode(object, object, object)
NumPy's np.char.encode(a, encoding=None, errors=None), which IS encode(NDArray, object, object):
CPython's str.encode(encoding, errors) per element of a U / StringDType array, the
results as an S array. The text is the stored one, a chararray's trailing whitespace included.
public NDArray encode(object a, object encoding = null, object errors = null)
Parameters
aobjectThe text: a
U/StringDTypearray or a text array_like (see the class remarks; a C#stringis a 0-dUarray).encodingobjectThe codec name, or null for UTF-8 (the codecs and aliases of encode(NDArray, object, object)), converted as NumPy's
np.asarrayconverts it and broadcast againsta.errorsobjectThe error handler, or null for
strict("ignore","replace","backslashreplace","xmlcharrefreplace","namereplace","surrogateescape","surrogatepass"); ignored whenencodingis null (NumPy's_clean_argsstops at the first None). Broadcast likeencoding.
Returns
- NDArray
A fresh C-ordered PLAIN
Sarray over the broadcast shape (a chararray operand too), as wide as the longest encoding (at least 1), 0-d for a scalar; an emptyS1array when the broadcast is empty.
Exceptions
- ArgumentNullException
ais null (see the class remarks).- AttributeError
aisS:type object 'bytes' has no attribute 'encode'.- TypeError
ais not text (string operation on non-string array); aStringDTypeNA object that is not a str; an argument that is not a str (encode() argument 'encoding' must be str, not numpy.bytes_).- ValueError
An argument holding a NUL (
embedded null character); a ragged argument list.- UnicodeEncodeError
A character the codec cannot encode under
strict, a handler that re-raises it, or a surrogate in an argument.- UnicodeError
The
undefinedcodec.- LookupError
An unknown or non-text codec (
unknown encoding: nope); an unknown handler name at the first error.- SystemError
A
Uelement of one unit past U+10FFFF.- IncorrectShapeException
The operands do not broadcast.
- NotSupportedException
A Python codec NumSharp does not implement; an argument with no NumSharp array form.
endswith(object, object, object, object)
NumPy's np.char.endswith(a, suffix, start=0, end=None), which IS endswith(NDArray, NDArray, NDArray, NDArray):
whether each element's a[start:end] ends with suffix.
public NDArray endswith(object a, object suffix, object start = null, object end = null)
Parameters
aobjectThe tested strings: an
S/U/StringDTypearray or a text array_like.suffixobjectThe suffixes, broadcast (the classes of count(object, object, object, object)).
startobjectThe range starts in slice notation, broadcast; null is NumPy's default 0.
endobjectThe range ends in slice notation, broadcast; null is NumPy's
None.
Returns
- NDArray
A plain bool array of the broadcast shape (0-d for scalar operands).
Exceptions
- ArgumentNullException
aorsuffixis null.- TypeError
No loop for the operand classes; two different
StringDTypeNA objects.- TypeError
A start / end that cannot reach int64 by a same_kind cast.
- OverflowException
A start / end literal past int64.
- IncorrectShapeException
The operands do not broadcast.
- ValueError
A
StringDTypeNA whose NA object is neither a string nor NaN-like; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).
equal(object, object)
NumPy's np.char.equal(x1, x2): x1 == x2 element-wise once each element has lost its trailing
NULs and ASCII whitespace — compare_chararrays(x1, x2, '==', True). So 'a ' equals 'a',
where np.equal says they differ.
public NDArray equal(object x1, object x2)
Parameters
x1objectThe first operand: an
S/Uarray or a text array_like (see the class remarks).x2objectThe second operand, of the same class.
Returns
- NDArray
The bool result of the broadcast shape (a 0-d array for two scalars), or null — NumPy's
NotImplemented— when one operand isSand the otherU.
Remarks
The stripped units are NUL, ' ', '\t', '\n', '\v', '\f', '\r' for
both classes (NumPy's NumPyOS_ascii_isspace); other whitespace such as '\xa0' or U+3000 stays,
and a leading space stays. The result is laid out as NumPy's iterator allocates it (an F-ordered pair gives an
F result).
Exceptions
- ArgumentNullException
An operand is null (NumPy's
None; see the class remarks).- TypeError
An operand is not
S/Utext — a number, a bool, a NEP 55StringDTypearray:comparison of non-string arrays.- IncorrectShapeException
The operands do not broadcast (NumPy's ValueError text).
expandtabs(object, object)
NumPy's np.char.expandtabs(a, tabsize=8), which IS expandtabs(NDArray, NDArray): each tab
replaced by spaces up to the next multiple of tabsize columns (the column restarts after
'\n' and '\r'; a tab size of 0 or less removes the tabs).
public NDArray expandtabs(object a, object tabsize = null)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like.tabsizeobjectThe tab sizes (any integer dtype), broadcast; null is NumPy's default 8.
Returns
- NDArray
A fresh array (for
S/Uat the widest result width as NumPy sizes it: a tab's columns plus every other character's BYTES, so aUresult is wider than its text).
Exceptions
- ArgumentNullException
ais null.- TypeError
A non-text operand (NumPy's no-loop text).
- TypeError
A tab size that cannot reach int64 by a same_kind cast (a float:
Cannot cast ufunc '_expandtabs_length' input 1 from dtype('float64') to dtype('int64') with casting rule 'same_kind').- IncorrectShapeException
The operands do not broadcast.
- OverflowException
An expanded string longer than 2^31 - 1 (
new string is too long).- ValueError
An empty broadcast; a
StringDTypeNA whose NA object is not a string.
find(object, object, object, object)
NumPy's np.char.find(a, sub, start=0, end=None), which IS find(NDArray, NDArray, NDArray, NDArray): for each
element, the lowest index where sub occurs inside a[start:end], or -1. Indices are
characters (code points for StringDType); trailing NULs never count.
public NDArray find(object a, object sub, object start = null, object end = null)
Parameters
aobjectThe searched strings: an
S/U/StringDTypearray or a text array_like.subobjectThe substrings, broadcast (the classes of count(object, object, object, object)).
startobjectThe range starts in slice notation, broadcast; null is NumPy's default 0.
endobjectThe range ends in slice notation, broadcast; null is NumPy's
None.
Returns
- NDArray
A plain int64 array of the broadcast shape (0-d for scalar operands).
Exceptions
- ArgumentNullException
aorsubis null.- TypeError
No loop for the operand classes; two different
StringDTypeNA objects.- TypeError
A start / end that cannot reach int64 by a same_kind cast.
- OverflowException
A start / end literal past int64.
- IncorrectShapeException
The operands do not broadcast.
- ValueError
A
StringDTypeNA whose NA object is not a string; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).
greater(object, object)
NumPy's np.char.greater(x1, x2): x1 > x2 element-wise after stripping trailing NULs and ASCII
whitespace — compare_chararrays(x1, x2, '>', True).
public NDArray greater(object x1, object x2)
Parameters
x1objectThe first operand (see equal(object, object)).
x2objectThe second operand.
Returns
- NDArray
The bool result, or null (NumPy's
NotImplemented) for anS/Upair.
Exceptions
- ArgumentNullException
An operand is null.
- TypeError
An operand is not
S/Utext.- IncorrectShapeException
The operands do not broadcast.
greater_equal(object, object)
NumPy's np.char.greater_equal(x1, x2): x1 >= x2 element-wise after stripping trailing NULs
and ASCII whitespace — compare_chararrays(x1, x2, '>=', True). The stripped strings compare unit by
unit as unsigned values (bytes for S, UCS-4 units for U).
public NDArray greater_equal(object x1, object x2)
Parameters
x1objectThe first operand (see equal(object, object)).
x2objectThe second operand.
Returns
- NDArray
The bool result, or null (NumPy's
NotImplemented) for anS/Upair.
Exceptions
- ArgumentNullException
An operand is null.
- TypeError
An operand is not
S/Utext.- IncorrectShapeException
The operands do not broadcast.
index(object, object, object, object)
NumPy's np.char.index(a, sub, start=0, end=None), which IS index(NDArray, NDArray, NDArray, NDArray):
find(object, object, object, object), but an element with no match raises ValueError: substring not found.
public NDArray index(object a, object sub, object start = null, object end = null)
Parameters
aobjectThe searched strings: an
S/U/StringDTypearray or a text array_like.subobjectThe substrings, broadcast (the classes of count(object, object, object, object)).
startobjectThe range starts in slice notation, broadcast; null is NumPy's default 0.
endobjectThe range ends in slice notation, broadcast; null is NumPy's
None.
Returns
- NDArray
A plain int64 array of the broadcast shape (0-d for scalar operands).
Exceptions
- ArgumentNullException
aorsubis null.- TypeError
No loop for the operand classes; two different
StringDTypeNA objects.- TypeError
A start / end that cannot reach int64 by a same_kind cast.
- OverflowException
A start / end literal past int64.
- IncorrectShapeException
The operands do not broadcast.
- ValueError
An element without a match (
substring not found); aStringDTypeNA whose NA object is not a string; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).
isalnum(object, NDArray, NDArray, DType)
NumPy's np.char.isalnum(x), which IS the isalnum(NDArray, NDArray, NDArray, DType) ufunc: True for each
element whose text has at least one character and only alphanumeric characters (CPython's
str.isalnum: alphabetic, decimal, digit or numeric). The text is the element's characters without
its trailing NULs, so a chararray's trailing whitespace counts: 'a1' is True; a stored
'ab ' is False (its trailing spaces are not alphanumeric).
public NDArray isalnum(object x, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
xobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: abyte[]is Python bytes). A number has no loop.outNDArrayAn output to write into and return (any dtype bool casts to under same_kind: a number receives 0 / 1, a text output
'True'/'False'cut to its width), or null.whereNDArrayA bool mask: only elements where it is True are computed, the others keep
out's values (uninitialized in a fresh result), or null for NumPy'swhere=True.dtypeDTypeNumPy's
dtype=: only bool has a loop; null leaves the loop to the operand.
Returns
- NDArray
A plain bool array of
x's shape (0-d for a scalar), orout. A chararrayxstill gives a plain array; a chararrayoutcomes back as a new view of it.
Exceptions
- ArgumentNullException
xis null (see the class remarks).- TypeError
xis not text, ordtypeis not bool (NumPy's no-loop text, which names a C# number by its default DType:Int64DType,Float64DType).- TypeError
outcannot receive bool (the same_kind output cast).- ArgumentException
A non-bool
where; operands that do not broadcast without/where.- ValueError
A read-only
out; a selectedStringDTypeNA whose descriptor's NA object is neither NaN-like nor a string.- NotSupportedException
xhas no NumSharp array form (an object NumPy would hold in an object array, which has no loop either).
isalpha(object, NDArray, NDArray, DType)
NumPy's np.char.isalpha(x), which IS the isalpha(NDArray, NDArray, NDArray, DType) ufunc: True for each
element whose text has at least one character and only alphabetic characters (CPython's
str.isalpha: the Unicode letter categories). The text is the element's characters without its
trailing NULs, so a chararray's trailing whitespace counts: 'abc' is True; a stored 'ab '
is False, though its element c[i] reads 'ab'.
public NDArray isalpha(object x, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
xobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: abyte[]is Python bytes). A number has no loop.outNDArrayAn output to write into and return (any dtype bool casts to under same_kind: a number receives 0 / 1, a text output
'True'/'False'cut to its width), or null.whereNDArrayA bool mask: only elements where it is True are computed, the others keep
out's values (uninitialized in a fresh result), or null for NumPy'swhere=True.dtypeDTypeNumPy's
dtype=: only bool has a loop; null leaves the loop to the operand.
Returns
- NDArray
A plain bool array of
x's shape (0-d for a scalar), orout. A chararrayxstill gives a plain array; a chararrayoutcomes back as a new view of it.
Exceptions
- ArgumentNullException
xis null (see the class remarks).- TypeError
xis not text, ordtypeis not bool (NumPy's no-loop text, which names a C# number by its default DType:Int64DType,Float64DType).- TypeError
outcannot receive bool (the same_kind output cast).- ArgumentException
A non-bool
where; operands that do not broadcast without/where.- ValueError
A read-only
out; a selectedStringDTypeNA whose descriptor's NA object is neither NaN-like nor a string.- NotSupportedException
xhas no NumSharp array form (an object NumPy would hold in an object array, which has no loop either).
isdecimal(object, NDArray, NDArray, DType)
NumPy's np.char.isdecimal(x), which IS the isdecimal(NDArray, NDArray, NDArray, DType) ufunc: True for
each element whose text has at least one character and only decimal characters (CPython's
str.isdecimal: '٣' is one, '²' is not); U and StringDType only: an
S operand has no loop. The text is the element's characters without its trailing NULs, so a
chararray's trailing whitespace counts: '123' is True; a stored '12 ' is False.
public NDArray isdecimal(object x, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
xobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: abyte[]is Python bytes). A number has no loop.outNDArrayAn output to write into and return (any dtype bool casts to under same_kind: a number receives 0 / 1, a text output
'True'/'False'cut to its width), or null.whereNDArrayA bool mask: only elements where it is True are computed, the others keep
out's values (uninitialized in a fresh result), or null for NumPy'swhere=True.dtypeDTypeNumPy's
dtype=: only bool has a loop; null leaves the loop to the operand.
Returns
- NDArray
A plain bool array of
x's shape (0-d for a scalar), orout. A chararrayxstill gives a plain array; a chararrayoutcomes back as a new view of it.
Exceptions
- ArgumentNullException
xis null (see the class remarks).- TypeError
xis not text (anSoperand too: NumPy's ufunc has no bytes loop), ordtypeis not bool (NumPy's no-loop text, which names a C# number by its default DType:Int64DType,Float64DType).- TypeError
outcannot receive bool (the same_kind output cast).- ArgumentException
A non-bool
where; operands that do not broadcast without/where.- ValueError
A read-only
out; a selectedStringDTypeNA whose descriptor's NA object is neither NaN-like nor a string.- NotSupportedException
xhas no NumSharp array form (an object NumPy would hold in an object array, which has no loop either).
isdigit(object, NDArray, NDArray, DType)
NumPy's np.char.isdigit(x), which IS the isdigit(NDArray, NDArray, NDArray, DType) ufunc: True for each
element whose text has at least one character and only digits (CPython's str.isdigit: the decimal
digits and the other digits, such as '²'; not '½'). The text is the element's characters
without its trailing NULs, so a chararray's trailing whitespace counts: '123' is True; '½'
is False.
public NDArray isdigit(object x, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
xobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: abyte[]is Python bytes). A number has no loop.outNDArrayAn output to write into and return (any dtype bool casts to under same_kind: a number receives 0 / 1, a text output
'True'/'False'cut to its width), or null.whereNDArrayA bool mask: only elements where it is True are computed, the others keep
out's values (uninitialized in a fresh result), or null for NumPy'swhere=True.dtypeDTypeNumPy's
dtype=: only bool has a loop; null leaves the loop to the operand.
Returns
- NDArray
A plain bool array of
x's shape (0-d for a scalar), orout. A chararrayxstill gives a plain array; a chararrayoutcomes back as a new view of it.
Exceptions
- ArgumentNullException
xis null (see the class remarks).- TypeError
xis not text, ordtypeis not bool (NumPy's no-loop text, which names a C# number by its default DType:Int64DType,Float64DType).- TypeError
outcannot receive bool (the same_kind output cast).- ArgumentException
A non-bool
where; operands that do not broadcast without/where.- ValueError
A read-only
out; a selectedStringDTypeNA whose descriptor's NA object is neither NaN-like nor a string.- NotSupportedException
xhas no NumSharp array form (an object NumPy would hold in an object array, which has no loop either).
islower(object, NDArray, NDArray, DType)
NumPy's np.char.islower(x), which IS the islower(NDArray, NDArray, NDArray, DType) ufunc: True for each
element whose text has at least one cased character and every cased character lowercase. The text is the
element's characters without its trailing NULs, so a chararray's trailing whitespace counts: a stored
'ab ' is True (spaces are uncased); 'aBc' is False.
public NDArray islower(object x, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
xobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: abyte[]is Python bytes). A number has no loop.outNDArrayAn output to write into and return (any dtype bool casts to under same_kind: a number receives 0 / 1, a text output
'True'/'False'cut to its width), or null.whereNDArrayA bool mask: only elements where it is True are computed, the others keep
out's values (uninitialized in a fresh result), or null for NumPy'swhere=True.dtypeDTypeNumPy's
dtype=: only bool has a loop; null leaves the loop to the operand.
Returns
- NDArray
A plain bool array of
x's shape (0-d for a scalar), orout. A chararrayxstill gives a plain array; a chararrayoutcomes back as a new view of it.
Exceptions
- ArgumentNullException
xis null (see the class remarks).- TypeError
xis not text, ordtypeis not bool (NumPy's no-loop text, which names a C# number by its default DType:Int64DType,Float64DType).- TypeError
outcannot receive bool (the same_kind output cast).- ArgumentException
A non-bool
where; operands that do not broadcast without/where.- ValueError
A read-only
out; a selectedStringDTypeNA whose descriptor's NA object is neither NaN-like nor a string.- NotSupportedException
xhas no NumSharp array form (an object NumPy would hold in an object array, which has no loop either).
isnumeric(object, NDArray, NDArray, DType)
NumPy's np.char.isnumeric(x), which IS the isnumeric(NDArray, NDArray, NDArray, DType) ufunc: True for
each element whose text has at least one character and only numeric characters (CPython's
str.isnumeric: digits, fractions such as '½', Roman and CJK numerals); U and
StringDType only: an S operand has no loop. The text is the element's characters without
its trailing NULs, so a chararray's trailing whitespace counts: '½' is True; 'a1' is
False.
public NDArray isnumeric(object x, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
xobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: abyte[]is Python bytes). A number has no loop.outNDArrayAn output to write into and return (any dtype bool casts to under same_kind: a number receives 0 / 1, a text output
'True'/'False'cut to its width), or null.whereNDArrayA bool mask: only elements where it is True are computed, the others keep
out's values (uninitialized in a fresh result), or null for NumPy'swhere=True.dtypeDTypeNumPy's
dtype=: only bool has a loop; null leaves the loop to the operand.
Returns
- NDArray
A plain bool array of
x's shape (0-d for a scalar), orout. A chararrayxstill gives a plain array; a chararrayoutcomes back as a new view of it.
Exceptions
- ArgumentNullException
xis null (see the class remarks).- TypeError
xis not text (anSoperand too: NumPy's ufunc has no bytes loop), ordtypeis not bool (NumPy's no-loop text, which names a C# number by its default DType:Int64DType,Float64DType).- TypeError
outcannot receive bool (the same_kind output cast).- ArgumentException
A non-bool
where; operands that do not broadcast without/where.- ValueError
A read-only
out; a selectedStringDTypeNA whose descriptor's NA object is neither NaN-like nor a string.- NotSupportedException
xhas no NumSharp array form (an object NumPy would hold in an object array, which has no loop either).
isspace(object, NDArray, NDArray, DType)
NumPy's np.char.isspace(x), which IS the isspace(NDArray, NDArray, NDArray, DType) ufunc: True for each
element whose text has at least one character and only whitespace (CPython's str.isspace for
U / StringDType; space and \t–\r for S). The text is the element's
characters without its trailing NULs, so a chararray's trailing whitespace counts: ' ' is True;
an empty element is False.
public NDArray isspace(object x, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
xobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: abyte[]is Python bytes). A number has no loop.outNDArrayAn output to write into and return (any dtype bool casts to under same_kind: a number receives 0 / 1, a text output
'True'/'False'cut to its width), or null.whereNDArrayA bool mask: only elements where it is True are computed, the others keep
out's values (uninitialized in a fresh result), or null for NumPy'swhere=True.dtypeDTypeNumPy's
dtype=: only bool has a loop; null leaves the loop to the operand.
Returns
- NDArray
A plain bool array of
x's shape (0-d for a scalar), orout. A chararrayxstill gives a plain array; a chararrayoutcomes back as a new view of it.
Exceptions
- ArgumentNullException
xis null (see the class remarks).- TypeError
xis not text, ordtypeis not bool (NumPy's no-loop text, which names a C# number by its default DType:Int64DType,Float64DType).- TypeError
outcannot receive bool (the same_kind output cast).- ArgumentException
A non-bool
where; operands that do not broadcast without/where.- ValueError
A read-only
out; a selectedStringDTypeNA whose descriptor's NA object is neither NaN-like nor a string.- NotSupportedException
xhas no NumSharp array form (an object NumPy would hold in an object array, which has no loop either).
istitle(object, NDArray, NDArray, DType)
NumPy's np.char.istitle(x), which IS the istitle(NDArray, NDArray, NDArray, DType) ufunc: True for each
element whose text is titlecased: an uppercase or titlecase character never follows a cased character, a
lowercase one always does, and at least one character is cased. The text is the element's characters
without its trailing NULs, so a chararray's trailing whitespace counts: 'Abc Def' is True;
'ABC' is False.
public NDArray istitle(object x, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
xobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: abyte[]is Python bytes). A number has no loop.outNDArrayAn output to write into and return (any dtype bool casts to under same_kind: a number receives 0 / 1, a text output
'True'/'False'cut to its width), or null.whereNDArrayA bool mask: only elements where it is True are computed, the others keep
out's values (uninitialized in a fresh result), or null for NumPy'swhere=True.dtypeDTypeNumPy's
dtype=: only bool has a loop; null leaves the loop to the operand.
Returns
- NDArray
A plain bool array of
x's shape (0-d for a scalar), orout. A chararrayxstill gives a plain array; a chararrayoutcomes back as a new view of it.
Exceptions
- ArgumentNullException
xis null (see the class remarks).- TypeError
xis not text, ordtypeis not bool (NumPy's no-loop text, which names a C# number by its default DType:Int64DType,Float64DType).- TypeError
outcannot receive bool (the same_kind output cast).- ArgumentException
A non-bool
where; operands that do not broadcast without/where.- ValueError
A read-only
out; a selectedStringDTypeNA whose descriptor's NA object is neither NaN-like nor a string.- NotSupportedException
xhas no NumSharp array form (an object NumPy would hold in an object array, which has no loop either).
isupper(object, NDArray, NDArray, DType)
NumPy's np.char.isupper(x), which IS the isupper(NDArray, NDArray, NDArray, DType) ufunc: True for each
element whose text has at least one cased character and every cased character uppercase. The text is the
element's characters without its trailing NULs, so a chararray's trailing whitespace counts: a stored
'AB ' is True (spaces are uncased); 'Ab' is False.
public NDArray isupper(object x, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
xobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: abyte[]is Python bytes). A number has no loop.outNDArrayAn output to write into and return (any dtype bool casts to under same_kind: a number receives 0 / 1, a text output
'True'/'False'cut to its width), or null.whereNDArrayA bool mask: only elements where it is True are computed, the others keep
out's values (uninitialized in a fresh result), or null for NumPy'swhere=True.dtypeDTypeNumPy's
dtype=: only bool has a loop; null leaves the loop to the operand.
Returns
- NDArray
A plain bool array of
x's shape (0-d for a scalar), orout. A chararrayxstill gives a plain array; a chararrayoutcomes back as a new view of it.
Exceptions
- ArgumentNullException
xis null (see the class remarks).- TypeError
xis not text, ordtypeis not bool (NumPy's no-loop text, which names a C# number by its default DType:Int64DType,Float64DType).- TypeError
outcannot receive bool (the same_kind output cast).- ArgumentException
A non-bool
where; operands that do not broadcast without/where.- ValueError
A read-only
out; a selectedStringDTypeNA whose descriptor's NA object is neither NaN-like nor a string.- NotSupportedException
xhas no NumSharp array form (an object NumPy would hold in an object array, which has no loop either).
join(object, object)
NumPy's np.char.join(sep, seq): every element of seq — a STRING — with its
characters joined by the separator element (join('-', 'osd') is 'o-s-d'), as Python's
sep.join(seq) iterates a string.
public NDArray join(object sep, object seq)
Parameters
sepobjectThe separators:
S/U/StringDTypetext or a text array_like.seqobjectThe strings, broadcast against
sep.
Returns
- NDArray
The joined text as NumPy's
_to_bytes_or_str_arraybuilds it: ofseq's class (U/Sas wide as the longest result, at least 1;StringDType()with default parameters), a fresh C-ordered array; for an empty broadcast an empty array ofseq's dtype, whatever it is.
Remarks
One overload, NumPy's signature. An S sequence joins only when empty (b'-'.join(b'ab')
iterates ints), as in NumPy. A list of words is not a sequence here: np.asarray(['ab', 'cd']) is a
string array, so each word's characters are joined.
An object seq of lists (split(object, object, object)'s result) is joined element by element as
NumPy's _vec_string joins it — each element's list items, its TypeError for a list item of the wrong
class — and then raises NumPy 2.4.2's own error, because _to_bytes_or_str_array calls
ObjectDType(n), which takes no argument: the idiom np.char.join(' ', np.char.split(a)) raises
in NumPy 2.4.2, and here.
Exceptions
- TypeError
sepis not text (string operation on non-string array, also for null: Python'sNone); per element, in NumPy's order: aStringDTypeNA separator that is not a str (descriptor 'join' for 'str' objects doesn't apply to a 'NoneType' object), a non-iterable sequence (a number or None — a nullseqis Python'sNone—:can only join an iterable), a sequence of the other class (sequence item 0: expected str instance, int found— iterating bytes gives ints —,sequence item 0: expected a bytes-like object, str found), and an objectseq(a C# list holding null) once every element joined (NumSharp.Backends.Strings.NDCharObjectPath.ObjectDTypeText, NumPy 2.4.2's own failure).- ValueError
A ragged list argument.
- SystemError
A
Useparator or sequence that is one code unit above U+10FFFF, or aUsequence holding such a unit (iterating it creates the character).- IncorrectShapeException
The arguments do not broadcast.
- NotSupportedException
NumPy's result is an empty OBJECT array, which an NDArray result cannot hold: an empty broadcast of an object
seq— an NDListArray (split(object, object, object)'s lists) or a C# list holding null.
less(object, object)
NumPy's np.char.less(x1, x2): x1 < x2 element-wise after stripping trailing NULs and ASCII
whitespace — compare_chararrays(x1, x2, '<', True).
public NDArray less(object x1, object x2)
Parameters
x1objectThe first operand (see equal(object, object)).
x2objectThe second operand.
Returns
- NDArray
The bool result, or null (NumPy's
NotImplemented) for anS/Upair.
Exceptions
- ArgumentNullException
An operand is null.
- TypeError
An operand is not
S/Utext.- IncorrectShapeException
The operands do not broadcast.
less_equal(object, object)
NumPy's np.char.less_equal(x1, x2): x1 <= x2 element-wise after stripping trailing NULs and
ASCII whitespace — compare_chararrays(x1, x2, '<=', True).
public NDArray less_equal(object x1, object x2)
Parameters
x1objectThe first operand (see equal(object, object)).
x2objectThe second operand.
Returns
- NDArray
The bool result, or null (NumPy's
NotImplemented) for anS/Upair.
Exceptions
- ArgumentNullException
An operand is null.
- TypeError
An operand is not
S/Utext.- IncorrectShapeException
The operands do not broadcast.
ljust(object, object, object)
NumPy's np.char.ljust(a, width, fillchar=' '), which IS ljust(NDArray, NDArray, NDArray): each element
left-justified in a string of width characters, padded on the right with
fillchar.
public NDArray ljust(object a, object width, object fillchar = null)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like.widthobjectThe integer widths, broadcast.
fillcharobjectThe one-character fills, broadcast; null is NumPy's default
' '.
Returns
- NDArray
A fresh array (see center(object, object, object)).
Exceptions
- ArgumentNullException
aorwidthis null.- TypeError
- ValueError
An empty broadcast; a
StringDTypeNA its rule refuses; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).- UnicodeEncodeError
A non-ASCII fill for an
Soperand.- IncorrectShapeException
The operands do not broadcast.
- OverflowException
A
StringDTyperesult pastsys.maxsizebytes.
lower(object)
NumPy's np.char.lower(a), which IS lower(NDArray): each element's text lowercased —
CPython's str.lower (the full mappings and the final sigma) for U and StringDType,
bytes.lower (ASCII letters only) for S.
public NDArray lower(object a)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks).
Returns
- NDArray
A fresh C-ordered PLAIN array of
a's dtype (a chararray operand too), 0-d for a scalar; anS/Uresult keeps the element width.
Exceptions
- ArgumentNullException
ais null (see the class remarks).- TypeError
ais not text (string operation on non-string array); aStringDTypeNA whose NA object is not a str.- SystemError
A
Uelement holding a code unit past U+10FFFF.- NotSupportedException
ahas no NumSharp array form.
lstrip(object, object)
NumPy's np.char.lstrip(a, chars=None), which IS lstrip(NDArray, NDArray): each element without
its LEADING characters found in chars (whitespace for null).
public NDArray lstrip(object a, object chars = null)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like.charsobjectThe characters to remove, as a set, broadcast (see strip(object, object)); null strips whitespace.
Returns
- NDArray
A fresh array of
a's dtype (a chararray view of it for a chararraya).
Exceptions
- ArgumentNullException
ais null.- TypeError
No loop for the operand classes; two different
StringDTypeNA objects.- IncorrectShapeException
The operands do not broadcast.
- ValueError
A
StringDTypeNA its rule refuses; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).
mod(object, object)
NumPy's np.char.mod(a, values): a % values element-wise — CPython's % formatting of each
element of a with the broadcast element of values. It IS
mod(NDArray, object) (NumPy re-exports the same function object).
public NDArray mod(object a, object values)
Parameters
aobjectThe format strings: an
S/U/StringDTypearray or a text array_like (see the class remarks: a C# string is a str, abyte[]Python bytes).valuesobjectThe values, converted as NumPy's
np.asarrayconverts them and broadcast againsta, ONE value per element (see mod(NDArray, object): a C# number is a Python number, a tuple or a list a sequence, a dict a mapping for%(key)sspecs, null Python'sNone).
Returns
- NDArray
A fresh C-ordered PLAIN array over the broadcast shape —
U/S(bya's class) as wide as the longest result, at least 1; a defaultStringDTypearray for aStringDTypeoperand; an empty array ofa's dtype when the broadcast is empty. A chararray operand gives a plain array too (np.asarraydrops the class);chararray % valuesis the chararray form.
Remarks
np.@char.mod(new[] { "%d", "%x" }, 255) is ["255", "ff"] (U3); an error ends the call at
the first element (C order) that raises, as in NumPy. Over S, %s writes a NumPy scalar's raw bytes
(the buffer protocol): np.@char.mod(new[] { new byte[] { (byte)'%', (byte)'s' } }, "X") holds the
np.str_'s UCS-4 bytes b"X\x00\x00\x00", read back as b"X" in an S4 result.
Exceptions
- ArgumentNullException
ais null (see the class remarks).- TypeError
ais not text (string operation on non-string array); the value count does not fit the format (not enough arguments for format string,not all arguments converted during string formatting); a conversion the value's type refuses (%d format: a real number is required, not numpy.str_);%(key)swithout a mapping; aStringDTyperesult holding a surrogate.- ValueError
A malformed format (
incomplete format,unsupported format character 'y' (0x79) at index 1); a NaN under an integer conversion; a raggedvalueslist.- OverflowException
An infinity under an integer conversion; a
%cargument out of range; an int too large for a float.- IndexError
A
%(key)slookup on a NumPy scalar.- KeyError
A
%(key)smissing from a dict.- SystemError
A
Uelement of one unit past U+10FFFF.- IncorrectShapeException
The operands do not broadcast.
- NotSupportedException
A value with no NumSharp form (an object array of lists).
multiply(object, object)
NumPy's np.char.multiply(a, i): every string repeated i times (a count below 1 gives an empty
string) — np.strings.multiply(a, i) with its TypeError re-raised as
ValueError("Can only multiply by integers"), the module's backward-compatible rule.
public NDArray multiply(object a, object i)
Parameters
aobjectThe strings (an
S/Uarray or a text array_like).iobjectThe repeat counts: an integer array_like, broadcast against
a.
Returns
- NDArray
A fresh text array of
a's class, as wide as the longest repetition.
Remarks
A NEP 55 StringDType a with an integer count computes NumPy's a * i
(multiply(NDArray, NDArray)'s StringDType branch); a TypeError there is re-raised
as the ValueError above, as for every class.
Exceptions
- ArgumentNullException
An operand is null.
- ValueError
Every
TypeErrorof multiply(NDArray, NDArray): a count that is not an integer (a float, a bool, text), a non-texta, an output width that is no valid descriptor (a uint64 count, a repetition wider than any descriptor) — allCan only multiply by integers(probed against NumPy 2.4.2). Also NumPy's own ValueErrors: an empty broadcast result (zero-size array to reduction operation maximum which has no identity) and operands that do not broadcast.- OverflowException
A string's
len * iexceedssys.maxsize("Overflow encountered in string multiply"): an OverflowError, not a TypeError, so it passes through.- IncorrectShapeException
aandido not broadcast.
not_equal(object, object)
NumPy's np.char.not_equal(x1, x2): x1 != x2 element-wise after stripping trailing NULs and ASCII
whitespace — compare_chararrays(x1, x2, '!=', True).
public NDArray not_equal(object x1, object x2)
Parameters
x1objectThe first operand (see equal(object, object)).
x2objectThe second operand.
Returns
- NDArray
The bool result, or null (NumPy's
NotImplemented) for anS/Upair.
Exceptions
- ArgumentNullException
An operand is null.
- TypeError
An operand is not
S/Utext.- IncorrectShapeException
The operands do not broadcast.
partition(object, object)
NumPy's np.char.partition(a, sep): each element split around the FIRST occurrence of
sep into the part before it, the separator and the part after it (without a match: the
element and two empty strings), stacked as ONE array whose last axis holds the three parts —
np.stack(np.strings.partition(a, sep), axis=-1). partition(NDArray, NDArray) returns the three
parts as three arrays instead.
public NDArray partition(object a, object sep)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks). A number array is cast to text the way NumPy casts it (np.char.partition(5, ' ')raises NumPy'sinvalid literal for int()).sepobjectThe separators, broadcast against
a: cast toa's dtype forS/U(a number is its text,1is'1'); aStringDTypeaneeds aStringDTypeseparator (NumPy 2.4.2 has no(StringDType, str)loop).
Returns
- NDArray
A plain array of the broadcast shape plus a last axis of length 3, as wide as its widest part (
S/U) orStringDType; laid out as NumPy'snp.stacklays out the parts (C order for a C-ordered input). A chararray input still gives a plain array:np.stackkeeps no subclass.
Remarks
For S / U NumPy computes the three parts as field views of one structured array and stacks
them; NumSharp computes three arrays and stacks them the same way. The stacked result is a fresh copy in
both, with NumPy's dtype, values and strides (an F-ordered input gives NumPy's permuted layout, neither C nor
F).
Exceptions
- ArgumentNullException
An operand is null (see the class remarks).
- ValueError
An empty separator (
empty separator); an empty broadcast (zero-size array to reduction operation maximum which has no identity, NumPy's sizing); a number operand that cannot be cast to the other's text (invalid literal for int() with base 10: np.str_(' ')); aStringDTypeNA whose NA object is not a string.- TypeError
No common dtype or no loop for the classes (NumPy's texts: a
StringDTypearray with aUseparator, a bytes separator besideStringDType); two differentStringDTypeNA objects.- UnicodeEncodeError
A non-ASCII separator cast to
S.- IncorrectShapeException
The operands do not broadcast.
replace(object, object, object, object)
NumPy's np.char.replace(a, old, new, count=-1), which IS replace(NDArray, NDArray, NDArray, NDArray): each element
with its occurrences of old replaced by new, left to right, at most
count of them (a negative count replaces all; an empty old inserts
new between every character and at both ends).
public NDArray replace(object a, object old, object @new, object count = null)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like.oldobjectThe searched strings, broadcast. A C#
string(NumPy's Pythonstr, which has no dtype) orbyte[]is cast toa's dtype first, truncated to its width; an array keeps its own dtype.newobjectThe replacements, broadcast (the rule of
old).countobjectThe most replacements per element: an integer array or literal, broadcast; null is NumPy's default -1 (NumPy's explicit
Noneraisesunsupported type object for operand 'count', which no C# argument can express).
Returns
- NDArray
A fresh array: for
S/Ua's class at the widest result width, laid out likea;StringDTypeforStringDType. A chararrayagives a chararray view of it.
Exceptions
- ArgumentNullException
a,oldornewis null.- TypeError
countis not an integer array (unsupported type float64 for operand 'count'); no common dtype or no loop for the classes; a uint64 count (NumPy's float descriptor); two differentStringDTypeNA objects.- IncorrectShapeException
A statement's operands do not broadcast.
- ValueError
An empty broadcast; a number cast to text; a
StringDTypeNA its rule refuses; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).- UnicodeEncodeError
A non-ASCII
old/newcast toS.
rfind(object, object, object, object)
NumPy's np.char.rfind(a, sub, start=0, end=None), which IS rfind(NDArray, NDArray, NDArray, NDArray): for each
element, the highest index where sub occurs inside a[start:end], or -1 (an empty
substring is found at the end of the range).
public NDArray rfind(object a, object sub, object start = null, object end = null)
Parameters
aobjectThe searched strings: an
S/U/StringDTypearray or a text array_like.subobjectThe substrings, broadcast (the classes of count(object, object, object, object)).
startobjectThe range starts in slice notation, broadcast; null is NumPy's default 0.
endobjectThe range ends in slice notation, broadcast; null is NumPy's
None.
Returns
- NDArray
A plain int64 array of the broadcast shape (0-d for scalar operands).
Exceptions
- ArgumentNullException
aorsubis null.- TypeError
No loop for the operand classes; two different
StringDTypeNA objects.- TypeError
A start / end that cannot reach int64 by a same_kind cast.
- OverflowException
A start / end literal past int64.
- IncorrectShapeException
The operands do not broadcast.
- ValueError
A
StringDTypeNA whose NA object is not a string; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).
rindex(object, object, object, object)
NumPy's np.char.rindex(a, sub, start=0, end=None), which IS rindex(NDArray, NDArray, NDArray, NDArray):
rfind(object, object, object, object), but an element with no match raises ValueError: substring not found.
public NDArray rindex(object a, object sub, object start = null, object end = null)
Parameters
aobjectThe searched strings: an
S/U/StringDTypearray or a text array_like.subobjectThe substrings, broadcast (the classes of count(object, object, object, object)).
startobjectThe range starts in slice notation, broadcast; null is NumPy's default 0.
endobjectThe range ends in slice notation, broadcast; null is NumPy's
None.
Returns
- NDArray
A plain int64 array of the broadcast shape (0-d for scalar operands).
Exceptions
- ArgumentNullException
aorsubis null.- TypeError
No loop for the operand classes; two different
StringDTypeNA objects.- TypeError
A start / end that cannot reach int64 by a same_kind cast.
- OverflowException
A start / end literal past int64.
- IncorrectShapeException
The operands do not broadcast.
- ValueError
An element without a match; a
StringDTypeNA whose NA object is not a string; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).
rjust(object, object, object)
NumPy's np.char.rjust(a, width, fillchar=' '), which IS rjust(NDArray, NDArray, NDArray): each element
right-justified in a string of width characters, padded on the left with
fillchar.
public NDArray rjust(object a, object width, object fillchar = null)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like.widthobjectThe integer widths, broadcast.
fillcharobjectThe one-character fills, broadcast; null is NumPy's default
' '.
Returns
- NDArray
A fresh array (see center(object, object, object)).
Exceptions
- ArgumentNullException
aorwidthis null.- TypeError
- ValueError
An empty broadcast; a
StringDTypeNA its rule refuses; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).- UnicodeEncodeError
A non-ASCII fill for an
Soperand.- IncorrectShapeException
The operands do not broadcast.
- OverflowException
A
StringDTyperesult pastsys.maxsizebytes.
rpartition(object, object)
NumPy's np.char.rpartition(a, sep): each element split around the LAST occurrence of
sep into the part before it, the separator and the part after it (without a match: two
empty strings and the element), stacked as one array whose last axis holds the three parts —
np.stack(np.strings.rpartition(a, sep), axis=-1).
public NDArray rpartition(object a, object sep)
Parameters
aobjectThe strings (see partition(object, object)).
sepobjectThe separators, broadcast and cast as partition(object, object) casts them.
Returns
- NDArray
A plain array of the broadcast shape plus a last axis of length 3 (see partition(object, object)).
Exceptions
- ArgumentNullException
An operand is null.
- ValueError
An empty separator; an empty broadcast; a number operand that cannot be cast to the other's text; a
StringDTypeNA whose NA object is not a string.- TypeError
No common dtype or no loop for the classes; two different
StringDTypeNA objects.- UnicodeEncodeError
A non-ASCII separator cast to
S.- IncorrectShapeException
The operands do not broadcast.
rsplit(object, object, object)
NumPy's np.char.rsplit(a, sep=None, maxsplit=None): split(object, object, object) from the right — with a
maxsplit, the splits counted from the end ('a,b,c'.rsplit(',', 1) is
['a,b', 'c']). Without one, the same words as split(object, object, object).
public NDListArray rsplit(object a, object sep = null, object maxsplit = null)
Parameters
aobjectThe text (see split(object, object, object)).
sepobjectThe separator (see split(object, object, object)).
maxsplitobjectThe most splits per element, from the right (see split(object, object, object)).
Returns
- NDListArray
NumPy's object array of lists (NDListArray).
Exceptions
- TypeError
As split(object, object, object) (the descriptor names
'rsplit').- OverflowException
A
maxsplitpastPy_ssize_t.- ValueError
An empty separator, or a ragged list argument.
- SystemError
A one-unit
Uelement, separator or word above U+10FFFF.- IncorrectShapeException
The arguments do not broadcast.
rstrip(object, object)
NumPy's np.char.rstrip(a, chars=None), which IS rstrip(NDArray, NDArray): each element without
its TRAILING characters found in chars (whitespace for null).
public NDArray rstrip(object a, object chars = null)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like.charsobjectThe characters to remove, as a set, broadcast (see strip(object, object)); null strips whitespace.
Returns
- NDArray
A fresh array of
a's dtype (a chararray view of it for a chararraya).
Exceptions
- ArgumentNullException
ais null.- TypeError
No loop for the operand classes; two different
StringDTypeNA objects.- IncorrectShapeException
The operands do not broadcast.
- ValueError
A
StringDTypeNA its rule refuses; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).
split(object, object, object)
NumPy's np.char.split(a, sep=None, maxsplit=None): every element's list of words, as Python's
str.split / bytes.split returns it. With sep null the words are the runs of
non-whitespace (CPython's 29 whitespace code points for U / StringDType, 6 ASCII bytes for
S) and empty words never appear; with a separator every occurrence splits, so empty words do.
public NDListArray split(object a, object sep = null, object maxsplit = null)
Parameters
aobjectThe text: an
S/U/StringDTypearray or a text array_like (see the class remarks).sepobjectThe separator, broadcast per element: null (NumPy's
None) for whitespace; text; for anSarray also any NumPy number, whose raw bytes are the separator (NumPy'sbytes.splitreads a NumPy scalar through the buffer protocol:np.char.split(s, 5)splits on the 8 bytes ofnp.int64(5), and astrseparator on its UCS-4 bytes); a C# list holding null gives some elementsNone(NumPy's object array).maxsplitobjectThe most splits per element, broadcast: null (NumPy's
None) or a negative value for no limit; any integer (NumSharp'sCharis NumPy'suint16).
Returns
- NDListArray
NumPy's object array of lists (NDListArray), C-ordered over the broadcast shape, 0-d for a 0-d broadcast.
Remarks
The first element (C order) that raises ends the call, as NumPy's loop does; an empty array raises none of the
element errors (np.char.split(empty, '') is an empty result). Each element is the NumPy scalar
_vec_string makes of it: trailing NULs are gone, embedded ones stay.
A U element shorter than the separator, or whose characters are all of a narrower kind than the
separator's ('abc' split on '€'), is CPython's [self]: the list holds the element's own
np.str_, which NDListArray's repr prints as np.str_('abc'), as NumPy's does.
Exceptions
- TypeError
ais not text (string operation on non-string array, also for null: Python'sNoneis an object array here, see the class remarks); per element, in NumPy's order: aStringDTypeNA that is not a str (descriptor 'split' for 'str' objects doesn't apply to a 'NoneType' object), amaxsplitwithoutindex('numpy.float64' object cannot be interpreted as an integer;np.boolhas none), a separator of the wrong type (must be str or None, not numpy.bytes_forU;a bytes-like object is required, not 'str'forSwith aStringDTypeseparator).- OverflowException
A
maxsplitpastPy_ssize_t(Python int too large to convert to C ssize_t).- ValueError
An empty separator (
empty separator); a ragged list argument (NumPy's inhomogeneous-shape text).- SystemError
A
Uelement, separator or word that is one code unit above U+10FFFF (CPython'sPyUnicode_Newrefusal).- IncorrectShapeException
The arguments do not broadcast (NumPy's
shape mismatch: objects cannot be broadcast to a single shape. Mismatch is between arg 0 with shape (2,) and arg 1 with shape (3,).).
splitlines(object, object)
NumPy's np.char.splitlines(a, keepends=None): every element's list of lines. U /
StringDType lines end at \n, \r, \r\n, \v, \f, \x1c,
\x1d, \x1e, \x85, U+2028 and U+2029; S lines at \n, \r and
\r\n only. A trailing boundary ends the last line (no empty line after it); an empty element has no
line.
public NDListArray splitlines(object a, object keepends = null)
Parameters
aobjectThe text (see split(object, object, object)).
keependsobjectWhether a line keeps its boundary, broadcast per element and read with Python's truth rule (
PyObject_IsTrue:0.5,'x'and NaN are true,''and 0 false); null (NumPy'sNone) is false.
Returns
- NDListArray
NumPy's object array of lists (NDListArray).
Exceptions
- TypeError
ais not text (null too: Python'sNone); aStringDTypeNA that is not a str (descriptor 'splitlines' for 'str' objects doesn't apply to a 'NoneType' object).- ValueError
A ragged list argument.
- SystemError
A one-unit
Uelement, keepends value or line above U+10FFFF.- IncorrectShapeException
aandkeependsdo not broadcast.
startswith(object, object, object, object)
NumPy's np.char.startswith(a, prefix, start=0, end=None), which IS startswith(NDArray, NDArray, NDArray, NDArray):
whether each element's a[start:end] begins with prefix.
public NDArray startswith(object a, object prefix, object start = null, object end = null)
Parameters
aobjectThe tested strings: an
S/U/StringDTypearray or a text array_like.prefixobjectThe prefixes, broadcast (the classes of count(object, object, object, object)).
startobjectThe range starts in slice notation, broadcast; null is NumPy's default 0.
endobjectThe range ends in slice notation, broadcast; null is NumPy's
None.
Returns
- NDArray
A plain bool array of the broadcast shape (0-d for scalar operands).
Exceptions
- ArgumentNullException
aorprefixis null.- TypeError
No loop for the operand classes; two different
StringDTypeNA objects.- TypeError
A start / end that cannot reach int64 by a same_kind cast.
- OverflowException
A start / end literal past int64.
- IncorrectShapeException
The operands do not broadcast.
- ValueError
A
StringDTypeNA whose NA object is neither a string nor NaN-like (a NaN-like NA is False); a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).
str_len(object, NDArray, NDArray, DType)
NumPy's np.char.str_len(x), which IS the str_len(NDArray, NDArray, NDArray, DType) ufunc: the length of every
element as int64 — characters for U, bytes for S, code points for StringDType. Trailing
NULs never count, embedded ones do; trailing whitespace counts (a chararray's stored text is measured, not its
stripped elements).
public NDArray str_len(object x, NDArray @out = null, NDArray where = null, DType dtype = null)
Parameters
xobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks). A number array has no loop.outNDArrayAn output to write into and return (any dtype int64 casts to under same_kind), or null.
whereNDArrayA bool mask: only elements where it is True are computed, the others keep
out's values (uninitialized in a fresh result), or null for NumPy'swhere=True.dtypeDTypeNumPy's
dtype=: only int64 has a loop; null leaves the loop to the operand.
Returns
- NDArray
A plain int64 array of
x's shape (0-d for a scalar), orout. A chararrayxstill gives a plain array; a chararrayoutcomes back as a new view of it.
Exceptions
- ArgumentNullException
xis null (see the class remarks).- TypeError
xis not text, ordtypeis not int64 (NumPy's no-loop text).- TypeError
outcannot receive int64 (the same_kind output cast).- ArgumentException
A non-bool
where; operands that do not broadcast without/where.- ValueError
A read-only
out; aStringDTypeNA whose descriptor's NA object is not a string (The length of a null string is undefined).- IncorrectShapeException
The operands do not broadcast.
strip(object, object)
NumPy's np.char.strip(a, chars=None), which IS strip(NDArray, NDArray): each element without its
leading and trailing characters found in chars (whitespace for null), keeping
a's dtype.
public NDArray strip(object a, object chars = null)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks).charsobjectThe characters to remove, as a set, broadcast:
a's class (aUset with aStringDTypea); null is NumPy'sNone, which strips whitespace — ASCII whitespace forS, Python'sstr.isspaceforU/StringDType.
Returns
- NDArray
A fresh array of
a's dtype and the broadcast shape; a chararrayagives a chararray view of it (NumPy'schararray.array_wrap).
Remarks
NumPy's trailing scan also strips NUL characters, its leading scan does not (strip(' \0ab') is
'\0ab').
Exceptions
- ArgumentNullException
ais null.- TypeError
No loop for the operand classes (a
bytesset besideU, a number: NumPy's no-loop text, naming_strip_charsor_strip_whitespace); two differentStringDTypeNA objects.- IncorrectShapeException
The operands do not broadcast.
- ValueError
A
StringDTypeNA its rule refuses; a chararray operand beside aStringDTypeone that NumPy's trivial loop copies intoStringDType()(0-d, or 1-d with at mostnp.getbufsize()elements:Can only create a chararray from string data.; a larger one computes NumPy's plain result).
swapcase(object)
NumPy's np.char.swapcase(a), which IS swapcase(NDArray): each element's uppercase
characters lowered and lowercase characters uppercased (CPython's str.swapcase /
bytes.swapcase); a titlecase character such as 'Dž' is neither and stays.
public NDArray swapcase(object a)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks).
Returns
- NDArray
A fresh C-ordered PLAIN array of
a's dtype (a chararray operand too), 0-d for a scalar; anS/Uresult keeps the element width ('ß'swaps to'SS', cut to fit).
Exceptions
- ArgumentNullException
ais null (see the class remarks).- TypeError
ais not text (string operation on non-string array); aStringDTypeNA whose NA object is not a str.- SystemError
A
Uelement holding a code unit past U+10FFFF.- NotSupportedException
ahas no NumSharp array form.
title(object)
NumPy's np.char.title(a), which IS title(NDArray): each element in titlecase — a
character after a cased character lowered, any other titlecased (CPython's str.title;
bytes.title over ASCII letters). Any uncased character starts a new "word": '12a' becomes
'12A'.
public NDArray title(object a)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks).
Returns
- NDArray
A fresh C-ordered PLAIN array of
a's dtype (a chararray operand too), 0-d for a scalar; anS/Uresult keeps the element width.
Exceptions
- ArgumentNullException
ais null (see the class remarks).- TypeError
ais not text (string operation on non-string array); aStringDTypeNA whose NA object is not a str.- SystemError
A
Uelement holding a code unit past U+10FFFF.- NotSupportedException
ahas no NumSharp array form.
translate(object, object, object)
NumPy's np.char.translate(a, table, deletechars=None), which IS translate(NDArray, object, object):
every character of each element mapped through table — CPython's str.translate for
U and StringDType, bytes.translate for S (whose deletechars
are then deleted).
public NDArray translate(object a, object table, object deletechars = null)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks).tableobjectThe table, read as the Python object it stands for and broadcast against
a(see translate(NDArray, object, object)): a dict keyed by code point forU/StringDType, a 256-byte table or null forS.deletecharsobjectThe bytes to delete (an
Soperand only); null passes nothing. NumPy ignores it forUand passes it tostr.translateforStringDType, which refuses it.
Returns
- NDArray
A fresh C-ordered PLAIN array of
a's dtype over the broadcast shape (a chararray operand too: NumPy'snp.asarraydrops the class), 0-d for a scalar; anS/Uresult keeps the element width.
Exceptions
- ArgumentNullException
ais null (see the class remarks).- TypeError
ais not text (string operation on non-string array); a table or delete set of the wrong kind;deletecharswith aStringDTypeoperand (str.translate() takes exactly one argument (2 given)); aStringDTypeNA whose NA object is not a str.- ValueError
A mapping outside
range(0x110000); anStable that is not 256 bytes long (translation table must be 256 characters long).- SystemError
A
Uunit past U+10FFFF that the call would keep.- IncorrectShapeException
The arguments do not broadcast.
- NotSupportedException
An argument with no NumSharp array form.
upper(object)
NumPy's np.char.upper(a), which IS upper(NDArray): each element's text uppercased —
CPython's str.upper (the full mappings: 'ß' becomes 'SS') for U and
StringDType, bytes.upper (ASCII letters only) for S.
public NDArray upper(object a)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like (see the class remarks).
Returns
- NDArray
A fresh C-ordered PLAIN array of
a's dtype (a chararray operand too), 0-d for a scalar. AnS/Uresult keeps the element width, so a mapping that grows is cut:'ß'in aU1array becomes'S'.
Exceptions
- ArgumentNullException
ais null (see the class remarks).- TypeError
ais not text (string operation on non-string array); aStringDTypeNA whose NA object is not a str.- SystemError
A
Uelement holding a code unit past U+10FFFF.- NotSupportedException
ahas no NumSharp array form.
zfill(object, object)
NumPy's np.char.zfill(a, width), which IS zfill(NDArray, NDArray): each element left-filled with
'0' to width characters, a leading '+' / '-' moved in front of the
zeros (zfill('-42', 5) is '-0042').
public NDArray zfill(object a, object width)
Parameters
aobjectThe strings: an
S/U/StringDTypearray or a text array_like.widthobjectThe integer widths, broadcast.
Returns
- NDArray
A fresh array (for
S/Uat the widest result width, laid out likea; a chararray view of it for a chararraya).
Exceptions
- ArgumentNullException
aorwidthis null.- TypeError
widthis not an integer array (unsupported type <U1 for operand 'width'); a non-text operand; a uint64 width; aStringDTypeNA that is neither a string nor NaN-like.- ValueError
An empty broadcast.
- IncorrectShapeException
The operands do not broadcast.
Operators
implicit operator DType(CharModule)
np.@char where a DType is expected: the Char dtype descriptor (NumSharp's UTF-16
code-unit dtype), the value the member held before it became the module.
public static implicit operator DType(CharModule module)
Parameters
moduleCharModuleThe module (char).
Returns
- DType
The
Chardescriptor, or null for a null module.