Пример #1
0
 def test_time32_python(self):
     """
     Python -> Rust -> Python
     """
     a = pyarrow.array([None, 1, 2], pyarrow.time32('s'))
     b = arrow_pyarrow_integration_testing.concatenate(a)
     expected = pyarrow.array([None, 1, 2] + [None, 1, 2], pyarrow.time32('s'))
     self.assertEqual(b, expected)
Пример #2
0
def test_time32_python():
    """
    Python -> Rust -> Python
    """
    a = pa.array([None, 1, 2], pa.time32("s"))
    b = rust.concatenate(a)
    expected = pa.array([None, 1, 2] + [None, 1, 2], pa.time32("s"))
    assert b == expected
    del a
    del b
    del expected
Пример #3
0
 def test_time32_python(self):
     """
     Python -> Rust -> Python
     """
     old_allocated = pyarrow.total_allocated_bytes()
     a = pyarrow.array([None, 1, 2], pyarrow.time32('s'))
     b = arrow_pyarrow_integration_testing.concatenate(a)
     expected = pyarrow.array([None, 1, 2] + [None, 1, 2], pyarrow.time32('s'))
     self.assertEqual(b, expected)
     del a
     del b
     del expected
     # No leak of C++ memory
     self.assertEqual(old_allocated, pyarrow.total_allocated_bytes())
Пример #4
0
def test_timestamp_python():
    """
    Python -> Rust -> Python
    """
    data = [
        None,
        datetime.datetime(2021, 1, 1, 1, 1, 1, 1),
        datetime.datetime(2020, 3, 9, 1, 1, 1, 1),
    ]
    a = pa.array(data, pa.timestamp("us"))
    b = rust.concatenate(a)
    expected = pa.array(data + data, pa.timestamp("us"))
    assert b == expected
    del a
    del b
    del expected
Пример #5
0
def test_timestamp_tz_python():
    """
    Python -> Rust -> Python
    """
    tzinfo = pytz.timezone("America/New_York")
    pyarrow_type = pa.timestamp("us", tz="America/New_York")
    data = [
        None,
        datetime.datetime(2021, 1, 1, 1, 1, 1, 1, tzinfo=tzinfo),
        datetime.datetime(2020, 3, 9, 1, 1, 1, 1, tzinfo=tzinfo),
    ]
    a = pa.array(data, type=pyarrow_type)
    b = rust.concatenate(a)
    expected = pa.array(data * 2, type=pyarrow_type)
    assert b == expected
    del a
    del b
    del expected