Skip to content

Commit b88eb35

Browse files
sinhrksjreback
authored andcommitted
TST/ERR: Add Period ops tests / fix error message
xref to pandas-dev#13242 closes pandas-dev#13251 Author: sinhrks <[email protected]> Closes pandas-dev#13250 from sinhrks/period_test and squashes the following commits: 33a04f3 [sinhrks] TST/ERR: Add Period ops tests / fix error message
1 parent 82bdc1d commit b88eb35

File tree

4 files changed

+276
-184
lines changed

4 files changed

+276
-184
lines changed

pandas/src/period.pyx

+4-5
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,8 @@ cdef class Period(object):
799799
else:
800800
ordinal = self.ordinal + (nanos // offset_nanos)
801801
return Period(ordinal=ordinal, freq=self.freq)
802-
msg = 'Input cannnot be converted to Period(freq={0})'
803-
raise ValueError(msg)
802+
msg = 'Input cannot be converted to Period(freq={0})'
803+
raise IncompatibleFrequency(msg.format(self.freqstr))
804804
elif isinstance(other, offsets.DateOffset):
805805
freqstr = frequencies.get_standard_freq(other)
806806
base = frequencies.get_base_alias(freqstr)
@@ -849,8 +849,8 @@ cdef class Period(object):
849849
return Period(ordinal=ordinal, freq=self.freq)
850850
elif isinstance(other, Period):
851851
if other.freq != self.freq:
852-
raise ValueError("Cannot do arithmetic with "
853-
"non-conforming periods")
852+
msg = _DIFFERENT_FREQ.format(self.freqstr, other.freqstr)
853+
raise IncompatibleFrequency(msg)
854854
if self.ordinal == tslib.iNaT or other.ordinal == tslib.iNaT:
855855
return Period(ordinal=tslib.iNaT, freq=self.freq)
856856
return self.ordinal - other.ordinal
@@ -865,7 +865,6 @@ cdef class Period(object):
865865
else:
866866
return NotImplemented
867867

868-
869868
def asfreq(self, freq, how='E'):
870869
"""
871870
Convert Period to desired frequency, either at the start or end of the

0 commit comments

Comments
 (0)