-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature clusterer import method (#76)
* Add `import_clusterer` method * Add test for new clusterer import * Add docstring * Fix "if main" of test file * Addition to gitignore
- Loading branch information
Showing
4 changed files
with
102 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ vgcore.* | |
*file2.csv | ||
*_output.csv | ||
*_passed.py | ||
*test_sissa_import.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
''' | ||
Test the import of a clusterer from csv file | ||
''' | ||
|
||
from check_result import check_result | ||
import os | ||
import sys | ||
import pandas as pd | ||
import pytest | ||
sys.path.insert(1, '../CLUEstering/') | ||
import CLUEstering as clue | ||
|
||
@pytest.fixture | ||
def sissa(): | ||
''' | ||
Returns the dataframe containing the sissa dataset | ||
''' | ||
return pd.read_csv("./test_datasets/sissa.csv") | ||
|
||
def test_clusterer_import(sissa): | ||
''' | ||
Try importing a clusterer from csv file and check that it's equal to the original clusterer | ||
''' | ||
# Check if the output file already exists and if it does, delete it | ||
if os.path.isfile('./test_sissa_import.csv'): | ||
os.remove('./test_sissa_import.csv') | ||
|
||
c = clue.clusterer(20., 10., 20.) | ||
c.read_data(sissa) | ||
c.run_clue() | ||
c.to_csv('./', 'test_sissa_import.csv') | ||
|
||
d = clue.clusterer(20., 10., 20.) | ||
d.import_clusterer('./', 'test_sissa_import.csv') | ||
|
||
assert c.clust_prop == d.clust_prop | ||
|
||
if __name__ == "__main__": | ||
c = clue.clusterer(20., 10., 20.) | ||
c.read_data("./test_datasets/sissa.csv") | ||
c.run_clue() | ||
c.cluster_plotter() | ||
c.to_csv('./', 'test_sissa_import.csv') | ||
|
||
d = clue.clusterer(20., 10., 20.) | ||
d.import_clusterer('./', 'test_sissa_import.csv') | ||
d.cluster_plotter() |