MCPcopy Create free account
hub / github.com/numpy/numpy / _convert_from_string

Function _convert_from_string

numpy/matrixlib/defmatrix.py:15–34  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

13
14
15def _convert_from_string(data):
16 for char in '[]':
17 data = data.replace(char, '')
18
19 rows = data.split(';')
20 newdata = []
21 count = 0
22 for row in rows:
23 trow = row.split(',')
24 newrow = []
25 for col in trow:
26 temp = col.split()
27 newrow.extend(map(ast.literal_eval, temp))
28 if count == 0:
29 Ncols = len(newrow)
30 elif len(newrow) != Ncols:
31 raise ValueError("Rows not the same size.")
32 count += 1
33 newdata.append(newrow)
34 return newdata
35
36
37@set_module('numpy')

Callers 1

__new__Method · 0.85

Calls 2

replaceMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected