class documentation

class TestDateTime:

View In Hierarchy

Undocumented

Method test​_assert​_equal Undocumented
Method test​_cast​_overflow Undocumented
Method test​_compare​_generic​_nat Undocumented
Method test​_corecursive​_input Undocumented
Method test​_creation​_overflow Undocumented
Method test​_datetime​_add Undocumented
Method test​_datetime​_arange Undocumented
Method test​_datetime​_arange​_no​_dtype Undocumented
Method test​_datetime​_array​_find​_type Undocumented
Method test​_datetime​_array​_str Undocumented
Method test​_datetime​_as​_string Undocumented
Method test​_datetime​_as​_string​_timezone Undocumented
Method test​_datetime​_busday​_holidays​_count Undocumented
Method test​_datetime​_busday​_holidays​_offset Undocumented
Method test​_datetime​_busday​_offset Undocumented
Method test​_datetime​_busdaycalendar Undocumented
Method test​_datetime​_casting​_rules Undocumented
Method test​_datetime​_compare Undocumented
Method test​_datetime​_compare​_nat Undocumented
Method test​_datetime​_conversions​_byteorders Undocumented
Method test​_datetime​_divide Undocumented
Method test​_datetime​_dtype​_creation Undocumented
Method test​_datetime​_is​_busday Undocumented
Method test​_datetime​_like Undocumented
Method test​_datetime​_maximum​_reduce Undocumented
Method test​_datetime​_minmax Undocumented
Method test​_datetime​_multiply Undocumented
Method test​_datetime​_nat​_argsort​_stability Undocumented
Method test​_datetime​_nat​_casting Undocumented
Method test​_datetime​_no​_subtract​_reducelike Undocumented
Method test​_datetime​_prefix​_conversions Undocumented
Method test​_datetime​_scalar​_construction Undocumented
Method test​_datetime​_scalar​_construction​_timezone Undocumented
Method test​_datetime​_string​_conversion Undocumented
Method test​_datetime​_subtract Undocumented
Method test​_datetime​_timedelta​_sort​_nat Undocumented
Method test​_datetime​_unary Undocumented
Method test​_datetime​_y2038 Undocumented
Method test​_days​_creation Undocumented
Method test​_days​_to​_pydate Undocumented
Method test​_different​_unit​_comparison Undocumented
Method test​_discovery​_from​_object​_array Undocumented
Method test​_divisor​_conversion​_as Undocumented
Method test​_divisor​_conversion​_day Undocumented
Method test​_divisor​_conversion​_fs Undocumented
Method test​_divisor​_conversion​_hour Undocumented
Method test​_divisor​_conversion​_minute Undocumented
Method test​_divisor​_conversion​_month Undocumented
Method test​_divisor​_conversion​_second Undocumented
Method test​_divisor​_conversion​_week Undocumented
Method test​_divisor​_conversion​_year Undocumented
Method test​_dtype​_comparison Undocumented
Method test​_dtype​_promotion Undocumented
Method test​_hours Undocumented
Method test​_isfinite​_isinf​_isnan​_units check isfinite, isinf, isnan for all units of <M, >M, <m, >m dtypes
Method test​_isfinite​_scalar Undocumented
Method test​_isnat Undocumented
Method test​_isnat​_error Undocumented
Method test​_limit​_str​_roundtrip Limits should roundtrip when converted to strings.
Method test​_limit​_symmetry Dates should have symmetric limits around the unix epoch at +/-np.int64
Method test​_month​_truncation Undocumented
Method test​_pickle Undocumented
Method test​_prohibit​_negative​_datetime Undocumented
Method test​_pydatetime​_creation Undocumented
Method test​_pyobject​_roundtrip Undocumented
Method test​_setstate Verify that datetime dtype __setstate__ can handle bad arguments
Method test​_string​_parser​_error​_check Undocumented
Method test​_string​_parser​_variants Undocumented
Method test​_time​_byteswapped​_cast Undocumented
Method test​_time​_byteswapping Undocumented
Method test​_timedelta​_0​_dim​_object​_array​_conversion Undocumented
Method test​_timedelta​_arange Undocumented
Method test​_timedelta​_arange​_no​_dtype Undocumented
Method test​_timedelta​_array​_str Undocumented
Method test​_timedelta​_correct​_mean Undocumented
Method test​_timedelta​_divmod Undocumented
Method test​_timedelta​_divmod​_warnings Undocumented
Method test​_timedelta​_floor​_div​_error Undocumented
Method test​_timedelta​_floor​_div​_precision Undocumented
Method test​_timedelta​_floor​_div​_warnings Undocumented
Method test​_timedelta​_floor​_divide Undocumented
Method test​_timedelta​_modulus Undocumented
Method test​_timedelta​_modulus​_div​_by​_zero Undocumented
Method test​_timedelta​_modulus​_error Undocumented
Method test​_timedelta​_modulus​_type​_resolution Undocumented
Method test​_timedelta​_nat​_argsort​_stability Undocumented
Method test​_timedelta​_nat​_format Undocumented
Method test​_timedelta​_np​_int​_construction Undocumented
Method test​_timedelta​_object​_array​_conversion Undocumented
Method test​_timedelta​_scalar​_construction Undocumented
Method test​_timedelta​_scalar​_construction​_units Undocumented
def test_assert_equal(self):

