Пример #1
0
    def __init__(self, study=None, **kwargs):
        super(StudyEditorExtendedForm, self).__init__(study=study, **kwargs)

        # Populate the choices for the environmental packages
        # Get environmental packages returns a list of tuples of the form
        # (env package name, table name), but we need a list of
        # (table name, env package name) so the actual environmental package
        # name is displayed on the GUI
        self.environmental_packages.choices = [
            (name, name) for name, table in get_environmental_packages()
        ]

        # Get the available timeseries types to populate the timeseries field
        choices = [[time_id, '%s, %s' % (int_t, time_t)]
                   for time_id, time_t, int_t in get_timeseries_types()]
        # Change None, None to 'No timeseries', just for GUI purposes
        choices[0][1] = 'No timeseries'
        self.timeseries.choices = choices

        # If a study is provided, put its values in the form
        if study:
            study_info = study.info

            self.environmental_packages.data = study.environmental_packages
            self.timeseries.data = study_info['timeseries_type_id']
Пример #2
0
 def test_get_timeseries_types(self):
     obs = get_timeseries_types()
     exp = [[1, 'None', 'None'], [2, 'real', 'single intervention'],
            [3, 'real', 'multiple intervention'],
            [4, 'real', 'combo intervention'],
            [5, 'pseudo', 'single intervention'],
            [6, 'pseudo', 'multiple intervention'],
            [7, 'pseudo', 'combo intervention'],
            [8, 'mixed', 'single intervention'],
            [9, 'mixed', 'multiple intervention'],
            [10, 'mixed', 'combo intervention']]
     self.assertEqual(obs, exp)
Пример #3
0
 def test_get_timeseries_types(self):
     obs = get_timeseries_types()
     exp = [[1, 'None', 'None'],
            [2, 'real', 'single intervention'],
            [3, 'real', 'multiple intervention'],
            [4, 'real', 'combo intervention'],
            [5, 'pseudo', 'single intervention'],
            [6, 'pseudo', 'multiple intervention'],
            [7, 'pseudo', 'combo intervention'],
            [8, 'mixed', 'single intervention'],
            [9, 'mixed', 'multiple intervention'],
            [10, 'mixed', 'combo intervention']]
     self.assertEqual(obs, exp)
Пример #4
0
 def test_get_timeseries_types(self):
     obs = get_timeseries_types()
     exp = [
         [1, "None", "None"],
         [2, "real", "single intervention"],
         [3, "real", "multiple intervention"],
         [4, "real", "combo intervention"],
         [5, "pseudo", "single intervention"],
         [6, "pseudo", "multiple intervention"],
         [7, "pseudo", "combo intervention"],
         [8, "mixed", "single intervention"],
         [9, "mixed", "multiple intervention"],
         [10, "mixed", "combo intervention"],
     ]
     self.assertEqual(obs, exp)
Пример #5
0
    def __init__(self, study=None, **kwargs):
        super(StudyEditorExtendedForm, self).__init__(study=study, **kwargs)

        # Populate the choices for the environmental packages
        # Get environmental packages returns a list of tuples of the form
        # (env package name, table name), but we need a list of
        # (table name, env package name) so the actual environmental package
        # name is displayed on the GUI
        self.environmental_packages.choices = [
            (name, name) for name, table in get_environmental_packages()]

        # Get the available timeseries types to populate the timeseries field
        choices = [[time_id, '%s, %s' % (int_t, time_t)]
                   for time_id, time_t, int_t in get_timeseries_types()]
        # Change None, None to 'No timeseries', just for GUI purposes
        choices[0][1] = 'No timeseries'
        self.timeseries.choices = choices

        # If a study is provided, put its values in the form
        if study:
            study_info = study.info

            self.environmental_packages.data = study.environmental_packages
            self.timeseries.data = study_info['timeseries_type_id']