Skip to content

Commit

Permalink
Rename examples to cli (#118)
Browse files Browse the repository at this point in the history
* Not necessary since Python 3.3

* Update ruff-action repo

* Rename to cli and enforce 88 chars

* Remove trailing whitespace

* Add changelog entry
  • Loading branch information
cbrnr authored Nov 4, 2024
1 parent e4c2417 commit 6a75c0c
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 136 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
- uses: chartboost/ruff-action@v1
- uses: astral-sh/ruff-action@v1
- uses: astral-sh/ruff-action@v1
with:
args: 'format --check'
args: "format --check"

test:
needs: style
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
### Fixed
- Expose detected segment (used in dejittering) as `stream["info"]["segments"]` ([#117](https://github.com/xdf-modules/pyxdf/pull/117) by [Robert Guggenberger](https://github.com/agricolab))

### Changed
- Rename `pyxdf.examples` module to `pyxdf.cli` ([#118](https://github.com/xdf-modules/xdf-Python/pull/118) by [Clemens Brunner](https://github.com/cbrnr))

## [1.16.8] - 2024-07-18
### Fixed
- Fix reading numeric array data on big-endian hosts ([#98](https://github.com/xdf-modules/pyxdf/pull/98) by [Ben Beasley](https://github.com/musicinmybrain))
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ plt.show()

## CLI examples

`pyxdf` has an `examples` module, which can be run from the command line for basic functionality.
`pyxdf` has a `cli` module with the following basic command line tools:

* `print_metadata` will enable a DEBUG logger to log read messages, then it will print basic metadata about each found stream.
* `python -m pyxdf.examples.print_metadata -f=/path/to/my.xdf`
* `print_metadata` will enable a DEBUG logger to log read messages, then it will print basic metadata for each found stream.
* `python -m pyxdf.cli.print_metadata -f=/path/to/my.xdf`
* `playback_lsl` will open an XDF file then replay its data in an infinite loop, but using current timestamps. This is useful for prototyping online processing.
* `python -m pyxdf.examples.playback_lsl /path/to/my.xdf`
* `python -m pyxdf.cli.playback_lsl /path/to/my.xdf`

## Installation

Expand Down
11 changes: 6 additions & 5 deletions pyxdf/examples/playback_lsl.py → pyxdf/cli/playback_lsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def __init__(
):
if rate != 1.0:
print(
"WARNING!! rate != 1.0; It is impossible to synchronize playback streams "
"with real time streams."
"WARNING!! rate != 1.0; it is impossible to synchronize playback "
"streams with real time streams."
)
self.rate: float = rate # Maximum rate is loop_time / avg_update_interval, whatever that might be.
self.rate: float = rate # Maximum rate is loop_time / avg_update_interval
self._boundary = loop_time
self._max_srate = max_sample_rate
decr = (1 / self._max_srate) if self._max_srate else 2 * sys.float_info.epsilon
Expand All @@ -89,7 +89,7 @@ def reset(self, reset_file_position: bool = False) -> None:
def set_rate(self, rate: float) -> None:
self.rate = rate
# Note: We do not update file_read_s and prev_file_read_s.
# Changing the playback rate does not change where we are in the file.
# Changing the playback rate does not change where we are in the file.
self.reset(reset_file_position=False)

def update(self):
Expand Down Expand Up @@ -121,7 +121,8 @@ def sleep(self, duration: Optional[float] = None) -> None:
if self._max_srate <= 0:
duration = 0.005
else:
# Check to see if the current time is not already beyond the expected time of the next iteration.
# Check to see if the current time is not already beyond the expected
# time of the next iteration.
step_time = 1 / self._max_srate
now_read_s = self.rate * (pylsl.local_clock() - self._wall_start)
next_read_s = self._file_read_s + step_time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ def main(fname: str):

print("Found {} streams:".format(len(streams)))
for ix, stream in enumerate(streams):
msg = "Stream {}: {} - type {} - uid {} - shape {} in {} segments at {} (effective {}) Hz"
msg = (
"Stream {}: {} - type {} - uid {} - shape {} in {} segments at {} "
"(effective {}) Hz"
)
print(
msg.format(
ix + 1,
Expand Down
Empty file removed pyxdf/examples/__init__.py
Empty file.
236 changes: 113 additions & 123 deletions pyxdf/pyxdf.py

Large diffs are not rendered by default.

Empty file removed pyxdf/test/__init__.py
Empty file.

0 comments on commit 6a75c0c

Please sign in to comment.