pele-python / mcpele

Monte Carlo and parallel tempering routines built on the pele foundation
Other
20 stars 5 forks source link

prefer kwargs to args in python and cython #49

Open js850 opened 10 years ago

js850 commented 10 years ago

On the python and cython level we should use keyword arguments rather than required arguments wherever possible. As an example look at https://github.com/pele-python/mcpele/blob/master/mcpele/monte_carlo/_action_cpp.pyx#L18

most of the arguments could have reasonable default values. Besides making things easier to call, it makes it much clearer also:

RecordEnergyHistogram(0, 10, bins=100, eqsteps=1e4)

is much clearer than

RecordEnergyHistogram(0, 10, 100, 1e4)

Where you have to look at the function definition to know what 100 and 1e4 are referring to. Also, we can change the order of the kwargs without worrying about messing anything up.