diff --git a/.circleci/config.yml b/.circleci/config.yml index e43ad0b..08c1cd7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ orbs: # See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/python codecov: codecov/codecov@3.0.0 slack: circleci/slack@4.4.4 - python: circleci/python@1.2 + python: circleci/python@2.1.1 # Define a job to be invoked later in a workflow. @@ -66,7 +66,7 @@ jobs: # Invoke jobs via workflows # See: https://circleci.com/docs/2.0/configuration-reference/#workflows workflows: - Python-3.8: # This is the name of the workflow, feel free to change it to better match your workflow. + Python-3.10: # This is the name of the workflow, feel free to change it to better match your workflow. # Inside the workflow, you define the jobs you want to run. jobs: - build-and-test: diff --git a/src/denmune.py b/src/denmune.py index 7fc86d1..27b3a29 100644 --- a/src/denmune.py +++ b/src/denmune.py @@ -125,29 +125,32 @@ def __init__( if isinstance(train_data, pd.DataFrame): train_data = train_data.to_numpy() train_data = train_data.copy(order='C') - elif type(train_data == np.ndarray and not train_data.data.c_contiguous): + # elif type(train_data == np.ndarray) and (not train_data.data.c_contiguous): + else: train_data = train_data.copy(order='C') if train_truth is not None: if isinstance(train_truth, pd.Series): train_truth = train_truth.to_numpy() train_truth = train_truth.copy(order='C') - elif type(train_truth == np.ndarray and not train_truth.data.c_contiguous): + # elif type(train_truth == np.ndarray) and (not train_truth.data.c_contiguous): + else: train_truth = train_truth.copy(order='C') if test_data is not None: if isinstance(test_data, pd.DataFrame): test_data = test_data.to_numpy() test_data = test_data.copy(order='C') - elif type(test_data == np.ndarray and not test_data.data.c_contiguous): - print ('I am in two') + # elif type(test_data == np.ndarray) and (not test_data.data.c_contiguous): + else: test_data = test_data.copy(order='C') if test_truth is not None: if isinstance(test_truth, pd.Series): test_truth = test_truth.to_numpy() test_truth = test_truth.copy(order='C') - elif type(test_truth == np.ndarray and not test_truth.data.c_contiguous): + # elif type(test_truth == np.ndarray) and (not test_truth.data.c_contiguous): + else: test_truth = test_truth.copy(order='C') self.train_sz = len(train_data) diff --git a/src/tests/test_denmune.py b/src/tests/test_denmune.py index afd6d36..c975ceb 100644 --- a/src/tests/test_denmune.py +++ b/src/tests/test_denmune.py @@ -46,7 +46,7 @@ def test_parameters(train_data, train_truth, test_data, test_truth, validate, sh labels, validity = dm.fit_predict(validate=validate, show_plots=show_plots, show_noise=show_noise, show_analyzer=show_analyzer) # This test use data that are not perfectly separable so the # accuracy is not 1. Accuracy around 0.70 - assert ( np.mean(dm.labels_pred == y_cc) > 0.70 or (1 - np.mean( dm.labels_pred == y_cc) > 0.70) ) + assert ( np.mean(labels == y_cc) > 0.70 or (1 - np.mean( labels == y_cc) > 0.70) ) def test_DenMune_propagation(): @@ -118,6 +118,6 @@ def test_exceptions(): #raise Exception('train_data is not None and train_truth is not None and test_truth is not None and test_data is None') with pytest.raises(Exception) as execinfo: - dm = DenMune(train_data=train_data, train_truth=train_labels) # default value for k_nearest is 0 which is invalid + dm = DenMune(train_data=train_data, train_truth=train_labels, k_nearest=0) # default value for k_nearest is 1 which is valid #labels, validity = dm.fit_predict() #raise Exception('k-nearest neighbor should be at least 1')