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

Remove local functionalities implemted in Orange #1031

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 1 addition & 5 deletions orangecontrib/text/corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def _rename_features(additional_names: List) -> Tuple[List, List, List]:
self.metas.copy(),
self.W.copy(),
text_features=copy(self.text_features),
attributes=self.attributes,
)
c.name = self.name # keep corpus's name
Corpus.retain_preprocessing(self, c)
Expand Down Expand Up @@ -544,8 +545,6 @@ def from_table(cls, domain, source, row_indices=...):
c = super().from_table(domain, source, row_indices)
c._setup_corpus()
Corpus.retain_preprocessing(source, c, row_indices)
# temp fix: remove when oldest Orange >= 3.34
c.attributes = deepcopy(c.attributes)
return c

@classmethod
Expand Down Expand Up @@ -587,8 +586,6 @@ def from_table_rows(cls, source, row_indices):
if hasattr(source, "_titles"):
# covering case when from_table_rows called by from_table
c._titles = source._titles[row_indices]
# temp fix: remove when oldest Orange >= 3.34
c.attributes = deepcopy(c.attributes)
return c

@classmethod
Expand Down Expand Up @@ -647,7 +644,6 @@ def retain_preprocessing(orig, new, key=...):

new._titles = orig._titles[key]
new.ngram_range = orig.ngram_range
new.attributes = orig.attributes
new.used_preprocessor = orig.used_preprocessor
else: # orig is not Corpus
new._set_unique_titles()
Expand Down
14 changes: 0 additions & 14 deletions orangecontrib/text/tests/test_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,20 +671,6 @@ def test_language_copied(self):
self.assertEqual(new_corpus.language, "sl")
self.assertEqual(corpus.language, "en")

def test_remove_attributes_copy(self):
"""
Happy new year!

We added a deepcopy of attributes to from_table and from_table_rows
since Orange didn't copy attributes. It should be removed when oldest
supported Orange is 3.34 or higher.
When test starts to fail:
- remove it
- remove copying of attributes in from_table and from_table_rows
- update Orange version to >=3.34 if not done yet
"""
self.assertLess(datetime.today(), datetime(2024, 1, 1))

def test_language_unpickle(self):
path = os.path.dirname(__file__)
file = os.path.abspath(os.path.join(path, "data", "book-excerpts.pkl"))
Expand Down
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
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ setenv =
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: scikit-learn==1.1.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