diff --git a/mumot/exceptions.py b/mumot/exceptions.py index 6880d65..ef96c9b 100644 --- a/mumot/exceptions.py +++ b/mumot/exceptions.py @@ -1,6 +1,5 @@ """MuMoT warning, exception and error classes.""" - class MuMoTWarning(Warning): """Class to report MuMoT-specific warnings. """ diff --git a/mumot/models.py b/mumot/models.py index 0294c8b..71d4a0d 100644 --- a/mumot/models.py +++ b/mumot/models.py @@ -25,6 +25,7 @@ Function ) from sympy.parsing.latex import parse_latex +from warnings import warn from . import ( controllers, @@ -1803,8 +1804,7 @@ def _getSingleAgentRules(self): if reactant in allConstantReactants: warningMsg = 'WARNING! Constant reactants appearing on the right-handside are ignored. Every constant reactant on the left-handside (implicitly) corresponds to the same constant reactant on the right-handside.\n'\ f'E.g., in rule ' + str(rule.lhsReactants) + ' -> ' + str(rule.rhsReactants) + ' constant reactants should not appear on the right-handside.' - print(warningMsg) - #raise exceptions.MuMoTWarning(warningMsg) + warn(warningMsg, exceptions.MuMoTWarning) break # print maximum one warning # Add to the target of the first non-empty item the new born coming from empty-set or constant reactants diff --git a/mumot/utils.py b/mumot/utils.py index 5339a50..2e5f45a 100644 --- a/mumot/utils.py +++ b/mumot/utils.py @@ -4,6 +4,7 @@ import numpy as np from sympy.parsing.latex import parse_latex +from warnings import warn from . import ( consts, @@ -101,7 +102,8 @@ def _format_advanced_option(optionName: str, inputValue, initValues, extraParam= """ if optionName == 'initialState': (allReactants, _) = extraParam - fixSumTo1 = extraParam2[0] + #fixSumTo1 = extraParam2[0] # until we have better information, all views should sum to 1, then use system size to scale + fixSumTo1 = True idleReactant = extraParam2[1] initialState = {} # handle initialState dictionary (either convert or generate a default one) @@ -148,8 +150,7 @@ def _format_advanced_option(optionName: str, inputValue, initValues, extraParam= idleValue = initialState[idleReactant][0] if idleValue > 1: wrn_msg = f"WARNING! the initial value of reactant {idleReactant} has been changed to {new_val}\n" - print(wrn_msg) - #raise exceptions.MuMoTWarning(wrn_msg) + warn(wrn_msg, exceptions.MuMoTWarning) initialState[idleReactant][0] = new_val # the idleValue have range min-max reset to [0,1] initialState[idleReactant][1] = 0 @@ -171,8 +172,7 @@ def _format_advanced_option(optionName: str, inputValue, initValues, extraParam= new_val = max(0, pop[0] + (1 - sumValues)) if not _almostEqual(pop[0], new_val): wrn_msg = f"WARNING! the initial value of reactant {reactant} has been changed to {new_val}\n" - print(wrn_msg) - #raise exceptions.MuMoTWarning(wrn_msg) + warn(wrn_msg, exceptions.MuMoTWarning) sumValues -= pop[0] sumValues += new_val initialState[reactant][0] = new_val @@ -193,8 +193,7 @@ def _format_advanced_option(optionName: str, inputValue, initValues, extraParam= for reactant in allReactants if reactant != reactantToFix]) wrn_msg = f"WARNING! the initial value of reactant {reactantToFix} has been changed to {new_val}\n" - print(wrn_msg) - #raise exceptions.MuMoTWarning(wrn_msg) + warn(wrn_msg, exceptions.MuMoTWarning) initialState[reactantToFix][0] = new_val return [initialState, fixedBool] # print("Initial State is " + str(initialState)) diff --git a/mumot/views.py b/mumot/views.py index a964133..6639419 100644 --- a/mumot/views.py +++ b/mumot/views.py @@ -32,6 +32,7 @@ symbols, ) from sympy.parsing.latex import parse_latex +from warnings import warn from . import ( consts, @@ -3912,8 +3913,7 @@ def _constructorSpecificParams(self, MAParams): # self._errorMessage.value = "Only Moving-Particle netType is available when rules contain the emptyset." if not self._netType == consts.NetworkType.DYNAMIC: wrnMsg = "Only Moving-Particle netType is available when rules contain the emptyset or constant reactants." - print(wrnMsg) - #raise exceptions.MuMoTWarning() + warn(wrnMsg, exceptions.MuMoTWarning) self._netType = consts.NetworkType.DYNAMIC if self._controller: # updating value and disabling widget if self._controller._widgetsExtraParams.get('netType') is not None: @@ -3928,8 +3928,7 @@ def _constructorSpecificParams(self, MAParams): wrnMsg = "WARNING! net-param value " + str(self._netParam) + " is invalid for Moving-Particles. Valid range is [0,1] indicating the particles' communication range. \n" self._netParam = 0.1 wrnMsg += "New default values is '_netParam'=" + str(self._netParam) - print(wrnMsg) - #raise exceptions.MuMoTWarning(wrnMsg) + warn(wrnMsg, exceptions.MuMoTWarning) def _build_bookmark(self, includeParams=True) -> str: log_str = "bookmark = " if not self._silent else ""