Skip to content

Commit

Permalink
ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cboulay committed Dec 7, 2024
1 parent a16d763 commit 0ae95f0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/pylsl/examples/HandleMetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import time

import numpy as np
from pylsl import StreamInfo, StreamInlet, StreamOutlet, resolve_byprop


Expand All @@ -13,7 +14,8 @@ def main():
# now attach some meta-data (in accordance with XDF format,
# see also https://github.com/sccn/xdf/wiki/Meta-Data)
chns = info.desc().append_child("channels")
for label in ["C3", "C4", "Cz", "FPz", "POz", "CPz", "O1", "O2"]:
ch_labels = ["C3", "C4", "Cz", "FPz", "POz", "CPz", "O1", "O2"]
for label in ch_labels:
ch = chns.append_child("channel")
ch.append_child_value("label", label)
ch.append_child_value("unit", "microvolts")
Expand All @@ -27,7 +29,9 @@ def main():
# create outlet for the stream
outlet = StreamOutlet(info)

# (...normally here one might start sending data into the outlet...)
# Send a sample into the outlet...
dummy_sample = np.arange(len(ch_labels), dtype=np.float32)
outlet.push_sample(dummy_sample)

# === the following could run on another computer ===

Expand Down
10 changes: 4 additions & 6 deletions src/pylsl/examples/PerformanceTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
)

try:
from pyfftw.interfaces.numpy_fft import ( # Performs much better than numpy's fftpack
irfft,
rfft,
)
from pyfftw.interfaces.numpy_fft import irfft
# Performs much better than numpy's fftpack
except ImportError:
from numpy.fft import irfft, rfft
from numpy.fft import irfft
try:
import sys

Expand Down Expand Up @@ -339,7 +337,7 @@ def __init__(self):
self.inlet = StreamInlet(streams[0], processing_flags=proc_flags)
# The following is an example of how to read stream info
stream_info = self.inlet.info()
stream_Fs = stream_info.nominal_srate()
# stream_Fs = stream_info.nominal_srate()
stream_xml = stream_info.desc()
chans_xml = stream_xml.child("channels")
chan_xml_list = []
Expand Down
4 changes: 2 additions & 2 deletions src/pylsl/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def __del__(self):
# noinspection PyBroadException
try:
lib.lsl_destroy_streaminfo(self.obj)
except:
pass
except Exception as e:
print(f"StreamInfo deletion triggered error: {e}")

# === Core Information (assigned at construction) ===

Expand Down
4 changes: 2 additions & 2 deletions src/pylsl/outlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def __del__(self):
# noinspection PyBroadException
try:
lib.lsl_destroy_outlet(self.obj)
except:
pass
except Exception as e:
print(f"StreamOutlet deletion triggered error: {e}")

def push_sample(self, x, timestamp=0.0, pushthrough=True):
"""Push a sample into the outlet.
Expand Down

0 comments on commit 0ae95f0

Please sign in to comment.