<commit_before>import numpy as np

from ...tests.helper import pytest
from .. import Time, ScaleValueError, sofa_time


class TestBasic():
    """Basic tests stemming from initial example and API reference"""

    def test_simple(self):
        times = ['1999-01-01 00:00:00.123456789', '2010-01-01 00:00:00']
        t = Time(times, format='iso', scale='utc')
        assert (repr(t) == "<Time object: scale='utc' format='iso' "
                "vals=['1999-01-01 00:00:00.123' '2010-01-01 00:00:00.000']>")
        assert np.allclose(t.jd1, np.array([2451179.5, 2455197.5]))
        assert np.allclose(t.jd2, np.array([1.42889802e-06, 0.00000000e+00]))

        # Set scale to TAI
        t = t.tai
        assert (repr(t) == "<Time object: scale='tai' format='iso' "
                "vals=['1999-01-01 00:00:32.123' '2010-01-01 00:00:34.000']>")
        assert np.allclose(t.jd1, np.array([2451179.5, 2455197.5]))
        assert np.allclose(t.jd2, np.array([0.0003718, 0.00039352]))

        # Get a new ``Time`` object which is referenced to the TT scale
        # (internal JD1 and JD1 are now with respect to TT scale)"""

        assert (repr(t.tt) == "<Time object: scale='tt' format='iso' "
                "vals=['1999-01-01 00:01:04.307' '2010-01-01 00:01:06.184']>")

        # Get the representation of the ``Time`` object in a particular format
        # (in this case seconds since 1998.0).  This returns either a scalar or
        # array, depending on whether the input was a scalar or array"""

        print t.cxcsec
        assert np.allclose(t.cxcsec, np.array([3.15360643e+07,
                                               3.78691266e+08]))<commit_msg>added test to ensure initializer copying works<commit_after>import numpy as np

from ...tests.helper import pytest
from .. import Time, ScaleValueError, sofa_time


class TestBasic():
    """Basic tests stemming from initial example and API reference"""

    def test_simple(self):
        times = ['1999-01-01 00:00:00.123456789', '2010-01-01 00:00:00']
        t = Time(times, format='iso', scale='utc')
        assert (repr(t) == "<Time object: scale='utc' format='iso' "
                "vals=['1999-01-01 00:00:00.123' '2010-01-01 00:00:00.000']>")
        assert np.allclose(t.jd1, np.array([2451179.5, 2455197.5]))
        assert np.allclose(t.jd2, np.array([1.42889802e-06, 0.00000000e+00]))

        # Set scale to TAI
        t = t.tai
        assert (repr(t) == "<Time object: scale='tai' format='iso' "
                "vals=['1999-01-01 00:00:32.123' '2010-01-01 00:00:34.000']>")
        assert np.allclose(t.jd1, np.array([2451179.5, 2455197.5]))
        assert np.allclose(t.jd2, np.array([0.0003718, 0.00039352]))

        # Get a new ``Time`` object which is referenced to the TT scale
        # (internal JD1 and JD1 are now with respect to TT scale)"""

        assert (repr(t.tt) == "<Time object: scale='tt' format='iso' "
                "vals=['1999-01-01 00:01:04.307' '2010-01-01 00:01:06.184']>")

        # Get the representation of the ``Time`` object in a particular format
        # (in this case seconds since 1998.0).  This returns either a scalar or
        # array, depending on whether the input was a scalar or array"""

        print t.cxcsec
        assert np.allclose(t.cxcsec, np.array([3.15360643e+07,
                                               3.78691266e+08]))

    def test_copy(self):
        """Test copying the values of a Time object by passing it into the
        Time initializer.
        """
        t = Time(2455197.5, format='jd', scale='utc')
        t2 = Time(t)

        assert t.jd - t2.jd == 0
        assert (t - t2).jd == 0
{'fraction_non_alphanumeric': 0.15124215124215123, 'fraction_numerical': 0.13622713622713623, 'mean_word_length': 2.398886827458256, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7036254', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1216, 'n_words': 336}