Skip to content

Commit

Permalink
MAINT: Turn of lir for now on Windows machines - trouble with numba
Browse files Browse the repository at this point in the history
  • Loading branch information
jwboth committed Dec 3, 2024
1 parent 41f0584 commit 61c560b
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/darsia/image/coordinatetransformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
from __future__ import annotations

import copy

# Check if on a windows machine
import platform
from typing import Union

import largestinteriorrectangle as lir
if platform.system() == "Windows":
lir = None
else:
import largestinteriorrectangle as lir

import numpy as np

import darsia
Expand Down Expand Up @@ -143,12 +150,17 @@ def find_intersection(self) -> tuple[slice, slice]:
# Determine the largest interior rectangle - require to transform to format
# expected by lir
if self.dim == 2:
lir_dst = lir.lir(np.array([active_corner_voxels_dst]).astype(np.int32))
rectangle_mask_corners = [lir.pt1(lir_dst), lir.pt2(lir_dst)]
return (
slice(rectangle_mask_corners[0][0], rectangle_mask_corners[1][0]),
slice(rectangle_mask_corners[0][1], rectangle_mask_corners[1][1]),
)
if lir is None:
raise ImportError(
"Python package largestinteriorrectangle not installed."
)
else:
lir_dst = lir.lir(np.array([active_corner_voxels_dst]).astype(np.int32))
rectangle_mask_corners = [lir.pt1(lir_dst), lir.pt2(lir_dst)]
return (
slice(rectangle_mask_corners[0][0], rectangle_mask_corners[1][0]),
slice(rectangle_mask_corners[0][1], rectangle_mask_corners[1][1]),
)
elif self.dim == 3:
# NOTE: In 3d, not the largest interior but smallest exterior rectangle is
# returned, which is not ideal, but is easier to access. The application of
Expand Down

0 comments on commit 61c560b

Please sign in to comment.