-
Notifications
You must be signed in to change notification settings - Fork 32
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
[BUG] - conversions inherit previous conversion attributes #88
Comments
This is because "Options" and "Tolerances" parameters are stored in a class as class attributes. During the initialization the set method changes the attribute value of the classes "Options" and "Tolerances" for the attribute name defined in the user template. If in the second call of the GEOUNED instance the attributes changed in the first instance call are not defined as input data in the second template, their value doesn't change from the first assignation because, the classes "Options" or "Tolerances" are the same as in the first call of the GEOUNED instance (after updating the value of their attibute). |
Thanks for the update Getting geouned to internaly make new tolerances and options instances to reset their values to defaults sounds most reasonable to me. Then the users are guaranteed to get the defaults that are mentioned in the docs. We could look into refactoring and perhaps remove the need for a global in the longer term |
I think a decompose strategy would be a natural solution here. It feels a bit excessive to expose all 63 attributes to the user in a single class interface. Users who want to specify everything could make make 3 classes and bring them together for the conversion. We currently have:
Here is how user level code could look I've used the same variable names as we currently have in the code but I am currently trying to snake_case variables and args and CamelCase classes so these may change. However here is a general layout for discussion from geouned import CadToCsG, Options, Tolerances, MCNP_numeric_format
my_options = Options(
forceCylinder=True,
forceNoOverlap=True,
)
my_tolerances = Tolerances(
relativeTolerance=1e-6,
relativePrecision=2.7e1
)
my_num_format = MCNP_numeric_format(
P_xyz="14.7e",
GQ_1to6": "18.15"
)
my_conversion = CadToCsg(
voidGen=True,
compSolids =False,
volSDEF =True,
startCell = 20,
options=my_options ,
tolerances=my_tolerances,
number_format=my_num_format
)
my_conversion.start() The arguments might want to be moved around a bit and one thing we could consider is to provide separate export methods on the CadToCsg which could remove some of the MC code specific attributes from the init. For example we could have class methods like Naturally we must also maintain compatibility with the config.ini input file method. I think we could have a keen to hear other thoughts |
If people are happy with this plan then the first course of action would be to move away from having Instead pass them from |
The proposed PR #102 is doing more or less what your are proposing. Originally I separated the input parameters in four groups (as they are now) depending on the type of parameters and their use for the translation process. Returning to your proposal, I am agree to pass the Options, Tolerances, and McnpNumericFormat as local classes to each CadToCSG instance. But formerly, when I tryied to do this, I face the problem that there were several method calls between the point where the class were defined and the methods/functions using their attributes, and passing the information through the different calls wasn't easy nor elegant. That's why I decided to use global classes. I think this work should be included as part of the refactoring work, and cannot be performed easily as isolated task. |
I didn't understand what method like |
This would export/write the input file for mcnp with a options set for the startcell. Currently the Options class has some attributes such as |
solved by #124 |
Describe the bug
When running more than one conversion in the same python script the attributes of Options, Tolerances and Numerical_format are carried between conversions.
This is difficult for the user to spot and could lead to a decent amount of confusion.
For example if the first conversion changes any of these setting in their config.ini file and does not over write them with the next config file then these new settings be carried between conversions. Impacts this settings in the config
To Reproduce
this example converts a stp file with a set relativePrecision then converts a second step file without specifying the relativePrecision and it would end up not having the default Tolerance.relativePrecision but instead it would get the relativePrecision setting from the previous conversion
Expected behavior
When the user makes a new GEOUNED instance then it should come with the defaults, not with the previous conversion values.
Error message
no error message
Please complete the following information):
The text was updated successfully, but these errors were encountered: