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

Method test_fromtextfile

numpy/ma/tests/test_mrecords.py:460–477  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

458 assert_equal(_mrec._mask.tolist(), mrec._mask.tolist())
459
460 def test_fromtextfile(self):
461 # Tests reading from a text file.
462 fcontent = (
463"""#
464'One (S)','Two (I)','Three (F)','Four (M)','Five (-)','Six (C)'
465'strings',1,1.0,'mixed column',,1
466'with embedded "double quotes"',2,2.0,1.0,,1
467'strings',3,3.0E5,3,,1
468'strings',4,-1e-10,,,1
469""")
470 with temppath() as path:
471 with open(path, 'w') as f:
472 f.write(fcontent)
473 mrectxt = fromtextfile(path, delimiter=',', varnames='ABCDEFG')
474 assert_(isinstance(mrectxt, MaskedRecords))
475 assert_equal(mrectxt.F, [1, 1, 1, 1])
476 assert_equal(mrectxt.E._mask, [1, 1, 1, 1])
477 assert_equal(mrectxt.C, [1, 2, 3.e+5, -1e-10])
478
479 def test_addfield(self):
480 # Tests addfield

Callers

nothing calls this directly

Calls 6

temppathFunction · 0.90
fromtextfileFunction · 0.90
assert_equalFunction · 0.90
openFunction · 0.85
assert_Function · 0.85
writeMethod · 0.45

Tested by

no test coverage detected