예제 #1
0
    def test_material2Tags_Alloys(self):
        target = Material2Tags()
        taxonomy = target.get_classes("SrFeCu0.2")

        assert len(taxonomy.keys()) == 1
        assert list(taxonomy.keys())[0] == 'Alloys'
        assert len(taxonomy['Alloys']) == 0
예제 #2
0
    def test_material2Tags_Oxide(self):
        target = Material2Tags()
        taxonomy = target.get_classes("LaFeO2")

        assert len(taxonomy.keys()) == 1
        assert list(taxonomy.keys())[0] == 'Oxides'
        assert len(taxonomy['Oxides']) == 1
        assert taxonomy['Oxides'][0] == 'Transition Metal-Oxides'
예제 #3
0
    def test_material2Tags_mixedCombinations(self):
        target = Material2Tags()
        taxonomy = target.get_classes("CsFe2As2")

        assert len(taxonomy.keys()) == 2
        first_level = sorted(list(taxonomy.keys()))
        assert first_level[0] == 'Iron-pnictides'
        assert first_level[1] == 'Pnictides'
        assert len(taxonomy['Iron-pnictides']) == 0
        assert len(taxonomy['Pnictides']) == 0
예제 #4
0
    def test_material2Tags_mixedCombinations_0(self):
        target = Material2Tags()
        taxonomy = target.get_classes("CuFrO2")

        assert len(taxonomy.keys()) == 2
        first_level = sorted(list(taxonomy.keys()))
        assert first_level[0] == 'Cuprates'
        assert first_level[1] == 'Oxides'
        assert len(taxonomy['Oxides']) == 1
        assert len(taxonomy['Cuprates']) == 0
예제 #5
0
class MaterialParserWrapper:
    # mp = MaterialParser()
    material2class = Material2Class()
    material2tags = Material2Tags()

    # def formula_to_composition(self, formula):
    #     composition = self.mp.formula2composition(formula)
    #
    #     if 'elements' in composition:
    #         return composition
    #
    #     else:
    #         return {}
    #
    def formula_to_class(self, formula):
        return self.material2class.get_class(formula)

    def formula_to_classes(self, formula):
        return self.material2tags.get_classes(formula)