Skip to content

Tag: python

Delete all zeros slices from 4d numpy array

I pretend to remove slices from the third dimension of a 4d numpy array if it’s contains only zeros. I have a 4d numpy array of dimensions [256,256,336,6] and I need to delete the slices in the third dimension that only contains zeros. So the result would have a shape like this , e.g. [256,256,300,6] if…

Issue with lookup(‘dig’) not finding ‘dnspython’

On a Red Hat 8.3 machine I try to use this ansible code: But I get an error: I think maybe the lookup(‘dig’) doesn’t search in the right place… However I think I do in fact have dnspython installed: More info: Answer Converting comment to answer. When you use the pip3 command it refere…

How to iterate dict in string.format

I read a lot of tutorials, but can not find how to iterate dict in string.format like this: which I want a result like this: so I can print variable length dict. Then I got error. Answer Currently your output is: That’s because k for k,v in dict is a generator expression. Don’t confuse it with set…