diff --git a/pkg/hypercube/hypercubeset.go b/pkg/hypercube/hypercubeset.go index 8a09076..0a55181 100644 --- a/pkg/hypercube/hypercubeset.go +++ b/pkg/hypercube/hypercubeset.go @@ -163,14 +163,6 @@ func (c *CanonicalSet) Subtract(other *CanonicalSet) *CanonicalSet { } } -func (c *CanonicalSet) getIntervalSetUnion() *interval.CanonicalSet { - res := interval.NewCanonicalSet() - for k := range c.layers { - res.Union(k) - } - return res -} - // ContainedIn returns true ic other contained in c func (c *CanonicalSet) ContainedIn(other *CanonicalSet) (bool, error) { if c == other { @@ -179,13 +171,11 @@ func (c *CanonicalSet) ContainedIn(other *CanonicalSet) (bool, error) { if c.dimensions != other.dimensions { return false, errors.New("ContainedIn mismatch between num of dimensions for input args") } - if c.dimensions == 1 { - if len(c.layers) != 1 || len(other.layers) != 1 { - return false, errors.New("unexpected object of dimension size 1") + if c.dimensions == 0 { + if len(c.layers) != 0 || len(other.layers) != 0 { + return false, errors.New("unexpected non-empty object of dimension size 0") } - cInterval := c.getIntervalSetUnion() - otherInterval := other.getIntervalSetUnion() - return cInterval.ContainedIn(otherInterval), nil + return true, nil } isSubsetCount := 0 diff --git a/pkg/hypercube/hypercubeset_test.go b/pkg/hypercube/hypercubeset_test.go index d9aa962..dc178db 100644 --- a/pkg/hypercube/hypercubeset_test.go +++ b/pkg/hypercube/hypercubeset_test.go @@ -119,6 +119,13 @@ func TestContainedIn(t *testing.T) { checkContained(t, b, a, false) } +func TestContainedIn1(t *testing.T) { + checkContained(t, cube(1, 3), cube(2, 4), false) + checkContained(t, cube(2, 4), cube(1, 3), false) + checkContained(t, cube(1, 3), cube(1, 4), true) + checkContained(t, cube(1, 4), cube(1, 3), false) +} + func TestContainedIn2(t *testing.T) { c := union( cube(1, 100, 200, 300),