Skip to content

Commit

Permalink
Mark require_one_based_indexing and has_offset_axes as public (#5…
Browse files Browse the repository at this point in the history
…6196)

The discussion here mentions `require_one_based_indexing` being part of
the public API: #43263

Both functions are also documented (albeit in the dev docs): 
* `require_one_based_indexing`:
https://docs.julialang.org/en/v1/devdocs/offset-arrays/#man-custom-indices
* `has_offset_axes`:
https://docs.julialang.org/en/v1/devdocs/offset-arrays/#For-objects-that-mimic-AbstractArray-but-are-not-subtypes

Towards #51335.

---------

Co-authored-by: Matt Bauman <mbauman@gmail.com>
  • Loading branch information
adrhill and mbauman authored Oct 25, 2024
1 parent bf8f814 commit b81e33f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ New library features
the uniquing checking ([#53474])
* `RegexMatch` objects can now be used to construct `NamedTuple`s and `Dict`s ([#50988])
* `Lockable` is now exported ([#54595])
* `Base.require_one_based_indexing` and `Base.has_offset_axes` are now public ([#56196])
* New `ltruncate`, `rtruncate` and `ctruncate` functions for truncating strings to text width, accounting for char widths ([#55351])
* `isless` (and thus `cmp`, sorting, etc.) is now supported for zero-dimensional `AbstractArray`s ([#55772])

Expand Down
4 changes: 4 additions & 0 deletions base/public.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public
acquire,
release,

# arrays
has_offset_axes,
require_one_based_indexing,

# collections
IteratorEltype,
IteratorSize,
Expand Down
6 changes: 6 additions & 0 deletions doc/src/base/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ Base.checkindex
Base.elsize
```

While most code can be written in an index-agnostic manner (see, e.g., [`eachindex`](@ref)), it can sometimes be useful to explicitly check for offset axes:
```@docs
Base.require_one_based_indexing
Base.has_offset_axes
```

## Views (SubArrays and other view types)

A “view” is a data structure that acts like an array (it is a subtype of `AbstractArray`), but the underlying data is actually
Expand Down

0 comments on commit b81e33f

Please sign in to comment.