Esempio n. 1
0
    def variables(self):
        l = []
        for name in self._dataset.variables:
            var = self._dataset.variables[name]
            if 'long_name' in var.ncattrs():
                long_name = var.long_name
            else:
                long_name = name

            if 'units' in var.ncattrs():
                units = var.units
            else:
                units = None

            if 'valid_min' in var.ncattrs():
                valid_min = float(
                    re.sub(r"[^0-9\.\+,eE]", "", str(var.valid_min)))
                valid_max = float(
                    re.sub(r"[^0-9\,\+,eE]", "", str(var.valid_max)))
            else:
                valid_min = None
                valid_max = None

            l.append(
                Variable(name, long_name, units, var.dimensions, valid_min,
                         valid_max))

        return VariableList(l)
Esempio n. 2
0
    def test_variable(self):
        v = Variable()
        self.assertEqual(0, v.value().as_number())
        self.assertEqual("", v.value().as_string())

        v.deserialize(
            ElementTree.XML(
                '<variable name="foo"><l>hello world</l></variable>'))
        self.assertEqual(v.name, "foo")
        self.assertEqual("hello world", v.value().as_string())
        self.assertEqual(v.contents, Literal("hello world"))
Esempio n. 3
0
    def test_variable(self):
        v = Variable()
        self.assertEqual(0, v.value().as_number())
        self.assertEqual("", v.value().as_string())

        v.deserialize(
            ElementTree.XML('<variable name="foo"><l>hello world</l></variable>'))
        self.assertEqual(v.name, "foo")
        self.assertEqual("hello world", v.value().as_string())
        self.assertEqual(v.contents, Literal("hello world"))
Esempio n. 4
0
 def test_variables_repr(self):
     v = Variables(
         OrderedDict([('x', Variable('x', Literal(47.0))),
                      ('y', Variable('y', Literal(52.0)))]))
     self.assertEqual(v, eval(repr(v)))
Esempio n. 5
0
 def test_variable_repr(self):
     x = Variable("name", Literal("val"))
     self.assertEqual(x, eval(repr(x)))
Esempio n. 6
0
    # kontrola zasobniku lokalnich ramcu
    LF_index = len(LF_var_list) - 1  # ulozeni indexu ramce
    lf_exists = False
    curr_LF = []  # inicializace prazdneho LF ramce
    # kontrola existence ramce
    if LF_index >= 0:
        lf_exists = True
        curr_LF = LF_var_list[LF_index].get_lf_list()

    inst = inst_list.get_inst()

    # INSTRUCTIONS

    if inst == 'DEFVAR':
        var = Variable()
        var.set_name_frame(inst_list.get_arg1())

        if var.frame == 'GF':
            for _var in var_list:
                if _var.full_name == inst_list.get_arg1():
                    print("Redefinice promenne", inst_list.get_arg1(), file=sys.stderr)
                    exit(52)
            var_list.append(var)

        if var.frame == 'LF':
            if LF_index < 0:
                print("Rámec LF neexistuje.", file=sys.stderr)
                exit(55)
            else:
                for _var in curr_LF: