當前位置: 首頁>>代碼示例>>Python>>正文


Python h5py.get_config方法代碼示例

本文整理匯總了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 
開發者ID:SeismicData,項目名稱:pyasdf,代碼行數:52,代碼來源:asdf_data_set.py

示例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 
開發者ID:SeismicData,項目名稱:pyasdf,代碼行數:45,代碼來源:watermark.py


注:本文中的h5py.get_config方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。