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


Python Dive.no_flight_time_wo_exception方法代码示例

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


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

示例1: TestRepetitiveDive1

# 需要导入模块: from dipplanner.dive import Dive [as 别名]
# 或者: from dipplanner.dive.Dive import no_flight_time_wo_exception [as 别名]
class TestRepetitiveDive1(TestDive):

    def setUp(self):
        TestDive.setUp(self)

        diveseg1 = SegmentDive(40, 20 * 60, self.airtank12, 0)
        self.profile0 = Dive([diveseg1], [self.airtank12])
        self.profile0.do_dive()

        diveseg2 = SegmentDive(40, 20 * 60, self.airtank, 0)
        self.profile1 = Dive([diveseg2], [self.airtank], self.profile0)
        self.profile1.do_surface_interval(20 * 60)
        self.profile1.do_dive()

    def test_rt(self):
        assert seconds_to_mmss(self.profile1.run_time) == ' 68:09', \
            'bad dive runtime ? (%s)' \
            % seconds_to_mmss(self.profile1.run_time)

    def test_otu(self):
        self.assertAlmostEqual(self.profile1.model.ox_tox.otu,
                               40.0702502936, 7, 'bad dive OTU ? (%s)'
                               % self.profile1.model.ox_tox.otu)

    def test_cns(self):
        self.assertAlmostEqual(self.profile1.model.ox_tox.cns * 100,
                               14.3091665925, 7, 'bad dive CNS ? (%s)'
                               % (self.profile1.model.ox_tox.cns * 100))

    def test_tank_cons(self):
        self.assertAlmostEqual(self.airtank12.used_gas, 2115.5196384,
                               7, 'bad used gas (%s)'
                               % self.airtank12.used_gas)

    def test_tank_cons_rule(self):
        self.assertEqual(self.profile1.tanks[0].check_rule(), True,
                         'Wrong tank status : it should pass the remaining '
                         'gas rule test (result:%s)'
                         % self.profile1.tanks[0].check_rule())

    def test_no_flight(self):
        no_flight_time = self.profile1.no_flight_time()
        self.assertEqual(no_flight_time, 5460, 'Bad no flight time: %s'
                         % no_flight_time)

    def test_no_flight_wo_exc(self):
        no_flight_time = self.profile1.no_flight_time_wo_exception()
        self.assertEqual(no_flight_time, 5460, 'Bad no flight time: %s'
                         % no_flight_time)

    def test_surfaceint(self):
        self.assertEqual(self.profile1.get_surface_interval(),
                         ' 20:00',
                         'wrong surface interval:%s'
                         % self.profile1.get_surface_interval())
开发者ID:hordurk,项目名称:dipplanner,代码行数:57,代码来源:dive_repetitive_air_test.py

示例2: main

# 需要导入模块: from dipplanner.dive import Dive [as 别名]
# 或者: from dipplanner.dive.Dive import no_flight_time_wo_exception [as 别名]
def main(cli_arguments=sys.argv):
    """main

    main uses the parameters, tanks and dives given in config file(s)
    and/or command line, calculates the dives and return the output in stdout.

    *Keyword Arguments:*
        arguments (list of string) -- list of arguments, like sys.argv

    *Return:*
        <nothing>

    *Raise:*
        <nothing>
    """
    if sys.version_info < (2, 7):
        raise SystemExit("ERROR: This programm needs python 2.7 or greater")

    activate_debug()

    # get the version
    try:
        version_file = open("RELEASE-VERSION", "r")
        try:
            version = version_file.readlines()[0]
            settings.__VERSION__ = version.strip()
        finally:
            version_file.close()
    except IOError:
        settings.__VERSION__ = "unknown"

    dipplanner_arguments = DipplannerCliArguments(cli_arguments)
    dives = dipplanner_arguments.dives

    profiles = []
    current_dive = None
    previous_dive = None
    for dive in dives:
        if previous_dive is None:
            current_dive = Dive(
                dives[dive]['segments'].values(),
                dives[dive]['tanks'].values())
        else:
            current_dive = Dive(
                dives[dive]['segments'].values(),
                dives[dive]['tanks'].values(),
                previous_dive
            )
        if dives[dive]['surface_interval']:
            current_dive.do_surface_interval(dives[dive]['surface_interval'])

        current_dive.do_dive_without_exceptions()
        profiles.append(current_dive)
        previous_dive = current_dive
        # now, dive exceptins do not stop the program anymore, but can be
        # displayed in the output template instead. The used MUST take care of
        # the result.

    # now calculate no flight time based on the last dive
    current_dive.no_flight_time_wo_exception()

    # now Prepare the output
    env = Environment(loader=PackageLoader('dipplanner', 'templates'))
    tpl = env.get_template(settings.TEMPLATE)
    text = tpl.render(settings=settings, dives=profiles)
    print text
开发者ID:hordurk,项目名称:dipplanner,代码行数:68,代码来源:main.py

示例3: TestRepetitiveDive3

