Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxeeem committed Dec 21, 2023
1 parent c1ad5de commit f9c4270
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pynars/NARS/DataStructures/_py/Bag.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def __init__(self, capacity: int, n_buckets: int = None, take_in_order: bool = T

self.levels = tuple(list() for i in range(self.n_levels)) # initialize buckets between 0 and capacity

self.currentCounter = 0
self.levelIndex = capacity % self.n_levels
self.current_counter = 0
self.level_index = capacity % self.n_levels

# self.buckets = self.Depq(maxlen=self.n_buckets)
n_digits = int(math.log10(self.n_levels)) + 3
Expand All @@ -74,12 +74,12 @@ def map_priority(priority: float):

def take(self, remove = True) -> Item:
if len(self) == 0: return None
if self._is_current_level_empty() or self.currentCounter == 0:
self.pointer = self.distributor.pick(self.levelIndex)
self.levelIndex = self.distributor.next(self.levelIndex)
if self._is_current_level_empty() or self.current_counter == 0:
self.pointer = self.distributor.pick(self.level_index)
self.level_index = self.distributor.next(self.level_index)
while self._is_current_level_empty():
self.pointer = self.distributor.pick(self.levelIndex)
self.levelIndex = self.distributor.next(self.levelIndex)
self.pointer = self.distributor.pick(self.level_index)
self.level_index = self.distributor.next(self.level_index)

if self.take_in_order:
# take the first item from the current bucket
Expand All @@ -97,7 +97,7 @@ def take(self, remove = True) -> Item:
else:
item = self.levels[self.pointer][idx]

self.currentCounter = idx
self.current_counter = idx

return item

Expand Down

0 comments on commit f9c4270

Please sign in to comment.