Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup CI infrastructure for automated tests #37

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest jupyter

- name: Install the bdikit package
run: |
pip install -e .

- name: Test with pytest
run: |
pytest
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
all: test

PHONY: test

test:
python3 -m pytest
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ scikit-learn
tabulate
flair
requests
scipy<1.13
matplotlib<3.9
Empty file added tests/__init__.py
Empty file.
39 changes: 39 additions & 0 deletions tests/test_column_mapping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import unittest
import pandas as pd
from bdikit.mapping_algorithms.column_mapping.algorithms import (
SimFloodAlgorithm,
JaccardDistanceAlgorithm,
DistributionBasedAlgorithm,
ComaAlgorithm,
CupidAlgorithm,
)


class ColumnMappingTest(unittest.TestCase):
def test_basic_column_mapping_algorithms(self):
for ColumnMatcher in [
SimFloodAlgorithm,
JaccardDistanceAlgorithm,
DistributionBasedAlgorithm,
ComaAlgorithm,
CupidAlgorithm,
]:
# given
table1 = pd.DataFrame(
{"column_1": ["a1", "b1", "c1"], "col_2": ["a2", "b2", "c2"]}
)
table2 = pd.DataFrame(
{"column_1a": ["a1", "b1", "c1"], "col2": ["a2", "b2", "c2"]}
)
column_matcher = ColumnMatcher(dataset=table1, global_table=table2)

# when
mapping = column_matcher.map()

# then
print(mapping)
self.assertEqual(
{"column_1": "column_1a", "col_2": "col2"},
mapping,
msg=f"{ColumnMatcher.__name__} failed to map columns",
)
Loading