Skip to content

[Bug] Expanding VectorFold with a negative number of folds will (naturally) fail #18

Open
@jakewilliami

Description

@jakewilliami

E.g.,

julia> collect(VectorFold([1, 2], 10, -5))
ERROR: ArgumentError: invalid Array dimensions

Proposed fix: create an internal constructor method for VectorFold (and maybe check PatternFold, as well?) to catch this. Would that be reasonable? Or do we...somehow want non-positive numbers of folds? E.g.:

mutable struct VectorFold{T,V <: AbstractVector{T}, I1 <: Integer, I2 <: Integer} <: PatternFold{T,V}
    pattern::V
    gap::T
    folds::I1
    current::I2
	
    function VectorFold(p::V, g::T, f::I1, c::I2) where {T,V <: AbstractVector{T}, I1 <: Integer, I2 <: Integer}
        f < 0 &&
            throw(ArgumentError("folds cannot be negative (you cannot have a negative number of folds)."))
            new{T, V, I1, I2}(p, g, f, c)
        end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions