小编Pet*_*ter的帖子

来自C#(使用SciPy)的IronPython调用因ImportException失败:"没有名为mtrand的模块"

我有一个python库,我试图通过来自C#应用程序的IronPython(v2.7 RC1 [2.7.0.30])调用来使用.该库非常广泛地使用NumPy和SciPy,当从命令行使用ipy运行时,它可以SciPy和NumPy for .NET一起使用,如下所示:

ipy.exe -X:Frames file_from_lib_importing_numpy.py
Run Code Online (Sandbox Code Playgroud)

但是,当我使用下面的代码从C#调用IronPython时,会抛出异常:

ImportException
"No module named mtrand"
   at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object value)
   at IronPython.Runtime.Operations.PythonOps.ImportStar(CodeContext context, String fullName, Int32 level)
   at Microsoft.Scripting.Interpreter.ActionCallInstruction3.Run(InterpretedFrame frame)
   ...
   at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)
   at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
   at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path)
   at Microsoft.Scripting.Hosting.ScriptRuntime.ExecuteFile(String path)
   at Microsoft.Scripting.Hosting.ScriptRuntime.UseFile(String path)
   ...
Run Code Online (Sandbox Code Playgroud)

调用IronPython的C#代码(它的一部分)如下:

    ScriptEngine _engine;

    var opts = new Dictionary<string, object>();
    opts["Frames"] = ScriptingRuntimeHelpers.True;
    _engine = Python.CreateEngine(opts);

    var sp = _engine.GetSearchPaths();
    sp.Add(@"c:\Program Files\IronPython 2.7");
    sp.Add(@"c:\Program Files\IronPython 2.7\DLLs");
    sp.Add(@"c:\Program Files\IronPython 2.7\Lib");
    sp.Add(@"c:\Program Files\IronPython …
Run Code Online (Sandbox Code Playgroud)

c# ironpython numpy scipy python.net

14
推荐指数
1
解决办法
7729
查看次数

Option [Int]的条件映射通过使用scalaz的函数对

我有一对,Option[Int]并希望找到这两个值中的最小值,如果它们都存在,否则只是其中之一.假设我有一个功能minOption:

def minOption(a: Option[Int], b: Option[Int]): Option[Int]
Run Code Online (Sandbox Code Playgroud)

我想要的是输入到输出的以下映射:

(Some(a), Some(b)) => Some(Math.min(a,b))
(Some(a), None) => Some(a)
(None, Some(b)) => Some(b)
(None, None) => None
Run Code Online (Sandbox Code Playgroud)

是否有捷径可寻?我无法想出使用嵌套模式匹配的明显方法.

我认为这应该是微不足道的scalaz,但我还不是很熟悉,也找不到办法.

scala scalaz

2
推荐指数
1
解决办法
269
查看次数

Ember-CLI测试不能包含'app'目录中的模块

我试图在我的应用程序中包含一个模块来自其中一个测试.甚至可以这样做吗?我只能在'tests'目录中包含一个模块.我一直得到臭名昭着的"找不到模块"错误.

http://localhost:4200/assets/test-support.js:5578:16: Could not find module d3graph/app/controllers/index imported from d3graph/tests/unit/utils/graph-helper-test

这是我的测试代码:

import { moduleFor, test }  from 'ember-qunit';
import Ember from 'ember';
import helper from '../../../app/anything/anywhere';  // <- THIS LINE FAILS

moduleFor('util:graph-helper', 'Graph Helper', {
  beforeEach: () => initialize()
});

function initialize() { /* something */ };

test('test desc', function(assert) {
  var testObj = this.subject();

  // test logic follows
});
Run Code Online (Sandbox Code Playgroud)

我确实尝试了对模块路径的各种修改,包括来自root的绝对路径,我甚至试过通过'require()',但唉没有成功.请帮忙.

ember.js ecmascript-6 ember-cli

1
推荐指数
1
解决办法
1166
查看次数

标签 统计

c# ×1

ecmascript-6 ×1

ember-cli ×1

ember.js ×1

ironpython ×1

numpy ×1

python.net ×1

scala ×1

scalaz ×1

scipy ×1