How to use the f90nml.fpy.pybool function in f90nml

To help you get started, we’ve selected a few f90nml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marshallward / f90nml / tests / test_f90nml.py View on Github external
def test_pybool(self):
        for fstr_true in ('true', '.true.', 't', '.t.'):
            self.assertEqual(pybool(fstr_true), True)

        for fstr_false in ('false', '.false.', 'f', '.f.'):
            self.assertEqual(pybool(fstr_false), False)

        for fstr_true in ('ture', '.t'):
            self.assertEqual(pybool(fstr_true, strict_logical=False), True)

        for fstr_false in ('flase', '.f'):
            self.assertEqual(pybool(fstr_false, strict_logical=False), False)

        for fstr in ('ture', '.t', 'flase', '.f'):
            self.assertRaises(ValueError, pybool, fstr)

        for fstr in ('g', '.', 'xyz'):
            self.assertRaises(ValueError, pybool, fstr, strict_logical=False)
github marshallward / f90nml / tests / test_f90nml.py View on Github external
def test_pybool(self):
        for fstr_true in ('true', '.true.', 't', '.t.'):
            self.assertEqual(pybool(fstr_true), True)

        for fstr_false in ('false', '.false.', 'f', '.f.'):
            self.assertEqual(pybool(fstr_false), False)

        for fstr_true in ('ture', '.t'):
            self.assertEqual(pybool(fstr_true, strict_logical=False), True)

        for fstr_false in ('flase', '.f'):
            self.assertEqual(pybool(fstr_false, strict_logical=False), False)

        for fstr in ('ture', '.t', 'flase', '.f'):
            self.assertRaises(ValueError, pybool, fstr)

        for fstr in ('g', '.', 'xyz'):
            self.assertRaises(ValueError, pybool, fstr, strict_logical=False)
github marshallward / f90nml / tests / test_f90nml.py View on Github external
def test_pybool(self):
        for fstr_true in ('true', '.true.', 't', '.t.'):
            self.assertEqual(pybool(fstr_true), True)

        for fstr_false in ('false', '.false.', 'f', '.f.'):
            self.assertEqual(pybool(fstr_false), False)

        for fstr_true in ('ture', '.t'):
            self.assertEqual(pybool(fstr_true, strict_logical=False), True)

        for fstr_false in ('flase', '.f'):
            self.assertEqual(pybool(fstr_false, strict_logical=False), False)

        for fstr in ('ture', '.t', 'flase', '.f'):
            self.assertRaises(ValueError, pybool, fstr)

        for fstr in ('g', '.', 'xyz'):
            self.assertRaises(ValueError, pybool, fstr, strict_logical=False)
github marshallward / f90nml / tests / test_f90nml.py View on Github external
def test_pybool(self):
        for fstr_true in ('true', '.true.', 't', '.t.'):
            self.assertEqual(pybool(fstr_true), True)

        for fstr_false in ('false', '.false.', 'f', '.f.'):
            self.assertEqual(pybool(fstr_false), False)

        for fstr_true in ('ture', '.t'):
            self.assertEqual(pybool(fstr_true, strict_logical=False), True)

        for fstr_false in ('flase', '.f'):
            self.assertEqual(pybool(fstr_false, strict_logical=False), False)

        for fstr in ('ture', '.t', 'flase', '.f'):
            self.assertRaises(ValueError, pybool, fstr)

        for fstr in ('g', '.', 'xyz'):
            self.assertRaises(ValueError, pybool, fstr, strict_logical=False)
github marshallward / f90nml / f90nml / parser.py View on Github external
self._update_tokens(write_token)
            v_im = self.token

            self._update_tokens(write_token)
            assert self.token == ')'

            self._update_tokens(write_token, override)
            v_str = '({0}, {1})'.format(v_re, v_im)

        recast_funcs = [int, pyfloat, pycomplex, pybool, pystr]

        for f90type in recast_funcs:
            try:
                # Unclever hack.. integrate this better
                if f90type == pybool:
                    value = pybool(v_str, self.strict_logical)
                else:
                    value = f90type(v_str)
                return value
            except ValueError:
                continue