Repository: hyrodium/BasicBSpline.jl (julia)

Issue:
`countknots` is sometimes incorrect
```julia
julia> using BasicBSpline

julia> k = KnotVector([-2,-1,-0.0,-0.0,0.0,1,3])
KnotVector([-2.0, -1.0, -0.0, -0.0, 0.0, 1.0, 3.0])

julia> countknots(k,0)
1

julia> countknots(k,-0.)
2
```
Both `countknots(k,0)` and `countknots(k,-0.)` should return `3`.

Pull request description:
This PR fixes #282.

Patch:
diff --git a/src/_KnotVector.jl b/src/_KnotVector.jl
index 1380286e9..5760d6240 100644
--- a/src/_KnotVector.jl
+++ b/src/_KnotVector.jl
@@ -273,5 +273,5 @@ function countknots(k::AbstractKnotVector, t::Real)
     # return count(==(t), k.vector)
 
     # for large case, this is faster
-    return length(searchsorted(k,t))
+    return length(searchsorted(_vec(k), t, lt=<))
 end


Test patch:
diff --git a/test/test_KnotVector.jl b/test/test_KnotVector.jl
index dab195e83..a18de1a9e 100644
--- a/test/test_KnotVector.jl
+++ b/test/test_KnotVector.jl
@@ -152,5 +152,10 @@
         @test countknots(k, 2.0) == 2
         @test 1 ∈ k
         @test 1.5 ∉ k
+
+        k = KnotVector([-2.0, -1.0, -0.0, -0.0, 0.0, 1.0, 3.0])
+        @test countknots(k,0) == 3
+        @test countknots(k,0.0) == 3
+        @test countknots(k,-0.0) == 3
     end
 end