Skip to content

Commit 2b7eab1

Browse files
committed
Add docstrings, fix 2.0 compatibility
1 parent 1ed28a8 commit 2b7eab1

File tree

7 files changed

+27
-106
lines changed

7 files changed

+27
-106
lines changed

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def genbody(f, func_list, lib="blosc2"):
1414

1515
f.write("\n\n\n")
1616
for func in func_list:
17-
f.write(f".. autofunction:: {lib}.{func}\n\n")
17+
f.write(f".. autofunction:: {lib}.{func}\n")
1818

1919

2020
sys.path.insert(0, os.path.abspath(os.path.dirname(blosc2.__file__)))

doc/reference/additional_funcs.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,12 @@ Their result is typically a :ref:`LazyExpr` instance, which can be evaluated (wi
2323

2424

2525
.. autofunction:: blosc2.clip
26-
2726
.. autofunction:: blosc2.conj
28-
2927
.. autofunction:: blosc2.contains
30-
3128
.. autofunction:: blosc2.imag
32-
3329
.. autofunction:: blosc2.real
34-
3530
.. autofunction:: blosc2.round
36-
3731
.. autofunction:: blosc2.where
38-
3932
Type Utilities
4033
--------------
4134

@@ -53,9 +46,6 @@ The following functions are useful for working with datatypes.
5346

5447

5548
.. autofunction:: blosc2.astype
56-
5749
.. autofunction:: blosc2.can_cast
58-
5950
.. autofunction:: blosc2.isdtype
60-
6151
.. autofunction:: blosc2.result_type

doc/reference/index_funcs.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,11 @@ The following functions are useful for performing indexing and oter associated o
2020

2121

2222
.. autofunction:: blosc2.broadcast_to
23-
2423
.. autofunction:: blosc2.count_nonzero
25-
2624
.. autofunction:: blosc2.expand_dims
27-
2825
.. autofunction:: blosc2.indices
29-
3026
.. autofunction:: blosc2.meshgrid
31-
3227
.. autofunction:: blosc2.sort
33-
3428
.. autofunction:: blosc2.squeeze
35-
3629
.. autofunction:: blosc2.take
37-
3830
.. autofunction:: blosc2.take_along_axis

doc/reference/linalg.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,10 @@ The following functions can be used for computing linear algebra operations with
1818

1919

2020
.. autofunction:: blosc2.linalg.matmul
21-
2221
.. autofunction:: blosc2.linalg.tensordot
23-
2422
.. autofunction:: blosc2.linalg.vecdot
25-
2623
.. autofunction:: blosc2.linalg.permute_dims
27-
2824
.. autofunction:: blosc2.linalg.transpose
29-
3025
.. autofunction:: blosc2.linalg.matrix_transpose
31-
3226
.. autofunction:: blosc2.linalg.diagonal
33-
3427
.. autofunction:: blosc2.linalg.outer

doc/reference/ufuncs.rst

Lines changed: 4 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Note: The functions ``conj``, ``real``, ``imag``, ``contains``, ``where`` are no
2525
asin
2626
asinh
2727
atan
28-
atan2
2928
atanh
29+
atan2
3030
bitwise_and
3131
bitwise_invert
3232
bitwise_left_shift
@@ -53,9 +53,9 @@ Note: The functions ``conj``, ``real``, ``imag``, ``contains``, ``where`` are no
5353
less
5454
less_equal
5555
log
56+
log10
5657
log1p
5758
log2
58-
log10
5959
logaddexp
6060
logical_and
6161
logical_not
@@ -87,145 +87,74 @@ Note: The functions ``conj``, ``real``, ``imag``, ``contains``, ``where`` are no
8787

8888

8989
.. autofunction:: blosc2.abs
90-
9190
.. autofunction:: blosc2.acos
92-
9391
.. autofunction:: blosc2.acosh
94-
9592
.. autofunction:: blosc2.add
96-
9793
.. autofunction:: blosc2.arccos
98-
9994
.. autofunction:: blosc2.arccosh
100-
10195
.. autofunction:: blosc2.arcsin
102-
10396
.. autofunction:: blosc2.arcsinh
104-
10597
.. autofunction:: blosc2.arctan
106-
10798
.. autofunction:: blosc2.arctan2
108-
10999
.. autofunction:: blosc2.arctanh
110-
111100
.. autofunction:: blosc2.asin
112-
113101
.. autofunction:: blosc2.asinh
114-
115102
.. autofunction:: blosc2.atan
116-
117-
.. autofunction:: blosc2.atan2
118-
119103
.. autofunction:: blosc2.atanh
120-
104+
.. autofunction:: blosc2.atan2
121105
.. autofunction:: blosc2.bitwise_and
122-
123106
.. autofunction:: blosc2.bitwise_invert
124-
125107
.. autofunction:: blosc2.bitwise_left_shift
126-
127108
.. autofunction:: blosc2.bitwise_or
128-
129109
.. autofunction:: blosc2.bitwise_right_shift
130-
131110
.. autofunction:: blosc2.bitwise_xor
132-
133111
.. autofunction:: blosc2.ceil
134-
135112
.. autofunction:: blosc2.conj
136-
137113
.. autofunction:: blosc2.copysign
138-
139114
.. autofunction:: blosc2.cos
140-
141115
.. autofunction:: blosc2.cosh
142-
143116
.. autofunction:: blosc2.divide
144-
145117
.. autofunction:: blosc2.equal
146-
147118
.. autofunction:: blosc2.exp
148-
149119
.. autofunction:: blosc2.expm1
150-
151120
.. autofunction:: blosc2.floor
152-
153121
.. autofunction:: blosc2.floor_divide
154-
155122
.. autofunction:: blosc2.greater
156-
157123
.. autofunction:: blosc2.greater_equal
158-
159124
.. autofunction:: blosc2.hypot
160-
161125
.. autofunction:: blosc2.isfinite
162-
163126
.. autofunction:: blosc2.isinf
164-
165127
.. autofunction:: blosc2.isnan
166-
167128
.. autofunction:: blosc2.less
168-
169129
.. autofunction:: blosc2.less_equal
170-
171130
.. autofunction:: blosc2.log
172-
131+
.. autofunction:: blosc2.log10
173132
.. autofunction:: blosc2.log1p
174-
175133
.. autofunction:: blosc2.log2
176-
177-
.. autofunction:: blosc2.log10
178-
179134
.. autofunction:: blosc2.logaddexp
180-
181135
.. autofunction:: blosc2.logical_and
182-
183136
.. autofunction:: blosc2.logical_not
184-
185137
.. autofunction:: blosc2.logical_or
186-
187138
.. autofunction:: blosc2.logical_xor
188-
189139
.. autofunction:: blosc2.matmul
190-
191140
.. autofunction:: blosc2.maximum
192-
193141
.. autofunction:: blosc2.minimum
194-
195142
.. autofunction:: blosc2.multiply
196-
197143
.. autofunction:: blosc2.negative
198-
199144
.. autofunction:: blosc2.nextafter
200-
201145
.. autofunction:: blosc2.not_equal
202-
203146
.. autofunction:: blosc2.positive
204-
205147
.. autofunction:: blosc2.pow
206-
207148
.. autofunction:: blosc2.reciprocal
208-
209149
.. autofunction:: blosc2.remainder
210-
211150
.. autofunction:: blosc2.sign
212-
213151
.. autofunction:: blosc2.signbit
214-
215152
.. autofunction:: blosc2.sin
216-
217153
.. autofunction:: blosc2.sinh
218-
219154
.. autofunction:: blosc2.sqrt
220-
221155
.. autofunction:: blosc2.square
222-
223156
.. autofunction:: blosc2.subtract
224-
225157
.. autofunction:: blosc2.tan
226-
227158
.. autofunction:: blosc2.tanh
228-
229159
.. autofunction:: blosc2.trunc
230-
231160
.. autofunction:: blosc2.vecdot

src/blosc2/ndarray.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2939,9 +2939,26 @@ def __array_interface__(self):
29392939

29402940
@property
29412941
def device(self):
2942+
"Hardware device the array data resides on. Always equal to 'cpu'."
29422943
return self._device
29432944

2944-
def to_device(self, device):
2945+
def to_device(self: NDArray, device: str):
2946+
"""
2947+
Copy the array from the device on which it currently resides to the specified device.
2948+
2949+
Parameters
2950+
----------
2951+
self: NDArray
2952+
Array instance.
2953+
2954+
device: str
2955+
Device to move array object to. Returns error except when device=='cpu'.
2956+
2957+
Returns
2958+
-------
2959+
out: NDArray
2960+
If device='cpu', the same array; else raises an Error.
2961+
"""
29452962
if device != "cpu":
29462963
raise ValueError(f"Unsupported device: {device}. Only 'cpu' is accepted.")
29472964
return self

tests/ndarray/test_evaluate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ def test_reduc_out(sample_data):
9696
@pytest.mark.parametrize("func", ["cumsum", "cumulative_sum", "cumprod"])
9797
def test_numpy_funcs(sample_data, func):
9898
a, b, c, shape = sample_data
99-
d_blosc2 = blosc2.evaluate(f"{func}(((a**3 + sin(a * 2)) < c) & (b > 0), axis=0)")
100-
a = a[:]
101-
b = b[:]
102-
c = c[:] # ensure that all operands are numpy arrays
10399
try:
104100
npfunc = getattr(np, func)
101+
d_blosc2 = blosc2.evaluate(f"{func}(((a**3 + sin(a * 2)) < c) & (b > 0), axis=0)")
102+
a = a[:]
103+
b = b[:]
104+
c = c[:] # ensure that all operands are numpy arrays
105105
d_numpy = npfunc(((a**3 + np.sin(a * 2)) < c) & (b > 0), axis=0)
106106
np.testing.assert_equal(d_blosc2, d_numpy)
107107
except AttributeError:

0 commit comments

Comments
 (0)