Skip to content

Commit

Permalink
Improve exceptions (#181)
Browse files Browse the repository at this point in the history
* Improve exception text
  • Loading branch information
jonasteuwen authored Oct 17, 2023
1 parent e235cbd commit 374c302
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .dev/bump_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def citation_regex(new_date, content):


readme_regexes = {
"bibtex_year": lambda year, content: re.sub(r"\{\d{4}\}", str(year), content), # {2023} in bibtex
"bibtex_month": lambda month, content: re.sub(r"\{\d{1,2}\}", str(month), content), # {5} or {12} in bibtex
"bibtex_year": lambda year, content: re.sub(r"\{\d{4}\}", f"{{{year}}}", content), # {2023} in bibtex
"bibtex_month": lambda month, content: re.sub(r"\{\d{1,2}\}", f"{{{month}}}", content), # {5} or {12} in bibtex
"plain_bib_year": lambda year, content: re.sub(r"(\d{4})", str(year), content), # (2023) in the plain bibliography
}

Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ authors:
given-names: "Eric"
orchid: "https://orcid.org/0000-0002-3375-6248"
title: "DLUP: Deep Learning Utilities for Pathology"
version: 0.3.30
date-released: 2023-10-13
version: 0.3.31
date-released: 2023-10-17
url: "https://github.com/nki-ai/dlup"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ If you use DLUP in your own research, please use the following BiBTeX entry:
month = {10},
title = {{DLUP: Deep Learning Utilities for Pathology}},
url = {https://github.com/nki-ai/dlup},
version = {0.3.30},
version = {0.3.31},
year = {2023}
}
```

or the following plain bibliography:

```
Teuwen, J., Romor, L., Pai, A., Schirris, Y., Marcus E. (2023). DLUP: Deep Learning Utilities for Pathology (Version 0.3.30) [Computer software]. https://github.com/nki-ai/dlup
Teuwen, J., Romor, L., Pai, A., Schirris, Y., Marcus E. (2023). DLUP: Deep Learning Utilities for Pathology (Version 0.3.31) [Computer software]. https://github.com/nki-ai/dlup
```
2 changes: 1 addition & 1 deletion dlup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

__author__ = """dlup contributors"""
__email__ = "[email protected]"
__version__ = "0.3.30"
__version__ = "0.3.31"

__all__ = ("SlideImage", "RegionView", "UnsupportedSlideError", "BoundaryMode")
7 changes: 5 additions & 2 deletions dlup/_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,13 @@ def read_region(
level_size = np.array(self.get_scaled_size(scaling))

if (size < 0).any():
raise ValueError("Size values must be greater than zero.")
raise ValueError(f"Size values must be greater than zero. Got {size}")

if ((location < 0) | ((location + size) > level_size)).any():
raise ValueError("Requested region is outside level boundaries.")
raise ValueError(
f"Requested region is outside level boundaries. "
f"{location.tolist()} + {size.tolist()} (={(location + size).tolist()}) > {level_size.tolist()}."
)

native_level = owsi.get_best_level_for_downsample(1 / scaling)
native_level_size = owsi.level_dimensions[native_level]
Expand Down
2 changes: 1 addition & 1 deletion dlup/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def index_to_dataset(self, idx: int) -> tuple[Dataset[T_co], int]:
"""
if idx < 0:
if -idx > len(self):
raise ValueError("absolute value of index should not exceed dataset length")
raise ValueError("Absolute value of index should not exceed dataset length")
idx = len(self) + idx
dataset_idx = bisect.bisect_right(self.cumulative_sizes, idx)
sample_idx = idx if dataset_idx == 0 else idx - self.cumulative_sizes[dataset_idx - 1]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.3.30
current_version = 0.3.31
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down

0 comments on commit 374c302

Please sign in to comment.