Skip to content

Commit 4731c8b

Browse files
Merge pull request #85 from ProjectTorreyPines/projection_bug_fix
Fixed projection function on ggd array project_prop_on_subset! function has been changed so that it does not restrict the input type anymore. The input type restriction was causing too much overhead in compilation (potentially a julia issue), but we aren't winning anything right now by fixing the type. The overhead comes when, during compile time, the script does not know the type of the input. This was happening in the second method, which takes a string path from the ggd array to the property. Since this string path can be anything, the compiler goes into endless computation inthe pre-compile step and gets stuck without giving any warning or errors. I suspect another overflow issue similar to JuliaLang/julia#58129 fixed in JuliaLang/julia#58159 .
2 parents 6de3c81 + 12f65fd commit 4731c8b

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "IMASggd"
22
uuid = "b7b5e640-9b39-4803-84eb-376048795def"
33
authors = ["Anchal Gupta <[email protected]>"]
4-
version = "3.2.2"
4+
version = "3.3.0"
55

66
[deps]
77
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"

src/subset_tools.jl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ end
271271

272272
"""
273273
project_prop_on_subset!(
274-
prop_arr::IMASdd.IDSvector{<:all__grid_subset_prop},
274+
prop_arr, # ::IMASdd.IDSvector{<:all__grid_subset_prop}
275275
from_subset::all__grid_subset,
276276
to_subset::all__grid_subset;
277277
space::all__space=get_space(from_subset),
@@ -316,7 +316,7 @@ the additional utility, this function also returns a tuple
316316
new instance
317317
"""
318318
function project_prop_on_subset!(
319-
prop_arr::IMASdd.IDSvector{<:all__grid_subset_prop},
319+
prop_arr, # ::IMASdd.IDSvector{<:all__grid_subset_prop}
320320
from_subset::all__grid_subset,
321321
to_subset::all__grid_subset;
322322
space::all__space=get_space(from_subset),
@@ -392,7 +392,7 @@ end
392392

393393
"""
394394
project_prop_on_subset!(
395-
ggds::IMASdd.IDSvector{<:all__ggd},
395+
ggds::Union{Vector{<:all__ggd}, IMASdd.IDSvector{<:all__ggd}},
396396
prop_path::String,
397397
from_subset::all__grid_subset,
398398
to_subset::all__grid_subset;
@@ -415,7 +415,7 @@ do the projection for all the states of the `ion`. This function call returns a
415415
list of return tuples for all projections performed.
416416
"""
417417
function project_prop_on_subset!(
418-
ggds::IMASdd.IDSvector{<:all__ggd},
418+
ggds::Union{Vector{<:all__ggd}, IMASdd.IDSvector{<:all__ggd}},
419419
prop_path::String,
420420
from_subset::all__grid_subset,
421421
to_subset::all__grid_subset;
@@ -426,13 +426,14 @@ function project_prop_on_subset!(
426426
from_subset,
427427
),
428428
) where {U <: Real}
429-
prop_arrays = Array{IMASdd.IDSvector{<:all__grid_subset_prop}}[]
429+
prop_arrays = []
430430
for ggd ggds
431-
append!(prop_arrays, _prop_arrays_from_path(prop_path::String, ggd))
431+
prop_arrays = [prop_arrays; _prop_arrays_from_path(prop_path, ggd)]
432432
end
433+
433434
to_return = []
434435
for prop_arr prop_arrays
435-
append!(
436+
push!(
436437
to_return,
437438
project_prop_on_subset!(
438439
prop_arr,
@@ -448,27 +449,29 @@ function project_prop_on_subset!(
448449
end
449450

450451
function _prop_arrays_from_path(prop_path::String, parent)
451-
prop_arrays = Array{IMASdd.IDSvector{<:all__grid_subset_prop}}[]
452452
if occursin(".", prop_path)
453453
pf = split(prop_path, ".")[1]
454454
rem_path = prop_path[(findfirst('.', prop_path)+1):end]
455455
if occursin("[", pf)
456456
new_parent = getfield(parent, Symbol(pf[1:(findfirst('[', pf)-1)]))
457457
ind_str = pf[(findfirst('[', pf)+1):(findfirst(']', pf)-1)]
458458
if ind_str == ":"
459+
prop_arrays = []
459460
for np new_parent
460-
append!(prop_arrays, _prop_arrays_from_path(rem_path, np))
461+
prop_arrays = [prop_arrays; _prop_arrays_from_path(rem_path, np)]
461462
end
463+
return prop_arrays
462464
else
463465
ind = parse(Int, ind_str)
464-
append!(prop_arrays, _prop_arrays_from_path(rem_path, new_parent[ind]))
466+
return _prop_arrays_from_path(rem_path, new_parent[ind])
465467
end
466468
else
467469
new_parent = getfield(parent, Symbol(pf))
468-
append!(prop_arrays, _prop_arrays_from_path(rem_path, new_parent))
470+
return _prop_arrays_from_path(rem_path, new_parent)
469471
end
472+
else
473+
return [getfield(parent, Symbol(prop_path))]
470474
end
471-
return prop_arrays
472475
end
473476

474477
"""

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ if args["projection"]
201201
from_subset,
202202
to_subset,
203203
)
204-
@test true
204+
@test length(projection_return) == length(idstd.edge_profiles.ggd)
205205
end
206206
end
207207

0 commit comments

Comments
 (0)