File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
tests/nested_pandas/series Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ def align_struct_list_offsets(array: pa.StructArray) -> pa.StructArray:
119119 )
120120 new_array = pa .StructArray .from_arrays (
121121 arrays = list_arrays ,
122- type = array .type ,
122+ fields = array .type . fields ,
123123 )
124124 return new_array
125125
@@ -281,7 +281,7 @@ def validate_list_struct_type(t: pa.ListType) -> None:
281281 raise ValueError (f"Expected a StructType as a list value type, got { t .value_type } " )
282282
283283
284- def validate_struct_list_type (t : pa .ListType ) -> None :
284+ def validate_struct_list_type (t : pa .StructType ) -> None :
285285 """Raise a ValueError if not a struct-list-type."""
286286 if not pa .types .is_struct (t ):
287287 raise ValueError (f"Expected a StructType, got { t } " )
Original file line number Diff line number Diff line change 1212 transpose_list_struct_type ,
1313 transpose_struct_list_array ,
1414 transpose_struct_list_type ,
15+ validate_struct_list_type ,
1516)
1617
1718
@@ -116,6 +117,26 @@ def test_align_chunked_struct_list_offsets():
116117 assert output_array .equals (input_array )
117118
118119
120+ def test_validate_struct_list_type ():
121+ """Test validate_struct_list_type function."""
122+ with pytest .raises (ValueError ):
123+ validate_struct_list_type (pa .float64 ())
124+
125+ with pytest .raises (ValueError ):
126+ validate_struct_list_type (pa .list_ (pa .struct ({"a" : pa .int64 ()})))
127+
128+ with pytest .raises (ValueError ):
129+ validate_struct_list_type (pa .struct ({"a" : pa .float64 ()}))
130+
131+ with pytest .raises (ValueError ):
132+ validate_struct_list_type (pa .struct ({"a" : pa .list_ (pa .float64 ()), "b" : pa .float64 ()}))
133+
134+ assert (
135+ validate_struct_list_type (pa .struct ({"a" : pa .list_ (pa .float64 ()), "b" : pa .list_ (pa .float64 ())}))
136+ is None
137+ )
138+
139+
119140def test_transpose_struct_list_type ():
120141 """Test transpose_struct_list_type function."""
121142 # Raises for wrong types
You can’t perform that action at this time.
0 commit comments