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.
Files changed (144) hide show
  1. dask_array/__init__.py +228 -0
  2. dask_array/_backends.py +76 -0
  3. dask_array/_backends_array.py +99 -0
  4. dask_array/_blockwise.py +1410 -0
  5. dask_array/_broadcast.py +272 -0
  6. dask_array/_chunk.py +445 -0
  7. dask_array/_chunk_types.py +54 -0
  8. dask_array/_collection.py +1644 -0
  9. dask_array/_concatenate.py +331 -0
  10. dask_array/_core_utils.py +1365 -0
  11. dask_array/_dispatch.py +141 -0
  12. dask_array/_einsum.py +277 -0
  13. dask_array/_expr.py +544 -0
  14. dask_array/_expr_flow.py +586 -0
  15. dask_array/_gufunc.py +805 -0
  16. dask_array/_histogram.py +617 -0
  17. dask_array/_map_blocks.py +652 -0
  18. dask_array/_new_collection.py +10 -0
  19. dask_array/_numpy_compat.py +135 -0
  20. dask_array/_overlap.py +1159 -0
  21. dask_array/_rechunk.py +1050 -0
  22. dask_array/_reshape.py +710 -0
  23. dask_array/_routines.py +102 -0
  24. dask_array/_shuffle.py +448 -0
  25. dask_array/_stack.py +264 -0
  26. dask_array/_svg.py +291 -0
  27. dask_array/_templates.py +29 -0
  28. dask_array/_test_utils.py +257 -0
  29. dask_array/_ufunc.py +385 -0
  30. dask_array/_utils.py +349 -0
  31. dask_array/_visualize.py +223 -0
  32. dask_array/_xarray.py +337 -0
  33. dask_array/core/__init__.py +34 -0
  34. dask_array/core/_blockwise_funcs.py +312 -0
  35. dask_array/core/_conversion.py +422 -0
  36. dask_array/core/_from_graph.py +97 -0
  37. dask_array/creation/__init__.py +71 -0
  38. dask_array/creation/_arange.py +121 -0
  39. dask_array/creation/_diag.py +116 -0
  40. dask_array/creation/_diagonal.py +241 -0
  41. dask_array/creation/_eye.py +103 -0
  42. dask_array/creation/_linspace.py +102 -0
  43. dask_array/creation/_mesh.py +134 -0
  44. dask_array/creation/_ones_zeros.py +454 -0
  45. dask_array/creation/_pad.py +270 -0
  46. dask_array/creation/_repeat.py +55 -0
  47. dask_array/creation/_tile.py +36 -0
  48. dask_array/creation/_tri.py +28 -0
  49. dask_array/creation/_utils.py +296 -0
  50. dask_array/fft.py +320 -0
  51. dask_array/io/__init__.py +39 -0
  52. dask_array/io/_base.py +10 -0
  53. dask_array/io/_from_array.py +257 -0
  54. dask_array/io/_from_delayed.py +95 -0
  55. dask_array/io/_from_graph.py +54 -0
  56. dask_array/io/_from_npy_stack.py +67 -0
  57. dask_array/io/_store.py +336 -0
  58. dask_array/io/_tiledb.py +159 -0
  59. dask_array/io/_to_npy_stack.py +65 -0
  60. dask_array/io/_zarr.py +449 -0
  61. dask_array/linalg/__init__.py +39 -0
  62. dask_array/linalg/_cholesky.py +234 -0
  63. dask_array/linalg/_lu.py +300 -0
  64. dask_array/linalg/_norm.py +94 -0
  65. dask_array/linalg/_qr.py +601 -0
  66. dask_array/linalg/_solve.py +349 -0
  67. dask_array/linalg/_svd.py +394 -0
  68. dask_array/linalg/_tensordot.py +334 -0
  69. dask_array/linalg/_utils.py +74 -0
  70. dask_array/manipulation/__init__.py +45 -0
  71. dask_array/manipulation/_expand.py +321 -0
  72. dask_array/manipulation/_flip.py +92 -0
  73. dask_array/manipulation/_roll.py +78 -0
  74. dask_array/manipulation/_transpose.py +309 -0
  75. dask_array/random/__init__.py +125 -0
  76. dask_array/random/_choice.py +181 -0
  77. dask_array/random/_expr.py +256 -0
  78. dask_array/random/_generator.py +441 -0
  79. dask_array/random/_random_state.py +259 -0
  80. dask_array/random/_utils.py +84 -0
  81. dask_array/reductions/__init__.py +84 -0
  82. dask_array/reductions/_arg_reduction.py +130 -0
  83. dask_array/reductions/_common.py +1082 -0
  84. dask_array/reductions/_cumulative.py +522 -0
  85. dask_array/reductions/_percentile.py +261 -0
  86. dask_array/reductions/_reduction.py +725 -0
  87. dask_array/reductions/_trace.py +56 -0
  88. dask_array/routines/__init__.py +133 -0
  89. dask_array/routines/_apply.py +84 -0
  90. dask_array/routines/_bincount.py +112 -0
  91. dask_array/routines/_broadcast.py +111 -0
  92. dask_array/routines/_coarsen.py +115 -0
  93. dask_array/routines/_diff.py +79 -0
  94. dask_array/routines/_gradient.py +158 -0
  95. dask_array/routines/_indexing.py +65 -0
  96. dask_array/routines/_insert_delete.py +132 -0
  97. dask_array/routines/_misc.py +122 -0
  98. dask_array/routines/_nonzero.py +72 -0
  99. dask_array/routines/_search.py +123 -0
  100. dask_array/routines/_select.py +113 -0
  101. dask_array/routines/_statistics.py +171 -0
  102. dask_array/routines/_topk.py +82 -0
  103. dask_array/routines/_triangular.py +74 -0
  104. dask_array/routines/_unique.py +232 -0
  105. dask_array/routines/_where.py +62 -0
  106. dask_array/slicing/__init__.py +67 -0
  107. dask_array/slicing/_basic.py +550 -0
  108. dask_array/slicing/_blocks.py +138 -0
  109. dask_array/slicing/_bool_index.py +145 -0
  110. dask_array/slicing/_setitem.py +329 -0
  111. dask_array/slicing/_squeeze.py +101 -0
  112. dask_array/slicing/_utils.py +1133 -0
  113. dask_array/slicing/_vindex.py +282 -0
  114. dask_array/stacking/__init__.py +15 -0
  115. dask_array/stacking/_block.py +83 -0
  116. dask_array/stacking/_simple.py +58 -0
  117. dask_array/templates/array.html.j2 +48 -0
  118. dask_array/tests/__init__.py +0 -0
  119. dask_array/tests/conftest.py +22 -0
  120. dask_array/tests/test_api.py +40 -0
  121. dask_array/tests/test_binary_op_chunks.py +107 -0
  122. dask_array/tests/test_coarse_slice_through_blockwise.py +362 -0
  123. dask_array/tests/test_collection.py +799 -0
  124. dask_array/tests/test_creation.py +1102 -0
  125. dask_array/tests/test_expr_flow.py +143 -0
  126. dask_array/tests/test_linalg.py +1130 -0
  127. dask_array/tests/test_map_blocks_multi_output.py +104 -0
  128. dask_array/tests/test_rechunk_pushdown.py +214 -0
  129. dask_array/tests/test_reductions.py +1091 -0
  130. dask_array/tests/test_routines.py +2853 -0
  131. dask_array/tests/test_shuffle_chunks.py +67 -0
  132. dask_array/tests/test_slice_pushdown.py +968 -0
  133. dask_array/tests/test_slice_through_blockwise.py +678 -0
  134. dask_array/tests/test_slice_through_overlap.py +366 -0
  135. dask_array/tests/test_slice_through_reshape.py +272 -0
  136. dask_array/tests/test_slicing.py +839 -0
  137. dask_array/tests/test_transpose_slice_pushdown.py +208 -0
  138. dask_array/tests/test_visualize.py +94 -0
  139. dask_array/tests/test_xarray.py +193 -0
  140. dask_array-0.1.0.dist-info/METADATA +48 -0
  141. dask_array-0.1.0.dist-info/RECORD +144 -0
  142. dask_array-0.1.0.dist-info/WHEEL +4 -0
  143. dask_array-0.1.0.dist-info/entry_points.txt +2 -0
  144. 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)