Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename examples to cli #118

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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.
Loading