Melodie Exceptions
- MelodieInfra.exceptions.exceptions.assert_exc_occurs(exc_id: int, func: Callable)
Assert that this exception will occur.
- MelodieInfra.exceptions.exceptions.assert_exc_type_occurs(exc_type: BaseException, func: Callable)
Assert that exception of exc_type must occur.
- exception MelodieInfra.exceptions.exceptions.MelodieException(exc_id: int, text: str)
Bases:
Exception
- class MelodieInfra.exceptions.exceptions.MelodieExceptions
Bases:
object
- class Assertions
Bases:
object
- static Type(name, obj, expected_type)
Assert that the type of obj is the expected_type.
- static IsNone(name, obj)
Assert variable obj is None.
- static NotNone(name, obj)
Assert that the obj is not None
- class General
Bases:
object
- static TypeError(name, obj, expected_type: type)
The encapsulation of TypeError
- static NoAttributeError(obj, attr_name: str)
The encapsulation of AttributeError
- class Program
Bases:
object
Errors related to programming
code: 1000
- ID = 1000
- class Variable
Bases:
object
- ID = 1010
- static VariableInvalid(var_desc: str, var_value: Any, expected_value: Any)
If this occurs, please check the value of variable
code: 1011
- static VariableNotInSet(var_desc: str, var_value: Any, allowed_set: Set[Any])
Please check if variable is in the allowed set.
code: 1012
example: If the allowed set is {“apple”, “pears”}, but the variable value is “banana”
- class State
Bases:
object
- ID = 1100
- static StateNotFoundError(state, all_states)
- static CannotMoveToNewStateError(old_state, new_state, all_possible_new_states: set)
- static NotAStateAttributeError(agent_cls, state_attr: str)
- class Scenario
Bases:
object
- ID = 1200
- static ScenarioIDDuplicatedError(id_scenario)
Scenario ID should be unique. If there are identical scenario-id in the scenario table or generated, this error will be raised.
code: 1201
example: The scenario table below could make this error occur.
ID
env_param_1
env_param_2
…
0
10
20
…
0
15
20
…
In this table, the ids of scenarios are identical, which will cause this exception.
- static ScenarioIDTypeError(id_scenario)
Scenario ID should be integer type.
code: 1202
hint: Please check carefully to make sure the scenario id is integer.
- static NoValidScenarioGenerated(scenarios)
Operators (Simulator/Trainer/Calibrator) will generate a list of scenarios. If no scenario has been generated, this error will be raised.
code: 1204
Hint:
If you overrode the
generate_scenarios
method of DataframeLoader, make sure valid value returned.If you are using
xlsx
tables, make sure the first page of<operator_type>_scenarios.xlsx
is not empty.
- static ParameterRedefinedError(parameter_name: str, all_params: List)
For the interactive parameters of Scenario, the name should be unique. If two parameters has the same name, this exception will be raised.
code: 1205
- class Agents
Bases:
object
- ID = 1300
- static AgentListEmpty(agent_manager)
code: 1301
- static AgentPropertyNameNotExist(property_name, agent)
code: 1302
- static AgentIDConflict(agent_container_name: str, agent_ids: List[int])
Agent ID should be unique.
code: 1303
- class Data
Bases:
object
This class is used when external data is imported or exported.
- ID = 1500
- static TableNameAlreadyExists(table_name: str, existed: str)
- static StaticTableNotRegistered(table_name: str, all_table_names: List[str])
Static table should be registered before use.
code: 1502
hint: Make sure this table is correctly registered in the DataLoader.
- static AttemptingReadingFromUnexistedTable(table_name)
When reading the database, the table must exist in the database. * code: 1503
- static ObjectPropertyTypeUnMatchTheDataFrameError(param_name: str, param_type: type, dataframe_dtypes: Dict[str, type], agent: Agent)
Object type should match the type defined in dataframe.
code: 1504
example: If the dataframe has type float, and agent property was str.
- static TableNameInvalid(table_name)
The table name should be an identifier.
code: 1505
hint: Do not use “+”, “-”, “*”, “/” or other special characters.
example:
table-123
;table+123
- static TableNotFound(table_name: str, all_tables: dict)
Table may not be registered.
code: 1506
- static InvalidDatabaseType(database: str, supported_db_types: Set[str])
code: 1508
- static NoDataframeLoaderDefined()
Dataframe Loader must be defined if you want to use the static table.
code: 1509
- static ColumnNameConsistencyError(df_name: str, missing: Set[str], undefined: Set[str])
The column name in code should be consistent to the table.
code: 1510