@@ -272,38 +272,38 @@ def test_parr_cmp_pi(self, freq, box_with_array):
272
272
tm .assert_equal (base <= idx , exp )
273
273
274
274
@pytest .mark .parametrize ("freq" , ["M" , "2M" , "3M" ])
275
- def test_parr_cmp_pi_mismatched_freq_raises (self , freq , box_with_array ):
275
+ def test_parr_cmp_pi_mismatched_freq (self , freq , box_with_array ):
276
276
# GH#13200
277
277
# different base freq
278
278
base = PeriodIndex (["2011-01" , "2011-02" , "2011-03" , "2011-04" ], freq = freq )
279
279
base = tm .box_expected (base , box_with_array )
280
280
281
- msg = "Input has different freq=A-DEC from "
282
- with pytest .raises (IncompatibleFrequency , match = msg ):
281
+ msg = rf"Invalid comparison between dtype=period\[ { freq } \] and Period "
282
+ with pytest .raises (TypeError , match = msg ):
283
283
base <= Period ("2011" , freq = "A" )
284
284
285
- with pytest .raises (IncompatibleFrequency , match = msg ):
285
+ with pytest .raises (TypeError , match = msg ):
286
286
Period ("2011" , freq = "A" ) >= base
287
287
288
288
# TODO: Could parametrize over boxes for idx?
289
289
idx = PeriodIndex (["2011" , "2012" , "2013" , "2014" ], freq = "A" )
290
- rev_msg = r"Input has different freq=(M|2M|3M) from PeriodArray\(freq= A-DEC\) "
290
+ rev_msg = r"Invalid comparison between dtype=period\[ A-DEC\] and PeriodArray "
291
291
idx_msg = rev_msg if box_with_array in [tm .to_array , pd .array ] else msg
292
- with pytest .raises (IncompatibleFrequency , match = idx_msg ):
292
+ with pytest .raises (TypeError , match = idx_msg ):
293
293
base <= idx
294
294
295
295
# Different frequency
296
- msg = "Input has different freq=4M from "
297
- with pytest .raises (IncompatibleFrequency , match = msg ):
296
+ msg = rf"Invalid comparison between dtype=period\[ { freq } \] and Period "
297
+ with pytest .raises (TypeError , match = msg ):
298
298
base <= Period ("2011" , freq = "4M" )
299
299
300
- with pytest .raises (IncompatibleFrequency , match = msg ):
300
+ with pytest .raises (TypeError , match = msg ):
301
301
Period ("2011" , freq = "4M" ) >= base
302
302
303
303
idx = PeriodIndex (["2011" , "2012" , "2013" , "2014" ], freq = "4M" )
304
- rev_msg = r"Input has different freq=(M|2M|3M) from PeriodArray\(freq= 4M\) "
304
+ rev_msg = r"Invalid comparison between dtype=period\[ 4M\] and PeriodArray "
305
305
idx_msg = rev_msg if box_with_array in [tm .to_array , pd .array ] else msg
306
- with pytest .raises (IncompatibleFrequency , match = idx_msg ):
306
+ with pytest .raises (TypeError , match = idx_msg ):
307
307
base <= idx
308
308
309
309
@pytest .mark .parametrize ("freq" , ["M" , "2M" , "3M" ])
@@ -354,12 +354,13 @@ def test_pi_cmp_nat_mismatched_freq_raises(self, freq):
354
354
idx1 = PeriodIndex (["2011-01" , "2011-02" , "NaT" , "2011-05" ], freq = freq )
355
355
356
356
diff = PeriodIndex (["2011-02" , "2011-01" , "2011-04" , "NaT" ], freq = "4M" )
357
- msg = "Input has different freq=4M from Period(Array|Index) "
358
- with pytest .raises (IncompatibleFrequency , match = msg ):
357
+ msg = rf"Invalid comparison between dtype=period\[ { freq } \] and PeriodArray "
358
+ with pytest .raises (TypeError , match = msg ):
359
359
idx1 > diff
360
360
361
- with pytest .raises (IncompatibleFrequency , match = msg ):
362
- idx1 == diff
361
+ result = idx1 == diff
362
+ expected = np .array ([False , False , False , False ], dtype = bool )
363
+ tm .assert_numpy_array_equal (result , expected )
363
364
364
365
# TODO: De-duplicate with test_pi_cmp_nat
365
366
@pytest .mark .parametrize ("dtype" , [object , None ])
0 commit comments