"""
import pandas as pd
import numpy as np
from pyrolite.mineral.mindb import get_mineral
from pyrolite.mineral.normative import endmember_decompose

########################################################################################
# First we'll start with a composition of an unknown olivine:
#
comp = pd.Series({"MgO": 42.06, "SiO2": 39.19, "FeO": 18.75})
########################################################################################
# We can break this down into olivine endmebmers using the
# :func:`~pyrolite.mineral.transform.endmember_decompose` function:
#
ed = endmember_decompose(pd.DataFrame(comp).T,
                         endmembers="olivine",
                         ord=1,
                         molecular=True)
ed
########################################################################################
# Equally, if you knew the likely endmembers beforehand, you could specify a list of
# endmembers:
#
ed = endmember_decompose(pd.DataFrame(comp).T,
                         endmembers=["forsterite", "fayalite"],
                         ord=1,
                         molecular=True)
ed
########################################################################################
# We can check this by recombining the components with these proportions. We can first
# lookup the compositions for our endmembers:
#
 def test_molecular(self):
     for molecular in [True, False]:
         with self.subTest(molecular=molecular):
             s = endmember_decompose(self.df, molecular=molecular)
 def test_endmembers_list_formulae(self):
     res = endmember_decompose(self.df, endmembers=["Mg2SiO4", "Fe2SiO4"])
 def test_endmembers_list_mineralnames(self):
     res = endmember_decompose(self.df,
                               endmembers=["forsterite", "fayalite"])
 def test_endmembers_mineral_group(self):
     res = endmember_decompose(self.df, endmembers="olivine")
 def test_default(self):
     res = endmember_decompose(self.df)