Skip to content

Commit

Permalink
Fix Polars.last (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
wagner authored Jul 14, 2023
1 parent 5e7c1f5 commit c99f6cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/polars/series.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ def [](item)
end

if item.is_a?(Integer)
if item < 0
item = len + item
end

return _s.get_idx(item)
end

Expand Down
1 change: 1 addition & 0 deletions test/series_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def test_negation
def test_get
s = Polars::Series.new(1..3)
assert_equal 2, s[1]
assert_equal 3, s[-1]
assert_series [1, 2], s[[0, 1]]
assert_series [1, 2], s[Polars::Series.new([0, 1])]
assert_series [1], s[0..0]
Expand Down

0 comments on commit c99f6cd

Please sign in to comment.