- Timestamp:
- 09/03/15 19:34:13 (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/mystic/constraints.py
r819 r823 589 589 >>> unique([1,2,3,1,2,4], {'min':0, 'max':11}) 590 590 [1, 2, 3, 4.175187820357143, 2.5407265707465716, 4] 591 >>> mcon.unique([1,2,3,1,2,4], float) 591 >>> unique([1,2,3,1,2,4], {'min':0, 'max':11, 'type':int}) 592 [1, 2, 3, 6, 8, 4] 593 >>> unique([1,2,3,1,2,4], float) 592 594 [1, 2, 3, 1.012375036824941, 3.9821250727509905, 4] 593 595 >>> unique([1,2,3,1,2,10], int) … … 616 618 _max = max(unique) 617 619 elif isinstance(full, dict): # specified min/max for floats 618 ok = min(unique) >= full['min'] and max(unique) < full['max'] 620 _type = full.pop('type', float) #NOTE: undocumented keys: min,max,type 621 minu = min(unique) 622 maxu = max(unique) 623 _min = full.get('min', minu) 624 _max = full.get('max', maxu) 625 ok = minu >= _min and maxu < _max 619 626 if not ok: 620 oops = list(unique - set(range(full['min'],full['max']))) 621 msg = "x=%s not in %s <= x < %s" % (oops[-1],full['min'],full['max']) 622 _min = full['min'] 623 _max = full['max'] 624 full = float 627 oops = list(unique - set(range(_min,_max))) 628 msg = "x=%s not in %s <= x < %s" % (oops[-1],_min,_max) 629 full = _type 625 630 else: # full is a list of all possible values 626 631 ok = unique.issubset(full)
Note: See TracChangeset
for help on using the changeset viewer.