Example #1
0
 def test_environmental(self):
     from dplace_app.load.environmental import (
         load_environmental_var, load_environmental,
     )
     res = load_environmental([self.get_dict(Source='EA')])
     self.assertEqual(res, 0)
     res = load_environmental_var(csv_dict_reader(data_path('envvariables.csv')))
     self.assertEqual(res, 3)
     row_dict = self.get_dict(
         dataset='EA',
         soc_id='EA12',
         xd_id='xd1',
         soc_name='Example EA Society',
         alternate_names='Example',
         main_focal_year='2016')
     load_societies([row_dict])
     res = load_environmental([self.get_dict(**{
         'Source': 'EA',
         'soc_ID': 'EA12',
         'AnnualMeanTemperature': 1,
         'AnnualTemperatureVariance': 1,
         'longitude': 1,
         'latitude': 1,
     })])
     self.assertEqual(res, 1)
Example #2
0
 def test_environmental(self):
     from dplace_app.load.environmental import (
         load_environmental_var, load_environmental,
     )
     res = load_environmental([self.get_dict(Dataset='EA')])
     self.assertEqual(res, 0)
     res = load_environmental_var(csv_dict_reader(data_path('envvariables.csv')))
     self.assertEqual(res, 3)
     load_societies(csv_dict_reader(data_path('societies.csv')))
     res = load_environmental(csv_dict_reader(data_path('envdata.csv')))
     self.assertEqual(res, 2)
Example #3
0
 def test_environmental(self):
     from dplace_app.load.environmental import (
         load_environmental_var,
         load_environmental,
     )
     res = load_environmental([self.get_dict(Dataset='EA')])
     self.assertEqual(res, 0)
     res = load_environmental_var(
         csv_dict_reader(data_path('envvariables.csv')))
     self.assertEqual(res, 3)
     load_societies(csv_dict_reader(data_path('societies.csv')))
     res = load_environmental(csv_dict_reader(data_path('envdata.csv')))
     self.assertEqual(res, 2)
Example #4
0
    def test_environmental(self):
        from dplace_app.load.environmental import (
            create_environmental_variables, load_environmental,
        )

        res = load_environmental([self.get_dict(Source='EA')])
        self.assertEqual(res, 0)
        row_dict = self.get_dict(
            dataset='EA',
            soc_id='EA12',
            xd_id='xd1',
            soc_name='Example EA Society',
            alternate_names='Example',
            main_focal_year='2016')
        load_societies([row_dict])
        res = load_environmental([self.get_dict(**{
            'Source': 'EA',
            'ID': 'EA12',
            'Orig.longitude': 1,
            'Orig.latitude': 1,
            'longitude': 1,
            'latitude': 1,
        })])
        self.assertEqual(res, 1)
Example #5
0
    def setUp(self):
        sources._SOURCE_CACHE = {}
        load_regions(data_path('regions.geojson'))
        load_environmental_var(csv_dict_reader(data_path('envvariables.csv')))
        load_vars(csv_dict_reader(data_path('variables.csv')))
        source_ea = Source.objects.get(name='Ethnographic Atlas')
        load_codes(csv_dict_reader(data_path('codes.csv')))

        family1 = self.set(LanguageFamily, 1, name='family1')
        family2 = self.set(LanguageFamily, 2, name='family2')
        iso_code = self.set(ISOCode, 1, iso_code='abc')
        language1 = self.set(Language,
                             1,
                             name='language1',
                             family=family1,
                             glotto_code='aaaa1234',
                             iso_code=iso_code)
        language2 = self.set(Language,
                             2,
                             name='language2',
                             family=family2,
                             glotto_code='dddd1234')
        language3 = self.set(Language,
                             3,
                             name='language3',
                             family=family2,
                             glotto_code='cccc1234',
                             iso_code=iso_code)
        tree1 = self.set(
            LanguageTree,
            1,
            newick_string='((aaaa1234:1,abc:1,abun1254:1)abun1252:1);',
            name='tree',
            source=source_ea)
        tree2 = self.set(
            LanguageTree,
            2,
            newick_string='((aaaa1234:1,abc:1,abun1254:1)abun1252:1);',
            name='tree.glotto.trees',
            source=source_ea)

        label1 = self.set(LanguageTreeLabels,
                          1,
                          languageTree=tree1,
                          label='aaaa1234',
                          language=language1)
        label2 = self.set(LanguageTreeLabels,
                          2,
                          languageTree=tree1,
                          label='abun1254',
                          language=language2)
        label3 = self.set(LanguageTreeLabels,
                          3,
                          languageTree=tree2,
                          label='abun1252',
                          language=language3)
        tree1.taxa.add(label1)
        tree1.taxa.add(label2)
        tree2.taxa.add(label3)

        society1 = self.set(
            Society,
            1,
            ext_id='society1',
            xd_id='xd1',
            name='Söciety1',
            region=GeographicRegion.objects.get(region_nam='Region1'),
            source=source_ea,
            language=language1,
            focal_year='2016',
            alternate_names='Society 1')
        society2 = self.set(
            Society,
            2,
            ext_id='society2',
            xd_id='xd2',
            region=GeographicRegion.objects.get(region_nam='Region2'),
            name='Society2',
            source=source_ea,
            language=language2)
        # Society 3 has the same language characteristics as society 1
        # but different EA Vars
        self.set(Society,
                 3,
                 ext_id='society3',
                 xd_id='xd1',
                 region=GeographicRegion.objects.get(region_nam='Region1'),
                 name='Society3',
                 source=source_ea,
                 language=language3)

        sequenceLabel1 = self.set(LanguageTreeLabelsSequence,
                                  1,
                                  society=society1,
                                  labels=label1,
                                  fixed_order=0)
        sequenceLabel2 = self.set(LanguageTreeLabelsSequence,
                                  2,
                                  society=society1,
                                  labels=label2,
                                  fixed_order=0)
        sequenceLabel3 = self.set(LanguageTreeLabelsSequence,
                                  3,
                                  society=society2,
                                  labels=label3,
                                  fixed_order=0)
        sequenceLabel4 = self.set(LanguageTreeLabelsSequence,
                                  4,
                                  society=society2,
                                  labels=label3,
                                  fixed_order=1)

        load_data(csv_dict_reader(data_path('data.csv')))
        load_environmental(csv_dict_reader(data_path('envdata.csv')))
