1
0
Fork 0
Old engine for Continuous Time Bayesian Networks. Superseded by reCTBN. 🐍 https://github.com/madlabunimib/PyCTBN
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
PyCTBN/venv/lib/python3.9/site-packages/pandas/tests/tslibs/test_fields.py

29 lines
1.1 KiB

import numpy as np
from pandas._libs.tslibs import fields
import pandas._testing as tm
def test_fields_readonly():
# https://github.com/vaexio/vaex/issues/357
# fields functions should't raise when we pass read-only data
dtindex = np.arange(5, dtype=np.int64) * 10 ** 9 * 3600 * 24 * 32
dtindex.flags.writeable = False
result = fields.get_date_name_field(dtindex, "month_name")
expected = np.array(["January", "February", "March", "April", "May"], dtype=object)
tm.assert_numpy_array_equal(result, expected)
result = fields.get_date_field(dtindex, "Y")
expected = np.array([1970, 1970, 1970, 1970, 1970], dtype=np.int32)
tm.assert_numpy_array_equal(result, expected)
result = fields.get_start_end_field(dtindex, "is_month_start", None)
expected = np.array([True, False, False, False, False], dtype=np.bool_)
tm.assert_numpy_array_equal(result, expected)
# treat dtindex as timedeltas for this next one
result = fields.get_timedelta_field(dtindex, "days")
expected = np.arange(5, dtype=np.int32) * 32
tm.assert_numpy_array_equal(result, expected)