Skip to content

Commit

Permalink
FIX: Correct order
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Jan 10, 2024
1 parent 5acde10 commit 0806a1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 1 addition & 2 deletions mne/_fiff/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def fiff_open(fname, preload=False, verbose=None):
raise


# @profile
def _fiff_open(fname, fid, preload):
# do preloading of entire file
if preload:
Expand Down Expand Up @@ -315,7 +314,7 @@ def _show_tree(
for k, kn, size, pos, type_ in zip(kinds[:-1], kinds[1:], sizes, poss, types):
if not tag_found and k != tag_id:
continue
tag = Tag(k, size, 0, -1, pos)
tag = Tag(kind=k, type=type_, size=size, next=FIFF.FIFFV_NEXT_NONE, pos=pos)
if read_limit is None or size <= read_limit:
try:
tag = read_tag(fid, pos)
Expand Down
6 changes: 1 addition & 5 deletions mne/_fiff/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def _read_julian(fid, tag, shape, rlims):
_call_dict_names[key] = dtype


def read_tag(fid, pos, shape=None, rlims=None, *, advance=True):
def read_tag(fid, pos, shape=None, rlims=None):
"""Read a Tag from a file at a given position.
Parameters
Expand All @@ -441,10 +441,6 @@ def read_tag(fid, pos, shape=None, rlims=None, *, advance=True):
Note that data are assumed to be stored row-major in the file. Only to
be used with data stored as a vector (not implemented for matrices
yet).
advance : bool
If True (default), advance to next tag position after reading.
.. versionadded:: 1.7
Returns
-------
Expand Down
13 changes: 11 additions & 2 deletions mne/commands/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
mne_what,
)
from mne.datasets import testing
from mne.io import read_info, read_raw_fif
from mne.io import read_info, read_raw_fif, show_fiff
from mne.utils import (
ArgvSetter,
_record_warnings,
Expand Down Expand Up @@ -100,13 +100,22 @@ def test_compare_fiff():
check_usage(mne_compare_fiff)


def test_show_fiff():
def test_show_fiff(tmp_path):
"""Test mne compare_fiff."""
check_usage(mne_show_fiff)
with ArgvSetter((raw_fname,)):
mne_show_fiff.run()
with ArgvSetter((raw_fname, "--tag=102")):
mne_show_fiff.run()
bad_fname = tmp_path / "test_bad_raw.fif"
with open(bad_fname, "wb") as fout:
with open(raw_fname, "rb") as fin:
fout.write(fin.read(100000))
with pytest.warns(RuntimeWarning, match="Invalid tag"):
lines = show_fiff(str(bad_fname), output=list)
last_line = lines[-1]
assert ">>>>BAD" in last_line
assert "302 = FIFF_EPOCH (734412b >f4)" in last_line


@requires_mne
Expand Down

0 comments on commit 0806a1f

Please sign in to comment.