Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Fix issue #135
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrudy committed Sep 28, 2016
1 parent 3386bfe commit ed58d71
Show file tree
Hide file tree
Showing 9 changed files with 5,491 additions and 4,887 deletions.
5,915 changes: 3,200 additions & 2,715 deletions pyearth/_basis.c

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions pyearth/_basis.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ cdef class BasisFunction:

cpdef BasisFunction get_coverage(BasisFunction self, INDEX_t variable)

cpdef bool has_linear(BasisFunction self, INDEX_t variable)

cpdef bool linear_in(BasisFunction self, INDEX_t variable)

cpdef _set_parent(BasisFunction self, BasisFunction parent)

cpdef _add_child(BasisFunction self, BasisFunction child)
Expand Down Expand Up @@ -184,6 +188,8 @@ cdef class HingeBasisFunction(HingeBasisFunctionBase):
dict knot_dict, dict translation)

cdef class LinearBasisFunction(DataVariableBasisFunction):
cpdef bool linear_in(LinearBasisFunction self, INDEX_t variable)

cpdef _smoothed_version(LinearBasisFunction self, BasisFunction parent,
dict knot_dict, dict translation)

Expand Down
15 changes: 14 additions & 1 deletion pyearth/_basis.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,17 @@ cdef class BasisFunction:
if child.covered(variable):
return child
return None


cpdef bool has_linear(BasisFunction self, INDEX_t variable):
cdef BasisFunction child # @DuplicatedSignature
for child in self.get_children():
if child.linear_in(variable):
return True
return False

cpdef bool linear_in(BasisFunction self, INDEX_t variable):
return False

cpdef _set_parent(BasisFunction self, BasisFunction parent):
'''Calls _add_child.'''
self.parent = parent
Expand Down Expand Up @@ -849,6 +859,9 @@ cdef class LinearBasisFunction(DataVariableBasisFunction):
self.variable = variable
self.label = label if label is not None else 'x' + str(variable)
self._set_parent(parent)

cpdef bool linear_in(LinearBasisFunction self, INDEX_t variable):
return variable == self.variable

cpdef _smoothed_version(LinearBasisFunction self, BasisFunction parent,
dict knot_dict, dict translation):
Expand Down
Loading

0 comments on commit ed58d71

Please sign in to comment.