Skip to content

Commit

Permalink
fix: stringify AggregatedData
Browse files Browse the repository at this point in the history
  • Loading branch information
iomz committed Aug 10, 2023
1 parent 3944058 commit 94c59f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/sample_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def on_classifier_event(self, ce: ClassifierEvent):
pass

async def on_aggregated_data(self, ad: AggregatedData):
logging.info(ad.json())
logging.info(ad)

async def on_emg_data(self, emg: EMGData):
# logging.info(emg)
Expand Down
2 changes: 1 addition & 1 deletion myo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, fvd: FVData, imu: IMUData):
self.imu = imu

def __str__(self):
return f"{repr(self.fvd)},{repr(self.imu)}"
return f"{','.join(map(str, self.fvd.fv))},{self.imu}"

def json(self):
return json.dumps(self.to_dict())
Expand Down
6 changes: 6 additions & 0 deletions myo/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ def __init__(self, w, x, y, z):
self.y = y / ORIENTATION_SCALE
self.z = z / ORIENTATION_SCALE

def __str__(self):
return f"{self.w},{self.x},{self.y},{self.z}"

def to_dict(self):
return {"w": self.w, "x": self.x, "y": self.y, "z": self.z}

Expand All @@ -218,6 +221,9 @@ def __repr__(self):
)
)

def __str__(self):
return f"{self.orientation},{','.join(map(str, self.accelerometer))},{','.join(map(str, self.gyroscope))}"

def json(self):
return json.dumps(self.to_dict())

Expand Down

0 comments on commit 94c59f0

Please sign in to comment.