-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove redundant _parse_symbol
methods
#4535
base: master
Are you sure you want to change the base?
Conversation
7880d0f
to
ffffd28
Compare
@@ -255,7 +249,7 @@ function blow_up_points(X::AbstractVariety, n::Int; symbol::String = "e") | |||
if n == 1 | |||
symbs = [SED] | |||
else | |||
symbs = _parse_symbol(SED, 1:n) | |||
symbs = ["$SED[$i]" for i in 1:n] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still a _parse_symbol
method for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, though it is now only is used in a single file, Main.jl
.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4535 +/- ##
=======================================
Coverage 84.42% 84.42%
=======================================
Files 672 672
Lines 89164 89158 -6
=======================================
- Hits 75273 75269 -4
+ Misses 13891 13889 -2
|
c83c0c7
to
40eb5d2
Compare
@@ -2523,7 +2520,7 @@ function abs_flag(dims::Vector{Int}; base::Ring=QQ, symbol::String="c") | |||
syms = vcat([_parse_symbol(symbol, i, 1:r) for (i,r) in enumerate(ranks)]...) | |||
# FIXME ordering | |||
# ord = prod(ordering_dp(r) for r in ranks) | |||
R = graded_polynomial_ring(base, syms, vcat([collect(1:r) for r in ranks]...))[1] | |||
R = graded_polynomial_ring(base, syms, vcat([1:r for r in ranks]...))[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R = graded_polynomial_ring(base, syms, vcat([1:r for r in ranks]...))[1] | |
R = graded_polynomial_ring(base, syms, reduce(vcat, (1:r for r in ranks)))[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me, but the pattern occurs several times in this file, so perhaps they should be changed all at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to say:
julia> ranks = [3,1,5];
julia> @b vcat([1:r for r in $ranks]...)
92.871 ns (7 allocs: 336 bytes)
julia> @b reduce(vcat, (1:r for r in $ranks))
58.886 ns (7 allocs: 320 bytes)
julia> @b reduce(vcat, [1:r for r in $ranks])
48.961 ns (6 allocs: 320 bytes)
julia> @b reduce(vcat, 1:r for r in $ranks)
60.154 ns (7 allocs: 320 bytes)
So the version which does reduce
over a vector is best here. None of these is great -- it could be done with a single allocation:
function parse_ranks(ranks)
res = Vector{Int}(undef, sum(ranks))
i = 1
for r in ranks
for j in 1:r
res[i] = j
i += 1
end
end
return res
end
function parse_ranks2(ranks)
res = sizehint!(Int[], sum(ranks))
for r in ranks
append!(res, 1:r)
end
return res
end
gives
julia> @b parse_ranks($ranks)
20.239 ns (2 allocs: 128 bytes)
julia> @b parse_ranks2($ranks)
36.541 ns (2 allocs: 128 bytes)
Of course none of this really matters, you just nerd-sniped me successfully ;-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The splatting version has the additional overhead of compiling a new method specialization every time you call it with a different number of arguments. This probably won't be caught by your chairmark
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but I am not using the splatting version, I am using reduce
with a Vector
which was best in the micro benchmarks.
Also replace some uses of `gens` by `symbols`
40eb5d2
to
e055c02
Compare
OK to merge this? Or any concerns? |
Also replace some uses of
gens
bysymbols
, and exploit thatgraded_polynomial_ring
can take multiple symbol lists to simplify some of the code.