Python for Practical Statistics
These days were a bit busy. I want to break the silence with an interesting link to a video. This is an interesting and fun to watch talk coming from the last PyCon. It talks about “practical statistics”, that is, how you can try to produce (or validate) a model when you can not compute the analytic model of a phenomenon. Many of the technique he describes can be used to any language, so it is suitable even if you do not program in Python.
How to use Rust in Python (Part 3)
In the previous part we have seen how to pass not trivial data to Rust functions such as a Python list. It is still not enough, though. In many cases we need to pass complex data structure back and forth from a Rust library. We may need to pass quaternions, 3D points, trees, a list of “books”… In short: anything.
Learning how to pass custom aggregated data types to Rust libraries (and back to Python) will be the focus of this part!
How to use Rust in Python (Part 2)
You can find the first part of this article HERE.
In the previous part we have seen how to run simple Rust functions with integer arguments. This is not enough, of course. We need to go further by passing Python lists to Rust functions.
The problem is that it is not possible to pass directly a Python list to a C interface. Python lists (we can call them Plists) are complicated beasts, you can easily see that they are objects full of methods, and attributes and… Stuff.
We need first to convert this in something edible from a Rust library. But first things first.
How to use Rust in Python (Part 1)
Rust is an amazing language. It is one of the best potential alternatives to C and has been elected two times in a row as the most promising language of the year (by me, :P). However, because its strict compile-time memory correctness enforcement and because it is a low-level language, it is not the fastest way to build a prototype. But don’t worry! Rust is the perfect language for embedding fast-binary libraries in Python! In this way we can get the best of both worlds!
Writing Rust code that can be executed in Python is stupidly easy. Obviously, you have to well design the interface between the two languages, but this will improve your Python code in two ways: 1) You can execute CPU-intensive algorithms at binary speed and 2) use real threads instead of the Python “simulated” ones (and because Rust is designed to be memory safe, writing thread safe routines is much easier). Let’s see!
Convert images to MovingAI maps
The MovingAI Benchmark Database is one of the most famous collections of maps for benchmark on pathfinding algorithms. I use it a lot during my work, it is useful to test an algorithm over a lot of real-world game maps. The consequence is that I developed a lot of tools to work with the map format of the MovingAI database.
The last of these tools is a straightforward Python script to convert images into maps in the MovingAI format. It is useful when you want to quickly develop some test maps.
YoshiX: Experiments made easy
Some months ago, I was frustrated by the monotony of the task of writing, running and collecting data from experiments. I was bored of facing always the same challenges, writing always the same code and facing always the same problems. In addition, every experiment ran on different platforms, and they quickly become difficult to replicate (and this should be the very point of every experiment).
Thus, I decided to write my personal framework for running experiments in Python: YoshiX. The idea behind YoshiX, inspired by classical Unit Testing libraries, is quite simple. You write your test in a separate file, then you run
yoshix and it automatically finds every experiment in a specific folder, runs them, and collects the output in the format of choice.
It is a simple tool; I still have not spent a lot of time in it. But I think it has some interesting developments. Let’s look into some details.