Monkey-patch UmfpackContext __del__

By putting the failing statement in a try: except: clause, the
exception is caught and the error message is silenced.

See
https://groups.google.com/d/msg/scikit-image/FrM5IGP6wh4/1hp-FtVZmfcJ
and
http://stackoverflow.com/questions/13977970/ignore-exceptions-printed-to-stderr-in-del/13977992?noredirect=1#comment28386412_13977992
This commit is contained in:
Juan Nunez-Iglesias
2013-10-05 14:27:51 +10:00
parent a15312e3c8
commit fc15f75f8d
@@ -9,14 +9,25 @@ significantly the performance.
"""
import warnings
import sys
import os
import numpy as np
from scipy import sparse, ndimage
try:
from scipy.sparse.linalg.dsolve import umfpack
old_del = umfpack.UmfpackContext.__del__
def new_del(self):
try:
old_del(self)
except AttributeError:
pass
umfpack.UmfpackContext.__del__ = new_del
UmfpackContext = umfpack.UmfpackContext()
except:
UmfpackContext = None
try:
from pyamg import ruge_stuben_solver
amg_loaded = True