# Path: geomdl/helpers.py
# def find_span_binsearch(degree, knot_vector, num_ctrlpts, knot, **kwargs):
# def find_span_linear(degree, knot_vector, num_ctrlpts, knot, **kwargs):
# def find_spans(degree, knot_vector, num_ctrlpts, knots, func=find_span_linear):
# def find_multiplicity(knot, knot_vector, **kwargs):
# def basis_function(degree, knot_vector, span, knot):
# def basis_function_one(degree, knot_vector, span, knot):
# def basis_functions(degree, knot_vector, spans, knots):
# def basis_function_all(degree, knot_vector, span, knot):
# def basis_function_ders(degree, knot_vector, span, knot, order):
# def basis_function_ders_one(degree, knot_vector, span, knot, order):
# def basis_functions_ders(degree, knot_vector, spans, knots, order):
# def knot_insertion(degree, knotvector, ctrlpts, u, **kwargs):
# def knot_insertion_alpha(u, knotvector, span, idx, leg):
# def knot_insertion_kv(knotvector, u, span, r):
# def knot_removal(degree, knotvector, ctrlpts, u, **kwargs):
# def knot_removal_alpha_i(u, degree, knotvector, num, idx):
# def knot_removal_alpha_j(u, degree, knotvector, num, idx):
# def knot_removal_kv(knotvector, span, r):
# def knot_refinement(degree, knotvector, ctrlpts, **kwargs):
# def degree_elevation(degree, ctrlpts, **kwargs):
# def degree_reduction(degree, ctrlpts, **kwargs):
# def curve_deriv_cpts(dim, degree, kv, cpts, rs, deriv_order=0):
# def surface_deriv_cpts(dim, degree, kv, cpts, cpsize, rs, ss, deriv_order=0):
#     N = [1.0 for _ in range(degree + 1)]  # N[0] = 1.0 by definition
#     N = [0.0 for _ in range(degree + span + 1)]
#     N = [[None for _ in range(degree + 1)] for _ in range(degree + 1)]
#     N = [[0.0 for _ in range(0, degree + 1)] for _ in range(0, degree + 1)]
#         ND = [0.0 for _ in range(0, k + 1)]
#         L = k - degree + j
#     L = k - degree + num
#     X = []
#     PK = [[[None for _ in range(dim)] for _ in range(r + 1)] for _ in range(deriv_order + 1)]
#     PKL = [[[[[None for _ in range(dim)]
#               for _ in range(cpsize[1])] for _ in range(cpsize[0])]
#             for _ in range(deriv_order + 1)] for _ in range(deriv_order + 1)]


from geomdl import helpers
"""
    Tests for the NURBS-Python package
    Released under The MIT License. See LICENSE file for details.
    Copyright (c) 2018-2019 Onur Rauf Bingol

    Requires "pytest" to run.
"""


GEOMDL_DELTA = 10e-8


def test_find_span_binsearch():
	degree = 2
	knot_vector = [0, 0, 0, 1, 2, 3, 4, 4, 5, 5, 5]
	num_ctrlpts = len(knot_vector) - degree - 1
	knot = 5.0 / 2.0

	to_check = helpers.find_span_binsearch(degree, knot_vector, num_ctrlpts, knot)
	result = 4  # Value from The Nurbs Book p.68

	assert to_check == result


def test_basis_function():
	degree = 2
	knot_vector = [0, 0, 0, 1, 2, 3, 4, 4, 5, 5, 5]
	span = 4
	knot = 5.0 / 2.0


# Path: geomdl/helpers.py
# def find_span_binsearch(degree, knot_vector, num_ctrlpts, knot, **kwargs):
# def find_span_linear(degree, knot_vector, num_ctrlpts, knot, **kwargs):
# def find_spans(degree, knot_vector, num_ctrlpts, knots, func=find_span_linear):
# def find_multiplicity(knot, knot_vector, **kwargs):
# def basis_function(degree, knot_vector, span, knot):
# def basis_function_one(degree, knot_vector, span, knot):
# def basis_functions(degree, knot_vector, spans, knots):
# def basis_function_all(degree, knot_vector, span, knot):
# def basis_function_ders(degree, knot_vector, span, knot, order):
# def basis_function_ders_one(degree, knot_vector, span, knot, order):
# def basis_functions_ders(degree, knot_vector, spans, knots, order):
# def knot_insertion(degree, knotvector, ctrlpts, u, **kwargs):
# def knot_insertion_alpha(u, knotvector, span, idx, leg):
# def knot_insertion_kv(knotvector, u, span, r):
# def knot_removal(degree, knotvector, ctrlpts, u, **kwargs):
# def knot_removal_alpha_i(u, degree, knotvector, num, idx):
# def knot_removal_alpha_j(u, degree, knotvector, num, idx):
# def knot_removal_kv(knotvector, span, r):
# def knot_refinement(degree, knotvector, ctrlpts, **kwargs):
# def degree_elevation(degree, ctrlpts, **kwargs):
# def degree_reduction(degree, ctrlpts, **kwargs):
# def curve_deriv_cpts(dim, degree, kv, cpts, rs, deriv_order=0):
# def surface_deriv_cpts(dim, degree, kv, cpts, cpsize, rs, ss, deriv_order=0):
#     N = [1.0 for _ in range(degree + 1)]  # N[0] = 1.0 by definition
#     N = [0.0 for _ in range(degree + span + 1)]
#     N = [[None for _ in range(degree + 1)] for _ in range(degree + 1)]
#     N = [[0.0 for _ in range(0, degree + 1)] for _ in range(0, degree + 1)]
#         ND = [0.0 for _ in range(0, k + 1)]
#         L = k - degree + j
#     L = k - degree + num
#     X = []
#     PK = [[[None for _ in range(dim)] for _ in range(r + 1)] for _ in range(deriv_order + 1)]
#     PKL = [[[[[None for _ in range(dim)]
#               for _ in range(cpsize[1])] for _ in range(cpsize[0])]
#             for _ in range(deriv_order + 1)] for _ in range(deriv_order + 1)]


# Path: tests/test_helpers.py
from geomdl import helpers

"""
    Tests for the NURBS-Python package
    Released under The MIT License. See LICENSE file for details.
    Copyright (c) 2018-2019 Onur Rauf Bingol

    Requires "pytest" to run.
"""


GEOMDL_DELTA = 10e-8


def test_find_span_binsearch():
	degree = 2
	knot_vector = [0, 0, 0, 1, 2, 3, 4, 4, 5, 5, 5]
	num_ctrlpts = len(knot_vector) - degree - 1
	knot = 5.0 / 2.0

	to_check = helpers.find_span_binsearch(degree, knot_vector, num_ctrlpts, knot)
	result = 4  # Value from The Nurbs Book p.68

	assert to_check == result


def test_basis_function():
	degree = 2
	knot_vector = [0, 0, 0, 1, 2, 3, 4, 4, 5, 5, 5]
	span = 4
	knot = 5.0 / 2.0


	to_check = helpers.basis_function(degree, knot_vector, span, knot)