From 467e9ba2433f8ae366a3274e4fcd931bde35c848 Mon Sep 17 00:00:00 2001 From: Anders Eklund <96499163+ajeklund@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:47:03 +0100 Subject: [PATCH 1/6] Add tuple as input parameter --- oteapi_dlite/strategies/parse_excel.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/oteapi_dlite/strategies/parse_excel.py b/oteapi_dlite/strategies/parse_excel.py index 3f95b534..0e9b3343 100644 --- a/oteapi_dlite/strategies/parse_excel.py +++ b/oteapi_dlite/strategies/parse_excel.py @@ -2,7 +2,7 @@ # pylint: disable=unused-argument import re from random import getrandbits -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, Union import dlite import numpy as np @@ -153,7 +153,10 @@ def split_column_name(column): return name, unit -def infer_metadata(rec: np.recarray, units: list) -> dlite.Instance: +def infer_metadata( + rec: np.recarray, + units: Union[list, tuple] +) -> dlite.Instance: """Infer dlite metadata from recarray `rec`.""" rnd = getrandbits(128) uri = f"http://onto-ns.com/meta/1.0/generated_from_excel_{rnd:0x}" From 2fa8af2dae0d55df29e3b0e977f02cabb2837f48 Mon Sep 17 00:00:00 2001 From: Anders Eklund <96499163+ajeklund@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:03:46 +0100 Subject: [PATCH 2/6] Fix formatting. --- oteapi_dlite/strategies/parse_excel.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/oteapi_dlite/strategies/parse_excel.py b/oteapi_dlite/strategies/parse_excel.py index 0e9b3343..ed068f90 100644 --- a/oteapi_dlite/strategies/parse_excel.py +++ b/oteapi_dlite/strategies/parse_excel.py @@ -154,8 +154,7 @@ def split_column_name(column): def infer_metadata( - rec: np.recarray, - units: Union[list, tuple] + rec: np.recarray, units: Union[list, tuple] ) -> dlite.Instance: """Infer dlite metadata from recarray `rec`.""" rnd = getrandbits(128) From 2006181063bc4efde190c88d7dae18b7507971cb Mon Sep 17 00:00:00 2001 From: Anders Eklund <96499163+ajeklund@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:18:43 +0100 Subject: [PATCH 3/6] Restrict to tuple. --- oteapi_dlite/strategies/parse_excel.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/oteapi_dlite/strategies/parse_excel.py b/oteapi_dlite/strategies/parse_excel.py index ed068f90..59468d4a 100644 --- a/oteapi_dlite/strategies/parse_excel.py +++ b/oteapi_dlite/strategies/parse_excel.py @@ -2,7 +2,7 @@ # pylint: disable=unused-argument import re from random import getrandbits -from typing import TYPE_CHECKING, Optional, Union +from typing import TYPE_CHECKING, Optional import dlite import numpy as np @@ -153,9 +153,7 @@ def split_column_name(column): return name, unit -def infer_metadata( - rec: np.recarray, units: Union[list, tuple] -) -> dlite.Instance: +def infer_metadata(rec: np.recarray, units: tuple) -> dlite.Instance: """Infer dlite metadata from recarray `rec`.""" rnd = getrandbits(128) uri = f"http://onto-ns.com/meta/1.0/generated_from_excel_{rnd:0x}" From bcdfe55c42d84dbaa4d437e3de160cee9226f2c1 Mon Sep 17 00:00:00 2001 From: Anders Eklund <96499163+ajeklund@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:12:52 +0100 Subject: [PATCH 4/6] Specify tuple of strings. --- oteapi_dlite/strategies/parse_excel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oteapi_dlite/strategies/parse_excel.py b/oteapi_dlite/strategies/parse_excel.py index 59468d4a..c101e269 100644 --- a/oteapi_dlite/strategies/parse_excel.py +++ b/oteapi_dlite/strategies/parse_excel.py @@ -153,7 +153,7 @@ def split_column_name(column): return name, unit -def infer_metadata(rec: np.recarray, units: tuple) -> dlite.Instance: +def infer_metadata(rec: np.recarray, units: tuple[str, ...]) -> dlite.Instance: """Infer dlite metadata from recarray `rec`.""" rnd = getrandbits(128) uri = f"http://onto-ns.com/meta/1.0/generated_from_excel_{rnd:0x}" From fa42710223888e6c63c3ffbea079275fefdfecea Mon Sep 17 00:00:00 2001 From: Anders Eklund <96499163+ajeklund@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:17:09 +0100 Subject: [PATCH 5/6] Specify Sequence of strings. --- oteapi_dlite/strategies/parse_excel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oteapi_dlite/strategies/parse_excel.py b/oteapi_dlite/strategies/parse_excel.py index c101e269..3aefe3c2 100644 --- a/oteapi_dlite/strategies/parse_excel.py +++ b/oteapi_dlite/strategies/parse_excel.py @@ -2,7 +2,7 @@ # pylint: disable=unused-argument import re from random import getrandbits -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, Sequence import dlite import numpy as np @@ -153,7 +153,7 @@ def split_column_name(column): return name, unit -def infer_metadata(rec: np.recarray, units: tuple[str, ...]) -> dlite.Instance: +def infer_metadata(rec: np.recarray, units: Sequence[str, ...]) -> dlite.Instance: """Infer dlite metadata from recarray `rec`.""" rnd = getrandbits(128) uri = f"http://onto-ns.com/meta/1.0/generated_from_excel_{rnd:0x}" From 7a697c88062ae356326d8a39bd532c00e2a9ff58 Mon Sep 17 00:00:00 2001 From: Anders Eklund <96499163+ajeklund@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:58:26 +0100 Subject: [PATCH 6/6] Specify tuple of strings. --- oteapi_dlite/strategies/parse_excel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oteapi_dlite/strategies/parse_excel.py b/oteapi_dlite/strategies/parse_excel.py index 3aefe3c2..c101e269 100644 --- a/oteapi_dlite/strategies/parse_excel.py +++ b/oteapi_dlite/strategies/parse_excel.py @@ -2,7 +2,7 @@ # pylint: disable=unused-argument import re from random import getrandbits -from typing import TYPE_CHECKING, Optional, Sequence +from typing import TYPE_CHECKING, Optional import dlite import numpy as np @@ -153,7 +153,7 @@ def split_column_name(column): return name, unit -def infer_metadata(rec: np.recarray, units: Sequence[str, ...]) -> dlite.Instance: +def infer_metadata(rec: np.recarray, units: tuple[str, ...]) -> dlite.Instance: """Infer dlite metadata from recarray `rec`.""" rnd = getrandbits(128) uri = f"http://onto-ns.com/meta/1.0/generated_from_excel_{rnd:0x}"