diff --git a/dev/generate-tests.py b/dev/generate-tests.py index 65db73858d..f5f10da26c 100644 --- a/dev/generate-tests.py +++ b/dev/generate-tests.py @@ -674,7 +674,7 @@ def gencudakerneltests(specdict): ) f.write( - "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" + "import cupy\nimport pytest\n\nimport awkward as ak\nimport awkward._connect.cuda as ak_cu\n\ncupy_nplike = ak.nplikes.Cupy.instance()\n\n" ) num = 1 if spec.tests == []: diff --git a/docs-sphinx/prepare_docstrings.py b/docs-sphinx/prepare_docstrings.py index a9b7bd3ff8..7b9c5e04b6 100644 --- a/docs-sphinx/prepare_docstrings.py +++ b/docs-sphinx/prepare_docstrings.py @@ -280,7 +280,7 @@ def dofunction(link, linelink, shortname, name, astfcn): "awkwardforth.rst", ]) - if modulename.startswith("awkward._") or modulename == "awkward.nplike" or modulename == "awkward.types._awkward_datashape_parser": + if modulename.startswith("awkward._") or modulename == "awkward.nplikes" or modulename == "awkward.types._awkward_datashape_parser": continue # don't show awkward._*, including _v2 link = ("`{0} 1: diff --git a/src/awkward/behaviors/categorical.py b/src/awkward/behaviors/categorical.py index 84fcd4eb2a..a5fbdefeba 100644 --- a/src/awkward/behaviors/categorical.py +++ b/src/awkward/behaviors/categorical.py @@ -4,7 +4,7 @@ import awkward as ak from awkward.highlevel import Array -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() class CategoricalBehavior(Array): @@ -61,8 +61,8 @@ def _categorical_equal(one, two): assert one.parameter("__array__") == "categorical" assert two.parameter("__array__") == "categorical" - one_index = ak.nplike.numpy.asarray(one.index) - two_index = ak.nplike.numpy.asarray(two.index) + one_index = ak.nplikes.numpy.asarray(one.index) + two_index = ak.nplikes.numpy.asarray(two.index) one_content = ak._util.wrap(one.content, behavior) two_content = ak._util.wrap(two.content, behavior) @@ -78,7 +78,7 @@ def _categorical_equal(one, two): two_hashable = [as_hashable(x) for x in two_list] two_lookup = {x: i for i, x in enumerate(two_hashable)} - one_to_two = ak.nplike.numpy.empty(len(one_hashable) + 1, dtype=np.int64) + one_to_two = ak.nplikes.numpy.empty(len(one_hashable) + 1, dtype=np.int64) for i, x in enumerate(one_hashable): one_to_two[i] = two_lookup.get(x, len(two_hashable)) one_to_two[-1] = -1 @@ -105,5 +105,5 @@ def _apply_ufunc(ufunc, method, inputs, kwargs): def register(behavior): behavior["categorical"] = CategoricalBehavior - behavior[ak.nplike.numpy.equal, "categorical", "categorical"] = _categorical_equal - behavior[ak.nplike.numpy.ufunc, "categorical"] = _apply_ufunc + behavior[ak.nplikes.numpy.equal, "categorical", "categorical"] = _categorical_equal + behavior[ak.nplikes.numpy.ufunc, "categorical"] = _apply_ufunc diff --git a/src/awkward/behaviors/string.py b/src/awkward/behaviors/string.py index 15ccdac4f0..046c11268a 100644 --- a/src/awkward/behaviors/string.py +++ b/src/awkward/behaviors/string.py @@ -3,14 +3,14 @@ import awkward as ak from awkward.highlevel import Array -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() class ByteBehavior(Array): __name__ = "Array" def __bytes__(self): - tmp = ak.nplike.of(self.layout).asarray(self.layout) + tmp = ak.nplikes.nplike_of(self.layout).asarray(self.layout) if hasattr(tmp, "tobytes"): return tmp.tobytes() else: @@ -51,7 +51,7 @@ class CharBehavior(Array): __name__ = "Array" def __bytes__(self): - tmp = ak.nplike.of(self.layout).asarray(self.layout) + tmp = ak.nplikes.nplike_of(self.layout).asarray(self.layout) if hasattr(tmp, "tobytes"): return tmp.tobytes() else: @@ -105,7 +105,7 @@ def __iter__(self): def _string_equal(one, two): - nplike = ak.nplike.of(one, two) + nplike = ak.nplikes.nplike_of(one, two) behavior = ak._util.behavior_of(one, two) one, two = ( @@ -141,7 +141,7 @@ def _string_notequal(one, two): def _string_broadcast(layout, offsets): - nplike = ak.nplike.of(offsets) + nplike = ak.nplikes.nplike_of(offsets) offsets = nplike.asarray(offsets) counts = offsets[1:] - offsets[:-1] if ak._util.win or ak._util.bits32: @@ -247,10 +247,10 @@ def register(behavior): behavior["string"] = StringBehavior behavior["__typestr__", "string"] = "string" - behavior[ak.nplike.numpy.equal, "bytestring", "bytestring"] = _string_equal - behavior[ak.nplike.numpy.equal, "string", "string"] = _string_equal - behavior[ak.nplike.numpy.not_equal, "bytestring", "bytestring"] = _string_notequal - behavior[ak.nplike.numpy.not_equal, "string", "string"] = _string_notequal + behavior[ak.nplikes.numpy.equal, "bytestring", "bytestring"] = _string_equal + behavior[ak.nplikes.numpy.equal, "string", "string"] = _string_equal + behavior[ak.nplikes.numpy.not_equal, "bytestring", "bytestring"] = _string_notequal + behavior[ak.nplikes.numpy.not_equal, "string", "string"] = _string_notequal behavior["__broadcast__", "bytestring"] = _string_broadcast behavior["__broadcast__", "string"] = _string_broadcast diff --git a/src/awkward/contents/bitmaskedarray.py b/src/awkward/contents/bitmaskedarray.py index b2ceda84fe..397746bd25 100644 --- a/src/awkward/contents/bitmaskedarray.py +++ b/src/awkward/contents/bitmaskedarray.py @@ -10,8 +10,8 @@ from awkward.forms.bitmaskedform import BitMaskedForm from awkward.index import Index -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class BitMaskedArray(Content): diff --git a/src/awkward/contents/bytemaskedarray.py b/src/awkward/contents/bytemaskedarray.py index e8a2f1738d..39bff4bd53 100644 --- a/src/awkward/contents/bytemaskedarray.py +++ b/src/awkward/contents/bytemaskedarray.py @@ -9,8 +9,8 @@ from awkward.forms.bytemaskedform import ByteMaskedForm from awkward.index import Index -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class ByteMaskedArray(Content): diff --git a/src/awkward/contents/content.py b/src/awkward/contents/content.py index dd6456ed3c..600a317de3 100644 --- a/src/awkward/contents/content.py +++ b/src/awkward/contents/content.py @@ -8,8 +8,8 @@ import awkward as ak import awkward._reducers -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() # FIXME: use common Sentinel class for this unset = object() @@ -45,10 +45,10 @@ def _init(self, identifier, parameters, nplike): ) ) - if nplike is not None and not isinstance(nplike, ak.nplike.NumpyLike): + if nplike is not None and not isinstance(nplike, ak.nplikes.NumpyLike): raise ak._util.error( TypeError( - "{} 'nplike' must be an ak.nplike.NumpyLike or None, not {}".format( + "{} 'nplike' must be an ak.nplikes.NumpyLike or None, not {}".format( type(self).__name__, repr(nplike) ) ) diff --git a/src/awkward/contents/emptyarray.py b/src/awkward/contents/emptyarray.py index 5994752f31..83484e70b7 100644 --- a/src/awkward/contents/emptyarray.py +++ b/src/awkward/contents/emptyarray.py @@ -6,8 +6,8 @@ from awkward.contents.content import Content, unset from awkward.forms.emptyform import EmptyForm -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class EmptyArray(Content): diff --git a/src/awkward/contents/indexedarray.py b/src/awkward/contents/indexedarray.py index 981d91b849..11e137ff9e 100644 --- a/src/awkward/contents/indexedarray.py +++ b/src/awkward/contents/indexedarray.py @@ -7,8 +7,8 @@ from awkward.forms.indexedform import IndexedForm from awkward.index import Index -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class IndexedArray(Content): diff --git a/src/awkward/contents/indexedoptionarray.py b/src/awkward/contents/indexedoptionarray.py index 2654c7de62..606610b1cf 100644 --- a/src/awkward/contents/indexedoptionarray.py +++ b/src/awkward/contents/indexedoptionarray.py @@ -7,8 +7,8 @@ from awkward.forms.indexedoptionform import IndexedOptionForm from awkward.index import Index -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class IndexedOptionArray(Content): diff --git a/src/awkward/contents/listarray.py b/src/awkward/contents/listarray.py index 70dd9a3ef3..d721272bfc 100644 --- a/src/awkward/contents/listarray.py +++ b/src/awkward/contents/listarray.py @@ -8,7 +8,7 @@ from awkward.forms.listform import ListForm from awkward.index import Index -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() class ListArray(Content): diff --git a/src/awkward/contents/listoffsetarray.py b/src/awkward/contents/listoffsetarray.py index 4d84299770..619cb3a791 100644 --- a/src/awkward/contents/listoffsetarray.py +++ b/src/awkward/contents/listoffsetarray.py @@ -7,8 +7,8 @@ from awkward.forms.listoffsetform import ListOffsetForm from awkward.index import Index -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class ListOffsetArray(Content): diff --git a/src/awkward/contents/numpyarray.py b/src/awkward/contents/numpyarray.py index aee2174cb9..5cfc1c0330 100644 --- a/src/awkward/contents/numpyarray.py +++ b/src/awkward/contents/numpyarray.py @@ -7,8 +7,8 @@ from awkward.forms.numpyform import NumpyForm from awkward.types.numpytype import primitive_to_dtype -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class NumpyArray(Content): @@ -40,12 +40,12 @@ def __deepcopy__(self, memo): def __init__(self, data, identifier=None, parameters=None, nplike=None): if nplike is None: - nplike = ak.nplike.of(data) + nplike = ak.nplikes.nplike_of(data) if isinstance(data, ak.index.Index): data = data.data self._data = nplike.asarray(data) - if not isinstance(nplike, ak.nplike.Jax): + if not isinstance(nplike, ak.nplikes.Jax): ak.types.numpytype.dtype_to_primitive(self._data.dtype) if len(self._data.shape) == 0: raise ak._util.error( @@ -80,11 +80,11 @@ def dtype(self): @property def ptr(self): - if isinstance(self.nplike, ak.nplike.Numpy): + if isinstance(self.nplike, ak.nplikes.Numpy): return self._data.ctypes.data - elif isinstance(self.nplike, ak.nplike.Cupy): + elif isinstance(self.nplike, ak.nplikes.Cupy): return self._data.data.ptr - elif isinstance(self.nplike, ak.nplike.Jax): + elif isinstance(self.nplike, ak.nplikes.Jax): return self._data.device_buffer.unsafe_buffer_pointer() else: raise ak._util.error( @@ -521,7 +521,7 @@ def is_contiguous(self): # Alternatively, self._data.flags["C_CONTIGUOUS"], but the following assumes # less of the nplike. - if isinstance(self.nplike, ak.nplike.Jax): + if isinstance(self.nplike, ak.nplikes.Jax): return True x = self._data.dtype.itemsize @@ -1095,7 +1095,7 @@ def _reduce_next( behavior, ) - if isinstance(self.nplike, ak.nplike.Jax): + if isinstance(self.nplike, ak.nplikes.Jax): import awkward._connect.jax._reducers # noqa: F401 if isinstance(reducer, type): diff --git a/src/awkward/contents/recordarray.py b/src/awkward/contents/recordarray.py index 2923b64566..2a7542ff1a 100644 --- a/src/awkward/contents/recordarray.py +++ b/src/awkward/contents/recordarray.py @@ -9,8 +9,8 @@ from awkward.forms.recordform import RecordForm from awkward.record import Record -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class RecordArray(Content): diff --git a/src/awkward/contents/regulararray.py b/src/awkward/contents/regulararray.py index 58d771be4f..84e11bd847 100644 --- a/src/awkward/contents/regulararray.py +++ b/src/awkward/contents/regulararray.py @@ -6,8 +6,8 @@ from awkward.contents.content import Content, unset from awkward.forms.regularform import RegularForm -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class RegularArray(Content): diff --git a/src/awkward/contents/unionarray.py b/src/awkward/contents/unionarray.py index c43161d504..7de4702ad6 100644 --- a/src/awkward/contents/unionarray.py +++ b/src/awkward/contents/unionarray.py @@ -11,8 +11,8 @@ from awkward.forms.unionform import UnionForm from awkward.index import Index, Index8, Index64 -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class UnionArray(Content): @@ -321,7 +321,7 @@ def project(self, index): @staticmethod def regular_index(tags, IndexClass=Index64, nplike=None): if nplike is None: - nplike = ak.nplike.of(tags) + nplike = ak.nplikes.nplike_of(tags) lentags = tags.length size = ak.index.Index64.empty(1, nplike) @@ -370,7 +370,7 @@ def nested_tags_index( offsets, counts, TagsClass=Index8, IndexClass=Index64, nplike=None ): if nplike is None: - nplike = ak.nplike.of(offsets, counts) + nplike = ak.nplikes.nplike_of(offsets, counts) f_offsets = ak.index.Index64(copy.deepcopy(offsets.data)) contentlen = f_offsets[f_offsets.length - 1] diff --git a/src/awkward/contents/unmaskedarray.py b/src/awkward/contents/unmaskedarray.py index 3ed9c8c34b..8e844d6a33 100644 --- a/src/awkward/contents/unmaskedarray.py +++ b/src/awkward/contents/unmaskedarray.py @@ -6,8 +6,8 @@ from awkward.contents.content import Content, unset from awkward.forms.unmaskedform import UnmaskedForm -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() class UnmaskedArray(Content): diff --git a/src/awkward/forms/form.py b/src/awkward/forms/form.py index 017a088796..b2a90353a9 100644 --- a/src/awkward/forms/form.py +++ b/src/awkward/forms/form.py @@ -6,7 +6,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def from_iter(input): diff --git a/src/awkward/forms/numpyform.py b/src/awkward/forms/numpyform.py index 251eb5878b..eef8d80303 100644 --- a/src/awkward/forms/numpyform.py +++ b/src/awkward/forms/numpyform.py @@ -5,7 +5,7 @@ import awkward as ak from awkward.forms.form import Form, _parameters_equal -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def from_dtype(dtype, parameters=None): diff --git a/src/awkward/highlevel.py b/src/awkward/highlevel.py index 8cea367708..9c6154975e 100644 --- a/src/awkward/highlevel.py +++ b/src/awkward/highlevel.py @@ -10,8 +10,8 @@ import awkward as ak from awkward._connect.numpy import NDArrayOperatorsMixin -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() _dir_pattern = re.compile(r"^[a-zA-Z_]\w*$") diff --git a/src/awkward/identifier.py b/src/awkward/identifier.py index af9f22f491..683966f251 100644 --- a/src/awkward/identifier.py +++ b/src/awkward/identifier.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def _identifiers_equal(one, two): @@ -32,7 +32,7 @@ def __init__(self, ref, fieldloc, data): raise ak._util.error( TypeError("Identifier fieldloc must be a dict of int -> str") ) - self._nplike = ak.nplike.of(data) + self._nplike = ak.nplikes.nplike_of(data) self._data = self._nplike.asarray(data, order="C") if len(self._data.shape) != 2: diff --git a/src/awkward/index.py b/src/awkward/index.py index f071046763..26fa7692d0 100644 --- a/src/awkward/index.py +++ b/src/awkward/index.py @@ -4,7 +4,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() _dtype_to_form = { np.dtype(np.int8): "i8", @@ -20,7 +20,7 @@ class Index: def __init__(self, data, metadata=None, nplike=None): if nplike is None: - nplike = ak.nplike.of(data) + nplike = ak.nplikes.nplike_of(data) self._nplike = nplike if metadata is not None and not isinstance(metadata, dict): raise ak._util.error(TypeError("Index metadata must be None or a dict")) @@ -165,7 +165,7 @@ def __getitem__(self, where): if hasattr(out, "shape") and len(out.shape) != 0: return Index(out, metadata=self.metadata, nplike=self.nplike) - elif (ak.nplike.is_jax_buffer(out) or ak.nplike.is_cupy_buffer(out)) and len( + elif (ak.nplikes.is_jax_buffer(out) or ak.nplikes.is_cupy_buffer(out)) and len( out.shape ) == 0: return out.item() @@ -198,7 +198,7 @@ def to_backend(self, backend): return self._to_nplike(ak._util.regularize_backend(backend)) def _to_nplike(self, nplike): - # if isinstance(nplike, ak.nplike.Jax): + # if isinstance(nplike, ak.nplikes.Jax): # print("YES OFFICER, this nplike right here") return Index(self.raw(nplike), metadata=self.metadata, nplike=nplike) diff --git a/src/awkward/nplike.py b/src/awkward/nplikes.py similarity index 98% rename from src/awkward/nplike.py rename to src/awkward/nplikes.py index 4aa63db4b9..32094fd5ba 100644 --- a/src/awkward/nplike.py +++ b/src/awkward/nplikes.py @@ -717,7 +717,7 @@ def array_str( class Jax(NumpyLike): @property def index_nplike(self): - return ak.nplike.Numpy.instance() + return ak.nplikes.Numpy.instance() def to_rectilinear(self, array, *args, **kwargs): if isinstance(array, self._module.DeviceArray): @@ -796,11 +796,11 @@ def ascontiguousarray(self, array, dtype=None): def raw(self, array, nplike): if isinstance(nplike, Jax): return array - elif isinstance(nplike, ak.nplike.Cupy): - cupy = ak.nplike.Cupy.instance() + elif isinstance(nplike, ak.nplikes.Cupy): + cupy = ak.nplikes.Cupy.instance() return cupy.asarray(array) - elif isinstance(nplike, ak.nplike.Numpy): - numpy = ak.nplike.Numpy.instance() + elif isinstance(nplike, ak.nplikes.Numpy): + numpy = ak.nplikes.Numpy.instance() return numpy.asarray(array) elif isinstance(nplike, ak._typetracer.TypeTracer): return ak._typetracer.TypeTracerArray(dtype=array.dtype, shape=array.shape) @@ -866,13 +866,13 @@ def is_jax_tracer(tracer): return type(tracer).__module__.startswith("jax.") -def of(*arrays, default_cls=Numpy): +def nplike_of(*arrays, default_cls=Numpy): """ Args: *arrays: iterable of possible array objects default_cls: default NumpyLike class if no array objects found - Return the #ak.nplike.NumpyLike that is best-suited to operating upon the given + Return the #ak.nplikes.NumpyLike that is best-suited to operating upon the given iterable of arrays. Return an instance of the `default_cls` if no known array types are found. """ diff --git a/src/awkward/operations/ak_all.py b/src/awkward/operations/ak_all.py index 38ef43a39a..ac7536237b 100644 --- a/src/awkward/operations/ak_all.py +++ b/src/awkward/operations/ak_all.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("all") diff --git a/src/awkward/operations/ak_any.py b/src/awkward/operations/ak_any.py index 9d80b28e08..8550ade6b2 100644 --- a/src/awkward/operations/ak_any.py +++ b/src/awkward/operations/ak_any.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("any") diff --git a/src/awkward/operations/ak_argcartesian.py b/src/awkward/operations/ak_argcartesian.py index ec5c8cfad3..aa5d7df693 100644 --- a/src/awkward/operations/ak_argcartesian.py +++ b/src/awkward/operations/ak_argcartesian.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def argcartesian( diff --git a/src/awkward/operations/ak_argcombinations.py b/src/awkward/operations/ak_argcombinations.py index 64a43bb64b..d4608bb437 100644 --- a/src/awkward/operations/ak_argcombinations.py +++ b/src/awkward/operations/ak_argcombinations.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def argcombinations( diff --git a/src/awkward/operations/ak_argmax.py b/src/awkward/operations/ak_argmax.py index f4997af3fa..5b29aeef09 100644 --- a/src/awkward/operations/ak_argmax.py +++ b/src/awkward/operations/ak_argmax.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("argmax") diff --git a/src/awkward/operations/ak_argmin.py b/src/awkward/operations/ak_argmin.py index 00fc1e97d8..5593513afe 100644 --- a/src/awkward/operations/ak_argmin.py +++ b/src/awkward/operations/ak_argmin.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("argmin") diff --git a/src/awkward/operations/ak_argsort.py b/src/awkward/operations/ak_argsort.py index b5112a6955..690fb52ad1 100644 --- a/src/awkward/operations/ak_argsort.py +++ b/src/awkward/operations/ak_argsort.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("argsort") diff --git a/src/awkward/operations/ak_backend.py b/src/awkward/operations/ak_backend.py index 32a434573a..4200e5cc47 100644 --- a/src/awkward/operations/ak_backend.py +++ b/src/awkward/operations/ak_backend.py @@ -48,13 +48,13 @@ def _impl(arrays): allow_other=True, ) if isinstance(layout, (ak.contents.Content, ak.index.Index)): - if isinstance(layout.nplike, ak.nplike.Numpy): + if isinstance(layout.nplike, ak.nplikes.Numpy): backends.add("cpu") - elif isinstance(layout.nplike, ak.nplike.Cupy): + elif isinstance(layout.nplike, ak.nplikes.Cupy): backends.add("cuda") - elif isinstance(layout.nplike, ak.nplike.Jax): + elif isinstance(layout.nplike, ak.nplikes.Jax): backends.add("jax") - elif isinstance(layout, ak.nplike.numpy.ndarray): + elif isinstance(layout, ak.nplikes.numpy.ndarray): backends.add("cpu") elif type(layout).__module__.startswith("cupy."): backends.add("cuda") diff --git a/src/awkward/operations/ak_broadcast_arrays.py b/src/awkward/operations/ak_broadcast_arrays.py index f92e4dc0e5..09f7ab40bc 100644 --- a/src/awkward/operations/ak_broadcast_arrays.py +++ b/src/awkward/operations/ak_broadcast_arrays.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("broadcast_arrays") @@ -167,7 +167,7 @@ def _impl(arrays, kwargs): for x in arrays: y = ak.operations.to_layout(x, allow_record=True, allow_other=True) if not isinstance(y, (ak.contents.Content, ak.Record)): - y = ak.contents.NumpyArray(ak.nplike.of(*arrays).array([y])) + y = ak.contents.NumpyArray(ak.nplikes.nplike_of(*arrays).array([y])) inputs.append(y) def action(inputs, depth, **kwargs): diff --git a/src/awkward/operations/ak_cartesian.py b/src/awkward/operations/ak_cartesian.py index a885717523..4e3151fabe 100644 --- a/src/awkward/operations/ak_cartesian.py +++ b/src/awkward/operations/ak_cartesian.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def cartesian( @@ -232,7 +232,7 @@ def cartesian( def _impl(arrays, axis, nested, parameters, with_name, highlevel, behavior): if isinstance(arrays, dict): behavior = ak._util.behavior_of(*arrays.values(), behavior=behavior) - nplike = ak.nplike.of(*arrays.values()) + nplike = ak.nplikes.nplike_of(*arrays.values()) new_arrays = {} for n, x in arrays.items(): new_arrays[n] = ak.operations.to_layout( @@ -242,7 +242,7 @@ def _impl(arrays, axis, nested, parameters, with_name, highlevel, behavior): else: arrays = list(arrays) behavior = ak._util.behavior_of(*arrays, behavior=behavior) - nplike = ak.nplike.of(*arrays) + nplike = ak.nplikes.nplike_of(*arrays) new_arrays = [] for x in arrays: new_arrays.append( diff --git a/src/awkward/operations/ak_combinations.py b/src/awkward/operations/ak_combinations.py index 554e5d7eea..e978e8f2eb 100644 --- a/src/awkward/operations/ak_combinations.py +++ b/src/awkward/operations/ak_combinations.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def combinations( diff --git a/src/awkward/operations/ak_concatenate.py b/src/awkward/operations/ak_concatenate.py index 682f9904db..8a75ce5e31 100644 --- a/src/awkward/operations/ak_concatenate.py +++ b/src/awkward/operations/ak_concatenate.py @@ -3,7 +3,7 @@ import awkward as ak from awkward.operations.ak_fill_none import fill_none -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("concatenate") @@ -50,14 +50,14 @@ def concatenate( def _impl(arrays, axis, merge, mergebool, highlevel, behavior): # Simple single-array, axis=0 fast-path - single_nplike = ak.nplike.of(arrays) + single_nplike = ak.nplikes.nplike_of(arrays) if ( # Is an Awkward Content isinstance(arrays, ak.contents.Content) # Is a NumPy Array - or ak.nplike.is_numpy_buffer(arrays) + or ak.nplikes.is_numpy_buffer(arrays) # Is an array with a known NumpyLike - or single_nplike is not ak.nplike.Numpy.instance() + or single_nplike is not ak.nplikes.Numpy.instance() ): # Convert the array to a layout object content = ak.operations.to_layout(arrays, allow_record=False, allow_other=False) @@ -132,7 +132,7 @@ def action(inputs, depth, **kwargs): inputs = nextinputs if depth == posaxis: - nplike = ak.nplike.of(*inputs) + nplike = ak.nplikes.nplike_of(*inputs) length = ak._typetracer.UnknownLength for x in inputs: diff --git a/src/awkward/operations/ak_copy.py b/src/awkward/operations/ak_copy.py index f898bf83f9..eb09234e8a 100644 --- a/src/awkward/operations/ak_copy.py +++ b/src/awkward/operations/ak_copy.py @@ -4,7 +4,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("copy") diff --git a/src/awkward/operations/ak_corr.py b/src/awkward/operations/ak_corr.py index 4f46618587..42533ed926 100644 --- a/src/awkward/operations/ak_corr.py +++ b/src/awkward/operations/ak_corr.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def corr( @@ -123,5 +123,5 @@ def _impl(x, y, weight, axis, keepdims, mask_identity, flatten_records): mask_identity, flatten_records, ) - nplike = ak.nplike.of(sumwxy, sumwxx, sumwyy) + nplike = ak.nplikes.nplike_of(sumwxy, sumwxx, sumwyy) return nplike.true_divide(sumwxy, nplike.sqrt(sumwxx * sumwyy)) diff --git a/src/awkward/operations/ak_count.py b/src/awkward/operations/ak_count.py index 7b10ab40a2..7f4cc276c9 100644 --- a/src/awkward/operations/ak_count.py +++ b/src/awkward/operations/ak_count.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def count(array, axis=None, keepdims=False, mask_identity=False, flatten_records=False): diff --git a/src/awkward/operations/ak_count_nonzero.py b/src/awkward/operations/ak_count_nonzero.py index 8e2f36fd20..b496b72032 100644 --- a/src/awkward/operations/ak_count_nonzero.py +++ b/src/awkward/operations/ak_count_nonzero.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("count_nonzero") diff --git a/src/awkward/operations/ak_covar.py b/src/awkward/operations/ak_covar.py index 1f7947bd5e..737557e18c 100644 --- a/src/awkward/operations/ak_covar.py +++ b/src/awkward/operations/ak_covar.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def covar( @@ -113,4 +113,4 @@ def _impl(x, y, weight, axis, keepdims, mask_identity, flatten_records): mask_identity, flatten_records, ) - return ak.nplike.of(sumwxy, sumw).true_divide(sumwxy, sumw) + return ak.nplikes.nplike_of(sumwxy, sumw).true_divide(sumwxy, sumw) diff --git a/src/awkward/operations/ak_fields.py b/src/awkward/operations/ak_fields.py index 9b4d65ed19..52f1cb1eb9 100644 --- a/src/awkward/operations/ak_fields.py +++ b/src/awkward/operations/ak_fields.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def fields(array): diff --git a/src/awkward/operations/ak_fill_none.py b/src/awkward/operations/ak_fill_none.py index 5d2790e609..635c9f18e8 100644 --- a/src/awkward/operations/ak_fill_none.py +++ b/src/awkward/operations/ak_fill_none.py @@ -5,7 +5,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def fill_none(array, value, axis=-1, highlevel=True, behavior=None): @@ -60,7 +60,7 @@ def fill_none(array, value, axis=-1, highlevel=True, behavior=None): def _impl(array, value, axis, highlevel, behavior): arraylayout = ak.operations.to_layout(array, allow_record=True, allow_other=False) - nplike = ak.nplike.of(arraylayout) + nplike = ak.nplikes.nplike_of(arraylayout) # Convert value type to appropriate layout if ( diff --git a/src/awkward/operations/ak_firsts.py b/src/awkward/operations/ak_firsts.py index eaf03b7dd9..b2b353cee8 100644 --- a/src/awkward/operations/ak_firsts.py +++ b/src/awkward/operations/ak_firsts.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def firsts(array, axis=1, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_flatten.py b/src/awkward/operations/ak_flatten.py index a7b60d5161..aeff5afab5 100644 --- a/src/awkward/operations/ak_flatten.py +++ b/src/awkward/operations/ak_flatten.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def flatten(array, axis=1, highlevel=True, behavior=None): @@ -99,7 +99,7 @@ def flatten(array, axis=1, highlevel=True, behavior=None): def _impl(array, axis, highlevel, behavior): layout = ak.operations.to_layout(array, allow_record=False, allow_other=False) - nplike = ak.nplike.of(layout) + nplike = ak.nplikes.nplike_of(layout) if axis is None: out = layout.completely_flatten(function_name="ak.flatten") diff --git a/src/awkward/operations/ak_from_arrow.py b/src/awkward/operations/ak_from_arrow.py index ffcbb14315..d2b2c21442 100644 --- a/src/awkward/operations/ak_from_arrow.py +++ b/src/awkward/operations/ak_from_arrow.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def from_arrow(array, generate_bitmasks=False, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_from_arrow_schema.py b/src/awkward/operations/ak_from_arrow_schema.py index a1663b5c00..378e77aecf 100644 --- a/src/awkward/operations/ak_from_arrow_schema.py +++ b/src/awkward/operations/ak_from_arrow_schema.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def from_arrow_schema(schema): diff --git a/src/awkward/operations/ak_from_avro_file.py b/src/awkward/operations/ak_from_avro_file.py index e60e632d64..e2000a6c43 100644 --- a/src/awkward/operations/ak_from_avro_file.py +++ b/src/awkward/operations/ak_from_avro_file.py @@ -5,7 +5,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def from_avro_file( diff --git a/src/awkward/operations/ak_from_buffers.py b/src/awkward/operations/ak_from_buffers.py index 3f6758a871..792ce4a292 100644 --- a/src/awkward/operations/ak_from_buffers.py +++ b/src/awkward/operations/ak_from_buffers.py @@ -4,8 +4,8 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() def from_buffers( @@ -30,8 +30,8 @@ def from_buffers( `"{form_key}"` and/or `"{attribute}"` or a function that takes these as keyword arguments and returns a string to use as a key for a buffer in the `container`. - nplike (#ak.nplike.NumpyLike): Library to use to generate values that are - put into the new array. The default, #ak.nplike.Numpy, makes NumPy + nplike (#ak.nplikes.NumpyLike): Library to use to generate values that are + put into the new array. The default, #ak.nplikes.Numpy, makes NumPy arrays, which are in main memory (e.g. not GPU). If all the values in `container` have the same `nplike` as this, they won't be copied. highlevel (bool): If True, return an #ak.Array; otherwise, return diff --git a/src/awkward/operations/ak_from_iter.py b/src/awkward/operations/ak_from_iter.py index 9e363fd86a..d2244ab24a 100644 --- a/src/awkward/operations/ak_from_iter.py +++ b/src/awkward/operations/ak_from_iter.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def from_iter( diff --git a/src/awkward/operations/ak_from_json.py b/src/awkward/operations/ak_from_json.py index 2a3a0d0e56..bc8b341867 100644 --- a/src/awkward/operations/ak_from_json.py +++ b/src/awkward/operations/ak_from_json.py @@ -7,8 +7,8 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() def from_json( diff --git a/src/awkward/operations/ak_from_parquet.py b/src/awkward/operations/ak_from_parquet.py index 51345fe34c..2421671a96 100644 --- a/src/awkward/operations/ak_from_parquet.py +++ b/src/awkward/operations/ak_from_parquet.py @@ -234,7 +234,7 @@ def _load( ) if len(arrays) == 0: - numpy = ak.nplike.Numpy.instance() + numpy = ak.nplikes.Numpy.instance() return ak.operations.ak_from_buffers._impl( subform, 0, _DictOfEmptyBuffers(), "", numpy, highlevel, behavior ) diff --git a/src/awkward/operations/ak_from_regular.py b/src/awkward/operations/ak_from_regular.py index 09ed6b3480..905876bfda 100644 --- a/src/awkward/operations/ak_from_regular.py +++ b/src/awkward/operations/ak_from_regular.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def from_regular(array, axis=1, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_full_like.py b/src/awkward/operations/ak_full_like.py index 7073ef8559..bbdbcb711e 100644 --- a/src/awkward/operations/ak_full_like.py +++ b/src/awkward/operations/ak_full_like.py @@ -3,7 +3,7 @@ import awkward as ak from awkward.operations.ak_zeros_like import _ZEROS -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("full_like") @@ -88,7 +88,7 @@ def _impl(array, fill_value, highlevel, behavior, dtype): # In the case of strings and byte strings, # converting the fill avoids a ValueError. dtype = np.dtype(dtype) - nplike = ak.nplike.of(array) + nplike = ak.nplikes.nplike_of(array) fill_value = nplike.array([fill_value], dtype=dtype)[0] # Also, if the fill_value cannot be converted to the dtype # this should throw a clear, early, error. @@ -100,7 +100,7 @@ def _impl(array, fill_value, highlevel, behavior, dtype): def action(layout, **kwargs): if layout.parameter("__array__") == "bytestring" and fill_value is _ZEROS: - nplike = ak.nplike.of(layout) + nplike = ak.nplikes.nplike_of(layout) asbytes = nplike.frombuffer(b"", dtype=np.uint8) return ak.contents.ListArray( ak.index.Index64( @@ -116,7 +116,7 @@ def action(layout, **kwargs): ) elif layout.parameter("__array__") == "bytestring": - nplike = ak.nplike.of(layout) + nplike = ak.nplikes.nplike_of(layout) if isinstance(fill_value, bytes): asbytes = fill_value else: @@ -136,7 +136,7 @@ def action(layout, **kwargs): ) elif layout.parameter("__array__") == "string" and fill_value is _ZEROS: - nplike = ak.nplike.of(layout) + nplike = ak.nplikes.nplike_of(layout) asbytes = nplike.frombuffer(b"", dtype=np.uint8) return ak.contents.ListArray( ak.index.Index64( @@ -152,7 +152,7 @@ def action(layout, **kwargs): ) elif layout.parameter("__array__") == "string": - nplike = ak.nplike.of(layout) + nplike = ak.nplikes.nplike_of(layout) asstr = str(fill_value).encode("utf-8", "surrogateescape") asbytes = nplike.frombuffer(asstr, dtype=np.uint8) return ak.contents.ListArray( @@ -168,7 +168,7 @@ def action(layout, **kwargs): ) elif isinstance(layout, ak.contents.NumpyArray): - nplike = ak.nplike.of(layout) + nplike = ak.nplikes.nplike_of(layout) original = nplike.asarray(layout.data) if fill_value == 0 or fill_value is _ZEROS: diff --git a/src/awkward/operations/ak_is_none.py b/src/awkward/operations/ak_is_none.py index 1ba8f911a4..49f38eeb92 100644 --- a/src/awkward/operations/ak_is_none.py +++ b/src/awkward/operations/ak_is_none.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def is_none(array, axis=0, highlevel=True, behavior=None): @@ -36,7 +36,7 @@ def getfunction_inner(layout, depth, **kwargs): if not isinstance(layout, ak.contents.Content): return - nplike = ak.nplike.of(layout) + nplike = ak.nplikes.nplike_of(layout) if layout.is_OptionType: layout = layout.toIndexedOptionArray64() diff --git a/src/awkward/operations/ak_isclose.py b/src/awkward/operations/ak_isclose.py index a4f085b563..9be652762b 100644 --- a/src/awkward/operations/ak_isclose.py +++ b/src/awkward/operations/ak_isclose.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() ### FIXME: ak._connect.numpy.implements needs to exist! diff --git a/src/awkward/operations/ak_linear_fit.py b/src/awkward/operations/ak_linear_fit.py index fe5e05dfa1..75e7882548 100644 --- a/src/awkward/operations/ak_linear_fit.py +++ b/src/awkward/operations/ak_linear_fit.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def linear_fit( @@ -96,7 +96,7 @@ def _impl(x, y, weight, axis, keepdims, mask_identity, flatten_records): ) with np.errstate(invalid="ignore"): - nplike = ak.nplike.of(x, y, weight) + nplike = ak.nplikes.nplike_of(x, y, weight) if weight is None: sumw = ak.operations.ak_count._impl( x, axis, keepdims, mask_identity, flatten_records diff --git a/src/awkward/operations/ak_local_index.py b/src/awkward/operations/ak_local_index.py index 2f0fc4c1e4..cf4945ea2f 100644 --- a/src/awkward/operations/ak_local_index.py +++ b/src/awkward/operations/ak_local_index.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def local_index(array, axis=-1, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_mask.py b/src/awkward/operations/ak_mask.py index f9a160a031..a637ebf106 100644 --- a/src/awkward/operations/ak_mask.py +++ b/src/awkward/operations/ak_mask.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def mask(array, mask, valid_when=True, highlevel=True, behavior=None): @@ -102,7 +102,7 @@ def _impl(array, mask, valid_when, highlevel, behavior): def action(inputs, **kwargs): layoutarray, layoutmask = inputs if isinstance(layoutmask, ak.contents.NumpyArray): - m = ak.nplike.of(layoutmask).asarray(layoutmask) + m = ak.nplikes.nplike_of(layoutmask).asarray(layoutmask) if not issubclass(m.dtype.type, (bool, np.bool_)): raise ak._util.error( ValueError( diff --git a/src/awkward/operations/ak_max.py b/src/awkward/operations/ak_max.py index c039a454f2..441c461f19 100644 --- a/src/awkward/operations/ak_max.py +++ b/src/awkward/operations/ak_max.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("max") diff --git a/src/awkward/operations/ak_mean.py b/src/awkward/operations/ak_mean.py index 7c1ce9668f..46c32a7f98 100644 --- a/src/awkward/operations/ak_mean.py +++ b/src/awkward/operations/ak_mean.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("mean") @@ -170,4 +170,4 @@ def _impl(x, weight, axis, keepdims, mask_identity, flatten_records): sumwx = ak.operations.ak_sum._impl( x * weight, axis, keepdims, mask_identity, flatten_records ) - return ak.nplike.of(sumwx, sumw).true_divide(sumwx, sumw) + return ak.nplikes.nplike_of(sumwx, sumw).true_divide(sumwx, sumw) diff --git a/src/awkward/operations/ak_metadata_from_parquet.py b/src/awkward/operations/ak_metadata_from_parquet.py index bfba9532e1..e3e30327ca 100644 --- a/src/awkward/operations/ak_metadata_from_parquet.py +++ b/src/awkward/operations/ak_metadata_from_parquet.py @@ -4,7 +4,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() ParquetMetadata = collections.namedtuple( diff --git a/src/awkward/operations/ak_min.py b/src/awkward/operations/ak_min.py index 6efc2f65a0..a3b84406f6 100644 --- a/src/awkward/operations/ak_min.py +++ b/src/awkward/operations/ak_min.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("min") diff --git a/src/awkward/operations/ak_moment.py b/src/awkward/operations/ak_moment.py index f6a38401b5..9505dd3bd3 100644 --- a/src/awkward/operations/ak_moment.py +++ b/src/awkward/operations/ak_moment.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def moment( @@ -104,4 +104,4 @@ def _impl(x, n, weight, axis, keepdims, mask_identity, flatten_records): mask_identity, flatten_records, ) - return ak.nplike.of(sumwxn, sumw).true_divide(sumwxn, sumw) + return ak.nplikes.nplike_of(sumwxn, sumw).true_divide(sumwxn, sumw) diff --git a/src/awkward/operations/ak_nan_to_none.py b/src/awkward/operations/ak_nan_to_none.py index 181c2071fe..8f0bd7e839 100644 --- a/src/awkward/operations/ak_nan_to_none.py +++ b/src/awkward/operations/ak_nan_to_none.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def nan_to_none(array, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_nan_to_num.py b/src/awkward/operations/ak_nan_to_num.py index 2bd1d649ca..98afac9631 100644 --- a/src/awkward/operations/ak_nan_to_num.py +++ b/src/awkward/operations/ak_nan_to_num.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("nan_to_num") @@ -68,7 +68,7 @@ def _impl(array, copy, nan, posinf, neginf, highlevel, behavior): broadcasting_ids[id(neginf)] = len(broadcasting) broadcasting.append(neginf_layout) - nplike = ak.nplike.of(layout) + nplike = ak.nplikes.nplike_of(layout) if len(broadcasting) == 1: diff --git a/src/awkward/operations/ak_num.py b/src/awkward/operations/ak_num.py index 130a55691b..0ac7087af4 100644 --- a/src/awkward/operations/ak_num.py +++ b/src/awkward/operations/ak_num.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def num(array, axis=1, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_ones_like.py b/src/awkward/operations/ak_ones_like.py index 59dd28845d..fdb5813c2a 100644 --- a/src/awkward/operations/ak_ones_like.py +++ b/src/awkward/operations/ak_ones_like.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("ones_like") diff --git a/src/awkward/operations/ak_packed.py b/src/awkward/operations/ak_packed.py index c4a202edba..24fbae6fca 100644 --- a/src/awkward/operations/ak_packed.py +++ b/src/awkward/operations/ak_packed.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def packed(array, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_pad_none.py b/src/awkward/operations/ak_pad_none.py index bb8c998986..ac677bbbab 100644 --- a/src/awkward/operations/ak_pad_none.py +++ b/src/awkward/operations/ak_pad_none.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def pad_none(array, target, axis=1, clip=False, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_parameters.py b/src/awkward/operations/ak_parameters.py index 6164530793..09265034e6 100644 --- a/src/awkward/operations/ak_parameters.py +++ b/src/awkward/operations/ak_parameters.py @@ -5,7 +5,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def parameters(array): diff --git a/src/awkward/operations/ak_prod.py b/src/awkward/operations/ak_prod.py index 61774504cb..ca4a977319 100644 --- a/src/awkward/operations/ak_prod.py +++ b/src/awkward/operations/ak_prod.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("prod") diff --git a/src/awkward/operations/ak_ptp.py b/src/awkward/operations/ak_ptp.py index 757a93eb38..a2d49d70b0 100644 --- a/src/awkward/operations/ak_ptp.py +++ b/src/awkward/operations/ak_ptp.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("ptp") diff --git a/src/awkward/operations/ak_ravel.py b/src/awkward/operations/ak_ravel.py index 17c9fa4af9..f271128a90 100644 --- a/src/awkward/operations/ak_ravel.py +++ b/src/awkward/operations/ak_ravel.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("ravel") @@ -50,7 +50,7 @@ def ravel(array, highlevel=True, behavior=None): def _impl(array, highlevel, behavior): layout = ak.operations.to_layout(array, allow_record=False, allow_other=False) - nplike = ak.nplike.of(layout) + nplike = ak.nplikes.nplike_of(layout) out = layout.completely_flatten(function_name="ak.ravel") assert isinstance(out, tuple) and all(isinstance(x, nplike.ndarray) for x in out) diff --git a/src/awkward/operations/ak_run_lengths.py b/src/awkward/operations/ak_run_lengths.py index b348110649..ffbbe9cffc 100644 --- a/src/awkward/operations/ak_run_lengths.py +++ b/src/awkward/operations/ak_run_lengths.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def run_lengths(array, highlevel=True, behavior=None): @@ -95,7 +95,7 @@ def run_lengths(array, highlevel=True, behavior=None): def _impl(array, highlevel, behavior): - nplike = ak.nplike.of(array) + nplike = ak.nplikes.nplike_of(array) def lengths_of(data, offsets): if len(data) == 0: diff --git a/src/awkward/operations/ak_singletons.py b/src/awkward/operations/ak_singletons.py index 70bfce8eb2..5b7a5a0f32 100644 --- a/src/awkward/operations/ak_singletons.py +++ b/src/awkward/operations/ak_singletons.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def singletons(array, highlevel=True, behavior=None): @@ -35,7 +35,7 @@ def singletons(array, highlevel=True, behavior=None): def _impl(array, highlevel, behavior): def action(layout, **kwargs): - nplike = ak.nplike.of(layout) + nplike = ak.nplikes.nplike_of(layout) if layout.is_OptionType: nulls = nplike.index_nplike.asarray( diff --git a/src/awkward/operations/ak_softmax.py b/src/awkward/operations/ak_softmax.py index dbca251dfa..10e415fe89 100644 --- a/src/awkward/operations/ak_softmax.py +++ b/src/awkward/operations/ak_softmax.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def softmax(x, axis=None, keepdims=False, mask_identity=False, flatten_records=False): @@ -59,7 +59,7 @@ def _impl(x, axis, keepdims, mask_identity, flatten_records): ) with np.errstate(invalid="ignore"): - nplike = ak.nplike.of(x) + nplike = ak.nplikes.nplike_of(x) expx = nplike.exp(x) denom = ak.operations.ak_sum._impl( expx, axis, keepdims, mask_identity, flatten_records diff --git a/src/awkward/operations/ak_sort.py b/src/awkward/operations/ak_sort.py index 3e70d20ec7..80d3a25504 100644 --- a/src/awkward/operations/ak_sort.py +++ b/src/awkward/operations/ak_sort.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("sort") diff --git a/src/awkward/operations/ak_std.py b/src/awkward/operations/ak_std.py index 05f448553a..2451e7c60f 100644 --- a/src/awkward/operations/ak_std.py +++ b/src/awkward/operations/ak_std.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("std") @@ -150,7 +150,7 @@ def _impl(x, weight, ddof, axis, keepdims, mask_identity, flatten_records): ) with np.errstate(invalid="ignore"): - return ak.nplike.of(x, weight).sqrt( + return ak.nplikes.nplike_of(x, weight).sqrt( ak.operations.ak_var._impl( x, weight, diff --git a/src/awkward/operations/ak_strings_astype.py b/src/awkward/operations/ak_strings_astype.py index fa2e4b3b88..a37c334294 100644 --- a/src/awkward/operations/ak_strings_astype.py +++ b/src/awkward/operations/ak_strings_astype.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def strings_astype(array, to, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_sum.py b/src/awkward/operations/ak_sum.py index fa51b2e7bf..3d785fd9c7 100644 --- a/src/awkward/operations/ak_sum.py +++ b/src/awkward/operations/ak_sum.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("sum") diff --git a/src/awkward/operations/ak_to_arrow.py b/src/awkward/operations/ak_to_arrow.py index 879cc98f5d..8dce65cafa 100644 --- a/src/awkward/operations/ak_to_arrow.py +++ b/src/awkward/operations/ak_to_arrow.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def to_arrow( diff --git a/src/awkward/operations/ak_to_arrow_table.py b/src/awkward/operations/ak_to_arrow_table.py index 1436b073ae..235b169520 100644 --- a/src/awkward/operations/ak_to_arrow_table.py +++ b/src/awkward/operations/ak_to_arrow_table.py @@ -4,7 +4,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def to_arrow_table( diff --git a/src/awkward/operations/ak_to_backend.py b/src/awkward/operations/ak_to_backend.py index e559cd4c52..89069e3d25 100644 --- a/src/awkward/operations/ak_to_backend.py +++ b/src/awkward/operations/ak_to_backend.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def to_backend(array, backend, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_to_buffers.py b/src/awkward/operations/ak_to_buffers.py index 2aff89b431..ca6814fe3a 100644 --- a/src/awkward/operations/ak_to_buffers.py +++ b/src/awkward/operations/ak_to_buffers.py @@ -2,8 +2,8 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() def to_buffers( @@ -36,8 +36,8 @@ def to_buffers( id_start (int): Starting `id` to use in `form_key` and hence `buffer_key`. This integer increases in a depth-first walk over the `array` nodes and can be used to generate unique keys for each Form. - nplike (#ak.nplike.NumpyLike): Library to use to generate values that are - put into the `container`. The default, #ak.nplike.Numpy, makes NumPy + nplike (#ak.nplikes.NumpyLike): Library to use to generate values that are + put into the `container`. The default, #ak.nplikes.Numpy, makes NumPy arrays, which are in main memory (e.g. not GPU) and satisfy Python's Buffer protocol. If all the buffers in `array` have the same `nplike` as this, they won't be copied. diff --git a/src/awkward/operations/ak_to_categorical.py b/src/awkward/operations/ak_to_categorical.py index ec259ea8e2..60e6ce84d5 100644 --- a/src/awkward/operations/ak_to_categorical.py +++ b/src/awkward/operations/ak_to_categorical.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def to_categorical(array, highlevel=True): @@ -100,8 +100,8 @@ def action(layout, **kwargs): hashable = [ak.behaviors.categorical.as_hashable(x) for x in content_list] lookup = {} - is_first = ak.nplike.numpy.empty(len(hashable), dtype=np.bool_) - mapping = ak.nplike.numpy.empty(len(hashable), dtype=np.int64) + is_first = ak.nplikes.numpy.empty(len(hashable), dtype=np.bool_) + mapping = ak.nplikes.numpy.empty(len(hashable), dtype=np.int64) for i, x in enumerate(hashable): if x in lookup: is_first[i] = False @@ -112,17 +112,17 @@ def action(layout, **kwargs): mapping[i] = j if layout.is_IndexedType and layout.is_OptionType: - original_index = ak.nplike.numpy.asarray(layout.index) + original_index = ak.nplikes.numpy.asarray(layout.index) index = mapping[original_index] index[original_index < 0] = -1 index = ak.index.Index64(index) elif layout.is_IndexedType: - original_index = ak.nplike.numpy.asarray(layout.index) + original_index = ak.nplikes.numpy.asarray(layout.index) index = ak.index.Index64(mapping[original_index]) elif layout.is_OptionType: - mask = ak.nplike.numpy.asarray(layout.mask_as_bool(valid_when=False)) + mask = ak.nplikes.numpy.asarray(layout.mask_as_bool(valid_when=False)) mapping[mask.view(np.bool_)] = -1 index = ak.index.Index64(mapping) diff --git a/src/awkward/operations/ak_to_dataframe.py b/src/awkward/operations/ak_to_dataframe.py index 857fe3197a..388b7caec6 100644 --- a/src/awkward/operations/ak_to_dataframe.py +++ b/src/awkward/operations/ak_to_dataframe.py @@ -2,9 +2,9 @@ import awkward as ak -numpy = ak.nplike.Numpy.instance() +numpy = ak.nplikes.Numpy.instance() -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def to_dataframe( diff --git a/src/awkward/operations/ak_to_json.py b/src/awkward/operations/ak_to_json.py index 297350bc3f..8a384a26f9 100644 --- a/src/awkward/operations/ak_to_json.py +++ b/src/awkward/operations/ak_to_json.py @@ -7,8 +7,8 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() def to_json( diff --git a/src/awkward/operations/ak_to_layout.py b/src/awkward/operations/ak_to_layout.py index efe5ed6935..cca5d6c826 100644 --- a/src/awkward/operations/ak_to_layout.py +++ b/src/awkward/operations/ak_to_layout.py @@ -4,8 +4,8 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() -numpy = ak.nplike.Numpy.instance() +np = ak.nplikes.NumpyMetadata.instance() +numpy = ak.nplikes.Numpy.instance() def to_layout( @@ -85,7 +85,7 @@ def _impl(array, allow_record, allow_other, numpytype): numpytype, ) - elif ak.nplike.is_cupy_buffer(array) and type(array).__name__ == "ndarray": + elif ak.nplikes.is_cupy_buffer(array) and type(array).__name__ == "ndarray": if not issubclass(array.dtype.type, numpytype): raise ak._util.error(ValueError(f"dtype {array.dtype!r} not allowed")) return _impl( @@ -95,7 +95,7 @@ def _impl(array, allow_record, allow_other, numpytype): numpytype, ) - elif ak.nplike.is_jax_buffer(array) and type(array).__name__ == "DeviceArray": + elif ak.nplikes.is_jax_buffer(array) and type(array).__name__ == "DeviceArray": if not issubclass(array.dtype.type, numpytype): raise ak._util.error(ValueError(f"dtype {array.dtype!r} not allowed")) return _impl( diff --git a/src/awkward/operations/ak_to_list.py b/src/awkward/operations/ak_to_list.py index 996816412d..3ddbe019b5 100644 --- a/src/awkward/operations/ak_to_list.py +++ b/src/awkward/operations/ak_to_list.py @@ -4,7 +4,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def to_list(array): diff --git a/src/awkward/operations/ak_to_regular.py b/src/awkward/operations/ak_to_regular.py index d54ce70d10..b30fe49c85 100644 --- a/src/awkward/operations/ak_to_regular.py +++ b/src/awkward/operations/ak_to_regular.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def to_regular(array, axis=1, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_transform.py b/src/awkward/operations/ak_transform.py index a73ef8be65..f434035e34 100644 --- a/src/awkward/operations/ak_transform.py +++ b/src/awkward/operations/ak_transform.py @@ -441,7 +441,7 @@ def _impl( more_layouts = [ ak.to_layout(x, allow_record=False, allow_other=False) for x in more_arrays ] - nplike = ak.nplike.of(layout, *more_layouts) + nplike = ak.nplikes.nplike_of(layout, *more_layouts) options = { "allow_records": allow_records, diff --git a/src/awkward/operations/ak_type.py b/src/awkward/operations/ak_type.py index fb8d9260ad..d3189d387d 100644 --- a/src/awkward/operations/ak_type.py +++ b/src/awkward/operations/ak_type.py @@ -4,7 +4,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def type(array): diff --git a/src/awkward/operations/ak_unflatten.py b/src/awkward/operations/ak_unflatten.py index 0a796c72f8..019077555a 100644 --- a/src/awkward/operations/ak_unflatten.py +++ b/src/awkward/operations/ak_unflatten.py @@ -4,7 +4,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def unflatten(array, counts, axis=0, highlevel=True, behavior=None): @@ -75,7 +75,7 @@ def unflatten(array, counts, axis=0, highlevel=True, behavior=None): def _impl(array, counts, axis, highlevel, behavior): - nplike = ak.nplike.of(array) + nplike = ak.nplikes.nplike_of(array) layout = ak.operations.to_layout(array, allow_record=False, allow_other=False) @@ -87,7 +87,7 @@ def _impl(array, counts, axis, highlevel, behavior): if counts.is_OptionType: mask = counts.mask_as_bool(valid_when=False) counts = counts.to_numpy(allow_missing=True) - counts = ak.nplike.numpy.ma.filled(counts, 0) + counts = ak.nplikes.numpy.ma.filled(counts, 0) elif counts.is_NumpyType or counts.is_UnknownType: counts = counts.to_numpy(allow_missing=False) mask = False diff --git a/src/awkward/operations/ak_unzip.py b/src/awkward/operations/ak_unzip.py index f0f7a497c0..18b0213c67 100644 --- a/src/awkward/operations/ak_unzip.py +++ b/src/awkward/operations/ak_unzip.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def unzip(array, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_values_astype.py b/src/awkward/operations/ak_values_astype.py index 1c583ae74f..2287b647a7 100644 --- a/src/awkward/operations/ak_values_astype.py +++ b/src/awkward/operations/ak_values_astype.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def values_astype(array, to, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_var.py b/src/awkward/operations/ak_var.py index 0b429c1c50..e9fb183ab7 100644 --- a/src/awkward/operations/ak_var.py +++ b/src/awkward/operations/ak_var.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("var") @@ -186,8 +186,8 @@ def _impl(x, weight, ddof, axis, keepdims, mask_identity, flatten_records): flatten_records, ) if ddof != 0: - return ak.nplike.of(sumwxx, sumw).true_divide(sumwxx, sumw) * ak.nplike.of( - sumw - ).true_divide(sumw, sumw - ddof) + return ak.nplikes.nplike_of(sumwxx, sumw).true_divide( + sumwxx, sumw + ) * ak.nplikes.nplike_of(sumw).true_divide(sumw, sumw - ddof) else: - return ak.nplike.of(sumwxx, sumw).true_divide(sumwxx, sumw) + return ak.nplikes.nplike_of(sumwxx, sumw).true_divide(sumwxx, sumw) diff --git a/src/awkward/operations/ak_where.py b/src/awkward/operations/ak_where.py index cee7a84eb3..61453ec091 100644 --- a/src/awkward/operations/ak_where.py +++ b/src/awkward/operations/ak_where.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() @ak._connect.numpy.implements("where") @@ -77,7 +77,7 @@ def _impl1(condition, mergebool, highlevel, behavior): akcondition = ak.operations.to_layout( condition, allow_record=False, allow_other=False ) - nplike = ak.nplike.of(akcondition) + nplike = ak.nplikes.nplike_of(akcondition) akcondition = ak.contents.NumpyArray(ak.operations.to_numpy(akcondition)) out = nplike.nonzero(ak.operations.to_numpy(akcondition)) @@ -106,7 +106,7 @@ def _impl3(condition, x, y, mergebool, highlevel, behavior): good_arrays.append(left) if isinstance(right, ak.contents.Content): good_arrays.append(right) - nplike = ak.nplike.of(*good_arrays) + nplike = ak.nplikes.nplike_of(*good_arrays) def action(inputs, **kwargs): akcondition, left, right = inputs diff --git a/src/awkward/operations/ak_with_field.py b/src/awkward/operations/ak_with_field.py index 1c394f2aef..0401fac0e5 100644 --- a/src/awkward/operations/ak_with_field.py +++ b/src/awkward/operations/ak_with_field.py @@ -5,7 +5,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def with_field(base, what, where=None, highlevel=True, behavior=None): @@ -101,7 +101,7 @@ def _impl(base, what, where, highlevel, behavior): else: def action(inputs, **kwargs): - nplike = ak.nplike.of(*inputs) + nplike = ak.nplikes.nplike_of(*inputs) base, what = inputs if isinstance(base, ak.contents.RecordArray): if what is None: diff --git a/src/awkward/operations/ak_with_name.py b/src/awkward/operations/ak_with_name.py index 7b37ba9e09..b754b5d2c8 100644 --- a/src/awkward/operations/ak_with_name.py +++ b/src/awkward/operations/ak_with_name.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def with_name(array, name, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_with_parameter.py b/src/awkward/operations/ak_with_parameter.py index b9d5cd7792..b757655f4f 100644 --- a/src/awkward/operations/ak_with_parameter.py +++ b/src/awkward/operations/ak_with_parameter.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def with_parameter(array, parameter, value, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_without_parameters.py b/src/awkward/operations/ak_without_parameters.py index e769959e01..c8eeb9aed1 100644 --- a/src/awkward/operations/ak_without_parameters.py +++ b/src/awkward/operations/ak_without_parameters.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def without_parameters(array, highlevel=True, behavior=None): diff --git a/src/awkward/operations/ak_zeros_like.py b/src/awkward/operations/ak_zeros_like.py index dfc36aa939..0421746bfa 100644 --- a/src/awkward/operations/ak_zeros_like.py +++ b/src/awkward/operations/ak_zeros_like.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() _ZEROS = object() diff --git a/src/awkward/operations/ak_zip.py b/src/awkward/operations/ak_zip.py index 1c4e1da882..d7622fc154 100644 --- a/src/awkward/operations/ak_zip.py +++ b/src/awkward/operations/ak_zip.py @@ -2,7 +2,7 @@ import awkward as ak -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def zip( diff --git a/src/awkward/record.py b/src/awkward/record.py index 2663cdc5af..faa20ae307 100644 --- a/src/awkward/record.py +++ b/src/awkward/record.py @@ -6,7 +6,7 @@ import awkward as ak from awkward.contents.content import Content -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() class Record: diff --git a/src/awkward/types/numpytype.py b/src/awkward/types/numpytype.py index b28220fe6c..48c6f99958 100644 --- a/src/awkward/types/numpytype.py +++ b/src/awkward/types/numpytype.py @@ -7,7 +7,7 @@ from awkward.forms.form import _parameters_equal from awkward.types.type import Type -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() def is_primitive(primitive): diff --git a/src/awkward/types/type.py b/src/awkward/types/type.py index 34b091cd3e..db530c3761 100644 --- a/src/awkward/types/type.py +++ b/src/awkward/types/type.py @@ -6,7 +6,7 @@ import awkward as ak from awkward.types._awkward_datashape_parser import Lark_StandAlone, Transformer -np = ak.nplike.NumpyMetadata.instance() +np = ak.nplikes.NumpyMetadata.instance() class Type: diff --git a/tests/test_0395-complex-type-arrays.py b/tests/test_0395-complex-type-arrays.py index a272814213..ba5f4fc5fd 100644 --- a/tests/test_0395-complex-type-arrays.py +++ b/tests/test_0395-complex-type-arrays.py @@ -227,7 +227,9 @@ def test_astype_complex(): (5.5 + 0j), ] assert to_list( - ak.nplike.of(array_complex64).asarray(ak.highlevel.Array(array_complex64)) + ak.nplikes.nplike_of(array_complex64).asarray( + ak.highlevel.Array(array_complex64) + ) ) == [ (0.25 + 0.0j), (0.5 + 0.0j), diff --git a/tests/test_0884-index-and-identifier-refactoring.py b/tests/test_0884-index-and-identifier-refactoring.py index 91489464ee..0972c7f752 100644 --- a/tests/test_0884-index-and-identifier-refactoring.py +++ b/tests/test_0884-index-and-identifier-refactoring.py @@ -7,14 +7,14 @@ def test_index32(): - py_array = ak.index.Index.zeros(10, ak.nplike.Numpy.instance(), np.int32) + py_array = ak.index.Index.zeros(10, ak.nplikes.Numpy.instance(), np.int32) assert len(py_array) == 10 assert "i32" == py_array.form def test_index64(): - py_array = ak.index.Index.zeros(10, ak.nplike.Numpy.instance(), np.int64) + py_array = ak.index.Index.zeros(10, ak.nplikes.Numpy.instance(), np.int64) assert len(py_array) == 10 assert "i64" == py_array.form diff --git a/tests/test_1247-numpy-to_rectilinear-ndarray.py b/tests/test_1247-numpy-to_rectilinear-ndarray.py index 58cd11705f..098e0da31c 100644 --- a/tests/test_1247-numpy-to_rectilinear-ndarray.py +++ b/tests/test_1247-numpy-to_rectilinear-ndarray.py @@ -8,6 +8,6 @@ def test(): array = np.array([1, 2, 9, 0]) - nplike = ak.nplike.of(array) + nplike = ak.nplikes.nplike_of(array) ak_array = ak.operations.from_numpy(array) assert nplike.to_rectilinear(array).tolist() == ak_array.tolist() diff --git a/tests/test_1672-broadcast-parameters.py b/tests/test_1672-broadcast-parameters.py index 5093f49d9f..c365e6bf61 100644 --- a/tests/test_1672-broadcast-parameters.py +++ b/tests/test_1672-broadcast-parameters.py @@ -4,7 +4,7 @@ import awkward as ak # noqa: F401 -numpy = ak.nplike.Numpy.instance() +numpy = ak.nplikes.Numpy.instance() @pytest.mark.skip("string broadcasting is broken") diff --git a/tests/test_1688-pack-categorical.py b/tests/test_1688-pack-categorical.py index b1b456f31b..d87b5c65b4 100644 --- a/tests/test_1688-pack-categorical.py +++ b/tests/test_1688-pack-categorical.py @@ -4,7 +4,7 @@ import awkward as ak # noqa: F401 -numpy = ak.nplike.Numpy.instance() +numpy = ak.nplikes.Numpy.instance() def test(): diff --git a/tests/test_1707-broadcast-parameters-ufunc.py b/tests/test_1707-broadcast-parameters-ufunc.py index da4663144d..8591a8d065 100644 --- a/tests/test_1707-broadcast-parameters-ufunc.py +++ b/tests/test_1707-broadcast-parameters-ufunc.py @@ -4,7 +4,7 @@ import awkward as ak # noqa: F401 -numpy = ak.nplike.Numpy.instance() +numpy = ak.nplikes.Numpy.instance() def test_numpy_1d(): diff --git a/tests/test_1709-ak-array-constructor-behavior.py b/tests/test_1709-ak-array-constructor-behavior.py index 9f3b5d21b4..714da5ce89 100644 --- a/tests/test_1709-ak-array-constructor-behavior.py +++ b/tests/test_1709-ak-array-constructor-behavior.py @@ -4,7 +4,7 @@ import awkward as ak # noqa: F401 -numpy = ak.nplike.Numpy.instance() +numpy = ak.nplikes.Numpy.instance() class MyBehavior(ak.Array):