cobra-array 0.2.1__tar.gz → 0.2.2__tar.gz

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 (31) hide show
  1. {cobra_array-0.2.1/src/cobra_array.egg-info → cobra_array-0.2.2}/PKG-INFO +1 -1
  2. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/__init__.py +1 -1
  3. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/compat/_array.pyi +56 -56
  4. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/compat/_namespace.pyi +29 -29
  5. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/types.py +5 -5
  6. {cobra_array-0.2.1 → cobra_array-0.2.2/src/cobra_array.egg-info}/PKG-INFO +1 -1
  7. {cobra_array-0.2.1 → cobra_array-0.2.2}/tests/test_compat.py +9 -0
  8. {cobra_array-0.2.1 → cobra_array-0.2.2}/LICENSE +0 -0
  9. {cobra_array-0.2.1 → cobra_array-0.2.2}/README.md +0 -0
  10. {cobra_array-0.2.1 → cobra_array-0.2.2}/pyproject.toml +0 -0
  11. {cobra_array-0.2.1 → cobra_array-0.2.2}/setup.cfg +0 -0
  12. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/_core.py +0 -0
  13. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/_utils.py +0 -0
  14. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/array_api.py +0 -0
  15. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/compat/__init__.py +0 -0
  16. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/compat/_array.py +0 -0
  17. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/compat/_base.py +0 -0
  18. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/compat/_namespace.py +0 -0
  19. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/convert.py +0 -0
  20. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/convert.pyi +0 -0
  21. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/default.py +0 -0
  22. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array/exceptions.py +0 -0
  23. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array.egg-info/SOURCES.txt +0 -0
  24. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array.egg-info/dependency_links.txt +0 -0
  25. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array.egg-info/requires.txt +0 -0
  26. {cobra_array-0.2.1 → cobra_array-0.2.2}/src/cobra_array.egg-info/top_level.txt +0 -0
  27. {cobra_array-0.2.1 → cobra_array-0.2.2}/tests/test_backend.py +0 -0
  28. {cobra_array-0.2.1 → cobra_array-0.2.2}/tests/test_compat_namespace.py +0 -0
  29. {cobra_array-0.2.1 → cobra_array-0.2.2}/tests/test_convert.py +0 -0
  30. {cobra_array-0.2.1 → cobra_array-0.2.2}/tests/test_default.py +0 -0
  31. {cobra_array-0.2.1 → cobra_array-0.2.2}/tests/test_wrap.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cobra-array
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A backend-agnostic array utility library that unifies array conversion, context control, and cross-library operations across `NumPy`/`PyTorch`-style ecosystems.
5
5
  Author-email: Zhen Tian <zhen.tian.cs@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/tinchen777/cobra-array.git
@@ -80,7 +80,7 @@ from ._utils import (
80
80
  )
81
81
 
82
82
  __author__ = "Zhen Tian"
83
- __version__ = "0.2.1"
83
+ __version__ = "0.2.2"
84
84
 
