Skip to content

Commit 71fb6af

Browse files
committed
Fix warnings
1 parent eaaaa1c commit 71fb6af

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

ext/VortexStepMethodControlPlotsExt.jl

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ function VortexStepMethod.save_plot(fig, save_path, title; data_type=".pdf")
6262
@debug "Current working directory: $(pwd())"
6363

6464
try
65-
fig.savefig(full_path)
65+
hasproperty(fig, :savefig) || throw(ArgumentError(
66+
"Figure object of type $(typeof(fig)) does not support savefig()."
67+
))
68+
getproperty(fig, :savefig)(full_path)
6669
@debug "Figure saved as $data_type"
6770

6871
if isfile(full_path)
@@ -658,20 +661,29 @@ function VortexStepMethod.plot_polars(
658661
# Load literature data if provided
659662
if !isempty(literature_path_list)
660663
for path in literature_path_list
661-
data = readdlm(path, ',')
662-
header = lowercase.(string.(data[1, :]))
664+
raw_data = readdlm(path, ',')
665+
table, header = if raw_data isa Tuple
666+
# readdlm(...; header=true) returns (data, header)
667+
raw_table, raw_header = raw_data
668+
raw_table, lowercase.(string.(vec(raw_header)))
669+
else
670+
# Header is in first row when a single matrix is returned
671+
raw_data[2:end, :], lowercase.(string.(raw_data[1, :]))
672+
end
663673
# Find column indices for alpha, CL, CD, CS (case-insensitive, allow common variants)
664674
alpha_idx = findfirst(x -> occursin("alpha", x) || x == "aoa", header)
665675
cl_idx = findfirst(x -> occursin("cl", x), header)
666676
cd_idx = findfirst(x -> occursin("cd", x), header)
667677
cs_idx = findfirst(x -> occursin("cs", x), header)
678+
(isnothing(alpha_idx) || isnothing(cl_idx) || isnothing(cd_idx)) &&
679+
throw(ArgumentError("Literature CSV must contain alpha/aoa, cl and cd columns: $path"))
668680
# Fallback: if CS not found, fill with zeros
669-
cs_col = cs_idx === nothing ? zeros(size(data, 1)-1) : data[2:end, cs_idx]
681+
cs_col = cs_idx === nothing ? zeros(size(table, 1)) : table[:, cs_idx]
670682
# Push as [alpha, CL, CD, CS]
671683
push!(polar_data_list, [
672-
data[2:end, alpha_idx],
673-
data[2:end, cl_idx],
674-
data[2:end, cd_idx],
684+
table[:, alpha_idx],
685+
table[:, cl_idx],
686+
table[:, cd_idx],
675687
cs_col
676688
])
677689
end

ext/VortexStepMethodMakieExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ Save a Makie figure to a file.
249249
# Keyword arguments
250250
- `data_type`: File extension (default: ".png", also supports ".jpeg")
251251
"""
252-
function VortexStepMethod.save_plot(fig, save_path, title; data_type=".png")
252+
function VortexStepMethod.save_plot(fig::Makie.Figure, save_path, title; data_type=".png")
253253
isnothing(save_path) && throw(ArgumentError("save_path should be provided"))
254254

255255
!isdir(save_path) && mkpath(save_path)
@@ -286,7 +286,7 @@ Display a Makie figure.
286286
# Keyword arguments
287287
- `dpi`: Dots per inch for the figure (default: 130) - currently unused in Makie
288288
"""
289-
function VortexStepMethod.show_plot(fig; dpi=130)
289+
function VortexStepMethod.show_plot(fig::Makie.Figure; dpi=130)
290290
display(fig)
291291
end
292292

0 commit comments

Comments
 (0)