@@ -138,6 +138,10 @@ cpdef get_freq_code(freqstr):
138
138
-------
139
139
return : tuple of base frequency code and stride (mult)
140
140
141
+ Raises
142
+ ------
143
+ TypeError : if passed a tuple witth incorrect types
144
+
141
145
Examples
142
146
--------
143
147
>>> get_freq_code('3D')
@@ -156,16 +160,16 @@ cpdef get_freq_code(freqstr):
156
160
if is_integer_object(freqstr[0 ]) and is_integer_object(freqstr[1 ]):
157
161
# e.g., freqstr = (2000, 1)
158
162
return freqstr
163
+ elif is_integer_object(freqstr[0 ]):
164
+ # Note: passing freqstr[1] below will raise TypeError if that
165
+ # is not a str
166
+ code = _period_str_to_code(freqstr[1 ])
167
+ stride = freqstr[0 ]
168
+ return code, stride
159
169
else :
160
170
# e.g., freqstr = ('T', 5)
161
- try :
162
- code = _period_str_to_code(freqstr[0 ])
163
- stride = freqstr[1 ]
164
- except :
165
- if is_integer_object(freqstr[1 ]):
166
- raise
167
- code = _period_str_to_code(freqstr[1 ])
168
- stride = freqstr[0 ]
171
+ code = _period_str_to_code(freqstr[0 ])
172
+ stride = freqstr[1 ]
169
173
return code, stride
170
174
171
175
if is_integer_object(freqstr):
@@ -177,7 +181,7 @@ cpdef get_freq_code(freqstr):
177
181
return code, stride
178
182
179
183
180
- cpdef _base_and_stride(freqstr):
184
+ cpdef _base_and_stride(str freqstr):
181
185
"""
182
186
Return base freq and stride info from string representation
183
187
@@ -207,7 +211,7 @@ cpdef _base_and_stride(freqstr):
207
211
return base, stride
208
212
209
213
210
- cpdef _period_str_to_code(freqstr):
214
+ cpdef _period_str_to_code(str freqstr):
211
215
freqstr = _lite_rule_alias.get(freqstr, freqstr)
212
216
213
217
if freqstr not in _dont_uppercase:
0 commit comments