Skip to content

Commit 22b07c0

Browse files
committed
fix tests and processing of supertypes
1 parent 06e8331 commit 22b07c0

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/utils_GUI/GUI_utils.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,7 @@ function update_descriptive_names!(gui::GUI)
633633
# apply inheritances for fetching descriptive names
634634
# create a dictionary were the keys are all the types defined in emx_packages and the values are the types they inherit from
635635
emx_supertypes_dict = get_supertypes(emx_packages)
636-
637636
inherit_descriptive_names_from_supertypes!(descriptive_names, emx_supertypes_dict)
638-
639637
for package emx_packages
640638
package_path::Union{String,Nothing} = dirname(dirname(Base.find_package(package)))
641639
if !isnothing(package_path)

src/utils_gen/utils.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,14 @@ function inherit_descriptive_names_from_supertypes!(descriptive_names, emx_super
515515
for fname emx_type_fieldnames
516516
for emx_supertype emx_supertypes[2:end] # skip first element as it is the type itself
517517
#check if the supertype has an entry in descriptive names for fname
518-
if haskey(descriptive_names[:structures], Symbol(emx_supertype)) &&
518+
# Extract only what is after the dot in emx_supertype, if any
519+
supertype_str = string(emx_supertype)
520+
supertype_key =
521+
occursin(r"\.", supertype_str) ?
522+
match(r"\.([^.]+)$", supertype_str).captures[1] : supertype_str
523+
if haskey(descriptive_names[:structures], Symbol(supertype_key)) &&
519524
haskey(
520-
descriptive_names[:structures][Symbol(emx_supertype)],
525+
descriptive_names[:structures][Symbol(supertype_key)],
521526
Symbol(fname),
522527
)
523528
# if so, and if the emx_type does not have an entry for fname, copy it
@@ -531,7 +536,7 @@ function inherit_descriptive_names_from_supertypes!(descriptive_names, emx_super
531536
Dict{Symbol,Any}()
532537
end
533538
descriptive_names[:structures][Symbol(emx_type)][Symbol(fname)] =
534-
descriptive_names[:structures][Symbol(emx_supertype)][Symbol(
539+
descriptive_names[:structures][Symbol(supertype_key)][Symbol(
535540
fname,
536541
)]
537542
end

test/test_interactivity.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ pin_plot_button = get_button(gui, :pin_plot)
101101
@test :RefNetworkNode keys(descriptive_names_raw[:structures])
102102

103103
descriptive_names = EMGUI.get_var(gui2, :descriptive_names)
104-
@test :Node keys(descriptive_names[:structures])
105104
@test descriptive_names[:structures][:StorCapOpexFixed][:opex_fixed] == str1
106105
@test descriptive_names[:structures][:RefNetworkNode][:opex_fixed] == str1
107106
EMGUI.close(gui2)

0 commit comments

Comments
 (0)