Last change
on this file since 82 was 81, checked in by Bart Vastenhouw, 3 years ago |
Added python timedependent parties (conceder, hardliner, etc)
|
File size:
1.0 KB
|
Rev | Line | |
---|
[81] | 1 | from decimal import Decimal
|
---|
| 2 |
|
---|
| 3 | from tudelft.utilities.immutablelist.Range import Range
|
---|
| 4 |
|
---|
| 5 | from geniusweb.issuevalue.NumberValue import NumberValue
|
---|
| 6 | from geniusweb.issuevalue.ValueSet import ValueSet
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | class NumberValueSet ( ValueSet ):
|
---|
| 10 | '''
|
---|
| 11 | number range from low to high with given step size
|
---|
| 12 | '''
|
---|
| 13 | def __init__(self, range:Range ):
|
---|
| 14 | if not isinstance(range, Range):
|
---|
| 15 | raise ValueError("range must be type Range but got "+repr(range))
|
---|
| 16 | self._range = range;
|
---|
| 17 |
|
---|
| 18 | def getRange(self)->Range :
|
---|
| 19 | '''
|
---|
| 20 | @return the range defining this NumberValueSet.
|
---|
| 21 | '''
|
---|
| 22 | return self._range
|
---|
| 23 |
|
---|
| 24 | def get(self, index:int) -> NumberValue :
|
---|
| 25 | return NumberValue(self._range.get(index))
|
---|
| 26 |
|
---|
| 27 | def size(self) -> int:
|
---|
| 28 | return self._range.size()
|
---|
| 29 |
|
---|
| 30 | def __repr__(self) -> str :
|
---|
| 31 | return "NumberValueSet[" + str(self._range.getLow()) + "," +\
|
---|
| 32 | str(self._range.getHigh()) + "," + str(self._range.getStep()) + "]"
|
---|
| 33 |
|
---|
| 34 | def __eq__(self, other):
|
---|
| 35 | return isinstance(other, self.__class__) and \
|
---|
| 36 | self._range == other._range
|
---|
| 37 |
|
---|
| 38 | def __hash__(self):
|
---|
| 39 | return hash(self._range)
|
---|
| 40 | |
---|
Note:
See
TracBrowser
for help on using the repository browser.