Skip to content

Commit

Permalink
Use enum2int from Orange
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimozGodec committed Jan 12, 2024
1 parent 35c3dc8 commit 66c0155
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 43 deletions.
2 changes: 1 addition & 1 deletion orangecontrib/text/widgets/owkeywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from Orange.widgets import gui
from Orange.widgets.settings import DomainContextHandler, ContextSetting, \
Setting
from Orange.widgets.utils import enum2int
from Orange.widgets.utils.concurrent import ConcurrentWidgetMixin, TaskState
from Orange.widgets.utils.itemmodels import PyTableModel, TableModel
from Orange.widgets.widget import Input, Output, OWWidget, Msg
Expand All @@ -23,7 +24,6 @@
from orangecontrib.text.keywords import ScoringMethods, AggregationMethods, \
YAKE_LANGUAGE_MAPPING, RAKE_LANGUAGES
from orangecontrib.text.preprocess import BaseNormalizer
from orangecontrib.text.widgets.utils import enum2int
from orangecontrib.text.widgets.utils.words import create_words_table, \
WORDS_COLUMN_NAME

Expand Down
2 changes: 1 addition & 1 deletion orangecontrib/text/widgets/owscoredocuments.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from Orange.data.util import get_unique_names
from Orange.util import wrap_callback
from Orange.widgets.settings import ContextSetting, PerfectDomainContextHandler, Setting
from Orange.widgets.utils import enum2int
from Orange.widgets.utils.annotated_data import create_annotated_table, add_columns
from Orange.widgets.utils.concurrent import ConcurrentWidgetMixin, TaskState
from Orange.widgets.utils.itemmodels import PyTableModel, TableModel
Expand All @@ -36,7 +37,6 @@
from orangecontrib.text import Corpus
from orangecontrib.text.preprocess import BaseNormalizer, NGrams, BaseTokenFilter
from orangecontrib.text.vectorization.sbert import SBERT
from orangecontrib.text.widgets.utils import enum2int

from orangecontrib.text.widgets.utils.words import create_words_table

Expand Down
21 changes: 0 additions & 21 deletions orangecontrib/text/widgets/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
from enum import IntEnum, Enum
from typing import Union

from .decorators import *
from .widgets import *
from .concurrent import asynchronous


def enum2int(enum: Union[Enum, IntEnum]) -> int:
"""
PyQt5 uses IntEnum like object for settings, for example SortOrder while
PyQt6 uses Enum. PyQt5's IntEnum also does not support value attribute.
This function transform both settings objects to int.
Parameters
----------
enum
IntEnum like object or Enum object with Qt's settings
Returns
-------
Settings transformed to int
"""
return int(enum) if isinstance(enum, int) else enum.value
18 changes: 0 additions & 18 deletions orangecontrib/text/widgets/utils/tests/test_utils.py

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lemmagen3
nltk>=3.0.5 # TweetTokenizer introduced in 3.0.5
numpy
odfpy>=1.3.5
Orange3 >=3.34.0
Orange3 >=3.35.0
orange-widget-base >=4.20.0
orange-canvas-core
owlready2
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ deps =
{env:PYQT_PYPI_NAME:PyQt5}=={env:PYQT_PYPI_VERSION:5.15.*}
{env:WEBENGINE_PYPI_NAME:PyQtWebEngine}=={env:WEBENGINE_PYPI_VERSION:5.15.*}
oldest: scikit-learn==1.0.1
oldest: orange3==3.34.0
oldest: orange3==3.35.0
oldest: orange-canvas-core==0.1.30
oldest: orange-widget-base==4.20.0
oldest: pandas==1.4.0
Expand Down

0 comments on commit 66c0155

Please sign in to comment.