From fd02e6adb2b166fa7bc88b286e0df6c95af8f196 Mon Sep 17 00:00:00 2001 From: Alexander Plavin Date: Wed, 18 Dec 2024 00:00:00 +0000 Subject: [PATCH] Revert "literal_pow: use it, add inverse" This reverts commit b1e2a9d7dd1a9ae98a261865d9b9c9542660e03c. --- src/fixargs.jl | 4 ---- src/overrides.jl | 5 ----- test/runtests.jl | 16 ---------------- 3 files changed, 25 deletions(-) diff --git a/src/fixargs.jl b/src/fixargs.jl index d5d5120c..9492d285 100644 --- a/src/fixargs.jl +++ b/src/fixargs.jl @@ -56,7 +56,3 @@ for kws in [(:rev,), (:by,), (:rev, :by), (:by, :rev)] @eval set(obj, o::FixArgsT(sort, (Placeholder,), NamedTuple{$kws}), val) = @set obj[sortperm(obj; o.kwargs...)] = val @eval modify(f, obj, o::FixArgsT(sort, (Placeholder,), NamedTuple{$kws})) = @modify(f, obj[sortperm(obj; o.kwargs...)]) end - -InverseFunctions.inverse(f::FixArgsT(Base.literal_pow, (typeof(^), Placeholder, Val))) = - fixargs(Base.literal_pow, ^, Placeholder(), Val(inv(_extract_val(f.args[3])))) -_extract_val(::Val{P}) where {P} = P diff --git a/src/overrides.jl b/src/overrides.jl index 822b6e88..ad3bbc68 100644 --- a/src/overrides.jl +++ b/src/overrides.jl @@ -121,11 +121,6 @@ function _parse_obj_optics(ex::Expr) is_bcast = @capture(ex, tmpf_.(tmpargs__)) @debug "Captured f_(args__)" f args is_bcast - if f === (:^) && length(args) == 2 && args[2] isa Int - args = [f, args[1], Val(args[2])] - f = Base.literal_pow - end - args_contain_under = map(arg -> tree_contains(arg, :_), args) f_contains_under = tree_contains(f, :_) f_contains_under && any(args_contain_under) && error("Either the function or the arguments can contain an underscore, not both") diff --git a/test/runtests.jl b/test/runtests.jl index 61d75b54..959bc122 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -402,22 +402,6 @@ end @test (aa=4, bb=5, cc=6) === modify(x -> Symbol(x, x), (a=4, b=5, c=6), @o keys(_)[∗]) end -@testitem "literal pow" begin - using Unitful - using AccessorsExtra: inverse - - f1(x) = x^2 - f2(x) = sqrt(x) - f3(x) = (@o _^2)(x) - f4(x) = inverse(@o _^2)(x) - f5(x, y) = @set $x^2 = y - @test (@inferred f1(2u"m")) == 4u"m"^2 - @test (@inferred f2(4u"m")) == 2u"m"^(1//2) - @test (@inferred f3(2u"m")) == 4u"m"^2 - @test (@inferred f4(4u"m")) == 2u"m"^(1//2) - @test (@inferred f5(2u"m", 4u"m")) == 2u"m"^(1//2) -end - @testitem "_" begin import CompatHelperLocal as CHL CHL.@check()