You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hei,
I just started working with oasis and i am struggeling to see where functions and variables come from.
For me (and maybe other new users?), the code would be easier to read and to work with, if some things would be more explicit.
Here is why i think i struggle:
I don't know where variables come from and I cant use automated tools, because of import all statements (from xyz import *) and because of hidden imports (importlib.import_module(xyz) or exec("xyz"))
It is impossible to keep track of which variables change (and which do not) and where variables change. This is because the global namespace (a dictionary) holds a dictionary NS_parameters as well as all variables in there. This means the problem specific variables exist twice and they are not always the same. E.g. tstep is changes in the global namespace (passed via **vars() to other functions and methods) but does not change in NS_parameters. Sometimes NS_parameters is passed to functions and methods, sometimes the whole global namespace. Some functions change NS_parameters, some functions change the global namespace and some change both.
I think it is somehwat dangerous to work with vars(). In my fork, i would like to work with a dictionary like NS_parameters only, without having these variables in the global namespace. Also I think NS_parameters should not be passed as a whole to functions that might change it without the users knowledge.
I hope it would be easier to work with the code if I change the following in my fork:
use explicit imports, e.g.
import oasis.common.utilities as ut
import dolfin as df
...
instead of any from xyz import *
replace hidden imports, e.g.
if problemname == "Channel":
import oasis.problems.NSfracStep.Channel as problemmod
elif problemname == "Cylinder":
import oasis.problems.NSfracStep.Cylinder as problemmod
...
remove problem specific variables from the global namespace and work with 'NS_parameters' only. All lines that quietly change variables in the global namespace, e.g. vars().update(xyz) in the main executable or globals().update(xyz) in a function or method would need to be changed.
Would oasis still work if i change it like that? Or is there a reason why all the namespaces need to be available in the main executable.
Do you think that would make sense, or do you have a different suggestion?
I am happy to change my fork that way and do a PR if you think this could be usefull in this repository.
The text was updated successfully, but these errors were encountered:
Hei,
I just started working with oasis and i am struggeling to see where functions and variables come from.
For me (and maybe other new users?), the code would be easier to read and to work with, if some things would be more explicit.
Here is why i think i struggle:
from xyz import *
) and because of hidden imports (importlib.import_module(xyz)
orexec("xyz")
)NS_parameters
as well as all variables in there. This means the problem specific variables exist twice and they are not always the same. E.g.tstep
is changes in the global namespace (passed via**vars()
to other functions and methods) but does not change inNS_parameters
. SometimesNS_parameters
is passed to functions and methods, sometimes the whole global namespace. Some functions changeNS_parameters
, some functions change the global namespace and some change both.I think it is somehwat dangerous to work with
vars()
. In my fork, i would like to work with a dictionary likeNS_parameters
only, without having these variables in the global namespace. Also I thinkNS_parameters
should not be passed as a whole to functions that might change it without the users knowledge.I hope it would be easier to work with the code if I change the following in my fork:
instead of any
from xyz import *
instead of
vars().update(xyz)
in the main executable orglobals().update(xyz)
in a function or method would need to be changed.Would oasis still work if i change it like that? Or is there a reason why all the namespaces need to be available in the main executable.
Do you think that would make sense, or do you have a different suggestion?
I am happy to change my fork that way and do a PR if you think this could be usefull in this repository.
The text was updated successfully, but these errors were encountered: