File tree Expand file tree Collapse file tree 5 files changed +23
-15
lines changed
fileformats/medimage_mrtrix3 Expand file tree Collapse file tree 5 files changed +23
-15
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
+ import typing as ty
2
3
import pytest
3
4
from pathlib import Path
4
5
@@ -22,9 +23,10 @@ def cli_parse_only():
22
23
if os .getenv ("_PYTEST_RAISE" , "0" ) != "0" :
23
24
24
25
@pytest .hookimpl (tryfirst = True )
25
- def pytest_exception_interact (call ):
26
- raise call .excinfo .value
26
+ def pytest_exception_interact (call : pytest .CallInfo [ty .Any ]) -> None :
27
+ if call .excinfo is not None :
28
+ raise call .excinfo .value
27
29
28
30
@pytest .hookimpl (tryfirst = True )
29
- def pytest_internalerror (excinfo ) :
31
+ def pytest_internalerror (excinfo : pytest . ExceptionInfo [ BaseException ]) -> None :
30
32
raise excinfo .value
Original file line number Diff line number Diff line change 2
2
import logging
3
3
from pathlib import Path
4
4
import tempfile
5
+ import typing as ty
5
6
import pytest
6
7
from fileformats .medimage import DicomDir , Nifti
7
8
24
25
if os .getenv ("_PYTEST_RAISE" , "0" ) != "0" :
25
26
26
27
@pytest .hookimpl (tryfirst = True )
27
- def pytest_exception_interact (call ):
28
- raise call .excinfo .value
28
+ def pytest_exception_interact (call : pytest .CallInfo [ty .Any ]) -> None :
29
+ if call .excinfo is not None :
30
+ raise call .excinfo .value
29
31
30
32
@pytest .hookimpl (tryfirst = True )
31
- def pytest_internalerror (excinfo ) :
33
+ def pytest_internalerror (excinfo : pytest . ExceptionInfo [ BaseException ]) -> None :
32
34
raise excinfo .value
33
35
34
36
Original file line number Diff line number Diff line change 1
- import numpy as np
1
+ import typing # noqa: F401
2
+ import numpy .typing
2
3
from fileformats .core import extra_implementation
3
4
from fileformats .medimage import DwiEncoding
5
+ from fileformats .medimage .diffusion import EncodingArrayType
4
6
from fileformats .medimage_mrtrix3 import BFile
5
7
6
8
7
9
@extra_implementation (DwiEncoding .read_array )
8
- def bfile_read_array (bfile : BFile ) -> np .ndarray :
9
- return np .asarray (
10
+ def bfile_read_array (
11
+ bfile : BFile ,
12
+ ) -> EncodingArrayType :
13
+ return numpy .asarray (
10
14
[[float (x ) for x in ln .split ()] for ln in bfile .read_contents ().splitlines ()]
11
15
)
Original file line number Diff line number Diff line change 1
1
import os
2
2
import logging
3
+ import typing as ty
3
4
from pathlib import Path
4
5
import tempfile
5
6
import pytest
23
24
if os .getenv ("_PYTEST_RAISE" , "0" ) != "0" :
24
25
25
26
@pytest .hookimpl (tryfirst = True )
26
- def pytest_exception_interact (call ):
27
- raise call .excinfo .value
27
+ def pytest_exception_interact (call : pytest .CallInfo [ty .Any ]) -> None :
28
+ if call .excinfo is not None :
29
+ raise call .excinfo .value
28
30
29
31
@pytest .hookimpl (tryfirst = True )
30
- def pytest_internalerror (excinfo ) :
32
+ def pytest_internalerror (excinfo : pytest . ExceptionInfo [ BaseException ]) -> None :
31
33
raise excinfo .value
32
34
33
35
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ class ImageDataFile(File):
91
91
92
92
@extra_implementation (FileSet .read_metadata )
93
93
def mrtrix_read_metadata (
94
- mif : BaseMrtrixImage , selected_keys : ty .Optional [ ty . Collection [ str ]] = None
94
+ mif : BaseMrtrixImage , ** kwargs : ty .Any
95
95
) -> ty .Mapping [str , ty .Any ]:
96
96
metadata = {}
97
97
with open (mif .fspath , "rb" ) as f :
@@ -127,6 +127,4 @@ def mrtrix_read_metadata(
127
127
else :
128
128
metadata [key ] = value
129
129
line = f .readline ().decode ("utf-8" )
130
- if selected_keys :
131
- metadata = {k : v for k , v in metadata .items () if k in selected_keys }
132
130
return metadata
You can’t perform that action at this time.
0 commit comments