<commit_before># Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-

import pytest

asdf = pytest.importorskip('asdf')
from asdf.tests.helpers import assert_roundtrip_tree

from astropy.time import Time, TimeDelta


@pytest.mark.parametrize('fmt', Time.FORMATS.keys())
def test_timedelta(fmt, tmpdir):

    t1 = Time(Time.now(), format=fmt)
    t2 = Time(Time.now(), format=fmt)

    td = t2 - t1
    tree = dict(timedelta=td)
    assert_roundtrip_tree(tree, tmpdir)


@pytest.mark.parametrize('scale', list(TimeDelta.SCALES) + [None])
def test_timedetal_scales(scale, tmpdir):

    tree = dict(timedelta=TimeDelta(0.125, scale=scale))
    assert_roundtrip_tree(tree, tmpdir)<commit_msg>Fix the ASDF test for TimeDelta formats<commit_after># Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-

import pytest

asdf = pytest.importorskip('asdf')
from asdf.tests.helpers import assert_roundtrip_tree

from astropy.time import Time, TimeDelta


@pytest.mark.parametrize('fmt', TimeDelta.FORMATS.keys())
def test_timedelta(fmt, tmpdir):

    t1 = Time(Time.now())
    t2 = Time(Time.now())

    td = TimeDelta(t2 - t1, format=fmt)
    tree = dict(timedelta=td)
    assert_roundtrip_tree(tree, tmpdir)


@pytest.mark.parametrize('scale', list(TimeDelta.SCALES) + [None])
def test_timedetal_scales(scale, tmpdir):

    tree = dict(timedelta=TimeDelta(0.125, scale=scale))
    assert_roundtrip_tree(tree, tmpdir)
{'fraction_non_alphanumeric': 0.13161465400271372, 'fraction_numerical': 0.013568521031207599, 'mean_word_length': 4.717054263565892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2763997', 'n_tokens_mistral': 557, 'n_tokens_neox': 534, 'n_words': 112}