From fbec2667e4905fb65ad034fee7c0d4094e96d634 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Wed, 16 Nov 2022 19:55:27 +0100 Subject: Replacing __str__ by __repr__. Removing save_as_csv. --- src/argaze/DataStructures.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/argaze/DataStructures.py b/src/argaze/DataStructures.py index 6502091..5bbd47e 100644 --- a/src/argaze/DataStructures.py +++ b/src/argaze/DataStructures.py @@ -46,10 +46,10 @@ class TimeStampedBuffer(collections.OrderedDict): super().__setitem__(ts, data) - def __str__(self): + def __repr__(self): """String representation""" - return json.dumps(self, default=vars) + return json.dumps(self, ensure_ascii = False, default=vars) def append(self, timestamped_buffer: TimeStampedBufferType) -> TimeStampedBufferType: """Append a timestamped buffer.""" @@ -153,25 +153,6 @@ class TimeStampedBuffer(collections.OrderedDict): return df - def save_as_csv(self, filepath, exclude=[]): - """Write into a csv file.""" - - try: - self.as_dataframe(exclude=exclude).to_csv(filepath, index=True) - - except: - raise RuntimeError(f'Can\' write {filepath}') - - def save_as_json(self, filepath): - """Write into a json file.""" - - try: - with open(filepath, 'w', encoding='utf-8') as jsonfile: - json.dump(self, jsonfile, ensure_ascii = False, default=vars) - - except: - raise RuntimeError(f'Can\' write {filepath}') - def plot(self, names=[], colors=[], split={}, samples=None) -> list: """Plot as [matplotlib](https://matplotlib.org/) time chart.""" -- cgit v1.1