@@ -112,69 +112,70 @@ def test_binary_operator_sub(self):
112
112
self .assertRaisesRegex (TypeError , ks_err_msg , lambda : psdf ["a" ] - psdf ["b" ])
113
113
114
114
def test_divide_by_zero_behavior (self ):
115
- # float / float
116
- for dtype in [np .float32 , np .float64 ]:
115
+ with ps .option_context ("compute.ansi_mode_support" , True ):
116
+ # float / float
117
+ for dtype in [np .float32 , np .float64 ]:
118
+ pdf = pd .DataFrame (
119
+ {
120
+ "a" : [1.0 , - 1.0 , 0.0 , np .nan ],
121
+ "b" : [0.0 , 0.0 , 0.0 , 0.0 ],
122
+ },
123
+ dtype = dtype ,
124
+ )
125
+ psdf = ps .from_pandas (pdf )
126
+
127
+ self .assert_eq (psdf ["a" ] / psdf ["b" ], pdf ["a" ] / pdf ["b" ])
128
+
129
+ # int / int
130
+ for dtype in [np .int32 , np .int64 ]:
131
+ pdf = pd .DataFrame (
132
+ {
133
+ "a" : [1 , - 1 , 0 ],
134
+ "b" : [0 , 0 , 0 ],
135
+ },
136
+ dtype = dtype ,
137
+ )
138
+ psdf = ps .from_pandas (pdf )
139
+ self .assert_eq (psdf ["a" ] / psdf ["b" ], pdf ["a" ] / pdf ["b" ])
140
+
141
+ # float / int
117
142
pdf = pd .DataFrame (
118
143
{
119
- "a" : [1.0 , - 1.0 , 0.0 , np .nan ],
120
- "b" : [0.0 , 0.0 , 0.0 , 0.0 ],
121
- },
122
- dtype = dtype ,
144
+ "a" : pd .Series ([1.0 , - 1.0 , 0.0 , np .nan ]),
145
+ "b" : pd .Series ([0 , 0 , 0 , 0 ]),
146
+ }
123
147
)
124
148
psdf = ps .from_pandas (pdf )
125
-
126
149
self .assert_eq (psdf ["a" ] / psdf ["b" ], pdf ["a" ] / pdf ["b" ])
127
150
128
- # int / int
129
- for dtype in [np .int32 , np .int64 ]:
151
+ # int / float
130
152
pdf = pd .DataFrame (
131
153
{
132
- "a" : [1 , - 1 , 0 ],
133
- "b" : [0 , 0 , 0 ],
134
- },
135
- dtype = dtype ,
154
+ "a" : pd .Series ([1 , - 1 , 0 ]),
155
+ "b" : pd .Series ([0.0 , 0.0 , 0.0 ]),
156
+ }
136
157
)
137
158
psdf = ps .from_pandas (pdf )
138
159
self .assert_eq (psdf ["a" ] / psdf ["b" ], pdf ["a" ] / pdf ["b" ])
139
160
140
- # float / int
141
- pdf = pd .DataFrame (
142
- {
143
- "a" : pd .Series ([1.0 , - 1.0 , 0.0 , np .nan ]),
144
- "b" : pd .Series ([0 , 0 , 0 , 0 ]),
145
- }
146
- )
147
- psdf = ps .from_pandas (pdf )
148
- self .assert_eq (psdf ["a" ] / psdf ["b" ], pdf ["a" ] / pdf ["b" ])
149
-
150
- # int / float
151
- pdf = pd .DataFrame (
152
- {
153
- "a" : pd .Series ([1 , - 1 , 0 ]),
154
- "b" : pd .Series ([0.0 , 0.0 , 0.0 ]),
155
- }
156
- )
157
- psdf = ps .from_pandas (pdf )
158
- self .assert_eq (psdf ["a" ] / psdf ["b" ], pdf ["a" ] / pdf ["b" ])
159
-
160
- # bool
161
- pdf = pd .DataFrame (
162
- {
163
- "a" : pd .Series ([True , False ]),
164
- "b" : pd .Series ([0 , 0 ]),
165
- }
166
- )
167
- psdf = ps .from_pandas (pdf )
168
- self .assert_eq (psdf ["a" ] / psdf ["b" ], pdf ["a" ] / pdf ["b" ])
161
+ # bool
162
+ pdf = pd .DataFrame (
163
+ {
164
+ "a" : pd .Series ([True , False ]),
165
+ "b" : pd .Series ([0 , 0 ]),
166
+ }
167
+ )
168
+ psdf = ps .from_pandas (pdf )
169
+ self .assert_eq (psdf ["a" ] / psdf ["b" ], pdf ["a" ] / pdf ["b" ])
169
170
170
- pdf = pd .DataFrame (
171
- {
172
- "a" : pd .Series ([True , False ]),
173
- "b" : pd .Series ([0.0 , 0.0 ]),
174
- }
175
- )
176
- psdf = ps .from_pandas (pdf )
177
- self .assert_eq (psdf ["a" ] / psdf ["b" ], pdf ["a" ] / pdf ["b" ])
171
+ pdf = pd .DataFrame (
172
+ {
173
+ "a" : pd .Series ([True , False ]),
174
+ "b" : pd .Series ([0.0 , 0.0 ]),
175
+ }
176
+ )
177
+ psdf = ps .from_pandas (pdf )
178
+ self .assert_eq (psdf ["a" ] / psdf ["b" ], pdf ["a" ] / pdf ["b" ])
178
179
179
180
def test_binary_operator_truediv (self ):
180
181
# Positive
0 commit comments