当前位置: 首页>>代码示例>>Python>>正文


Python MPICommons.myRank方法代码示例

本文整理汇总了Python中KMCLib.Backend.Backend.MPICommons.myRank方法的典型用法代码示例。如果您正苦于以下问题:Python MPICommons.myRank方法的具体用法?Python MPICommons.myRank怎么用?Python MPICommons.myRank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KMCLib.Backend.Backend.MPICommons的用法示例。


在下文中一共展示了MPICommons.myRank方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testPrettyPrint

# 需要导入模块: from KMCLib.Backend.Backend import MPICommons [as 别名]
# 或者: from KMCLib.Backend.Backend.MPICommons import myRank [as 别名]
    def testPrettyPrint(self):
        """ Test that we can call the pretty print function. """
        # Print to stdout.
        original_sys_stdout = sys.stdout
        try:
            stream_1   = StringIO.StringIO()
            sys.stdout = stream_1

            # Print to stdout.
            ref_str = "This is what we print"
            prettyPrint(ref_str)

            # Check.
            if MPICommons.myRank() == 0:
                ref_str = ref_str + "\n"
            else:
                ref_str = ""
            self.assertEqual(stream_1.getvalue(), ref_str)

        finally:
            # Put the original stdout back.
            sys.stdout = original_sys_stdout

        # Print to another stream.
        stream_2 = StringIO.StringIO()
        ref_str = "This is what we print next time."
        prettyPrint(ref_str, output=stream_2)

        # Check.
        if MPICommons.myRank() == 0:
            ref_str = ref_str + "\n"
        else:
            ref_str = ""

        self.assertEqual(stream_2.getvalue(), ref_str)
开发者ID:lmpizarro,项目名称:KMCLib,代码行数:37,代码来源:PrintUtilitiesTest.py

示例2: testPrintHeader

# 需要导入模块: from KMCLib.Backend.Backend import MPICommons [as 别名]
# 或者: from KMCLib.Backend.Backend.MPICommons import myRank [as 别名]
    def testPrintHeader(self):
        """ Test the print header function. """
        # Print to stdout.
        original_sys_stdout = sys.stdout

        try:
            stream_1   = StringIO.StringIO()
            sys.stdout = stream_1

            # Print to stdout.
            printHeader()

            # Check.
            if MPICommons.myRank() == 0:
                ref_str = """# -----------------------------------------------------------------------------
# KMCLib version 1.1.01
# Distributed under the GPLv3 license
# Copyright (C)  2012-2015  Mikael Leetmaa
# Developed by Mikael Leetmaa <[email protected]>
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# LICENSE and README files, and the source code, for details.
#
# You should have received a copy of the GNU General Public License version 3
# (GPLv3) along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------

"""
            else:
                ref_str = ""

            # Check.
            self.assertEqual(ref_str, stream_1.getvalue())

        finally:
            # Put the original stdout back.
            sys.stdout = original_sys_stdout

        # Print to another stream.
        stream_2 = StringIO.StringIO()
        prettyPrint(ref_str, output=stream_2)

        # Check.
        self.assertTrue(ref_str in stream_2.getvalue())
开发者ID:lmpizarro,项目名称:KMCLib,代码行数:48,代码来源:PrintUtilitiesTest.py


注:本文中的KMCLib.Backend.Backend.MPICommons.myRank方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。