exchange_calendars icon indicating copy to clipboard operation
exchange_calendars copied to clipboard

FutureWarning for XKRX

Open maread99 opened this issue 1 year ago • 1 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.

maread99 avatar Apr 08 '23 23:04 maread99

This issue is also mentioned in #128.

maread99 avatar Apr 09 '23 08:04 maread99