Pipeline question

Continuing the discussion from Structure and performance questions from a Fortran programmer: functions, global variables, array allocations, input files, and structs:

Is this how you move stuff from place to place in everyday scientific pipelines? Or do you tend to do something else? If you do, sometimes you need to get rid of some fields in these NamedTuples. How do you do that?

Thanks for your help!

I think it’s best to think of named tuples as anonymous structs. Convenient, but if you’re always returning the same objects, creating a proper structure is the next logical step. There’s nothing wrong with having lots of small structs.

As for deletion and general modification, Accessors.jl is the way to go

julia> using Accessors

julia> nt = (; x=4, y=10)
(x = 4, y = 10)

julia> nt2 = @delete nt.x
(y = 10,)

(beware that it creates a new named tuple)

I didn’t know how to delete an entry. Thank you, @cstjean .

To select a subset:

julia> nt = (; a = "hello", b = 3.14, c = -999, d = :somesymbol)
(a = "hello", b = 3.14, c = -999, d = :somesymbol)

julia> nt[ (:b, :c) ]
(b = 3.14, c = -999)

This also creates a new NamedTuple, I think.

Great answers! But is this how data is typically moved around?