Mocking a failing module import in Python

Published: Feb. 11, 2021

When testing Python code, one sometimes has to imitate a broken or missing module. In a specific example, the pywin32 package requires running a post-installation script with administrator privileges after initial installation. Importing, for example, the win32security module of pywin32 may throw an ImportError if the postinstallation script wasn't executed. Packages that depend on pywin32 may want to handle this situation gracefully so that users who just pip install mypackage get only a soft failure or at least a helpful error message. If one wants to test this behavior in continuous integration and get code coverage, the ImportError has to be triggered even if pywin32 is installed correctly. Here is a short example that mimicks a broken or missing package with pytest and monkeypatch, since I didn't find this elsewhere:

Continue reading

Comments: Be first to comment!

Calculate unique connecting vectors for point cloud using numpy

Published: Jan. 26, 2019
This article explains how to calculate a list of all vectors for unique pairings that connect the points, without the inverse and without the connection to itself, using numpy.

Continue reading

Comments: Comments are closed.

Should kids be vaccinated?

Published: March 28, 2015
Earlier today I checked my daughter's vaccination record. Continue reading to find out why this made me happy from the bottom of my heart.

Continue reading

Comments: Comments are closed.

Mass-backup for CDs and DVDs on Linux

Published: Jan. 4, 2015
Tags: / /
Here's a little shell script to create backups from many removable discs in a row. The only user interaction in the loop is to change the disc and close the tray. The script waits each time until a new disc is inserted.

Continue reading

Comments: Comments are closed.

Bonding ceramic sputter targets to metal holders

Published: Oct. 13, 2014

Bonding ceramic sputter targets to metal holders

Ceramic sputter targets often need to be bonded to a metallic carrier. The better this bond provides mechanical, electrical and thermal contact, the better and longer the target works. This article describes indium soldering, the method that worked best during my PhD work where I used high-pressure oxygen sputtering extensively. The text is partly adapted from my PhD thesis.

Continue reading

Category: Materials Comments: Comments are closed.

Stealing is the best way to choose house plants

Published: Sept. 12, 2014
Tags: /

Stealing is the best way to choose house plants

My grandma once told me that giving plants as gifts is bad luck. She said that plants have to be bought or best stolen. For a long time I was puzzled by that. But in fact, there's a simple, logical explanation. Find out why my grandma was right!

Continue reading

Category: Plants Comments: Comments are closed.

Software can be changed!

Published: May 20, 2013
Part of my current work as a product manager is to make sure our software caters to the needs of various user groups. That means I observe what people do and how they do it in order to figure out what could be improved. Doing that I noticed a fundamental difference between users and software developers: Users are not used to modify software! Read more on how to improve the situation.

Continue reading

Comments: Comments are closed.

Why LaTeX?

Published: Feb. 20, 2013

Many scientists swear by LaTeX, while others prefer Word or LibreOffice. I personally use LaTeX for any serious scientific writing. But for which reasons do people use LaTeX?

Continue reading

Comments: Comments are closed.

Science 2.0: Blog system that supports scientific articles

Published: Feb. 20, 2013
For a long time it has been difficult to include special formatting like mathematical or chemical formulae, footnotes, figures with numbers, and reference lists in HTML documents. Alex and Gundula Clausen implemented these features for this blog in a way similar to LaTeX. Scientific articles can therefore be presented as blog articles and not only provided as PDF downloads. This is in my opinion the future of scientific publishing.

Continue reading

Comments: Comments are closed.

Variable resistor made by repeated steps of epitaxial deposition and lithographic structuring of oxide layers by using wet chemical etchants

Published: Jan. 22, 2013

Variable resistors were constructed from epitaxial $\ce{SrRuO3}$ (SRO), $\ce{La_{0.67}Sr_{0.33}MnO3}$ (LSMO) and $\ce{SrTiO3}$ layers with perovskite crystal structure. Each layer was patterned separately by lithographic methods. Optimized wet chemical etchants and several polishing steps in organic solvents allowed good epitaxy of subsequent layers, comparable to epitaxy on pristine substrates. Periodate as the oxidizing agent for SRO and iodide with ascorbic acid as the reducing agents for LSMO were used to attack these chemically resistant oxides. The final devices changed their conductance in a similar manner to previously described variable resistors that were defined with shadow masks.

This article was originally published in Thin Solid Films (2013)

Continue reading

Category: Journal article Comments: 1 comment