intiocean / pyinter

A interval package for Python which deals with interval arithmetic
MIT License
9 stars 11 forks source link

Difficult to debug strings in intervals #8

Open dbgoodman opened 10 years ago

dbgoodman commented 10 years ago

Currently it's very difficult to tell if a user accidentally passed in strings to pyinterval.closedopen. For instance, in the case of:

bad_interval =  pyinterval.closedopen('100','200')

The repr() and str() modules don't show the quotes around the values, so it looks like you passed in integers. The only way to tell is by using

bad_interval._data._lower_value
bad_interval._data._upper_value

I understand you want the module to be type-agnostic, which is admirable, but making repr() look like:

['100','200')

instead of:

[100,200)

might make it easier to debug problems.

intiocean commented 10 years ago

Hi @dbgoodman,

Thanks for your comment.

I guess changing the Interval.__repr__() method to include the repr() of its lower and upper values instead of the str() might make this more obvious. Feel free to submit a pull request with this change and a test otherwise I'll take a look when I get a chance.

Inti