Skip to content

Commit 170d08b

Browse files
author
Si Wei How
committed
Edit error messages
1 parent 4cd7db1 commit 170d08b

File tree

2 files changed

+7
-41
lines changed

2 files changed

+7
-41
lines changed

pandas/tests/tseries/offsets/test_offsets.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@ def setup_method(self, method):
770770
def test_constructor_errors(self):
771771
from datetime import time as dt_time
772772
with pytest.raises(ValueError,
773-
match='time data must be specified only with hour and minute'):
773+
match='time data must be specified only with hour '
774+
'and minute'):
774775
BusinessHour(start=dt_time(11, 0, 5))
775776
with pytest.raises(ValueError,
776777
match="time data must match '%H:%M' format"):
@@ -779,10 +780,10 @@ def test_constructor_errors(self):
779780
match="time data must match '%H:%M' format"):
780781
BusinessHour(start='14:00:05')
781782
with pytest.raises(ValueError,
782-
match='number of starting time cannot be 0'):
783+
match='Must include at least 1 start time'):
783784
BusinessHour(start=[])
784785
with pytest.raises(ValueError,
785-
match='number of ending time cannot be 0'):
786+
match='Must include at least 1 end time'):
786787
BusinessHour(end=[])
787788
with pytest.raises(ValueError,
788789
match='number of starting time and ending time '
@@ -793,7 +794,9 @@ def test_constructor_errors(self):
793794
'must be the same'):
794795
BusinessHour(start=['09:00', '11:00'], end=['10:00'])
795796
with pytest.raises(ValueError,
796-
match=r'invalid starting and ending time\(s\)'):
797+
match=r'invalid starting and ending time\(s\): '
798+
'opening hours should not touch or overlap with '
799+
'one another'):
797800
BusinessHour(start=['09:00', '11:00'], end=['12:00', '20:00'])
798801

799802
def test_different_normalize_equals(self):

pandas/tseries/offsets.py

-37
Original file line numberDiff line numberDiff line change
@@ -583,21 +583,13 @@ def __init__(self, start='09:00', end='17:00', offset=timedelta(0)):
583583
if _iterable_not_string(start):
584584
start = np.asarray(start)
585585
if len(start) == 0:
586-
<<<<<<< HEAD
587586
raise ValueError('Must include at least 1 start time')
588-
=======
589-
raise ValueError('number of starting time cannot be 0')
590-
>>>>>>> Edit comments and tests
591587
else:
592588
start = np.array([start])
593589
if _iterable_not_string(end):
594590
end = np.asarray(end)
595591
if len(end) == 0:
596-
<<<<<<< HEAD
597592
raise ValueError('Must include at least 1 end time')
598-
=======
599-
raise ValueError('number of ending time cannot be 0')
600-
>>>>>>> Edit comments and tests
601593
else:
602594
end = np.array([end])
603595

@@ -653,16 +645,10 @@ def _get_daytime_flag(self, start, end):
653645

654646
def _next_opening_time(self, other, sign=1):
655647
"""
656-
<<<<<<< HEAD
657648
If self.n and sign have the same sign, return the earliest opening time
658649
later than or equal to current time.
659650
Otherwise the latest opening time earlier than or equal to current
660651
time.
661-
=======
662-
If self.n and dir have the same sign, return the earliest opening time
663-
later than or equal to current time.
664-
Otherwise the latest opening time earlier than or equal to current time.
665-
>>>>>>> Edit comments and tests
666652
667653
Opening time always locates on BusinessDay.
668654
However, closing time may not if business hour extends over midnight.
@@ -671,20 +657,14 @@ def _next_opening_time(self, other, sign=1):
671657
latest_start = self.start[-1]
672658
if not self.next_bday.onOffset(other):
673659
# today is not business day
674-
<<<<<<< HEAD
675660
other = other + sign * self.next_bday
676661
if self.n * sign >= 0:
677-
=======
678-
other = other + dir * self.next_bday
679-
if self.n * dir >= 0:
680-
>>>>>>> Edit comments and tests
681662
return datetime(other.year, other.month, other.day,
682663
earliest_start.hour, earliest_start.minute)
683664
else:
684665
return datetime(other.year, other.month, other.day,
685666
latest_start.hour, latest_start.minute)
686667
else:
687-
<<<<<<< HEAD
688668
if self.n * sign >= 0 and latest_start < other.time():
689669
# current time is after latest starting time in today
690670
other = other + sign * self.next_bday
@@ -696,19 +676,6 @@ def _next_opening_time(self, other, sign=1):
696676
return datetime(other.year, other.month, other.day,
697677
latest_start.hour, latest_start.minute)
698678
if self.n * sign >= 0:
699-
=======
700-
if self.n * dir >= 0 and latest_start < other.time():
701-
# current time is after latest starting time in today
702-
other = other + dir * self.next_bday
703-
return datetime(other.year, other.month, other.day,
704-
earliest_start.hour, earliest_start.minute)
705-
elif self.n * dir < 0 and other.time() < earliest_start:
706-
# current time is before earliest starting time in today
707-
other = other + dir * self.next_bday
708-
return datetime(other.year, other.month, other.day,
709-
latest_start.hour, latest_start.minute)
710-
if self.n * dir >= 0:
711-
>>>>>>> Edit comments and tests
712679
# find earliest starting time later than or equal to current time
713680
for st in self.start:
714681
if other.time() <= st:
@@ -725,12 +692,8 @@ def _prev_opening_time(self, other):
725692
"""
726693
If n is positive, return the latest opening time earlier than or equal
727694
to current time.
728-
<<<<<<< HEAD
729695
Otherwise the earliest opening time later than or equal to current
730696
time.
731-
=======
732-
Otherwise the earliest opening time later than or equal to current time.
733-
>>>>>>> Edit comments and tests
734697
735698
"""
736699
return self._next_opening_time(other, sign=-1)

0 commit comments

Comments
 (0)