From b4d03325de5388db559fd11f3ff78ef51921b6d2 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Mon, 27 Jul 2020 09:50:33 +0200 Subject: [PATCH] docstrings and added Dataset totalcount function --- fishbook/frontend/frontend_classes.py | 36 +++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/fishbook/frontend/frontend_classes.py b/fishbook/frontend/frontend_classes.py index f84d08e..c6959c5 100644 --- a/fishbook/frontend/frontend_classes.py +++ b/fishbook/frontend/frontend_classes.py @@ -80,14 +80,16 @@ class Cell: class Dataset: - """[summary] + """The Dataset class represents an entry in the "datasets" table in the database. In the relacs context a Dataset represents all that has been recorded between pressing enter. For example all that is stored in the folder 2020-01-01-aa. + + """ def __init__(self, dataset_id=None, tuple=None): - """[summary] + """Constructor of a Dataset entity. Args: - dataset_id ([type], optional): [description]. Defaults to None. - tuple ([type], optional): [description]. Defaults to None. + dataset_id (str, optional): the id. Defaults to None. + tuple (tuple, optional): The properties used to identify the entity in the database. Usually only for internal use. Defaults to None. """ self.__samplerate = 0.0 if tuple: @@ -113,7 +115,7 @@ class Dataset: @property def experimenter(self): - """The person who recording the dataset. + """The person who did record the dataset. Returns: str: The experimenter @@ -122,6 +124,11 @@ class Dataset: @property def recording_date(self): + """The Dataset's recording date. + + Returns: + str: the recording date. + """ return self.__tuple["recording_date"] @property @@ -162,8 +169,27 @@ class Dataset: def samplerate(self): return self.__samplerate + @staticmethod + def totalDatasetCount(): + """Returns the total number of datasets defined in the database. + + Returns: + int: the count + """ + return len(Datasets) + @staticmethod def find(min_duration=None, experimenter=None, quality=None): + """Find dataset entries in the database. You may restrict the search by providing the following arguments. + + Args: + min_duration (float, optional): minimum duration of the recording session, if not given, any length datasets will be returned. Defaults to None. + experimenter (str, optional): the name of the one who did the recording. The name does not need to be the full name. Defaults to None. + quality (str, optional): the quality assigned to the dataset during recording (e.g. good, fair, poor). Defaults to None. + + Returns: + list: list of Dataset object matching the search criteria. + """ dataset_list = Datasets if min_duration: dataset_list = dataset_list & "duration > %.2f" % min_duration