Skip to content

Commit

Permalink
Merge pull request #6506 from ales-erjavec/remove-distutils
Browse files Browse the repository at this point in the history
Remove use of deprecated distrutils
  • Loading branch information
markotoplak committed Jul 14, 2023
2 parents d17f021 + 1ef8025 commit 92d84ee
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 28 deletions.
5 changes: 1 addition & 4 deletions Orange/canvas/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
import random
import uuid
import warnings

import os
import sys
import itertools
from distutils.version import LooseVersion

from typing import Dict, Any, Optional, Iterable, List

Expand Down Expand Up @@ -112,7 +109,7 @@ def splash_screen():

version = Config.ApplicationVersion
if version:
version_parsed = LooseVersion(version)
version_parsed = pkg_resources.parse_version(version)
version_comp = version_parsed.version
version = ".".join(map(str, version_comp[:2]))
size = 13
Expand Down
4 changes: 2 additions & 2 deletions Orange/evaluation/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
--------
>>> import Orange
>>> data = Orange.data.Table('iris')
>>> learner = Orange.classification.LogisticRegressionLearner()
>>> learner = Orange.classification.LogisticRegressionLearner(solver="liblinear")
>>> results = Orange.evaluation.TestOnTrainingData(data, [learner])
"""
Expand Down Expand Up @@ -293,7 +293,7 @@ class LogLoss(ClassificationScore):
Examples
--------
>>> Orange.evaluation.LogLoss(results)
array([ 0.3...])
array([0.3...])
"""
__wraps__ = skl_metrics.log_loss
Expand Down
4 changes: 2 additions & 2 deletions Orange/statistics/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ def bincount(x, weights=None, max_val=None, minlength=0):
values as well, even if they do not appear in the data. However, this will
not truncate the bincount if values larger than `max_count` are found.
>>> bincount([0, 0, 1, 1, 2], max_val=4)
(array([ 2., 2., 1., 0., 0.]), 0.0)
(array([2., 2., 1., 0., 0.]), 0.0)
>>> bincount([0, 1, 2, 3, 4], max_val=2)
(array([ 1., 1., 1., 1., 1.]), 0.0)
(array([1., 1., 1., 1., 1.]), 0.0)
"""
# Store the original matrix before any manipulation to check for sparse
Expand Down
18 changes: 1 addition & 17 deletions Orange/tests/test_doctest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import sys
import os
import unittest
from doctest import DocTestSuite, ELLIPSIS, NORMALIZE_WHITESPACE
from distutils.version import LooseVersion

import numpy

SKIP_DIRS = (
# Skip modules which import and initialize stuff that require QApplication
Expand Down Expand Up @@ -55,24 +51,12 @@ def clear(self):
def suite(package):
"""Assemble test suite for doctests in path (recursively)"""
from importlib import import_module
# numpy 1.14 changed array str/repr (NORMALIZE_WHITESPACE does not
# handle this). When 1.15 is released update all docstrings and skip the
# tests for < 1.14.
npversion = LooseVersion(numpy.__version__)
if npversion >= LooseVersion("1.14"):
def setUp(test):
raise unittest.SkipTest("Skip doctest on numpy >= 1.14.0")
else:
def setUp(test):
pass

for module in find_modules(package.__file__):
try:
module = import_module(module)
yield DocTestSuite(module,
globs=Context(module.__dict__.copy()),
optionflags=ELLIPSIS | NORMALIZE_WHITESPACE,
setUp=setUp)
optionflags=ELLIPSIS | NORMALIZE_WHITESPACE)
except ValueError:
pass # No doctests in module
except ImportError:
Expand Down
5 changes: 3 additions & 2 deletions Orange/widgets/evaluate/tests/test_owliftcurve.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pylint: disable=protected-access,duplicate-code
import copy
import pkg_resources
import unittest
from distutils.version import LooseVersion
from unittest.mock import Mock

import numpy as np
Expand All @@ -26,7 +26,8 @@
# scikit-learn==1.1.1 does not support read the docs, therefore
# we can not make it a requirement for now. When the minimum required
# version is >=1.1.1, delete these exceptions.
OK_SKLEARN = LooseVersion(sklearn.__version__) >= LooseVersion("1.1.1")
OK_SKLEARN = pkg_resources.parse_version(sklearn.__version__) >= \
pkg_resources.parse_version("1.1.1")
SKIP_REASON = "Only test precision-recall with scikit-learn>=1.1.1"


Expand Down
1 change: 0 additions & 1 deletion Orange/widgets/evaluate/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import unittest
import collections
from distutils.version import LooseVersion
from itertools import count
from unittest.mock import patch

Expand Down

0 comments on commit 92d84ee

Please sign in to comment.