From 80acf9e59231877666d575f8a1b26e01a037745e Mon Sep 17 00:00:00 2001 From: yukio89 Date: Tue, 20 Feb 2024 09:25:31 +0000 Subject: [PATCH] =?UTF-8?q?get=5Fbase=5Fcellcount=E3=81=AEunitcount?= =?UTF-8?q?=E3=81=AE=E7=AE=97=E5=87=BA=E6=96=B9=E6=B3=95=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/japanmesh/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/japanmesh/main.py b/src/japanmesh/main.py index b17ca1c..e659541 100644 --- a/src/japanmesh/main.py +++ b/src/japanmesh/main.py @@ -164,7 +164,10 @@ def get_mesh_vertex(x: int, x_size: float, y: int, y_size: float) -> (float, flo @lru_cache(maxsize=None) def get_base_cellcount(meshnum: int) -> (int, int, int): - unitcount = math.prod([info["ratio"] for idx, info in enumerate(MESH_INFOS) if 0 < idx <= meshnum]) + idxs = [meshnum] + while idxs[-1]!=1: + idxs.append(MESH_INFOS[idxs[-1]]["parent"]) + unitcount = math.prod([MESH_INFOS[i]["ratio"] for i in idxs]) if not MINIMUM_LON.is_integer(): raise Exception(f'Unexpected MINIMUM_LON: {MINIMUM_LON}')