|
7 | 7 |
|
8 | 8 | import tiledb
|
9 | 9 |
|
10 |
| -from .common import DiskTestCase |
11 |
| - |
12 | 10 | pd = pytest.importorskip("pandas")
|
13 | 11 | tm = pd._testing
|
14 | 12 |
|
15 | 13 |
|
16 |
| -class AttrDataTest(DiskTestCase): |
17 |
| - @hp.settings(deadline=None, verbosity=hp.Verbosity.verbose) |
18 |
| - @hp.given(st.binary()) |
19 |
| - @pytest.mark.parametrize("mode", ["np", "df"]) |
20 |
| - def test_bytes_npdf(self, mode, data): |
21 |
| - start = time.time() |
| 14 | +@pytest.mark.parametrize("mode", ["np", "df"]) |
| 15 | +@hp.settings(deadline=None, verbosity=hp.Verbosity.verbose) |
| 16 | +@hp.given(st.binary()) |
| 17 | +def test_bytes_npdf(checked_path, mode, data): |
| 18 | + start = time.time() |
| 19 | + |
| 20 | + uri = "mem://" + checked_path.path() |
| 21 | + hp.note(f"!!! path '{uri}' time: {time.time() - start}") |
| 22 | + |
| 23 | + array = np.array([data], dtype="S0") |
| 24 | + |
| 25 | + start_ingest = time.time() |
| 26 | + if mode == "np": |
| 27 | + with tiledb.from_numpy(uri, array) as A: |
| 28 | + pass |
| 29 | + else: |
| 30 | + series = pd.Series(array) |
| 31 | + df = pd.DataFrame({"": series}) |
| 32 | + # NOTE: ctx required here for mem:// |
| 33 | + tiledb.from_pandas(uri, df, sparse=False, ctx=tiledb.default_ctx()) |
22 | 34 |
|
23 |
| - uri = "mem://" + self.path() |
24 |
| - hp.note(f"!!! self.path() '{uri}' time: {time.time() - start}") |
| 35 | + hp.note(f"{mode} ingest time: {time.time() - start_ingest}") |
25 | 36 |
|
26 |
| - array = np.array([data], dtype="S0") |
| 37 | + # DEBUG |
| 38 | + tiledb.stats_enable() |
| 39 | + tiledb.stats_reset() |
| 40 | + # END DEBUG |
27 | 41 |
|
28 |
| - start_ingest = time.time() |
| 42 | + with tiledb.open(uri) as A: |
29 | 43 | if mode == "np":
|
30 |
| - with tiledb.from_numpy(uri, array) as A: |
31 |
| - pass |
| 44 | + np.testing.assert_array_equal(A.multi_index[:][""], array) |
32 | 45 | else:
|
33 |
| - series = pd.Series(array) |
34 |
| - df = pd.DataFrame({"": series}) |
35 |
| - # NOTE: ctx required here for mem:// |
36 |
| - tiledb.from_pandas(uri, df, sparse=False, ctx=tiledb.default_ctx()) |
37 |
| - |
38 |
| - hp.note(f"{mode} ingest time: {time.time() - start_ingest}") |
39 |
| - |
40 |
| - # DEBUG |
41 |
| - tiledb.stats_enable() |
42 |
| - tiledb.stats_reset() |
43 |
| - # END DEBUG |
44 |
| - |
45 |
| - with tiledb.open(uri) as A: |
46 |
| - if mode == "np": |
47 |
| - np.testing.assert_array_equal(A.multi_index[:][""], array) |
48 |
| - else: |
49 |
| - tm.assert_frame_equal(A.df[:], df) |
50 |
| - |
51 |
| - hp.note(tiledb.stats_dump(print_out=False)) |
52 |
| - |
53 |
| - # DEBUG |
54 |
| - tiledb.stats_disable() |
55 |
| - |
56 |
| - duration = time.time() - start |
57 |
| - hp.note(f"!!! test_bytes_{mode} duration: {duration}") |
58 |
| - if duration > 2: |
59 |
| - # Hypothesis setup is (maybe) causing deadline exceeded errors |
60 |
| - # https://github.com/TileDB-Inc/TileDB-Py/issues/1194 |
61 |
| - # Set deadline=None and use internal timing instead. |
62 |
| - pytest.fail(f"!!! {mode} function body duration exceeded 2s: {duration}") |
| 46 | + tm.assert_frame_equal(A.df[:], df) |
| 47 | + |
| 48 | + hp.note(tiledb.stats_dump(print_out=False)) |
| 49 | + |
| 50 | + # DEBUG |
| 51 | + tiledb.stats_disable() |
| 52 | + |
| 53 | + duration = time.time() - start |
| 54 | + hp.note(f"!!! test_bytes_{mode} duration: {duration}") |
| 55 | + if duration > 2: |
| 56 | + # Hypothesis setup is (maybe) causing deadline exceeded errors |
| 57 | + # https://github.com/TileDB-Inc/TileDB-Py/issues/1194 |
| 58 | + # Set deadline=None and use internal timing instead. |
| 59 | + pytest.fail(f"!!! {mode} function body duration exceeded 2s: {duration}") |
0 commit comments