@@ -48,6 +48,18 @@ def numpy(request):
4848 return request .param
4949
5050
51+ def get_int32_compat_dtype (numpy , orient ):
52+ # See GH#32527
53+ dtype = np .int64
54+ if not ((numpy is None or orient == "index" ) or (numpy is True and orient is None )):
55+ if compat .is_platform_windows ():
56+ dtype = np .int32
57+ else :
58+ dtype = np .intp
59+
60+ return dtype
61+
62+
5163class TestUltraJSONTests :
5264 @pytest .mark .skipif (
5365 compat .is_platform_32bit (), reason = "not compliant on 32-bit, xref #15865"
@@ -833,13 +845,20 @@ def test_dataframe(self, orient, numpy):
833845 if orient == "records" and numpy :
834846 pytest .skip ("Not idiomatic pandas" )
835847
848+ dtype = get_int32_compat_dtype (numpy , orient )
849+
836850 df = DataFrame (
837- [[1 , 2 , 3 ], [4 , 5 , 6 ]], index = ["a" , "b" ], columns = ["x" , "y" , "z" ]
851+ [[1 , 2 , 3 ], [4 , 5 , 6 ]],
852+ index = ["a" , "b" ],
853+ columns = ["x" , "y" , "z" ],
854+ dtype = dtype ,
838855 )
839856 encode_kwargs = {} if orient is None else dict (orient = orient )
840857 decode_kwargs = {} if numpy is None else dict (numpy = numpy )
858+ assert (df .dtypes == dtype ).all ()
841859
842860 output = ujson .decode (ujson .encode (df , ** encode_kwargs ), ** decode_kwargs )
861+ assert (df .dtypes == dtype ).all ()
843862
844863 # Ensure proper DataFrame initialization.
845864 if orient == "split" :
@@ -857,7 +876,8 @@ def test_dataframe(self, orient, numpy):
857876 elif orient == "index" :
858877 df = df .transpose ()
859878
860- tm .assert_frame_equal (output , df , check_dtype = False )
879+ assert (df .dtypes == dtype ).all ()
880+ tm .assert_frame_equal (output , df )
861881
862882 def test_dataframe_nested (self , orient ):
863883 df = DataFrame (
@@ -897,14 +917,20 @@ def test_dataframe_numpy_labelled(self, orient):
897917 tm .assert_frame_equal (output , df )
898918
899919 def test_series (self , orient , numpy ):
920+ dtype = get_int32_compat_dtype (numpy , orient )
900921 s = Series (
901- [10 , 20 , 30 , 40 , 50 , 60 ], name = "series" , index = [6 , 7 , 8 , 9 , 10 , 15 ]
922+ [10 , 20 , 30 , 40 , 50 , 60 ],
923+ name = "series" ,
924+ index = [6 , 7 , 8 , 9 , 10 , 15 ],
925+ dtype = dtype ,
902926 ).sort_values ()
927+ assert s .dtype == dtype
903928
904929 encode_kwargs = {} if orient is None else dict (orient = orient )
905930 decode_kwargs = {} if numpy is None else dict (numpy = numpy )
906931
907932 output = ujson .decode (ujson .encode (s , ** encode_kwargs ), ** decode_kwargs )
933+ assert s .dtype == dtype
908934
909935 if orient == "split" :
910936 dec = _clean_dict (output )
@@ -920,7 +946,8 @@ def test_series(self, orient, numpy):
920946 s .name = None
921947 s .index = [0 , 1 , 2 , 3 , 4 , 5 ]
922948
923- tm .assert_series_equal (output , s , check_dtype = False )
949+ assert s .dtype == dtype
950+ tm .assert_series_equal (output , s )
924951
925952 def test_series_nested (self , orient ):
926953 s = Series (
0 commit comments