@@ -413,17 +413,7 @@ def test_to_df_with_pretty_px_with_various_schemas_converts_prices_as_expected(
413413
414414@pytest .mark .parametrize (
415415 "expected_schema" ,
416- [
417- Schema .MBO ,
418- Schema .MBP_1 ,
419- Schema .MBP_10 ,
420- Schema .TBBO ,
421- Schema .TRADES ,
422- Schema .OHLCV_1S ,
423- Schema .OHLCV_1M ,
424- Schema .OHLCV_1H ,
425- Schema .OHLCV_1D ,
426- ],
416+ [pytest .param (schema , id = str (schema )) for schema in Schema ],
427417)
428418def test_from_file_given_various_paths_returns_expected_metadata (
429419 test_data_path : Callable [[Schema ], Path ],
@@ -474,7 +464,7 @@ def test_mbo_to_csv_writes_expected_file_to_disk(
474464 written = open (path , mode = "rb" ).read ()
475465 assert path .exists ()
476466 expected = (
477- b"ts_recv,ts_event,ts_in_delta,publisher_id,channel_id,instrument_id,order_id,act" # noqa
467+ b"ts_recv,ts_event,ts_in_delta,publisher_id,channel_id,instrument_id,order_id,act" # noqa
478468 b"ion,side,flags,price,size,sequence\n 1609160400000704060,16091604000004298" # noqa
479469 b"31,22993,1,0,5482,647784973705,C,A,128,3722750000000,1,1170352\n 160916040" # noqa
480470 b"0000711344,1609160400000431665,19621,1,0,5482,647784973631,C,A,128,372300000" # noqa
@@ -718,16 +708,7 @@ def test_mbp_1_to_json_with_all_options_writes_expected_file_to_disk(
718708
719709@pytest .mark .parametrize (
720710 "schema" ,
721- [
722- s
723- for s in Schema
724- if s
725- not in (
726- Schema .OHLCV_1H ,
727- Schema .OHLCV_1D ,
728- Schema .DEFINITION ,
729- )
730- ],
711+ [pytest .param (schema , id = str (schema )) for schema in Schema ],
731712)
732713def test_dbnstore_repr (
733714 test_data : Callable [[Schema ], bytes ],
@@ -820,17 +801,7 @@ def test_dbnstore_iterable_parallel(
820801
821802@pytest .mark .parametrize (
822803 "schema" ,
823- [
824- Schema .MBO ,
825- Schema .MBP_1 ,
826- Schema .MBP_10 ,
827- Schema .OHLCV_1D ,
828- Schema .OHLCV_1H ,
829- Schema .OHLCV_1M ,
830- Schema .OHLCV_1S ,
831- Schema .TBBO ,
832- Schema .TRADES ,
833- ],
804+ [pytest .param (schema , id = str (schema )) for schema in Schema ],
834805)
835806def test_dbnstore_compression_equality (
836807 test_data : Callable [[Schema ], bytes ],
@@ -923,17 +894,7 @@ def test_dbnstore_buffer_long(
923894
924895@pytest .mark .parametrize (
925896 "schema" ,
926- [
927- Schema .MBO ,
928- Schema .MBP_1 ,
929- Schema .MBP_10 ,
930- Schema .OHLCV_1D ,
931- Schema .OHLCV_1H ,
932- Schema .OHLCV_1M ,
933- Schema .OHLCV_1S ,
934- Schema .TBBO ,
935- Schema .TRADES ,
936- ],
897+ [pytest .param (schema , id = str (schema )) for schema in Schema ],
937898)
938899def test_dbnstore_to_ndarray_with_schema (
939900 schema : Schema ,
@@ -957,19 +918,30 @@ def test_dbnstore_to_ndarray_with_schema(
957918 assert row == expected [i ]
958919
959920
921+ def test_dbnstore_to_ndarray_with_schema_empty (
922+ test_data : Callable [[Schema ], bytes ],
923+ ) -> None :
924+ """
925+ Test that calling to_ndarray on a DBNStore that contains no data of the
926+ specified schema returns an empty DataFrame.
927+ """
928+ # Arrange
929+ dbn_stub_data = (
930+ zstandard .ZstdDecompressor ().stream_reader (test_data (Schema .TRADES )).read ()
931+ )
932+
933+ # Act
934+ dbnstore = DBNStore .from_bytes (data = dbn_stub_data )
935+
936+ array = dbnstore .to_ndarray (schema = Schema .MBO )
937+
938+ # Assert
939+ assert len (array ) == 0
940+
941+
960942@pytest .mark .parametrize (
961943 "schema" ,
962- [
963- Schema .MBO ,
964- Schema .MBP_1 ,
965- Schema .MBP_10 ,
966- Schema .OHLCV_1D ,
967- Schema .OHLCV_1H ,
968- Schema .OHLCV_1M ,
969- Schema .OHLCV_1S ,
970- Schema .TBBO ,
971- Schema .TRADES ,
972- ],
944+ [pytest .param (schema , id = str (schema )) for schema in Schema ],
973945)
974946def test_dbnstore_to_df_with_schema (
975947 schema : Schema ,
@@ -990,3 +962,24 @@ def test_dbnstore_to_df_with_schema(
990962
991963 # Assert
992964 assert actual .equals (expected )
965+
966+
967+ def test_dbnstore_to_df_with_schema_empty (
968+ test_data : Callable [[Schema ], bytes ],
969+ ) -> None :
970+ """
971+ Test that calling to_df on a DBNStore that contains no data of the
972+ specified schema returns an empty DataFrame.
973+ """
974+ # Arrange
975+ dbn_stub_data = (
976+ zstandard .ZstdDecompressor ().stream_reader (test_data (Schema .TRADES )).read ()
977+ )
978+
979+ # Act
980+ dbnstore = DBNStore .from_bytes (data = dbn_stub_data )
981+
982+ df = dbnstore .to_df (schema = Schema .MBO )
983+
984+ # Assert
985+ assert df .empty
0 commit comments