Skip to content

Commit 8866f46

Browse files
authored
Merge pull request #37 from VIDA-NYU/setup-test-ci
Setup CI infrastructure for automated tests
2 parents 5f479e7 + 7f66dfe commit 8866f46

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed

.github/workflows/build.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.8", "3.9", "3.10", "3.11"]
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install pytest jupyter
23+
24+
- name: Install the bdikit package
25+
run: |
26+
pip install -e .
27+
28+
- name: Test with pytest
29+
run: |
30+
pytest

Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
all: test
2+
3+
PHONY: test
4+
5+
test:
6+
python3 -m pytest

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ scikit-learn
88
tabulate
99
flair
1010
requests
11+
scipy<1.13
12+
matplotlib<3.9

tests/__init__.py

Whitespace-only changes.

tests/test_column_mapping.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import unittest
2+
import pandas as pd
3+
from bdikit.mapping_algorithms.column_mapping.algorithms import (
4+
SimFloodAlgorithm,
5+
JaccardDistanceAlgorithm,
6+
DistributionBasedAlgorithm,
7+
ComaAlgorithm,
8+
CupidAlgorithm,
9+
)
10+
11+
12+
class ColumnMappingTest(unittest.TestCase):
13+
def test_basic_column_mapping_algorithms(self):
14+
for ColumnMatcher in [
15+
SimFloodAlgorithm,
16+
JaccardDistanceAlgorithm,
17+
DistributionBasedAlgorithm,
18+
ComaAlgorithm,
19+
CupidAlgorithm,
20+
]:
21+
# given
22+
table1 = pd.DataFrame(
23+
{"column_1": ["a1", "b1", "c1"], "col_2": ["a2", "b2", "c2"]}
24+
)
25+
table2 = pd.DataFrame(
26+
{"column_1a": ["a1", "b1", "c1"], "col2": ["a2", "b2", "c2"]}
27+
)
28+
column_matcher = ColumnMatcher(dataset=table1, global_table=table2)
29+
30+
# when
31+
mapping = column_matcher.map()
32+
33+
# then
34+
print(mapping)
35+
self.assertEqual(
36+
{"column_1": "column_1a", "col_2": "col2"},
37+
mapping,
38+
msg=f"{ColumnMatcher.__name__} failed to map columns",
39+
)

0 commit comments

Comments
 (0)