22from IPython .display import display , Math , HTML # type: ignore
33from dataclasses import dataclass , field
44import re
5- import hypernetx as hnx
6- import matplotlib .pyplot as plt
7- import sympy
8- from latex2sympy2 import latex2sympy
5+ import hypernetx as hnx # type: ignore
6+ import matplotlib .pyplot as plt # type: ignore
7+ import sympy # type: ignore
8+ from latex2sympy2 import latex2sympy # type: ignore
99
1010
1111OPTION_LIST = {
@@ -137,7 +137,9 @@ def get_eq_hypergraph(api_results, api_requirements, with_printing=True):
137137 # Prepare the data for HyperNetX visualization
138138 hyperedges = {}
139139 for _eq , details in api_results ["results" ].items ():
140- hyperedges [_get_latex_string_format (details ["latex_equation" ])] = details ["used_vars" ]
140+ hyperedges [_get_latex_string_format (details ["latex_equation" ])] = details [
141+ "used_vars"
142+ ]
141143
142144 # Create the hypergraph using HyperNetX
143145 h = hnx .Hypergraph (hyperedges )
@@ -159,7 +161,9 @@ def get_eq_hypergraph(api_results, api_requirements, with_printing=True):
159161 symbol_explanations = _get_node_names_for_node_lables (node_labels , api_requirements )
160162
161163 # Adding the symbol explanations as a legend
162- explanation_text = "\n " .join ([f"${ symbol } $: { desc } " for symbol , desc in symbol_explanations ])
164+ explanation_text = "\n " .join (
165+ [f"${ symbol } $: { desc } " for symbol , desc in symbol_explanations ]
166+ )
163167 plt .annotate (
164168 explanation_text ,
165169 xy = (1.05 , 0.5 ),
@@ -226,6 +230,7 @@ def _add_used_vars_to_results(api_results, api_requirements):
226230
227231 return api_results
228232
233+
229234############################################################################################################
230235
231236
@@ -372,7 +377,9 @@ def display_table(change):
372377 value = default_value ,
373378 layout = widgets .Layout (width = "150px" ),
374379 )
375- units_text = widgets .Text (layout = widgets .Layout (width = "150px" ), value = default_unit )
380+ units_text = widgets .Text (
381+ layout = widgets .Layout (width = "150px" ), value = default_unit
382+ )
376383
377384 # Combine widgets into a horizontal box
378385 row = widgets .HBox (
@@ -420,7 +427,9 @@ def submit_values(_):
420427
421428 # Function to add a new requirement row
422429 def add_req (_ ):
423- unique_key = f"req_{ len ([k for k in value_widgets if k .startswith ('req_' )]) + 1 } "
430+ unique_key = (
431+ f"req_{ len ([k for k in value_widgets if k .startswith ('req_' )]) + 1 } "
432+ )
424433
425434 # Create a dropdown for variable selection with dynamic width
426435 variable_dropdown = widgets .Dropdown (
@@ -434,7 +443,9 @@ def add_req(_):
434443 layout = widgets .Layout (width = "150px" ),
435444 )
436445
437- units_text = widgets .Text (placeholder = "Units" , layout = widgets .Layout (width = "150px" ))
446+ units_text = widgets .Text (
447+ placeholder = "Units" , layout = widgets .Layout (width = "150px" )
448+ )
438449
439450 new_row = widgets .HBox ([variable_dropdown , value_text , units_text ])
440451
0 commit comments