Does anyone as experience getting fish structures into python?
What I mean is that you can access fish variables in python using itasca.fish.get() function.
This does not work for fish structures as you get an unknown type conversion: this is not too surprising.
I am aware of workaround, for example by converting the fish structure to a map that is a known conversion type for itasca.fish.get(). But, that is a bit of a dirty workaround when you only want to access a member of a fish structure.
Are their known ways to directly access fish structure members without a workaround?
Thanks for the suggestion. Starting with version 9.8.55, FISH structures can be converted into Python dictionaries, making it easier to access their members from Python. Below is a small test:
> import itasca as it
>
> it.command("model new")
>
> # FISH structures are returned to Python as a dict of member name -> value
> it.command("""
> fish define make_structs
> struct inner(a,b)
> struct pt(x,y,name,flag,items,child)
> global s = struct pt(1.5,2,'A',true,list.range(1,3),struct inner(false,'z'))
> global e = struct inner
> end
> [make_structs]
> """)
>
> s = it.fish.get("s")
> assert(isinstance(s, dict))
> assert(sorted(s.keys()) == sorted(['x','y','name','flag','items','child']))
> assert(s['x'] == 1.5)
> assert(s['y'] == 2)
> assert(isinstance(s['y'], int))
> assert(s['name'] == 'A')
> assert(s['flag'] is True)
> assert(s['items'] == (1,2,3))
> assert(s['child'] == {'a': False, 'b': 'z'})