本文整理汇总了Python中numpy.compat.asbytes_nested函数的典型用法代码示例。如果您正苦于以下问题:Python asbytes_nested函数的具体用法?Python asbytes_nested怎么用?Python asbytes_nested使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了asbytes_nested函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_no_delimiter
def test_no_delimiter(self):
"Test LineSplitter w/o delimiter"
strg = asbytes(" 1 2 3 4 5 # test")
test = LineSplitter()(strg)
assert_equal(test, asbytes_nested(['1', '2', '3', '4', '5']))
test = LineSplitter('')(strg)
assert_equal(test, asbytes_nested(['1', '2', '3', '4', '5']))
开发者ID:Garrett-R,项目名称:numpy,代码行数:7,代码来源:test__iotools.py
示例2: test_partition
def test_partition(self):
P = self.A.partition(asbytes_nested(['3', 'M']))
tgt = asbytes_nested([[(' abc ', '', ''), ('', '', '')],
[('12', '3', '45'), ('', 'M', 'ixedCase')],
[('12', '3', ' \t 345 \0 '), ('UPPER', '', '')]])
assert_(issubclass(P.dtype.type, np.string_))
assert_array_equal(P, tgt)
开发者ID:cimarieta,项目名称:usp,代码行数:7,代码来源:test_defchararray.py
示例3: test_set_elements
def test_set_elements(self):
base = self.base.copy()
# Set an element to mask .....................
mbase = base.view(mrecarray).copy()
mbase[-2] = masked
assert_equal(
mbase._mask.tolist(),
np.array([(0, 0, 0), (1, 1, 1), (0, 0, 0), (1, 1, 1), (1, 1, 1)],
dtype=bool))
# Used to be mask, now it's recordmask!
assert_equal(mbase.recordmask, [0, 1, 0, 1, 1])
# Set slices .................................
mbase = base.view(mrecarray).copy()
mbase[:2] = (5, 5, 5)
assert_equal(mbase.a._data, [5, 5, 3, 4, 5])
assert_equal(mbase.a._mask, [0, 0, 0, 0, 1])
assert_equal(mbase.b._data, [5., 5., 3.3, 4.4, 5.5])
assert_equal(mbase.b._mask, [0, 0, 0, 0, 1])
assert_equal(mbase.c._data,
asbytes_nested(['5', '5', 'three', 'four', 'five']))
assert_equal(mbase.b._mask, [0, 0, 0, 0, 1])
mbase = base.view(mrecarray).copy()
mbase[:2] = masked
assert_equal(mbase.a._data, [1, 2, 3, 4, 5])
assert_equal(mbase.a._mask, [1, 1, 0, 0, 1])
assert_equal(mbase.b._data, [1.1, 2.2, 3.3, 4.4, 5.5])
assert_equal(mbase.b._mask, [1, 1, 0, 0, 1])
assert_equal(mbase.c._data,
asbytes_nested(['one', 'two', 'three', 'four', 'five']))
assert_equal(mbase.b._mask, [1, 1, 0, 0, 1])
开发者ID:dyao-vu,项目名称:meta-core,代码行数:31,代码来源:test_mrecords.py
示例4: test_space_delimiter
def test_space_delimiter(self):
"Test space delimiter"
strg = asbytes(" 1 2 3 4 5 # test")
test = LineSplitter(asbytes(' '))(strg)
assert_equal(test, asbytes_nested(['1', '2', '3', '4', '', '5']))
test = LineSplitter(asbytes(' '))(strg)
assert_equal(test, asbytes_nested(['1 2 3 4', '5']))
开发者ID:Garrett-R,项目名称:numpy,代码行数:7,代码来源:test__iotools.py
示例5: test_rpartition
def test_rpartition(self):
P = self.A.rpartition(asbytes_nested(['3', 'M']))
assert_(issubclass(P.dtype.type, np.string_))
assert_array_equal(P, asbytes_nested([
[('', '', ' abc '), ('', '', '')],
[('12', '3', '45'), ('', 'M', 'ixedCase')],
[('123 \t ', '3', '45 \0 '), ('', '', 'UPPER')]]))
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:7,代码来源:test_defchararray.py
示例6: test_space_delimiter
def test_space_delimiter(self):
"Test space delimiter"
strg = asbytes(" 1 2 3 4 5 # test")
test = LineSplitter(asbytes(" "))(strg)
assert_equal(test, asbytes_nested(["1", "2", "3", "4", "", "5"]))
test = LineSplitter(asbytes(" "))(strg)
assert_equal(test, asbytes_nested(["1 2 3 4", "5"]))
开发者ID:asval,项目名称:numpy,代码行数:7,代码来源:test__iotools.py
示例7: test_no_delimiter
def test_no_delimiter(self):
"Test LineSplitter w/o delimiter"
strg = asbytes(" 1 2 3 4 5 # test")
test = LineSplitter()(strg)
assert_equal(test, asbytes_nested(["1", "2", "3", "4", "5"]))
test = LineSplitter("")(strg)
assert_equal(test, asbytes_nested(["1", "2", "3", "4", "5"]))
开发者ID:asval,项目名称:numpy,代码行数:7,代码来源:test__iotools.py
示例8: test_variable_fixed_width
def test_variable_fixed_width(self):
strg = asbytes(" 1 3 4 5 6# test")
test = LineSplitter((3, 6, 6, 3))(strg)
assert_equal(test, asbytes_nested(["1", "3", "4 5", "6"]))
#
strg = asbytes(" 1 3 4 5 6# test")
test = LineSplitter((6, 6, 9))(strg)
assert_equal(test, asbytes_nested(["1", "3 4", "5 6"]))
开发者ID:asval,项目名称:numpy,代码行数:8,代码来源:test__iotools.py
示例9: test_tab_delimiter
def test_tab_delimiter(self):
"Test tab delimiter"
strg = asbytes(" 1\t 2\t 3\t 4\t 5 6")
test = LineSplitter(asbytes("\t"))(strg)
assert_equal(test, asbytes_nested(["1", "2", "3", "4", "5 6"]))
strg = asbytes(" 1 2\t 3 4\t 5 6")
test = LineSplitter(asbytes("\t"))(strg)
assert_equal(test, asbytes_nested(["1 2", "3 4", "5 6"]))
开发者ID:asval,项目名称:numpy,代码行数:8,代码来源:test__iotools.py
示例10: test_partition
def test_partition(self):
if sys.version_info >= (2, 5):
P = self.A.partition(asbytes_nested(['3', 'M']))
assert issubclass(P.dtype.type, np.string_)
assert_array_equal(P, asbytes_nested([
[(' abc ', '', ''), ('', '', '')],
[('12', '3', '45'), ('', 'M', 'ixedCase')],
[('12', '3', ' \t 345 \0 '), ('UPPER', '', '')]]))
开发者ID:umitceylan,项目名称:Visualizr,代码行数:8,代码来源:test_defchararray.py
示例11: test_other_delimiter
def test_other_delimiter(self):
"Test LineSplitter on delimiter"
strg = asbytes("1,2,3,4,,5")
test = LineSplitter(asbytes(","))(strg)
assert_equal(test, asbytes_nested(["1", "2", "3", "4", "", "5"]))
#
strg = asbytes(" 1,2,3,4,,5 # test")
test = LineSplitter(asbytes(","))(strg)
assert_equal(test, asbytes_nested(["1", "2", "3", "4", "", "5"]))
开发者ID:asval,项目名称:numpy,代码行数:9,代码来源:test__iotools.py
示例12: test_other_delimiter
def test_other_delimiter(self):
"Test LineSplitter on delimiter"
strg = asbytes("1,2,3,4,,5")
test = LineSplitter(asbytes(','))(strg)
assert_equal(test, asbytes_nested(['1', '2', '3', '4', '', '5']))
#
strg = asbytes(" 1,2,3,4,,5 # test")
test = LineSplitter(asbytes(','))(strg)
assert_equal(test, asbytes_nested(['1', '2', '3', '4', '', '5']))
开发者ID:Garrett-R,项目名称:numpy,代码行数:9,代码来源:test__iotools.py
示例13: test_lapack
def test_lapack(self):
f = FindDependenciesLdd()
depsLibg2c = f.grep_dependencies(lapack_lite.__file__,
asbytes_nested(['libg2c']))
depsLibgfortran = f.grep_dependencies(lapack_lite.__file__,
asbytes_nested(['libgfortran']))
self.assertFalse(len(depsLibg2c)*len(depsLibgfortran) > 0,
"""Both g77 and gfortran runtimes linked in lapack_lite ! This is likely to
cause random crashes and wrong results. See numpy INSTALL.txt for more
information.""")
开发者ID:ewalter,项目名称:numpy,代码行数:10,代码来源:test_build.py
示例14: test_strip
def test_strip(self):
assert issubclass(self.A.strip().dtype.type, np.string_)
assert_array_equal(
self.A.strip(), asbytes_nested([["abc", ""], ["12345", "MixedCase"], ["123 \t 345", "UPPER"]])
)
assert_array_equal(
self.A.strip(asbytes_nested(["15", "EReM"])),
asbytes_nested([[" abc ", ""], ["234", "ixedCas"], ["23 \t 345 \x00", "UPP"]]),
)
assert issubclass(self.B.strip().dtype.type, np.unicode_)
assert_array_equal(self.B.strip(), [["\u03a3", ""], ["12345", "MixedCase"], ["123 \t 345", "UPPER"]])
开发者ID:Kurios,项目名称:Project32,代码行数:11,代码来源:test_defchararray.py
示例15: test_constant_fixed_width
def test_constant_fixed_width(self):
"Test LineSplitter w/ fixed-width fields"
strg = asbytes(" 1 2 3 4 5 # test")
test = LineSplitter(3)(strg)
assert_equal(test, asbytes_nested(["1", "2", "3", "4", "", "5", ""]))
#
strg = asbytes(" 1 3 4 5 6# test")
test = LineSplitter(20)(strg)
assert_equal(test, asbytes_nested(["1 3 4 5 6"]))
#
strg = asbytes(" 1 3 4 5 6# test")
test = LineSplitter(30)(strg)
assert_equal(test, asbytes_nested(["1 3 4 5 6"]))
开发者ID:asval,项目名称:numpy,代码行数:13,代码来源:test__iotools.py
示例16: test_constant_fixed_width
def test_constant_fixed_width(self):
"Test LineSplitter w/ fixed-width fields"
strg = asbytes(" 1 2 3 4 5 # test")
test = LineSplitter(3)(strg)
assert_equal(test, asbytes_nested(['1', '2', '3', '4', '', '5', '']))
#
strg = asbytes(" 1 3 4 5 6# test")
test = LineSplitter(20)(strg)
assert_equal(test, asbytes_nested(['1 3 4 5 6']))
#
strg = asbytes(" 1 3 4 5 6# test")
test = LineSplitter(30)(strg)
assert_equal(test, asbytes_nested(['1 3 4 5 6']))
开发者ID:Garrett-R,项目名称:numpy,代码行数:13,代码来源:test__iotools.py
示例17: test_rpartition
def test_rpartition(self):
if sys.version_info >= (2, 5):
P = self.A.rpartition(asbytes_nested(["3", "M"]))
assert issubclass(P.dtype.type, np.string_)
assert_array_equal(
P,
asbytes_nested(
[
[("", "", " abc "), ("", "", "")],
[("12", "3", "45"), ("", "M", "ixedCase")],
[("123 \t ", "3", "45 \0 "), ("", "", "UPPER")],
]
),
)
开发者ID:Kurios,项目名称:Project32,代码行数:14,代码来源:test_defchararray.py
示例18: test_replace
def test_replace(self):
R = self.A.replace(asbytes_nested(["3", "a"]), asbytes_nested(["##########", "@"]))
assert issubclass(R.dtype.type, np.string_)
assert_array_equal(
R,
asbytes_nested(
[[" abc ", ""], ["12##########45", "[email protected]"], ["12########## \t ##########45 \x00", "UPPER"]]
),
)
if sys.version_info[0] < 3:
# NOTE: b'abc'.replace(b'a', 'b') is not allowed on Py3
R = self.A.replace(asbytes("a"), "\u03a3")
assert issubclass(R.dtype.type, np.unicode_)
assert_array_equal(R, [[" \u03a3bc ", ""], ["12345", "MixedC\u03a3se"], ["123 \t 345 \x00", "UPPER"]])
开发者ID:Kurios,项目名称:Project32,代码行数:15,代码来源:test_defchararray.py
示例19: test_array
def test_array(self):
a = np.array([[1, 2], [3, 4]], float)
fmt = "%.18e"
c = StringIO()
np.savetxt(c, a, fmt=fmt)
c.seek(0)
assert_equal(
c.readlines(), asbytes_nested([(fmt + " " + fmt + "\n") % (1, 2), (fmt + " " + fmt + "\n") % (3, 4)])
)
a = np.array([[1, 2], [3, 4]], int)
c = StringIO()
np.savetxt(c, a, fmt="%d")
c.seek(0)
assert_equal(c.readlines(), asbytes_nested(["1 2\n", "3 4\n"]))
开发者ID:hector1618,项目名称:numpy,代码行数:15,代码来源:test_io.py
示例20: test_from_object_array
def test_from_object_array(self):
A = np.array([['abc', 2],
['long ', '0123456789']], dtype='O')
B = np.char.array(A)
assert_equal(B.dtype.itemsize, 10)
assert_array_equal(B, asbytes_nested([['abc', '2'],
['long', '0123456789']]))
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:7,代码来源:test_defchararray.py
注:本文中的numpy.compat.asbytes_nested函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论