@@ -809,29 +809,45 @@ def test_vector(self):
809
809
dtype = BinaryVectorDtype .PACKED_BIT ,
810
810
) # type: ignore[call-overload]
811
811
812
+ def assertRepr (self , obj ):
813
+ new_obj = eval (repr (obj ))
814
+ self .assertEqual (type (new_obj ), type (obj ))
815
+ self .assertEqual (repr (new_obj ), repr (obj ))
816
+
812
817
def test_binaryvector_repr (self ):
813
818
"""Tests of repr(BinaryVector)"""
814
- data = [127 , 7 ]
815
- zero = BinaryVector ([], BinaryVectorDtype .INT8 )
816
- self .assertEqual (
817
- repr (zero ), "BinaryVector(dtype=BinaryVectorDtype.INT8, padding=0, data=[])"
818
- )
819
- one = BinaryVector (data , BinaryVectorDtype .INT8 )
819
+
820
+ data = [1 / 127 , - 7 / 6 ]
821
+ one = BinaryVector (data , BinaryVectorDtype .FLOAT32 )
820
822
self .assertEqual (
821
- repr (one ), f"BinaryVector(dtype=BinaryVectorDtype.INT8 , padding=0, data={ data } )"
823
+ repr (one ), f"BinaryVector(dtype=BinaryVectorDtype.FLOAT32 , padding=0, data={ data } )"
822
824
)
823
- two = BinaryVector (data , BinaryVectorDtype .FLOAT32 )
825
+ self .assertRepr (one )
826
+
827
+ data = [127 , 7 ]
828
+ two = BinaryVector (data , BinaryVectorDtype .INT8 )
824
829
self .assertEqual (
825
- repr (two ), f"BinaryVector(dtype=BinaryVectorDtype.FLOAT32 , padding=0, data={ data } )"
830
+ repr (two ), f"BinaryVector(dtype=BinaryVectorDtype.INT8 , padding=0, data={ data } )"
826
831
)
827
- three = BinaryVector (data , BinaryVectorDtype .FLOAT32 , padding = 0 )
832
+ self .assertRepr (two )
833
+
834
+ three = BinaryVector (data , BinaryVectorDtype .INT8 , padding = 0 )
828
835
self .assertEqual (
829
- repr (three ), f"BinaryVector(dtype=BinaryVectorDtype.FLOAT32 , padding=0, data={ data } )"
836
+ repr (three ), f"BinaryVector(dtype=BinaryVectorDtype.INT8 , padding=0, data={ data } )"
830
837
)
838
+ self .assertRepr (three )
839
+
831
840
four = BinaryVector (data , BinaryVectorDtype .PACKED_BIT , padding = 3 )
832
841
self .assertEqual (
833
842
repr (four ), f"BinaryVector(dtype=BinaryVectorDtype.PACKED_BIT, padding=3, data={ data } )"
834
843
)
844
+ self .assertRepr (four )
845
+
846
+ zero = BinaryVector ([], BinaryVectorDtype .INT8 )
847
+ self .assertEqual (
848
+ repr (zero ), "BinaryVector(dtype=BinaryVectorDtype.INT8, padding=0, data=[])"
849
+ )
850
+ self .assertRepr (zero )
835
851
836
852
def test_unicode_regex (self ):
837
853
"""Tests we do not get a segfault for C extension on unicode RegExs.
0 commit comments