Skip to content

Operators, indexing and named parameters from Lua#47

Merged
greatwolf merged 7 commits intobastibe:masterfrom
marcelvanherk:master
Dec 12, 2016
Merged

Operators, indexing and named parameters from Lua#47
greatwolf merged 7 commits intobastibe:masterfrom
marcelvanherk:master

Conversation

@marcelvanherk
Copy link
Contributor

Hi,

these commits would add operators on python objects from Lua (2 commits, my mistake), default non-string Lua indexing to python indexing, and allow calling a python method with named parameters. The latter change has a few indendation errors due to copy/paste from editor. The branch has been tested.

marcelvanherk and others added 7 commits December 11, 2016 13:45
Implemented __mul metamethod in lua that maps to python __mul __ or __rmul __, same for lua __div, __add, __sub, __pow. Tested in nparray.
Added a test where any index or newindex request with a non-string key is mapped to a python index irrespective of the asindx status. This allows in lua e.g. a = np.arange(0, 10); print(a[0])
This change is needed to make the implementation of operators work.
If a single parameter is passed when calling a python function and that parameter is a table, then numbered elements are passed as regular arguments and named elements as named parameters. This allows, e.g., plt.plot(x, y) and plt.plot{x, y, c='red'} to coexist. The latter is a lua shortcut for passing a single table as argument. When you want to pass a single table as regular argument use func{{1, 2}} or func({1, 2}, nil)
C doesn't officially define min max.
Fixed tabs.
Need at least CMake 3.0.0 for FindLua. Earlier versions only have FindLua50 and FindLua51.
@greatwolf greatwolf merged commit 53ab376 into bastibe:master Dec 12, 2016
@marcelvanherk
Copy link
Contributor Author

Nice work. Thanks.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants