Skip to content

Commit

Permalink
reconfigure paths for tests outside of package
Browse files Browse the repository at this point in the history
  • Loading branch information
crvernon committed Dec 19, 2023
1 parent 7fa1a21 commit b30586e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ include DISCLAIMER
include notebooks/*.*
include data/tas-data/README.md
include data/temp-data/README.md
include tests/*.csv
Empty file removed tests/__init__.py
Empty file.
9 changes: 2 additions & 7 deletions tests/test_fx_recipe.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import unittest
from importlib import resources

import pandas as pd

from stitches.fx_match import match_neighborhood
from stitches.fx_recipe import (
get_num_perms,
make_recipe,
permute_stitching_recipes,
remove_duplicates,
)
Expand Down Expand Up @@ -465,9 +463,6 @@ class TestRecipe(unittest.TestCase):
}
)

# ###################################################
# tests
# ###################################################

def test_get_num_perms(self):
"""
Expand All @@ -477,10 +472,10 @@ def test_get_num_perms(self):
and that the list contains the expected columns.
"""
# Read in the match test data.
path = resources.files("stitches") / "tests" / "test-match_w_dup.csv"
path = "test-match_w_dup.csv"
match_data = pd.read_csv(path)

"Test get_num_perms"
# Test get_num_perms
out = get_num_perms(match_data)
self.assertEqual(type(out), list)
# Throw an error if the output does not match what we would expect.
Expand Down
7 changes: 3 additions & 4 deletions tests/test_match.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
from importlib import resources

import pandas as pd

Expand All @@ -21,15 +20,15 @@ def test_match_fxns(self):
operates correctly.
"""
# Read in some made up target data.
path = resources.files("stitches") / "tests" / "test-target_dat.csv"
path = "test-target_dat.csv"
data = pd.read_csv(path)

# Start by checking on a self test & without the drop hist constraint.
self_match = match_neighborhood(data, data, tol=0)
self.assertEqual(data.shape[0], self_match.shape[0])

# Now try matching with the test archive
path = resources.files("stitches") / "tests" / "test-archive_dat.csv"
path = "test-archive_dat.csv"
archive = pd.read_csv(path)
match1 = match_neighborhood(data, archive, tol=0)
# We know this must be true because the test archive contains duplicates of the
Expand Down Expand Up @@ -60,7 +59,7 @@ def test_match_fxns(self):

"Test drop_hist_false_duplicates"
# Read in the match test data.
path = resources.files("stitches") / "tests" / "test-match_w_dup.csv"
path = "test-match_w_dup.csv"
match_data = pd.read_csv(path)
cleaned = drop_hist_false_duplicates(match_data)
self.assertTrue(nrow(match_data) > nrow(cleaned))
Expand Down
6 changes: 2 additions & 4 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import unittest
from importlib import resources

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -81,12 +80,11 @@ def test_file_fxns(self):
"""

# Make sure that all of the files returned by the list_files function are all true.
test_dir = resources.files("stitches") / "tests"
test_dir = "."
out = list_files(test_dir)
self.assertTrue(all(list(map(os.path.exists, out))))

# Make sure that we can load a csv data file
self.assertTrue(type(load_data_files("tests")) == pd.core.frame.DataFrame)
# test failure
with self.assertRaises(TypeError):
load_data_files("fake")

Expand Down

0 comments on commit b30586e

Please sign in to comment.