Where does the ref procedure defined?
i can not find it in the code ,nor in numpy or python and not in the documentation.
It seems used to access a line like in an ndarray:
(define Z (numpy.array '[[0 0 0 0 0 0]
[0 0 0 1 0 0]
[0 1 0 1 0 0]
[0 0 1 1 0 0]
[0 0 0 0 0 0]
[0 0 0 0 0 0]]))
(ref Z 2)
(obj "ndarray" : array([0, 0, 0, 1, 0, 0]))
i have also defined this:
; getter for ndarray line
(define (ndarray-line-ref A lin)
(numpy.take A (numpy.array (list lin)) #:axis 0))
(ndarray-line-ref Z 2)
(obj "ndarray" : array([[0, 0, 0, 1, 0, 0]]))
i also wrote a setter for ndarray line, does it already exist something undocumented in pyffi?
Look at python-operators.rkt for the definition of ref.
The same file contains :=.
1 Like
thank, it escaped my grep on the files.
I read the code fast.
seems ti uses PyObject_GetItem in the lambda-case (never used lambda-case so i could be wrong) ,seems i get the same result with numpy python code.
Will look later := but for now i do not understand where the operator come from, python? ,pyffi? ,scheme? python-C-API? It is hard to trace code between the 3 languages
Check this table:
Source code: Lib/operator.py The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expres...
If you need a Python operator, the table shows which function to use.
In this case obj[k] is mapped to getitem(obj,k).
oh yes i used it years ago before for overloading operators,later with decorator , i had created a sort of type annotation , later type annotation being integrated (not my own implementation) in Python standarts.....
thank