peacock-data-public-datasets-idc-cronscript
/
venv
/lib
/python3.10
/site-packages
/pandas
/tests
/arithmetic
/conftest.py
import numpy as np | |
import pytest | |
import pandas as pd | |
from pandas import Index | |
def one(request): | |
""" | |
Several variants of integer value 1. The zero-dim integer array | |
behaves like an integer. | |
This fixture can be used to check that datetimelike indexes handle | |
addition and subtraction of integers and zero-dimensional arrays | |
of integers. | |
Examples | |
-------- | |
dti = pd.date_range('2016-01-01', periods=2, freq='h') | |
dti | |
DatetimeIndex(['2016-01-01 00:00:00', '2016-01-01 01:00:00'], | |
dtype='datetime64[ns]', freq='h') | |
dti + one | |
DatetimeIndex(['2016-01-01 01:00:00', '2016-01-01 02:00:00'], | |
dtype='datetime64[ns]', freq='h') | |
""" | |
return request.param | |
zeros = [ | |
box_cls([0] * 5, dtype=dtype) | |
for box_cls in [Index, np.array, pd.array] | |
for dtype in [np.int64, np.uint64, np.float64] | |
] | |
zeros.extend([box_cls([-0.0] * 5, dtype=np.float64) for box_cls in [Index, np.array]]) | |
zeros.extend([np.array(0, dtype=dtype) for dtype in [np.int64, np.uint64, np.float64]]) | |
zeros.extend([np.array(-0.0, dtype=np.float64)]) | |
zeros.extend([0, 0.0, -0.0]) | |
def zero(request): | |
""" | |
Several types of scalar zeros and length 5 vectors of zeros. | |
This fixture can be used to check that numeric-dtype indexes handle | |
division by any zero numeric-dtype. | |
Uses vector of length 5 for broadcasting with `numeric_idx` fixture, | |
which creates numeric-dtype vectors also of length 5. | |
Examples | |
-------- | |
arr = RangeIndex(5) | |
arr / zeros | |
Index([nan, inf, inf, inf, inf], dtype='float64') | |
""" | |
return request.param | |
# ------------------------------------------------------------------ | |
# Scalar Fixtures | |
def scalar_td(request): | |
""" | |
Several variants of Timedelta scalars representing 10 minutes and 7 seconds. | |
""" | |
return request.param | |
def three_days(request): | |
""" | |
Several timedelta-like and DateOffset objects that each represent | |
a 3-day timedelta | |
""" | |
return request.param | |
def two_hours(request): | |
""" | |
Several timedelta-like and DateOffset objects that each represent | |
a 2-hour timedelta | |
""" | |
return request.param | |
_common_mismatch = [ | |
pd.offsets.YearBegin(2), | |
pd.offsets.MonthBegin(1), | |
pd.offsets.Minute(), | |
] | |
def not_daily(request): | |
""" | |
Several timedelta-like and DateOffset instances that are _not_ | |
compatible with Daily frequencies. | |
""" | |
return request.param | |