Skip to content

Commit

Permalink
Post release 1.8 and handle deprecation (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Scheltienne authored Nov 29, 2024
1 parent c60a156 commit f4f0f73
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 53 deletions.
2 changes: 0 additions & 2 deletions doc/development/changes/1.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

.. include:: ./authors.inc

.. _latest:

Version 1.8
===========

Expand Down
1 change: 1 addition & 0 deletions doc/development/changes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
.. toctree::
:titlesonly:

latest.rst
1.8.rst
1.7.rst
1.6.rst
Expand Down
22 changes: 22 additions & 0 deletions doc/development/changes/latest.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. NOTE: we use cross-references to highlight new functions and classes.
Please follow the examples below, so the changelog page will have a link to
the function/class documentation.
.. NOTE: there are 3 separate sections for changes, based on type:
- "Enhancements" for new features
- "Bugs" for bug fixes
- "API changes" for backward-incompatible changes
.. NOTE: You can use the :pr:`xx` and :issue:`xx` role to x-ref to a GitHub PR
or issue from this project.
:hide-toc:

.. include:: ./authors.inc

.. _latest:

Version 1.9
===========

- xxx
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ maintainers = [
name = 'mne_lsl'
readme = 'README.md'
requires-python = '>=3.10'
version = '1.8.0'
version = '1.9.0.dev0'

[project.optional-dependencies]
all = [
Expand Down
18 changes: 6 additions & 12 deletions src/mne_lsl/stream/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,14 @@ def connect(
return self
if acquisition_delay is not None:
check_type(acquisition_delay, ("numeric",), "acquisition_delay")
if acquisition_delay < 0:
if acquisition_delay <= 0:
raise ValueError(
"The acquisition delay must be a positive number defining the "
"delay at which new samples are acquired in seconds. For instance, "
"0.2 corresponds to a pull every 200 ms. None corresponds to "
f"manual acquisition. The provided {acquisition_delay} is invalid."
"The acquisition delay must be a strictly positive number defining "
"the delay at which new samples are acquired in seconds. For "
"instance, 0.2 corresponds to a pull every 200 ms. None "
"corresponds to manual acquisition. The provided "
f"{acquisition_delay} is invalid."
)
if acquisition_delay == 0:
warn(
"Argument acquisition_delay=0 is deprecated in favor of "
"acquisition_delay=None.",
DeprecationWarning,
)
acquisition_delay = None
self._acquisition_delay = acquisition_delay
self._n_new_samples = 0
self._executor = (
Expand Down
13 changes: 3 additions & 10 deletions src/mne_lsl/stream/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,14 @@ def connect(self, acquisition_delay: float | None = 0.001) -> EpochsStream:
)
if acquisition_delay is not None:
check_type(acquisition_delay, ("numeric",), "acquisition_delay")
if acquisition_delay < 0:
if acquisition_delay <= 0:
raise ValueError(
"The acquisition delay must be a positive number defining the "
"delay at which the epochs might be updated in seconds. For "
"The acquisition delay must be a strictly positive number defining "
"the delay at which the epochs might be updated in seconds. For "
"instance, 0.2 corresponds to a query to the event source every "
"200 ms. None corresponds to manual acquisition. The provided "
f"{acquisition_delay} is invalid."
)
if acquisition_delay == 0:
warn(
"Argument acquisition_delay=0 is deprecated in favor of "
"acquisition_delay=None.",
DeprecationWarning,
)
acquisition_delay = None
self._acquisition_delay = acquisition_delay
assert self._n_new_epochs == 0 # sanity-check
# create the buffer and start acquisition in a separate thread
Expand Down
18 changes: 0 additions & 18 deletions tests/stream/test_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,21 +1072,3 @@ def test_epochs_single_event(mock_lsl_stream, outlet_marker: StreamOutlet):
time.sleep(0.2)
assert epochs.n_new_epochs == 1
assert event_stream.n_new_samples == 1


def test_manual_acquisition_deprecation(mock_lsl_stream):
"""Test deprecation of acquisition_delay=0."""
stream = StreamLSL(
0.5, name=mock_lsl_stream.name, source_id=mock_lsl_stream.source_id
).connect(acquisition_delay=0.1)
epochs = EpochsStream(
stream,
10,
event_channels="trg",
event_id=dict(a=1),
tmin=-0.05,
tmax=0.15,
baseline=(None, 0),
)
with pytest.warns(DeprecationWarning, match="acquisition_delay"):
epochs.connect(acquisition_delay=0)
11 changes: 1 addition & 10 deletions tests/stream/test_stream_lsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_stream_invalid():
Stream(1, stype=101)
with pytest.raises(TypeError, match="must be an instance of str"):
Stream(1, source_id=101)
with pytest.raises(ValueError, match="must be a positive number"):
with pytest.raises(ValueError, match="must be a strictly positive number"):
Stream(bufsize=2).connect(acquisition_delay=-1)


Expand Down Expand Up @@ -1214,12 +1214,3 @@ def test_manual_acquisition_errors(mock_lsl_stream):
with pytest.raises(RuntimeError, match="Acquisition is done automatically"):
stream.acquire()
stream.disconnect()


def test_manual_acquisition_deprecation(mock_lsl_stream):
"""Test deprecation of acquisition_delay=0."""
stream = Stream(
bufsize=2.0, name=mock_lsl_stream.name, source_id=mock_lsl_stream.source_id
)
with pytest.warns(DeprecationWarning, match="acquisition_delay"):
stream.connect(acquisition_delay=0)

0 comments on commit f4f0f73

Please sign in to comment.