Fail in case of name and explicit space name collisions
This commit is contained in:
parent
30e5e92968
commit
dc406fe19f
@ -244,6 +244,10 @@ class HyperStrategyMixin(object):
|
|||||||
if not attr_name.startswith('__'): # Ignore internals, not strictly necessary.
|
if not attr_name.startswith('__'): # Ignore internals, not strictly necessary.
|
||||||
attr = getattr(self, attr_name)
|
attr = getattr(self, attr_name)
|
||||||
if issubclass(attr.__class__, BaseParameter):
|
if issubclass(attr.__class__, BaseParameter):
|
||||||
|
if (category and attr_name.startswith(category + '_')
|
||||||
|
and attr.category is not None and attr.category != category):
|
||||||
|
raise OperationalException(
|
||||||
|
f'Inconclusive parameter name {attr_name}, category: {attr.category}.')
|
||||||
if (category is None or category == attr.category or
|
if (category is None or category == attr.category or
|
||||||
(attr_name.startswith(category + '_') and attr.category is None)):
|
(attr_name.startswith(category + '_') and attr.category is None)):
|
||||||
yield attr_name, attr
|
yield attr_name, attr
|
||||||
|
@ -1093,8 +1093,6 @@ def test_print_epoch_details(capsys):
|
|||||||
|
|
||||||
|
|
||||||
def test_in_strategy_auto_hyperopt(mocker, hyperopt_conf, tmpdir) -> None:
|
def test_in_strategy_auto_hyperopt(mocker, hyperopt_conf, tmpdir) -> None:
|
||||||
# mocker.patch('freqtrade.optimize.hyperopt.dump', MagicMock())
|
|
||||||
# mocker.patch('freqtrade.optimize.hyperopt.file_dump_json')
|
|
||||||
(Path(tmpdir) / 'hyperopt_results').mkdir(parents=True)
|
(Path(tmpdir) / 'hyperopt_results').mkdir(parents=True)
|
||||||
# No hyperopt needed
|
# No hyperopt needed
|
||||||
del hyperopt_conf['hyperopt']
|
del hyperopt_conf['hyperopt']
|
||||||
|
@ -617,3 +617,8 @@ def test_auto_hyperopt_interface(default_conf):
|
|||||||
|
|
||||||
# Parameter is disabled - so value from sell_param dict will NOT be used.
|
# Parameter is disabled - so value from sell_param dict will NOT be used.
|
||||||
assert strategy.sell_minusdi.value == 0.5
|
assert strategy.sell_minusdi.value == 0.5
|
||||||
|
|
||||||
|
strategy.sell_rsi = IntParameter([0, 10], default=5, space='buy')
|
||||||
|
|
||||||
|
with pytest.raises(OperationalException, match=r"Inconclusive parameter.*"):
|
||||||
|
[x for x in strategy.enumerate_parameters('sell')]
|
||||||
|
Loading…
Reference in New Issue
Block a user