Skip to content

Commit 09acc1e

Browse files
committed
ci: enable tests using Github actions
1 parent a87c400 commit 09acc1e

8 files changed

Lines changed: 42 additions & 6 deletions

File tree

.github/workflows/test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest]
13+
python: [3.7, 3.8, 3.9]
14+
runs-on: ${{ matrix.os }}
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up Python ${{ matrix.python }}
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: ${{ matrix.python }}
22+
- uses: actions/cache@v3
23+
with:
24+
path: ~/.cache/pip
25+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-test.txt') }}
26+
restore-keys: |
27+
${{ runner.os }}-pip-
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -e .
32+
pip install -r requirements-test.txt
33+
- name: Test with pytest
34+
run: |
35+
pytest tests/

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ jupyter_client>=5.2.3
44
ipykernel>=5.1.3
55
pre-commit>=2.9.0
66
matplotlib
7+
pandas
File renamed without changes.

tests/testgpu.py renamed to tests/test_gpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from histogrammar.primitives.sum import Sum
3737
from histogrammar.util import xrange, named
3838
from histogrammar import util
39-
from tests.testnumpy import makeSamples
39+
from tests.test_numpy import makeSamples
4040

4141
tolerance = 1e-5
4242
util.relativeTolerance = tolerance
File renamed without changes.

tests/test_pandas_histogrammar.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_make_histograms_no_time_axis():
9797
assert time_axis == ""
9898
assert "date" in hists
9999
h = hists["date"]
100-
assert h.binWidth == 751582381944448.0
100+
assert h.binWidth == pytest.approx(751582381944448.0)
101101
for cols in features:
102102
cols = cols.split(":")
103103
assert len(cols) == 1
@@ -122,23 +122,23 @@ def test_make_histograms_with_time_axis():
122122
assert time_axis == "date"
123123
assert "date:age" in hists
124124
h = hists["date:age"]
125-
assert h.binWidth == 751582381944448.0
125+
assert h.binWidth == pytest.approx(751582381944448.0)
126126
for cols in features:
127127
cols = cols.split(":")
128128
assert len(cols) == 2 and cols[0] == "date"
129129
for f, bs in bin_specs.items():
130130
assert len(bs) == 2
131131
assert "date:age" in bin_specs
132132
dateage = bin_specs["date:age"]
133-
assert dateage[0]["binWidth"] == 751582381944448.0
133+
assert dateage[0]["binWidth"] == pytest.approx(751582381944448.0)
134134
assert dateage[1]["binWidth"] == 2.0
135135
assert dateage[1]["origin"] == 9.5
136136

137137
# test get_bin_specs 1
138138
bin_specs = get_bin_specs(hists)
139139
assert "date:age" in bin_specs
140140
dateage = bin_specs["date:age"]
141-
assert dateage[0]["binWidth"] == 751582381944448.0
141+
assert dateage[0]["binWidth"] == pytest.approx(751582381944448.0)
142142
assert dateage[1]["binWidth"] == 2.0
143143
assert dateage[1]["origin"] == 9.5
144144

@@ -151,7 +151,7 @@ def test_make_histograms_with_time_axis():
151151

152152
# test get_bin_specs 3
153153
bin_specs = get_bin_specs(hists["date:age"])
154-
assert bin_specs[0]["binWidth"] == 751582381944448.0
154+
assert bin_specs[0]["binWidth"] == pytest.approx(751582381944448.0)
155155
assert bin_specs[1]["binWidth"] == 2.0
156156
assert bin_specs[1]["origin"] == 9.5
157157

File renamed without changes.

0 commit comments

Comments
 (0)