85
85
  __all__ = [
86
86
  "array_spec",
@@ -116,14 +116,14 @@ class CompatArray(Compat, Generic[TT, DT]):
116
116
  """
117
117
  ...
118
118
 
119
- def acos(self) -> CompatArray[float, DT]:
119
+ def acos(self) -> CompatArray[type[float], DT]:
120
120
  """
121
121
  Computes the element-wise `principal value of the inverse cosine` of `self`.
122
122
  - `self` should have a floating-point data type.
123
123
  """
124
124
  ...
125
125
 
126
- def acosh(self) -> CompatArray[float, DT]:
126
+ def acosh(self) -> CompatArray[type[float], DT]:
127
127
  """
128
128
  Computes the element-wise `inverse hyperbolic cosine` of `self`.
129
129
  - `self` should have a floating-point data type.
@@ -137,28 +137,28 @@ class CompatArray(Compat, Generic[TT, DT]):
137
137
  """
138
138
  ...
139
139
 
140
- def asin(self) -> CompatArray[float, DT]:
140
+ def asin(self) -> CompatArray[type[float], DT]:
141
141
  """
142
142
  Computes the element-wise `principal value of the inverse sine` of `self`.
143
143
  - `self` should have a floating-point data type.
144
144
  """
145
145
  ...
146
146
 
147
- def asinh(self) -> CompatArray[float, DT]:
147
+ def asinh(self) -> CompatArray[type[float], DT]:
148
148
  """
149
149
  Computes the element-wise `inverse hyperbolic sine` of `self`.
150
150
  - `self` should have a floating-point data type.
151
151
  """
152
152
  ...
153
153
 
154
- def atan(self) -> CompatArray[float, DT]:
154
+ def atan(self) -> CompatArray[type[float], DT]:
155
155
  """
156
156
  Computes the element-wise `principal value of the inverse tangent` of `self`.
157
157
  - `self` should have a floating-point data type.
158
158
  """
159
159
  ...
160
160
 
161
- def atan2(self, other: ArrayOrReal, /) -> CompatArray[float, DT]:
161
+ def atan2(self, other: ArrayOrReal, /) -> CompatArray[type[float], DT]:
162
162
  """
163
163
  Computes the element-wise `inverse tangent` of `self / other`, taking into account the signs of both inputs.
164
164
  - `self` should have a real-valued floating-point data type.
@@ -166,7 +166,7 @@ class CompatArray(Compat, Generic[TT, DT]):
166
166
  """
167
167
  ...
168
168
 
169
- def atanh(self) -> CompatArray[float, DT]:
169
+ def atanh(self) -> CompatArray[type[float], DT]:
170
170
  """
171
171
  Computes the element-wise `inverse hyperbolic tangent` of `self`.
172
172
  - `self` should have a floating-point data type.
@@ -240,7 +240,7 @@ class CompatArray(Compat, Generic[TT, DT]):
240
240
  """
241
241
  ...
242
242
 
243
- def copysign(self, other: ArrayOrReal, /) -> CompatArray[float, DT]:
243
+ def copysign(self, other: ArrayOrReal, /) -> CompatArray[type[float], DT]:
244
244
  """
245
245
  Computes the element-wise `copysign` of `self` with `other`.
246
246
  - `self` should have a real-valued floating-point data type.
@@ -248,41 +248,41 @@ class CompatArray(Compat, Generic[TT, DT]):
248
248
  """
249
249
  ...
250
250
 
251
- def cos(self) -> CompatArray[float, DT]:
251
+ def cos(self) -> CompatArray[type[float], DT]:
252
252
  """
253
253
  Computes the element-wise `cosine` of `self`.
254
254
  - `self` should have a floating-point data type.
255
255
  """
256
256
  ...
257
257
 
258
- def cosh(self) -> CompatArray[float, DT]:
258
+ def cosh(self) -> CompatArray[type[float], DT]:
259
259
  """
260
260
  Computes the element-wise `hyperbolic cosine` of `self`.
261
261
  - `self` should have a floating-point data type.
262
262
  """
263
263
  ...
264
264
 
265
- def divide(self, other: ArrayOrScalar, /) -> CompatArray[float, DT]:
265
+ def divide(self, other: ArrayOrScalar, /) -> CompatArray[type[float], DT]:
266
266
  """
267
267
  Computes the element-wise `division` of `self` by `other`.
268
268
  - `self` should have a numeric data type.
269
269
  """
270
270
  ...
271
271
 
272
- def equal(self, other: ArrayOrAny, /) -> CompatArray[bool, DT]:
272
+ def equal(self, other: ArrayOrAny, /) -> CompatArray[type[bool], DT]:
273
273
  """
274
274
  Computes the element-wise truth value of `self == other`.
275
275
  """
276
276
  ...
277
277
 
278
- def exp(self) -> CompatArray[float, DT]:
278
+ def exp(self) -> CompatArray[type[float], DT]:
279
279
  """
280
280
  Computes the element-wise `exponential` (`exp(x)`) of `self`.
281
281
  - `self` should have a floating-point data type.
282
282
  """
283
283
  ...
284
284
 
285
- def expm1(self) -> CompatArray[float, DT]:
285
+ def expm1(self) -> CompatArray[type[float], DT]:
286
286
  """
287
287
  Computes the element-wise `exp(x) - 1` of `self`.
288
288
  - `self` should have a floating-point data type.
@@ -305,21 +305,21 @@ class CompatArray(Compat, Generic[TT, DT]):
305
305
  """
306
306
  ...
307
307
 
308
- def greater(self, other: ArrayOrReal, /) -> CompatArray[bool, DT]:
308
+ def greater(self, other: ArrayOrReal, /) -> CompatArray[type[bool], DT]:
309
309
  """
310
310
  Computes the element-wise truth value of `self > other`.
311
311
  - `self` should have a real-valued data type.
312
312
  """
313
313
  ...
314
314
 
315
- def greater_equal(self, other: ArrayOrReal, /) -> CompatArray[bool, DT]:
315
+ def greater_equal(self, other: ArrayOrReal, /) -> CompatArray[type[bool], DT]:
316
316
  """
317
317
  Computes the element-wise truth value of `self >= other`.
318
318
  - `self` should have a real-valued data type.
319
319
  """
320
320
  ...
321
321
 
322
- def hypot(self, other: ArrayOrReal, /) -> CompatArray[float, DT]:
322
+ def hypot(self, other: ArrayOrReal, /) -> CompatArray[type[float], DT]:
323
323
  """
324
324
  Computes the element-wise `hypotenuse` of `self` and `other`.
325
325
  - `self` should have a real-valued floating-point data type.
@@ -327,77 +327,77 @@ class CompatArray(Compat, Generic[TT, DT]):
327
327
  """
328
328
  ...
329
329
 
330
- def imag(self) -> CompatArray[float, DT]:
330
+ def imag(self) -> CompatArray[type[float], DT]:
331
331
  """
332
332
  Computes the element-wise `imaginary component` of `self`.
333
333
  - `self` should have a complex floating-point data type.
334
334
  """
335
335
  ...
336
336
 
337
- def isfinite(self) -> CompatArray[bool, DT]:
337
+ def isfinite(self) -> CompatArray[type[bool], DT]:
338
338
  """
339
339
  Tests the element-wise `finiteness` of `self`.
340
340
  - `self` should have a numeric data type.
341
341
  """
342
342
  ...
343
343
 
344
- def isinf(self) -> CompatArray[bool, DT]:
344
+ def isinf(self) -> CompatArray[type[bool], DT]:
345
345
  """
346
346
  Tests the element-wise `infinity` of `self`.
347
347
  - - `self` should have a numeric data type.
348
348
  """
349
349
  ...
350
350
 
351
- def isnan(self) -> CompatArray[bool, DT]:
351
+ def isnan(self) -> CompatArray[type[bool], DT]:
352
352
  """
353
353
  Tests the element-wise `NaN` of `self`.
354
354
  - `self` should have a numeric data type.
355
355
  """
356
356
  ...
357
357
 
358
- def less(self, other: ArrayOrReal, /) -> CompatArray[bool, DT]:
358
+ def less(self, other: ArrayOrReal, /) -> CompatArray[type[bool], DT]:
359
359
  """
360
360
  Computes the element-wise truth value of `self < other`.
361
361
  - `self` should have a real-valued data type.
362
362
  """
363
363
  ...
364
364
 
365
- def less_equal(self, other: ArrayOrReal, /) -> CompatArray[bool, DT]:
365
+ def less_equal(self, other: ArrayOrReal, /) -> CompatArray[type[bool], DT]:
366
366
  """
367
367
  Computes the element-wise truth value of `self <= other`.
368
368
  - `self` should have a real-valued data type.
369
369
  """
370
370
  ...
371
371
 
372
- def log(self) -> CompatArray[float, DT]:
372
+ def log(self) -> CompatArray[type[float], DT]:
373
373
  """
374
374
  Computes the element-wise `natural logarithm` (base `e`) of `self`.
375
375
  - `self` should have a floating-point data type.
376
376
  """
377
377
  ...
378
378
 
379
- def log1p(self) -> CompatArray[float, DT]:
379
+ def log1p(self) -> CompatArray[type[float], DT]:
380
380
  """
381
381
  Computes the element-wise `log(1 + x)` (base `e`) of `self`.
382
382
  - `self` should have a floating-point data type.
383
383
  """
384
384
  ...
385
385
 
386
- def log2(self) -> CompatArray[float, DT]:
386
+ def log2(self) -> CompatArray[type[float], DT]:
387
387
  """
388
388
  Computes the element-wise `base-2 logarithm` of `self`.
389
389
  - `self` should have a floating-point data type.
390
390
  """
391
391
  ...
392
392
 
393
- def log10(self) -> CompatArray[float, DT]:
393
+ def log10(self) -> CompatArray[type[float], DT]:
394
394
  """
395
395
  Computes the element-wise `base-10 logarithm` of `self`.
396
396
  - `self` should have a floating-point data type.
397
397
  """
398
398
  ...
399
399
 
400
- def logaddexp(self, other: ArrayOrReal, /) -> CompatArray[float, DT]:
400
+ def logaddexp(self, other: ArrayOrReal, /) -> CompatArray[type[float], DT]:
401
401
  """
402
402
  Computes the element-wise `logaddexp` of `self` and `other`.
403
403
  - Equivalent to `log(exp(self) + exp(other))`.
@@ -405,28 +405,28 @@ class CompatArray(Compat, Generic[TT, DT]):
405
405
  """
406
406
  ...
407
407
 
408
- def logical_and(self, other: ArrayOrbool, /) -> CompatArray[bool, DT]:
408
+ def logical_and(self, other: ArrayOrbool, /) -> CompatArray[type[bool], DT]:
409
409
  """
410
410
  Computes the element-wise `logical AND` of `self` and `other`.
411
411
  - `self` should have a boolean data type.
412
412
  """
413
413
  ...
414
414
 
415
- def logical_not(self) -> CompatArray[bool, DT]:
415
+ def logical_not(self) -> CompatArray[type[bool], DT]:
416
416
  """
417
417
  Computes the element-wise `logical NOT` of `self`.
418
418
  - `self` should have a boolean data type.
419
419
  """
420
420
  ...
421
421
 
422
- def logical_or(self, other: ArrayOrbool, /) -> CompatArray[bool, DT]:
422
+ def logical_or(self, other: ArrayOrbool, /) -> CompatArray[type[bool], DT]:
423
423
  """
424
424
  Computes the element-wise `logical OR` of `self` and `other`.
425
425
  - `self` should have a boolean data type.
426
426
  """
427
427
  ...
428
428
 
429
- def logical_xor(self, other: ArrayOrbool, /) -> CompatArray[bool, DT]:
429
+ def logical_xor(self, other: ArrayOrbool, /) -> CompatArray[type[bool], DT]:
430
430
  """
431
431
  Computes the element-wise `logical XOR` of `self` and `other`.
432
432
  - `self` should have a boolean data type.
@@ -468,7 +468,7 @@ class CompatArray(Compat, Generic[TT, DT]):
468
468
  """
469
469
  ...
470
470
 
471
- def not_equal(self, other: ArrayOrAny, /) -> CompatArray[bool, DT]:
471
+ def not_equal(self, other: ArrayOrAny, /) -> CompatArray[type[bool], DT]:
472
472
  """
473
473
  Computes the element-wise truth value of `self != other`.
474
474
  """
@@ -489,14 +489,14 @@ class CompatArray(Compat, Generic[TT, DT]):
489
489
  """
490
490
  ...
491
491
 
492
- def real(self) -> CompatArray[float, DT]:
492
+ def real(self) -> CompatArray[type[float], DT]:
493
493
  """
494
494
  Computes the element-wise `real component` of `self`.
495
495
  - `self` should have a numeric data type.
496
496
  """
497
497
  ...
498
498
 
499
- def reciprocal(self) -> CompatArray[float, DT]:
499
+ def reciprocal(self) -> CompatArray[type[float], DT]:
500
500
  """
501
501
  Computes the element-wise `reciprocal` of `self`.
502
502
  - `self` should have a floating-point data type.
@@ -524,7 +524,7 @@ class CompatArray(Compat, Generic[TT, DT]):
524
524
  """
525
525
  ...
526
526
 
527
- def signbit(self) -> CompatArray[bool, DT]:
527
+ def signbit(self) -> CompatArray[type[bool], DT]:
528
528
  """
529
529
  Tests the element-wise `sign bit` of `self`.
530
530
  - Tests each element for whenever is either `-0`, `less than zero`, or a signed `NaN` (i.e., a NaN value whose sign bit is 1).
@@ -532,14 +532,14 @@ class CompatArray(Compat, Generic[TT, DT]):
532
532
  """
533
533
  ...
534
534
 
535
- def sin(self) -> CompatArray[float, DT]:
535
+ def sin(self) -> CompatArray[type[float], DT]:
536
536
  """
537
537
  Computes the element-wise `sine` of `self`.
538
538
  - `self` should have a floating-point data type.
539
539
  """
540
540
  ...
541
541
 
542
- def sinh(self) -> CompatArray[float, DT]:
542
+ def sinh(self) -> CompatArray[type[float], DT]:
543
543
  """
544
544
  Computes the element-wise `hyperbolic sine` of `self`.
545
545
  - `self` should have a floating-point data type.
@@ -553,7 +553,7 @@ class CompatArray(Compat, Generic[TT, DT]):
553
553
  """
554
554
  ...
555
555
 
556
- def sqrt(self) -> CompatArray[float, DT]:
556
+ def sqrt(self) -> CompatArray[type[float], DT]:
557
557
  """
558
558
  Computes the element-wise `principal square root` of `self`.
559
559
  - `self` should have a floating-point data type.
@@ -567,14 +567,14 @@ class CompatArray(Compat, Generic[TT, DT]):
567
567
  """
568
568
  ...
569
569
 
570
- def tan(self) -> CompatArray[float, DT]:
570
+ def tan(self) -> CompatArray[type[float], DT]:
571
571
  """
572
572
  Computes the element-wise `tangent` of `self`.
573
573
  - `self` should have a floating-point data type.
574
574
  """
575
575
  ...
576
576
 
577
- def tanh(self) -> CompatArray[float, DT]:
577
+ def tanh(self) -> CompatArray[type[float], DT]:
578
578
  """
579
579
  Computes the element-wise `hyperbolic tangent` of `self`.
580
580
  - `self` should have a floating-point data type.
@@ -993,7 +993,7 @@ class CompatArray(Compat, Generic[TT, DT]):
993
993
  self, *,
994
994
  axis: Optional[int] = None,
995
995
  keepdims: bool = False
996
- ) -> CompatArray[int, DT]:
996
+ ) -> CompatArray[type[int], DT]:
997
997
  """
998
998
  Returns the indices of the maximum values along a specified axis.
999
999
 
@@ -1026,7 +1026,7 @@ class CompatArray(Compat, Generic[TT, DT]):
1026
1026
  self, *,
1027
1027
  axis: Optional[int] = None,
1028
1028
  keepdims: bool = False
1029
- ) -> CompatArray[int, DT]:
1029
+ ) -> CompatArray[type[int], DT]:
1030
1030
  """
1031
1031
  Returns the indices of the minimum values along a specified axis.
1032
1032
 
@@ -1055,13 +1055,13 @@ class CompatArray(Compat, Generic[TT, DT]):
1055
1055
  """
