ISISNeutronMuon / ISISNeutronMuon/MDMC

n_steps argument for control object

Open
#1,499 0 comments 0 reactions 0 assignees View on GitHub
bug P3
Dominant language
Python
Stars
4
Forks
0
Avg merge
2d 4h
Merged PRs (30d)
5

Description

**Description of the error**
Arguments for the control object are inconsistent for different minimizers

**Describe the expected result**
When creating a control object, only `minimizer_type` should need to be changed when switching between minimizers

**Describe the actual result**
GPR requires `n_steps` to be set in the control object, whereas GPO and MMC do not. Trying to create a control object with GPR and no `n_steps` argument gives the error:

```
Traceback (most recent call last):
File "/home/MDMCv0.2_pilot/examples/argon.py", line 62, in
control = Control(simulation=simulation,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/MDMC/control/control.py", line 228, in __init__
self.minimizer = MinimizerFactory.create_minimizer(minimizer_type, self,self.fit_parameters,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/MDMC/refinement/minimizers/minimizer_factory.py", line 57, in create_minimizer
return classes[0][1](control, parameter,**settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/MDMC/refinement/minimizers/GPR.py", line 52, in __init__
self.create_parameter_point_array(parameters)
File "/usr/local/lib/python3.12/site-packages/MDMC/refinement/minimizers/GPR.py", line 81, in create_parameter_point_array
latin_points = samples.random(n=self.control.n_steps)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/scipy/stats/_qmc.py", line 958, in random
sample = self._random(n, workers=workers)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/scipy/stats/_qmc.py", line 1448, in _random
lhs = self.lhs_method(n)
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/scipy/stats/_qmc.py", line 1458, in _random_lhs
perms = np.tile(np.arange(1, n + 1),
~~^~~
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
```

**Suggested fix**
When using GPR, a clearer error should be displayed to the user stating that they need to set `n_steps` in the control object

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.