Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite test/unit_test_io.jl with new fuselage/wing/tail #74

Open
aditeyashukla opened this issue Aug 6, 2024 · 1 comment
Open

Rewrite test/unit_test_io.jl with new fuselage/wing/tail #74

aditeyashukla opened this issue Aug 6, 2024 · 1 comment
Assignees

Comments

@aditeyashukla
Copy link
Contributor

aditeyashukla commented Aug 6, 2024

@argonaut22 IO unit test doesn't work because of new fuselage (and soon wing/tail)
we can fix this when wing/tail is pushed as you would have to fix it then too (If you want to get a head start you can pull the branch wing_remodel on my branch)

@askprash
Copy link
Member

askprash commented Aug 6, 2024

Left some suggestions and caveats here:

acdict = struct2dict(ac)
## But this works for the output portion but need to be *very* careful in reading it.
# The dictionary stores by sorting the hash or something so the order is going to be different
# So the only way to effectively load this would be to enforce kwargs explicitly either
# by ensuring all the structs are defined with the @kwargs macro or an explicit kw constructor is provided.

and here:

function struct2dict(obj)
type = typeof(obj)
# println("T = $type")
d = Dict()
for key fieldnames(type)
# println("field = $key")
if fieldtype(type, key) <: Union{AbstractArray,Number,String}
# println("pushing...")
push!(d, key => getfield(obj, key))
else
# println("recursing...")
push!(d, key => struct2dict(getfield(obj, key)))
end
end
return d
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants