Skip to content

Commit

Permalink
test(datatypes): test to_ and from_ format methods
Browse files Browse the repository at this point in the history
  • Loading branch information
deepyaman authored and jcrist committed Jan 4, 2024
1 parent 6fd4550 commit 6e3fcd7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ibis/expr/datatypes/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Annotated, NamedTuple

import pytest
from pytest import param

import ibis.expr.datatypes as dt
from ibis.common.annotations import ValidationError
Expand Down Expand Up @@ -672,3 +673,23 @@ def test_type_coercion():
p = Pattern.from_typehint(Annotated[dt.Interval, Attrs(unit=As(TimeUnit))])
assert p.match(dt.Interval("s"), {}) == dt.Interval("s")
assert p.match(dt.Interval("ns"), {}) == dt.Interval("ns")


@pytest.mark.parametrize(
"dtype",
[
param(dt.int16, id="int16"),
param(dt.int32, id="int32"),
param(dt.int64, id="int64"),
param(dt.uint8, id="uint8"),
param(dt.uint16, id="uint16"),
param(dt.uint32, id="uint32"),
param(dt.uint64, id="uint64"),
param(dt.float32, id="float32"),
param(dt.float64, id="float64"),
param(dt.boolean, id="boolean"),
],
)
@pytest.mark.parametrize("fmt", ["numpy", "pandas", "pyarrow"])
def test_type_roundtrip(dtype, fmt):
assert getattr(dt.DataType, f"from_{fmt}")(getattr(dtype, f"to_{fmt}")()) == dtype

0 comments on commit 6e3fcd7

Please sign in to comment.