Skip to content
Snippets Groups Projects

Resolve "release v1.4.0"

Merged Ghost User requested to merge release_v1.4.0 into master
3 files
+ 51
0
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -11,6 +11,7 @@ from mlair.helpers import remove_items
class AbstractDataHandler:
_requirements = []
_store_attributes = []
def __init__(self, *args, **kwargs):
pass
@@ -32,6 +33,31 @@ class AbstractDataHandler:
list_of_args = arg_spec.args + arg_spec.kwonlyargs
return remove_items(list_of_args, ["self"] + list(args))
@classmethod
def store_attributes(cls):
"""
Let MLAir know that some data should be stored in the data store. This is used for calculations on the train
subset that should be applied to validation and test subset.
To work properly, add a class variable cls._store_attributes to your data handler. If your custom data handler
is constructed on different data handlers (e.g. like the DefaultDataHandler), it is required to overwrite the
get_store_attributs method in addition to return attributes from the corresponding subclasses. This is not
required, if only attributes from the main class are to be returned.
Note, that MLAir will store these attributes with the data handler's identification. This depends on the custom
data handler setting. When loading an attribute from the data handler, it is therefore required to extract the
right information by using the class identification. In case of the DefaultDataHandler this can be achieved to
convert all keys of the attribute to string and compare these with the station parameter.
"""
return list(set(cls._store_attributes))
def get_store_attributes(self):
"""Returns all attribute names and values that are indicated by the store_attributes method."""
attr_dict = {}
for attr in self.store_attributes():
attr_dict[attr] = self.__getattribute__(attr)
return attr_dict
@classmethod
def transformation(cls, *args, **kwargs):
return None
Loading