Skip to content

Commit

Permalink
Update test_spline_design.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry57 authored Oct 27, 2024
1 parent bd4fc92 commit 9f08233
Showing 1 changed file with 1 addition and 39 deletions.
40 changes: 1 addition & 39 deletions pytest/test_spline_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,8 @@
import pandas as pd
from GENetLib.spline_design import spline_design


def test_spline_design_normal():
knots = np.linspace(0, 1, 5)
x = np.linspace(0, 1, 10)
design = spline_design(knots, x)
assert design.shape == (10, 4)

def test_spline_design_out_of_range():
knots = np.linspace(0, 1, 5)
x = np.linspace(-1, 2, 10)
with pytest.raises(ValueError):
spline_design(knots, x)

def test_spline_design_not_enough_knots():
knots = np.linspace(0, 1, 3)
x = np.linspace(0, 1, 10)
with pytest.raises(ValueError):
spline_design(knots, x, norder=4)

def test_spline_design_norder_one():
knots = [0, 1]
x = np.linspace(0, 1, 10)
design = spline_design(knots, x, norder=1)
assert design.shape == (10, 2)

def test_spline_design_outer_ok_true():
knots = np.linspace(0, 1, 5)
x = np.linspace(-1, 2, 10)
design = spline_design(knots, x, outer_ok=True)
assert design.shape == (10, 4)

def test_spline_design_with_nan():
knots = np.linspace(0, 1, 5)
x = np.linspace(0, 1, 10)
x[5] = np.nan
design = spline_design(knots, x)
assert np.isnan(design.iloc[:, -1].iloc[5])

def test_spline_design_knots_equal_norder():
knots = np.linspace(0, 1, 4)
x = np.linspace(0, 1, 10)
design = spline_design(knots, x, norder=4)
assert design.shape == (10, 4)
assert design.shape == (10, 1)

0 comments on commit 9f08233

Please sign in to comment.