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