Skip to content

Commit

Permalink
Merge pull request #1271 from openml/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
PGijsbers authored Aug 2, 2023
2 parents d26a911 + 4b0ec45 commit 1d7fbda
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
args: [--line-length=100]
Expand Down Expand Up @@ -28,7 +28,7 @@ repos:
args: [ --disallow-untyped-defs, --disallow-any-generics,
--disallow-any-explicit, --implicit-optional ]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
name: flake8 openml
Expand Down
10 changes: 6 additions & 4 deletions openml/datasets/data_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class OpenMLDataFeature(object):
nominal_values : list(str)
list of the possible values, in case of nominal attribute
number_missing_values : int
Number of rows that have a missing value for this feature.
"""

LEGAL_DATA_TYPES = ["nominal", "numeric", "string", "date"]
Expand All @@ -30,8 +31,8 @@ def __init__(
nominal_values: List[str],
number_missing_values: int,
):
if type(index) != int:
raise ValueError("Index is of wrong datatype")
if not isinstance(index, int):
raise TypeError(f"Index must be `int` but is {type(index)}")
if data_type not in self.LEGAL_DATA_TYPES:
raise ValueError(
"data type should be in %s, found: %s" % (str(self.LEGAL_DATA_TYPES), data_type)
Expand All @@ -50,8 +51,9 @@ def __init__(
else:
if nominal_values is not None:
raise TypeError("Argument `nominal_values` must be None for non-nominal feature.")
if type(number_missing_values) != int:
raise ValueError("number_missing_values is of wrong datatype")
if not isinstance(number_missing_values, int):
msg = f"number_missing_values must be int but is {type(number_missing_values)}"
raise TypeError(msg)

self.index = index
self.name = str(name)
Expand Down
4 changes: 3 additions & 1 deletion openml/datasets/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ def __list_datasets(api_call, output_format="dict"):
datasets_dict = xmltodict.parse(xml_string, force_list=("oml:dataset",))

# Minimalistic check if the XML is useful
assert type(datasets_dict["oml:data"]["oml:dataset"]) == list, type(datasets_dict["oml:data"])
assert isinstance(datasets_dict["oml:data"]["oml:dataset"], list), type(
datasets_dict["oml:data"]
)
assert datasets_dict["oml:data"]["@xmlns:oml"] == "http://openml.org/openml", datasets_dict[
"oml:data"
]["@xmlns:oml"]
Expand Down
2 changes: 1 addition & 1 deletion openml/evaluations/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __list_evaluations(api_call, output_format="object"):
"Error in return XML, does not contain " '"oml:evaluations": %s' % str(evals_dict)
)

assert type(evals_dict["oml:evaluations"]["oml:evaluation"]) == list, type(
assert isinstance(evals_dict["oml:evaluations"]["oml:evaluation"], list), type(
evals_dict["oml:evaluations"]
)

Expand Down
2 changes: 1 addition & 1 deletion openml/flows/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def __list_flows(api_call: str, output_format: str = "dict") -> Union[Dict, pd.D
flows_dict = xmltodict.parse(xml_string, force_list=("oml:flow",))

# Minimalistic check if the XML is useful
assert type(flows_dict["oml:flows"]["oml:flow"]) == list, type(flows_dict["oml:flows"])
assert isinstance(flows_dict["oml:flows"]["oml:flow"], list), type(flows_dict["oml:flows"])
assert flows_dict["oml:flows"]["@xmlns:oml"] == "http://openml.org/openml", flows_dict[
"oml:flows"
]["@xmlns:oml"]
Expand Down
2 changes: 1 addition & 1 deletion openml/runs/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ def __list_runs(api_call, output_format="dict"):
'"http://openml.org/openml": %s' % str(runs_dict)
)

assert type(runs_dict["oml:runs"]["oml:run"]) == list, type(runs_dict["oml:runs"])
assert isinstance(runs_dict["oml:runs"]["oml:run"], list), type(runs_dict["oml:runs"])

runs = OrderedDict()
for run_ in runs_dict["oml:runs"]["oml:run"]:
Expand Down
2 changes: 1 addition & 1 deletion openml/setups/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def __list_setups(api_call, output_format="object"):
'"%s": %s' % (openml_uri, str(setups_dict))
)

assert type(setups_dict["oml:setups"]["oml:setup"]) == list, type(setups_dict["oml:setups"])
assert isinstance(setups_dict["oml:setups"]["oml:setup"], list), type(setups_dict["oml:setups"])

setups = dict()
for setup_ in setups_dict["oml:setups"]["oml:setup"]:
Expand Down
2 changes: 1 addition & 1 deletion openml/study/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def __list_studies(api_call, output_format="object") -> Union[Dict, pd.DataFrame
study_dict = xmltodict.parse(xml_string, force_list=("oml:study",))

# Minimalistic check if the XML is useful
assert type(study_dict["oml:study_list"]["oml:study"]) == list, type(
assert isinstance(study_dict["oml:study_list"]["oml:study"], list), type(
study_dict["oml:study_list"]
)
assert study_dict["oml:study_list"]["@xmlns:oml"] == "http://openml.org/openml", study_dict[
Expand Down
2 changes: 1 addition & 1 deletion openml/tasks/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def __list_tasks(api_call, output_format="dict"):
'"http://openml.org/openml": %s' % str(tasks_dict)
)

assert type(tasks_dict["oml:tasks"]["oml:task"]) == list, type(tasks_dict["oml:tasks"])
assert isinstance(tasks_dict["oml:tasks"]["oml:task"], list), type(tasks_dict["oml:tasks"])

tasks = dict()
procs = _get_estimation_procedure_list()
Expand Down
2 changes: 1 addition & 1 deletion openml/tasks/split.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, name, description, split):

def __eq__(self, other):
if (
type(self) != type(other)
(not isinstance(self, type(other)))
or self.name != other.name
or self.description != other.description
or self.split.keys() != other.split.keys()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_runs/test_run_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _assert_predictions_equal(self, predictions, predictions_prime):
for col_idx in compare_slice:
val_1 = predictions["data"][idx][col_idx]
val_2 = predictions_prime["data"][idx][col_idx]
if type(val_1) == float or type(val_2) == float:
if isinstance(val_1, float) or isinstance(val_2, float):
self.assertAlmostEqual(
float(val_1),
float(val_2),
Expand Down

0 comments on commit 1d7fbda

Please sign in to comment.