> That does not seem to work, gx's shape differes from test to test. I'm -1 adding an array2 here only to use empty_like.

I am not sure if I get what you mean, but you could simply replace
np.zero by np.empty, and it seems to me that the code would do the same
thing.