|
56 | 56 | TYPE_CHECKING_INVALID_USAGE,
|
57 | 57 | WINDOWS,
|
58 | 58 | check,
|
| 59 | + pytest_warns_bounded, |
59 | 60 | )
|
60 | 61 |
|
61 | 62 | from pandas.io.api import to_pickle
|
@@ -371,57 +372,77 @@ def test_hdfstore():
|
371 | 372 | assert_type(store.select("df", start=0, stop=1), Union[DataFrame, Series]),
|
372 | 373 | DataFrame,
|
373 | 374 | )
|
374 |
| - check( |
375 |
| - assert_type(store.select("df", where="index>=1"), Union[DataFrame, Series]), |
376 |
| - DataFrame, |
377 |
| - ) |
378 |
| - check( |
379 |
| - assert_type( |
380 |
| - store.select("df", where=Term("index>=1")), |
381 |
| - Union[DataFrame, Series], |
382 |
| - ), |
383 |
| - DataFrame, |
384 |
| - ) |
385 |
| - check( |
386 |
| - assert_type( |
387 |
| - store.select("df", where=[Term("index>=1")]), |
388 |
| - Union[DataFrame, Series], |
389 |
| - ), |
390 |
| - DataFrame, |
391 |
| - ) |
392 |
| - check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame) |
393 |
| - for key in store: |
394 |
| - check(assert_type(key, str), str) |
395 |
| - check(assert_type(store.close(), None), type(None)) |
| 375 | + with pytest_warns_bounded( |
| 376 | + DeprecationWarning, |
| 377 | + match="`alltrue` is deprecated as of NumPy 1.25.0", |
| 378 | + lower="1.24.99", |
| 379 | + version_str=np.__version__, |
| 380 | + ): |
| 381 | + check( |
| 382 | + assert_type( |
| 383 | + store.select("df", where="index>=1"), Union[DataFrame, Series] |
| 384 | + ), |
| 385 | + DataFrame, |
| 386 | + ) |
| 387 | + check( |
| 388 | + assert_type( |
| 389 | + store.select("df", where=Term("index>=1")), |
| 390 | + Union[DataFrame, Series], |
| 391 | + ), |
| 392 | + DataFrame, |
| 393 | + ) |
| 394 | + check( |
| 395 | + assert_type( |
| 396 | + store.select("df", where=[Term("index>=1")]), |
| 397 | + Union[DataFrame, Series], |
| 398 | + ), |
| 399 | + DataFrame, |
| 400 | + ) |
| 401 | + check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame) |
| 402 | + for key in store: |
| 403 | + check(assert_type(key, str), str) |
| 404 | + check(assert_type(store.close(), None), type(None)) |
396 | 405 |
|
397 |
| - store = HDFStore(path, model="r") |
398 |
| - check( |
399 |
| - assert_type(read_hdf(store, "df"), Union[DataFrame, Series]), |
400 |
| - DataFrame, |
401 |
| - ) |
402 |
| - store.close() |
| 406 | + store = HDFStore(path, model="r") |
| 407 | + check( |
| 408 | + assert_type(read_hdf(store, "df"), Union[DataFrame, Series]), |
| 409 | + DataFrame, |
| 410 | + ) |
| 411 | + store.close() |
403 | 412 |
|
404 | 413 |
|
405 | 414 | def test_read_hdf_iterator():
|
406 |
| - with ensure_clean() as path: |
407 |
| - check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None)) |
408 |
| - ti = read_hdf(path, chunksize=1) |
409 |
| - check(assert_type(ti, TableIterator), TableIterator) |
410 |
| - ti.close() |
| 415 | + with pytest_warns_bounded( |
| 416 | + DeprecationWarning, |
| 417 | + match="`alltrue` is deprecated as of NumPy 1.25.0", |
| 418 | + lower="1.24.99", |
| 419 | + version_str=np.__version__, |
| 420 | + ): |
| 421 | + with ensure_clean() as path: |
| 422 | + check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None)) |
| 423 | + ti = read_hdf(path, chunksize=1) |
| 424 | + check(assert_type(ti, TableIterator), TableIterator) |
| 425 | + ti.close() |
411 | 426 |
|
412 |
| - ti = read_hdf(path, "df", iterator=True) |
413 |
| - check(assert_type(ti, TableIterator), TableIterator) |
414 |
| - for _ in ti: |
415 |
| - pass |
416 |
| - ti.close() |
| 427 | + ti = read_hdf(path, "df", iterator=True) |
| 428 | + check(assert_type(ti, TableIterator), TableIterator) |
| 429 | + for _ in ti: |
| 430 | + pass |
| 431 | + ti.close() |
417 | 432 |
|
418 | 433 |
|
419 | 434 | def test_hdf_context_manager():
|
420 |
| - with ensure_clean() as path: |
421 |
| - check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None)) |
422 |
| - with HDFStore(path, mode="r") as store: |
423 |
| - check(assert_type(store.is_open, bool), bool) |
424 |
| - check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame) |
| 435 | + with pytest_warns_bounded( |
| 436 | + DeprecationWarning, |
| 437 | + match="`alltrue` is deprecated as of NumPy 1.25.0", |
| 438 | + lower="1.24.99", |
| 439 | + version_str=np.__version__, |
| 440 | + ): |
| 441 | + with ensure_clean() as path: |
| 442 | + check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None)) |
| 443 | + with HDFStore(path, mode="r") as store: |
| 444 | + check(assert_type(store.is_open, bool), bool) |
| 445 | + check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame) |
425 | 446 |
|
426 | 447 |
|
427 | 448 | def test_hdf_series():
|
|
0 commit comments