# 需要导入模块: from dipplanner.dive import Dive [as 别名]
# 或者: from dipplanner.dive.Dive import no_flight_time_wo_exception [as 别名]
class TestRepetitiveDive3(TestDive):

    def setUp(self):
        TestDive.setUp(self)

        diveseg1 = SegmentDive(40, 20 * 60, self.airtank12, 0)
        self.profile0 = Dive([diveseg1], [self.airtank12])
        self.profile0.do_dive()

        diveseg2 = SegmentDive(30, 40 * 60, self.airtank, 0)
        self.profile1 = Dive([diveseg2], [self.airtank], self.profile0)
        self.profile1.do_surface_interval(30 * 60)
        self.profile1.do_dive()

        diveseg3 = SegmentDive(25, 35 * 60, self.airtank, 0)
        self.profile2 = Dive([diveseg3], [self.airtank], self.profile1)
        self.profile2.do_surface_interval(60 * 60)

        # self.profile2.refill_tanks()

        self.profile2.do_dive()

        diveseg4 = SegmentDive(40, 20 * 60, self.airtank, 0)
        self.profile3 = Dive([diveseg4], [self.airtank], self.profile2)
        self.profile3.do_surface_interval(12 * 60 * 60)

        # self.profile3.refill_tanks()

        self.profile3.do_dive()

    def test_rt(self):
        assert seconds_to_mmss(self.profile3.run_time) == ' 38:36', \
            'bad dive runtime ? (%s)' \
            % seconds_to_mmss(self.profile3.run_time)

    def test_otu(self):
        self.assertAlmostEqual(self.profile3.model.ox_tox.otu,
                               86.8657204829, 7, 'bad dive OTU ? (%s)'
                               % self.profile3.model.ox_tox.otu)

    def test_cns(self):
        self.assertAlmostEqual(self.profile3.model.ox_tox.cns * 100,
                               7.75546902304, 7, 'bad dive CNS ? (%s)'
                               % (self.profile3.model.ox_tox.cns * 100))

    def test_tank_cons(self):
        self.assertAlmostEqual(self.airtank.used_gas, 2115.5196384, 7,
                               'bad used gas (%s)'
                               % self.airtank.used_gas)

    def test_tank_cons_rule(self):
        self.assertEqual(self.profile3.tanks[0].check_rule(), True,
                         'Wrong tank status : it should pass the remaining '
                         'gas rule test (result:%s)'
                         % self.profile2.tanks[0].check_rule())

    def test_no_flight(self):
        no_flight_time = self.profile3.no_flight_time()
        self.assertEqual(no_flight_time, 1620, 'Bad no flight time: %s'
                         % no_flight_time)

    def test_no_flight_wo_exc(self):
        no_flight_time = self.profile3.no_flight_time_wo_exception()
        self.assertEqual(no_flight_time, 1620, 'Bad no flight time: %s'
        % no_flight_time)

    def test_surfaceint(self):
        self.assertEqual(self.profile3.get_surface_interval(),
                         '720:00',
                         'wrong surface interval:%s'
                         % self.profile3.get_surface_interval())
开发者ID:hordurk,项目名称:dipplanner,代码行数:73,代码来源:dive_repetitive_air_test.py

示例4: TestRepetitiveDive2

# 需要导入模块: from dipplanner.dive import Dive [as 别名]
# 或者: from dipplanner.dive.Dive import no_flight_time_wo_exception [as 别名]
class TestRepetitiveDive2(TestDive):

    def setUp(self):
        TestDive.setUp(self)

        diveseg1 = SegmentDive(40, 20 * 60, self.airtank12, 0)
        self.profile0 = Dive([diveseg1], [self.airtank12])
        self.profile0.do_dive()

        diveseg2 = SegmentDive(30, 40 * 60, self.airtank, 0)
        self.profile1 = Dive([diveseg2], [self.airtank], self.profile0)
        self.profile1.do_surface_interval(30 * 60)
        self.profile1.do_dive()

        diveseg3 = SegmentDive(25, 35 * 60, self.airtank, 0)
        self.profile2 = Dive([diveseg3], [self.airtank], self.profile1)
        self.profile2.do_surface_interval(60 * 60)

        # self.profile2.refill_tanks()

        self.profile2.do_dive()

    def test_rt(self):
        assert seconds_to_mmss(self.profile2.run_time) == ' 70:18', \
            'bad dive runtime ? (%s)' \
            % seconds_to_mmss(self.profile2.run_time)

    def test_otu(self):
        self.assertAlmostEqual(self.profile2.model.ox_tox.otu,
                               66.8427163401, 7, 'bad dive OTU ? (%s)'
                               % self.profile2.model.ox_tox.otu)

    def test_cns(self):
        self.assertAlmostEqual(self.profile2.model.ox_tox.cns * 100,
                               18.1490350581, 7, 'bad dive CNS ? (%s)'
                               % (self.profile2.model.ox_tox.cns * 100))

    def test_tank_cons(self):
        self.assertAlmostEqual(self.airtank.used_gas, 2701.73162947, 7,
                               'bad used gas (%s)'
                               % self.airtank.used_gas)

    def test_tank_cons_rule(self):
        self.assertEqual(self.profile2.tanks[0].check_rule(), True,
                         'Wrong tank status : it should pass the remaining '
                         'gas rule test (result:%s)'
                         % self.profile2.tanks[0].check_rule())

    def test_no_flight(self):
        no_flight_time = self.profile2.no_flight_time()
        self.assertEqual(no_flight_time, 18360, 'Bad no flight time: %s'
                         % no_flight_time)

    def test_no_flight_wo_exc(self):
        no_flight_time = self.profile2.no_flight_time_wo_exception()
        self.assertEqual(no_flight_time, 18360, 'Bad no flight time: %s'
                         % no_flight_time)

    def test_surfaceint(self):
        self.assertEqual(self.profile2.get_surface_interval(),
                         ' 60:00',
                         'wrong surface interval:%s'
                         % self.profile2.get_surface_interval())
开发者ID:hordurk,项目名称:dipplanner,代码行数:65,代码来源:dive_repetitive_air_test.py


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