Example #6
0
    def setUp(self):
        sources._SOURCE_CACHE = {}
        load_regions(data_path('regions.geojson'))
        load_environmental_var(csv_dict_reader(data_path('envvariables.csv')))
        load_vars(csv_dict_reader(data_path('variables.csv')))
        source_ea = Source.objects.get(name='Ethnographic Atlas')
        load_codes(csv_dict_reader(data_path('codes.csv')))

        family1 = self.set(LanguageFamily, 1, name='family1')
        family2 = self.set(LanguageFamily, 2, name='family2')
        iso_code = self.set(ISOCode, 1, iso_code='abc')
        language1 = self.set(
            Language, 1,
            name='language1', family=family1, glotto_code='aaaa1234', iso_code=iso_code)
        language2 = self.set(
            Language, 2,
            name='language2', family=family2, glotto_code='dddd1234')
        language3 = self.set(
            Language, 3,
            name='language3', family=family2, glotto_code='cccc1234', iso_code=iso_code)    
        tree1 = self.set(
            LanguageTree, 1,
            newick_string='((aaaa1234:1,abc:1,abun1254:1)abun1252:1);',
            name='tree',
            source=source_ea)
        tree2 = self.set(
            LanguageTree, 2,
            newick_string='((aaaa1234:1,abc:1,abun1254:1)abun1252:1);',
            name='tree.glotto.trees',
            source=source_ea)

        label1 = self.set(
            LanguageTreeLabels, 1,
            languageTree=tree1, label='aaaa1234',
            language=language1
        )
        label2 = self.set(
            LanguageTreeLabels, 2, 
            languageTree=tree1, label='abun1254',
            language=language2
        )
        label3 = self.set(
            LanguageTreeLabels, 3,
            languageTree=tree2, label='abun1252',
            language=language3
        )
        tree1.taxa.add(label1)
        tree1.taxa.add(label2)
        tree2.taxa.add(label3)

        society1 = self.set(
            Society, 1,
            ext_id='society1',
            xd_id='xd1',
            name='Söciety1',
            region=GeographicRegion.objects.get(region_nam='Region1'),
            source=source_ea,
            language=language1,
            focal_year='2016',
            alternate_names='Society 1')
        society2 = self.set(
            Society, 2,
            ext_id='society2',
            xd_id='xd2',
            region=GeographicRegion.objects.get(region_nam='Region2'),
            name='Society2',
            source=source_ea,
            language=language2)
        # Society 3 has the same language characteristics as society 1
        # but different EA Vars
        self.set(
            Society, 3,
            ext_id='society3',
            xd_id='xd1',
            region=GeographicRegion.objects.get(region_nam='Region1'),
            name='Society3',
            source=source_ea,
            language=language3)

        sequenceLabel1 = self.set(
            LanguageTreeLabelsSequence, 1,
            society = society1, labels = label1,
            fixed_order=0
        )
        sequenceLabel2 = self.set(
            LanguageTreeLabelsSequence, 2,
            society = society1, labels = label2,
            fixed_order=0
        )
        sequenceLabel3 = self.set(
            LanguageTreeLabelsSequence, 3,
            society = society2, labels = label3,
            fixed_order=0
        )
        sequenceLabel4 = self.set(
            LanguageTreeLabelsSequence, 4,
            society = society2, labels = label3,
            fixed_order=1
        )

        load_data(csv_dict_reader(data_path('data.csv')))
        load_environmental(csv_dict_reader(data_path('envdata.csv')))