dask-array 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dask_array/__init__.py +228 -0
- dask_array/_backends.py +76 -0
- dask_array/_backends_array.py +99 -0
- dask_array/_blockwise.py +1410 -0
- dask_array/_broadcast.py +272 -0
- dask_array/_chunk.py +445 -0
- dask_array/_chunk_types.py +54 -0
- dask_array/_collection.py +1644 -0
- dask_array/_concatenate.py +331 -0
- dask_array/_core_utils.py +1365 -0
- dask_array/_dispatch.py +141 -0
- dask_array/_einsum.py +277 -0
- dask_array/_expr.py +544 -0
- dask_array/_expr_flow.py +586 -0
- dask_array/_gufunc.py +805 -0
- dask_array/_histogram.py +617 -0
- dask_array/_map_blocks.py +652 -0
- dask_array/_new_collection.py +10 -0
- dask_array/_numpy_compat.py +135 -0
- dask_array/_overlap.py +1159 -0
- dask_array/_rechunk.py +1050 -0
- dask_array/_reshape.py +710 -0
- dask_array/_routines.py +102 -0
- dask_array/_shuffle.py +448 -0
- dask_array/_stack.py +264 -0
- dask_array/_svg.py +291 -0
- dask_array/_templates.py +29 -0
- dask_array/_test_utils.py +257 -0
- dask_array/_ufunc.py +385 -0
- dask_array/_utils.py +349 -0
- dask_array/_visualize.py +223 -0
- dask_array/_xarray.py +337 -0
- dask_array/core/__init__.py +34 -0
- dask_array/core/_blockwise_funcs.py +312 -0
- dask_array/core/_conversion.py +422 -0
- dask_array/core/_from_graph.py +97 -0
- dask_array/creation/__init__.py +71 -0
- dask_array/creation/_arange.py +121 -0
- dask_array/creation/_diag.py +116 -0
- dask_array/creation/_diagonal.py +241 -0
- dask_array/creation/_eye.py +103 -0
- dask_array/creation/_linspace.py +102 -0
- dask_array/creation/_mesh.py +134 -0
- dask_array/creation/_ones_zeros.py +454 -0
- dask_array/creation/_pad.py +270 -0
- dask_array/creation/_repeat.py +55 -0
- dask_array/creation/_tile.py +36 -0
- dask_array/creation/_tri.py +28 -0
- dask_array/creation/_utils.py +296 -0
- dask_array/fft.py +320 -0
- dask_array/io/__init__.py +39 -0
- dask_array/io/_base.py +10 -0
- dask_array/io/_from_array.py +257 -0
- dask_array/io/_from_delayed.py +95 -0
- dask_array/io/_from_graph.py +54 -0
- dask_array/io/_from_npy_stack.py +67 -0
- dask_array/io/_store.py +336 -0
- dask_array/io/_tiledb.py +159 -0
- dask_array/io/_to_npy_stack.py +65 -0
- dask_array/io/_zarr.py +449 -0
- dask_array/linalg/__init__.py +39 -0
- dask_array/linalg/_cholesky.py +234 -0
- dask_array/linalg/_lu.py +300 -0
- dask_array/linalg/_norm.py +94 -0
- dask_array/linalg/_qr.py +601 -0
- dask_array/linalg/_solve.py +349 -0
- dask_array/linalg/_svd.py +394 -0
- dask_array/linalg/_tensordot.py +334 -0
- dask_array/linalg/_utils.py +74 -0
- dask_array/manipulation/__init__.py +45 -0
- dask_array/manipulation/_expand.py +321 -0
- dask_array/manipulation/_flip.py +92 -0
- dask_array/manipulation/_roll.py +78 -0
- dask_array/manipulation/_transpose.py +309 -0
- dask_array/random/__init__.py +125 -0
- dask_array/random/_choice.py +181 -0
- dask_array/random/_expr.py +256 -0
- dask_array/random/_generator.py +441 -0
- dask_array/random/_random_state.py +259 -0
- dask_array/random/_utils.py +84 -0
- dask_array/reductions/__init__.py +84 -0
- dask_array/reductions/_arg_reduction.py +130 -0
- dask_array/reductions/_common.py +1082 -0
- dask_array/reductions/_cumulative.py +522 -0
- dask_array/reductions/_percentile.py +261 -0
- dask_array/reductions/_reduction.py +725 -0
- dask_array/reductions/_trace.py +56 -0
- dask_array/routines/__init__.py +133 -0
- dask_array/routines/_apply.py +84 -0
- dask_array/routines/_bincount.py +112 -0
- dask_array/routines/_broadcast.py +111 -0
- dask_array/routines/_coarsen.py +115 -0
- dask_array/routines/_diff.py +79 -0
- dask_array/routines/_gradient.py +158 -0
- dask_array/routines/_indexing.py +65 -0
- dask_array/routines/_insert_delete.py +132 -0
- dask_array/routines/_misc.py +122 -0
- dask_array/routines/_nonzero.py +72 -0
- dask_array/routines/_search.py +123 -0
- dask_array/routines/_select.py +113 -0
- dask_array/routines/_statistics.py +171 -0
- dask_array/routines/_topk.py +82 -0
- dask_array/routines/_triangular.py +74 -0
- dask_array/routines/_unique.py +232 -0
- dask_array/routines/_where.py +62 -0
- dask_array/slicing/__init__.py +67 -0
- dask_array/slicing/_basic.py +550 -0
- dask_array/slicing/_blocks.py +138 -0
- dask_array/slicing/_bool_index.py +145 -0
- dask_array/slicing/_setitem.py +329 -0
- dask_array/slicing/_squeeze.py +101 -0
- dask_array/slicing/_utils.py +1133 -0
- dask_array/slicing/_vindex.py +282 -0
- dask_array/stacking/__init__.py +15 -0
- dask_array/stacking/_block.py +83 -0
- dask_array/stacking/_simple.py +58 -0
- dask_array/templates/array.html.j2 +48 -0
- dask_array/tests/__init__.py +0 -0
- dask_array/tests/conftest.py +22 -0
- dask_array/tests/test_api.py +40 -0
- dask_array/tests/test_binary_op_chunks.py +107 -0
- dask_array/tests/test_coarse_slice_through_blockwise.py +362 -0
- dask_array/tests/test_collection.py +799 -0
- dask_array/tests/test_creation.py +1102 -0
- dask_array/tests/test_expr_flow.py +143 -0
- dask_array/tests/test_linalg.py +1130 -0
- dask_array/tests/test_map_blocks_multi_output.py +104 -0
- dask_array/tests/test_rechunk_pushdown.py +214 -0
- dask_array/tests/test_reductions.py +1091 -0
- dask_array/tests/test_routines.py +2853 -0
- dask_array/tests/test_shuffle_chunks.py +67 -0
- dask_array/tests/test_slice_pushdown.py +968 -0
- dask_array/tests/test_slice_through_blockwise.py +678 -0
- dask_array/tests/test_slice_through_overlap.py +366 -0
- dask_array/tests/test_slice_through_reshape.py +272 -0
- dask_array/tests/test_slicing.py +839 -0
- dask_array/tests/test_transpose_slice_pushdown.py +208 -0
- dask_array/tests/test_visualize.py +94 -0
- dask_array/tests/test_xarray.py +193 -0
- dask_array-0.1.0.dist-info/METADATA +48 -0
- dask_array-0.1.0.dist-info/RECORD +144 -0
- dask_array-0.1.0.dist-info/WHEEL +4 -0
- dask_array-0.1.0.dist-info/entry_points.txt +2 -0
- dask_array-0.1.0.dist-info/licenses/LICENSE +29 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""NumPy compatibility utilities.
|
|
2
|
+
|
|
3
|
+
Since dask_array targets numpy >= 2.0, this module provides simplified shims.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
# Parse numpy version to tuple for comparisons
|
|
11
|
+
_np_version = tuple(int(x) for x in np.__version__.split(".")[:2])
|
|
12
|
+
|
|
13
|
+
# Version flags - NUMPY_GE_200 is always True since we require numpy >= 2.0
|
|
14
|
+
NUMPY_GE_200 = True
|
|
15
|
+
NUMPY_GE_210 = _np_version >= (2, 1)
|
|
16
|
+
NUMPY_GE_220 = _np_version >= (2, 2)
|
|
17
|
+
NUMPY_GE_240 = _np_version >= (2, 4)
|
|
18
|
+
|
|
19
|
+
# These are available directly in numpy >= 2.0
|
|
20
|
+
from numpy.exceptions import AxisError, ComplexWarning
|
|
21
|
+
from numpy.lib.array_utils import normalize_axis_index, normalize_axis_tuple
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class _Recurser:
|
|
25
|
+
"""
|
|
26
|
+
Utility class for recursing over nested iterables.
|
|
27
|
+
|
|
28
|
+
This was copied almost verbatim from numpy.core.shape_base._Recurser.
|
|
29
|
+
See numpy license at https://github.com/numpy/numpy/blob/master/LICENSE.txt
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(self, recurse_if):
|
|
33
|
+
self.recurse_if = recurse_if
|
|
34
|
+
|
|
35
|
+
def map_reduce(
|
|
36
|
+
self,
|
|
37
|
+
x,
|
|
38
|
+
f_map=lambda x, **kwargs: x,
|
|
39
|
+
f_reduce=lambda x, **kwargs: x,
|
|
40
|
+
f_kwargs=lambda **kwargs: kwargs,
|
|
41
|
+
**kwargs,
|
|
42
|
+
):
|
|
43
|
+
"""
|
|
44
|
+
Iterate over the nested list, applying:
|
|
45
|
+
* ``f_map`` (T -> U) to items
|
|
46
|
+
* ``f_reduce`` (Iterable[U] -> U) to mapped items
|
|
47
|
+
|
|
48
|
+
For instance, ``map_reduce([[1, 2], 3, 4])`` is::
|
|
49
|
+
|
|
50
|
+
f_reduce([
|
|
51
|
+
f_reduce([
|
|
52
|
+
f_map(1),
|
|
53
|
+
f_map(2)
|
|
54
|
+
]),
|
|
55
|
+
f_map(3),
|
|
56
|
+
f_map(4)
|
|
57
|
+
]])
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
State can be passed down through the calls with `f_kwargs`,
|
|
61
|
+
to iterables of mapped items. When kwargs are passed, as in
|
|
62
|
+
``map_reduce([[1, 2], 3, 4], **kw)``, this becomes::
|
|
63
|
+
|
|
64
|
+
kw1 = f_kwargs(**kw)
|
|
65
|
+
kw2 = f_kwargs(**kw1)
|
|
66
|
+
f_reduce([
|
|
67
|
+
f_reduce([
|
|
68
|
+
f_map(1), **kw2)
|
|
69
|
+
f_map(2, **kw2)
|
|
70
|
+
], **kw1),
|
|
71
|
+
f_map(3, **kw1),
|
|
72
|
+
f_map(4, **kw1)
|
|
73
|
+
]], **kw)
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
def f(x, **kwargs):
|
|
77
|
+
if not self.recurse_if(x):
|
|
78
|
+
return f_map(x, **kwargs)
|
|
79
|
+
else:
|
|
80
|
+
next_kwargs = f_kwargs(**kwargs)
|
|
81
|
+
return f_reduce((f(xi, **next_kwargs) for xi in x), **kwargs)
|
|
82
|
+
|
|
83
|
+
return f(x, **kwargs)
|
|
84
|
+
|
|
85
|
+
def walk(self, x, index=()):
|
|
86
|
+
"""
|
|
87
|
+
Iterate over x, yielding (index, value, entering), where
|
|
88
|
+
|
|
89
|
+
* ``index``: a tuple of indices up to this point
|
|
90
|
+
* ``value``: equal to ``x[index[0]][...][index[-1]]``. On the first iteration, is
|
|
91
|
+
``x`` itself
|
|
92
|
+
* ``entering``: bool. The result of ``recurse_if(value)``
|
|
93
|
+
"""
|
|
94
|
+
do_recurse = self.recurse_if(x)
|
|
95
|
+
yield index, x, do_recurse
|
|
96
|
+
|
|
97
|
+
if not do_recurse:
|
|
98
|
+
return
|
|
99
|
+
for i, xi in enumerate(x):
|
|
100
|
+
yield from self.walk(xi, index + (i,))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def moveaxis(a, source, destination):
|
|
104
|
+
"""Move axes of an array to new positions."""
|
|
105
|
+
source = normalize_axis_tuple(source, a.ndim, "source")
|
|
106
|
+
destination = normalize_axis_tuple(destination, a.ndim, "destination")
|
|
107
|
+
if len(source) != len(destination):
|
|
108
|
+
raise ValueError("`source` and `destination` arguments must have the same number of elements")
|
|
109
|
+
|
|
110
|
+
order = [n for n in range(a.ndim) if n not in source]
|
|
111
|
+
|
|
112
|
+
for dest, src in sorted(zip(destination, source)):
|
|
113
|
+
order.insert(dest, src)
|
|
114
|
+
|
|
115
|
+
result = a.transpose(order)
|
|
116
|
+
return result
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def rollaxis(a, axis, start=0):
|
|
120
|
+
"""Roll the specified axis backwards, until it lies in a given position."""
|
|
121
|
+
n = a.ndim
|
|
122
|
+
axis = normalize_axis_index(axis, n)
|
|
123
|
+
if start < 0:
|
|
124
|
+
start += n
|
|
125
|
+
msg = "'%s' arg requires %d <= %s < %d, but %d was passed in"
|
|
126
|
+
if not (0 <= start < n + 1):
|
|
127
|
+
raise ValueError(msg % ("start", -n, "start", n + 1, start))
|
|
128
|
+
if axis < start:
|
|
129
|
+
start -= 1
|
|
130
|
+
if axis == start:
|
|
131
|
+
return a[...]
|
|
132
|
+
axes = list(range(0, n))
|
|
133
|
+
axes.remove(axis)
|
|
134
|
+
axes.insert(start, axis)
|
|
135
|
+
return a.transpose(axes)
|