5

I'm computing a polyfit multiple times during a program, and some of my inputs are np.nan and are going to get the algorithm problems. I know this, and in this application I don't care.

When things mess up, this is printed to the console:

Intel MKL ERROR: Parameter 4 was incorrect on entry to DELSD.

I simply want to suppress this error. I've already tried:

import warnings
warnings.simplefilter('ignore', np.RankWarning)
warnings.simplefilter('ignore', np.ComplexWarning)
warnings.filterwarnings('ignore', "Intel MKL ERROR")

Which suppresses some warnings, but not the Intel MKL one. I simply want to keep it from printing in the console (since it breaks up the other status messages I'm printing).

The following should trigger the problem:

import numpy as np
def line_fit(R, X):
    num_rows = np.shape(R)[0]
    p = np.zeros(num_rows)
    for i in range(num_rows):
        temp = np.polyfit(R[i, :], X[i, :], 1)
        p[i] = temp[1]
    return p
temp = np.array((((198.652-76.1781j),(132.614-43.8134j),(115.042-41.2485j),(91.7754-39.1649j),(78.8538-37.389j),(67.8769-34.6342j)),
((np.nan),(1671.79-796.522j),(1206.44-824.202j),(654.572-682.673j),(438.175-559.025j),(303.624-452.122j)),
((np.nan-1j*np.nan),(1671.32-794.931j),(1198.71-803.533j),(649.574-624.276j),(443.286-530.36j),(308.609-438.738j))))
R = np.real(temp)
X = np.imag(temp)
coeff = line_fit(R, X)

Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)], NumPy 1.8.0

schodge
  • 891
  • 2
  • 16
  • 29
  • I assume you're using the MKL-linked numpy from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy? – MattDMo Jun 11 '14 at 22:03
  • I think so. Not sure if there's a way to check that (`numpy.__version__` offers no clue), I'm using WinPython and I'm not compiling anything myself. – schodge Jun 11 '14 at 22:26
  • I ran your sample on my ubuntu 12.10 python 2.7.3 numpy 1.8.0, compiled with GCC, and the error looks a little bit clearer : "ValueError: On entry to DLASCL parameter number 4 had an illegal value" -- Hope this may help you. – Louis Jun 12 '14 at 06:16
  • Thanks. Definitely doesn't like the nan. I tried `warnings.simplefilter('ignore', ValueError)` just now, but that doesn't suppress it. There must be some way to keep stuff from being written to the console... ? – schodge Jun 12 '14 at 17:31
  • The Intel MKL Error error went away for me after I followed the solution [here](https://stackoverflow.com/a/70571114/12865125) – Spirit of the Void Jan 03 '22 at 20:41

2 Answers2

3

The error

Intel MKL ERROR: Parameter 4 was incorrect on entry to DELSD

occurs when you have Nan or Inf value in your input. Please check and impute it.

Nim J
  • 993
  • 2
  • 9
  • 15
2

If a function decides to print an error message directly to stdout/stderr without using the normal Python error reporting mechanism (i.e. exception handling and warnings), there's little you can do to stop it from doing so. If it really annoys you, you can apparently suppress writing to stderr altogether. There is a solution in another SO question as to how to do it temporarily (e.g. just for this function): Suppress stdout / stderr print from Python functions. Obviously if you do this, you're also going to miss all the relevant outputs from this function, too, so use it with caution.

Community
  • 1
  • 1
Jsl
  • 842
  • 1
  • 5
  • 10