1056
1056
  ...
1057
1057
 
1058
- def nonzero(self) -> Tuple[CompatArray[int, DT], ...]: ...
1058
+ def nonzero(self) -> Tuple[CompatArray[type[int], DT], ...]: ...
1059
1059
 
1060
1060
  def count_nonzero(
1061
1061
  self, *,
1062
1062
  axis: Optional[Union[int, Tuple[int, ...]]] = None,
1063
1063
  keepdims: bool = False
1064
- ) -> CompatArray[int, DT]:
1064
+ ) -> CompatArray[type[int], DT]:
1065
1065
  """
1066
1066
  Counts the number of `self` elements which are non-zero.
1067
1067
 
@@ -1096,7 +1096,7 @@ class CompatArray(Compat, Generic[TT, DT]):
1096
1096
  /, *,
1097
1097
  side: Literal['left', 'right'] = "left",
1098
1098
  sorter: Optional[ArrayLike[Any]] = None
1099
- ) -> CompatArray[int, DT]:
1099
+ ) -> CompatArray[type[int], DT]:
1100
1100
  """
1101
1101
  Finds the indices into `self` such that, if the corresponding elements in `other` were inserted before the indices, the order of `self`, when sorted in ascending order, would be preserved.
1102
1102
  - `self` must be a one-dimensional array. Should have a real-valued data type.
