-
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
Changes in users initialization #102
Conversation
Change to allow setting users parameters by either config file or geouned set method
GEO.set('stepFile', stepFileName) | ||
GEO.set('geometryName','Placa') | ||
GEO.set('outFormat', ('mcnp', 'openMC_XML')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be the normal way to set class attributes that python users would be familiar with
GEO.set('stepFile', stepFileName) | |
GEO.set('geometryName','Placa') | |
GEO.set('outFormat', ('mcnp', 'openMC_XML')) | |
GEO.stepFile = stepFileName | |
GEO.geometryName = Placa | |
GEO.outFormat = ('mcnp', 'openMC_XML') |
Ideally this would work for options and tolerances as well
class Tolerances: | ||
from .tolerancesDefault import defaultValues, typeDict, KwrdEquiv | ||
|
||
@classmethod | ||
def setDefaultAttribute(cls): | ||
for key,value in cls.defaultValues.items(): | ||
setattr(cls, key, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can set all the defaults in the Class init with default args
let me make a PR into this PR to show what I mean
@classmethod | ||
def setAttribute(cls,key,value): | ||
if key in cls.defaultValues.keys(): | ||
setattr(cls, key, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
classes allow attributes to be set if we set them in the regular python manner without the need for a custom Attribute setter, so I don't think we need this
from .mcnpNumericDefault import defaultValues | ||
|
||
@classmethod | ||
def setDefaultAttribute(cls): | ||
for key,value in cls.defaultValues.items(): | ||
setattr(cls, key, value) | ||
|
||
@classmethod | ||
def setAttribute(cls,key,value): | ||
if key in cls.defaultValues.keys(): | ||
setattr(cls, key, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments as above for the class Options
@@ -0,0 +1,16 @@ | |||
defaultValues = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be done in the class on creation
@@ -0,0 +1,30 @@ | |||
# default options values | |||
defaultValues = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above, can be moved into the class. Then users know the default values that are being used as the class tells them in the doc strings and with hover text in IDEs
@@ -0,0 +1,53 @@ | |||
defaultValues = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above, we can move this to the class
"min_area": float, # minimun face area to consider in cell definition | ||
} | ||
|
||
KwrdEquiv = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw this in the original init file and it would be really great if we just have one set of names and don't need an equivalence dictionary
Options.setDefaultAttribute() | ||
McnpNumericFormat.setDefaultAttribute() | ||
Tolerances.setDefaultAttribute() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these three lines won't be needed if we declare the defaults in the class args
|
||
with open(output_dir / "config.ini", mode="w") as file: | ||
file.write(template) | ||
template = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice [Parameters]
and [Options]
have been removed from the config file, but I don't see this change in the other config files for example those config files in scripts. Perhaps we still need [Parameters]
and [Options]
in here?
There are parts of the GEOUNED.init.py file that check for Parameters and Options so I guess the options parameters like forceCylinder are not getting set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Parameters]
, [Options]
and the other sections identifiers are still required in the external config file when the method SetConfiguration
(renamed from SetOptions
) is used to pass the parameters values.
In the tests/test_convert.py I changed the mode to pass the parameters, instead of writing a file and use the SetConfiguration
method, all parameters are stored in a dictionnary and passed with the method set
. This method is able to identify any valid parameter name (of any section) and assign its value to the corresponding variable/attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like we now have arguments for parameters and options being added to the CadToCsg class in the same manner as CadToCsg arguments.
@psauvan I think this PR is a great step in a nice direction. Congrats. I have a few suggestions if you are interested. I think we can ignore all the code comments I've made above if you want I can follow up this PR with another PR that shows more clearly what I'm trying to express |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is in general a good step in the right direction, let us merge this in to dev and we can build on it.
Perhaps just one answer on this comment would be good before merging |
* Add a github workflow that prevents PRs to main that is not comming from dev (#92) * Fix to position of additional cylindrical surface used to limit torus extent (#96) * camel case for all classes (#95) * camel case for all classes * corrected file imports for georeverse * Apply suggestions from code review variable back to snake case * variable back to snake case * back to snake case * back to previous var name * Snake case variables (PR 1 of several) (#98) * snake case for CellDefinitions file, tests pass * vars in snake_case 2 more files * working still * using is to compare with bool (#99) * Add comments to Geometry.py and booleanFunction.py files (#101) * Add comments to Geometry_GU.py * Add comments to booleanFunction.py * Add comments to Geometry_GU.py * Specific imports instead of wild card (#100) * improved import statements flake8 hints * removed extra line * solve issue #75 in getTransMatrix function (#103) * Changes in users initialization (#102) * Add a github workflow that prevents PRs to main that is not comming from dev (#92) (#93) * Add scripting interface Change to allow setting users parameters by either config file or geouned set method * minor fix * Changes in geounedClassCall.py --------- Co-authored-by: AlvaroCubi <[email protected]> * Adding formatter to CI to keep code in PEP8 (#104) * added format checker * run black . locally * f strings instead of .format (#106) * replaced all .format with f strings * corrected f string conversion * Snake case variables (PR 2 of several) (#105) * snake case im more varibles * formatting --------- Co-authored-by: Patrick Sauvan <[email protected]> * Quicker tests for ci (#109) * removing slowest two geometries * removing slow files from CI * format * added draft template (#97) * Removing unused code (#107) @psauvan comment has been taken into account. Unreachable code that was there for future consideration has been changed to comments. * if statement includes False so never runs code * if statement includes True so always run and never reaches else * line after return never reached * unused arg * unused arg * unused arg calling function * commented unused code as requested * formatting * format * Testing writing inputs for more MC codes (#108) * also writting openmc python, phits and serpent files * formatting * decreased lcoal run time and added all outFormats * black using same version as in pyproject * py3.11 in formatting ci * matched exactly black versions * simpler black pinning * format * Snake case functions (#115) * converted more functions * more snake case functions * more snake case function names * more snake case functions * more snake case functions * more snake case functions * formatting * formatting * formatting * formatting * converting function names to snake class * duplicate import openmc (#116) * Sphinx based docs with CI action to build and hosted on gh-pages (#119) * started rtd * testing docs action * update pip * corrected python version * added s to docs * publish every time * added static folder * skipping ci for non code files * changed to rerad the docs theme * started install section * added more sections * added api class * docs ci using conda * added -y for freecad * trying py 3.12 * mimic working conda ci * using rst so no markdown convertion needed * added github edit link * removed path prints * added readme link, badge * format * Add issue templates (#112) * Add a github workflow that prevents PRs to main that is not comming from dev (#92) (#93) * Create feature request template * improve documentation template * update feature request template --------- Co-authored-by: AlvaroCubi <[email protected]> * Trigger docs build on push only (#126) * pushing triggers doics build * added if push * added missing = sign (#130) * added missing package (#135) * replaced print statements with log (#133) * replaced print statements with log * added logger * formatting * removed encoding arg * removed verbose as all gets logged * removed unused logger * removed , from logging cmd * sorted imports * added another tqdm loop * isort * format * Fixing logger commands (#137) * fixed multi comma log statements * capital letters for progress bar sections * formatted * removal of Options as global variable (#138) * instances of Options class passed by arg * updated usage to show how to use Options * format pep8 * added missing options arg * added missing args options * passing in options as arg * bug fix for compsolid * format * removal of Tolerances as global variable (#139) * passing tolerance as arg not global var * added tolerance example to usage section * one set of argument names * moved atr and types getting out of loop * format * passing missing options and tolerances * format * found bug hidden in try: except statement * using tolerance for more local varibles * formatting * Numerical format to normal class (#141) * replaced global with class passed by arg * format * Improving docs install section (#145) * added dev install instructions * added method section * testing the setting of all class arguments (#147) * Adding getters setters type checking to Options, Tolerances, NumericFormat class (#148) * added type ching setters * added low limit checking for reals * format * added type checkers for Tolerances * format * Add settings class (#149) * settings being passed through the code * all the attributes show in usage example * Adding export csg method (#150) * added export csg method * format * leaving comments in tests * Adding support for json config file (#152) * testing from json * returned file to pre PR status * returned file to init * returned file to init * temp fixing for serpent universe, issue raised * making use of stp file already on repo * Adding command line tool including documentation and testing (#155) * split usage into two sections * added minimal config from cli example to ci * improved cli docs * format * removed duplication between readme and docs (#156) * Moving code from __init__ file to core.py (#157) * moved core logic from init * format * Fixing issue 154 (#158) * added test that currently fails * fixed bug with freecad attribute usage * added missing arg * format * added missing args bug (#159) * added missing args * format * added description of solid being decomposed (#161) * Context managers for writing try 2 (#160) * Add a github workflow that prevents PRs to main that is not comming from dev (#92) (#93) * using context managers to write files * review comments 4/5 --------- Co-authored-by: AlvaroCubi <[email protected]> * Creating folder if needed (#162) * added tests to check writing to folder * back to org * back to org * back to org * creating output folder prior to writing * isort on the imports * format * setting line length to 128 (#163) * Lower case folder names and files (#165) * renamed subfolders to lowercase * renamed files to lower case * openmc_py and openmc_xml lower case (#166) * openmc_py and openmc_xml lower case * removed outdated code comment * Added type checking on export csg (#167) * added input checking on export_csg * compacted same types * Update src/geouned/GEOUNED/core.py --------- Co-authored-by: Patrick Sauvan <[email protected]> * Adding windows install instructions (#169) * added windows install instructions * improved install instructions --------- Co-authored-by: teade <[email protected]> Co-authored-by: Jonathan Shimwell <[email protected]> Co-authored-by: Jonathan Shimwell <[email protected]> Co-authored-by: Patrick Sauvan <[email protected]> Co-authored-by: alberto743 <[email protected]> Co-authored-by: Alex Valentine <[email protected]>
Changes allow to set user parameters by either using the configuration file (the original one)
or setting parameters directly to the GEOUNED instance.
The modifications implemented should resolve the issue #88