You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use missing instead of nothing for dynamic values (#232)
* Use `missing` instead of `nothing` for dynamic values
* Tests pass locally, fixes: missing == missing -> missing means we need === for comparisons, and Static.find_first_eq still returns nothing on failure, like Base.findfirst
* Add test/Project.toml
* Updates for Static v0.5.1
* Remove `reduce_tup` from docs now that it's in Static
* Move block/banded stuff to requires
Co-authored-by: Chris Elrod <[email protected]>
Copy file name to clipboardExpand all lines: docs/src/index.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ julia> ArrayInterface.size(a)
44
44
(static(1), 3)
45
45
46
46
julia> ArrayInterface.known_size(typeof(a))
47
-
(1, nothing)
47
+
(1, missing)
48
48
49
49
```
50
50
@@ -62,8 +62,8 @@ Methods should avoid forcing conversion to static sizes when dynamic sizes could
62
62
Fore example, `fxn(x) = _fxn(Static.static(ArrayInterface.size(x)), x)` would result in dynamic dispatch if `x` is an instance of `Matrix`.
63
63
Additionally, `ArrayInterface.size` should only be used outside of generated functions to avoid possible world age issues.
64
64
65
-
Generally, `ArrayInterface.size` uses the return of `known_size` to form a static value for those dimensions with known length and only queries dimensions corresponding to `nothing`.
66
-
For example, the previous example had a known size of `(1, nothing)`.
65
+
Generally, `ArrayInterface.size` uses the return of `known_size` to form a static value for those dimensions with known length and only queries dimensions corresponding to `missing`.
66
+
For example, the previous example had a known size of `(1, missing)`.
67
67
Therefore, `ArrayInterface.size` would have compile time information about the first dimension returned as `static(1)` and would only look up the size of the second dimension at run time.
68
68
This means the above example `ArrayInterface.size(a)` would lower to code similar to this at compile time: `Static.StaticInt(1), Base.arraysize(x, 1)`.
69
69
Generic support for `ArrayInterface.known_size` relies on calling `known_length` for each type returned from `axes_types`.
@@ -155,7 +155,7 @@ using ArrayInterface: axes_types, parent_type, to_dims
155
155
for dim in1:ndims(A)
156
156
# offset relative to parent array
157
157
O =relative_known_offsets(A, dim)
158
-
if O ===nothing# offset is not known at compile time and is an `Int`
158
+
if O ===missing# offset is not known at compile time and is an `Int`
0 commit comments