Skip to content

Commit

Permalink
feat(#59): test_cluster for kmeans
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Sep 20, 2024
1 parent 3cb28d8 commit a0d3c7e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ sr-detector = { path = "./sr-detector" }
nltk = "^3.9.1"
scikit-learn = "^1.5.1"
cohere = "^5.9.1"
loguru = "^0.7.2"

[tool.poetry.group.dev.dependencies]
pytest = "^8.2.2"
Expand Down
45 changes: 45 additions & 0 deletions sr-data/src/tests/test_cluster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
Test case for cluster step.
"""
# The MIT License (MIT)
#
# Copyright (c) 2024 Aliaksei Bialiauski
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import os
import shutil
import unittest
from sr_data.steps.cluster import kmeans


class TestCluster(unittest.TestCase):

def test_clusters_kmeans_numerical(self):
kmeans(
os.path.join(
os.path.dirname(os.path.realpath(__file__)), "to-cluster.csv"
),
"kmeans"
)
expected = "kmeans/to-cluster/clusters"
self.assertTrue(
os.path.exists(expected),
f"Path {expected} does not exists"
)
shutil.rmtree("kmeans")
9 changes: 9 additions & 0 deletions sr-data/src/tests/to-cluster.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repo,score
jeff/foo,112.5
jeff/testing,112.5
jeff/some,112.5
jeff/dummy,112.5
jeff/bar2,112.5
jeff/test1,112.5
jeff/test,112.5
jeff/bar,112.5

0 comments on commit a0d3c7e

Please sign in to comment.