# Path: DSTK/GAM/gam.py
# def _recurse(tree, feature_vec):
# def _get_sum_of_gamma_correction(tree, data, labels, class_weights, feature_name):
# def _get_shape_for_attribute(attribute_data, labels, class_weights, feature_name, criterion, splitter,
#                              max_depth, min_samples_split, min_samples_leaf, min_weight_fraction_leaf,
#                              max_features, random_state, max_leaf_nodes, presort):
#     def __init__(self, **kwargs):
#     def _get_metadata_dict(self):
#     def _train_cost(self, data, labels):
#     def _get_pseudo_responses(self, data, labels):
#     def _init_shapes_and_data(self, data, labels):
#     def _update_learning_rate(self, dct, epoch):
#     def _initialize_class_weights(self, labels):
#     def _get_class_weights(self, labels):
#     def train(self, data, targets, **kwargs):
#     def _get_trimmed_record_indices(self, responses):
#     def _calculate_gradient_shape(self, data, labels, bag_indices=None, max_workers=1):
#     def __init__(self, gam):
#     def __getattr__(self, item):
#     def smoothen(self, data, penalty=None):
#     def _create_smooth_shape(shape, values, name, penalties):
#     def _fit_spline(values, target_vals, penalties):
# class GAM(BaseGAM):
# class SmoothGAM(BaseGAM):


import pytest
import numpy as np
from DSTK.GAM.gam import ShapeFunction



def _create_partition(lst_of_splits):
    return np.append(lst_of_splits, np.PINF)


def test_returning_value():
    func = ShapeFunction(_create_partition(np.linspace(1, 10, 10)), -1 * np.linspace(1, 10, 11), 'test_1')

    assert func.get_value(10.45) == -10.0
    assert func.get_value(0.45) == -1.0
    assert func.get_value(2.0) == -2.8


def test_func_multiply():
    func1 = ShapeFunction(np.linspace(1, 3, 3), np.linspace(1, 3, 3), 'test_1')

# Path: DSTK/GAM/gam.py
# def _recurse(tree, feature_vec):
# def _get_sum_of_gamma_correction(tree, data, labels, class_weights, feature_name):
# def _get_shape_for_attribute(attribute_data, labels, class_weights, feature_name, criterion, splitter,
#                              max_depth, min_samples_split, min_samples_leaf, min_weight_fraction_leaf,
#                              max_features, random_state, max_leaf_nodes, presort):
#     def __init__(self, **kwargs):
#     def _get_metadata_dict(self):
#     def _train_cost(self, data, labels):
#     def _get_pseudo_responses(self, data, labels):
#     def _init_shapes_and_data(self, data, labels):
#     def _update_learning_rate(self, dct, epoch):
#     def _initialize_class_weights(self, labels):
#     def _get_class_weights(self, labels):
#     def train(self, data, targets, **kwargs):
#     def _get_trimmed_record_indices(self, responses):
#     def _calculate_gradient_shape(self, data, labels, bag_indices=None, max_workers=1):
#     def __init__(self, gam):
#     def __getattr__(self, item):
#     def smoothen(self, data, penalty=None):
#     def _create_smooth_shape(shape, values, name, penalties):
#     def _fit_spline(values, target_vals, penalties):
# class GAM(BaseGAM):
# class SmoothGAM(BaseGAM):


# Path: DSTK/tests/tests_gam/test_shape_function.py
import pytest
import numpy as np
from DSTK.GAM.gam import ShapeFunction




def _create_partition(lst_of_splits):
    return np.append(lst_of_splits, np.PINF)


def test_returning_value():
    func = ShapeFunction(_create_partition(np.linspace(1, 10, 10)), -1 * np.linspace(1, 10, 11), 'test_1')

    assert func.get_value(10.45) == -10.0
    assert func.get_value(0.45) == -1.0
    assert func.get_value(2.0) == -2.8


def test_func_multiply():
    func1 = ShapeFunction(np.linspace(1, 3, 3), np.linspace(1, 3, 3), 'test_1')

    func2 = ShapeFunction(np.linspace(1, 3, 3), 0.5 * np.linspace(1, 3, 3), 'test_2')