Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tuple as input type in parse_excel.infer_metadata() #213

Merged
merged 6 commits into from
Feb 15, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion oteapi_dlite/strategies/parse_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ 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: tuple) -> dlite.Instance:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since any sequence will work, I will suggest to state that explicitly:

Suggested change
def infer_metadata(rec: np.recarray, units: tuple) -> dlite.Instance:
def infer_metadata(rec: np.recarray, units: "Sequence") -> dlite.Instance:

This requires that we load from typing import Sequence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but this does not work together with @CasperWA's suggestion to also specify an unknown number of strings. (That results in TypeError: Parameters to generic types must be types. Got Ellipsis.). I will hence go for tuple[str, ...].

"""Infer dlite metadata from recarray `rec`."""
rnd = getrandbits(128)
uri = f"http://onto-ns.com/meta/1.0/generated_from_excel_{rnd:0x}"
Expand Down
Loading