Contour.jl icon indicating copy to clipboard operation
Contour.jl copied to clipboard

Require z to be a matrix

Open aabacchus opened this issue 4 months ago • 0 comments

interpolate requires that z is an AbstractMatrix, ie rank 2, but contours and contour etc are happy to take any kind of data, as long as the first two dimensions match x and y. I passed a rank 3 array (of eigenenergies over 2d momentum space), hoping to get contours over all the energies, but the error only appears in the interpolate function. Since z should be a matrix there, the higher-level functions should also only accept a matrix.

Weirdly, the MethodError isn't thrown if I pass a list of levels directly, or if those levels don't intersect with the data, because get_levels_cells returns an empty Dict, so the iteration in trace_contour doesn't happen and so the preallocated ContourLevel is returned without anything actually put in it: https://github.com/JuliaGeometry/Contour.jl/blob/26994c47dcb9af88f2dc1961fb5291c8969afd1a/src/Contour.jl#L291 which relates to #80

aabacchus avatar Aug 31 '25 18:08 aabacchus