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

Delaying the depreciation of old dataset names in the dataset list #464

Merged
merged 11 commits into from Aug 21, 2023
2 changes: 1 addition & 1 deletion docs/source/whats_new.rst
Expand Up @@ -66,7 +66,7 @@ Bugs
- Fix :func:`moabb.paradigms.FakeImageryParadigm`, :func:`moabb.paradigms.FakeP300Paradigm` and :func:`moabb.paradigms.FakeSSVEPParadigm` ``is_valid`` methods to only accept the correct datasets (PR :gh:`408` by `Pierre Guetschel`_)
- Fix ``dataset_list`` construction, which could be empty due to bad import order (PR :gh:`449` by `Thomas Moreau`_).
- Fixing dataset downloader from servers with non-http (PR :gh:`433` by `Sara Sedlar`_)

- Fix ``dataset_list`` to include deprecated datasets (PR :gh:`464` by `Bruno Aristimunha`_)
API changes
~~~~~~~~~~~

Expand Down
43 changes: 21 additions & 22 deletions moabb/datasets/__init__.py
Expand Up @@ -11,6 +11,16 @@
# flake8: noqa
from .alex_mi import AlexMI
from .bbci_eeg_fnirs import Shin2017A, Shin2017B

# Depreciated datasets (will be removed in the future):
from .bnci import BNCI2014001 # noqa: F401
from .bnci import BNCI2014002 # noqa: F401
from .bnci import BNCI2014004 # noqa: F401
from .bnci import BNCI2014008 # noqa: F401
from .bnci import BNCI2014009 # noqa: F401
from .bnci import BNCI2015001 # noqa: F401
from .bnci import BNCI2015003 # noqa: F401
from .bnci import BNCI2015004 # noqa: F401
from .bnci import (
BNCI2014_001,
BNCI2014_002,
Expand All @@ -21,6 +31,13 @@
BNCI2015_003,
BNCI2015_004,
)
from .braininvaders import VirtualReality # noqa: F401
from .braininvaders import bi2012 # noqa: F401
from .braininvaders import bi2013a # noqa: F401
from .braininvaders import bi2014a # noqa: F401
from .braininvaders import bi2014b # noqa: F401
from .braininvaders import bi2015a # noqa: F401
from .braininvaders import bi2015b # noqa: F401
from .braininvaders import (
BI2012,
BI2013a,
Expand All @@ -35,12 +52,15 @@
from .gigadb import Cho2017
from .huebner_llp import Huebner2017, Huebner2018
from .Lee2019 import Lee2019_ERP, Lee2019_MI, Lee2019_SSVEP
from .mpi_mi import MunichMI # noqa: F401
from .mpi_mi import GrosseWentrup2009
from .neiry import DemonsP300
from .phmd_ml import HeadMountedDisplay # noqa: F401
from .phmd_ml import Cattan2019_PHMD
from .physionet_mi import PhysionetMI
from .schirrmeister2017 import Schirrmeister2017
from .sosulski2019 import Sosulski2019
from .ssvep_exo import SSVEPExo # noqa: F401
from .ssvep_exo import Kalunga2016
from .ssvep_mamem import MAMEM1, MAMEM2, MAMEM3
from .ssvep_nakanishi import Nakanishi2015
Expand All @@ -51,27 +71,6 @@
from .Zhou2016 import Zhou2016


# Call this last in order to make sure the dataset list contains all
# Call this last in order to make sure the dataset list is populated with
# the datasets imported in this file.
_init_dataset_list()
del _init_dataset_list

# Depreciated datasets (not added to dataset_list):
from .bnci import BNCI2014001 # noqa: F401
from .bnci import BNCI2014002 # noqa: F401
from .bnci import BNCI2014004 # noqa: F401
from .bnci import BNCI2014008 # noqa: F401
from .bnci import BNCI2014009 # noqa: F401
from .bnci import BNCI2015001 # noqa: F401
from .bnci import BNCI2015003 # noqa: F401
from .bnci import BNCI2015004 # noqa: F401
from .braininvaders import VirtualReality # noqa: F401
from .braininvaders import bi2012 # noqa: F401
from .braininvaders import bi2013a # noqa: F401
from .braininvaders import bi2014a # noqa: F401
from .braininvaders import bi2014b # noqa: F401
from .braininvaders import bi2015a # noqa: F401
from .braininvaders import bi2015b # noqa: F401
from .mpi_mi import MunichMI # noqa: F401
from .phmd_ml import HeadMountedDisplay # noqa: F401
from .ssvep_exo import SSVEPExo # noqa: F401
13 changes: 8 additions & 5 deletions moabb/tests/datasets.py
Expand Up @@ -183,6 +183,8 @@ def test_dataset_accept(self):
def test_datasets_init(self):
codes = []
logger = logging.getLogger("moabb.datasets.base")
deprecated_list, _, _ = zip(*aliases_list)

for ds in dataset_list:
kwargs = {}
if inspect.signature(ds).parameters.get("accept"):
Expand All @@ -192,9 +194,11 @@ def test_datasets_init(self):
# Trick needed because assertNoLogs only inrtoduced in python 3.10:
logger.warning(f"Testing {ds.__name__}")
obj = ds(**kwargs)
self.assertEqual(len(cm.output), 1)
if type(obj).__name__ not in deprecated_list:
self.assertEqual(len(cm.output), 1)
self.assertIsNotNone(obj)
codes.append(obj.code)
if type(obj).__name__ not in deprecated_list:
codes.append(obj.code)

# Check that all codes are unique:
self.assertEqual(len(codes), len(set(codes)))
Expand All @@ -219,17 +223,16 @@ def test_dataset_list(self):
if aliases_list:
depreciated_list, _, _ = zip(*aliases_list)
else:
depreciated_list = []
pass
all_datasets = [
c
for c in db.__dict__.values()
if (
inspect.isclass(c)
and issubclass(c, BaseDataset)
and c.__name__ not in depreciated_list
# and c.__name__ not in depreciated_list
)
]

assert len(dataset_list) == len(all_datasets)
assert set(dataset_list) == set(all_datasets)

Expand Down