コード例 #1
0
with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    min_dt = Timestamp(1900, 1, 1).to_pydatetime()
    max_dt = Timestamp(1900, 1, 1).to_pydatetime()

gen_date_range = st.builds(
    pd.date_range,
    start=st.datetimes(
        # TODO: Choose the min/max values more systematically
        min_value=Timestamp(1900, 1, 1).to_pydatetime(),
        max_value=Timestamp(2100, 1, 1).to_pydatetime(),
    ),
    periods=st.integers(min_value=2, max_value=100),
    freq=st.sampled_from("Y Q M D H T s ms us ns".split()),
    tz=st.one_of(st.none(), dateutil_timezones(), pytz_timezones()),
)

gen_random_datetime = st.datetimes(
    min_value=min_dt,
    max_value=max_dt,
    timezones=st.one_of(st.none(), dateutil_timezones(), pytz_timezones()),
)

# The strategy for each type is registered in conftest.py, as they don't carry
# enough runtime information (e.g. type hints) to infer how to build them.
gen_yqm_offset = st.one_of(
    *map(
        st.from_type,
        [
            MonthBegin,
コード例 #2
0
with warnings.catch_warnings():
    warnings.simplefilter('ignore')
    min_dt = pd.Timestamp(1900, 1, 1).to_pydatetime(),
    max_dt = pd.Timestamp(1900, 1, 1).to_pydatetime(),

gen_date_range = st.builds(
    pd.date_range,
    start=st.datetimes(
        # TODO: Choose the min/max values more systematically
        min_value=pd.Timestamp(1900, 1, 1).to_pydatetime(),
        max_value=pd.Timestamp(2100, 1, 1).to_pydatetime()
    ),
    periods=st.integers(min_value=2, max_value=100),
    freq=st.sampled_from('Y Q M D H T s ms us ns'.split()),
    tz=st.one_of(st.none(), dateutil_timezones(), pytz_timezones()),
)

gen_random_datetime = st.datetimes(
    min_value=min_dt,
    max_value=max_dt,
    timezones=st.one_of(st.none(), dateutil_timezones(), pytz_timezones())
)

# The strategy for each type is registered in conftest.py, as they don't carry
# enough runtime information (e.g. type hints) to infer how to build them.
gen_yqm_offset = st.one_of(*map(st.from_type, [
    MonthBegin, MonthEnd, BMonthBegin, BMonthEnd,
    QuarterBegin, QuarterEnd, BQuarterBegin, BQuarterEnd,
    YearBegin, YearEnd, BYearBegin, BYearEnd
]))