Exemple #1
0
def test_optimized_int_type_for_typed_sequence(sequence, optimized_int_type,
                                               expected_dtype):
    arr = pa.array(
        TypedSequence(sequence, optimized_int_type=optimized_int_type))
    assert get_base_dtype(arr.type) == expected_dtype
Exemple #2
0
 def test_array_type_forbidden(self):
     with self.assertRaises(ValueError):
         _ = pa.array(TypedSequence([1, 2, 3]), type=pa.int64())
Exemple #3
0
 def test_try_type_and_type_forbidden(self):
     with self.assertRaises(ValueError):
         _ = pa.array(
             TypedSequence([1, 2, 3],
                           try_type=Value("bool"),
                           type=Value("int64")))
 def test_catch_overflow(self):
     if version.parse(pa.__version__) < version.parse("2.0.0"):
         with self.assertRaises(OverflowError):
             _ = pa.array(TypedSequence(
                 [["x" * 1024]] *
                 ((2 << 20) + 1)))  # ListArray with a bit more than 2GB
Exemple #5
0
 def test_no_type(self):
     arr = pa.array(TypedSequence([1, 2, 3]))
     self.assertEqual(arr.type, pa.int64())
 def test_try_compatible_extension_type(self):
     arr = pa.array(
         TypedSequence([[[1, 2, 3]]],
                       try_type=Array2DExtensionType((1, 3), "int64")))
     self.assertEqual(arr.type, Array2DExtensionType((1, 3), "int64"))
 def test_try_incompatible_extension_type(self):
     arr = pa.array(
         TypedSequence(["foo", "bar"],
                       try_type=Array2DExtensionType((1, 3), "int64")))
     self.assertEqual(arr.type, pa.string())
 def test_try_incompatible_type(self):
     arr = pa.array(TypedSequence(["foo", "bar"], try_type=pa.int64()))
     self.assertEqual(arr.type, pa.string())
 def test_incompatible_extension_type(self):
     with self.assertRaises((TypeError, pa.lib.ArrowInvalid)):
         _ = pa.array(
             TypedSequence(["foo", "bar"],
                           type=Array2DExtensionType((1, 3), "int64")))
 def test_try_compatible_type(self):
     arr = pa.array(TypedSequence([1, 2, 3], try_type=pa.int32()))
     self.assertEqual(arr.type, pa.int32())
 def test_incompatible_type(self):
     with self.assertRaises((TypeError, pa.lib.ArrowInvalid)):
         _ = pa.array(TypedSequence(["foo", "bar"], type=pa.int64()))
 def test_try_type_and_type_forbidden(self):
     with self.assertRaises(AssertionError):
         _ = pa.array(
             TypedSequence([1, 2, 3], try_type=pa.bool_(), type=pa.int64()))
 def test_catch_overflow(self):
     with self.assertRaises(OverflowError):
         _ = pa.array(TypedSequence(
             [["x" * 1024]] *
             ((2 << 20) + 1)))  # ListArray with a bit more than 2GB
Exemple #14
0
 def test_catch_overflow(self):
     if config.PYARROW_VERSION.major < 2:
         with self.assertRaises(OverflowError):
             _ = pa.array(TypedSequence([["x" * 1024]] * ((2 << 20) + 1)))  # ListArray with a bit more than 2GB