Undocumented

def test_cast_overflow(self):

Undocumented

def test_compare_generic_nat(self):

Undocumented

def test_corecursive_input(self):

Undocumented

def test_creation_overflow(self):

Undocumented

def test_datetime_add(self):

Undocumented

def test_datetime_arange(self):

Undocumented

def test_datetime_arange_no_dtype(self):

Undocumented

def test_datetime_array_find_type(self):

Undocumented

def test_datetime_array_str(self):

Undocumented

def test_datetime_as_string(self):

Undocumented

@pytest.mark.skipif(not _has_pytz, reason='The pytz module is not available.')
def test_datetime_as_string_timezone(self):

Undocumented

def test_datetime_busday_holidays_count(self):

Undocumented

def test_datetime_busday_holidays_offset(self):

Undocumented

def test_datetime_busday_offset(self):

Undocumented

def test_datetime_busdaycalendar(self):

Undocumented

def test_datetime_casting_rules(self):

Undocumented

def test_datetime_compare(self):

Undocumented

def test_datetime_compare_nat(self):

Undocumented

@pytest.mark.parametrize('time_dtype', ['m8[D]', 'M8[Y]'])
@pytest.mark.parametrize('str_dtype', ['U', 'S'])
def test_datetime_conversions_byteorders(self, str_dtype, time_dtype):

Undocumented

def test_datetime_divide(self):

Undocumented

def test_datetime_dtype_creation(self):

Undocumented

def test_datetime_is_busday(self):

Undocumented

def test_datetime_like(self):

Undocumented

def test_datetime_maximum_reduce(self):

Undocumented

def test_datetime_minmax(self):

Undocumented

def test_datetime_multiply(self):

Undocumented

@pytest.mark.parametrize('size', [3, 21, 217, 1000])
def test_datetime_nat_argsort_stability(self, size):

Undocumented

def test_datetime_nat_casting(self):

Undocumented

def test_datetime_no_subtract_reducelike(self):

Undocumented

def test_datetime_prefix_conversions(self):

Undocumented

def test_datetime_scalar_construction(self):

Undocumented

def test_datetime_scalar_construction_timezone(self):

Undocumented

def test_datetime_string_conversion(self):

Undocumented

def test_datetime_subtract(self):

Undocumented

@pytest.mark.parametrize('arr, expected', [(['NaT', 1, 2, 3], [1, 2, 3, 'NaT']), (['NaT', 9, 'NaT', -707], [-707, 9, 'NaT', 'NaT']), ([1, -2, 3, 'NaT'], [-2, 1, 3, 'NaT']), ([[51, -220, 'NaT'], [-17, 'NaT', -90]], [[-220, 51, 'NaT'], [-90, -17, 'NaT']])])
@pytest.mark.parametrize('dtype', ['M8[ns]', 'M8[us]', 'm8[ns]', 'm8[us]'])
def test_datetime_timedelta_sort_nat(self, arr, expected, dtype):

Undocumented

def test_datetime_unary(self):

Undocumented

def test_datetime_y2038(self):

Undocumented

def test_days_creation(self):

Undocumented

def test_days_to_pydate(self):

