Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def test_fromstring_missing():
    assert_equal(np.fromstring("1xx3x4x5x6", sep="x"), np.array([1]))
Ejemplo n.º 3
0
def test_fromstring_empty():
    assert_equal(np.fromstring("xxxxx", sep="x"), np.array([]))
Ejemplo n.º 4
0
def test_fromstring_bogus():
    assert_equal(np.fromstring("1. 2. 3. flop 4.", dtype=float, sep=" "),
                 np.array([1., 2., 3.]))
Ejemplo n.º 5
0
 def test_fromstring_foreign_value(self):
     b = np.fromstring("1,234", dtype=np.longdouble, sep=" ")
     assert_array_equal(b[0], 1)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 def test_fromstring_foreign(self):
     s = "1.234"
     a = np.fromstring(s, dtype=np.longdouble, sep=" ")
     assert_equal(a[0], np.longdouble(s))
Ejemplo n.º 8
0
 def test_fromstring_best_effort(self):
     assert_equal(np.fromstring("1,234", dtype=np.longdouble, sep=" "),
                  np.array([1.]))
Ejemplo n.º 9
0
 def test_fromstring_best_effort_float(self):
     assert_equal(np.fromstring("1,234", dtype=float, sep=" "),
                  np.array([1.]))
Ejemplo n.º 10
0
 def test_fromstring_foreign_repr(self):
     f = 1.234
     a = np.fromstring(repr(f), dtype=float, sep=" ")
     assert_equal(a[0], f)