Skip to content

Commit 72ad271

Browse files
committed
isempty-bang
1 parent 0b7259b commit 72ad271

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/basic.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ struct AddedOperator{T,
293293
ops::O
294294

295295
function AddedOperator(ops)
296+
@assert !isempty(ops)
296297
T = promote_type(eltype.(ops)...)
297298
new{T,typeof(ops)}(ops)
298299
end
@@ -414,6 +415,7 @@ struct ComposedOperator{T,O,C} <: AbstractSciMLOperator{T}
414415
isset::Bool
415416

416417
function ComposedOperator(ops, cache, isset::Bool)
418+
@assert !isempty(ops)
417419
for i in reverse(2:length(ops))
418420
opcurr = ops[i]
419421
opnext = ops[i-1]

src/scalar.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct AddedScalarOperator{T,O} <: AbstractSciMLScalarOperator{T}
115115
ops::O
116116

117117
function AddedScalarOperator(ops::NTuple{N,AbstractSciMLScalarOperator}) where{N}
118+
@assert !isempty(ops)
118119
T = promote_type(eltype.(ops)...)
119120
new{T,typeof(ops)}(ops)
120121
end
@@ -140,18 +141,18 @@ for op in (
140141
end
141142
end
142143

143-
#function Base.convert(::Type{Number}, α::AddedScalarOperator{T}) where{T}
144-
# sum(op -> convert(Number, op), α.ops; init=zero(T))
145-
#end
146-
147144
function Base.convert(::Type{Number}, α::AddedScalarOperator{T}) where{T}
148-
val = zero(T)
149-
for op in α.ops
150-
val += convert(Number, op)
151-
end
152-
val
145+
sum(op -> convert(Number, op), α.ops)
153146
end
154147

148+
#function Base.convert(::Type{Number}, α::AddedScalarOperator{T}) where{T}
149+
# val = zero(T)
150+
# for op in α.ops
151+
# val += convert(Number, op)
152+
# end
153+
# val
154+
#end
155+
155156
Base.conj(L::AddedScalarOperator) = AddedScalarOperator(conj.(L.ops))
156157

157158
getops::AddedScalarOperator) = α.ops
@@ -165,6 +166,7 @@ struct ComposedScalarOperator{T,O} <: AbstractSciMLScalarOperator{T}
165166
ops::O
166167

167168
function ComposedScalarOperator(ops::NTuple{N,AbstractSciMLScalarOperator}) where{N}
169+
@assert !isempty(ops)
168170
T = promote_type(eltype.(ops)...)
169171
new{T,typeof(ops)}(ops)
170172
end

0 commit comments

Comments
 (0)