nag4py导入错误:“cannot Import name INIT\u FAIL”

2024-10-03 06:30:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个脚本来计算特征值和向量而不需要平衡,我几乎每天都在使用它,这需要nag4py。代码在这个blog中:http://www.walkingrandomly.com/?p=5303,它有一个相关的SO post(How to use eig with the nobalance option as in MATLAB?)。你知道吗

昨天我升级了nag4py,现在在运行已经运行多年的同一个脚本时遇到以下错误:

from nag4py.util import Nag_RowMajor,Nag_NoBalancing,Nag_NotLeftVecs,Nag_RightVecs,Nag_RCondEigVecs,Integer,NagError,INIT_FAIL

ImportError: cannot import name INIT_FAIL

同时,我已经通过导入默认使用无平衡选项的倍频程解决了这个问题。但是我想用nag4py来解决这个问题。你知道吗

我已经测试了NAG许可证,它是有效的。你知道吗


Tags: 代码import脚本comhttpsoinitwww
1条回答
网友
1楼 · 发布于 2024-10-03 06:30:31

nag4py包的发布版本使用了“quiet\u fail”和“noise\u fail”,这两个版本在嵌入式文档中有记录:

Error or warning cases detected by the NAG C Library are handled in nag4py using a similar NagError mechanism as in the Library itself. The nag4py util module provides two convenience functions ('quiet_fail' and 'noisy_fail') to create a NagError instance with printing of messages disabled or enabled, respectively.

这是零钱:

Index: nag4py/util.py
===================================================================
 - nag4py/util.py  (revision 104707)
+++ nag4py/util.py  (revision 104708)
@@ -4736,14 +4736,20 @@
     return _arg


-def INIT_FAIL(fail):
+def quiet_fail():
+    "Returns a NagError instance with printing disabled."
+    fail = NagError()
     fail.eprint = Nag_FALSE
+    return fail

-def SET_FAIL(fail):
+def noisy_fail():
+    "Returns a NagError instance with printing enabled."
+    fail = NagError()
     fail.eprint = Nag_TRUE
+    return fail

-__all__.append("INIT_FAIL")
-__all__.append("SET_FAIL")
+__all__.append("quiet_fail")
+__all__.append("noisy_fail")

 def get_input_func():
     from sys import version_info

相关问题 更多 >