Undocumented

def test_different_unit_comparison(self):

Undocumented

@pytest.mark.parametrize('shape', [(), (1)])
def test_discovery_from_object_array(self, shape):

Undocumented

def test_divisor_conversion_as(self):

Undocumented

def test_divisor_conversion_day(self):

Undocumented

def test_divisor_conversion_fs(self):

Undocumented

def test_divisor_conversion_hour(self):

Undocumented

def test_divisor_conversion_minute(self):

Undocumented

def test_divisor_conversion_month(self):

Undocumented

def test_divisor_conversion_second(self):

Undocumented

def test_divisor_conversion_week(self):

Undocumented

def test_divisor_conversion_year(self):

Undocumented

def test_dtype_comparison(self):

Undocumented

def test_dtype_promotion(self):

Undocumented

def test_hours(self):

Undocumented

@pytest.mark.parametrize('unit', ['Y', 'M', 'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns', 'ps', 'fs', 'as'])
@pytest.mark.parametrize('dstr', ['<datetime64[%s]', '>datetime64[%s]', '<timedelta64[%s]', '>timedelta64[%s]'])
def test_isfinite_isinf_isnan_units(self, unit, dstr):
check isfinite, isinf, isnan for all units of <M, >M, <m, >m dtypes
def test_isfinite_scalar(self):

Undocumented

def test_isnat(self):

Undocumented

def test_isnat_error(self):

Undocumented

@pytest.mark.parametrize('time_unit', ['Y', 'M', pytest.param('W', marks=pytest.mark.xfail(reason='gh-13197')), 'D', 'h', 'm', 's', 'ms', 'us', 'ns', 'ps', 'fs', 'as', pytest.param('10D', marks=pytest.mark.xfail(reason='similar to gh-13197'))])
@pytest.mark.parametrize('sign', [-1, 1])
def test_limit_str_roundtrip(self, time_unit, sign):

Limits should roundtrip when converted to strings.

This tests the conversion to and from npy_datetimestruct.

@pytest.mark.parametrize('time_unit', ['Y', 'M', 'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns', 'ps', 'fs', 'as', '10D', '2M'])
def test_limit_symmetry(self, time_unit):
Dates should have symmetric limits around the unix epoch at +/-np.int64
def test_month_truncation(self):

Undocumented

def test_pickle(self):

Undocumented

@pytest.mark.parametrize('unit', ['s', 'ms', 'us', 'ns', 'ps', 'fs', 'as'])
def test_prohibit_negative_datetime(self, unit):

Undocumented

def test_pydatetime_creation(self):

Undocumented

def test_pyobject_roundtrip(self):

Undocumented

def test_setstate(self):
Verify that datetime dtype __setstate__ can handle bad arguments
def test_string_parser_error_check(self):

Undocumented

def test_string_parser_variants(self):

Undocumented

@pytest.mark.parametrize(['time1', 'time2'], [('M8[s]', 'M8[D]'), ('m8[s]', 'm8[ns]')])
def test_time_byteswapped_cast(self, time1, time2):

Undocumented

@pytest.mark.parametrize('time_dtype', ['m8[D]', 'M8[Y]'])
def test_time_byteswapping(self, time_dtype):

Undocumented

def test_timedelta_0_dim_object_array_conversion(self):

Undocumented

def test_timedelta_arange(self):

Undocumented

def test_timedelta_arange_no_dtype(self):

Undocumented

def test_timedelta_array_str(self):

Undocumented

def test_timedelta_correct_mean(self):

Undocumented

@pytest.mark.parametrize('op1, op2', [(np.timedelta64(7, 's'), np.timedelta64(4, 's')), (np.timedelta64(7, 's'), np.timedelta64(-4, 's')), (np.timedelta64(8, 's'), np.timedelta64(-4, 's')), (np.timedelta64(1, 'm'), np.timedelta64(31, 's')), (np.timedelta64(1890), np.timedelta64(31)), (np.timedelta64(2, 'Y'), np.timedelta64('13', 'M')), (np.array([1, 2, 3], dtype='m8'), np.array([2], dtype='m8'))])
def test_timedelta_divmod(self, op1, op2):

Undocumented

