MCPcopy Create free account
hub / github.com/Derive-Risk/pyfair / _construct_output

Method _construct_output

pyfair/report/simple_report.py:29–94  ·  view source on GitHub ↗

HTML creation function called by FairBaseReport.to_html() This is responsible for creating all of the HTML for a given report type.

(self)

Source from the content-addressed store, hash-verified

27 self._template = self._template_paths['simple'].read_text()
28
29 def _construct_output(self):
30 """HTML creation function called by FairBaseReport.to_html()
31
32 This is responsible for creating all of the HTML for a given report
33 type.
34
35 """
36 # Alias
37 t = self._template
38 # Add css
39 t = t.replace('{STYLE}', self._css)
40 # Add Metadata
41 t = t.replace('{METADATA}', self._get_metadata_table())
42 # Get logo tag
43 b64 = self.base64ify(self._logo_location)
44 t = t.replace('{PYTHON_LOGO}', b64)
45
46 # Overview Table
47 overview_html = self._get_overview_table(self._model_or_models)
48 t = t.replace('{OVERVIEW_DATAFRAME}', overview_html)
49
50 # Overview Hist
51 hist = self._get_distribution(self._model_or_models.values())
52 t = t.replace('{HIST}', hist)
53
54 # Overview Exceedence Curves
55 exceed = self._get_exceedence_curves(self._model_or_models.values())
56 t = t.replace('{EXCEEDENCE}', exceed)
57
58 # Create parameter html
59 parameter_html = ''
60 for name, model in self._model_or_models.items():
61 parameter_html += "<h1>{}</h1>".format(name)
62
63 # Create images which differ based on type
64 if model.__class__.__name__ == 'FairModel':
65 parameter_html += self._get_tree(model)
66 if model.__class__.__name__ == 'FairMetaModel':
67 parameter_html += self._get_violins(model)
68
69 # Create table
70
71 # Create tables which differ based on type
72 if model.__class__.__name__ == 'FairModel':
73 parameter_html += self._get_model_parameter_table(model)
74 if model.__class__.__name__ == 'FairMetaModel':
75 parameter_html += self._get_metamodel_parameter_table(model)
76
77 parameter_html += "<br>"
78
79 # TODO Text wrap
80 t = t.replace('{PARAMETER_HTML}', parameter_html)
81
82 # JSON and Source
83 json = ''
84 for name, model in self._model_or_models.items():
85 json += name
86 json += '\n====================\n'

Callers 1

test_generate_imageMethod · 0.95

Calls 11

_get_metadata_tableMethod · 0.80
base64ifyMethod · 0.80
_get_overview_tableMethod · 0.80
_get_distributionMethod · 0.80
_get_treeMethod · 0.80
_get_violinsMethod · 0.80
_get_caller_sourceMethod · 0.80
to_jsonMethod · 0.45

Tested by 1

test_generate_imageMethod · 0.76