Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interval exception detect when modify the lower or the upper property on an exist interval instance #48

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Taktoshi
Copy link

@Taktoshi Taktoshi commented Jan 20, 2020

Fix the bug of range exception detection when change the lower or the upper property. Add 12 new tests in test_initialization.py named class TestIntervalChanging.

before fixing:

interval = IntInterval([1, 2])
interval

IntInterval('[1, 2]')

interval.lower = 3
interval

IntInterval('[3, 2]')

after fixing:

interval = IntInterval([1, 2])
interval

IntInterval('[1, 2]')

interval.lower = 3
interval

it will raise the RangeBoundsException:
intervals.exc.RangeBoundsException: Min value 3 is bigger than max value 2.

Update the .travis.yml because the python3.3 can not download. So I change the archive for Trusty.

Taktoshi and others added 6 commits January 20, 2020 20:29
…exist interval instance.

before fixing:
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
IntInterval('[3, 2]')

after fixing:
…exist interval instance.

before fixing:
>>> interval = IntInterval([1, 2])
>>> interval
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
IntInterval('[3, 2]')

after fixing:
>>> interval = IntInterval([1, 2])
>>> interval
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
it will raise the RangeBoundsException:
intervals.exc.RangeBoundsException: Min value 3 is bigger than max value 2.
…exist interval instance.

before fixing:
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
IntInterval('[3, 2]')

after fixing:
>>> interval = IntInterval([1, 2])
>>> interval
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
it will raise the RangeBoundsException:
intervals.exc.RangeBoundsException: Min value 3 is bigger than max value 2.
@Taktoshi Taktoshi closed this Jan 20, 2020
@Taktoshi Taktoshi reopened this Jan 20, 2020
isinstance(arg, self.type) or
isinstance(arg, type(self)) or
arg == inf or arg == -inf
isinstance(arg, list) or
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this and all similar style changes where you add extra indents.

Copy link
Author

@Taktoshi Taktoshi Jan 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have revised all that changes.

@mark.parametrize(
('constructor', 'number_range', 'bad_upper'),
(
(IntInterval, (1, 2), 0),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the indentation of 4 spaces not 8.

Copy link
Author

@Taktoshi Taktoshi Jan 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation has been revised to 4.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still lines with indentation of 8 not 4

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will check again and change them.

…y on an exist interval instance.

before fixing:
>>> interval = IntInterval([1, 2])
>>> interval
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
IntInterval('[3, 2]')

after fixing:
>>> interval = IntInterval([1, 2])
>>> interval
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
it will raise the RangeBoundsException:
intervals.exc.RangeBoundsException: Min value 3 is bigger than max value 2.
…y on an exist interval instance.

before fixing:
>>> interval = IntInterval([1, 2])
>>> interval
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
IntInterval('[3, 2]')

after fixing:
>>> interval = IntInterval([1, 2])
>>> interval
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
it will raise the RangeBoundsException:
intervals.exc.RangeBoundsException: Min value 3 is bigger than max value 2.
…y on an exist interval instance.

before fixing:
>>> interval = IntInterval([1, 2])
>>> interval
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
IntInterval('[3, 2]')

after fixing:
>>> interval = IntInterval([1, 2])
>>> interval
IntInterval('[1, 2]')
>>> interval.lower = 3
>>> interval
it will raise the RangeBoundsException:
intervals.exc.RangeBoundsException: Min value 3 is bigger than max value 2.
@Taktoshi Taktoshi requested a review from kvesteri January 24, 2020 06:31
@AlexandreDecan
Copy link

@easybase Can I suggest you to have a look at https://github.com/AlexandreDecan/portion ? It's a Python library providing data structure and operations for intervals (atomic and interval sets). And we will be happy to accept pull requests, even the ones that do not comply style-wise ;-)

Apologies, it's a bit of publicity for another project, but this repository does not seem to be really maintained anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants