Last change
on this file since 62 was 59, checked in by Wouter Pasman, 3 years ago |
#44 manual commit of first public release, because this will cause the dist directory to move
|
File size:
977 bytes
|
Line | |
---|
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 | def __init__(self, range:Range ):
|
---|
12 | if not isinstance(range, Range):
|
---|
13 | raise ValueError("range must be type Range but got "+repr(range))
|
---|
14 | self._range = range;
|
---|
15 |
|
---|
16 | def getRange(self)->Range :
|
---|
17 | '''
|
---|
18 | @return the range defining this NumberValueSet.
|
---|
19 | '''
|
---|
20 | return self._range
|
---|
21 |
|
---|
22 | def get(self, index:int) -> NumberValue :
|
---|
23 | return NumberValue(self._range.get(index))
|
---|
24 |
|
---|
25 | def size(self) -> int:
|
---|
26 | return self._range.size()
|
---|
27 |
|
---|
28 | def __repr__(self) -> str :
|
---|
29 | return "NumberValueSet[" + str(self._range.getLow()) + "," +\
|
---|
30 | str(self._range.getHigh()) + "," + str(self._range.getStep()) + "]"
|
---|
31 |
|
---|
32 | def __eq__(self, other):
|
---|
33 | return isinstance(other, self.__class__) and \
|
---|
34 | self._range == other._range
|
---|
35 |
|
---|
36 | def __hash__(self):
|
---|
37 | return hash(self._range)
|
---|
38 | |
---|
Note:
See
TracBrowser
for help on using the repository browser.