<commit_before>import os
import datetime as dt
import pandas as pd
import pytz
from pandas.testing import assert_index_equal

from pandas_market_calendars.exchange_calendar_nyse import NYSEExchangeCalendar


def test_custom_open_close():
    cal = NYSEExchangeCalendar(open_time=dt.time(9), close_time=dt.time(10))
    sched = cal.schedule("2021-08-16", "2021-08-16")
    assert sched.market_open.iat[0] == pd.Timestamp("2021-08-16 13:00:00+00:00")
    assert sched.market_close.iat[0] == pd.Timestamp("2021-08-16 14:00:00+00:00")

    assert not NYSEExchangeCalendar.regular_market_times is cal.regular_market_times



def test_days_at_time_open():
    cal = NYSEExchangeCalendar()

    # check if market_open before/after 1985 is correct
    valid = cal.valid_days("1984-12-30", "1985-01-03")
    at_open = cal.days_at_time(valid, "market_open")

    assert_index_equal(at_open, pd.DatetimeIndex(
        ['1984-12-31 10:00:00', '1985-01-02 09:30:00',
         '1985-01-03 09:30:00'], dtype='datetime64[ns]', freq=None
    ).tz_localize(cal.tz).tz_convert("UTC"))

    # check if it is rounded
    valid = cal.valid_days("1901-12-13", "1901-12-16")
    at_open = cal.days_at_time(valid, "market_open")

    assert_index_equal(at_open, pd.DatetimeIndex(
        ['1901-12-13 10:00:00', '1901-12-14 10:00:00',
         '1901-12-16 10:00:00'], dtype='datetime64[ns]', freq=None
    ).tz_localize(cal.tz).tz_convert("UTC"))

    # check if chosen time is kept
    cal = NYSEExchangeCalendar(open_time=dt.time(9))
    at_open = cal.days_at_time(valid, "market_open")

    assert_index_equal(at_open, pd.DatetimeIndex(
        ['1901-12-13 09:00:00', '1901-12-14 09:00:00',
         '1901-12-16 09:00:00'], dtype='datetime64[ns]', freq=None
    ).tz_localize(cal.tz).tz_convert("UTC"))


def test_days_at_time_close():
    cal = NYSEExchangeCalendar()

    # test market_close before/after 1952-09-29
    valid = cal.valid_days("1952-09-26", "1952-09-30")
    at_close = cal.days_at_time(valid, "market_close")

    assert_index_equal(at_close, pd.DatetimeIndex(
        ['1952-09-26 15:00:00', '1952-09-29 15:30:00',
         '1952-09-30 15:30:00'], dtype='datetime64[ns]', freq=None
    ).tz_localize(cal.tz).tz_convert("UTC"))
<commit_msg> added pytest.mark.xfail to a couple of tests that rely on old behaviour of days_at_time<commit_after>import os
import datetime as dt
import pandas as pd
import pytest
import pytz
from pandas.testing import assert_index_equal

from pandas_market_calendars.exchange_calendar_nyse import NYSEExchangeCalendar


def test_custom_open_close():
    cal = NYSEExchangeCalendar(open_time=dt.time(9), close_time=dt.time(10))
    sched = cal.schedule("2021-08-16", "2021-08-16")
    assert sched.market_open.iat[0] == pd.Timestamp("2021-08-16 13:00:00+00:00")
    assert sched.market_close.iat[0] == pd.Timestamp("2021-08-16 14:00:00+00:00")

    assert not NYSEExchangeCalendar.regular_market_times is cal.regular_market_times


@pytest.mark.xfail
def test_days_at_time_open():
    cal = NYSEExchangeCalendar()

    # check if market_open before/after 1985 is correct
    valid = cal.valid_days("1984-12-30", "1985-01-03")
    at_open = cal.days_at_time(valid, "market_open")

    assert_index_equal(at_open, pd.DatetimeIndex(
        ['1984-12-31 10:00:00', '1985-01-02 09:30:00',
         '1985-01-03 09:30:00'], dtype='datetime64[ns]', freq=None
    ).tz_localize(cal.tz).tz_convert("UTC"))

    # check if it is rounded
    valid = cal.valid_days("1901-12-13", "1901-12-16")
    at_open = cal.days_at_time(valid, "market_open")

    assert_index_equal(at_open, pd.DatetimeIndex(
        ['1901-12-13 10:00:00', '1901-12-14 10:00:00',
         '1901-12-16 10:00:00'], dtype='datetime64[ns]', freq=None
    ).tz_localize(cal.tz).tz_convert("UTC"))

    # check if chosen time is kept
    cal = NYSEExchangeCalendar(open_time=dt.time(9))
    at_open = cal.days_at_time(valid, "market_open")

    assert_index_equal(at_open, pd.DatetimeIndex(
        ['1901-12-13 09:00:00', '1901-12-14 09:00:00',
         '1901-12-16 09:00:00'], dtype='datetime64[ns]', freq=None
    ).tz_localize(cal.tz).tz_convert("UTC"))

@pytest.mark.xfail
def test_days_at_time_close():
    cal = NYSEExchangeCalendar()

    # test market_close before/after 1952-09-29
    valid = cal.valid_days("1952-09-26", "1952-09-30")
    at_close = cal.days_at_time(valid, "market_close")

    assert_index_equal(at_close, pd.DatetimeIndex(
        ['1952-09-26 15:00:00', '1952-09-29 15:30:00',
         '1952-09-30 15:30:00'], dtype='datetime64[ns]', freq=None
    ).tz_localize(cal.tz).tz_convert("UTC"))

{'fraction_non_alphanumeric': 0.1508367746142143, 'fraction_numerical': 0.127798304716366, 'mean_word_length': 4.164983164983165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2823480', 'n_tokens_mistral': 2104, 'n_tokens_neox': 1717, 'n_words': 294}