scilens 0.4.13__py3-none-any.whl → 0.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scilens/components/compare_floats.py +18 -17
- scilens/components/compare_models.py +1 -1
- scilens/config/models/__init__.py +1 -0
- scilens/config/models/compare_float_thresholds.py +1 -1
- scilens/config/models/reader_format_cols.py +2 -2
- scilens/config/models/reader_format_trees.py +7 -0
- scilens/config/models/reader_format_txt.py +0 -1
- scilens/config/models/readers.py +8 -3
- scilens/readers/cols_dataset.py +4 -2
- scilens/readers/reader_csv.py +8 -8
- scilens/readers/reader_json.py +11 -0
- scilens/readers/reader_manager.py +27 -21
- scilens/readers/reader_txt_fixed_cols.py +39 -33
- scilens/readers/reader_xml.py +12 -0
- scilens/readers/reader_yaml.py +11 -0
- scilens/readers/tree.py +70 -0
- scilens/report/templates/compare_13_section_numbers_table.html +7 -0
- scilens/utils/xml.py +19 -0
- {scilens-0.4.13.dist-info → scilens-0.5.1.dist-info}/METADATA +1 -1
- {scilens-0.4.13.dist-info → scilens-0.5.1.dist-info}/RECORD +22 -16
- {scilens-0.4.13.dist-info → scilens-0.5.1.dist-info}/WHEEL +0 -0
- {scilens-0.4.13.dist-info → scilens-0.5.1.dist-info}/entry_points.txt +0 -0
|
@@ -33,21 +33,22 @@ class CompareFloats:
|
|
|
33
33
|
def compare_vectors(A,test_vector,reference_vector,group,info_vector=_A):
|
|
34
34
|
R='ignore';M=info_vector;L='RIAE_trapezoid';H=group;F=reference_vector;B=test_vector
|
|
35
35
|
if len(B)!=len(F):raise Exception('Vectors have different lengths')
|
|
36
|
-
N=0;G=_B;
|
|
37
|
-
if
|
|
38
|
-
if
|
|
36
|
+
N=0;G=_B;E=A.thresholds.vectors.ponderation_method if A.thresholds.vectors else _A
|
|
37
|
+
if E=='RIAE':E=L
|
|
38
|
+
if E:logging.debug(f"Using ponderation method: {E} with reduction_method {A.thresholds.vectors.reduction_method}")
|
|
39
39
|
I=_A
|
|
40
|
-
if A.thresholds.vectors and
|
|
40
|
+
if A.thresholds.vectors and E=='amplitude_moderation':S=vector_get_amplitude(B)[_D];I=S*A.thresholds.vectors.amplitude_moderation_multiplier;O=A.thresholds.vectors.reduction_method
|
|
41
41
|
J=_A
|
|
42
|
-
if A.thresholds.vectors and
|
|
43
|
-
K=CheckVectors.relative_integral_absolute_error_trapezoid(F,B,range(len(B)))if
|
|
42
|
+
if A.thresholds.vectors and E in[L,'RIAE_midpoint']:
|
|
43
|
+
K=CheckVectors.relative_integral_absolute_error_trapezoid(F,B,range(len(B)))if E==L else CheckVectors.relative_integral_absolute_error_midpoint(F,B,range(len(B)))
|
|
44
44
|
if K is _A:logging.warning('RIAE calculation returned None. This may indicate an issue with the vectors.')
|
|
45
45
|
else:
|
|
46
46
|
J=A.thresholds.vectors.reduction_method
|
|
47
|
-
if K>A.thresholds.vectors.riae_threshold:T=CompareFloatsErr(is_relative=_B,value=K);
|
|
47
|
+
if K>A.thresholds.vectors.riae_threshold:T=CompareFloatsErr(is_relative=_B,value=K);D=Compare2ValuesResults(SEVERITY_ERROR,f"RIAE ({E}) > {A.thresholds.vectors.riae_threshold}",T);G=A.compare_errors.add(H,D)
|
|
48
48
|
U=len(B)
|
|
49
|
-
for
|
|
50
|
-
|
|
49
|
+
for C in range(U):
|
|
50
|
+
if B[C]is _A and F[C]is _A:continue
|
|
51
|
+
P=B[C]-F[C]
|
|
51
52
|
if P==0:continue
|
|
52
53
|
else:N+=1;H.incr(_C)
|
|
53
54
|
if G:continue
|
|
@@ -55,15 +56,15 @@ class CompareFloats:
|
|
|
55
56
|
if I is not _A and abs(P)<I:
|
|
56
57
|
if O==R:continue
|
|
57
58
|
elif O=='soften':
|
|
58
|
-
|
|
59
|
-
if
|
|
59
|
+
D=A.compare_2_values(B[C],F[C])
|
|
60
|
+
if D:D.severity=SEVERITY_WARNING
|
|
60
61
|
else:
|
|
61
|
-
|
|
62
|
-
if
|
|
63
|
-
if
|
|
64
|
-
Q={'index':
|
|
65
|
-
if M:Q['info']=M[
|
|
66
|
-
G=A.compare_errors.add(H,
|
|
62
|
+
D=A.compare_2_values(B[C],F[C])
|
|
63
|
+
if D and J:D.severity=SEVERITY_WARNING
|
|
64
|
+
if D:
|
|
65
|
+
Q={'index':C}
|
|
66
|
+
if M:Q['info']=M[C]
|
|
67
|
+
G=A.compare_errors.add(H,D,info=Q)
|
|
67
68
|
return G,N
|
|
68
69
|
def add_group_and_compare_vectors(A,group_name,parent_group,group_data,test_vector,reference_vector,info_vector=_A):C,B=A.compare_errors.add_group('vectors',group_name,parent=parent_group,data=group_data);return(B,)+A.compare_vectors(test_vector,reference_vector,B,info_vector=info_vector)
|
|
69
70
|
def compare_matrices(H,test_mat,ref_mat,group,x_vector=_A,y_vector=_A):
|
|
@@ -8,7 +8,7 @@ SEVERITY_WARNING='warning'
|
|
|
8
8
|
class CompareFloatsErr:is_relative:bool;value:float;test:float|_A=_A;reference:float|_A=_A
|
|
9
9
|
@dataclass
|
|
10
10
|
class Compare2ValuesResults:severity:str;message:str;comp_err:CompareFloatsErr|_A=_A
|
|
11
|
-
class CompareErr(BaseModel):err:CompareFloatsErr|_A;msg:int;group:int|_A=_A;info:dict|_A=_A
|
|
11
|
+
class CompareErr(BaseModel):err:CompareFloatsErr|_A;msg:int;group:int|_A=_A;info:dict|str|_A=_A
|
|
12
12
|
COMPARE_GROUP_TYPE=Literal['node','lines','vectors',' matrix','metrics','pixels']
|
|
13
13
|
@dataclass
|
|
14
14
|
class CompareGroup:
|
|
@@ -6,6 +6,7 @@ from.execute import ExecuteConfig
|
|
|
6
6
|
from.reader_format_txt import ReaderTxtIgnoreConfig,ReaderTxtConfig
|
|
7
7
|
from.reader_format_csv import ReaderCsvConfig
|
|
8
8
|
from.reader_format_txt_fixed_cols import ReaderTxtFixedColsConfig
|
|
9
|
+
from.reader_format_trees import ReaderJsonConfig,ReaderXmlConfig,ReaderYamlConfig,ReaderTreeBaseConfig
|
|
9
10
|
from.readers import ReadersConfig
|
|
10
11
|
from.file_reader import FileReaderConfig
|
|
11
12
|
from.report_html import ReportHtmlConfig,ReportHtmlCurvesConfig,ReportParameterOpenFileInConfig,ReportParameterPageModeConfig
|
|
@@ -2,7 +2,7 @@ _B='forbid'
|
|
|
2
2
|
_A=None
|
|
3
3
|
from pydantic import BaseModel,Field,model_validator
|
|
4
4
|
class CompareFloatVectorsConfig(BaseModel,extra=_B):
|
|
5
|
-
reduction_method:str=Field(default='soften',description="Méthode de réduction de sévérité des erreurs. Peut être `soften` ou `ignore`. Si `soften`, réduit la sévérité de l'erreur. Si `ignore`, ne lève pas d'erreur.");ponderation_method:str=Field(description='Méthode de calcul de reduction de sévérité. Peut être`amplitude_moderation`, `RIAE`, `RIAE_trapezoid` ou `RIAE_midpoint
|
|
5
|
+
reduction_method:str=Field(default='soften',description="Méthode de réduction de sévérité des erreurs. Peut être `soften` ou `ignore`. Si `soften`, réduit la sévérité de l'erreur. Si `ignore`, ne lève pas d'erreur.");ponderation_method:str=Field(description='Méthode de calcul de reduction de sévérité. Peut être`amplitude_moderation`, `RIAE`, `RIAE_trapezoid` ou `RIAE_midpoint` (`RIAE`=`RIAE_trapezoid`).');amplitude_moderation_multiplier:float|_A=Field(default=_A,description="Multipler utilisé dans l'amplitude pondérée `multiplier * |Max(Vector)-Min(Vector)|` qui sera comparée à l'erreur absolue `|Test-Reference|`.");riae_threshold:float|_A=Field(default=_A,description="Seuil de l'erreur relative intégrale absolue. Si l'erreur est supérieure à ce seuil, on appliquera la reduction_method globalement.")
|
|
6
6
|
@model_validator(mode='after')
|
|
7
7
|
def check_value_required(self):
|
|
8
8
|
A=self
|
|
@@ -4,7 +4,7 @@ _A=None
|
|
|
4
4
|
from pydantic import BaseModel,Field,model_validator
|
|
5
5
|
from enum import Enum
|
|
6
6
|
class ReaderCurveParserNameConfig(str,Enum):COL_X='col_x';COLS_COUPLE='cols_couple'
|
|
7
|
-
class ReaderCurveParserColXConfig(BaseModel,extra=_B):x:int|str|list[str]=Field(default=1,description="Si `integer`, index de la colonne pour l'axe x (index `1` pour la première colonne)."+"Si `String`, nom de la colonne pour l'axe x. Si la colonne n'existe pas, il n'y aura pas de parsing."+_C+"Si `List[String] (utiles dans un contexte multi dataset), noms de la colonne pour l'axe x, noms des colonnes pour l'axe x , si plusieurs colonnes correspondent, la première trouvée sera utilisée. Si aucune colonne ne correspond, il n'y aura pas de parsing."+_C)
|
|
7
|
+
class ReaderCurveParserColXConfig(BaseModel,extra=_B):x:int|str|list[str]=Field(default=1,description="Si `integer`, index de la colonne pour l'axe x (index `1` pour la première colonne)."+"Si `String`, nom de la colonne pour l'axe x. Si la colonne n'existe pas, il n'y aura pas de parsing."+_C+"Si `List[String] (utiles dans un contexte multi dataset), noms de la colonne pour l'axe x, noms des colonnes pour l'axe x , si plusieurs colonnes correspondent, la première trouvée sera utilisée. Si aucune colonne ne correspond, il n'y aura pas de parsing."+_C);x_not_found_skip:bool=Field(default=True,description="Si aucune colonne n'est trouvée correspondant au parammètre `x`, ne parse pas de courbes.")
|
|
8
8
|
class ReaderCurveParserColsCoupleConfig(BaseModel,extra=_B):x_index:int=Field(description='NOT IMPLEMENTED - Index Col x');y_index:int=Field(description='NOT IMPLEMENTED - Index Col y')
|
|
9
9
|
class ReaderColsCurveParserConfig(BaseModel,extra=_B):
|
|
10
10
|
name:ReaderCurveParserNameConfig=Field(description='Le type de `paramètres` dépend de cette valeur');parameters:ReaderCurveParserColXConfig|ReaderCurveParserColsCoupleConfig|_A=Field(default=_A,description='Paramètres du parser de courbes')
|
|
@@ -17,4 +17,4 @@ class ReaderColsCurveParserConfig(BaseModel,extra=_B):
|
|
|
17
17
|
elif A.name==ReaderCurveParserNameConfig.COLS_COUPLE:A.parameters=ReaderCurveParserColsCoupleConfig(**A.parameters)
|
|
18
18
|
return A
|
|
19
19
|
class ReaderColsRowsConfig(BaseModel,extra=_B):ignore_patterns:list[str]|_A=Field(default=_A,description='Liste des patterns de lignes à ignorer. Ex: ["^#", "^//"]. Non applicable si `is_matrix` est vrai.');line_start:int|_A=Field(default=_A,description='Ligne de début pour lire le fichier (les en-têtes sont comptées comme une ligne). Si non défini, commence à la première ligne.');line_end:int|_A=Field(default=_A,description="Ligne de fin pour lire le fichier (les en-têtes sont comptées comme une ligne). Si non défini, lit jusqu'à la dernière ligne.");index_min_value:float|_A=Field(default=_A,description="Valeur minimale de l'index pour les lignes à lire (valeur incluses).");index_max_value:float|_A=Field(default=_A,description="Valeur maximale de l'index pour les lignes à lire (valeur incluses).")
|
|
20
|
-
class ReaderColsConfig(BaseModel,extra=_B):ignore_columns:list[str]|list[int]|_A=Field(default=_A,description="Liste des colonnes à ignorer (nom de l'en tête ou numéro de colonne).");select_columns:list[str]|list[int]|_A=Field(default=_A,description="Liste des colonnes à sélectionner (nom de l'en tête ou numéro de colonne).");index_col:int|str|list[str]|_A=Field(default=_A,description='Colonne(s) à utiliser comme index (date/heure, itération, étape, ...) (Utilisé dans différentes règles). Numéro de colonne ou nom(s) de colonne. (Valide seulement si non matrice)');rows:ReaderColsRowsConfig|_A=Field(default=_A,description='Configuration des lignes à lire.');curve_parser:ReaderColsCurveParserConfig|_A=Field(default=_A,description='Parseur de courbe à utiliser.')
|
|
20
|
+
class ReaderColsConfig(BaseModel,extra=_B):ignore_columns:list[str]|list[int]|_A=Field(default=_A,description="Liste des colonnes à ignorer (nom de l'en tête ou numéro de colonne).");select_columns:list[str]|list[int]|_A=Field(default=_A,description="Liste des colonnes à sélectionner (nom de l'en tête ou numéro de colonne).");index_col:int|str|list[str]|_A=Field(default=_A,description='Colonne(s) à utiliser comme index (date/heure, itération, étape, ...) (Utilisé dans différentes règles). Numéro de colonne ou nom(s) de colonne. (Valide seulement si non matrice)');rows:ReaderColsRowsConfig|_A=Field(default=_A,description='Configuration des lignes à lire.');nulls_allowed:bool=Field(default=True,description='Accepte les valeurs vides si True.');nulls_strings:list[str]|_A=Field(default=_A,description='Chaines de caracters à considérer comme vides.');curve_parser:ReaderColsCurveParserConfig|_A=Field(default=_A,description='Parseur de courbe à utiliser.')
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
_B=None
|
|
2
|
+
_A='forbid'
|
|
3
|
+
from pydantic import BaseModel,Field
|
|
4
|
+
class ReaderTreeBaseConfig(BaseModel,extra=_A):path_exclude_patterns:list[str]|_B=Field(default=_B,description='Patterns (Unix shell-style wildcards) to exclude certain paths from processing.');path_include_patterns:list[str]|_B=Field(default=_B,description='Patterns (Unix shell-style wildcards) to include certain paths from processing.')
|
|
5
|
+
class ReaderJsonConfig(ReaderTreeBaseConfig,extra=_A):0
|
|
6
|
+
class ReaderXmlConfig(ReaderTreeBaseConfig,extra=_A):0
|
|
7
|
+
class ReaderYamlConfig(ReaderTreeBaseConfig,extra=_A):0
|
|
@@ -2,7 +2,6 @@ _B='forbid'
|
|
|
2
2
|
_A=None
|
|
3
3
|
from pydantic import BaseModel,Field
|
|
4
4
|
from scilens.config.models.reader_metrics import ReaderTxtMetricsConfig
|
|
5
|
-
from scilens.config.models.compare_float_thresholds import CompareFloatThresholdsConfig
|
|
6
5
|
class ReaderTxtReportLines(BaseModel,extra=_B):pre:int=Field(default=0,description="Nombre de ligne avant l'erreur à présenter avec le message d'erreur.");post:int=Field(default=0,description="Nombre de ligne après l'erreur à présenter avec le message d'erreur.")
|
|
7
6
|
class ReaderTxtIgnoreConfig(BaseModel,extra=_B):pattern:str=Field(default='',description='Motif de chaîne à ignorer.');pre:int=Field(default=0,description='Nombre de ligne supplémentaires à ignorer avant.');post:int=Field(default=0,description='Nombre de ligne supplémentaires à ignorer après.')
|
|
8
7
|
class ReaderTxtConfig(BaseModel,extra=_B):error_rule_patterns:list[str]|_A=Field(default=_A,description='Liste de motifs de chaîne à vérifier. Si un motif est trouvé, génère une erreur. Ex: `["NaN", "infinity"]`');ignore:dict[str,list[ReaderTxtIgnoreConfig]]|_A=Field(default=_A,description='Ignore les lignes d\'un fichier selon un motif. Ex: `{"path": [{"pattern": "NaN", "pre": 0, "post": 0}]}`');report_lines:dict[str,ReaderTxtReportLines]|_A=Field(default=_A,description='Nombre de lignes à reporter avant et après une erreur. Ex: `{"path": {"pre": 0, "post": 0}`');metrics:list['ReaderTxtMetricsConfig']|_A=Field(default=_A,description='Liste des métriques')
|
scilens/config/models/readers.py
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
_B=None
|
|
1
2
|
_A='forbid'
|
|
2
|
-
from typing import Literal
|
|
3
|
+
from typing import Literal,Optional
|
|
3
4
|
from pydantic import BaseModel,Field
|
|
4
5
|
from scilens.config.models.reader_format_txt import ReaderTxtConfig
|
|
5
6
|
from scilens.config.models.reader_format_csv import ReaderCsvConfig
|
|
6
7
|
from scilens.config.models.reader_format_txt_fixed_cols import ReaderTxtFixedColsConfig
|
|
8
|
+
from scilens.config.models.reader_format_trees import ReaderJsonConfig,ReaderXmlConfig,ReaderYamlConfig
|
|
7
9
|
from scilens.config.models.reader_format_netcdf import ReaderNetcdfConfig
|
|
8
10
|
class BaseCatalogItem(BaseModel,extra=_A):type:str
|
|
9
11
|
class ReaderTxtConfigItem(BaseCatalogItem,extra=_A):type:Literal['txt'];parameters:ReaderTxtConfig
|
|
10
12
|
class ReaderCsvConfigItem(BaseCatalogItem,extra=_A):type:Literal['csv'];parameters:ReaderCsvConfig
|
|
11
13
|
class ReaderTxtFixedColsConfigItem(BaseCatalogItem,extra=_A):type:Literal['txt_fixed_cols'];parameters:ReaderTxtFixedColsConfig
|
|
14
|
+
class ReaderJsonConfigItem(BaseCatalogItem,extra=_A):type:Literal['json'];parameters:ReaderJsonConfig
|
|
15
|
+
class ReaderXmlConfigItem(BaseCatalogItem,extra=_A):type:Literal['xml'];parameters:ReaderXmlConfig
|
|
16
|
+
class ReaderYamlConfigItem(BaseCatalogItem,extra=_A):type:Literal['yaml'];parameters:ReaderYamlConfig
|
|
12
17
|
class ReaderNetcdfConfigItem(BaseCatalogItem,extra=_A):type:Literal['netcdf'];parameters:ReaderNetcdfConfig
|
|
13
|
-
CATALOG_ITEM_TYPE=ReaderTxtConfigItem|ReaderCsvConfigItem|ReaderTxtFixedColsConfigItem|ReaderNetcdfConfigItem
|
|
14
|
-
class ReadersConfig(BaseModel,extra=_A):txt:ReaderTxtConfig=Field(default=ReaderTxtConfig(),description='Configuration des readers txt.');csv:ReaderCsvConfig=Field(default=ReaderCsvConfig(),description='Configuration des readers csv.');txt_fixed_cols:ReaderTxtFixedColsConfig=Field(default=ReaderTxtFixedColsConfig(),description='Configuration des readers txt avec colonnes fixes.');netcdf:ReaderNetcdfConfig=Field(default=ReaderNetcdfConfig(),description='Configuration des readers
|
|
18
|
+
CATALOG_ITEM_TYPE=ReaderTxtConfigItem|ReaderCsvConfigItem|ReaderTxtFixedColsConfigItem|ReaderJsonConfigItem|ReaderXmlConfigItem|ReaderYamlConfigItem|ReaderNetcdfConfigItem
|
|
19
|
+
class ReadersConfig(BaseModel,extra=_A):txt:ReaderTxtConfig=Field(default=ReaderTxtConfig(),description='Configuration des readers txt.');csv:ReaderCsvConfig=Field(default=ReaderCsvConfig(),description='Configuration des readers csv.');txt_fixed_cols:ReaderTxtFixedColsConfig=Field(default=ReaderTxtFixedColsConfig(),description='Configuration des readers txt avec colonnes fixes.');default_config_json:ReaderJsonConfig|_B=Field(default=_B,description='Configuration des readers json.');default_config_xml:ReaderXmlConfig|_B=Field(default=_B,description='Configuration des readers xml.');default_config_yaml:ReaderYamlConfig|_B=Field(default=_B,description='Configuration des readers yaml.');netcdf:ReaderNetcdfConfig=Field(default=ReaderNetcdfConfig(),description='Configuration des readers netcdf.');catalog:dict[str,CATALOG_ITEM_TYPE]|_B=Field(default=_B,description="Catalogue de configuration de readers par clé. Ex: `{'csv_comma': {'type': 'csv', 'parameters': {'delimiter': ','}}, 'csv_semicolon': {'type': 'csv', 'parameters': {'delimiter': ';'}}}`")
|
scilens/readers/cols_dataset.py
CHANGED
|
@@ -25,9 +25,11 @@ def get_col_indexes(source,numeric_col_indexes,names):
|
|
|
25
25
|
class ColsDataset:
|
|
26
26
|
cols_count:int=0;rows_count:int=0;names:list[str]=field(default_factory=lambda:[]);numeric_col_indexes:list[int]=field(default_factory=lambda:[]);data:list[list[float]]=field(default_factory=lambda:[]);origin_line_nb:list[int]=field(default_factory=lambda:[])
|
|
27
27
|
def get_col_indexes(A,col_x):return get_col_indexes(col_x,A.numeric_col_indexes,A.names)
|
|
28
|
-
def get_curves_col_x(F,col_x):
|
|
28
|
+
def get_curves_col_x(F,col_x,x_not_found_skip=True):
|
|
29
29
|
J='title';C=col_x;A=F;G={};H=F.get_col_indexes(C)
|
|
30
|
-
if not H:
|
|
30
|
+
if not H:
|
|
31
|
+
if x_not_found_skip:return{},{}
|
|
32
|
+
else:raise ValueError(f"get_curves_col_x Column {C} not found in numeric columns.")
|
|
31
33
|
D=H[0];G[_D]=D;K=[B for(A,B)in enumerate(A.numeric_col_indexes)if A!=D];E=[];I=[]
|
|
32
34
|
for B in K:C=A.data[D];L=A.data[B];M={J:A.names[B],'short_title':A.names[B],'series':[[C[A],L[A]]for A in range(A.rows_count)],_C:B};E+=[M];N={J:A.names[B],'type':'simple','xaxis':A.names[D],'yaxis':A.names[B],_B:[len(E)-1]};I+=[N]
|
|
33
35
|
return{_B:E,_E:I},G
|
scilens/readers/reader_csv.py
CHANGED
|
@@ -27,7 +27,7 @@ class ReaderCsv(ReaderInterface):
|
|
|
27
27
|
if bool(re.match(B,line)):return _B
|
|
28
28
|
return False
|
|
29
29
|
def read(A,reader_options):
|
|
30
|
-
C=reader_options;A.reader_options=C;F,L,
|
|
30
|
+
C=reader_options;A.reader_options=C;F,L,W=csv_detect(A.origin.path,A.reader_options.delimiter,A.reader_options.quotechar,encoding=A.encoding);A.has_header=F;A.cols=L;A.numeric_col_indexes=W;A.index_col_index=_A;A.ignore_lines_patterns=_A;G=_A;H=_A;I=_A;J=_A;B=C.cols
|
|
31
31
|
if B:
|
|
32
32
|
if B.index_col:
|
|
33
33
|
if B.index_col:R=get_col_indexes(B.index_col,A.numeric_col_indexes,L);A.index_col_index=R[0]if R else _A
|
|
@@ -39,8 +39,8 @@ class ReaderCsv(ReaderInterface):
|
|
|
39
39
|
I=B.rows.index_min_value;J=B.rows.index_max_value
|
|
40
40
|
if I and J and I>J:raise ValueError(f"Index min value {I} cannot be greater than index max value {J}.")
|
|
41
41
|
A.raw_lines_number=_A;A.curves=_A;A.report_matrices=_A;A.metrics=_A
|
|
42
|
-
with open(A.origin.path,'r',encoding=A.encoding)as
|
|
43
|
-
S=
|
|
42
|
+
with open(A.origin.path,'r',encoding=A.encoding)as X:
|
|
43
|
+
S=X.readlines();M=csv.reader(S,delimiter=A.reader_options.delimiter,quotechar=A.reader_options.quotechar)
|
|
44
44
|
if C.is_matrix:
|
|
45
45
|
K=C.matrix or ReaderCsvMatrixConfig();P=mat_from_iterator(x_name=K.x_name,y_name=K.y_name,reader=M,has_header=F,x_value_line=K.x_value_line,has_y=K.has_y)
|
|
46
46
|
if K.export_report:A.report_matrices=get_data([P],['csv'])
|
|
@@ -49,7 +49,7 @@ class ReaderCsv(ReaderInterface):
|
|
|
49
49
|
if C.cols and C.cols.ignore_columns:
|
|
50
50
|
if not F:raise Exception('Ignore columns is not supported without header.')
|
|
51
51
|
if isinstance(C.cols.ignore_columns[0],str):A.numeric_col_indexes=[B for B in A.numeric_col_indexes if A.cols[B]not in C.cols.ignore_columns]
|
|
52
|
-
if isinstance(C.cols.ignore_columns[0],int):
|
|
52
|
+
if isinstance(C.cols.ignore_columns[0],int):Y=[A-1 for A in B.ignore_columns];A.numeric_col_indexes=[A for A in A.numeric_col_indexes if A not in Y]
|
|
53
53
|
T=len(L);D=ColsDataset(cols_count=T,names=L,numeric_col_indexes=A.numeric_col_indexes,data=[[]for A in range(T)]);E=0
|
|
54
54
|
if F and E==0:next(M);E+=1
|
|
55
55
|
if G:
|
|
@@ -75,11 +75,11 @@ class ReaderCsv(ReaderInterface):
|
|
|
75
75
|
if B and B.curve_parser:
|
|
76
76
|
if B.curve_parser.name==ReaderCurveParserNameConfig.COL_X:
|
|
77
77
|
O=_A
|
|
78
|
-
if B.curve_parser.parameters:O=B.curve_parser.parameters.x
|
|
79
|
-
elif B.index_col:O=B.index_col
|
|
78
|
+
if B.curve_parser.parameters:O=B.curve_parser.parameters.x;V=B.curve_parser.parameters.x_not_found_skip
|
|
79
|
+
elif B.index_col:O=B.index_col;V=_B
|
|
80
80
|
if not O:raise ValueError('Curve parser COL_X requires a parameter x, or index_col to be defined.')
|
|
81
|
-
A.curves,
|
|
82
|
-
if A.curves:A.cols_curve=ColsCurves(type=ReaderCurveParserNameConfig.COL_X,info=
|
|
81
|
+
A.curves,Z=D.get_curves_col_x(O,x_not_found_skip=V)
|
|
82
|
+
if A.curves:A.cols_curve=ColsCurves(type=ReaderCurveParserNameConfig.COL_X,info=Z,curves=A.curves)
|
|
83
83
|
elif B.curve_parser.name==ReaderCurveParserNameConfig.COLS_COUPLE:raise NotImplementedError('cols_couple not implemented')
|
|
84
84
|
else:raise Exception('Curve parser not supported.')
|
|
85
85
|
def compare(A,compare_floats,param_reader,param_is_ref=_B):
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from scilens.readers.reader_interface import ReaderInterface
|
|
3
|
+
from scilens.config.models import ReaderJsonConfig,ReaderTreeBaseConfig
|
|
4
|
+
from scilens.components.compare_floats import CompareFloats
|
|
5
|
+
import json
|
|
6
|
+
from.tree import Tree
|
|
7
|
+
class ReaderJson(ReaderInterface):
|
|
8
|
+
configuration_type_code='json';category='datalines';extensions=['JSON']
|
|
9
|
+
def read(A,config):C=None;B=config;A.reader_options=B;D=open(A.origin.path,'r',encoding=A.encoding);E=json.load(D);D.close();F=Tree(ReaderTreeBaseConfig(path_include_patterns=B.path_include_patterns if B else C,path_exclude_patterns=B.path_exclude_patterns if B else C));A.floats_data=F.data_to_numeric_values(E);A.metrics=C
|
|
10
|
+
def compare(A,compare_floats,param_reader,param_is_ref=True):C=param_is_ref;B=param_reader;D=A if C else B;E=A if not C else B;Tree.compare(compare_floats,test_floats_data=D.floats_data,ref_floats_data=E.floats_data)
|
|
11
|
+
def class_info(A):return{'metrics':A.metrics}
|
|
@@ -12,7 +12,10 @@ def extension_format(extension):
|
|
|
12
12
|
from scilens.readers.reader_txt import ReaderTxt
|
|
13
13
|
from scilens.readers.reader_csv import ReaderCsv
|
|
14
14
|
from scilens.readers.reader_txt_fixed_cols import ReaderTxtFixedCols
|
|
15
|
-
|
|
15
|
+
from scilens.readers.reader_json import ReaderJson
|
|
16
|
+
from scilens.readers.reader_yaml import ReaderYaml
|
|
17
|
+
from scilens.readers.reader_xml import ReaderXml
|
|
18
|
+
BUILTIN_PLUGINS=[ReaderTxt,ReaderCsv,ReaderTxtFixedCols,ReaderJson,ReaderYaml,ReaderXml]
|
|
16
19
|
LIB_PLUGINS_ENTRY_POINT='scilens.reader_plugins'
|
|
17
20
|
class ReaderManager:
|
|
18
21
|
def __init__(A):
|
|
@@ -28,23 +31,26 @@ class ReaderManager:
|
|
|
28
31
|
for A in B.plugins:
|
|
29
32
|
if code==A.configuration_type_code:return A
|
|
30
33
|
def get_reader_from_file(F,path,name='',config=_A,readers_config=_A,curve_parser=_A):
|
|
31
|
-
I=curve_parser;G=path;C=readers_config;
|
|
32
|
-
if
|
|
33
|
-
for(M,L)in
|
|
34
|
-
if extension_format(M)==
|
|
35
|
-
if not C.catalog or L not in C.catalog.keys():raise NoReaderFound(f"Reader config not found for {
|
|
36
|
-
H=C.catalog[L];
|
|
37
|
-
if not
|
|
38
|
-
N=H.parameters;return
|
|
39
|
-
if
|
|
40
|
-
for(O,P)in
|
|
41
|
-
if extension_format(O)==
|
|
42
|
-
|
|
43
|
-
if not
|
|
44
|
-
if not
|
|
45
|
-
|
|
46
|
-
if
|
|
47
|
-
elif
|
|
48
|
-
elif
|
|
49
|
-
elif
|
|
50
|
-
|
|
34
|
+
I=curve_parser;G=path;C=readers_config;B=config;J=ReaderOrigin(type='file',path=G,short_name=os.path.basename(G));K=B.encoding if B else'utf-8';Q,E=os.path.splitext(G);E=extension_format(E)
|
|
35
|
+
if B and B.extension_readers_catalog:
|
|
36
|
+
for(M,L)in B.extension_readers_catalog.items():
|
|
37
|
+
if extension_format(M)==E:
|
|
38
|
+
if not C.catalog or L not in C.catalog.keys():raise NoReaderFound(f"Reader config not found for {E}")
|
|
39
|
+
H=C.catalog[L];A=F._get_reader_from_configuration_type_code(H.type)
|
|
40
|
+
if not A:raise Exception(f"Reader not found for contiguration type code {H.type}")
|
|
41
|
+
N=H.parameters;return A(J,name=name,encoding=K,curve_parser=I),N
|
|
42
|
+
if B and B.extension_mapping:
|
|
43
|
+
for(O,P)in B.extension_mapping.items():
|
|
44
|
+
if extension_format(O)==E:E=extension_format(P);break
|
|
45
|
+
A=F._get_reader_from_extension(E)
|
|
46
|
+
if not A and B and B.extension_fallback:A=F._get_reader_from_extension(B.extension_fallback)
|
|
47
|
+
if not A:raise NoReaderFound(f"Reader cound not be derived")
|
|
48
|
+
D=_A
|
|
49
|
+
if A.__name__=='ReaderTxt':D=C.txt
|
|
50
|
+
elif A.__name__=='ReaderCsv':D=C.csv
|
|
51
|
+
elif A.__name__=='ReaderTxtFixedCols':D=C.txt_fixed_cols
|
|
52
|
+
elif A.__name__=='ReaderJson':D=C.default_config_json
|
|
53
|
+
elif A.__name__=='ReaderXml':D=C.default_config_xml
|
|
54
|
+
elif A.__name__=='ReaderYaml':D=C.default_config_yaml
|
|
55
|
+
elif A.__name__=='ReaderNetcdf':D=C.netcdf
|
|
56
|
+
return A(J,name=name,encoding=K,curve_parser=I),D
|
|
@@ -51,43 +51,49 @@ class ReaderTxtFixedCols(ReaderInterface):
|
|
|
51
51
|
return C
|
|
52
52
|
def _derive_col_indexes(A,header_row=_A):0
|
|
53
53
|
def read(A,reader_options):
|
|
54
|
-
|
|
55
|
-
if
|
|
56
|
-
if
|
|
57
|
-
|
|
58
|
-
if
|
|
59
|
-
if
|
|
60
|
-
if
|
|
61
|
-
logging.debug(f"Using column widths: {
|
|
62
|
-
for
|
|
63
|
-
else:logging.debug(f"Using column indexes: {
|
|
64
|
-
else:logging.debug(f"Using auto derived column indexes.");
|
|
54
|
+
C=reader_options;A.reader_options=C;A.ignore_lines_patterns=_A;I=_A;M=_A;B=C.cols
|
|
55
|
+
if B:
|
|
56
|
+
if B.rows:A.ignore_lines_patterns=B.rows.ignore_patterns;I=B.rows.line_start;M=B.rows.line_end
|
|
57
|
+
G=A._get_parsed_headers(A.origin.path)if C.has_header else _A;N=open(A.origin.path,'r',encoding=A.encoding);E=[]
|
|
58
|
+
if C.column_indexes or C.column_widths:
|
|
59
|
+
if C.column_indexes and C.column_widths:raise Exception('column_indexes and column_widths are exclusive.')
|
|
60
|
+
if C.column_widths:
|
|
61
|
+
logging.debug(f"Using column widths: {C.column_widths}");J=0
|
|
62
|
+
for O in C.column_widths:E+=[(J,J+O)];J+=O
|
|
63
|
+
else:logging.debug(f"Using column indexes: {C.column_indexes}");E=C.column_indexes
|
|
64
|
+
else:logging.debug(f"Using auto derived column indexes.");S=A._get_first_data_line(A.origin.path);E=A._discover_col_idx_ralgin_spaces(S)
|
|
65
65
|
logging.debug(f"Column indexes: {E}")
|
|
66
66
|
if not E:raise Exception('No column indexes or widths provided, and no headers found to derive column indexes.')
|
|
67
|
-
|
|
68
|
-
if
|
|
69
|
-
if
|
|
70
|
-
if isinstance(
|
|
71
|
-
if isinstance(
|
|
72
|
-
if
|
|
73
|
-
if isinstance(
|
|
74
|
-
if isinstance(
|
|
75
|
-
|
|
76
|
-
for
|
|
77
|
-
|
|
78
|
-
if A._ignore_line(
|
|
79
|
-
if
|
|
80
|
-
if
|
|
81
|
-
for(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
67
|
+
H=len(E);D=ColsDataset(cols_count=H,names=[f"Column {A+1}"for A in range(H)],numeric_col_indexes=[A for A in range(H)],data=[[]for A in range(H)])
|
|
68
|
+
if G:D.names=G.data
|
|
69
|
+
if B and B.ignore_columns:
|
|
70
|
+
if isinstance(B.ignore_columns[0],str):D.numeric_col_indexes=[A for A in D.numeric_col_indexes if D.names[A]not in B.ignore_columns]
|
|
71
|
+
if isinstance(B.ignore_columns[0],int):T=[A-1 for A in B.ignore_columns];D.numeric_col_indexes=[A for A in D.numeric_col_indexes if A not in T]
|
|
72
|
+
if B and B.select_columns:
|
|
73
|
+
if isinstance(B.select_columns[0],str):D.numeric_col_indexes=[A for A in D.numeric_col_indexes if D.names[A]in B.select_columns]
|
|
74
|
+
if isinstance(B.select_columns[0],int):U=[A-1 for A in B.select_columns];D.numeric_col_indexes=[A for A in D.numeric_col_indexes if A in U]
|
|
75
|
+
F=I or 0
|
|
76
|
+
for P in islice(N,I,M):
|
|
77
|
+
F+=1
|
|
78
|
+
if A._ignore_line(P):continue
|
|
79
|
+
if G:
|
|
80
|
+
if G.ori_line_idx==F-1:continue
|
|
81
|
+
for(K,Q)in enumerate(E):
|
|
82
|
+
L=P[Q[0]:Q[1]].strip();R=string_2_float(L)
|
|
83
|
+
if R is _A:
|
|
84
|
+
if not B.nulls_allowed:raise Exception(f"line_nb {F} col_index {K} value is empty not allowed, or not a float")
|
|
85
|
+
elif L and B.nulls_strings:
|
|
86
|
+
if L not in B.nulls_strings:raise Exception(f"line_nb {F} col_index {K} value is not a float")
|
|
87
|
+
D.data[K].append(R)
|
|
88
|
+
D.origin_line_nb.append(F)
|
|
89
|
+
D.rows_count=len(D.origin_line_nb);N.close();A.cols_dataset=D;A.raw_lines_number=F;A.metrics=_A
|
|
90
|
+
if C.metrics:A.metrics=D.compute_metrics(C.metrics)
|
|
85
91
|
A.curves=_A;A.cols_curve=_A
|
|
86
|
-
if
|
|
87
|
-
if
|
|
88
|
-
A.curves,V=
|
|
92
|
+
if C.cols and C.cols.curve_parser:
|
|
93
|
+
if C.cols.curve_parser.name==ReaderCurveParserNameConfig.COL_X:
|
|
94
|
+
A.curves,V=D.get_curves_col_x(C.cols.curve_parser.parameters.x)
|
|
89
95
|
if A.curves:A.cols_curve=ColsCurves(type=ReaderCurveParserNameConfig.COL_X,info=V,curves=A.curves)
|
|
90
|
-
elif
|
|
96
|
+
elif C.cols.curve_parser.name==ReaderCurveParserNameConfig.COLS_COUPLE:raise NotImplementedError('cols_couple not implemented')
|
|
91
97
|
else:raise Exception('Curve parser not supported.')
|
|
92
98
|
def compare(A,compare_floats,param_reader,param_is_ref=True):D=param_is_ref;C=param_reader;B=compare_floats;E=A.cols_dataset if D else C.cols_dataset;F=A.cols_dataset if not D else C.cols_dataset;G=A.cols_curve;I,H=B.compare_errors.add_group('node','txt cols');return compare(H,B,E,F,G)
|
|
93
99
|
def class_info(A):return{'cols':A.cols_dataset.names,'raw_lines_number':A.raw_lines_number,'curves':A.curves,'metrics':A.metrics}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from scilens.readers.reader_interface import ReaderInterface
|
|
3
|
+
from scilens.config.models import ReaderXmlConfig,ReaderTreeBaseConfig
|
|
4
|
+
from scilens.components.compare_floats import CompareFloats
|
|
5
|
+
from.tree import Tree
|
|
6
|
+
from scilens.utils.xml import etree_to_dict
|
|
7
|
+
import xml.etree.ElementTree as ET
|
|
8
|
+
class ReaderXml(ReaderInterface):
|
|
9
|
+
configuration_type_code='xml';category='datalines';extensions=['XML']
|
|
10
|
+
def read(A,config):D=None;B=config;A.reader_options=B;E=open(A.origin.path,'r',encoding=A.encoding);C=ET.parse(E);F=C.getroot();G=etree_to_dict(F);E.close();C=Tree(ReaderTreeBaseConfig(path_include_patterns=B.path_include_patterns if B else D,path_exclude_patterns=B.path_exclude_patterns if B else D));A.floats_data=C.data_to_numeric_values(G);A.metrics=D
|
|
11
|
+
def compare(A,compare_floats,param_reader,param_is_ref=True):C=param_is_ref;B=param_reader;D=A if C else B;E=A if not C else B;Tree.compare(compare_floats,test_floats_data=D.floats_data,ref_floats_data=E.floats_data)
|
|
12
|
+
def class_info(A):return{'metrics':A.metrics}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from scilens.readers.reader_interface import ReaderInterface
|
|
3
|
+
from scilens.config.models import ReaderYamlConfig,ReaderTreeBaseConfig
|
|
4
|
+
from scilens.components.compare_floats import CompareFloats
|
|
5
|
+
import yaml
|
|
6
|
+
from.tree import Tree
|
|
7
|
+
class ReaderYaml(ReaderInterface):
|
|
8
|
+
configuration_type_code='yaml';category='datalines';extensions=['YAML']
|
|
9
|
+
def read(A,config):C=None;B=config;A.reader_options=B;D=open(A.origin.path,'r',encoding=A.encoding);E=yaml.safe_load(D);D.close();F=Tree(ReaderTreeBaseConfig(path_include_patterns=B.path_include_patterns if B else C,path_exclude_patterns=B.path_exclude_patterns if B else C));A.floats_data=F.data_to_numeric_values(E);A.metrics=C
|
|
10
|
+
def compare(A,compare_floats,param_reader,param_is_ref=True):C=param_is_ref;B=param_reader;D=A if C else B;E=A if not C else B;Tree.compare(compare_floats,test_floats_data=D.floats_data,ref_floats_data=E.floats_data)
|
|
11
|
+
def class_info(A):return{'metrics':A.metrics}
|
scilens/readers/tree.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
_B=False
|
|
2
|
+
_A=None
|
|
3
|
+
import logging,fnmatch
|
|
4
|
+
from scilens.components.compare_floats import CompareFloats
|
|
5
|
+
from scilens.components.compare_models import SEVERITY_ERROR,Compare2ValuesResults
|
|
6
|
+
from scilens.config.models.reader_format_trees import ReaderTreeBaseConfig
|
|
7
|
+
NumericPathValues=list[tuple[str,float]]
|
|
8
|
+
def find_numeric_values_and_keys(k,v):
|
|
9
|
+
A=[]
|
|
10
|
+
if isinstance(v,dict):
|
|
11
|
+
for(B,C)in v.items():A.extend(find_numeric_values_and_keys(f"{k}/{B}",C))
|
|
12
|
+
elif isinstance(v,list):
|
|
13
|
+
for(B,C)in enumerate(v):A.extend(find_numeric_values_and_keys(f"{k}[{B}]",C))
|
|
14
|
+
elif isinstance(v,(int,float)):A.append((k,v))
|
|
15
|
+
elif isinstance(v,str):
|
|
16
|
+
try:D=float(v);A.append((k,D))
|
|
17
|
+
except ValueError:pass
|
|
18
|
+
return A
|
|
19
|
+
def find_numeric_values(v):
|
|
20
|
+
A=[]
|
|
21
|
+
if isinstance(v,dict):
|
|
22
|
+
for B in v.values():A.extend(find_numeric_values(B))
|
|
23
|
+
elif isinstance(v,list):
|
|
24
|
+
for C in v:A.extend(find_numeric_values(C))
|
|
25
|
+
elif isinstance(v,(int,float)):A.append(v)
|
|
26
|
+
elif isinstance(v,str):
|
|
27
|
+
try:D=float(v);A.append(D)
|
|
28
|
+
except ValueError:pass
|
|
29
|
+
return A
|
|
30
|
+
def filter_numeric_values_by_patterns(numeric_values_with_keys,include_patterns=_A,exclude_patterns=_A):
|
|
31
|
+
E=exclude_patterns;D=include_patterns;F=[]
|
|
32
|
+
for(B,G)in numeric_values_with_keys:
|
|
33
|
+
A=True
|
|
34
|
+
if E:
|
|
35
|
+
for C in E:
|
|
36
|
+
if fnmatch.fnmatch(B,C):A=_B;break
|
|
37
|
+
if A and D:
|
|
38
|
+
A=_B
|
|
39
|
+
for C in D:
|
|
40
|
+
if fnmatch.fnmatch(B,C):A=True;break
|
|
41
|
+
if A:F.append((B,G))
|
|
42
|
+
return F
|
|
43
|
+
class Tree:
|
|
44
|
+
def __init__(A,config):A.config=config
|
|
45
|
+
def data_to_numeric_values(D,data):
|
|
46
|
+
E=D.config.path_include_patterns;F=D.config.path_exclude_patterns;logging.debug(f"Extracting numeric values from tree data");A=find_numeric_values_and_keys('',data);logging.debug(f"Found {len(A)} numeric values in tree data, 10 first:")
|
|
47
|
+
for(B,C)in A[:10]:logging.debug(f" {B}: {C}")
|
|
48
|
+
if E or F:
|
|
49
|
+
logging.debug(f"Applying include/exclude patterns");A=filter_numeric_values_by_patterns(A,include_patterns=E,exclude_patterns=F);logging.debug(f"After filtering, {len(A)} numeric values remain, 10 first:")
|
|
50
|
+
for(B,C)in A[:10]:logging.debug(f" {B}: {C}")
|
|
51
|
+
return A
|
|
52
|
+
@classmethod
|
|
53
|
+
def compare(V,compare_floats,test_floats_data,ref_floats_data):
|
|
54
|
+
Q='diff';P='tree';C=ref_floats_data;B=test_floats_data;A=compare_floats;R,S=A.compare_errors.add_group('node','json');R,D=A.compare_errors.add_group(P,P,parent=S);B=sorted(B,key=lambda x:x[0]);C=sorted(C,key=lambda x:x[0]);E=_B;K=len(B);L=len(C);T=max(K,L);F=0;G=0
|
|
55
|
+
for W in range(T):
|
|
56
|
+
H,M=B[F]if F<K else(_A,_A);J,N=C[G]if G<L else(_A,_A)
|
|
57
|
+
if H!=J:
|
|
58
|
+
D.incr(Q)
|
|
59
|
+
if not E:
|
|
60
|
+
if J>H:F+=1;I=f"Test: {H}"
|
|
61
|
+
else:G+=1;I=f"Ref.: {J}"
|
|
62
|
+
E=A.compare_errors.add(D,Compare2ValuesResults(SEVERITY_ERROR,'Different keys for numeric values'),info=I)
|
|
63
|
+
continue
|
|
64
|
+
F+=1;G+=1;I=H;U=M-N
|
|
65
|
+
if U==0:continue
|
|
66
|
+
else:
|
|
67
|
+
D.incr(Q)
|
|
68
|
+
if not E:
|
|
69
|
+
O=A.compare_2_values(M,N)
|
|
70
|
+
if O:E=A.compare_errors.add(D,O,info=I)
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
<th class="p-2" rowspan="2">x</th>
|
|
27
27
|
<th class="p-2" rowspan="2">y</th>
|
|
28
28
|
{% endif %}
|
|
29
|
+
{% if group.type == "tree" %}
|
|
30
|
+
<th class="p-2" colspan="2" rowspan="2">Key</th>
|
|
31
|
+
{% endif %}
|
|
29
32
|
</tr>
|
|
30
33
|
<tr>
|
|
31
34
|
<th class="p-2 test-bg-50">Test</th>
|
|
@@ -86,6 +89,10 @@
|
|
|
86
89
|
<td class="number">{{ item.info.y }}</td>
|
|
87
90
|
{% endif %}
|
|
88
91
|
|
|
92
|
+
{% if group.type == "tree" %}
|
|
93
|
+
<td>{{ item.info }}</td>
|
|
94
|
+
{% endif %}
|
|
95
|
+
|
|
89
96
|
</tr>
|
|
90
97
|
{% endfor %}
|
|
91
98
|
{% endfor %}
|
scilens/utils/xml.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import xml.etree.ElementTree as ET
|
|
2
|
+
def etree_to_dict(t):
|
|
3
|
+
C={t.tag:{}if t.attrib else None};D=list(t)
|
|
4
|
+
if D:
|
|
5
|
+
A={}
|
|
6
|
+
for G in map(etree_to_dict,D):
|
|
7
|
+
for(B,E)in G.items():
|
|
8
|
+
if B in A:
|
|
9
|
+
if isinstance(A[B],list):A[B].append(E)
|
|
10
|
+
else:A[B]=[A[B],E]
|
|
11
|
+
else:A[B]=E
|
|
12
|
+
C={t.tag:A}
|
|
13
|
+
if t.attrib:C[t.tag].update(('@'+A,B)for(A,B)in t.attrib.items())
|
|
14
|
+
if t.text:
|
|
15
|
+
F=t.text.strip()
|
|
16
|
+
if D or t.attrib:
|
|
17
|
+
if F:C[t.tag]['#text']=F
|
|
18
|
+
else:C[t.tag]=F
|
|
19
|
+
return C
|
|
@@ -10,9 +10,9 @@ scilens/components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
|
10
10
|
scilens/components/analyse_folder.py,sha256=yqc-dscKaHLZJCYeXGak2v0c3F2aeX0E11AFPfya6r0,208
|
|
11
11
|
scilens/components/compare_2_files.py,sha256=IlgfAi9GTAa9TlCXXjCkSZut_yJoCoXh31ctEokAjjE,2330
|
|
12
12
|
scilens/components/compare_errors.py,sha256=vGb4DWP89HMIeBm0dZU2nt-ksppAs_37xtCHaPd0w5Y,1640
|
|
13
|
-
scilens/components/compare_floats.py,sha256=
|
|
13
|
+
scilens/components/compare_floats.py,sha256=g6tD8QodXdz3kcgMW1-ccZp6A4bFia3xll8mPQ0rlg8,4685
|
|
14
14
|
scilens/components/compare_folders.py,sha256=s7cgo2JhZi8F7tt3lGbPhkaO2726Lz3c4LYGP2HbWtA,2773
|
|
15
|
-
scilens/components/compare_models.py,sha256=
|
|
15
|
+
scilens/components/compare_models.py,sha256=EvxBZ1hPhqViCiTx7pfVIcwllkHjCjuc0mNEVa0Yqw0,941
|
|
16
16
|
scilens/components/executor.py,sha256=PLeKolzPd4wPX8e6DdfOb0uHGky3DxTcKN9QtB6oe3Q,3712
|
|
17
17
|
scilens/components/file_reader.py,sha256=7SbKCqb4Co_pqAKX3wweYhqAcVkU7BDlT903sLd76Kc,1407
|
|
18
18
|
scilens/components/num/vectors.py,sha256=r2FBOzGfAFkLiLRShIp72V3chDvIR0ZJ3f4_p4m7gzY,782
|
|
@@ -20,21 +20,22 @@ scilens/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
20
20
|
scilens/config/cli_run_options.py,sha256=Ls7yK5QDUPFbk73nbjGuPvuRbBRYw4Miag5ISpu3prg,281
|
|
21
21
|
scilens/config/env_var.py,sha256=NqNBoIfngJEXaGEm7jGqre5pmkJ9eUjiWzbDrTVfi2c,292
|
|
22
22
|
scilens/config/load.py,sha256=ltcv90GlsMJR2FE2ZL_jDscL7k5aGoHoMatWw61lrTw,1672
|
|
23
|
-
scilens/config/models/__init__.py,sha256=
|
|
23
|
+
scilens/config/models/__init__.py,sha256=lTpDxeSVAGOJtH9MFg25yh0vwwf3VdMFlhdbrhgkk6o,776
|
|
24
24
|
scilens/config/models/app.py,sha256=UCC7Be6gOwvxQpM5Wl1HIf2Xb61CmslFzXvj_50eqsQ,1558
|
|
25
25
|
scilens/config/models/base.py,sha256=k92CR8TA5L8dZJtg28c8albk16AK9-3umdosA7aYsxw,499
|
|
26
26
|
scilens/config/models/compare.py,sha256=IiH1wJWYVnPnUJ3BiMeGDy8CFHwPOw1nQS2wfk-0p44,2152
|
|
27
|
-
scilens/config/models/compare_float_thresholds.py,sha256=
|
|
27
|
+
scilens/config/models/compare_float_thresholds.py,sha256=4l-AMfzpOUnBYU9hsSFAmIL-B6OyfQeVnsiAhRZSYsQ,2153
|
|
28
28
|
scilens/config/models/execute.py,sha256=yF_q8swd4-s2KyT_RwtSzOW41AY5GiEZaLhGUGJBU0Y,2340
|
|
29
29
|
scilens/config/models/execute_and_compare.py,sha256=aIWF1NIgdq5USS9ZVWOKgpEyMagCvqYYWYSXWvBBgjg,597
|
|
30
30
|
scilens/config/models/file_reader.py,sha256=0-ldLt4YVmb2IwdfEHiIqDsioyXwqSkxrlfuEOmcyrA,1191
|
|
31
|
-
scilens/config/models/reader_format_cols.py,sha256=
|
|
31
|
+
scilens/config/models/reader_format_cols.py,sha256=1SbSqBdwwrc516N3xz80S8jiQQrqQ5zWnRT0Zfa1iEc,3875
|
|
32
32
|
scilens/config/models/reader_format_csv.py,sha256=KWEH0c12n6hdaWAKdHXYMT5SvH4UqBFvP7d3ZkJr7r8,1620
|
|
33
33
|
scilens/config/models/reader_format_netcdf.py,sha256=Skr5lZACqVRrrlvs7R1RVFBpMTDthLJN-Fbs24jtb7o,1271
|
|
34
|
-
scilens/config/models/
|
|
34
|
+
scilens/config/models/reader_format_trees.py,sha256=5T9YU0iG5e3bfi7DTjqomT6CCwQJiPhx0wBp3i_Asps,564
|
|
35
|
+
scilens/config/models/reader_format_txt.py,sha256=wE4wHJlP1Q9DMyhIkSJ2Je3CSvk2p_S46sUbmYNHUh0,1374
|
|
35
36
|
scilens/config/models/reader_format_txt_fixed_cols.py,sha256=XmmFS0LdGR81XCjJIyW4cngivFo_8drckqe_k8fhqJk,1385
|
|
36
37
|
scilens/config/models/reader_metrics.py,sha256=uLwyd2vE4GRHbArYRv1BRH_acTL1hbFB7HgZRDJiAJg,965
|
|
37
|
-
scilens/config/models/readers.py,sha256=
|
|
38
|
+
scilens/config/models/readers.py,sha256=x3-I_TvFrR5_lS6Po_ns9hRjXqMKGqFygo8UUlwxTJ4,2514
|
|
38
39
|
scilens/config/models/report.py,sha256=_4W96v5izWCC_CrMzh3PM0mZIUAa3L26ZQqjV0Mv0f4,1008
|
|
39
40
|
scilens/config/models/report_html.py,sha256=IsKlmE7QbSTiPrOaxPc48Ne7xPE5yqTcLjxqN_i-unY,3803
|
|
40
41
|
scilens/config/models/report_output.py,sha256=XfzTsd1G3QjbZFer9dkWa1pa3HKbmK85UcHg6A7loOQ,890
|
|
@@ -50,15 +51,19 @@ scilens/processors/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
|
50
51
|
scilens/processors/models/results.py,sha256=KoWxh13Zgi7PuPql8hkf4VjCis42ZxAuzIgJxBWVaX8,119
|
|
51
52
|
scilens/processors/processor_interface.py,sha256=jzMp1529JXnMGTJijVy6b_1zmARAMNv70f2lgys7vn4,452
|
|
52
53
|
scilens/readers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
|
-
scilens/readers/cols_dataset.py,sha256=
|
|
54
|
+
scilens/readers/cols_dataset.py,sha256=Gqb_uE3bUOJKBs3LpEWghhT6bBB0I0BIKT0mUQCDpf4,4084
|
|
54
55
|
scilens/readers/exceptions.py,sha256=JzmxcjnR5sH-IOWVeCC5A1bSwxv-jCAtIJvDjzx1CTI,32
|
|
55
56
|
scilens/readers/mat_dataset.py,sha256=Z9TYDWaH2aqdniLNDjlpR6VVNHMSARjh52clhdMyOn4,1496
|
|
56
|
-
scilens/readers/reader_csv.py,sha256=
|
|
57
|
+
scilens/readers/reader_csv.py,sha256=ISEjLjMFcRziryZTYyH-Jg4vOtgPVwAH1kgfEQBHVAA,5619
|
|
57
58
|
scilens/readers/reader_interface.py,sha256=r1pu9LyweTGXU8YfI3FPZy1Em4stzmJb-6j90j1tPQQ,938
|
|
58
|
-
scilens/readers/
|
|
59
|
+
scilens/readers/reader_json.py,sha256=WVztvb00vnJvvt9btnmlbLV3ImknGOy-1ACDlbf3llg,940
|
|
60
|
+
scilens/readers/reader_manager.py,sha256=oBCBaDKPzgV4CtT9RgxppDbrvjf7XiRXJ5q35q2cSds,3033
|
|
59
61
|
scilens/readers/reader_txt.py,sha256=U3hGIorj-Nv-jq6zYtvbDv2LQBHTgW52PHbV8A5FMA8,4526
|
|
60
|
-
scilens/readers/reader_txt_fixed_cols.py,sha256=
|
|
62
|
+
scilens/readers/reader_txt_fixed_cols.py,sha256=_XaWkPEuuGy7p2A2VS0UHFS2RX1dWidYogzRWK022dg,5197
|
|
63
|
+
scilens/readers/reader_xml.py,sha256=iGn_O8GDEBR8owNKYHS3r1KlAfT9oJuanZeRDuYrgnQ,1035
|
|
64
|
+
scilens/readers/reader_yaml.py,sha256=6lZ77ls327r8T743OFCTg9doQNZQoa4L6O3sLu7LaLg,945
|
|
61
65
|
scilens/readers/transform.py,sha256=kppfgPkXymF0qtquFivuosLVfF66L9bE-wGx-3bMHv8,307
|
|
66
|
+
scilens/readers/tree.py,sha256=GDDFUfjcJaooz_2WTajAumSIsB9aCX8CizWvMFAaCGE,2844
|
|
62
67
|
scilens/report/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
63
68
|
scilens/report/assets/logo.svg,sha256=W-1OVqcvdBjf-1AHHcV6WciIUqBoVFUh52Tc3o_jqtA,4519
|
|
64
69
|
scilens/report/assets/logo_cglb.svg,sha256=tEpkSr2h-jjQMecqiHef98Mxod4GD5j5nCQaFloTYso,2411
|
|
@@ -79,7 +84,7 @@ scilens/report/templates/compare_12_sections.html,sha256=X0YP_LgpzdIoM2rqEip9uoR
|
|
|
79
84
|
scilens/report/templates/compare_13_section_images.html,sha256=RZ2WGpbuW9eCgmY8szNNVPCTtllm8KczfticBIWxZhA,935
|
|
80
85
|
scilens/report/templates/compare_13_section_numbers copy.html,sha256=0PWK_I2kNX3LjPLkkY4eSYIeB7YFkA28nk-PPLDhnaY,1753
|
|
81
86
|
scilens/report/templates/compare_13_section_numbers.html,sha256=9etEMSqwrDyJIn_nMbKEVaDgnFL_hBxSjPR-hU2wgDI,851
|
|
82
|
-
scilens/report/templates/compare_13_section_numbers_table.html,sha256=
|
|
87
|
+
scilens/report/templates/compare_13_section_numbers_table.html,sha256=bLh0hBp8lj7iehd0wrgPi_owsX_Aft-aciwWXfQSJhw,3110
|
|
83
88
|
scilens/report/templates/html_macros.html,sha256=jKatNSn4nX_72_wHl0-0dhxZZZBoGDGpOg7E7TMZSGs,1185
|
|
84
89
|
scilens/report/templates/html_widget_err.html,sha256=sjbtooSh7RGFs8kcct4_tMi_n8FQiaoqRhUjBzHduZM,336
|
|
85
90
|
scilens/report/templates/index.html,sha256=02nQg3yqGX69g4W7Zy0EKU_SOrskMd3N4hZhg4uAzu8,6089
|
|
@@ -116,7 +121,8 @@ scilens/utils/template.py,sha256=KXBfzeCRQyBT0KNzWvGEVNVqTlRStyx4V3c_N4H29sc,402
|
|
|
116
121
|
scilens/utils/time_tracker.py,sha256=DdVBoMpVLXrX0qZZXyLm4g38EwDVLlRcBqcpNex1mYY,545
|
|
117
122
|
scilens/utils/vectors.py,sha256=4N2BZSC5n3HgZqPujDGF5NdjVmSL1rOHb_qw4OoABQY,103
|
|
118
123
|
scilens/utils/web.py,sha256=MAFWpIFOKz7QhqDoFh-Qwstvc76KpcxstSgHFT8FOL4,901
|
|
119
|
-
scilens
|
|
120
|
-
scilens-0.
|
|
121
|
-
scilens-0.
|
|
122
|
-
scilens-0.
|
|
124
|
+
scilens/utils/xml.py,sha256=HcB-ymJy8o4lsczHpXznGrbYahq_3cnnkPOdRfWdHfg,461
|
|
125
|
+
scilens-0.5.1.dist-info/METADATA,sha256=DOsseDeHbJk5qKFuuvkZGdNkTOc4BiJb_nGfmsxa_qw,1405
|
|
126
|
+
scilens-0.5.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
127
|
+
scilens-0.5.1.dist-info/entry_points.txt,sha256=DaKGgxUEUv34GJAoXtta6ecL37ercejep9sCSSRQK2s,48
|
|
128
|
+
scilens-0.5.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|