Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Lilith Orion Hafner <[email protected]>
  • Loading branch information
MilesCranmer and LilithHafner authored Jul 4, 2024
1 parent 54150eb commit 6028074
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ end

function (f::Fix{N})(args::Vararg{Any,M}; kws...) where {N,M}
if N isa Symbol
N in keys(kws) && throw(ArgumentError("found duplicate keyword argument passed to `Fix{N}`"))
N in keys(kws) && throw(ArgumentError("found duplicate keyword argument passed to `Fix`"))
f_kws = NamedTuple{(N,)}((f.x,))
return f.f(args...; f_kws..., kws...)
else # Int
Expand Down
9 changes: 3 additions & 6 deletions test/functional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -353,20 +353,17 @@ end
sum1(x) == [3.0 3.0]
end
@testset "Dummy-proofing" begin
@test_throws ArgumentError Fix{0}(>, 1)
@test_throws "expected `N` in `Fix{N}` to be integer greater than 0" Fix{0}(>, 1)
@test_throws ArgumentError("expected `N` in `Fix{N}` to be integer greater than 0") Fix{0}(>, 1)

@test_throws ArgumentError Fix{0.5}(>, 1)
@test_throws "expected type parameter in `Fix` to be `Int` or `Symbol`, but got type=Float64" Fix{0.5}(>, 1)
@test_throws ArgumentError("expected type parameter in `Fix` to be `Int` or `Symbol`, but got type=Float64") Fix{0.5}(>, 1)

@test_throws ArgumentError Fix{UInt64(1)}(>, 1)

# duplicate keywords
sum1 = Fix(sum; dims=1)
x = ones(3, 2)
@test sum1(x) == [3.0 3.0]
@test_throws ArgumentError sum1(x; dims=2)
@test_throws "found duplicate keyword argument passed to `Fix{N}`" sum1(x; dims=2)
@test_throws ArgumentError("found duplicate keyword argument passed to `Fix`") sum1(x; dims=2)
end
end
end

0 comments on commit 6028074

Please sign in to comment.