Repository: hyrodium/BasicBSpline.jl (julia)

Issue:
Strange `issqsubset` behavior
I believe there were some issues like this before.
```julia
julia> using BasicBSpline

julia> P1 = BSplineSpace{3}(KnotVector([2, 2, 2, 3, 3, 4, 4, 4]))
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([2, 2, 2, 3, 3, 4, 4, 4]))

julia> P2 = BSplineSpace{3}(KnotVector([1, 3, 3, 3, 4]))
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 3, 3, 3, 4]))

julia> dim(P1)
4

julia> dim(P2)
1

julia> P1 ⊑ P2  # shuold be false
true
```

Pull request description:
This PR fixes #329.

Patch:
diff --git a/src/_BSplineSpace.jl b/src/_BSplineSpace.jl
index c7c8f28a1..cbb5c20ba 100644
--- a/src/_BSplineSpace.jl
+++ b/src/_BSplineSpace.jl
@@ -184,6 +184,11 @@ function issqsubset(P::BSplineSpace{p}, P′::BSplineSpace{p′}) where {p, p′
     if p₊ < 0
         return false
     elseif domain(P) ≠ domain(P′)
+        # The domains must be equal for P ⊑ P′.
+        return false
+    elseif !(k′[1+p′] < k′[end-p′])
+        # The width(domain(P′)) must be non-zero for P ⊑ P′.
+        # There may be some edge-case like P′ ⊑ P′, but we don't need `true` for that situation.
         return false
     end
 


Test patch:
diff --git a/test/test_BSplineSpace.jl b/test/test_BSplineSpace.jl
index 6f316a678..2402a0b4e 100644
--- a/test/test_BSplineSpace.jl
+++ b/test/test_BSplineSpace.jl
@@ -102,6 +102,17 @@
         @test P3 ⊋ P1
     end
 
+    @testset "sqsubset" begin
+        P1 = BSplineSpace{3}(KnotVector([2, 2, 2, 3, 3, 4, 4, 4]))
+        P2 = BSplineSpace{3}(KnotVector([1, 3, 3, 3, 4]))
+        P3 = BSplineSpace{2}(knotvector"3 3")
+        P4 = BSplineSpace{3}(knotvector"4 4")
+        P5 = BSplineSpace{3}(knotvector"414")
+
+        @test P1 ⋢ P2
+        @test P3 ⊑ P4 ⊑ P5
+    end
+
     @testset "equality" begin
         P1 = BSplineSpace{2}(KnotVector([1, 2, 3, 5, 8, 8, 9]))
         P2 = BSplineSpace{2}(KnotVector([1, 2, 3, 5, 8, 8, 9]))