Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

Commit

Permalink
Fixes #391 (#1534)
Browse files Browse the repository at this point in the history
* Fixes #391

Add overload that takes a tuple

* Add simple test

* Fix typo
  • Loading branch information
slide authored Nov 6, 2016
1 parent 3e86f91 commit d1fe8f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ public static object GetItem(Array data, Slice slice) {
return GetSlice(data, data.Length, slice);
}

[SpecialName]
public static object GetItem(Array data, PythonTuple tuple) {
if (data == null) throw PythonOps.TypeError("expected Array, got None");
return GetItem(data, tuple.ToArray());
}

[SpecialName]
public static object GetItem(Array data, params object[] indices) {
if (indices == null || indices.Length < 1) throw PythonOps.TypeError("__getitem__ requires at least 1 parameter");
Expand Down
5 changes: 5 additions & 0 deletions Languages/IronPython/Tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,10 @@ def silly(): a_multi[0:][1:0]
type_helper(str, " ")
type_helper(str, "abc")

def test_tuple_indexer():
array1 = System.Array.CreateInstance(int, 20, 20)
array1[0,0] = 5
AreEqual(array1[0,0], array1[(0,0)])

#--MAIN------------------------------------------------------------------------
run_test(__name__)

0 comments on commit d1fe8f1

Please sign in to comment.