ukaea / paramak

Create parametric 3D fusion reactor CAD models
https://paramak.readthedocs.io/en/main/
36 stars 12 forks source link

Consider using .format() in string compositions #711

Open GregVernon opened 3 years ago

GregVernon commented 3 years ago

I've found that Cubit commands are often a little easier to read / more maintainable using the .format() method.

For instance, turn this: https://github.com/ukaea/paramak/blob/7924ab0b20e53b0122f56789734bfb795cd73d38/paramak/parametric_neutronics/make_faceteted_neutronics_model.py#L79-L83

into:

cubit.cmd("unite vol {} with vol {}".format(new_vols, new_vols))

or a three-line statement (still fewer lines than the original):

command = "unite vol {} with vol {}"
command.format(new_vols, new_vols)
cubit.cmd(command)
shimwell commented 3 years ago

Thanks Greg this is a nice suggestion, thanks for taking the time to help out. We certainly appreciate it.

I has make a PR for this improvement, it will be a bit slower to merge than our usual PRs as to test this we need to connect to our Trelis license server and perform local tests.

I'm keen to update this script from its python 2 origins and also keen to run it using the system python instead of that os.system call that I current use which is a bit of a mess

https://github.com/ukaea/paramak/blob/8188fb5683b56ac75562f98c409d4da9696becc5/paramak/parametric_neutronics/neutronics_model.py#L366-L367