Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmj3197 committed Jun 4, 2024
1 parent d997da4 commit d3589e0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
48 changes: 33 additions & 15 deletions tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,42 @@ def test_scaled(self):
)

def test_desc(self):
descr, _ = load_wireless_data(desc=True)
self.assertTrue(isinstance(descr, str))
descr1, _ = load_wireless_data(desc=True)
self.assertTrue(isinstance(descr1, str))
descr2, _ = load_wisconsin_breast_cancer_data(desc=True)
self.assertTrue(isinstance(descr2, str))
descr3, _ = load_wine_data(desc=True)
self.assertTrue(isinstance(descr3, str))

def test_scaled_as_numpy(self):
X, y = load_wireless_data(scaled=True, return_X_y=True)
self.assertEqual(X.shape[0], 2000)
self.assertEqual(y.shape[0], 2000)
self.assertTrue(isinstance(X, np.ndarray))
self.assertTrue(isinstance(y, np.ndarray))
X1, y1 = load_wireless_data(scaled=True, return_X_y=True)
X2, y2 = load_wisconsin_breast_cancer_data(scaled=True, return_X_y=True)
X3, y3 = load_wine_data(scaled=True, return_X_y=True)
self.assertTrue(isinstance(X1, np.ndarray))
self.assertTrue(isinstance(y1, np.ndarray))
self.assertTrue(isinstance(X2, np.ndarray))
self.assertTrue(isinstance(y2, np.ndarray))
self.assertTrue(isinstance(X3, np.ndarray))
self.assertTrue(isinstance(y3, np.ndarray))

def test_desc_with_Xy(self):
descr, X, y = load_wireless_data(desc=True, return_X_y=True)
self.assertEqual(X.shape[0], 2000)
self.assertEqual(y.shape[0], 2000)
self.assertTrue(isinstance(descr, str))
descr1, X1, y1 = load_wireless_data(desc=True, return_X_y=True)
descr2, X2, y2 = load_wisconsin_breast_cancer_data(desc=True, return_X_y=True)
descr3, X3, y3 = load_wine_data(desc=True, return_X_y=True)
self.assertTrue(isinstance(descr1, str))
self.assertTrue(isinstance(descr2, str))
self.assertTrue(isinstance(descr3, str))
self.assertTrue(isinstance(X1, np.ndarray))
self.assertTrue(isinstance(y1, np.ndarray))
self.assertTrue(isinstance(X2, np.ndarray))
self.assertTrue(isinstance(y2, np.ndarray))
self.assertTrue(isinstance(X3, np.ndarray))
self.assertTrue(isinstance(y3, np.ndarray))

def test_as_numpy(self):
df = load_wireless_data(as_dataframe=False)
self.assertEqual(df.shape[0], 2000)
self.assertEqual(df.shape[1], 8)
self.assertTrue(isinstance(df, np.ndarray))
df1 = load_wireless_data(as_dataframe=False)
df2 = load_wisconsin_breast_cancer_data(as_dataframe=False)
df3 = load_wine_data(as_dataframe=False)
self.assertTrue(isinstance(df1, np.ndarray))
self.assertTrue(isinstance(df2, np.ndarray))
self.assertTrue(isinstance(df3, np.ndarray))
4 changes: 4 additions & 0 deletions tests/test_pkbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import unittest
import numpy as np
import pandas as pd
import plotly.graph_objects as go
from QuadratiK.spherical_clustering import PKBC, PKBD


Expand Down Expand Up @@ -65,6 +66,9 @@ def test_pkbc(self):
pkbd_cluster_fit_numpy_membership.validation(y_true=y_true), tuple
)

self.assertIsInstance(pkbd_cluster_fit_numpy.plot(3), type(go.Figure()))
self.assertIsInstance(pkbd_cluster_fit_numpy.summary(), str)

with self.assertRaises(Exception):
PKBC(num_clust=-1).fit(pd.DataFrame(data))

Expand Down

0 comments on commit d3589e0

Please sign in to comment.