Skip to content

Faster bit-level data packing

An 256*64 pixel OLED display connected to Raspberry Pi (Zero W) has 4 bit greyscale pixel data packed into a byte (i.e. two pixels per byte), so 8192 bytes in total. E.g. the bytes become Converting these bytes either obtained from a Pillow (PIL) Image or a cairo ImageSurface takes up to 0.9 s when naively it…

Python comparing two lists and filtering items

I would like to do some word filtering (extracting only items in ‘keyword’ list that exist in ‘whitelist’). Here is my code so far: I want to remove every word except for ‘Cat’, ‘Dog’, and ‘Cow’ (which are in the ‘whitelist’) so that the …

How to exclude imports from automodapi output?

I am trying to use automodapi to generate documentation for my Django project. When I call automodapi like this: the output includes all imported classes and functions, e.g, the Django Model class, in the index of Functions and Classes. I would like to exclude the imports and only list those classes and funct…

Pandas: ValueError: cannot convert float NaN to integer

I get ValueError: cannot convert float NaN to integer for following: The “x” is a column in the csv file, I cannot spot any float NaN in the file, and I don’t understand the error or why I am getting it. When I read the column as String, then it has values like -1,0,1,…2000, all look v…

opencv cascade.detectMultiScale creates error: (-215) !empty()

I am following this tutorial to understand haar features. While writing following code: getting following error: (Sachin is the image i downloaded from google, of size (237,237,3) and after converting gray it is (237,237) with min=23, max=210. I am using opencv 3.1.0 with python 3.6, installed using command c…

ImportError: No module named ‘spacy.en’

I’m working on a codebase that uses Spacy. I installed spacy using: and then At the end of this last command, I got a message: Now, when I try running my code, on the line: it gives me the following error: I’ve looked on Stackexchange and the closest is: Import error with spacy: “No module n…