Skip to content

Commit

Permalink
Move AxisArray monkey patch to util module so downstream can use it…
Browse files Browse the repository at this point in the history
… without importing pylsl.
  • Loading branch information
cboulay committed Sep 3, 2024
1 parent a22a041 commit 1e75f0d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
15 changes: 1 addition & 14 deletions src/ezmsg/lsl/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,9 @@

import numpy as np
import pylsl

import ezmsg.core as ez
from ezmsg.util.messages.axisarray import AxisArray


@dataclass
class CustomAxis(AxisArray.Axis):
labels: typing.List[str] = field(default_factory=lambda: [])

@classmethod
def SpaceAxis(cls, labels: typing.List[str]): # , locs: typing.Optional[npt.NDArray] = None):
return cls(unit="mm", labels=labels)


# Monkey-patch AxisArray with our customized Axis
AxisArray.Axis = CustomAxis
from .util import AxisArray


# Reproduce pylsl.string2fmt but add float64 for more familiar numpy usage
Expand Down
17 changes: 17 additions & 0 deletions src/ezmsg/lsl/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from dataclasses import dataclass, field
import typing

from ezmsg.util.messages.axisarray import AxisArray


@dataclass
class CustomAxis(AxisArray.Axis):
labels: typing.List[str] = field(default_factory=lambda: [])

@classmethod
def SpaceAxis(cls, labels: typing.List[str]): # , locs: typing.Optional[npt.NDArray] = None):
return cls(unit="mm", labels=labels)


# Monkey-patch AxisArray with our customized Axis
AxisArray.Axis = CustomAxis

0 comments on commit 1e75f0d

Please sign in to comment.