Skip to content

Commit

Permalink
remove default value for n
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Dec 20, 2023
1 parent 2df4df0 commit 83cca18
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ julia> import Pkg; Pkg.add("ChunkSplitters")
The main interface is the `chunks` iterator, and the enumeration of chunks, with `enumerate`.

```julia
chunks(array::AbstractArray; n::Int=Threads.nthreads(), distribution::Symbol=:batch)
chunks(array::AbstractArray; n::Int, distribution::Symbol=:batch)
```
This iterator returns a vector of ranges which indicates the range of indices of the input `array` for each given chunk. The `distribution` parameter is optional. If `distribution == :batch`, the ranges are consecutive (default behavior). If `distribution == :scatter`, the range is scattered over the array.

Expand Down
4 changes: 2 additions & 2 deletions src/ChunkSplitters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using TestItems
export chunks, getchunk

"""
chunks(array::AbstractArray; n::Int=Threads.nthreads(), distribution::Symbol=:batch)
chunks(array::AbstractArray; n::Int, distribution::Symbol=:batch)
Returns an iterator that splits the *indices* of `array` into `n`-many chunks.
The iterator can be used to process chunks of `array` one after another or in parallel (e.g. with `@threads`).
Expand Down Expand Up @@ -63,7 +63,7 @@ struct Chunk{T<:AbstractArray}
end

# Constructor for the chunks
function chunks(x::AbstractArray; n::Int=Threads.nthreads(), distribution::Symbol=:batch)
function chunks(x::AbstractArray; n::Int, distribution::Symbol=:batch)
n >= 1 || throw(ArgumentError("n must be >= 1"))
(distribution in distribution_types) || throw(ArgumentError("distribution must be one of $distribution"))
Chunk{typeof(x)}(x, min(length(x), n), distribution)
Expand Down

0 comments on commit 83cca18

Please sign in to comment.