source: geniuswebcore/geniusweb/issuevalue/NumberValueSet.py@ 63

Last change on this file since 63 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 
1from decimal import Decimal
2
3from tudelft.utilities.immutablelist.Range import Range
4
5from geniusweb.issuevalue.NumberValue import NumberValue
6from geniusweb.issuevalue.ValueSet import ValueSet
7
8
9class 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.