Python pandas.tseries.offsets.Nano() Examples

The following are 30 code examples of pandas.tseries.offsets.Nano(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pandas.tseries.offsets , or try the search function .
Example #1
Source File: test_libfrequencies.py    From vnpy_crypto with MIT License 7 votes vote down vote up
def test_is_superperiod_subperiod():

    # input validation
    assert not (is_superperiod(offsets.YearEnd(), None))
    assert not (is_subperiod(offsets.MonthEnd(), None))
    assert not (is_superperiod(None, offsets.YearEnd()))
    assert not (is_subperiod(None, offsets.MonthEnd()))
    assert not (is_superperiod(None, None))
    assert not (is_subperiod(None, None))

    assert (is_superperiod(offsets.YearEnd(), offsets.MonthEnd()))
    assert (is_subperiod(offsets.MonthEnd(), offsets.YearEnd()))

    assert (is_superperiod(offsets.Hour(), offsets.Minute()))
    assert (is_subperiod(offsets.Minute(), offsets.Hour()))

    assert (is_superperiod(offsets.Second(), offsets.Milli()))
    assert (is_subperiod(offsets.Milli(), offsets.Second()))

    assert (is_superperiod(offsets.Milli(), offsets.Micro()))
    assert (is_subperiod(offsets.Micro(), offsets.Milli()))

    assert (is_superperiod(offsets.Micro(), offsets.Nano()))
    assert (is_subperiod(offsets.Nano(), offsets.Micro())) 
Example #2
Source File: resample.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def _adjust_bin_edges(self, binner, ax_values):
        # Some hacks for > daily data, see #1471, #1458, #1483

        if self.freq != 'D' and is_superperiod(self.freq, 'D'):
            if self.closed == 'right':
                # GH 21459, GH 9119: Adjust the bins relative to the wall time
                bin_edges = binner.tz_localize(None)
                bin_edges = bin_edges + timedelta(1) - Nano(1)
                bin_edges = bin_edges.tz_localize(binner.tz).asi8
            else:
                bin_edges = binner.asi8

            # intraday values on last day
            if bin_edges[-2] > ax_values.max():
                bin_edges = bin_edges[:-1]
                binner = binner[:-1]
        else:
            bin_edges = binner.asi8
        return binner, bin_edges 
Example #3
Source File: test_ticks.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_Nanosecond():
    timestamp = Timestamp(datetime(2010, 1, 1))
    assert_offset_equal(Nano(),
                        timestamp,
                        timestamp + np.timedelta64(1, 'ns'))
    assert_offset_equal(Nano(-1),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)
    assert_offset_equal(2 * Nano(),
                        timestamp,
                        timestamp + np.timedelta64(2, 'ns'))
    assert_offset_equal(-1 * Nano(),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)

    assert Nano(3) + Nano(2) == Nano(5)
    assert Nano(3) - Nano(2) == Nano()

    # GH9284
    assert Nano(1) + Nano(10) == Nano(11)
    assert Nano(5) + Micro(1) == Nano(1005)
    assert Micro(5) + Nano(1) == Nano(5001) 
Example #4
Source File: test_ticks.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_tick_division(cls):
    off = cls(10)

    assert off / cls(5) == 2
    assert off / 2 == cls(5)
    assert off / 2.0 == cls(5)

    assert off / off.delta == 1
    assert off / off.delta.to_timedelta64() == 1

    assert off / Nano(1) == off.delta / Nano(1).delta

    if cls is not Nano:
        # A case where we end up with a smaller class
        result = off / 1000
        assert isinstance(result, offsets.Tick)
        assert not isinstance(result, cls)
        assert result.delta == off.delta / 1000

    if cls._inc < Timedelta(seconds=1):
        # Case where we end up with a bigger class
        result = off / .001
        assert isinstance(result, offsets.Tick)
        assert not isinstance(result, cls)
        assert result.delta == off.delta / .001 
Example #5
Source File: test_ticks.py    From coffeegrindsize with MIT License 6 votes vote down vote up
def test_Nanosecond():
    timestamp = Timestamp(datetime(2010, 1, 1))
    assert_offset_equal(Nano(),
                        timestamp,
                        timestamp + np.timedelta64(1, 'ns'))
    assert_offset_equal(Nano(-1),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)
    assert_offset_equal(2 * Nano(),
                        timestamp,
                        timestamp + np.timedelta64(2, 'ns'))
    assert_offset_equal(-1 * Nano(),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)

    assert Nano(3) + Nano(2) == Nano(5)
    assert Nano(3) - Nano(2) == Nano()

    # GH9284
    assert Nano(1) + Nano(10) == Nano(11)
    assert Nano(5) + Micro(1) == Nano(1005)
    assert Micro(5) + Nano(1) == Nano(5001) 
Example #6
Source File: test_ticks.py    From coffeegrindsize with MIT License 6 votes vote down vote up
def test_tick_division(cls):
    off = cls(10)

    assert off / cls(5) == 2
    assert off / 2 == cls(5)
    assert off / 2.0 == cls(5)

    assert off / off.delta == 1
    assert off / off.delta.to_timedelta64() == 1

    assert off / Nano(1) == off.delta / Nano(1).delta

    if cls is not Nano:
        # A case where we end up with a smaller class
        result = off / 1000
        assert isinstance(result, offsets.Tick)
        assert not isinstance(result, cls)
        assert result.delta == off.delta / 1000

    if cls._inc < Timedelta(seconds=1):
        # Case where we end up with a bigger class
        result = off / .001
        assert isinstance(result, offsets.Tick)
        assert not isinstance(result, cls)
        assert result.delta == off.delta / .001 
Example #7
Source File: test_timestamp.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_tz(self):
        tstr = '2014-02-01 09:00'
        ts = Timestamp(tstr)
        local = ts.tz_localize('Asia/Tokyo')
        assert local.hour == 9
        assert local == Timestamp(tstr, tz='Asia/Tokyo')
        conv = local.tz_convert('US/Eastern')
        assert conv == Timestamp('2014-01-31 19:00', tz='US/Eastern')
        assert conv.hour == 19

        # preserves nanosecond
        ts = Timestamp(tstr) + offsets.Nano(5)
        local = ts.tz_localize('Asia/Tokyo')
        assert local.hour == 9
        assert local.nanosecond == 5
        conv = local.tz_convert('US/Eastern')
        assert conv.nanosecond == 5
        assert conv.hour == 19 
Example #8
Source File: test_ticks.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_Nanosecond():
    timestamp = Timestamp(datetime(2010, 1, 1))
    assert_offset_equal(Nano(),
                        timestamp,
                        timestamp + np.timedelta64(1, 'ns'))
    assert_offset_equal(Nano(-1),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)
    assert_offset_equal(2 * Nano(),
                        timestamp,
                        timestamp + np.timedelta64(2, 'ns'))
    assert_offset_equal(-1 * Nano(),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)

    assert Nano(3) + Nano(2) == Nano(5)
    assert Nano(3) - Nano(2) == Nano()

    # GH9284
    assert Nano(1) + Nano(10) == Nano(11)
    assert Nano(5) + Micro(1) == Nano(1005)
    assert Micro(5) + Nano(1) == Nano(5001) 
Example #9
Source File: test_ticks.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_Nanosecond():
    timestamp = Timestamp(datetime(2010, 1, 1))
    assert_offset_equal(Nano(),
                        timestamp,
                        timestamp + np.timedelta64(1, 'ns'))
    assert_offset_equal(Nano(-1),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)
    assert_offset_equal(2 * Nano(),
                        timestamp,
                        timestamp + np.timedelta64(2, 'ns'))
    assert_offset_equal(-1 * Nano(),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)

    assert Nano(3) + Nano(2) == Nano(5)
    assert Nano(3) - Nano(2) == Nano()

    # GH9284
    assert Nano(1) + Nano(10) == Nano(11)
    assert Nano(5) + Micro(1) == Nano(1005)
    assert Micro(5) + Nano(1) == Nano(5001) 
Example #10
Source File: test_libfrequencies.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_is_superperiod_subperiod():

    # input validation
    assert not (is_superperiod(offsets.YearEnd(), None))
    assert not (is_subperiod(offsets.MonthEnd(), None))
    assert not (is_superperiod(None, offsets.YearEnd()))
    assert not (is_subperiod(None, offsets.MonthEnd()))
    assert not (is_superperiod(None, None))
    assert not (is_subperiod(None, None))

    assert (is_superperiod(offsets.YearEnd(), offsets.MonthEnd()))
    assert (is_subperiod(offsets.MonthEnd(), offsets.YearEnd()))

    assert (is_superperiod(offsets.Hour(), offsets.Minute()))
    assert (is_subperiod(offsets.Minute(), offsets.Hour()))

    assert (is_superperiod(offsets.Second(), offsets.Milli()))
    assert (is_subperiod(offsets.Milli(), offsets.Second()))

    assert (is_superperiod(offsets.Milli(), offsets.Micro()))
    assert (is_subperiod(offsets.Micro(), offsets.Milli()))

    assert (is_superperiod(offsets.Micro(), offsets.Nano()))
    assert (is_subperiod(offsets.Nano(), offsets.Micro())) 
Example #11
Source File: resample.py    From recruit with Apache License 2.0 6 votes vote down vote up
def _adjust_bin_edges(self, binner, ax_values):
        # Some hacks for > daily data, see #1471, #1458, #1483

        if self.freq != 'D' and is_superperiod(self.freq, 'D'):
            if self.closed == 'right':
                # GH 21459, GH 9119: Adjust the bins relative to the wall time
                bin_edges = binner.tz_localize(None)
                bin_edges = bin_edges + timedelta(1) - Nano(1)
                bin_edges = bin_edges.tz_localize(binner.tz).asi8
            else:
                bin_edges = binner.asi8

            # intraday values on last day
            if bin_edges[-2] > ax_values.max():
                bin_edges = bin_edges[:-1]
                binner = binner[:-1]
        else:
            bin_edges = binner.asi8
        return binner, bin_edges 
Example #12
Source File: test_frequencies.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def test_is_superperiod_subperiod():

    # input validation
    assert not (frequencies.is_superperiod(offsets.YearEnd(), None))
    assert not (frequencies.is_subperiod(offsets.MonthEnd(), None))
    assert not (frequencies.is_superperiod(None, offsets.YearEnd()))
    assert not (frequencies.is_subperiod(None, offsets.MonthEnd()))
    assert not (frequencies.is_superperiod(None, None))
    assert not (frequencies.is_subperiod(None, None))

    assert (frequencies.is_superperiod(offsets.YearEnd(), offsets.MonthEnd()))
    assert (frequencies.is_subperiod(offsets.MonthEnd(), offsets.YearEnd()))

    assert (frequencies.is_superperiod(offsets.Hour(), offsets.Minute()))
    assert (frequencies.is_subperiod(offsets.Minute(), offsets.Hour()))

    assert (frequencies.is_superperiod(offsets.Second(), offsets.Milli()))
    assert (frequencies.is_subperiod(offsets.Milli(), offsets.Second()))

    assert (frequencies.is_superperiod(offsets.Milli(), offsets.Micro()))
    assert (frequencies.is_subperiod(offsets.Micro(), offsets.Milli()))

    assert (frequencies.is_superperiod(offsets.Micro(), offsets.Nano()))
    assert (frequencies.is_subperiod(offsets.Nano(), offsets.Micro())) 
Example #13
Source File: test_timestamp.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_tz(self):
        tstr = '2014-02-01 09:00'
        ts = Timestamp(tstr)
        local = ts.tz_localize('Asia/Tokyo')
        assert local.hour == 9
        assert local == Timestamp(tstr, tz='Asia/Tokyo')
        conv = local.tz_convert('US/Eastern')
        assert conv == Timestamp('2014-01-31 19:00', tz='US/Eastern')
        assert conv.hour == 19

        # preserves nanosecond
        ts = Timestamp(tstr) + offsets.Nano(5)
        local = ts.tz_localize('Asia/Tokyo')
        assert local.hour == 9
        assert local.nanosecond == 5
        conv = local.tz_convert('US/Eastern')
        assert conv.nanosecond == 5
        assert conv.hour == 19 
Example #14
Source File: test_ticks.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_tick_division(cls):
    off = cls(10)

    assert off / cls(5) == 2
    assert off / 2 == cls(5)
    assert off / 2.0 == cls(5)

    assert off / off.delta == 1
    assert off / off.delta.to_timedelta64() == 1

    assert off / Nano(1) == off.delta / Nano(1).delta

    if cls is not Nano:
        # A case where we end up with a smaller class
        result = off / 1000
        assert isinstance(result, offsets.Tick)
        assert not isinstance(result, cls)
        assert result.delta == off.delta / 1000

    if cls._inc < Timedelta(seconds=1):
        # Case where we end up with a bigger class
        result = off / .001
        assert isinstance(result, offsets.Tick)
        assert not isinstance(result, cls)
        assert result.delta == off.delta / .001 
Example #15
Source File: test_ticks.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_Nanosecond():
    timestamp = Timestamp(datetime(2010, 1, 1))
    assert_offset_equal(Nano(),
                        timestamp,
                        timestamp + np.timedelta64(1, 'ns'))
    assert_offset_equal(Nano(-1),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)
    assert_offset_equal(2 * Nano(),
                        timestamp,
                        timestamp + np.timedelta64(2, 'ns'))
    assert_offset_equal(-1 * Nano(),
                        timestamp + np.timedelta64(1, 'ns'),
                        timestamp)

    assert Nano(3) + Nano(2) == Nano(5)
    assert Nano(3) - Nano(2) == Nano()

    # GH9284
    assert Nano(1) + Nano(10) == Nano(11)
    assert Nano(5) + Micro(1) == Nano(1005)
    assert Micro(5) + Nano(1) == Nano(5001) 
Example #16
Source File: test_timestamp.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def test_tz(self):
        t = '2014-02-01 09:00'
        ts = Timestamp(t)
        local = ts.tz_localize('Asia/Tokyo')
        assert local.hour == 9
        assert local == Timestamp(t, tz='Asia/Tokyo')
        conv = local.tz_convert('US/Eastern')
        assert conv == Timestamp('2014-01-31 19:00', tz='US/Eastern')
        assert conv.hour == 19

        # preserves nanosecond
        ts = Timestamp(t) + offsets.Nano(5)
        local = ts.tz_localize('Asia/Tokyo')
        assert local.hour == 9
        assert local.nanosecond == 5
        conv = local.tz_convert('US/Eastern')
        assert conv.nanosecond == 5
        assert conv.hour == 19 
Example #17
Source File: test_ticks.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_NanosecondGeneric():
    timestamp = Timestamp(datetime(2010, 1, 1))
    assert timestamp.nanosecond == 0

    result = timestamp + Nano(10)
    assert result.nanosecond == 10

    reverse_result = Nano(10) + timestamp
    assert reverse_result.nanosecond == 10 
Example #18
Source File: test_ticks.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_delta_to_tick():
    delta = timedelta(3)

    tick = offsets._delta_to_tick(delta)
    assert (tick == offsets.Day(3))

    td = Timedelta(nanoseconds=5)
    tick = offsets._delta_to_tick(td)
    assert tick == Nano(5) 
Example #19
Source File: test_qcut.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_qcut_nat(ser):
    # see gh-19768
    intervals = IntervalIndex.from_tuples([
        (ser[0] - Nano(), ser[2] - Day()),
        np.nan, (ser[2] - Day(), ser[2])])
    expected = Series(Categorical(intervals, ordered=True))

    result = qcut(ser, 2)
    tm.assert_series_equal(result, expected) 
Example #20
Source File: test_ticks.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_NanosecondGeneric():
    timestamp = Timestamp(datetime(2010, 1, 1))
    assert timestamp.nanosecond == 0

    result = timestamp + Nano(10)
    assert result.nanosecond == 10

    reverse_result = Nano(10) + timestamp
    assert reverse_result.nanosecond == 10 
Example #21
Source File: test_tile.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_qcut_nat(self, s):
        # GH 19768
        intervals = IntervalIndex.from_tuples(
            [(s[0] - Nano(), s[2] - Day()), np.nan, (s[2] - Day(), s[2])])
        expected = Series(Categorical(intervals, ordered=True))
        result = qcut(s, 2)
        tm.assert_series_equal(result, expected) 
Example #22
Source File: test_dply_datetime.py    From siuba with MIT License 5 votes vote down vote up
def test_period_floor_tick(unit):
    src = pd.DatetimeIndex(["2020-01-02"])
    res = floor_date((src + Nano()).to_period("ns"), unit)
    tm.assert_index_equal(res, src.to_period(unit)) 
Example #23
Source File: test_ticks.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_tick_zero(cls1, cls2):
    assert cls1(0) == cls2(0)
    assert cls1(0) + cls2(0) == cls1(0)

    if cls1 is not Nano:
        assert cls1(2) + cls2(0) == cls1(2)

    if cls1 is Nano:
        assert cls1(2) + Nano(0) == cls1(2) 
Example #24
Source File: test_timestamp.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_nanosecond_timestamp(self):
        # GH 7610
        expected = 1293840000000000005
        t = Timestamp('2011-01-01') + offsets.Nano(5)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000005')"
        assert t.value == expected
        assert t.nanosecond == 5

        t = Timestamp(t)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000005')"
        assert t.value == expected
        assert t.nanosecond == 5

        t = Timestamp(np_datetime64_compat('2011-01-01 00:00:00.000000005Z'))
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000005')"
        assert t.value == expected
        assert t.nanosecond == 5

        expected = 1293840000000000010
        t = t + offsets.Nano(5)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000010')"
        assert t.value == expected
        assert t.nanosecond == 10

        t = Timestamp(t)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000010')"
        assert t.value == expected
        assert t.nanosecond == 10

        t = Timestamp(np_datetime64_compat('2011-01-01 00:00:00.000000010Z'))
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000010')"
        assert t.value == expected
        assert t.nanosecond == 10 
Example #25
Source File: test_dply_datetime.py    From siuba with MIT License 5 votes vote down vote up
def test_tick(unit):
    src = pd.DatetimeIndex(["2020-01-02"])
    check_floor_ceil(src, Nano(), unit) 
Example #26
Source File: test_qcut.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_qcut_nat(ser):
    # see gh-19768
    intervals = IntervalIndex.from_tuples([
        (ser[0] - Nano(), ser[2] - Day()),
        np.nan, (ser[2] - Day(), ser[2])])
    expected = Series(Categorical(intervals, ordered=True))

    result = qcut(ser, 2)
    tm.assert_series_equal(result, expected) 
Example #27
Source File: test_timestamp.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_nanosecond_timestamp(self):
        # GH 7610
        expected = 1293840000000000005
        t = Timestamp('2011-01-01') + offsets.Nano(5)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000005')"
        assert t.value == expected
        assert t.nanosecond == 5

        t = Timestamp(t)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000005')"
        assert t.value == expected
        assert t.nanosecond == 5

        t = Timestamp(np_datetime64_compat('2011-01-01 00:00:00.000000005Z'))
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000005')"
        assert t.value == expected
        assert t.nanosecond == 5

        expected = 1293840000000000010
        t = t + offsets.Nano(5)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000010')"
        assert t.value == expected
        assert t.nanosecond == 10

        t = Timestamp(t)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000010')"
        assert t.value == expected
        assert t.nanosecond == 10

        t = Timestamp(np_datetime64_compat('2011-01-01 00:00:00.000000010Z'))
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000010')"
        assert t.value == expected
        assert t.nanosecond == 10 
Example #28
Source File: test_timestamp.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_nanosecond_timestamp(self):
        # GH 7610
        expected = 1293840000000000005
        t = Timestamp('2011-01-01') + offsets.Nano(5)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000005')"
        assert t.value == expected
        assert t.nanosecond == 5

        t = Timestamp(t)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000005')"
        assert t.value == expected
        assert t.nanosecond == 5

        t = Timestamp(np_datetime64_compat('2011-01-01 00:00:00.000000005Z'))
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000005')"
        assert t.value == expected
        assert t.nanosecond == 5

        expected = 1293840000000000010
        t = t + offsets.Nano(5)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000010')"
        assert t.value == expected
        assert t.nanosecond == 10

        t = Timestamp(t)
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000010')"
        assert t.value == expected
        assert t.nanosecond == 10

        t = Timestamp(np_datetime64_compat('2011-01-01 00:00:00.000000010Z'))
        assert repr(t) == "Timestamp('2011-01-01 00:00:00.000000010')"
        assert t.value == expected
        assert t.nanosecond == 10 
Example #29
Source File: test_ticks.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_NanosecondGeneric():
    timestamp = Timestamp(datetime(2010, 1, 1))
    assert timestamp.nanosecond == 0

    result = timestamp + Nano(10)
    assert result.nanosecond == 10

    reverse_result = Nano(10) + timestamp
    assert reverse_result.nanosecond == 10 
Example #30
Source File: test_ticks.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_delta_to_tick():
    delta = timedelta(3)

    tick = offsets._delta_to_tick(delta)
    assert (tick == offsets.Day(3))

    td = Timedelta(nanoseconds=5)
    tick = offsets._delta_to_tick(td)
    assert tick == Nano(5)