From 5f59ea5a71c5e3fb8d59192d849b1ef331029019 Mon Sep 17 00:00:00 2001 From: Konstantin Malanchev Date: Wed, 3 Apr 2024 12:21:34 -0400 Subject: [PATCH] Docstrings for tests --- src/nested_pandas/__init__.py | 3 +- src/nested_pandas/series/accessor.py | 2 +- src/nested_pandas/series/dtype.py | 11 +++--- tests/nested_pandas/series/test_accessor.py | 29 +++++++++++++--- tests/nested_pandas/series/test_dtype.py | 6 +++- tests/nested_pandas/series/test_ext_array.py | 36 ++++++++++++++++++-- tests/nested_pandas/series/test_packer.py | 14 +++++--- 7 files changed, 82 insertions(+), 19 deletions(-) diff --git a/src/nested_pandas/__init__.py b/src/nested_pandas/__init__.py index f276388..4577a8f 100644 --- a/src/nested_pandas/__init__.py +++ b/src/nested_pandas/__init__.py @@ -1,6 +1,7 @@ from .example_module import greetings, meaning -from .series.dtype import NestedDtype + # Import for registering from .series.accessor import NestSeriesAccessor # noqa: F401 +from .series.dtype import NestedDtype __all__ = ["greetings", "meaning", "NestedDtype"] diff --git a/src/nested_pandas/series/accessor.py b/src/nested_pandas/series/accessor.py index 1d8a085..49876fb 100644 --- a/src/nested_pandas/series/accessor.py +++ b/src/nested_pandas/series/accessor.py @@ -10,8 +10,8 @@ from numpy.typing import ArrayLike from pandas.api.extensions import register_series_accessor -from nested_pandas.series.packer import pack_sorted_df_into_struct from nested_pandas.series.dtype import NestedDtype +from nested_pandas.series.packer import pack_sorted_df_into_struct __all__ = ["NestSeriesAccessor"] diff --git a/src/nested_pandas/series/dtype.py b/src/nested_pandas/series/dtype.py index cc9baea..7dd8c95 100644 --- a/src/nested_pandas/series/dtype.py +++ b/src/nested_pandas/series/dtype.py @@ -102,7 +102,8 @@ def construct_from_string(cls, string: str) -> Self: # type: ignore[name-define field_strings = fields_str.split(", ") if len(field_strings) == 0: raise ValueError( - "Not a valid nested type string, expected at least a single field inside 'nested'" + "Not a valid nested type string, expected at least a single field inside " + "'nested'" ) fields = {} @@ -111,13 +112,13 @@ def construct_from_string(cls, string: str) -> Self: # type: ignore[name-define field_name, field_type = field_string.split(": ", maxsplit=1) except ValueError as e: raise ValueError( - "Not a valid nested type string, expected 'nested', got invalid field string " - f"'{field_string}'" + "Not a valid nested type string, expected 'nested', got invalid field " + f"string '{field_string}'" ) from e if not field_type.startswith("[") or not field_type.endswith("]"): raise ValueError( - "Not a valid nested type string, expected 'nested', got invalid field type " - f"string '{field_type}'" + "Not a valid nested type string, expected 'nested', got invalid field " + f"type string '{field_type}'" ) value_type = field_type.removeprefix("[").removesuffix("]") diff --git a/tests/nested_pandas/series/test_accessor.py b/tests/nested_pandas/series/test_accessor.py index aae9c94..d3a736f 100644 --- a/tests/nested_pandas/series/test_accessor.py +++ b/tests/nested_pandas/series/test_accessor.py @@ -2,14 +2,14 @@ import pandas as pd import pyarrow as pa import pytest -from numpy.testing import assert_array_equal -from pandas.testing import assert_frame_equal, assert_series_equal - from nested_pandas import NestedDtype from nested_pandas.series.ext_array import NestedExtensionArray +from numpy.testing import assert_array_equal +from pandas.testing import assert_frame_equal, assert_series_equal def test_registered(): + """Test that the series accessor .nest is registered.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1, 2, 3]), np.array([1.0, 2.0, 1.0])]), @@ -23,6 +23,7 @@ def test_registered(): def test_to_lists(): + """Test that the .nest.to_lists() method works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), -np.array([1.0, 2.0, 1.0])]), @@ -52,6 +53,7 @@ def test_to_lists(): def test_to_lists_with_fields(): + """Test that the .nest.to_lists(fields=...) method works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), -np.array([1.0, 2.0, 1.0])]), @@ -76,6 +78,7 @@ def test_to_lists_with_fields(): def test_to_flat(): + """Test that the .nest.to_flat() method works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -112,6 +115,7 @@ def test_to_flat(): def test_to_flat_with_fields(): + """Test that the .nest.to_flat(fields=...) method works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -142,6 +146,7 @@ def test_to_flat_with_fields(): def test_fields(): + """Test that the .nest.fields attribute works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -155,6 +160,7 @@ def test_fields(): def test_flat_length(): + """Test that the .nest.flat_length attribute works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -168,6 +174,7 @@ def test_flat_length(): def test_set_flat_field(): + """Test that the .nest.set_flat_field() method works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -191,6 +198,7 @@ def test_set_flat_field(): def test_set_list_field(): + """Test that the .nest.set_list_field() method works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -214,6 +222,7 @@ def test_set_list_field(): def test_pop_field(): + """Test that the .nest.pop_field() method works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -238,6 +247,7 @@ def test_pop_field(): def test_query_flat_1(): + """Test that the .nest.query_flat() method works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([4.0, 5.0, 6.0])]), @@ -262,7 +272,8 @@ def test_query_flat_1(): # Currently we remove empty rows from the output series -def test_query_flat_2(): +def test_query_flat_empty_rows(): + """Test that the .nest.query_flat() method works as expected for empty rows.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([4.0, 5.0, 6.0])]), @@ -279,6 +290,7 @@ def test_query_flat_2(): def test_get_list_series(): + """Test that the .nest.get_list_series() method works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1, 2, 3]), np.array([4, 5, 6])]), @@ -302,6 +314,7 @@ def test_get_list_series(): def test___getitem___single_field(): + """Test that the .nest["field"] works for a single field.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -332,6 +345,7 @@ def test___getitem___single_field(): def test___getitem___multiple_fields(): + """Test that the .nest[["b", "a"]] works for multiple fields.""" arrays = [ pa.array([np.array([1.0, 2.0, 3.0]), -np.array([1.0, 2.0, 1.0])]), pa.array([np.array([4.0, 5.0, 6.0]), -np.array([3.0, 4.0, 5.0])]), @@ -361,6 +375,7 @@ def test___getitem___multiple_fields(): def test___setitem___with_flat(): + """Test that the .nest["field"] = ... works for a single field.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -384,6 +399,7 @@ def test___setitem___with_flat(): def test___setitem___with_list(): + """Test that the .nest["field"] = ... works for a single field.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -407,6 +423,7 @@ def test___setitem___with_list(): def test___setited___raises_for_ambiguous_lengths_1(): + """Test that the .nest["field"] = ... raises for ambiguous lengths of the right hand side.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array( @@ -430,6 +447,7 @@ def test___setited___raises_for_ambiguous_lengths_1(): def test___setited___raises_for_ambiguous_lengths_2(): + """Test that the .nest["field"] = ... raises for ambiguous lengths of the right hand side.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0]), np.array([])]), @@ -444,6 +462,7 @@ def test___setited___raises_for_ambiguous_lengths_2(): def test___delitem__(): + """Test that the `del .nest["field"]` works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -459,6 +478,7 @@ def test___delitem__(): def test___iter__(): + """Test that the iter(.nest) works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -472,6 +492,7 @@ def test___iter__(): def test___len__(): + """Test that the len(.nest) works.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), diff --git a/tests/nested_pandas/series/test_dtype.py b/tests/nested_pandas/series/test_dtype.py index 59be48f..0abcd61 100644 --- a/tests/nested_pandas/series/test_dtype.py +++ b/tests/nested_pandas/series/test_dtype.py @@ -1,6 +1,5 @@ import pyarrow as pa import pytest - from nested_pandas.series.dtype import NestedDtype from nested_pandas.series.ext_array import NestedExtensionArray @@ -19,6 +18,7 @@ ], ) def test_from_pyarrow_dtype(pyarrow_dtype): + """Test that we can construct NestedDtype from pyarrow struct type.""" dtype = NestedDtype(pyarrow_dtype) assert dtype.pyarrow_dtype == pyarrow_dtype @@ -35,11 +35,13 @@ def test_from_pyarrow_dtype(pyarrow_dtype): ], ) def test_from_pyarrow_dtype_raises(pyarrow_dtype): + """Test that we raise an error when constructing NestedDtype from invalid pyarrow type.""" with pytest.raises(ValueError): NestedDtype(pyarrow_dtype) def test_from_fields(): + """Test NestedDtype.from_fields().""" fields = {"a": pa.int64(), "b": pa.float64()} dtype = NestedDtype.from_fields(fields) assert dtype.pyarrow_dtype == pa.struct( @@ -60,9 +62,11 @@ def test_from_fields(): ], ) def test_name_vs_construct_from_string(fields): + """Test that dtype.name is consistent with dtype.construct_from_string(dtype.name).""" dtype = NestedDtype.from_fields(fields) assert dtype == NestedDtype.construct_from_string(dtype.name) def test_construct_array_type(): + """Test that NestedDtype.construct_array_type() returns NestedExtensionArray.""" assert NestedDtype.construct_array_type() is NestedExtensionArray diff --git a/tests/nested_pandas/series/test_ext_array.py b/tests/nested_pandas/series/test_ext_array.py index c7fb97e..c4d9ead 100644 --- a/tests/nested_pandas/series/test_ext_array.py +++ b/tests/nested_pandas/series/test_ext_array.py @@ -2,14 +2,14 @@ import pandas as pd import pyarrow as pa import pytest -from numpy.testing import assert_array_equal -from pandas.testing import assert_frame_equal, assert_series_equal - from nested_pandas import NestedDtype from nested_pandas.series.ext_array import NestedExtensionArray +from numpy.testing import assert_array_equal +from pandas.testing import assert_frame_equal, assert_series_equal def test_ext_array_dtype(): + """Test that the dtype of the extension array is correct.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -22,6 +22,7 @@ def test_ext_array_dtype(): def test_series_dtype(): + """Test that the dtype of the series is correct.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -35,6 +36,7 @@ def test_series_dtype(): def test_series_built_with_dtype(): + """Test that the series is built correctly with the given dtype.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -48,6 +50,7 @@ def test_series_built_with_dtype(): def test_series_built_from_dict(): + """Test that the series is built correctly from a dictionary.""" data = [ {"a": [1, 2, 3], "b": [-4.0, -5.0, -6.0]}, {"a": [1, 2, 1], "b": [-3.0, -4.0, -5.0]}, @@ -71,6 +74,7 @@ def test_series_built_from_dict(): def test__convert_df_to_pa_scalar(): + """Test that we can convert a DataFrame to a pyarrow scalar.""" df = pd.DataFrame({"a": [1, 2, 3], "b": [-4.0, -5.0, -6.0]}) pa_scalar = NestedExtensionArray._convert_df_to_pa_scalar(df, type=None) @@ -81,6 +85,7 @@ def test__convert_df_to_pa_scalar(): def test__convert_df_to_pa_from_scalar(): + """Test that we can convert a DataFrame to a pyarrow scalar.""" df = pd.DataFrame({"a": [1, 2, 3], "b": [-4.0, -5.0, -6.0]}) pa_scalar = NestedExtensionArray._convert_df_to_pa_scalar(df, type=None) @@ -91,6 +96,7 @@ def test__convert_df_to_pa_from_scalar(): def test__convert_df_to_pa_from_series(): + """Test that we can convert a DataFrame to a pyarrow scalar.""" series = pd.Series( [ pd.DataFrame({"a": [1, 2, 3], "b": [-4.0, -5.0, -6.0]}), @@ -108,6 +114,7 @@ def test__convert_df_to_pa_from_series(): def test__convert_df_to_pa_from_list(): + """Test that we can convert a DataFrame to a pyarrow scalar.""" list_of_dfs = [ pd.DataFrame({"a": [1, 2, 3], "b": [-4.0, -5.0, -6.0]}), pd.DataFrame({"a": [1, 2, 1], "b": [-3.0, -4.0, -5.0]}), @@ -123,6 +130,7 @@ def test__convert_df_to_pa_from_list(): def test__from_sequence(): + """Test that we can convert a list of DataFrames to a NestedExtensionArray.""" list_of_dfs = [ pd.DataFrame({"a": [1, 2, 3], "b": [-4.0, -5.0, -6.0]}), pd.DataFrame({"a": [1, 2, 1], "b": [-3.0, -4.0, -5.0]}), @@ -139,6 +147,7 @@ def test__from_sequence(): def test___setitem___single_df(): + """Tests nested_ext_array[i] = pd.DataFrame(...) with df of the same size as the struct array.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1, 2, 3]), np.array([1, 2, 1])]), @@ -163,6 +172,7 @@ def test___setitem___single_df(): def test___setitem___single_df_different_size(): + """Tests nested_ext_array[i] = pd.DataFrame(...) with df of different size than the struct array.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1, 2, 3]), np.array([1, 2, 1])]), @@ -187,6 +197,7 @@ def test___setitem___single_df_different_size(): def test___setitem___single_df_to_all_rows(): + """Tests nested_ext_array[:] = pd.DataFrame(...)""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1, 2, 3]), np.array([1, 2, 1])]), @@ -211,6 +222,7 @@ def test___setitem___single_df_to_all_rows(): def test___setitem___list_of_dfs(): + """Tests nested_ext_array[:] = [pd.DataFrame(...), pd.DataFrame(...), ...]""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1, 2, 3]), np.array([1, 2, 1])]), @@ -238,6 +250,7 @@ def test___setitem___list_of_dfs(): def test___setitem___series_of_dfs(): + """Tests nested_ext_array[:] = pd.Series([pd.DataFrame(...), pd.DataFrame(...), ...])""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1, 2, 3]), np.array([1, 2, 1])]), @@ -285,12 +298,14 @@ def test___setitem___series_of_dfs(): ], ) def test_series_built_raises(data): + """Test that the extension array raises an error when the data is not valid.""" pa_array = pa.array(data) with pytest.raises(ValueError): _array = NestedExtensionArray(pa_array) def test_list_offsets(): + """Test that the list offsets are correct.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1, 2, 3]), np.array([1, 2, 1])], type=pa.list_(pa.uint8())), @@ -305,6 +320,7 @@ def test_list_offsets(): def test___getitem__(): + """Tests series[i] is a valid DataFrame.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -321,6 +337,7 @@ def test___getitem__(): def test_series_apply_udf_argument(): + """Tests `x` in series.apply(lambda x: x) is a valid DataFrame.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -337,6 +354,7 @@ def test_series_apply_udf_argument(): def test___iter__(): + """Tests iter(series) yields valid DataFrames.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -352,6 +370,7 @@ def test___iter__(): def test_field_names(): + """Tests that the extension array field names are correct.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])]), @@ -365,6 +384,7 @@ def test_field_names(): def test_flat_length(): + """Tests that the flat length of the extension array is correct.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0, 2.0])]), @@ -378,6 +398,7 @@ def test_flat_length(): def test_view_fields_with_single_field(): + """Tests ext_array.view("field")""" arrays = [ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0, 2.0])]), pa.array([-np.array([4.0, 5.0, 6.0]), -np.array([3.0, 4.0, 5.0, 6.0])]), @@ -403,6 +424,7 @@ def test_view_fields_with_single_field(): def test_view_fields_with_multiple_fields(): + """Tests ext_array.view(["field1", "field2"])""" arrays = [ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 3.0, 4.0])]), pa.array([-np.array([4.0, 5.0, 6.0]), -np.array([3.0, 4.0, 5.0, 6.0])]), @@ -427,6 +449,7 @@ def test_view_fields_with_multiple_fields(): def test_view_fields_raises_for_invalid_field(): + """Tests that we raise an error when trying to view a field that does not exist.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 3.0, 4.0])]), @@ -441,6 +464,7 @@ def test_view_fields_raises_for_invalid_field(): def test_view_fields_raises_for_non_unique_fields(): + """Tests that we raise an error when trying to view multiple fields with the sama name.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 3.0, 4.0])]), @@ -455,6 +479,7 @@ def test_view_fields_raises_for_non_unique_fields(): def test_set_flat_field_new_field_scalar(): + """Tests setting a new field with a scalar value.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0, 2.0])]), @@ -480,6 +505,7 @@ def test_set_flat_field_new_field_scalar(): def test_set_flat_field_replace_field_array(): + """Tests replacing a field with a new "flat" array.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 3.0, 4.0])]), @@ -504,6 +530,7 @@ def test_set_flat_field_replace_field_array(): def test_set_list_field_new_field(): + """Tests setting a new field with a new "list" array""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0, 2.0])]), @@ -529,6 +556,7 @@ def test_set_list_field_new_field(): def test_set_list_field_replace_field(): + """Tests replacing a field with a new "list" array.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0, 2.0])]), @@ -553,6 +581,7 @@ def test_set_list_field_replace_field(): def test_pop_field(): + """Tests that we can pop a field from the extension array.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0, 2.0])]), @@ -578,6 +607,7 @@ def test_pop_field(): def test_delete_last_field_raises(): + """Tests that we raise an error when trying to delete the last field left.""" struct_array = pa.StructArray.from_arrays( arrays=[ pa.array([np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0, 2.0])]), diff --git a/tests/nested_pandas/series/test_packer.py b/tests/nested_pandas/series/test_packer.py index e0252de..5859a9d 100644 --- a/tests/nested_pandas/series/test_packer.py +++ b/tests/nested_pandas/series/test_packer.py @@ -1,14 +1,14 @@ import numpy as np import pandas as pd import pyarrow as pa -from numpy.testing import assert_array_equal -from pandas.testing import assert_frame_equal, assert_series_equal - from nested_pandas import NestedDtype from nested_pandas.series import packer +from numpy.testing import assert_array_equal +from pandas.testing import assert_frame_equal, assert_series_equal def test_pack_flat_into_df(): + """Test pack_flat_into_df().""" df = pd.DataFrame( data={ "a": [7, 8, 9, 1, 2, 3, 4, 5, 6], @@ -57,6 +57,7 @@ def test_pack_flat_into_df(): def test_pack_flat(): + """Test pack_flat().""" df = pd.DataFrame( data={ "a": [7, 8, 9, 1, 2, 3, 4, 5, 6], @@ -81,6 +82,7 @@ def test_pack_flat(): def test_pack_sorted_df_into_struct(): + """Test pack_sorted_df_into_struct().""" df = pd.DataFrame( data={ "a": [1, 2, 3, 4, 5, 6, 7, 8, 9], @@ -105,6 +107,7 @@ def test_pack_sorted_df_into_struct(): def test_pack_lists(): + """Test pack_lists().""" packed_df = pd.DataFrame( data={ "a": [ @@ -129,7 +132,8 @@ def test_pack_lists(): assert_series_equal(series.struct.field(field_name), packed_df[field_name]) -def test_dfs(): +def test_pack_dfs(): + """Test pack_dfs().""" dfs = [ pd.DataFrame( data={ @@ -176,6 +180,7 @@ def test_dfs(): def test_view_sorted_df_as_list_arrays(): + """Test view_sorted_df_as_list_arrays().""" flat_df = pd.DataFrame( data={ "a": [1, 2, 3, 4, 5, 6, 7, 8, 9], @@ -209,6 +214,7 @@ def test_view_sorted_df_as_list_arrays(): def test_view_sorted_series_as_list_array(): + """Test view_sorted_series_as_list_array().""" series = pd.Series( data=[1, 2, 3, 4, 5, 6, 7, 8, 9], index=[1, 1, 2, 2, 3, 3, 4, 4, 4],