array-api-shape-check 0.1.0__tar.gz → 0.1.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: array-api-shape-check
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Check shapes of input arrays easily
5
5
  Author-email: 34j <34j.95a2p@simplelogin.com>
6
6
  License-Expression: MIT
@@ -107,13 +107,7 @@ Not enough information to determine variable subscript ndims:
107
107
  >>> import pytest
108
108
  >>> from array_api_shape_check import InconsistentNdimErrorMultipleSolutions, InconsistentNdimErrorNoSolutions, InconsistentShapeError
109
109
  >>> with pytest.raises(InconsistentNdimErrorMultipleSolutions, match="number of variables"):
110
- ... check_shapes(
111
- ... "*i*j",
112
- ... (
113
- ... 1,
114
- ... 1,
115
- ... ),
116
- ... )
110
+ ... check_shapes("*i*j", (1, 1))
117
111
  >>> with pytest.raises(InconsistentNdimErrorMultipleSolutions, match="rank"):
118
112
  ... check_shapes("*i*j,*i*j", (1, 1), (1, 1))
119
113
  ```
@@ -79,13 +79,7 @@ Not enough information to determine variable subscript ndims:
79
79
  >>> import pytest
80
80
  >>> from array_api_shape_check import InconsistentNdimErrorMultipleSolutions, InconsistentNdimErrorNoSolutions, InconsistentShapeError
81
81
  >>> with pytest.raises(InconsistentNdimErrorMultipleSolutions, match="number of variables"):
82
- ... check_shapes(
83
- ... "*i*j",
84
- ... (
85
- ... 1,
86
- ... 1,
87
- ... ),
88
- ... )
82
+ ... check_shapes("*i*j", (1, 1))
89
83
  >>> with pytest.raises(InconsistentNdimErrorMultipleSolutions, match="rank"):
90
84
  ... check_shapes("*i*j,*i*j", (1, 1), (1, 1))
91
85
  ```
@@ -4,7 +4,7 @@ requires = [ "setuptools>=77.0.3" ]
4
4
 
5
5
  [project]
6
6
  name = "array-api-shape-check"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  description = "Check shapes of input arrays easily"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,4 +1,4 @@
1
- __version__ = "0.1.0"
1
+ __version__ = "0.1.1"
2
2
  from ._main import (
3
3
  InconsistentNdimError,
4
4
  InconsistentNdimErrorMultipleSolutions,
@@ -365,17 +365,28 @@ def check_shapes(
365
365
  >>> info.unique
366
366
  (i:3, j:4, *k:(5,), *l:(6, 7))
367
367
 
368
+ Internally `check_shapes()` calls `parse_variable_ndim()`,
369
+ which determines the number of dimensions for variable subscripts by least squares.
370
+ If this is successful, checks if each subscript is consistent,
371
+ then finnaly raises error for all inconsistencies at once.
372
+
373
+ Diving into the details of the first item:
374
+
375
+ >>> item = info.all[0][0]
376
+ >>> item.name # the name of the subscript
377
+ 'i'
378
+ >>> item.is_variable # whether the subscript is variable (starts with "*")
379
+ False
380
+ >>> item.shape_current # the current shape of the subscript
381
+ (1,)
382
+ >>> item.shape_broadcasted # the broadcasted shape of the subscript
383
+ (3,)
384
+
368
385
  Not enough information to determine variable subscript ndims:
369
386
 
370
387
  >>> import pytest
371
388
  >>> with pytest.raises(InconsistentNdimErrorMultipleSolutions, match="number of variables"):
372
- ... check_shapes(
373
- ... "*i*j",
374
- ... (
375
- ... 1,
376
- ... 1,
377
- ... ),
378
- ... )
389
+ ... check_shapes("*i*j", (1, 1))
379
390
  >>> with pytest.raises(InconsistentNdimErrorMultipleSolutions, match="rank"):
380
391
  ... check_shapes("*i*j,*i*j", (1, 1), (1, 1))
381
392
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: array-api-shape-check
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Check shapes of input arrays easily
5
5
  Author-email: 34j <34j.95a2p@simplelogin.com>
6
6
  License-Expression: MIT
@@ -107,13 +107,7 @@ Not enough information to determine variable subscript ndims:
107
107
  >>> import pytest
108
108
  >>> from array_api_shape_check import InconsistentNdimErrorMultipleSolutions, InconsistentNdimErrorNoSolutions, InconsistentShapeError
109
109
  >>> with pytest.raises(InconsistentNdimErrorMultipleSolutions, match="number of variables"):
110
- ... check_shapes(
111
- ... "*i*j",
112
- ... (
113
- ... 1,
114
- ... 1,
115
- ... ),
116
- ... )
110
+ ... check_shapes("*i*j", (1, 1))
117
111
  >>> with pytest.raises(InconsistentNdimErrorMultipleSolutions, match="rank"):
118
112
  ... check_shapes("*i*j,*i*j", (1, 1), (1, 1))
119
113
  ```