本文整理汇总了Python中h5py.get_config方法的典型用法代码示例。如果您正苦于以下问题:Python h5py.get_config方法的具体用法?Python h5py.get_config怎么用?Python h5py.get_config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类h5py
的用法示例。
在下文中一共展示了h5py.get_config方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mpi
# 需要导入模块: import h5py [as 别名]
# 或者: from h5py import get_config [as 别名]
def mpi(self):
"""
Returns a named tuple with ``comm``, ``rank``, ``size``, and ``MPI``
if run with MPI and ``False`` otherwise.
"""
# Simple cache as this is potentially accessed a lot.
if hasattr(self, "__is_mpi"):
return self.__is_mpi
if self.__force_mpi is True:
self.__is_mpi = True
elif self.__force_mpi is False:
self.__is_mpi = False
else:
self.__is_mpi = is_mpi_env()
# If it actually is an mpi environment, set the communicator and the
# rank.
if self.__is_mpi:
# Check if HDF5 has been complied with parallel I/O.
c = h5py.get_config()
if not hasattr(c, "mpi") or not c.mpi:
is_parallel = False
else:
is_parallel = True
if not is_parallel:
msg = (
"Running under MPI requires HDF5/h5py to be complied "
"with support for parallel I/O."
)
raise RuntimeError(msg)
import mpi4py
# This is not needed on most mpi4py installations.
if not mpi4py.MPI.Is_initialized():
mpi4py.MPI.Init()
# Set mpi tuple to easy class wide access.
mpi_ns = collections.namedtuple(
"mpi_ns", ["comm", "rank", "size", "MPI"]
)
comm = mpi4py.MPI.COMM_WORLD
self.__is_mpi = mpi_ns(
comm=comm, rank=comm.rank, size=comm.size, MPI=mpi4py.MPI
)
return self.__is_mpi
示例2: get_watermark
# 需要导入模块: import h5py [as 别名]
# 或者: from h5py import get_config [as 别名]
def get_watermark():
"""
Return information about the current system relevant for pyasdf.
"""
vendor = MPI.get_vendor() if MPI else None
c = h5py.get_config()
if not hasattr(c, "mpi") or not c.mpi:
is_parallel = False
else:
is_parallel = True
watermark = {
"python_implementation": platform.python_implementation(),
"python_version": platform.python_version(),
"python_compiler": platform.python_compiler(),
"platform_system": platform.system(),
"platform_release": platform.release(),
"platform_version": platform.version(),
"platform_machine": platform.machine(),
"platform_processor": platform.processor(),
"platform_processor_count": cpu_count(),
"platform_architecture": platform.architecture()[0],
"platform_hostname": gethostname(),
"date": strftime("%d/%m/%Y"),
"time": strftime("%H:%M:%S"),
"timezone": strftime("%Z"),
"hdf5_version": h5py.version.hdf5_version,
"parallel_h5py": is_parallel,
"mpi_vendor": vendor[0] if vendor else None,
"mpi_vendor_version": ".".join(map(str, vendor[1]))
if vendor
else None,
"problematic_multiprocessing": is_multiprocessing_problematic(),
}
watermark["module_versions"] = {
module: get_distribution(module).version for module in modules
}
if MPI is None:
watermark["module_versions"]["mpi4py"] = None
return watermark