Python sortedcontainers.SortedSet() Examples
The following are 30
code examples of sortedcontainers.SortedSet().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sortedcontainers
, or try the search function
.
Example #1
Source File: integrator_learner.py From adaptive with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _set_data(self, data): ( self.priority_split, self.data, self.pending_points, self._stack, x_mapping, self.ivals, self.first_ival, ) = data # Add the pending_points to the _stack such that they are evaluated again for x in self.pending_points: if x not in self._stack: self._stack.append(x) # x_mapping is a data structure that can't easily be saved # so we recreate it here self.x_mapping = defaultdict(lambda: SortedSet([], key=attrgetter("rdepth"))) for k, _set in x_mapping.items(): self.x_mapping[k].update(_set)
Example #2
Source File: test_stress_sortedset.py From pyFileFixity with MIT License | 6 votes |
def test_init(): sst = SortedSet() sst._check() sst = SortedSet(load=10000) assert sst._list._load == 10000 assert sst._list._twice == 20000 assert sst._list._half == 5000 sst._check() sst = SortedSet(range(10000)) assert all(tup[0] == tup[1] for tup in zip(sst, range(10000))) sst.clear() assert len(sst) == 0 assert list(iter(sst)) == [] sst._check()
Example #3
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 6 votes |
def test_islice(): ss = SortedSet(load=7) assert [] == list(ss.islice()) values = list(range(53)) ss.update(values) for start in range(53): for stop in range(53): assert list(ss.islice(start, stop)) == values[start:stop] for start in range(53): for stop in range(53): assert list(ss.islice(start, stop, reverse=True)) == values[start:stop][::-1] for start in range(53): assert list(ss.islice(start=start)) == values[start:] assert list(ss.islice(start=start, reverse=True)) == values[start:][::-1] for stop in range(53): assert list(ss.islice(stop=stop)) == values[:stop] assert list(ss.islice(stop=stop, reverse=True)) == values[:stop][::-1]
Example #4
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_union(): temp = SortedSet(range(0, 50), load=7) that = SortedSet(range(50, 100), load=9) result = temp.union(that) assert all(result[val] == val for val in range(100)) assert all(temp[val] == val for val in range(50)) assert all(that[val] == (val + 50) for val in range(50))
Example #5
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_isub(): temp = SortedSet(range(100), load=7) temp -= range(0, 10) temp -= range(10, 20) assert all((val + 20) == temp[val] for val in range(80))
Example #6
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_index(): temp = SortedSet(range(100), load=7) assert all(temp.index(val) == val for val in range(100))
Example #7
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_and(): temp = SortedSet(range(100), load=7) that = temp & range(20) & range(10, 30) assert all(that[val] == (val + 10) for val in range(10)) assert all(temp[val] == val for val in range(100))
Example #8
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_intersection(): temp = SortedSet(range(100), load=7) that = temp.intersection(range(0, 20), range(10, 30)) assert all(that[val] == (val + 10) for val in range(10)) assert all(temp[val] == val for val in range(100))
Example #9
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_intersection_update(): temp = SortedSet(range(100), load=7) temp &= range(0, 20) temp &= range(10, 30) assert all(temp[val] == (val + 10) for val in range(10))
Example #10
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_isdisjoint(): temp = SortedSet(range(100), load=7) that = SortedSet(range(100, 200), load=9) assert temp.isdisjoint(that)
Example #11
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_issuperset(): temp = SortedSet(range(100), load=7) that = SortedSet(range(25, 75), load=9) assert temp.issuperset(that)
Example #12
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_xor(): temp = SortedSet(range(0, 75), load=7) that = SortedSet(range(25, 100), load=9) result = temp ^ that assert all(result[val] == val for val in range(25)) assert all(result[val + 25] == (val + 75) for val in range(25)) assert all(temp[val] == val for val in range(75)) assert all(that[val] == (val + 25) for val in range(75))
Example #13
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_symmetric_difference(): temp = SortedSet(range(0, 75), load=7) that = SortedSet(range(25, 100), load=9) result = temp.symmetric_difference(that) assert all(result[val] == val for val in range(25)) assert all(result[val + 25] == (val + 75) for val in range(25)) assert all(temp[val] == val for val in range(75)) assert all(that[val] == (val + 25) for val in range(75))
Example #14
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_symmetric_difference_update(): temp = SortedSet(range(0, 75), load=7) that = SortedSet(range(25, 100), load=9) temp ^= that assert all(temp[val] == val for val in range(25)) assert all(temp[val + 25] == (val + 75) for val in range(25))
Example #15
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_pop(): temp = SortedSet(range(0, 100), load=7) temp.pop() temp.pop(0) assert all(temp[val] == (val + 1) for val in range(98))
Example #16
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_or(): temp = SortedSet(range(0, 50), load=7) that = SortedSet(range(50, 100), load=9) result = temp | that assert all(result[val] == val for val in range(100)) assert all(temp[val] == val for val in range(50)) assert all(that[val] == (val + 50) for val in range(50))
Example #17
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_difference_update(): temp = SortedSet(range(100), load=7) temp.difference_update(range(0, 10), range(10, 20)) assert all((val + 20) == temp[val] for val in range(80))
Example #18
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_update(): temp = SortedSet(range(0, 80), load=7) temp.update(range(80, 90), range(90, 100)) assert all(temp[val] == val for val in range(100))
Example #19
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_ior(): temp = SortedSet(range(0, 80), load=7) temp |= range(80, 90) temp |= range(90, 100) assert all(temp[val] == val for val in range(100))
Example #20
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_repr(): temp = SortedSet(range(0, 10), load=7) assert repr(temp) == 'SortedSet([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], key=None, load=7)'
Example #21
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_pickle(): import pickle alpha = SortedSet(range(10000), key=negate, load=500) beta = pickle.loads(pickle.dumps(alpha)) assert alpha == beta assert alpha._key == beta._key assert alpha._load == beta._load
Example #22
Source File: test_stress_sortedset.py From pyFileFixity with MIT License | 5 votes |
def stress_operator(sst): other = SortedSet(sst) stress_delitem(other) assert other < sst assert sst > other
Example #23
Source File: test_stress_sortedset.py From pyFileFixity with MIT License | 5 votes |
def stress_issubset(sst): that = SortedSet(sst) that.update(range(1000)) assert sst.issubset(that)
Example #24
Source File: test_stress_sortedset.py From pyFileFixity with MIT License | 5 votes |
def stress_issuperset(sst): that = SortedSet(sst) assert sst.issuperset(that)
Example #25
Source File: sequence_learner.py From adaptive with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, function, sequence): self._original_function = function self.function = _IgnoreFirstArgument(function) self._to_do_indices = SortedSet({i for i, _ in enumerate(sequence)}) self._ntotal = len(sequence) self.sequence = copy(sequence) self.data = SortedDict() self.pending_points = set()
Example #26
Source File: memory.py From biggraphite with Apache License 2.0 | 5 votes |
def __init__(self): """Create a new MemoryAccessor.""" super(_MemoryAccessor, self).__init__("memory") self._metric_to_points = collections.defaultdict(sortedcontainers.SortedDict) self._name_to_metric = {} self._directory_names = sortedcontainers.SortedSet() self.__downsampler = _downsampling.Downsampler() self.__delayed_writer = _delayed_writer.DelayedWriter(self)
Example #27
Source File: dispatcher.py From aries-staticagent-python with Apache License 2.0 | 5 votes |
def add_handler(self, handler: Handler): """ Add a handler to routing tables. """ self.handlers[handler.type] = handler key = (handler.type.doc_uri, handler.type.protocol, handler.type.name) if key not in self.handler_versions: self.handler_versions[key] = SortedSet() self.handler_versions[key].add(handler.type.version_info)
Example #28
Source File: test_coverage_sortedset.py From pyFileFixity with MIT License | 5 votes |
def test_lt_gt(): temp = SortedSet(range(100), load=7) that = SortedSet(range(25, 75), load=9) assert that < temp assert not (temp < that) assert that < temp._set assert temp > that assert not (that > temp) assert temp > that._set
Example #29
Source File: fog.py From py-trie with MIT License | 5 votes |
def __init__(self) -> None: # Always start without knowing anything about a trie. The only unexplored # prefix is the root prefix: (), which means the whole trie is unexplored. self._unexplored_prefixes = SortedSet({()})
Example #30
Source File: fog.py From py-trie with MIT License | 5 votes |
def _new_trie_fog(cls, unexplored_prefixes: SortedSet) -> 'HexaryTrieFog': """ Convert a set of unexplored prefixes to a proper HexaryTrieFog object. """ copy = cls() copy._unexplored_prefixes = unexplored_prefixes return copy