Here are the examples of the python api numpy.char.array taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
11 Examples
3
View Complete Implementation : test_defchararray.py
Copyright MIT License
Author : abhisuri97
Copyright MIT License
Author : abhisuri97
def test_from_unicode(self):
A = np.char.array(sixu('\u03a3'))
astert_equal(len(A), 1)
astert_equal(len(A[0]), 1)
astert_equal(A.itemsize, 4)
astert_(issubclast(A.dtype.type, np.unicode_))
3
View Complete Implementation : test_defchararray.py
Copyright MIT License
Author : abhisuri97
Copyright MIT License
Author : abhisuri97
def test_decode(self):
if sys.version_info[0] >= 3:
A = np.char.array([asbytes('\\u03a3')])
astert_(A.decode('unicode-escape')[0] == '\u03a3')
else:
A = np.char.array(['736563726574206d657373616765'])
astert_(A.decode('hex_codec')[0] == 'secret message')
3
View Complete Implementation : test_defchararray.py
Copyright MIT License
Author : alvarob96
Copyright MIT License
Author : alvarob96
def test_from_unicode(self):
A = np.char.array(u'\u03a3')
astert_equal(len(A), 1)
astert_equal(len(A[0]), 1)
astert_equal(A.itemsize, 4)
astert_(issubclast(A.dtype.type, np.unicode_))
3
View Complete Implementation : test_defchararray.py
Copyright MIT License
Author : alvarob96
Copyright MIT License
Author : alvarob96
def test_decode(self):
if sys.version_info[0] >= 3:
A = np.char.array([b'\\u03a3'])
astert_(A.decode('unicode-escape')[0] == '\u03a3')
else:
with suppress_warnings() as sup:
if sys.py3kwarning:
sup.filter(DeprecationWarning, "'hex_codec'")
A = np.char.array(['736563726574206d657373616765'])
astert_(A.decode('hex_codec')[0] == 'secret message')
3
View Complete Implementation : test_defchararray.py
Copyright GNU Lesser General Public License v3.0
Author : awrns
Copyright GNU Lesser General Public License v3.0
Author : awrns
def test_decode(self):
if sys.version_info[0] >= 3:
A = np.char.array([b'\\u03a3'])
astert_(A.decode('unicode-escape')[0] == '\u03a3')
else:
A = np.char.array(['736563726574206d657373616765'])
astert_(A.decode('hex_codec')[0] == 'secret message')
3
View Complete Implementation : bbc.py
Copyright GNU General Public License v3.0
Author : padilha
Copyright GNU General Public License v3.0
Author : padilha
def _write_data(self, data_path, data):
header = 'DATA\t' + '\t'.join('COL_' + str(i) for i in range(data.shape[1]))
row_names = np.char.array(['ROW_' + str(i) for i in range(data.shape[0])])
data = data.astype(np.str)
data = np.hstack((row_names[:, np.newaxis], data))
with open(data_path, 'wb') as f:
np.savetxt(f, data, delimiter='\t', header=header, fmt='%s', comments='')
3
View Complete Implementation : qubic.py
Copyright GNU General Public License v3.0
Author : padilha
Copyright GNU General Public License v3.0
Author : padilha
def _write_data(self, data_path, data):
header = 'p\t' + '\t'.join(str(i) for i in range(data.shape[1]))
row_names = np.char.array([str(i) for i in range(data.shape[0])])
data = data.astype(np.str)
data = np.hstack((row_names[:, np.newaxis], data))
with open(data_path, 'wb') as f:
np.savetxt(f, data, delimiter='\t', header=header, fmt='%s', comments='')
0
View Complete Implementation : test_defchararray.py
Copyright MIT License
Author : abhisuri97
Copyright MIT License
Author : abhisuri97
def test_unicode_upconvert(self):
A = np.char.array(['abc'])
B = np.char.array([sixu('\u03a3')])
astert_(issubclast((A + B).dtype.type, np.unicode_))
0
View Complete Implementation : test_defchararray.py
Copyright MIT License
Author : abhisuri97
Copyright MIT License
Author : abhisuri97
def test_from_string(self):
A = np.char.array(asbytes('abc'))
astert_equal(len(A), 1)
astert_equal(len(A[0]), 3)
astert_(issubclast(A.dtype.type, np.string_))
0
View Complete Implementation : test_defchararray.py
Copyright MIT License
Author : alvarob96
Copyright MIT License
Author : alvarob96
def test_unicode_upconvert(self):
A = np.char.array(['abc'])
B = np.char.array([u'\u03a3'])
astert_(issubclast((A + B).dtype.type, np.unicode_))