Skip to content

Commit

Permalink
feat!: remove deprecations for 1.4.0 release (#2688)
Browse files Browse the repository at this point in the history
* feat!: drop `typestr` argument

* feat!: drop `Form.type_from_behavior`

* feat!: drop `ak.typetracer.empty_if_typetracer`

* feat!: drop `UnionArray.simplified`'s `merge` argument

* feat!: drop string and categorical behaviors

* Revert "feat!: drop string and categorical behaviors"

This reverts commit 9218a77. This is required because it these classes are likely serialised in some behavior dictionaries

* fix: catch broken tests

* feat!: don't import unused behaviors

* test: drop reference to unused behavior

* feat: replace behaviors with pass-throughs
  • Loading branch information
agoose77 authored Sep 4, 2023
1 parent a5efdfe commit aaf09c1
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 266 deletions.
2 changes: 0 additions & 2 deletions src/awkward/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
from awkward.highlevel import *

# behaviors
import awkward.behaviors.categorical
import awkward.behaviors.string
from awkward.behaviors.mixins import *

# exports
Expand Down
14 changes: 1 addition & 13 deletions src/awkward/behaviors/categorical.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
from awkward._errors import deprecate
from awkward.highlevel import Array


class CategoricalBehavior(Array):
__name__ = "Array"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

deprecate(
f"{type(self).__name__} is deprecated: categorical types are now considered a built-in feature "
f"provided by Awkward Array, rather than an extension.",
version="2.4.0",
)
CategoricalBehavior = Array
56 changes: 4 additions & 52 deletions src/awkward/behaviors/string.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,7 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
from awkward._errors import deprecate
from awkward.highlevel import Array


class ByteBehavior(Array):
__name__ = "Array"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

deprecate(
f"{type(self).__name__} is deprecated: string types are now considered a built-in feature "
f"provided by Awkward Array, rather than an extension.",
version="2.4.0",
)


class CharBehavior(Array):
__name__ = "Array"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

deprecate(
f"{type(self).__name__} is deprecated: string types are now considered a built-in feature "
f"provided by Awkward Array, rather than an extension.",
version="2.4.0",
)


class ByteStringBehavior(Array):
__name__ = "Array"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

deprecate(
f"{type(self).__name__} is deprecated: string types are now considered a built-in feature "
f"provided by Awkward Array, rather than an extension.",
version="2.4.0",
)


class StringBehavior(Array):
__name__ = "Array"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

deprecate(
f"{type(self).__name__} is deprecated: string types are now considered a built-in feature "
f"provided by Awkward Array, rather than an extension.",
version="2.4.0",
)
ByteBehavior = Array
CharBehavior = Array
ByteStringBehavior = Array
StringBehavior = Array
14 changes: 2 additions & 12 deletions src/awkward/contents/unionarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import awkward as ak
from awkward._backends.backend import Backend
from awkward._errors import deprecate
from awkward._layout import maybe_posaxis
from awkward._nplikes.numpy import Numpy
from awkward._nplikes.numpylike import ArrayLike, IndexType, NumpyMetadata
Expand Down Expand Up @@ -228,17 +227,8 @@ def simplified(
contents,
*,
parameters=None,
merge=UNSET,
mergebool=False,
):
if merge is UNSET:
merge = True
else:
deprecate(
"The `merge` argument to UnionArray.simplified(...) is deprecated; "
"it is no longer possible to construct UnionArrays with mergeable contents.",
version="2.4.0",
)
self_index = index
self_tags = tags
self_contents = contents
Expand Down Expand Up @@ -282,7 +272,7 @@ def simplified(
# For each "final" outer union content
for k in range(len(contents)):
# Try and merge inner union content with running outer-union contentca
if merge and contents[k]._mergeable_next(inner_cont, mergebool):
if contents[k]._mergeable_next(inner_cont, mergebool):
backend.maybe_kernel_error(
backend[
"awkward_UnionArray_simplify",
Expand Down Expand Up @@ -362,7 +352,7 @@ def simplified(
unmerged = False
break

elif merge and contents[k]._mergeable_next(self_cont, mergebool):
elif contents[k]._mergeable_next(self_cont, mergebool):
backend.maybe_kernel_error(
backend[
"awkward_UnionArray_simplify_one",
Expand Down
10 changes: 0 additions & 10 deletions src/awkward/forms/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,16 +476,6 @@ def _repr_args(self):
def type(self):
raise NotImplementedError

def type_from_behavior(self, behavior):
deprecate(
"low level types produced by forms do not hold references to behaviors. "
"Use a high-level type (e.g. ak.types.ArrayType or ak.types.ScalarType) to"
"associate a type with behavior information, or simply access the low-level"
"type from Form.type",
version="2.4.0",
)
return self.type

def columns(self, list_indicator=None, column_prefix=()):
output = []
self._columns(column_prefix, output, list_indicator)
Expand Down
18 changes: 3 additions & 15 deletions src/awkward/types/listtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import annotations

from awkward._behavior import find_array_typestr
from awkward._errors import deprecate
from awkward._parameters import parameters_are_equal, type_parameters_equal
from awkward._typing import Self, final
from awkward._util import UNSET
Expand All @@ -11,14 +10,13 @@

@final
class ListType(Type):
def copy(self, *, content: Type = UNSET, parameters=UNSET, typestr=UNSET) -> Self:
def copy(self, *, content: Type = UNSET, parameters=UNSET) -> Self:
return ListType(
self._content if content is UNSET else content,
parameters=self._parameters if parameters is UNSET else parameters,
typestr=self._typestr if typestr is UNSET else typestr,
)

def __init__(self, content, *, parameters=None, typestr=None):
def __init__(self, content, *, parameters=None):
if not isinstance(content, Type):
raise TypeError(
"{} 'content' must be a Type subtype, not {}".format(
Expand All @@ -31,22 +29,15 @@ def __init__(self, content, *, parameters=None, typestr=None):
type(self).__name__, repr(parameters)
)
)
if typestr is not None and not isinstance(typestr, str):
raise TypeError(
"{} 'typestr' must be of type string or None, not {}".format(
type(self).__name__, repr(typestr)
)
)
self._content = content
self._parameters = parameters
self._typestr = typestr

@property
def content(self):
return self._content

def _get_typestr(self, behavior) -> str | None:
typestr = find_array_typestr(behavior, self._parameters, self._typestr)
typestr = find_array_typestr(behavior, self._parameters)
if typestr is not None:
return typestr

Expand All @@ -62,9 +53,6 @@ def _get_typestr(self, behavior) -> str | None:
return None

def _str(self, indent, compact, behavior):
if self._typestr is not None:
deprecate("typestr argument is deprecated", "2.4.0")

typestr = self._get_typestr(behavior)
if typestr is not None:
out = [typestr]
Expand Down
18 changes: 3 additions & 15 deletions src/awkward/types/numpytype.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import re

from awkward._behavior import find_array_typestr
from awkward._errors import deprecate
from awkward._nplikes.numpylike import NumpyMetadata
from awkward._parameters import parameters_are_equal, type_parameters_equal
from awkward._typing import Self, final
Expand Down Expand Up @@ -95,30 +94,22 @@ def dtype_to_primitive(dtype):

@final
class NumpyType(Type):
def copy(self, *, primitive: Type = UNSET, parameters=UNSET, typestr=UNSET) -> Self:
def copy(self, *, primitive: Type = UNSET, parameters=UNSET) -> Self:
return NumpyType(
self._primitive if primitive is UNSET else primitive,
parameters=self._parameters if parameters is UNSET else parameters,
typestr=self._typestr if typestr is UNSET else typestr,
)

def __init__(self, primitive, *, parameters=None, typestr=None):
def __init__(self, primitive, *, parameters=None):
primitive = dtype_to_primitive(primitive_to_dtype(primitive))
if parameters is not None and not isinstance(parameters, dict):
raise TypeError(
"{} 'parameters' must be of type dict or None, not {}".format(
type(self).__name__, repr(parameters)
)
)
if typestr is not None and not isinstance(typestr, str):
raise TypeError(
"{} 'typestr' must be of type string or None, not {}".format(
type(self).__name__, repr(typestr)
)
)
self._primitive = primitive
self._parameters = parameters
self._typestr = typestr

@property
def primitive(self):
Expand All @@ -127,7 +118,7 @@ def primitive(self):
_str_parameters_exclude = ("__categorical__", "__unit__")

def _get_typestr(self, behavior) -> str | None:
typestr = find_array_typestr(behavior, self._parameters, self._typestr)
typestr = find_array_typestr(behavior, self._parameters)
if typestr is not None:
return typestr

Expand All @@ -141,9 +132,6 @@ def _get_typestr(self, behavior) -> str | None:
return None

def _str(self, indent, compact, behavior):
if self._typestr is not None:
deprecate("typestr argument is deprecated", "2.4.0")

typestr = self._get_typestr(behavior)
if typestr is not None:
out = [typestr]
Expand Down
34 changes: 5 additions & 29 deletions src/awkward/types/optiontype.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import annotations

from awkward._behavior import find_array_typestr
from awkward._errors import deprecate
from awkward._parameters import (
parameters_are_equal,
parameters_union,
Expand All @@ -18,14 +17,13 @@

@final
class OptionType(Type):
def copy(self, *, content: Type = UNSET, parameters=UNSET, typestr=UNSET) -> Self:
def copy(self, *, content: Type = UNSET, parameters=UNSET) -> Self:
return OptionType(
self._content if content is UNSET else content,
parameters=self._parameters if parameters is UNSET else parameters,
typestr=self._typestr if typestr is UNSET else typestr,
)

def __init__(self, content, *, parameters=None, typestr=None):
def __init__(self, content, *, parameters=None):
if not isinstance(content, Type):
raise TypeError(
"{} 'content' must be a Type subclass, not {}".format(
Expand All @@ -38,25 +36,15 @@ def __init__(self, content, *, parameters=None, typestr=None):
type(self).__name__, repr(parameters)
)
)
if typestr is not None and not isinstance(typestr, str):
raise TypeError(
"{} 'typestr' must be of type string or None, not {}".format(
type(self).__name__, repr(typestr)
)
)
self._content = content
self._parameters = parameters
self._typestr = typestr

@property
def content(self):
return self._content

def _str(self, indent, compact, behavior):
if self._typestr is not None:
deprecate("typestr argument is deprecated", "2.4.0")

typestr = find_array_typestr(behavior, self._parameters, self._typestr)
typestr = find_array_typestr(behavior, self._parameters)

head = []
tail = []
Expand Down Expand Up @@ -101,31 +89,19 @@ def simplify_option_union(self):
contents = []
for content in self._content.contents:
if isinstance(content, OptionType):
typestr = (
content._typestr if self._typestr is None else self._typestr
)
contents.append(
OptionType(
content.content,
parameters=parameters_union(
self._parameters, content._parameters
),
typestr=typestr,
)
)

else:
contents.append(
OptionType(
content, parameters=self._parameters, typestr=self._typestr
)
)
contents.append(OptionType(content, parameters=self._parameters))

return UnionType(
contents,
parameters=self._content.parameters,
typestr=self._content.typestr,
)
return UnionType(contents, parameters=self._content.parameters)

else:
return self
Expand Down
Loading

0 comments on commit aaf09c1

Please sign in to comment.