Skip to content

Bounded Float and Int#33

Merged
minrk merged 5 commits intoipython:masterfrom
SylvainCorlay:bounded_float
Jun 15, 2015
Merged

Bounded Float and Int#33
minrk merged 5 commits intoipython:masterfrom
SylvainCorlay:bounded_float

Conversation

@SylvainCorlay
Copy link
Member

@minrk This allows defining a min and max attribute to a Float trait type.

@SylvainCorlay
Copy link
Member Author

(I will add a test if you are fine with this.)

@minrk
Copy link
Member

minrk commented Jun 15, 2015

I think it makes sense. I would do the same on Integer, though.

@SylvainCorlay
Copy link
Member Author

Added a bounded Int. In Python 3.0, int does not really have a maximum value. Hence the implementation is a bit different than for Float.

@SylvainCorlay SylvainCorlay changed the title Bounded float Bounded Float and Int Jun 15, 2015
Copy link
Member

Choose a reason for hiding this comment

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

lesser -> less

@takluyver
Copy link
Member

The error messages should also include the value that it was trying to set, I think, by analogy with the type mismatch error messages:

"The '%s' trait of %s instance must be %s, but a value of %s was specified."

@SylvainCorlay
Copy link
Member Author

@takluyver as per you suggestions.

Copy link
Member

Choose a reason for hiding this comment

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

repr_type() will return something like 200 <class 'int'>. Given that at this point it must be the correct type, we can just show its repr with %r in the format string.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@takluyver
Copy link
Member

👍

@SylvainCorlay
Copy link
Member Author

green button?

minrk added a commit that referenced this pull request Jun 15, 2015
@minrk minrk merged commit a15ac67 into ipython:master Jun 15, 2015
@minrk minrk modified the milestones: 4.1, 4.0 Nov 9, 2015
@pbugnion pbugnion mentioned this pull request Jul 30, 2016
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