[[ 16. 17. 18. 19.]
[ 20. 21. 22. 23.]]]
6.0 0.0 13.0 8.0
-
+
>>> obj_array()
[a 1 {}]
a 1 {}
Traceback (most recent call last):
...
ValueError: ndarray is not C contiguous
-
+
>>> test_dtype('b', inc1_byte)
>>> test_dtype('B', inc1_ubyte)
>>> test_dtype('h', inc1_short)
>>> test_dtype('I', inc1_uint)
>>> test_dtype('l', inc1_long)
>>> test_dtype('L', inc1_ulong)
-
+
>>> test_dtype('f', inc1_float)
>>> test_dtype('d', inc1_double)
>>> test_dtype('g', inc1_longdouble)
Traceback (most recent call last):
...
ValueError: Non-native byte order not supported
-
+
>>> test_recordarray()
-
+
>>> print(test_nested_dtypes(np.zeros((3,), dtype=np.dtype([\
('a', np.dtype('i,i')),\
('b', np.dtype('i,i'))\
]))))
- array([((0, 0), (0, 0)), ((1, 2), (1, 4)), ((1, 2), (1, 4))],
+ array([((0, 0), (0, 0)), ((1, 2), (1, 4)), ((1, 2), (1, 4))],
dtype=[('a', [('f0', '!i4'), ('f1', '!i4')]), ('b', [('f0', '!i4'), ('f1', '!i4')])])
>>> print(test_nested_dtypes(np.zeros((3,), dtype=np.dtype([\
ValueError: Buffer dtype mismatch, expected 'int' but got 'float' in 'DoubleInt.y'
>>> print(test_packed_align(np.zeros((1,), dtype=np.dtype('b,i', align=False))))
- array([(22, 23)],
+ array([(22, 23)],
dtype=[('f0', '|i1'), ('f1', '!i4')])
>>> print(test_unpacked_align(np.zeros((1,), dtype=np.dtype('b,i', align=True))))
- array([(22, 23)],
+ array([(22, 23)],
dtype=[('f0', '|i1'), ('', '|V3'), ('f1', '!i4')])
>>> print(test_packed_align(np.zeros((1,), dtype=np.dtype('b,i', align=True))))
8,16
>>> test_point_record()
- array([(0.0, 0.0), (1.0, -1.0), (2.0, -2.0)],
+ array([(0.0, 0.0), (1.0, -1.0), (2.0, -2.0)],
dtype=[('x', '!f8'), ('y', '!f8')])
-
+
"""
except:
__doc__ = u""
Since Py2.3 doctest don't support <BLANKLINE>, manually replace blank lines
with <_BLANKLINE_>
"""
- return unicode(arr).replace(u'\n\n', u'\n<_BLANKLINE_>\n')
+ return unicode(arr).replace(u'\n\n', u'\n<_BLANKLINE_>\n')
def basic():
cdef object[int, ndim=2] buf = np.arange(10, dtype=b'i').reshape((2, 5))
def inc1_cfloat_struct(np.ndarray[np.cfloat_t] arr):
arr[1].real += 1
arr[1].imag += 1
-
+
def inc1_cdouble_struct(np.ndarray[np.cdouble_t] arr):
arr[1].real += 1
arr[1].imag += 1
def inc1_int32_t(np.ndarray[np.int32_t] arr): arr[1] += 1
def inc1_float64_t(np.ndarray[np.float64_t] arr): arr[1] += 1
-
+
def test_dtype(dtype, inc1):
if dtype in ("g", np.longdouble,
"G", np.clongdouble):
def test_unpacked_align(np.ndarray[UnpackedStruct] arr):
arr[0].a = 22
- arr[0].b = 23
+ arr[0].b = 23
return repr(arr).replace('<', '!').replace('>', '!')
def test_complextypes():
>>> print_all( text.split(sep) )
ab jd
sdflk as sa
- sadas asdas fsdf
+ sadas asdas fsdf
>>> print_all( split_sep(text, sep) )
ab jd
sdflk as sa
- sadas asdas fsdf
+ sadas asdas fsdf
"""
return s.split(sep)
"""
>>> print_all( text.split(sep, 1) )
ab jd
- sdflk as sa sadas asdas fsdf
+ sdflk as sa sadas asdas fsdf
>>> print_all( split_sep_max(text, sep, 1) )
ab jd
- sdflk as sa sadas asdas fsdf
+ sdflk as sa sadas asdas fsdf
"""
return s.split(sep, max)
"""
>>> print_all( text.split(sep, 1) )
ab jd
- sdflk as sa sadas asdas fsdf
+ sdflk as sa sadas asdas fsdf
>>> print_all( split_sep_max_int(text, sep) )
ab jd
- sdflk as sa sadas asdas fsdf
+ sdflk as sa sadas asdas fsdf
"""
return s.split(sep, 1)
>>> print_all( multiline_text.splitlines() )
ab jd
sdflk as sa
- sadas asdas fsdf
+ sadas asdas fsdf
>>> len(splitlines(multiline_text))
3
>>> print_all( splitlines(multiline_text) )
ab jd
sdflk as sa
- sadas asdas fsdf
+ sadas asdas fsdf
"""
return s.splitlines()
<BLANKLINE>
sdflk as sa
<BLANKLINE>
- sadas asdas fsdf
+ sadas asdas fsdf
>>> len(splitlines_keep(multiline_text, True))
3
>>> print_all( splitlines_keep(multiline_text, True) )
<BLANKLINE>
sdflk as sa
<BLANKLINE>
- sadas asdas fsdf
+ sadas asdas fsdf
"""
return s.splitlines(keep)
<BLANKLINE>
sdflk as sa
<BLANKLINE>
- sadas asdas fsdf
+ sadas asdas fsdf
>>> print_all( multiline_text.splitlines(False) )
ab jd
sdflk as sa
- sadas asdas fsdf
+ sadas asdas fsdf
>>> len(splitlines_keep_bint(multiline_text))
7
>>> print_all( splitlines_keep_bint(multiline_text) )
<BLANKLINE>
sdflk as sa
<BLANKLINE>
- sadas asdas fsdf
+ sadas asdas fsdf
--
ab jd
sdflk as sa
- sadas asdas fsdf
+ sadas asdas fsdf
"""
return s.splitlines(True) + ['--'] + s.splitlines(False)
def replace(unicode s, substring, repl):
"""
>>> print( text.replace('sa', 'SA') )
- ab jd sdflk as SA SAdas asdas fsdf
+ ab jd sdflk as SA SAdas asdas fsdf
>>> print( replace(text, 'sa', 'SA') )
- ab jd sdflk as SA SAdas asdas fsdf
+ ab jd sdflk as SA SAdas asdas fsdf
"""
return s.replace(substring, repl)
def replace_maxcount(unicode s, substring, repl, maxcount):
"""
>>> print( text.replace('sa', 'SA', 1) )
- ab jd sdflk as SA sadas asdas fsdf
+ ab jd sdflk as SA sadas asdas fsdf
>>> print( replace_maxcount(text, 'sa', 'SA', 1) )
- ab jd sdflk as SA sadas asdas fsdf
+ ab jd sdflk as SA sadas asdas fsdf
"""
return s.replace(substring, repl, maxcount)