我正在研究一个涉及RHEL 6.3(x86_64)系统上的网络消息队列(msgpack,zmq,...)的项目.我正在安装最新的glib,gevent,pygobject,pygtk等软件包,以便让pylab/matplotlib工作(这也没有成功).
放弃后我回到我的代码,不知怎的,我设法破坏了我的hdf5/h5py安装 - h5py在导入时无法找到libhdf5.so.7.我立即在RHEL 6.3(x86_64)上的/ usr/local/hdf5中重新安装了hdf5-1.8.9,如下所示:
./configure --prefix=/usr/local/hdf5
make
make check
sudo make install
make check install
Run Code Online (Sandbox Code Playgroud)
这似乎工作得很好.然后我去重新安装h5py(在python 2.7.3中):
python2.7 setup.py build --hdf5=/usr/local/hdf5/
python2.7 setup.py test # optional
# sudo python2.7 setup.py install
Run Code Online (Sandbox Code Playgroud)
无法在测试中导入_errors文件,如下所示:
======================================================================
ERROR: _hl.tests.test_attrs_data (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: _hl.tests.test_attrs_data
Traceback (most recent call last):
File "/usr/local/lib/python2.7/unittest/loader.py", line 252, in _find_tests
module = self._get_module_from_name(name)
File "/usr/local/lib/python2.7/unittest/loader.py", line 230, in _get_module_from_name
__import__(name)
File "/home/cronburg/Downloads/h5py-2.0.1/build/lib.linux-x86_64-2.7/h5py/_hl/tests/test_attrs_data.py", line 5, in <module>
import h5py
File "/home/cronburg/Downloads/h5py-2.0.1/build/lib.linux-x86_64-2.7/h5py/__init__.py", line 1, …Run Code Online (Sandbox Code Playgroud) 我有一个大型的C项目,必须用gcc编译.所以我将主可执行文件链接到这样的文件:
#include <HsFFI.h>
static void my_enter(void) __attribute__((constructor));
static void my_enter(void) {
static char *argv[] = { "Pointer.exe", 0 };
//static char *argv[] = { "Pointer.exe", "+RTS", "-N", "-p", "-s", "-h", "-i0.1", "-RTS", 0 };
static char **argv_ = argv;
static int argc = 1; // 8 for profiling
hs_init(&argc, &argv_);
//hs_init_with_rtsopts(&argc, &argv_);
}
static void my_exit(void) __attribute__((destructor));
static void my_exit(void) { hs_exit(); }
Run Code Online (Sandbox Code Playgroud)
它按预期工作 - GHC运行时系统初始化,我能够使用FFI从C调用Haskell代码.
然后,我尝试Debug.Trace使用"+RTS", "-N", "-p", "-s", "-h", "-i0.1", "-RTS"上面注释掉的行上的标志启用分析(主要用于堆栈跟踪)和代码覆盖(HPC).但是我在初始化期间收到有关线程和分析的错误消息:
Pointer.exe: the flag …Run Code Online (Sandbox Code Playgroud) 如何在h5py中绕过磁盘I/O?目前我必须做这样的事情:
msg = socket.recv()
fp = open("tmp.hdf5", 'wb')
fp.write(msg)
fp.close()
f = h5py.File('tmp.hdf5', 'r')
... # alter the file
fp = open("tmp.hdf5", 'rb')
msg = fp.read()
msg = f.toString()
socket.send(data)
Run Code Online (Sandbox Code Playgroud)
我想做这样的事情:
msg = socket.recv()
f = h5py.File(msg, driver='core')
... # alter the file
msg = f.toString()
socket.send(msg)
Run Code Online (Sandbox Code Playgroud)
我的问题是速度 - 磁盘I/O是一个巨大的瓶颈.是否有一种快速简便的方法来创建h5py File对象字符串,然后将该文件解压缩为字符串?如果涉及它,我愿意选择像Cython这样的东西......
下面FooA明确地使用类型in (#)和in queryPcompiles如预期的那样:
{-# LANGUAGE RankNTypes, ScopedTypeVariables #-}
module Foo where
class Foo a where
newtype FooParser a = FooParser { (#) :: FooA -> (a, FooA) }
queryP :: (FooA -> a) -> FooParser a
queryP f = FooParser $ \(b :: FooA) -> (f b, b)
data FooA = FooA Int
instance Foo FooA where
Run Code Online (Sandbox Code Playgroud)
但是当我尝试像这样定义FooParser和queryP使用类型Foo类时:
{-# LANGUAGE RankNTypes, ScopedTypeVariables #-}
module Foo where
class Foo a where …Run Code Online (Sandbox Code Playgroud) 有没有更好的方法可以fs'使用函子或应用程序来编写以下函数?
fncnB = (* 2)
fncnA = (* 3)
fs' fs = zip (map (fncnA . fst) fs) $ map (fncnB . snd) fs
Run Code Online (Sandbox Code Playgroud)
我从这个问题中看到,我可以依靠列表的函子实例来映射作用在每个元组的两个元素上的单个函数,或者例如在元组的应用实例上将函数仅应用于二元组的后半部分,但我很好奇函子和应用程序如何适合对多组分数据类型列表进行操作的图片。
haskell ×3
h5py ×2
hdf5 ×2
python ×2
applicative ×1
ffi ×1
functor ×1
ghc ×1
importerror ×1
typeclass ×1