diff --git a/firanka/series/range.py b/firanka/series/range.py index 994677021fb7a1513d4572ef70b65467a05e691f..cf3c36d2fa32d4dcc043baf00a38f095cff0960d 100644 --- a/firanka/series/range.py +++ b/firanka/series/range.py @@ -22,29 +22,25 @@ class Range(object): """ Range of real numbers """ + def __from_str(self, rs): + if rs[0] not in '<(': raise ValueError('Must start with ( or <') + if rs[-1] not in '>)': raise ValueError('Must end with ) or >') + if ';' not in rs: raise ValueError('Separator ; required') + + start, stop = rs[1:-1].split(';') + start = float(start) + stop = float(stop) + return float(start), float(stop), rs[0] == '<', rs[-1] == '>' + + def __from_range(self, rs): + return rs.start, rs.stop, rs.lend_inclusive, rs.rend_inclusive + def __init__(self, *args): if len(args) == 1: rs, = args - if isinstance(rs, type(self)): - start = rs.start - stop = rs.stop - lend_inclusive = rs.lend_inclusive - rend_inclusive = rs.rend_inclusive - else: - rs, = args - - if rs[0] not in '<(': raise ValueError('Must start with ( or <') - if rs[-1] not in '>)': raise ValueError('Must end with ) or >') - if ';' not in rs: raise ValueError('Separator ; required') - - lend_inclusive = rs[0] == '<' - rend_inclusive = rs[-1] == '>' - - start, stop = rs[1:-1].split(';') - start = float(start) - stop = float(stop) - else: - start, stop, lend_inclusive, rend_inclusive = args + args = self.__from_range(rs) if isinstance(rs, type(self)) else self.__from_str(rs) + + start, stop, lend_inclusive, rend_inclusive = args if lend_inclusive and math.isinf(start): raise ValueError('Greater or equal with infinity!') diff --git a/setup.cfg b/setup.cfg index e0b23bb71491a9851d782c1935584714f7172651..f5a5bacec769d8a50d08cab9fe7de7498a9a9e78 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] description-file = README.md -name = firanka license = MIT License classifiers = Programming Language :: Python