Skip to content

Commit

Permalink
wip: remove _v2 imports
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Sep 10, 2022
1 parent 2ca0236 commit 9b7f7d0
Show file tree
Hide file tree
Showing 395 changed files with 14,105 additions and 15,150 deletions.
2 changes: 1 addition & 1 deletion dev/flake8_awkward.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Flake8ASTErrorInfo(NamedTuple):


class Visitor(ast.NodeVisitor):
msg = "AK101 exception must be wrapped in ak._v2._util.*error"
msg = "AK101 exception must be wrapped in ak._util.*error"

def __init__(self):
self.errors: list[Flake8ASTErrorInfo] = []
Expand Down
4 changes: 2 additions & 2 deletions dev/generate-kernel-signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ def kernel_signatures_cuda_py(specification):
float64,
)
from awkward._v2._connect.cuda import fetch_specialization
from awkward._v2._connect.cuda import import_cupy
from awkward._connect.cuda import fetch_specialization
from awkward._connect.cuda import import_cupy
cupy = import_cupy("Awkward Arrays with CUDA")
"""
Expand Down
2 changes: 1 addition & 1 deletion dev/generate-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ def gencudakerneltests(specdict):
)

f.write(
"import cupy\nimport pytest\n\nimport awkward as ak\nimport awkward._v2._connect.cuda as ak_cu\n\ncupy_nplike = ak.nplike.Cupy.instance()\n\n"
"import cupy\nimport pytest\n\nimport awkward as ak\nimport awkward._connect.cuda as ak_cu\n\ncupy_nplike = ak.nplike.Cupy.instance()\n\n"
)
num = 1
if spec.tests == []:
Expand Down
6 changes: 3 additions & 3 deletions src/awkward/__init_old__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import awkward.layout

# internal
import awkward._v2
import awkward
import awkward._cpu_kernels
import awkward._libawkward

from awkward._v2.highlevel import Array
from awkward._v2.record import Record
from awkward.highlevel import Array
from awkward.record import Record

# version
__version__ = awkward._ext.__version__
Expand Down
76 changes: 37 additions & 39 deletions src/awkward/_broadcasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
from collections.abc import Sequence

import awkward as ak
from awkward._v2.contents.content import Content # noqa: F401
from awkward._v2.contents.emptyarray import EmptyArray # noqa: F401
from awkward._v2.contents.numpyarray import NumpyArray # noqa: F401
from awkward._v2.contents.regulararray import RegularArray # noqa: F401
from awkward._v2.contents.listarray import ListArray # noqa: F401
from awkward._v2.contents.listoffsetarray import ListOffsetArray # noqa: F401
from awkward._v2.contents.recordarray import RecordArray # noqa: F401
from awkward._v2.contents.indexedarray import IndexedArray # noqa: F401
from awkward._v2.contents.indexedoptionarray import IndexedOptionArray # noqa: F401
from awkward._v2.contents.bytemaskedarray import ByteMaskedArray # noqa: F401
from awkward._v2.contents.bitmaskedarray import BitMaskedArray # noqa: F401
from awkward._v2.contents.unmaskedarray import UnmaskedArray # noqa: F401
from awkward._v2.contents.unionarray import UnionArray # noqa: F401
from awkward._v2.record import Record # noqa: F401
from awkward._v2.index import (
from awkward.contents.content import Content # noqa: F401
from awkward.contents.emptyarray import EmptyArray # noqa: F401
from awkward.contents.numpyarray import NumpyArray # noqa: F401
from awkward.contents.regulararray import RegularArray # noqa: F401
from awkward.contents.listarray import ListArray # noqa: F401
from awkward.contents.listoffsetarray import ListOffsetArray # noqa: F401
from awkward.contents.recordarray import RecordArray # noqa: F401
from awkward.contents.indexedarray import IndexedArray # noqa: F401
from awkward.contents.indexedoptionarray import IndexedOptionArray # noqa: F401
from awkward.contents.bytemaskedarray import ByteMaskedArray # noqa: F401
from awkward.contents.bitmaskedarray import BitMaskedArray # noqa: F401
from awkward.contents.unmaskedarray import UnmaskedArray # noqa: F401
from awkward.contents.unionarray import UnionArray # noqa: F401
from awkward.record import Record # noqa: F401
from awkward.index import (
Index, # noqa: F401
Index8, # noqa: F401
# IndexU8, # noqa: F401
Expand Down Expand Up @@ -93,7 +93,7 @@ def checklength(inputs, options):
length = inputs[0].length
for x in inputs[1:]:
if x.length != length:
raise ak._v2._util.error(
raise ak._util.error(
ValueError(
"cannot broadcast {} of length {} with {} of length {}{}".format(
type(inputs[0]).__name__,
Expand Down Expand Up @@ -189,13 +189,13 @@ class BroadcastParameterRule(str, enum.Enum):
def _parameters_of(obj: Any, default: Any = NO_PARAMETERS) -> Any:
"""
Args:
obj: #ak._v2.contents.Content that holds parameters, or object
default: value to return if obj is not an #ak._v2.contents.Content
obj: #ak.contents.Content that holds parameters, or object
default: value to return if obj is not an #ak.contents.Content
Return the parameters of an object if it is a #ak._v2.contents.Content;
Return the parameters of an object if it is a #ak.contents.Content;
otherwise, return a default value.
"""
if isinstance(obj, ak._v2.contents.Content):
if isinstance(obj, ak.contents.Content):
return obj._parameters
else:
return default
Expand All @@ -206,7 +206,7 @@ def _all_or_nothing_parameters_factory(
) -> BroadcastParameterFactory:
"""
Args:
inputs: sequence of #ak._v2.contents.Content or other objects
inputs: sequence of #ak.contents.Content or other objects
Return a callable that creates an appropriately sized list of parameter objects.
The parameter objects within this list are built using an "all or nothing rule":
Expand All @@ -225,9 +225,7 @@ def _all_or_nothing_parameters_factory(
first_parameters = input_parameters[0]
# Ensure all parameters match, or set parameters to None
for other_parameters in input_parameters[1:]:
if not ak._v2.forms.form._parameters_equal(
first_parameters, other_parameters
):
if not ak.forms.form._parameters_equal(first_parameters, other_parameters):
break
else:
parameters = first_parameters
Expand All @@ -245,7 +243,7 @@ def _intersection_parameters_factory(
) -> BroadcastParameterFactory:
"""
Args:
inputs: sequence of #ak._v2.contents.Content or other objects
inputs: sequence of #ak.contents.Content or other objects
Return a callable that creates an appropriately sized list of parameter objects.
The parameter objects within this list are built using an "intersection rule":
Expand All @@ -265,7 +263,7 @@ def _intersection_parameters_factory(
# If we encounter None-parameters, then we stop early
# as there can be no intersection.
for parameters in input_parameters:
if ak._v2.forms.form._parameters_is_empty(parameters):
if ak.forms.form._parameters_is_empty(parameters):
break
else:
parameters_to_intersect.append(parameters.items())
Expand All @@ -288,7 +286,7 @@ def _one_to_one_parameters_factory(
) -> BroadcastParameterFactory:
"""
Args:
inputs: sequence of #ak._v2.contents.Content or other objects
inputs: sequence of #ak.contents.Content or other objects
Return a callable that creates an appropriately sized list of parameter objects.
The parameter objects within this list are built using a "one-to-one rule":
Expand All @@ -304,7 +302,7 @@ def _one_to_one_parameters_factory(

def apply(n_outputs) -> list[dict[str, Any] | None]:
if n_outputs != len(inputs):
raise ak._v2._util.error(
raise ak._util.error(
ValueError(
"cannot follow one-to-one parameter broadcasting rule for actions "
"which change the number of outputs."
Expand All @@ -320,7 +318,7 @@ def _none_parameters_factory(
) -> BroadcastParameterFactory:
"""
Args:
inputs: sequence of #ak._v2.contents.Content or other objects
inputs: sequence of #ak.contents.Content or other objects
Return a callable that creates an appropriately sized list of parameter objects.
The parameter objects within this list are built using an "all or nothing rule":
Expand Down Expand Up @@ -398,7 +396,7 @@ def apply_step(
try:
parameters_factory_impl = BROADCAST_RULE_TO_FACTORY_IMPL[rule]
except KeyError:
raise ak._v2._util.error(
raise ak._util.error(
ValueError(
f"`broadcast_parameters_rule` should be one of {[str(x) for x in BroadcastParameterRule]}, "
f"but this routine received `{rule}`"
Expand Down Expand Up @@ -512,7 +510,7 @@ def continuation():
if length is None:
length = tagslist[-1].shape[0]
elif length != tagslist[-1].shape[0]:
raise ak._v2._util.error(
raise ak._util.error(
ValueError(
"cannot broadcast UnionArray of length {} "
"with UnionArray of length {}{}".format(
Expand Down Expand Up @@ -687,7 +685,7 @@ def continuation():
elif x.size == maxsize:
nextinputs.append(x.content[: x.length * x.size])
else:
raise ak._v2._util.error(
raise ak._util.error(
ValueError(
"cannot broadcast RegularArray of size "
"{} with RegularArray of size {} {}".format(
Expand Down Expand Up @@ -826,7 +824,7 @@ def continuation():
for x, p in zip(outcontent, parameters)
)
else:
raise ak._v2._util.error(
raise ak._util.error(
AssertionError(
"unexpected offsets, starts: {}, {}".format(
type(offsets), type(starts)
Expand All @@ -837,7 +835,7 @@ def continuation():
# General list-handling case: the offsets of each list may be different.
else:
fcns = [
ak._v2._util.custom_broadcast(x, behavior)
ak._util.custom_broadcast(x, behavior)
if isinstance(x, Content)
else None
for x in inputs
Expand Down Expand Up @@ -908,7 +906,7 @@ def continuation():
# Any RecordArrays?
elif any(isinstance(x, RecordArray) for x in inputs):
if not options["allow_records"]:
raise ak._v2._util.error(
raise ak._util.error(
ValueError(f"cannot broadcast records {in_function(options)}")
)

Expand All @@ -918,7 +916,7 @@ def continuation():
if fields is None:
fields = x.fields
elif set(fields) != set(x.fields):
raise ak._v2._util.error(
raise ak._util.error(
ValueError(
"cannot broadcast records because fields don't "
"match{}:\n {}\n {}".format(
Expand All @@ -931,7 +929,7 @@ def continuation():
if length is None:
length = x.length
elif length != x.length:
raise ak._v2._util.error(
raise ak._util.error(
ValueError(
"cannot broadcast RecordArray of length {} "
"with RecordArray of length {}{}".format(
Expand Down Expand Up @@ -971,7 +969,7 @@ def continuation():
)

else:
raise ak._v2._util.error(
raise ak._util.error(
ValueError(
"cannot broadcast: {}{}".format(
", ".join(repr(type(x)) for x in inputs), in_function(options)
Expand All @@ -995,7 +993,7 @@ def continuation():
elif result is None:
return continuation()
else:
raise ak._v2._util.error(AssertionError(result))
raise ak._util.error(AssertionError(result))


def broadcast_and_apply(
Expand Down
Loading

0 comments on commit 9b7f7d0

Please sign in to comment.