Index getting/setting
- Dominant language
- Python
- Stars
- 893
- Forks
- 101
- PR merge metrics
- No merged PRs in 30d
Description
Julia Arrays are treated differently from other AbstractArrays. This results in surprising, inconsistent behavior.
* Arrays are automatically converted to numpy arrays. So indexing into them works, and they are 0-indexed.
* Other AbstractArrays, such as DataFrames, are not converted. So indexing into them doesn't work, and even if it did, they would be 1-indexed. This is rather strange.
Would it be possible to overload indexing for array-like operators, and to handle the 0 -> 1 indexing conversion automatically?
```
In [1]: import julia
In [2]: j = julia.Julia()
In [3]: A = j.eval("zeros(3,3)")
...: A[1,1] = 2
...: A
...:
Out[3]:
array([[ 0., 0., 0.],
[ 0., 2., 0.],
[ 0., 0., 0.]])
In [4]: j.using("DataFrames")
...: Adf = j.DataFrame(A)
...: Adf[1,1] = 2
...:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
1 j.using("DataFrames")
2 Adf = j.DataFrame(A)
----> 3 Adf[1,1] = 2
TypeError: 'PyCall.jlwrap' object does not support item assignment
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.