gerrymanoim / exchange_calendars

Calendars for various securities exchanges.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FutureWarning for XKRX

maread99 opened this issue · comments

The test TestXKRXCalendar.test_feb_29_2022_in_lunar_calendar results in 6 instances of the following deprecation warning:

...\exchange_calendars\exchange_calendars\pandas_extensions\korean_holiday.py:76: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
    dt = pd.Timestamp(dt)

It seems to be due to a DatetimeIndex being passed to the dt parameter of the alternative_holiday function which is being called for the IndependenceMovementDay holiday, although it's not clear to me why it's receiving a DatetimeIndex.

It could be silenced with no change in behaviour, and the eventual bug when it is deprecated could be avoided, by changing this line from:

if dt >= since:

to:

if isinstance(dt, pd.Timestamp) and dt >= since:

Although this change would cause no change in behavior (as is, with a DatetimeIndex it evaluates to False as it's ambiguous), I haven't changed it because it would just hide the real issue which is that alternative_holiday is getting a DatetimeIndex when it seems to be expecting a Timestamp.

This issue is also mentioned in #128.