How I automated the test of anki's GUI

Here is how I created automatic test for Anki's user interface. Those tricks may potentially be useful potentially for other (py)Qt project.

Automatically testing a GUI is complicated. Indeed, the method you call when you open the GUI does not return until the main window is closed. A natural idea would then be to open the main window in a Thread, and create the tests in another one. But in (py)Qt, every things related to the GUI must occur in the main thread, which make this threading idea impossible.

Another easy solution would be to write the test inside the software, and use an option, or a global variable, to tell that you want to test the software once it's opened. This would work, but it means the test code is inside the software code, which is not beautiful.

One nice thing with anki is that it has an add-on system, which means that you can execute arbitrary code without having this code in anki. So, this is what I did. My test tells anki to start with a non-standard main folder. This folder contains a collection used for the test, and one add-on. The real tests are then in the add-on code. I thus tell the add-on to catch any exception and then to close the program with a non-zero exit code. My main test file only have to test that the execution of anki returns a 0 code.

Of course, if there is some unexpected problem, which allows windows to be opened and not to be closed, then anki will be stuck. But at least, seing anki stuck will show that there is a trouble. And an automated test system will simply fail because the test takes too much time.

Learning how to play music with anki

I've been playing music for half of my life. But while I was enjoying sight reading partitions, and sometime practiced a little bit the boring part (scales, arpeggios), I have been stuck. Here is a list of what changed:

  • The most frustrating thing for me being that I relied on partitions. Which means that if you gave me a piano or guitar without a partition, I wasn't able to play anything. I found that ridiculous, and anki helped me solve that.
  • Similarly, I played classical guitar, and I didn't know how to read tab. Because, honestly, they are so many chords, I keep forgetting them. Which means that, if you give me a song with tab, as they are hundred of thousands of them, I couldn't play it, because it was not written in a way I can easily read. I don't know every single chord yet (and I'll probably never know them all), I know far more chords today than what I knew before I started anki, and it clearly helps learning songs and doing improv.

The example in this post are related to ocarina, guitar, piano, harmonica and tin whistle. I will explain what differs and what is similar for all of those instruments. Some explanation may not always be clear, if you don't know the instruments I'm talking about. But don't worry, if you don't understand, just read the next paragraph, you should be able to get the general idea.

This article will be illustrated using almost only cards that I have really seen the day I was writing this article. You can find here my [piano], [guitar] and [ocarina] decks. They are far from being perfect, some typos may still be in them. But it may help you to understand what I write here. And maybe you can find them useful in your collection.

Continue reading

Anki and learning which require practice (origami, knot, instrument...)

I use anki to learn things which require practice. Origami, drawing, music, rope (nodes and shibari). Music will be considered in another text.

I consider two kinds of practical knowledge:

  • some practice requires making choices regularly (like drawing, or musical improv)
  • some practice requires learning and practicing some exact moves over and over. That may be the case when you want to learn a musical piece, or how to tie some particular note.

I don' have any idea how to deal with the first kind of knowledge, thus I'll only consider the second kind. I'll list here different methods, which depends on what I want to learn. I don't know in general how to decide which method is the best one.

Continue reading

Lists in anki: desiderata and partial solution

In this text, I assume you are familiar with anki, and in particular know what is a field, a card, a card's type (aka template), a note and a note's type (aka a model), and that you have an idea of what are the rules used by anki to decide which cards should be generated or not.

There is one big limitation in anki, it concerns lists[1]. Here I list my trouble, the existing work arounds I know, their limits, and the functionnality I would really want. Sadly, this functionnality seems to require such a big modification of anki's underlying model that I fear that no add-on can answer my request. In particular if I want this request to also be satisfied in smartphone's application, which does not allows to add add-ons.

Learning a list of things is hard, but it's something I sometime want to do. A poem/song is just a list of line. Sometime, a mathematical notions have 4 distinct names. E.g. a pullback is also called a fiber product, a fibered product and a Cartesian square. In some othe case, a mathematical objects admits many distinct definitions[2]. E.g. I've got 5 definitions of left-trivial monoids. And I'd also wanted to see if I can learn the list of the prime number less than 100. Mostly to see how hard it is to learn an arbitrary list.

Notes

[1] I assume here that sets are list, with an arbitrary order

[2] This is in general considered to be a proof that the object is really interesting

Continue reading

Note on an introduction on Anki given a 35C3

This post is a comment about a self-organised workshop Introduction to anki I gave at #35C3 (35th Chaos Communication Congress, a congress of 17k hackers). This workshop was announced on the anki's subredd where I asked for ideas. I received a lot of useful feedback from this subreddit and from the related discord server. The main audience of the current blog post is thus those person, already in anki's community. This post contains idea in random order.

Continue reading

The trolley problem, and what you should do if I'm on the tracks

Originally published in French and crossposted on LessWrong. Translation by Épiphanie.

Trigger warning: Death, suicide, and murder. Trolley problem.

This is quite the conventional and ethical conundrum: You are near train tracks, and a train is rolling down the hill. It is going to run over 4 people who are tied to the rails of the main track. However, you can change the train's direction to a secondary track by pulling a lever; so that it runs over only one guy, also tied down the rails. Should you pull the lever?

I do believe there is a more interesting way to frame it: What would you choose if you are yourself tied to the rails, alone, while the train is not heading toward you yet. My own answer is very simple: I want the person deciding where the train should go to have _no doubts_ they should pull the lever! Because, for lack of context, I assume that the other four people are just me, or rather copy of mes. That's a bit simplistic, of course they are not perfect clone. But as far as concrete predicates go, they are indistinguishable. That is to say I have odds of being on tracks alone of 1 in 5, and odds for being in the group of 4 in 5. And tell you what, I prefer dying with 20% probability because of what someone did, rather than to die with 80% probability because no one was ever willing to take the burden of responsibility.

Continue reading

Page top