gandalfcode / gandalf

GANDALF (Graphical Astrophysics code for N-body Dynamics And Lagrangian Fluids)
GNU General Public License v2.0
44 stars 12 forks source link

Multiple types in python #47

Open giovanni-rosotti opened 8 years ago

giovanni-rosotti commented 8 years ago

It could be useful to have (some of) the python functions to support multiple types. It could be done either by passing lists of types (e.g. ['dust','sph']) or making the code understand fictitious type (e.g. 'total'). I'd prefer the first one but would like to know what you think. Once we have decided the interface, I need to decide the implementation (i.e. either aggregate the arrays in python or modifying the c++ snapshot class. Or modifying only the render class if we think it's useful only for renders)

rbooth200 commented 8 years ago

I prefer the list solution, it is more flexible. Although we need to be careful since both strings and lists are iterable.

giovanni-rosotti commented 8 years ago

Damn it, yes! But we can check if the type is a string, there's a robust way of doing it (although, it's different in python 2/3) which I'm already using somewhere else

rbooth200 commented 8 years ago

The answer is here [1], and requires using the six package:

[1] http://stackoverflow.com/questions/1303243/how-to-find-out-if-a-python-object-is-a-string