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 unused imports #35

Merged
merged 2 commits into from
Aug 3, 2023
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
1 change: 0 additions & 1 deletion examples/ag_news.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
from sklearn.metrics import classification_report
from sklearn.utils import shuffle
from torchtext.datasets import AG_NEWS

from npc_gzip.compressors.base import BaseCompressor
Expand Down
1 change: 0 additions & 1 deletion examples/imdb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
from sklearn.metrics import classification_report
from sklearn.utils import shuffle
from torchtext.datasets import IMDB

from npc_gzip.compressors.base import BaseCompressor
Expand Down
2 changes: 0 additions & 2 deletions npc_gzip/aggregations.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import itertools

import numpy as np


def concatenate_with_space(stringa: str, stringb: str) -> str:
"""
Expand Down
2 changes: 1 addition & 1 deletion npc_gzip/distance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Sequence, Union
from typing import Sequence

import numpy as np

Expand Down
10 changes: 5 additions & 5 deletions npc_gzip/knn_classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Sequence, Union
from typing import Optional, Sequence

import numpy as np
from tqdm import tqdm
Expand Down Expand Up @@ -86,10 +86,10 @@ def __init__(
assert (
self.training_inputs.shape == self.training_labels.shape
), f"""
Training Inputs and Labels did not maintain their
Training Inputs and Labels did not maintain their
shape during the conversion from lists to numpy arrays.
This is most likely a bug in the numpy package:

self.training_inputs.shape: {self.training_inputs.shape}
self.training_labels.shape: {self.training_labels.shape}
"""
Expand Down Expand Up @@ -309,9 +309,9 @@ def predict(
assert (
top_k <= x.shape[0]
), f"""
top_k ({top_k}) must be less or equal to than the number of
top_k ({top_k}) must be less or equal to than the number of
samples provided to be predicted on ({x.shape[0]})

"""

# sample training inputs and labels
Expand Down
6 changes: 2 additions & 4 deletions npc_gzip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
import random
import string

from npc_gzip.exceptions import InvalidObjectTypeException


def generate_sentence(number_of_words: int = 10) -> str:
"""
Generates a sentence of random
numbers and letters, with
`number_of_words` words in the
numbers and letters, with
`number_of_words` words in the
sentence such that len(out.split()) \
== `number_of_words`.

Expand Down
4 changes: 1 addition & 3 deletions original_codebase/data.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import csv
import os
import random
from collections import OrderedDict, defaultdict
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union

import numpy as np
import torch
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
from torch.utils.data import DataLoader, Subset


def _load_csv_filepath(csv_filepath: str) -> list:
Expand Down
11 changes: 1 addition & 10 deletions original_codebase/experiments.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
# Experiment framework
import operator
import os
import pickle
import random
import statistics
from collections import Counter, defaultdict
from copy import deepcopy
from functools import partial
from itertools import repeat
from statistics import mode
from collections import defaultdict
from typing import Any, Callable, Optional

import numpy as np
import torch
from compressors import DefaultCompressor
from sklearn.metrics.cluster import adjusted_rand_score, normalized_mutual_info_score
from tqdm import tqdm


Expand Down
3 changes: 0 additions & 3 deletions tests/test_aggregations.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import pytest

from npc_gzip.aggregations import aggregate_strings, concatenate_with_space
from npc_gzip.exceptions import StringTooShortException


class TestAggregations:
Expand Down
1 change: 0 additions & 1 deletion tests/test_base_compressor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import gzip
from types import ModuleType

import pytest

Expand Down
4 changes: 0 additions & 4 deletions tests/test_bz2_compressor.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import bz2
from types import ModuleType

import pytest

from npc_gzip.compressors.base import BaseCompressor
from npc_gzip.compressors.bz2_compressor import Bz2Compressor
from npc_gzip.exceptions import InvalidCompressorException


class TestBz2Compressor:
Expand Down
4 changes: 0 additions & 4 deletions tests/test_gzip_compressor.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import gzip
from types import ModuleType

import pytest

from npc_gzip.compressors.base import BaseCompressor
from npc_gzip.compressors.gzip_compressor import GZipCompressor
from npc_gzip.exceptions import InvalidCompressorException


class TestBz2Compressor:
Expand Down
2 changes: 0 additions & 2 deletions tests/test_knn_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from npc_gzip.compressors.bz2_compressor import Bz2Compressor
from npc_gzip.compressors.gzip_compressor import GZipCompressor
from npc_gzip.compressors.lzma_compressor import LzmaCompressor
from npc_gzip.distance import Distance
from npc_gzip.exceptions import (
InputLabelEqualLengthException,
InvalidObjectTypeException,
UnsupportedDistanceMetricException,
)
from npc_gzip.knn_classifier import KnnClassifier
Expand Down
4 changes: 0 additions & 4 deletions tests/test_lzma_compressor.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import lzma
from types import ModuleType

import pytest

from npc_gzip.compressors.base import BaseCompressor
from npc_gzip.compressors.lzma_compressor import LzmaCompressor
from npc_gzip.exceptions import InvalidCompressorException


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

import pytest

from npc_gzip.exceptions import InvalidObjectTypeException
from npc_gzip.utils import generate_dataset, generate_sentence


Expand Down