| 1585 | assert_equal(c1, c2) |
| 1586 | |
| 1587 | def test_fromfile_tofile_seeks(self): |
| 1588 | # tofile/fromfile used to get (#1610) the Python file handle out of sync |
| 1589 | with tempfile.NamedTemporaryFile() as f: |
| 1590 | f.write(np.arange(255, dtype='u1').tobytes()) |
| 1591 | |
| 1592 | f.seek(20) |
| 1593 | ret = np.fromfile(f, count=4, dtype='u1') |
| 1594 | assert_equal(ret, np.array([20, 21, 22, 23], dtype='u1')) |
| 1595 | assert_equal(f.tell(), 24) |
| 1596 | |
| 1597 | f.seek(40) |
| 1598 | np.array([1, 2, 3], dtype='u1').tofile(f) |
| 1599 | assert_equal(f.tell(), 43) |
| 1600 | |
| 1601 | f.seek(40) |
| 1602 | data = f.read(3) |
| 1603 | assert_equal(data, b"\x01\x02\x03") |
| 1604 | |
| 1605 | f.seek(80) |
| 1606 | f.read(4) |
| 1607 | data = np.fromfile(f, dtype='u1', count=4) |
| 1608 | assert_equal(data, np.array([84, 85, 86, 87], dtype='u1')) |
| 1609 | |
| 1610 | def test_complex_scalar_warning(self): |
| 1611 | for tp in [np.csingle, np.cdouble, np.clongdouble]: |