<jupyter_start><jupyter_text>Deriving evolver and driver classesIn `micromagneticmodel` package, base classes `micromagneticmodel.Driver` and `micromagneticmodel.Evolver` are defined. Their purpose is to build individual evolvers and drivers in a particular micromagnetic calculator. In this tutorial, we will demonstrate some of their basic properties, on an example of a `micromagneticmodel.Driver` class. The behaviour of the `micromagneticmodel.Evolver` class is the same.Let us derive `MyDriver` class. In order to define it, `_allowed_attributes` list must be defined. It is a list of strings, which lists the kwargs which are allowed to be passed.<jupyter_code>import micromagneticmodel as mm

class MyDriver(mm.Driver):
    _allowed_attributes = ['arg1', 'arg2']
    
    def drive(system):
        return system<jupyter_output><empty_output><jupyter_text>`Driver` class does not require any parameters to be passed at initialisation. If a keyword argument is from `_allowed_kwargs` list, it will be assigned as a class attribute. Otherwise, `AttributeError` will be raised.<jupyter_code>driver = MyDriver(arg1=1, arg2='value')<jupyter_output><empty_output><jupyter_text>The attributes are<jupyter_code>driver.arg1
driver.arg2<jupyter_output><empty_output><jupyter_text>If we try to pass a keyword argument at initialisation, which is not in the `_allowed_kwargs` list, `AttributeError` is rased:<jupyter_code>try:
    driver = MyDriver(arg3=1)
except AttributeError:
    print('Exception raised.')<jupyter_output>Exception raised.<jupyter_text>The main driver method which must be implemented by a derived class is `drive`.<jupyter_code>try:
    driver.drive()
except NotImplementedError:
    print('Exception raised.')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07849829351535836, 'fraction_numerical': 0.005119453924914676, 'mean_word_length': 6.2987551867219915, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '448919', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 512, 'n_tokens_neox': 501, 'n_words': 178, 'path': 'docs/evolver-driver.ipynb', 'repo_name': 'ubermag/micromagneticmodel', 'size': '1758'}