Skip to content

Commit

Permalink
get rid of the negative dimension count error check
Browse files Browse the repository at this point in the history
  • Loading branch information
nsajko authored Jan 9, 2025
1 parent 7a7793a commit 4eed3e7
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,7 @@ Base.IteratorSize(::Type{T}) where {T<:Broadcasted} = Base.HasShape{ndims(T)}()
Base.ndims(BC::Type{<:Broadcasted{<:Any,Nothing}}) = _maxndims_broadcasted(BC)
# the `AbstractArrayStyle` type parameter is required to be either equal to `Any` or be an `Int` value
Base.ndims(BC::Type{<:Broadcasted{<:AbstractArrayStyle{Any},Nothing}}) = _maxndims_broadcasted(BC)
function Base.ndims(::Type{<:Broadcasted{<:AbstractArrayStyle{N},Nothing}}) where {N}
n = N::Int
if n < 0
throw(ArgumentError("dimension count must not be negative"))
end
n
end
Base.ndims(::Type{<:Broadcasted{<:AbstractArrayStyle{N},Nothing}}) where {N} = N::Int

function _maxndims_broadcasted(BC::Type{<:Broadcasted})
_maxndims(fieldtype(BC, :args))
Expand Down

0 comments on commit 4eed3e7

Please sign in to comment.