Skip to content

Curve.rebinned() errors when fixp is outside domain #109

@antnieszka

Description

@antnieszka

I think, we may have some inconsistency in Curve.change_domain() and Curve.rebinned().

class TestCurve(TestCase):
    def setUp(self):
        self.c = Curve([[0, 0], [5, 5], [10, 0]])

    # other tests...

    def test_rebinned(self):
        new_c = self.c.rebinned(step=1)
        assert np.array_equal(new_c.x, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
        
        # E1
        new_c = self.c.rebinned(step=2, fixp=15)
        assert np.array_equal(new_c.x, [1, 3, 5, 7, 9, 11])
        
        # E2
        new_c = self.c.rebinned(step=2, fixp=-5)
        assert np.array_equal(new_c.x, [-1, 1, 3, 5, 7, 9])

And in Curve.rebinned we can find following comment:

        fixp doesn't have to be inside original domain.

As marked in code above #E1 and #E2 throw following exception:

...
>           raise ValueError('in change_domain():' 'the old domain does not include the new one')
E           ValueError: in change_domain():the old domain does not include the new one

beprof/curve.py:113: ValueError

If I comment out raise ValueError() in Curve.change_domain() tests work, no exceptions are thrown... And the above only happens when fixp is outside original domain.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions