@Kuba It was an operator that existed in a beta version of Mathematica but was subsequently removed, see this. I don't remember what it did right now, but I think it was explained at one point here in the chat.
Direct transfer of a packed array from Mathematica to python (using numpy, but I've got some support for being efficient without it).
2
Need to polish up and bug test, but I put the code up here if people want to take a look.
I also added some more "pythonic" things to it, like being able to say for x in link: ... by making use of the .ready property and a general .get function to write a __next__
@b3m2a1 Did you do it based on that discussion I had with Kh40tiK? Or did you find another method to detect a packed array on a link, based on the J/Link code?
Yes, I was waiting for your project to get to a state where we can try it out.
I'm most interested in calling Python from M (i.e. the reverse).
The classic example: set up an array processing function (such as eigenvalues) with automatic argument and return value translation. Like MFunction["eig"] in MATLink.
@Kh40tiK Let us know when yours reaches the same state.
So somehow we ended up with three Python interfaces being developed in parallel (including ExternalEvaluate, which seems to be making good progress, but still hasn't convinced me that it can become practically usable)
Sigh... PDFs of DiscreteMarkovProcesses have often small imaginary parts if transition matrices are inexact, and if they're exact, computation can take quite long...
@Szabolcs I saw how JLink did it and used a trick of my own. That .evaluate function wraps its argument in some packets that try to convert its arg to a packed array and return some meta-info telling me if its or not.
I'll also put in a setup function (since ideally all you'll need to do in the end is call and edited version of that setup.py file to build the .so file). I just used python's native stuff for building out C extensions so hopefully I can handle most of the difficulty myself which would be nice for making it "batteries included".
In terms of calling python from Mathematica I'll need to write a bit more before I have that down just right (I have a __callPython method which is the template for how it will work, just not fully done yet). That's a bit of Mathematica-side work to get that happening, but really not very much. Most of the code complexity is python-side.
I have posted a new version of OBJImporter to Github. The new version fixes the problem that @HenrikSchumacher found and increases the overall performance of the package.
Look at callJava in KernelLinkImpl. When calls occur JLink passes data to the Java side to handle type info and things.
Then it calls the appropriate getArray function to efficiently read the data back in.
The way I do it is passing a package-specific head (PJLink`Packed`PackedArrayInfo or something...I forget). Then I call the appropriate _getArray based on that data. The wrapping I do adds that as packets currently, but I will likely just write some Mathematica package that can add it all on the Mathematica side and do a bunch more than have a KernelLink load that automatically on its first call.
@bobthechemist Good lord. My Arduino arrived today. I thought it's a nice thing to have when I want to experiment with the kids.. Now I'm sitting here and play with RGB LEDs.. And now guess who was the one that planted this idea into my head.
@halirutan The IDE works fine for very many applications. I have recently started programming ATTiny85 chips and have bought an Atmel ICE programmer to go along with Atmel studio.
I'm coming from a non-programmer/computer science background, so I'm fine with the limited capabilities of the Arduino IDE and a bit overwhelmed by Atmel studio.
I use the Arduino IDE 1.8.5. on Windows. Ultimately I will use the Arduino IDE on a Raspberry, because I want to have a development environment that will be still avalaible in 5-10 years.
I guess I'm fine with Arduino IDE too. I haven't planned any projects anyway, but I made a lot of experiments with lights with the kids and maybe I can get one of them hooked.
And it was just incredible how easy it was to set everything up.
@bobthechemist One question: I looked through the language reference and some of the library code. Is this "real" C++? What are the limitations of the language?
I've taken one course - many years ago - in C++, so I don't know how much of what I do is "real". The most sophisticated Arduino programming I've done has been my syringe pump which involves classes and overloaded constructors - and I was proud of knowing what that meant :)
@Szabolcs, @halirutan and others I'm considering including a "Mathematica" module on the python side where I register a bunch of Mathematica functions so you can just write code that looks almost exactly like Mathematica code and have it automatically translate into packets for evaluation over the link. I have most of the infrastructure in place I think to make it work quickly, but I'm also wondering if it's worth it. What do you think?