Skip to content

Conversation

@pourhouse
Copy link

@pourhouse pourhouse commented Jan 11, 2018

This will handle cases of ringbuf[-<n>], which were failing when self._arr is not full.

This may address the needs of your Issue #5, but I suspect it will not handle accesses when the index selector is an array_like with negative items.

@codecov-io
Copy link

codecov-io commented Jan 11, 2018

Codecov Report

Merging #6 into master will increase coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #6      +/-   ##
==========================================
+ Coverage   98.49%   98.58%   +0.08%     
==========================================
  Files           3        3              
  Lines         266      282      +16     
==========================================
+ Hits          262      278      +16     
  Misses          4        4
Impacted Files Coverage Δ
tests.py 98.76% <100%> (+0.1%) ⬆️
numpy_ringbuffer/__init__.py 98.31% <100%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 341c8db...cd47b57. Read the comment docs.

return self._arr[item]
item_arr = np.asarray(item)
if issubclass(item_arr.dtype.type, np.integer):
item_arr = (item_arr + self._left_index) % self._capacity

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just:

item_arr = ((item_arr % len(self)) + self._left_index) % self._capacity

instead of lines 167-170? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants