Skip to content

Commit 22be8b8

Browse files
committed
refactor: code reduction
1 parent e2d7287 commit 22be8b8

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/ComposableExpression.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ function (ex::AbstractComposableExpression)(
216216
else
217217
# Convert Number to ValidVector with repeated values
218218
filled_array = similar(sample_vector.x)
219-
fill!(filled_array, float(arg))
220-
ValidVector(filled_array, _is_valid(arg))
219+
fill!(filled_array, arg)
220+
ValidVector(filled_array, true)
221221
end
222222
end
223223

@@ -367,13 +367,11 @@ for op in (
367367
end
368368
#! format: on
369369

370-
# Array interface error methods for ValidVector
371-
Base.getindex(::ValidVector, ::Any...) = throw(ValidVectorAccessError())
372370
Base.length(::ValidVector) = throw(ValidVectorAccessError())
373-
Base.size(::ValidVector, ::Any...) = throw(ValidVectorAccessError())
374371
Base.push!(::ValidVector, ::Any) = throw(ValidVectorAccessError())
375-
Base.append!(::ValidVector, ::Any) = throw(ValidVectorAccessError())
376-
Base.setindex!(::ValidVector, ::Any...) = throw(ValidVectorAccessError())
372+
for op in (:getindex, :size, :append!, :setindex!)
373+
@eval Base.$(op)(::ValidVector, ::Any...) = throw(ValidVectorAccessError())
374+
end
377375

378376
# TODO: Support for 3-ary operators
379377

0 commit comments

Comments
 (0)