@@ -1187,7 +1187,7 @@ class CompatArray(Compat, Generic[TT, DT]):
1187
1187
  axis: int = -1,
1188
1188
  descending: bool = False,
1189
1189
  stable: bool = True
1190
- ) -> CompatArray[int, DT]:
1190
+ ) -> CompatArray[type[int], DT]:
1191
1191
  """
1192
1192
  Returns the indices that sort `self` along a specified axis.
1193
1193
 
@@ -1633,7 +1633,7 @@ class CompatArray(Compat, Generic[TT, DT]):
1633
1633
  self, *,
1634
1634
  axis: Optional[Union[int, Tuple[int, ...]]] = None,
1635
1635
  keepdims: bool = False
1636
- ) -> CompatArray[bool, DT]:
1636
+ ) -> CompatArray[type[bool], DT]:
1637
1637
  """
1638
1638
  Tests whether all `self` elements evaluate to `True` along a specified axis.
1639
1639
  - `Positive infinity`, `negative infinity`, and `NaN` must evaluate to `True`;
@@ -1666,7 +1666,7 @@ class CompatArray(Compat, Generic[TT, DT]):
1666
1666
  self, *,
1667
1667
  axis: Optional[Union[int, Tuple[int, ...]]] = None,
1668
1668
  keepdims: bool = False
