From feaa82b4bfdfc81eba88f71a36a413466375388e Mon Sep 17 00:00:00 2001 From: Adam Paquette Date: Mon, 28 Jan 2019 18:00:51 -0700 Subject: [PATCH] Updated some python documentation --- ale/drivers/__init__.py | 7 ++++++- ale/drivers/base.py | 26 +++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/ale/drivers/__init__.py b/ale/drivers/__init__.py index 7f0056e..d5f94b1 100644 --- a/ale/drivers/__init__.py +++ b/ale/drivers/__init__.py @@ -21,7 +21,12 @@ drivers = dict(chain.from_iterable(inspect.getmembers(dmod, lambda x: inspect.is def load(label): """ - Load label from + Attempt to load a given label from all possible drivers + + Parameters + ---------- + label : str + String path to the given label file """ for name, driver in drivers.items(): try: diff --git a/ale/drivers/base.py b/ale/drivers/base.py index 57e8d37..3b8eb59 100644 --- a/ale/drivers/base.py +++ b/ale/drivers/base.py @@ -22,9 +22,25 @@ class Driver(): self._file = file def __str__(self): + """ + Returns a string representation of the class + + Returns + ------- + str + String representation of all attributes and methods of the class + """ return str(self.to_dict()) def is_valid(self): + """ + Checks if the driver has an intrument id associated with it + + Returns + ------- + bool + True if an instrument_id is defined, False otherwise + """ try: iid = self.instrument_id return True @@ -32,10 +48,18 @@ class Driver(): return False def to_dict(self): + """ + Generates a dictionary of keys based on the attributes and methods assocated with + the driver and the required keys for the driver + + Returns + ------- + dict + Dictionary of key, attribute pairs + """ keys = set(dir(self)) & self.required_keys return {p:getattr(self, p) for p in keys} - class LineScanner(Driver): @property def name_model(self): -- GitLab