def test_fromstring(): o = 1 + LD_INFO.eps s = (" " + repr(o)) * 5 a = np.array([o] * 5) assert_equal(np.fromstring(s, sep=" ", dtype=np.longdouble), a, err_msg="reading '%s'" % s)
def test_fromstring_missing(): assert_equal(np.fromstring("1xx3x4x5x6", sep="x"), np.array([1]))
def test_fromstring_empty(): assert_equal(np.fromstring("xxxxx", sep="x"), np.array([]))
def test_fromstring_bogus(): assert_equal(np.fromstring("1. 2. 3. flop 4.", dtype=float, sep=" "), np.array([1., 2., 3.]))
def test_fromstring_foreign_value(self): b = np.fromstring("1,234", dtype=np.longdouble, sep=" ") assert_array_equal(b[0], 1)
def test_fromstring_foreign_sep(self): a = np.array([1, 2, 3, 4]) b = np.fromstring("1,2,3,4,", dtype=np.longdouble, sep=",") assert_array_equal(a, b)
def test_fromstring_foreign(self): s = "1.234" a = np.fromstring(s, dtype=np.longdouble, sep=" ") assert_equal(a[0], np.longdouble(s))
def test_fromstring_best_effort(self): assert_equal(np.fromstring("1,234", dtype=np.longdouble, sep=" "), np.array([1.]))
def test_fromstring_best_effort_float(self): assert_equal(np.fromstring("1,234", dtype=float, sep=" "), np.array([1.]))
def test_fromstring_foreign_repr(self): f = 1.234 a = np.fromstring(repr(f), dtype=float, sep=" ") assert_equal(a[0], f)