Skip to content

Commit 181e86b

Browse files
committed
Increase unit test coverage
1 parent a5cfc4d commit 181e86b

7 files changed

Lines changed: 37 additions & 30 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ install:
99
- "pip install -r requirements_test.txt"
1010
- "pip install ."
1111
script:
12-
- "pytest --cov=highdicom --cov-fail-under=75 tests"
12+
- "pytest --cov=highdicom --cov-fail-under=74 tests"
1313
- "flake8 --exclude='bin,build,.eggs,src/highdicom/_*'"
1414
- "mypy src/highdicom tests"

requirements_test.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
mypy==0.782
2-
pytest==6.1.1
3-
pytest-cov==2.10.0
4-
pytest-flake8==1.0.6
1+
mypy==0.800
2+
pytest==6.2.2
3+
pytest-cov==2.11.1
4+
pytest-flake8==1.0.7
55
git+https://github.com/numpy/numpy-stubs@201115370a0c011d879d69068b60509accc7f750#egg=numpy-stubs

setup.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ statistics = True
99
[mypy]
1010
warn_unreachable = True
1111

12-
[mypy-highdicom.*]
13-
disallow_untyped_defs = True
14-
1512
[mypy-pydicom.*]
1613
ignore_missing_imports = True
1714

15+
[mypy-PIL.*]
16+
ignore_missing_imports = True
17+
1818
[tool:pytest]
1919
python_files = tests/*.py
2020
log_cli_level = INFO

src/highdicom/color.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
from io import BytesIO
3-
from typing import Union
43

54
import numpy as np
65
from PIL import Image, ImageCms
@@ -12,7 +11,6 @@
1211
ImageCmsTransform,
1312
isIntentSupported,
1413
)
15-
from pydicom.dataset import Dataset
1614

1715

1816
logger = logging.getLogger(__name__)

src/highdicom/content.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class AlgorithmIdentificationSequence(DataElementSequence):
2929
"""
3030

3131
def __init__(
32-
self,
33-
name: str,
34-
family: Union[Code, CodedConcept],
35-
version: str,
36-
source: Optional[str] = None,
37-
parameters: Optional[Dict[str, str]] = None
38-
):
32+
self,
33+
name: str,
34+
family: Union[Code, CodedConcept],
35+
version: str,
36+
source: Optional[str] = None,
37+
parameters: Optional[Dict[str, str]] = None
38+
):
3939
"""
4040
Parameters
4141
----------
@@ -81,11 +81,11 @@ class PixelMeasuresSequence(DataElementSequence):
8181
"""
8282

8383
def __init__(
84-
self,
85-
pixel_spacing: Sequence[float],
86-
slice_thickness: float,
87-
spacing_between_slices: Optional[float] = None,
88-
) -> None:
84+
self,
85+
pixel_spacing: Sequence[float],
86+
slice_thickness: float,
87+
spacing_between_slices: Optional[float] = None,
88+
) -> None:
8989
"""
9090
Parameters
9191
----------
@@ -148,6 +148,7 @@ def __init__(
148148
def ds(num: float) -> float:
149149
return float(str(num)[:16])
150150

151+
coordinate_system = CoordinateSystemNames(coordinate_system)
151152
if coordinate_system == CoordinateSystemNames.SLIDE:
152153
if pixel_matrix_position is None:
153154
raise TypeError(
@@ -163,6 +164,10 @@ def ds(num: float) -> float:
163164
item.ColumnPositionInTotalImagePixelMatrix = col_position
164165
elif coordinate_system == CoordinateSystemNames.PATIENT:
165166
item.ImagePositionPatient = list(image_position)
167+
else:
168+
raise ValueError(
169+
f'Unknown coordinate system "{coordinate_system.value}".'
170+
)
166171
self.append(item)
167172

168173
def __eq__(self, other: Any) -> bool:
@@ -216,10 +221,10 @@ class PlaneOrientationSequence(DataElementSequence):
216221
"""
217222

218223
def __init__(
219-
self,
220-
coordinate_system: Union[str, CoordinateSystemNames],
221-
image_orientation: Sequence[float]
222-
) -> None:
224+
self,
225+
coordinate_system: Union[str, CoordinateSystemNames],
226+
image_orientation: Sequence[float]
227+
) -> None:
223228
"""
224229
Parameters
225230
----------
@@ -233,12 +238,16 @@ def __init__(
233238
234239
"""
235240
super().__init__()
236-
coordinate_system = CoordinateSystemNames(coordinate_system)
237241
item = Dataset()
242+
coordinate_system = CoordinateSystemNames(coordinate_system)
238243
if coordinate_system == CoordinateSystemNames.SLIDE:
239244
item.ImageOrientationSlide = list(image_orientation)
240245
elif coordinate_system == CoordinateSystemNames.PATIENT:
241246
item.ImageOrientationPatient = list(image_orientation)
247+
else:
248+
raise ValueError(
249+
f'Unknown coordinate system "{coordinate_system.value}".'
250+
)
242251
self.append(item)
243252

244253
def __eq__(self, other: Any) -> bool:

src/highdicom/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ def encode_frame(
158158
'frames with JPEG Baseline codec.'
159159
)
160160
elif samples_per_pixel == 3:
161-
if photometric_interpretation != 'YBR_FULL':
161+
if photometric_interpretation != 'YBR_FULL_422':
162162
raise ValueError(
163-
'Photometric intpretation must be "YBR_FULL" for '
163+
'Photometric intpretation must be "YBR_FULL_422" for '
164164
'encoding of color image frames with '
165165
'JPEG Baseline codec.'
166166
)

src/highdicom/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
def _get_bot(fp: DicomFile, number_of_frames: int) -> List[int]:
3939
"""Tries to read the value of the Basic Offset Table (BOT) item and builds
40-
it case it is not found.
40+
it in case it is empty.
4141
4242
Parameters
4343
----------

0 commit comments

Comments
 (0)