# Path: src/core/def_tools.py
# def keys_sorted(dictionary, n_top=None):
#     import heapq
#     if n_top is None:
#         n_top = len(dictionary.keys())
#     else:
#         n_top = int(n_top)
#     return heapq.nlargest(n_top, dictionary, key = lambda k:dictionary[k])
# 
# def num2str(num, d):
#     s = str(num)
#     #if '.' in s:
#     #   s = s[:s.index('.')+d+1]
# 
#     return s


import sys
import os
import cantera as ct
import json
import time
import copy
from PyQt4 import uic
from PyQt4.QtGui import * 
from PyQt4.QtCore import * 
from def_dialog import common
from src.core.def_tools import keys_sorted, num2str



class dialog_database_mixture(common):


	""" >>>>>>>>>-------------------------
	0.0.0. dialog_database_mixture
		   called by: dialog_database

	"""

	# this class is inherited from helper, rather than base_dialog
	# because most methods in base_dialog is not used here




	# helper ============================


	def fun_mix_str(self, composition):
		if len(composition.keys()) == 1:
			return composition.keys()[0]

		spid = dict()
		for sp in composition.keys():
			spid[sp] = self.parent.soln['detailed'].species_index(sp)


# Path: src/core/def_tools.py
# def keys_sorted(dictionary, n_top=None):
#     import heapq
#     if n_top is None:
#         n_top = len(dictionary.keys())
#     else:
#         n_top = int(n_top)
#     return heapq.nlargest(n_top, dictionary, key = lambda k:dictionary[k])
# 
# def num2str(num, d):
#     s = str(num)
#     #if '.' in s:
#     #   s = s[:s.index('.')+d+1]
# 
#     return s


# Path: src/gui/dialog_database_mixture.py
import sys
import os
import cantera as ct
import json
import time
import copy
from PyQt4 import uic
from PyQt4.QtGui import * 
from PyQt4.QtCore import * 
from def_dialog import common
from src.core.def_tools import keys_sorted, num2str




class dialog_database_mixture(common):


	""" >>>>>>>>>-------------------------
	0.0.0. dialog_database_mixture
		   called by: dialog_database

	"""

	# this class is inherited from helper, rather than base_dialog
	# because most methods in base_dialog is not used here




	# helper ============================


	def fun_mix_str(self, composition):
		if len(composition.keys()) == 1:
			return composition.keys()[0]

		spid = dict()
		for sp in composition.keys():
			spid[sp] = self.parent.soln['detailed'].species_index(sp)


		sps = keys_sorted(spid)