[frontend] add __repr__ and to dict methods
This commit is contained in:
parent
48acf9edb3
commit
e37d4d5add
@ -6,6 +6,7 @@ import numpy as np
|
||||
from IPython import embed
|
||||
from fishbook.backend.util import progress
|
||||
import datetime as dt
|
||||
import yaml
|
||||
|
||||
class Cell:
|
||||
"""The Cell class represents a recorded cell. It is characterized by *id*, the cell *type*, the *firing_rate*, and the recording *location*.
|
||||
@ -382,6 +383,16 @@ class Dataset:
|
||||
def _tuple(self):
|
||||
return self.__tuple.copy()
|
||||
|
||||
@property
|
||||
def yaml(self):
|
||||
settings = yaml.dump({"dataset id": self.id, "recording date": self.recording_date,
|
||||
"duration": self.recording_duration, "comment": self.comment,
|
||||
"experimenter": self.experimenter, "quality": self.quality,
|
||||
"data_source": self.data_source, "host": self.data_host,
|
||||
"setup": self.setup, "nixed": self.has_nix})
|
||||
return settings
|
||||
|
||||
|
||||
def __str__(self):
|
||||
str = "dataset id: %s\n" % self.id
|
||||
str += "recorded: %s \t by: %s\n" % (self.recording_date, self.experimenter)
|
||||
@ -390,6 +401,8 @@ class Dataset:
|
||||
str += "comment: %s" % self.comment
|
||||
return str
|
||||
|
||||
def __repr__(self):
|
||||
return self.__str__()
|
||||
|
||||
class RePro:
|
||||
"""The RePro class represents an entry in the repro table. This is a run of a certain relacs "Research Protocol".
|
||||
@ -518,6 +531,17 @@ class RePro:
|
||||
str += "start time: %s\t duration: %s\n" % (self.start, self.duration)
|
||||
return str
|
||||
|
||||
def __repr__(self):
|
||||
return self.__str__()
|
||||
|
||||
@property
|
||||
def to_dict(self):
|
||||
r_settings = yaml.safe_load(self.settings.replace("\t", " "))
|
||||
settings = {"repro id": self.id, "run": self.run, "cell": self.cell_id,
|
||||
"name": self.name, "start": self.start, "duration": self.duration,
|
||||
"settings":r_settings}
|
||||
return settings
|
||||
|
||||
|
||||
class Stimulus:
|
||||
"""The stimulus class represents a Stimulus that was presented. A Stimulus has several properties
|
||||
@ -622,6 +646,17 @@ class Stimulus:
|
||||
|
||||
return results, total
|
||||
|
||||
def __repr__(self):
|
||||
return self.__str__()
|
||||
|
||||
@property
|
||||
def to_dict(self):
|
||||
s_settings = yaml.safe_load(self.settings.replace("\t", " "))
|
||||
settings = {"id": self.id, "run": self.run, "stimulus name" : self.name,
|
||||
"stimulus index": self.index, "duration": self.duration, "start time": self.start_time,
|
||||
"name": self.name, "settings": s_settings}
|
||||
return settings
|
||||
|
||||
|
||||
class Subject:
|
||||
"""Representation of the recorded subject's properties.
|
||||
|
Loading…
Reference in New Issue
Block a user