From 341b9704b47d7f1e0492eb25ef30e62b48696672 Mon Sep 17 00:00:00 2001 From: Martin Bauer <martin.bauer@fau.de> Date: Wed, 5 Dec 2018 14:39:32 +0100 Subject: [PATCH] Updated n-phase test --- utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/utils.py b/utils.py index c163954b5..6e620b5f2 100644 --- a/utils.py +++ b/utils.py @@ -5,6 +5,7 @@ from typing import Mapping from collections import Counter import sympy as sp +import numpy as np class DotDict(dict): @@ -87,6 +88,20 @@ def fully_contains(l1, l2): return True +def boolean_array_bounding_box(boolean_array): + """Returns bounding box around "true" area of boolean array""" + dim = len(boolean_array.shape) + bounds = [] + for i in range(dim): + for j in range(dim): + if i != j: + arr_1d = np.any(boolean_array, axis=j) + begin = np.argmax(arr_1d) + end = begin + np.argmin(arr_1d[begin:]) + bounds.append((begin, end)) + return bounds + + class LinearEquationSystem: """Symbolic linear system of equations - consisting of matrix and right hand side. -- GitLab