@@ -1391,8 +1391,7 @@ ctypedef int (*accessor)(int64_t ordinal, int freq) except -1
1391
1391
def get_period_field (int code , int64_t value , int freq ,
1392
1392
int64_t mult ):
1393
1393
cdef accessor f = _get_accessor_func(code)
1394
- value = remove_mult(value, mult)
1395
- return f(value, freq)
1394
+ return f(remove_mult(value, mult), freq)
1396
1395
1397
1396
def get_period_field_arr (int code , ndarray[int64_t] arr ,
1398
1397
int freq , int64_t mult ):
@@ -1412,31 +1411,6 @@ def get_period_field_arr(int code, ndarray[int64_t] arr,
1412
1411
return out
1413
1412
1414
1413
1415
- cdef int apply_accessor(accessor func, int64_t value, int freq,
1416
- int64_t mult) except - 1 :
1417
- value = remove_mult(value, mult)
1418
- return func(value, freq)
1419
-
1420
- # same but for arrays
1421
-
1422
- cdef ndarray[int64_t] apply_accessor_arr(accessor func, ndarray[int64_t] arr,
1423
- int freq, int64_t mult):
1424
- cdef:
1425
- Py_ssize_t i, sz
1426
- ndarray[int64_t] out
1427
- # accessor f
1428
-
1429
- # f = _get_accessor_func(code)
1430
-
1431
- sz = len (arr)
1432
- out = np.empty(sz, dtype = np.int64)
1433
-
1434
- for i in range (sz):
1435
- out[i] = remove_mult(arr[i], mult)
1436
- out[i] = func(out[i], freq)
1437
-
1438
- return out
1439
-
1440
1414
1441
1415
cdef accessor _get_accessor_func(int code):
1442
1416
if code == 0 :
@@ -1464,79 +1438,3 @@ cdef accessor _get_accessor_func(int code):
1464
1438
else :
1465
1439
raise ValueError (' Unrecognized code: %s ' % code)
1466
1440
1467
-
1468
- # def get_period_year_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1469
- # return apply_accessor_arr(pyear, arr, freq, mult)
1470
-
1471
- # def get_period_qyear_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1472
- # return apply_accessor_arr(pqyear, arr, freq, mult)
1473
-
1474
- # def get_period_quarter_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1475
- # return apply_accessor_arr(pquarter, arr, freq, mult)
1476
-
1477
- # def get_period_month_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1478
- # return apply_accessor_arr(pmonth, arr, freq, mult)
1479
-
1480
- # def get_period_day_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1481
- # return apply_accessor_arr(pday, arr, freq, mult)
1482
-
1483
- # def get_period_hour_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1484
- # return apply_accessor_arr(phour, arr, freq, mult)
1485
-
1486
- # def get_period_minute_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1487
- # return apply_accessor_arr(pminute, arr, freq, mult)
1488
-
1489
- # def get_period_second_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1490
- # return apply_accessor_arr(psecond, arr, freq, mult)
1491
-
1492
- # def get_period_dow_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1493
- # return apply_accessor_arr(pday_of_week, arr, freq, mult)
1494
-
1495
- # def get_period_week_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1496
- # return apply_accessor_arr(pweek, arr, freq, mult)
1497
-
1498
- # def get_period_weekday_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1499
- # return apply_accessor_arr(pweekday, arr, freq, mult)
1500
-
1501
- # def get_period_doy_arr(ndarray[int64_t] arr, int freq, int64_t mult):
1502
- # return apply_accessor_arr(pday_of_year, arr, freq, mult)
1503
-
1504
- # def get_abs_time(freq, dailyDate, originalDate):
1505
- # return getAbsTime(freq, dailyDate, originalDate)
1506
-
1507
-
1508
- # cpdef int get_period_year(int64_t value, int freq, int64_t mult) except -1:
1509
- # return apply_accessor(pyear, value, freq, mult)
1510
-
1511
- # cpdef int get_period_qyear(int64_t value, int freq, int64_t mult) except -1:
1512
- # return apply_accessor(pqyear, value, freq, mult)
1513
-
1514
- # cpdef int get_period_quarter(int64_t value, int freq, int64_t mult) except -1:
1515
- # return apply_accessor(pquarter, value, freq, mult)
1516
-
1517
- # cpdef int get_period_month(int64_t value, int freq, int64_t mult) except -1:
1518
- # return apply_accessor(pmonth, value, freq, mult)
1519
-
1520
- # cpdef int get_period_day(int64_t value, int freq, int64_t mult) except -1:
1521
- # return apply_accessor(pday, value, freq, mult)
1522
-
1523
- # cpdef int get_period_hour(int64_t value, int freq, int64_t mult) except -1:
1524
- # return apply_accessor(phour, value, freq, mult)
1525
-
1526
- # cpdef int get_period_minute(int64_t value, int freq, int64_t mult) except -1:
1527
- # return apply_accessor(pminute, value, freq, mult)
1528
-
1529
- # cpdef int get_period_second(int64_t value, int freq, int64_t mult) except -1:
1530
- # return apply_accessor(psecond, value, freq, mult)
1531
-
1532
- # cpdef int get_period_dow(int64_t value, int freq, int64_t mult) except -1:
1533
- # return apply_accessor(pday_of_week, value, freq, mult)
1534
-
1535
- # cpdef int get_period_week(int64_t value, int freq, int64_t mult) except -1:
1536
- # return apply_accessor(pweek, value, freq, mult)
1537
-
1538
- # cpdef int get_period_weekday(int64_t value, int freq, int64_t mult) except -1:
1539
- # return apply_accessor(pweekday, value, freq, mult)
1540
-
1541
- # cpdef int get_period_doy(int64_t value, int freq, int64_t mult) except -1:
1542
- # return apply_accessor(pday_of_year, value, freq, mult)
0 commit comments