@pytest.mark.parametrize('op1, op2', [(np.timedelta64(10, 'us'), np.timedelta64(0, 'us')), (np.timedelta64('NaT'), np.timedelta64(50, 'us')), (np.timedelta64(np.iinfo(np.int64).min), np.timedelta64(-1))])
def test_timedelta_divmod_warnings(self, op1, op2):

Undocumented

@pytest.mark.parametrize('val1, val2', [(np.timedelta64(7, 'Y'), np.timedelta64(3, 's')), (np.timedelta64(7, 'M'), np.timedelta64(1, 'D'))])
def test_timedelta_floor_div_error(self, val1, val2):

Undocumented

@pytest.mark.parametrize('val1, val2', [(9007199254740993, 1), (9007199254740999, -2)])
def test_timedelta_floor_div_precision(self, val1, val2):

Undocumented

@pytest.mark.parametrize('op1, op2', [(np.timedelta64(10, 'us'), np.timedelta64(0, 'us')), (np.timedelta64('NaT'), np.timedelta64(50, 'us')), (np.timedelta64(np.iinfo(np.int64).min), np.timedelta64(-1))])
def test_timedelta_floor_div_warnings(self, op1, op2):

Undocumented

@pytest.mark.parametrize('op1, op2, exp', [(np.timedelta64(7, 's'), np.timedelta64(4, 's'), 1), (np.timedelta64(7, 's'), np.timedelta64(-4, 's'), -2), (np.timedelta64(8, 's'), np.timedelta64(-4, 's'), -2), (np.timedelta64(1, 'm'), np.timedelta64(31, 's'), 1), (np.timedelta64(1890), np.timedelta64(31), 60), (np.timedelta64(2, 'Y'), np.timedelta64('13', 'M'), 1), (np.array([1, 2, 3], dtype='m8'), np.array([2], dtype='m8'), np.array([0, 1, 1], dtype=np.int64))])
def test_timedelta_floor_divide(self, op1, op2, exp):

Undocumented

@pytest.mark.parametrize('val1, val2, expected', [(np.timedelta64(7, 's'), np.timedelta64(3, 's'), np.timedelta64(1, 's')), (np.timedelta64(3, 's'), np.timedelta64(-2, 's'), np.timedelta64(-1, 's')), (np.timedelta64(-3, 's'), np.timedelta64(2, 's'), np.timedelta64(1, 's')), (np.timedelta64(17, 's'), np.timedelta64(22, 's'), np.timedelta64(17, 's')), (np.timedelta64(22, 's'), np.timedelta64(17, 's'), np.timedelta64(5, 's')), (np.timedelta64(1, 'm'), np.timedelta64(57, 's'), np.timedelta64(3, 's')), (np.timedelta64(1, 'us'), np.timedelta64(727, 'ns'), np.timedelta64(273, 'ns')), (np.timedelta64('NaT'), np.timedelta64(50, 'ns'), np.timedelta64('NaT')), (np.timedelta64(2, 'Y'), np.timedelta64(22, 'M'), np.timedelta64(2, 'M'))])
def test_timedelta_modulus(self, val1, val2, expected):

Undocumented

def test_timedelta_modulus_div_by_zero(self):

Undocumented

@pytest.mark.parametrize('val1, val2', [(np.timedelta64(7, 'Y'), np.timedelta64(3, 's')), (np.timedelta64(7, 'M'), np.timedelta64(1, 'D'))])
def test_timedelta_modulus_error(self, val1, val2):

Undocumented

@pytest.mark.parametrize('val1, val2', [(np.timedelta64(7, 'Y'), 15), (7.5, np.timedelta64(1, 'D'))])
def test_timedelta_modulus_type_resolution(self, val1, val2):

Undocumented

@pytest.mark.parametrize('size', [3, 21, 217, 1000])
def test_timedelta_nat_argsort_stability(self, size):

Undocumented

def test_timedelta_nat_format(self):

Undocumented

@pytest.mark.parametrize('unit', ['Y', 'M', 'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns', 'ps', 'fs', 'as', 'generic'])
def test_timedelta_np_int_construction(self, unit):

Undocumented

def test_timedelta_object_array_conversion(self):

Undocumented

def test_timedelta_scalar_construction(self):

Undocumented

def test_timedelta_scalar_construction_units(self):

Undocumented