diff --git a/ibis/expr/datatypes/core.py b/ibis/expr/datatypes/core.py index 2d7796c7272e..9c89c7fc85fa 100644 --- a/ibis/expr/datatypes/core.py +++ b/ibis/expr/datatypes/core.py @@ -20,7 +20,6 @@ map_to, validator, ) -from ibis.util import deprecated, warn_deprecated dtype = Dispatcher('dtype') diff --git a/ibis/expr/schema.py b/ibis/expr/schema.py index 74a56014b96e..9afe2aa6f854 100644 --- a/ibis/expr/schema.py +++ b/ibis/expr/schema.py @@ -1,7 +1,7 @@ from __future__ import annotations import collections -from typing import TYPE_CHECKING, Iterable, Iterator, Mapping +from typing import TYPE_CHECKING, Iterable, Iterator from multipledispatch import Dispatcher @@ -10,7 +10,7 @@ from ibis.common.exceptions import IntegrityError from ibis.common.grounds import Concrete from ibis.common.validators import frozendict_of, instance_of, validator -from ibis.util import deprecated, indent, warn_deprecated +from ibis.util import indent if TYPE_CHECKING: import pandas as pd @@ -50,30 +50,6 @@ class Schema(Concrete): """A mapping of [`str`][str] to [`DataType`][ibis.expr.datatypes.DataType] objects representing the type of each column.""" - @classmethod - def __create__(cls, names, types=None): - if types is None: - return super().__create__(fields=names) - else: - warn_deprecated( - "Schema(names, types)", - as_of="4.1", - removed_in="5.0", - instead=( - "construct a Schema using a mapping of names to types instead: " - "Schema(dict(zip(names, types)))" - ), - ) - return schema(names, types) - - def __reduce__(self): - return (self.__class__, (self.fields, None)) - - def copy(self, fields=None): - if fields is None: - fields = self.fields - return type(self)(fields) - def __repr__(self) -> str: space = 2 + max(map(len, self.names), default=0) return "ibis.Schema {{{}\n}}".format( @@ -133,37 +109,6 @@ def equals(self, other: Schema) -> bool: ) return self.__cached_equals__(other) - @deprecated( - as_of="4.1", - removed_in="5.0", - instead="construct a new Schema without the undesired names instead", - ) - def delete(self, names_to_delete: Iterable[str]) -> Schema: - """Remove `names_to_delete` names from `self`. - - Parameters - ---------- - names_to_delete - Iterable of `str` to remove from the schema. - - Examples - -------- - >>> import ibis - >>> sch = ibis.schema({"a": "int", "b": "string"}) - >>> sch.delete({"a"}) - ibis.Schema { - b string - } - """ - for name in names_to_delete: - if name not in self: - raise KeyError(name) - - delete = frozenset(names_to_delete) - fields = {k: v for k, v in self.fields.items() if k not in delete} - - return self.__class__(fields) - @classmethod def from_tuples( cls, @@ -192,36 +137,6 @@ def from_tuples( """ return cls(dict(values)) - @classmethod - @deprecated( - as_of="4.1", - removed_in="5.0", - instead="directly construct a Schema instead", - ) - def from_dict(cls, dictionary: Mapping[str, str | dt.DataType]) -> Schema: - """Construct a `Schema` from a `Mapping`. - - Parameters - ---------- - dictionary - Mapping from which to construct a `Schema` instance. - - Returns - ------- - Schema - A new schema - - Examples - -------- - >>> import ibis - >>> ibis.Schema.from_dict({"a": "int", "b": "string"}) - ibis.Schema { - a int64 - b string - } - """ - return cls(dictionary) - def to_pandas(self): """Return the equivalent pandas datatypes.""" from ibis.backends.pandas.client import ibis_schema_to_pandas @@ -245,10 +160,6 @@ def __ge__(self, other: Schema) -> bool: """Return whether `self` is a superset of or equal to `other`.""" return set(self.items()) >= set(other.items()) - @deprecated(as_of="4.1", removed_in="5.0", instead="use Schema.merge() instead") - def append(self, other: Schema) -> Schema: - return self.merge(other) - def merge(self, other: Schema) -> Schema: """Merge `other` to `self`. diff --git a/ibis/tests/expr/test_schema.py b/ibis/tests/expr/test_schema.py index 236cf439d615..2a17ab01795c 100644 --- a/ibis/tests/expr/test_schema.py +++ b/ibis/tests/expr/test_schema.py @@ -137,11 +137,10 @@ def test_whole_schema(): def test_schema_names_and_types_length_must_match(): - with pytest.raises(IntegrityError), pytest.warns(FutureWarning): - sch.Schema(names=["a", "b"], types=["int", "str", "float"]) + with pytest.raises(IntegrityError): + sch.schema(["a", "b"], ["int", "str", "float"]) - with pytest.warns(FutureWarning): - schema = sch.Schema(names=["a", "b"], types=["int", "str"]) + schema = sch.schema(["a", "b"], ["int", "str"]) assert isinstance(schema, sch.Schema) assert schema.names == ("a", "b") @@ -213,11 +212,3 @@ def test_api_accepts_schema_objects(): def test_names_types(): s = ibis.schema(names=["a"], types=["array"]) assert s == ibis.schema(dict(a="array")) - - -def test_schema_delete(): - s1 = ibis.schema({"a": "int64", "b": "string", "c": "float64", "d": "int64"}) - with pytest.warns(FutureWarning): - s2 = s1.delete(["b", "d"]) - - assert s2 == ibis.schema({"a": "int64", "c": "float64"})