Push
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import sympy as sp
|
||||
import numpy as np
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, Tuple, Iterable
|
||||
from typing import Dict, Tuple, Iterable, Any
|
||||
from Export import Export
|
||||
from Datenbank import Datenbankzugriff
|
||||
|
||||
@@ -71,7 +71,7 @@ class StochastischesModell:
|
||||
# Q_ll[i, i] = q_ii #Diagonale
|
||||
# return Q_ll
|
||||
|
||||
def Qll_symbolisch(self, pfad_datenbank, liste_beobachtungen_symbolisch):
|
||||
def Qll_symbolisch(self, pfad_datenbank: str, liste_beobachtungen_symbolisch: list) -> sp.Matrix:
|
||||
liste_standardabweichungen_symbole = []
|
||||
liste_beobachtungen_symbolisch = [str(b) for b in liste_beobachtungen_symbolisch]
|
||||
liste_beobachtungen_symbolisch = [b for b in liste_beobachtungen_symbolisch if not b.startswith("lA_")]
|
||||
@@ -191,7 +191,7 @@ class StochastischesModell:
|
||||
Export.matrix_to_csv(r"Zwischenergebnisse\Qll_Symbolisch.csv", liste_beobachtungen_symbolisch, liste_beobachtungen_symbolisch, Qll, "Qll")
|
||||
return Qll
|
||||
|
||||
def Qll_numerisch(self, pfad_datenbank, Qll_Matrix_Symbolisch, liste_beobachtungen_symbolisch):
|
||||
def Qll_numerisch(self, pfad_datenbank: str, Qll_Matrix_Symbolisch: sp.Matrix, liste_beobachtungen_symbolisch: list) -> np.Matrix:
|
||||
liste_beobachtungen_symbolisch = [str(b).strip() for b in liste_beobachtungen_symbolisch]
|
||||
liste_beobachtungen_symbolisch = [b for b in liste_beobachtungen_symbolisch if not b.startswith("lA_")]
|
||||
|
||||
@@ -308,8 +308,34 @@ class StochastischesModell:
|
||||
raise ValueError(
|
||||
f"Qll_numerisch: Fehlende Substitutionen ({len(fehlend)}): {[str(s) for s in fehlend[:80]]}")
|
||||
|
||||
liste_werte = [substitutionen[s] for s in self.liste_symbole_lambdify]
|
||||
Qll_numerisch = np.asarray(self.func_Qll_numerisch(*liste_werte), dtype=float)
|
||||
#liste_werte = [substitutionen[s] for s in self.liste_symbole_lambdify]
|
||||
#Qll_numerisch = np.asarray(self.func_Qll_numerisch(*liste_werte), dtype=float)
|
||||
|
||||
rows = int(Qll_Matrix_Symbolisch.rows)
|
||||
cols = int(Qll_Matrix_Symbolisch.cols)
|
||||
|
||||
Qll_numerisch = np.zeros((rows, cols), dtype=float)
|
||||
|
||||
for i in range(rows):
|
||||
for j in range(cols):
|
||||
eintrag = Qll_Matrix_Symbolisch[i, j]
|
||||
if eintrag == 0:
|
||||
continue
|
||||
try:
|
||||
if hasattr(eintrag, "is_zero") and (eintrag.is_zero is True):
|
||||
continue
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
eintrag_num = eintrag.xreplace(substitutionen)
|
||||
|
||||
if hasattr(eintrag_num, "free_symbols") and len(eintrag_num.free_symbols) > 0:
|
||||
rest = sorted(list(eintrag_num.free_symbols), key=lambda s: str(s))
|
||||
raise ValueError(
|
||||
f"Qll_numerisch: Eintrag [{i},{j}] bleibt symbolisch. Rest-Symbole: {[str(s) for s in rest[:20]]}"
|
||||
)
|
||||
|
||||
Qll_numerisch[i, j] = float(eintrag_num)
|
||||
|
||||
Export.matrix_to_csv(
|
||||
r"Zwischenergebnisse\Qll_Numerisch.csv",
|
||||
@@ -321,7 +347,7 @@ class StochastischesModell:
|
||||
|
||||
return Qll_numerisch
|
||||
|
||||
def QAA_symbolisch(self, liste_beobachtungen_symbolisch):
|
||||
def QAA_symbolisch(self, liste_beobachtungen_symbolisch: list) -> np.Matrix:
|
||||
liste_standardabweichungen_symbole = []
|
||||
liste_beobachtungen_symbolisch = [str(b) for b in liste_beobachtungen_symbolisch]
|
||||
liste_beobachtungen_symbolisch = [b for b in liste_beobachtungen_symbolisch if b.startswith("lA_")]
|
||||
@@ -341,7 +367,7 @@ class StochastischesModell:
|
||||
Export.matrix_to_csv(r"Zwischenergebnisse\QAA_Symbolisch.csv", liste_beobachtungen_symbolisch, liste_beobachtungen_symbolisch, Qll, "Qll")
|
||||
return Qll
|
||||
|
||||
def QAA_numerisch(self, pfad_datenbank, QAA_Matrix_Symbolisch, liste_beobachtungen_symbolisch):
|
||||
def QAA_numerisch(self, pfad_datenbank: str, QAA_Matrix_Symbolisch: sp.Matrix, liste_beobachtungen_symbolisch: list) -> np.Matrix:
|
||||
liste_beobachtungen_symbolisch = [str(b).strip() for b in liste_beobachtungen_symbolisch]
|
||||
liste_beobachtungen_symbolisch = [b for b in liste_beobachtungen_symbolisch if b.startswith("lA_")]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user