@@ -809,29 +809,45 @@ def test_vector(self):
809809 dtype = BinaryVectorDtype .PACKED_BIT ,
810810 ) # type: ignore[call-overload]
811811
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+
812817 def test_binaryvector_repr (self ):
813818 """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 )
820822 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 } )"
822824 )
823- two = BinaryVector (data , BinaryVectorDtype .FLOAT32 )
825+ self .assertRepr (one )
826+
827+ data = [127 , 7 ]
828+ two = BinaryVector (data , BinaryVectorDtype .INT8 )
824829 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 } )"
826831 )
827- three = BinaryVector (data , BinaryVectorDtype .FLOAT32 , padding = 0 )
832+ self .assertRepr (two )
833+
834+ three = BinaryVector (data , BinaryVectorDtype .INT8 , padding = 0 )
828835 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 } )"
830837 )
838+ self .assertRepr (three )
839+
831840 four = BinaryVector (data , BinaryVectorDtype .PACKED_BIT , padding = 3 )
832841 self .assertEqual (
833842 repr (four ), f"BinaryVector(dtype=BinaryVectorDtype.PACKED_BIT, padding=3, data={ data } )"
834843 )
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 )
835851
836852 def test_unicode_regex (self ):
837853 """Tests we do not get a segfault for C extension on unicode RegExs.
0 commit comments