Skip to content

Commit 8a95fe2

Browse files
committed
fix missing quantile in src/compat/pyplot.jl
1 parent ea199a2 commit 8a95fe2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/compat/pyplot.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using .PyPlot
22
import .PyPlot: plot, plot3D, plt
33
using Meshing
4+
using Statistics: quantile
45

56
# Defaults --------------------------------------------------------------------------------
67

@@ -76,23 +77,24 @@ function plot(flat::AbstractFourierLattice, Rs::DirectBasis{D};
7677
xyz = range(-.5, .5, length=N)
7778
vals = calcfouriergridded(xyz, flat, N)
7879
if isnothing(isoval)
80+
isnothing(filling) && error(ArgumentError("`filling` and `isoval` cannot both be `nothing`"))
7981
# we don't want to "double count" the BZ edges - so to avoid that, exclude the last
80-
# index of each dimension (same approach as in `filling2isoval`)
82+
# index of each dimension (same approach as in `MPBUtils.filling2isoval`)
8183
isoidxs = OneTo(N-1)
8284
vals′ = if D == 2; (@view vals[isoidxs, isoidxs])
8385
elseif D == 3; (@view vals[isoidxs, isoidxs, isoidxs])
8486
end
85-
isoval = !isnothing(filling) ? quantile(Iterators.flatten(vals′), filling) : zero(Float64)
87+
isoval = quantile(Iterators.flatten(vals′), filling)
8688
end
87-
plotiso(xyz,vals,isoval,Rs,repeat,fig)
89+
plotiso(xyz, vals, isoval, Rs, repeat, fig)
8890

89-
return xyz,vals,isoval
91+
return xyz, vals, isoval
9092
end
9193

9294
# plot isocontour of data
9395
function plotiso(xyz, vals, isoval::Real, Rs::DirectBasis{D},
94-
repeat::Union{Integer, Nothing}=nothing,
95-
fig=nothing) where D
96+
repeat::Union{Integer, Nothing}=nothing,
97+
fig=nothing) where D
9698

9799
if isnothing(fig)
98100
fig = plt.figure()

0 commit comments

Comments
 (0)