1669
- ) -> CompatArray[bool, DT]:
1669
+ ) -> CompatArray[type[bool], DT]:
1670
1670
  """
1671
1671
  Tests whether any `self` elements evaluate to `True` along a specified axis.
1672
1672
  - `Positive infinity`, `negative infinity`, and `NaN` must evaluate to `True`;
@@ -1778,22 +1778,22 @@ class CompatArray(Compat, Generic[TT, DT]):
1778
1778
  def __and__(self, other: ArrayOrIntLike, /) -> CompatArray[TT, DT]: ...
1779
1779
  def __bool__(self) -> bool: ...
1780
1780
  def __complex__(self) -> complex: ...
1781
- def __eq__(self, other: ArrayOrAny, /) -> CompatArray[bool, DT]: ...
1781
+ def __eq__(self, other: ArrayOrAny, /) -> CompatArray[type[bool], DT]: ...
1782
1782
  def __float__(self) -> float: ...
1783
1783
  def __floordiv__(self, other: ArrayOrReal, /) -> CompatArray[TT, DT]: ...
1784
- def __ge__(self, other: ArrayOrReal, /) -> CompatArray[bool, DT]: ...
1784
+ def __ge__(self, other: ArrayOrReal, /) -> CompatArray[type[bool], DT]: ...
1785
1785
  def __getitem__(self, key: Any, /) -> CompatArray[TT, DT]: ...
1786
- def __gt__(self, other: ArrayOrReal, /) -> CompatArray[bool, DT]: ...
1786
+ def __gt__(self, other: ArrayOrReal, /) -> CompatArray[type[bool], DT]: ...
1787
1787
  def __index__(self) -> int: ...
1788
1788
  def __int__(self) -> int: ...
1789
1789
  def __invert__(self) -> CompatArray[TT, DT]: ...
1790
- def __le__(self, other: ArrayOrReal, /) -> CompatArray[bool, DT]: ...
1790
+ def __le__(self, other: ArrayOrReal, /) -> CompatArray[type[bool], DT]: ...
1791
1791
  def __lshift__(self, other: ArrayOrInt, /) -> CompatArray[TT, DT]: ...
1792
- def __lt__(self, other: ArrayOrReal, /) -> CompatArray[bool, DT]: ...
1792
+ def __lt__(self, other: ArrayOrReal, /) -> CompatArray[type[bool], DT]: ...
1793
1793
  def __matmul__(self, other: ArrayLike[Any], /) -> CompatArray[Any, DT]: ...
1794
1794
  def __mod__(self, other: ArrayOrReal, /) -> CompatArray[Any, DT]: ...
1795
1795
  def __mul__(self, other: ArrayOrScalar, /) -> CompatArray[Any, DT]: ...
1796
- def __ne__(self, other: ArrayOrAny, /) -> CompatArray[bool, DT]: ...
1796
+ def __ne__(self, other: ArrayOrAny, /) -> CompatArray[type[bool], DT]: ...
1797
1797
  def __neg__(self) -> CompatArray[TT, DT]: ...
1798
1798
  def __or__(self, other: ArrayOrIntLike, /) -> CompatArray[TT, DT]: ...
1799
1799
  def __pos__(self) -> CompatArray[TT, DT]: ...
@@ -1801,7 +1801,7 @@ class CompatArray(Compat, Generic[TT, DT]):
1801
1801
  def __rshift__(self, other: ArrayOrInt, /) -> CompatArray[TT, DT]: ...
1802
1802
  def __setitem__(self, key: Any, value: Any, /): ...
1803
1803
  def __sub__(self, other: ArrayOrScalar, /) -> CompatArray[Any, DT]: ...
1804
- def __truediv__(self, other: ArrayOrScalar, /) -> CompatArray[float, DT]: ...
1804
+ def __truediv__(self, other: ArrayOrScalar, /) -> CompatArray[type[float], DT]: ...
1805
1805
  def __xor__(self, other: ArrayOrIntLike, /) -> CompatArray[TT, DT]: ...
1806
1806
 
1807
1807
 
@@ -82,17 +82,17 @@ class CompatNamespace(Compat):
82
82
  ...
83
83
 
84
84
  @overload
85
- def arange(self, start: int, /, stop: Optional[int] = ..., step: int = ..., *, dtype: None = ..., device: None = ...) -> CompatArray[int, Literal["cpu"]]: ...
85
+ def arange(self, start: int, /, stop: Optional[int] = ..., step: int = ..., *, dtype: None = ..., device: None = ...) -> CompatArray[type[int], Literal["cpu"]]: ...
86
86
  @overload
87
- def arange(self, start: Union[int, float], /, stop: Optional[Union[int, float]] = ..., step: Union[int, float] = ..., *, dtype: None = ..., device: None = ...) -> CompatArray[float, Literal["cpu"]]: ...
87
+ def arange(self, start: Union[int, float], /, stop: Optional[Union[int, float]] = ..., step: Union[int, float] = ..., *, dtype: None = ..., device: None = ...) -> CompatArray[type[float], Literal["cpu"]]: ...
88
88
  @overload
89
- def arange(self, start: int, /, stop: Optional[int] = ..., step: int = ..., *, dtype: None = ..., device: DeviceT) -> CompatArray[int, DeviceT]: ...
89
+ def arange(self, start: int, /, stop: Optional[int] = ..., step: int = ..., *, dtype: None = ..., device: DeviceT) -> CompatArray[type[int], DeviceT]: ...
90
90
  @overload
91
- def arange(self, start: int, /, stop: Optional[int] = ..., step: int = ..., *, dtype: None = ..., device: AnyDevice) -> CompatArray[int, AnyDevice]: ...
91
+ def arange(self, start: int, /, stop: Optional[int] = ..., step: int = ..., *, dtype: None = ..., device: AnyDevice) -> CompatArray[type[int], AnyDevice]: ...
92
92
  @overload
93
- def arange(self, start: Union[int, float], /, stop: Optional[Union[int, float]] = ..., step: Union[int, float] = ..., *, dtype: None = ..., device: DeviceT) -> CompatArray[float, DeviceT]: ...
93
+ def arange(self, start: Union[int, float], /, stop: Optional[Union[int, float]] = ..., step: Union[int, float] = ..., *, dtype: None = ..., device: DeviceT) -> CompatArray[type[float], DeviceT]: ...
94
94
  @overload
95
- def arange(self, start: Union[int, float], /, stop: Optional[Union[int, float]] = ..., step: Union[int, float] = ..., *, dtype: None = ..., device: AnyDevice) -> CompatArray[float, AnyDevice]: ...
95
+ def arange(self, start: Union[int, float], /, stop: Optional[Union[int, float]] = ..., step: Union[int, float] = ..., *, dtype: None = ..., device: AnyDevice) -> CompatArray[type[float], AnyDevice]: ...
96
96
  @overload
97
97
  def arange(self, start: Union[int, float], /, stop: Optional[Union[int, float]] = ..., step: Union[int, float] = ..., *, dtype: DTypeT, device: None = ...) -> CompatArray[DTypeT, Literal["cpu"]]: ...
98
98
  @overload
@@ -143,11 +143,11 @@ class CompatNamespace(Compat):
143
143
  ...
144
144
 
145
145
  @overload
146
- def empty(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: None = ...) -> CompatArray[float, Literal["cpu"]]: ...
146
+ def empty(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: None = ...) -> CompatArray[type[float], Literal["cpu"]]: ...
147
147
  @overload
148
- def empty(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: DeviceT) -> CompatArray[float, DeviceT]: ...
148
+ def empty(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: DeviceT) -> CompatArray[type[float], DeviceT]: ...
149
149
  @overload
150
- def empty(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: AnyDevice) -> CompatArray[float, AnyDevice]: ...
150
+ def empty(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: AnyDevice) -> CompatArray[type[float], AnyDevice]: ...
151
151
  @overload
152
152
  def empty(self, shape: Union[int, Tuple[int, ...]], *, dtype: DTypeT, device: None = ...) -> CompatArray[DTypeT, Literal["cpu"]]: ...
153
153
  @overload
@@ -230,11 +230,11 @@ class CompatNamespace(Compat):
230
230
  ...
231
231
 
232
232
  @overload
233
- def eye(self, n_rows: int, n_cols: Optional[int] = ..., /, *, k: int = ..., dtype: None = ..., device: None = ...) -> CompatArray[float, Literal["cpu"]]: ...
233
+ def eye(self, n_rows: int, n_cols: Optional[int] = ..., /, *, k: int = ..., dtype: None = ..., device: None = ...) -> CompatArray[type[float], Literal["cpu"]]: ...
234
234
  @overload
235
- def eye(self, n_rows: int, n_cols: Optional[int] = ..., /, *, k: int = ..., dtype: None = ..., device: DeviceT) -> CompatArray[float, DeviceT]: ...
235
+ def eye(self, n_rows: int, n_cols: Optional[int] = ..., /, *, k: int = ..., dtype: None = ..., device: DeviceT) -> CompatArray[type[float], DeviceT]: ...
236
236
  @overload
237
- def eye(self, n_rows: int, n_cols: Optional[int] = ..., /, *, k: int = ..., dtype: None = ..., device: AnyDevice) -> CompatArray[float, AnyDevice]: ...
237
+ def eye(self, n_rows: int, n_cols: Optional[int] = ..., /, *, k: int = ..., dtype: None = ..., device: AnyDevice) -> CompatArray[type[float], AnyDevice]: ...
238
238
  @overload
239
239
  def eye(self, n_rows: int, n_cols: Optional[int] = ..., /, *, k: int = ..., dtype: DTypeT, device: None = ...) -> CompatArray[DTypeT, Literal["cpu"]]: ...
240
240
  @overload
@@ -432,11 +432,11 @@ class CompatNamespace(Compat):
432
432
  ...
433
433
 
434
434
  @overload
435
- def linspace(self, start: Union[int, float, complex], stop: Union[int, float, complex], /, num: int, *, dtype: None = ..., device: None = ..., endpoint: bool = ...) -> CompatArray[float, Literal["cpu"]]: ...
435
+ def linspace(self, start: Union[int, float, complex], stop: Union[int, float, complex], /, num: int, *, dtype: None = ..., device: None = ..., endpoint: bool = ...) -> CompatArray[type[float], Literal["cpu"]]: ...
436
436
  @overload
437
- def linspace(self, start: Union[int, float, complex], stop: Union[int, float, complex], /, num: int, *, dtype: None = ..., device: DeviceT, endpoint: bool = ...) -> CompatArray[float, DeviceT]: ...
437
+ def linspace(self, start: Union[int, float, complex], stop: Union[int, float, complex], /, num: int, *, dtype: None = ..., device: DeviceT, endpoint: bool = ...) -> CompatArray[type[float], DeviceT]: ...
438
438
  @overload
439
- def linspace(self, start: Union[int, float, complex], stop: Union[int, float, complex], /, num: int, *, dtype: None = ..., device: AnyDevice, endpoint: bool = ...) -> CompatArray[float, AnyDevice]: ...
439
+ def linspace(self, start: Union[int, float, complex], stop: Union[int, float, complex], /, num: int, *, dtype: None = ..., device: AnyDevice, endpoint: bool = ...) -> CompatArray[type[float], AnyDevice]: ...
440
440
  @overload
441
441
  def linspace(self, start: Union[int, float, complex], stop: Union[int, float, complex], /, num: int, *, dtype: DTypeT, device: None = ..., endpoint: bool = ...) -> CompatArray[DTypeT, Literal["cpu"]]: ...
442
442
  @overload
@@ -497,11 +497,11 @@ class CompatNamespace(Compat):
497
497
  def meshgrid(self, *arrays: ArrayLike[Any], indexing: Literal["xy", "ij"] = "xy") -> List[CompatArray[Any, AnyDevice]]: ...
498
498
 
499
499
  @overload
500
- def ones(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: None = ...) -> CompatArray[float, Literal["cpu"]]: ...
500
+ def ones(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: None = ...) -> CompatArray[type[float], Literal["cpu"]]: ...
501
501
  @overload
502
- def ones(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: DeviceT) -> CompatArray[float, DeviceT]: ...
502
+ def ones(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: DeviceT) -> CompatArray[type[float], DeviceT]: ...
503
503
  @overload
504
- def ones(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: AnyDevice) -> CompatArray[float, AnyDevice]: ...
504
+ def ones(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: AnyDevice) -> CompatArray[type[float], AnyDevice]: ...
505
505
  @overload
506
506
  def ones(self, shape: Union[int, Tuple[int, ...]], *, dtype: DTypeT, device: None = ...) -> CompatArray[DTypeT, Literal["cpu"]]: ...
507
507
  @overload
@@ -649,11 +649,11 @@ class CompatNamespace(Compat):
649
649
  ...
650
650
 
651
651
  @overload
652
- def zeros(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: None = ...) -> CompatArray[float, Literal["cpu"]]: ...
652
+ def zeros(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: None = ...) -> CompatArray[type[float], Literal["cpu"]]: ...
653
653
  @overload
654
- def zeros(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: DeviceT) -> CompatArray[float, DeviceT]: ...
654
+ def zeros(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: DeviceT) -> CompatArray[type[float], DeviceT]: ...
655
655
  @overload
656
- def zeros(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: AnyDevice) -> CompatArray[float, AnyDevice]: ...
656
+ def zeros(self, shape: Union[int, Tuple[int, ...]], *, dtype: None = ..., device: AnyDevice) -> CompatArray[type[float], AnyDevice]: ...
657
657
  @overload
658
658
  def zeros(self, shape: Union[int, Tuple[int, ...]], *, dtype: DTypeT, device: None = ...) -> CompatArray[DTypeT, Literal["cpu"]]: ...
659
659
  @overload
@@ -844,20 +844,20 @@ class CompatNamespace(Compat):
844
844
 
845
845
  # === Linear Algebra Extension ===
846
846
  @overload
847
- def vector_norm(self, x: NDArray[Any], /, *, axis: Optional[Union[int, Tuple[int, ...]]] = ..., keepdims: bool = ..., ord: Union[int, float, Literal["inf", "-inf"]] = ...) -> CompatArray[float, Literal["cpu"]]: ...
847
+ def vector_norm(self, x: NDArray[Any], /, *, axis: Optional[Union[int, Tuple[int, ...]]] = ..., keepdims: bool = ..., ord: Union[int, float, Literal["inf", "-inf"]] = ...) -> CompatArray[type[float], Literal["cpu"]]: ...
848
848
  @overload
849
- def vector_norm(self, x: CompatArray[Any, deviceT], /, *, axis: Optional[Union[int, Tuple[int, ...]]] = ..., keepdims: bool = ..., ord: Union[int, float, Literal["inf", "-inf"]] = ...) -> CompatArray[float, deviceT]: ...
849
+ def vector_norm(self, x: CompatArray[Any, deviceT], /, *, axis: Optional[Union[int, Tuple[int, ...]]] = ..., keepdims: bool = ..., ord: Union[int, float, Literal["inf", "-inf"]] = ...) -> CompatArray[type[float], deviceT]: ...
850
850
  @overload
851
- def vector_norm(self, x: ArrayLike[Any], /, *, axis: Optional[Union[int, Tuple[int, ...]]] = ..., keepdims: bool = ..., ord: Union[int, float, Literal["inf", "-inf"]] = ...) -> CompatArray[float, AnyDevice]: ...
852
- def vector_norm(self, x: ArrayLike[Any], /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False, ord: Union[int, float, Literal["inf", "-inf"]] = 2) -> CompatArray[float, AnyDevice]: ...
851
+ def vector_norm(self, x: ArrayLike[Any], /, *, axis: Optional[Union[int, Tuple[int, ...]]] = ..., keepdims: bool = ..., ord: Union[int, float, Literal["inf", "-inf"]] = ...) -> CompatArray[type[float], AnyDevice]: ...
852
+ def vector_norm(self, x: ArrayLike[Any], /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False, ord: Union[int, float, Literal["inf", "-inf"]] = 2) -> CompatArray[type[float], AnyDevice]: ...
853
853
 
854
854
  @overload
855
- def matrix_norm(self, x: NDArray[Any], /, *, keepdims: bool = ..., ord: Optional[Union[int, float, Literal["inf", "-inf", "fro", "nuc"]]] = ...) -> CompatArray[float, Literal["cpu"]]: ...
855
+ def matrix_norm(self, x: NDArray[Any], /, *, keepdims: bool = ..., ord: Optional[Union[int, float, Literal["inf", "-inf", "fro", "nuc"]]] = ...) -> CompatArray[type[float], Literal["cpu"]]: ...
856
856
  @overload
857
- def matrix_norm(self, x: CompatArray[Any, deviceT], /, *, keepdims: bool = ..., ord: Optional[Union[int, float, Literal["inf", "-inf", "fro", "nuc"]]] = ...) -> CompatArray[float, deviceT]: ...
857
+ def matrix_norm(self, x: CompatArray[Any, deviceT], /, *, keepdims: bool = ..., ord: Optional[Union[int, float, Literal["inf", "-inf", "fro", "nuc"]]] = ...) -> CompatArray[type[float], deviceT]: ...
858
858
  @overload
859
- def matrix_norm(self, x: ArrayLike[Any], /, *, keepdims: bool = ..., ord: Optional[Union[int, float, Literal["inf", "-inf", "fro", "nuc"]]] = ...) -> CompatArray[float, AnyDevice]: ...
860
- def matrix_norm(self, x: ArrayLike[Any], /, *, keepdims: bool = False, ord: Optional[Union[int, float, Literal["inf", "-inf", "fro", "nuc"]]] = "fro") -> CompatArray[float, AnyDevice]: ...
859
+ def matrix_norm(self, x: ArrayLike[Any], /, *, keepdims: bool = ..., ord: Optional[Union[int, float, Literal["inf", "-inf", "fro", "nuc"]]] = ...) -> CompatArray[type[float], AnyDevice]: ...
860
+ def matrix_norm(self, x: ArrayLike[Any], /, *, keepdims: bool = False, ord: Optional[Union[int, float, Literal["inf", "-inf", "fro", "nuc"]]] = "fro") -> CompatArray[type[float], AnyDevice]: ...
861
861
 
862
862
  @property
863
863
  def linalg(self) -> ModuleType: ...
@@ -56,16 +56,16 @@ ArrayOrInt = Union[ArrayLike[Any], int]
56
56
 
57
57
  class UniqueAllResult(NamedTuple, Generic[DTypeT_co, AnyDeviceT_co]):
58
58
  values: CompatArray[DTypeT_co, AnyDeviceT_co]
59
- indices: CompatArray[int, AnyDeviceT_co]
60
- inverse_indices: CompatArray[int, AnyDeviceT_co]
61
- counts: CompatArray[int, AnyDeviceT_co]
59
+ indices: CompatArray[type[int], AnyDeviceT_co]
60
+ inverse_indices: CompatArray[type[int], AnyDeviceT_co]
61
+ counts: CompatArray[type[int], AnyDeviceT_co]
62
62
 
63
63
 
64
64
  class UniqueCountsResult(NamedTuple, Generic[DTypeT_co, AnyDeviceT_co]):
65
65
  values: CompatArray[DTypeT_co, AnyDeviceT_co]
66
- counts: CompatArray[int, AnyDeviceT_co]
66
+ counts: CompatArray[type[int], AnyDeviceT_co]
67
67
 
68
68
 
69
69
  class UniqueInverseResult(NamedTuple, Generic[DTypeT_co, AnyDeviceT_co]):
70
70
  values: CompatArray[DTypeT_co, AnyDeviceT_co]
71
- inverse_indices: CompatArray[int, AnyDeviceT_co]
71
+ inverse_indices: CompatArray[type[int], AnyDeviceT_co]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cobra-array
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A backend-agnostic array utility library that unifies array conversion, context control, and cross-library operations across `NumPy`/`PyTorch`-style ecosystems.
5
5
  Author-email: Zhen Tian <zhen.tian.cs@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/tinchen777/cobra-array.git
@@ -85,6 +85,15 @@ def test_unstack_and_nonzero():
85
85
 
86
86
  pieces = a.unstack(axis=0)
87
87
  nz = a.nonzero()
88
+
89
+ ff = CompatArray(nz[0])
90
+
91
+ fff = a.cxp.zeros((1,2))
92
+
93
+ ff = CompatArray(fff)
94
+
95
+ gg = a.argmax()
96
+
88
97
 
89
98
  assert isinstance(pieces, tuple)
90
99
  assert len(pieces) == 2
File without changes
File without changes
File without changes
File without changes