Skip to content

Commit

Permalink
FIX empty dataset_list in python3.10 (#449)
Browse files Browse the repository at this point in the history
* FIX empty dataset_list in python3.10

* [pre-commit.ci] auto fixes from pre-commit.com hooks

* DOC add what's new entry

- FIX comment position due to pre-commit messing with the files

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
tomMoral and pre-commit-ci[bot] committed Aug 4, 2023
1 parent 0757a3b commit 01e2899
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/source/whats_new.rst
Expand Up @@ -59,6 +59,7 @@ Bugs
- Fix :func:`moabb.benchmark` overwriting ``include_datasets`` list (:gh:`408` by `Pierre Guetschel`_)
- Fix :func:`moabb.paradigms.base.BaseParadigm` using attributes before defining them (PR :gh:`408`, issue :gh:`425` by `Pierre Guetschel`_)
- 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`_).

API changes
~~~~~~~~~~~
Expand Down Expand Up @@ -368,3 +369,4 @@ API changes
.. _Jan Sosulski: https://github.com/jsosulski
.. _Pierre Guetschel: https://github.com/PierreGtch
.. _Ludovic Darmet: https://github.com/ludovicdmt
.. _Thomas Moreau: https://github.com/tommoral
6 changes: 6 additions & 0 deletions moabb/datasets/__init__.py
Expand Up @@ -46,5 +46,11 @@
from .ssvep_nakanishi import Nakanishi2015
from .ssvep_wang import Wang2016
from .upper_limb import Ofner2017
from .utils import _init_dataset_list
from .Weibo2014 import Weibo2014
from .Zhou2016 import Zhou2016


# Call this last in order to make sure the dataset list contains all
# the datasets imported in this file.
_init_dataset_list()
3 changes: 0 additions & 3 deletions moabb/datasets/utils.py
Expand Up @@ -15,9 +15,6 @@ def _init_dataset_list():
dataset_list.append(ds[1])


_init_dataset_list()


def dataset_search( # noqa: C901
paradigm=None,
multi_session=False,
Expand Down
15 changes: 14 additions & 1 deletion moabb/tests/datasets.py
@@ -1,13 +1,16 @@
import inspect
import shutil
import tempfile
import unittest

import mne

from moabb import datasets as db
from moabb.datasets import Shin2017A, Shin2017B, VirtualReality
from moabb.datasets.base import BaseDataset
from moabb.datasets.compound_dataset import CompoundDataset
from moabb.datasets.fake import FakeDataset, FakeVirtualRealityDataset
from moabb.datasets.utils import block_rep
from moabb.datasets.utils import block_rep, dataset_list
from moabb.paradigms import P300


Expand Down Expand Up @@ -147,6 +150,16 @@ def test_dataset_accept(self):
if mne.get_config("MNE_DATASETS_BBCIFNIRS_PATH") is None:
self.assertRaises(AttributeError, ds.get_data, [1])

def test_dataset_list(self):
all_datasets = len(
[
issubclass(c, BaseDataset)
for c in db.__dict__.values()
if inspect.isclass(c)
]
)
assert len(dataset_list) == all_datasets


class Test_VirtualReality_Dataset(unittest.TestCase):
def __init__(self, *args, **kwargs):
Expand Down

0 comments on commit 01e2899

Please sign in to comment.