Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and eddiebergman committed Jan 12, 2024
commit 6b10d34e4e3f46d71ca4ef0548df7b989bbcd9f0
2 changes: 1 addition & 1 deletion openml/datasets/data_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__( # noqa: PLR0913
data_type: str,
nominal_values: list[str],
number_missing_values: int,
ontologies: list[str]
ontologies: list[str],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this needs to have a default value as it is otherwise a breaking change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

while technically it would make break code, I find it unlikely that people use this constructor outside our library. In the library, I think I have updated all constructors

):
if not isinstance(index, int):
raise TypeError(f"Index must be `int` but is {type(index)}")
Expand Down
43 changes: 17 additions & 26 deletions openml/datasets/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,44 +1081,35 @@ def data_feature_add_ontology(data_id, index, ontology):
-------
True or throws an OpenML server exception
"""
upload_data = {
'data_id': data_id,
'index': index,
'ontology': ontology
}
upload_data = {"data_id": data_id, "index": index, "ontology": ontology}
openml._api_calls._perform_api_call("data/feature/ontology/add", "post", data=upload_data)
# an error will be thrown in case the request was unsuccessful
return True


def data_feature_remove_ontology(data_id, index, ontology):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add typing

"""
Removes an existing ontology (URL) to a given dataset feature (defined
by a dataset id and index). The dataset has to exists on OpenML and needs
to have been processed by the evaluation engine. Ontology needs to be
attached to the specific fearure.
Removes an existing ontology (URL) to a given dataset feature (defined
Comment thread
LennartPurucker marked this conversation as resolved.
Outdated
by a dataset id and index). The dataset has to exists on OpenML and needs
to have been processed by the evaluation engine. Ontology needs to be
attached to the specific fearure.

Parameters
----------
data_id : int
id of the dataset to which the feature belongs
Parameters
----------
data_id : int
id of the dataset to which the feature belongs

index : int
index of the feature in dataset (0-based)
index : int
index of the feature in dataset (0-based)

ontology : str
URL to ontology (max. 256 characters)
ontology : str
URL to ontology (max. 256 characters)

Returns
-------
True or throws an OpenML server exception
Returns
-------
True or throws an OpenML server exception
"""

upload_data = {
'data_id': data_id,
'index': index,
'ontology': ontology
}
upload_data = {"data_id": data_id, "index": index, "ontology": ontology}
openml._api_calls._perform_api_call("data/feature/ontology/remove", "post", data=upload_data)
# an error will be thrown in case the request was unsuccessful
return True
Expand Down