Skip to content

Commit cac4dad

Browse files
committed
linted
1 parent 324f6ee commit cac4dad

File tree

15 files changed

+306
-370
lines changed

15 files changed

+306
-370
lines changed

src/axiomatic/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,14 @@
8787
from . import (
8888
code_execution,
8989
document,
90-
91-
9290
formalization,
9391
fso,
9492
lean,
9593
pic,
9694
requirements,
9795
tools,
9896
)
99-
from .client import AsyncAxiomatic, Axiomatic, AxtractHelper
97+
from .client import AsyncAxiomatic, Axiomatic, AxtractHelper
10098
from .environment import AxiomaticEnvironment
10199
from .version import __version__
102100

src/axiomatic/axtract/axtract_report.py

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,14 @@
189189
</head>
190190
"""
191191

192+
192193
def create_report(report_data: EquationExtractionResponse, report_path: str = "./report.html"):
193194
"""
194195
Creates an HTML report for the extracted equations.
195196
"""
196-
html_content = HTML_HEAD + """
197+
html_content = (
198+
HTML_HEAD
199+
+ """
197200
<body>
198201
<div class="menu-bar">
199202
<a href="#" onclick="showHypergraph()">Relation Graph</a>
@@ -203,7 +206,8 @@ def create_report(report_data: EquationExtractionResponse, report_path: str = ".
203206
<div class="container">
204207
<div class="equation-list">
205208
"""
206-
209+
)
210+
207211
# Add equations to the list
208212
for i, eq in enumerate(report_data.equations):
209213
html_content += f"""
@@ -212,15 +216,15 @@ def create_report(report_data: EquationExtractionResponse, report_path: str = ".
212216
\\[{eq.original_format}\\]
213217
</div>
214218
"""
215-
219+
216220
html_content += """
217221
</div>
218222
<div class="details-panel">
219223
<div id="empty-message" style="text-align: center; color: #666;">
220224
Select an equation to view details
221225
</div>
222226
"""
223-
227+
224228
# Add equation details
225229
for i, eq in enumerate(report_data.equations):
226230
html_content += f"""
@@ -239,20 +243,20 @@ def create_report(report_data: EquationExtractionResponse, report_path: str = ".
239243
<th>Description</th>
240244
</tr>
241245
"""
242-
246+
243247
for symbol in eq.latex_symbols:
244248
html_content += f"""
245249
<tr>
246250
<td>\\({symbol.key}\\)</td>
247251
<td>{symbol.value}</td>
248252
</tr>
249253
"""
250-
254+
251255
html_content += """
252256
</table>
253257
</div>
254258
"""
255-
259+
256260
html_content += """
257261
</div>
258262
</div>
@@ -266,58 +270,54 @@ def create_report(report_data: EquationExtractionResponse, report_path: str = ".
266270
class="menu-button">Close</button>
267271
<div id="graph-container" style="width: 100%; height: 100%;">
268272
"""
269-
273+
270274
# Generate the relation graph as a separate HTML file
271275
graph_html = generate_relation_graph(report_data.equations)
272-
graph_file_path = os.path.join(os.path.dirname(report_path), 'relation_graph.html')
273-
with open(graph_file_path, 'w', encoding='utf-8') as f:
276+
graph_file_path = os.path.join(os.path.dirname(report_path), "relation_graph.html")
277+
with open(graph_file_path, "w", encoding="utf-8") as f:
274278
f.write(graph_html)
275-
279+
276280
# Extract just the graph content from the full HTML
277281
# This avoids duplicate HTML, head, body tags
278282
graph_content = extract_graph_content(graph_html)
279283
html_content += graph_content
280-
284+
281285
# Add the relation graph link to the main menu with proper styling
282286
html_content = html_content.replace(
283287
'<a href="#" onclick="showHypergraph()">Relation Graph</a>',
284-
f'<a href="{os.path.basename(graph_file_path)}" target="_blank" class="menu-button">Relation Graph</a>'
288+
f'<a href="{os.path.basename(graph_file_path)}" target="_blank" class="menu-button">Relation Graph</a>',
285289
)
286-
290+
287291
# Remove the menu-item related code since we're using menu-button class
288-
html_content = re.sub(
289-
r'\.menu-item \{.*?\}',
290-
'',
291-
html_content,
292-
flags=re.DOTALL
293-
)
294-
292+
html_content = re.sub(r"\.menu-item \{.*?\}", "", html_content, flags=re.DOTALL)
293+
295294
# Remove the showHypergraph and hideHypergraph functions
296295
html_content = re.sub(
297-
r'<script>\s*function showHypergraph\(\).*?function hideHypergraph\(\).*?</script>',
298-
'',
296+
r"<script>\s*function showHypergraph\(\).*?function hideHypergraph\(\).*?</script>",
297+
"",
299298
html_content,
300-
flags=re.DOTALL
299+
flags=re.DOTALL,
301300
)
302-
301+
303302
# Close all remaining tags if needed
304303
if "</div></div></div>" not in html_content:
305304
html_content += """
306305
</div>
307306
</div>
308307
</div>
309308
"""
310-
311-
with open(report_path, 'w', encoding='utf-8') as f:
309+
310+
with open(report_path, "w", encoding="utf-8") as f:
312311
f.write(html_content)
313312

313+
314314
def extract_graph_content(graph_html: str) -> str:
315315
"""
316316
Extracts the relevant graph content from the full HTML generated by pyvis.
317-
317+
318318
Args:
319319
graph_html: Full HTML string from pyvis
320-
320+
321321
Returns:
322322
String containing just the graph-specific content
323323
"""
@@ -330,8 +330,6 @@ def extract_graph_content(graph_html: str) -> str:
330330
if body_end != -1:
331331
# Extract just the graph content
332332
return graph_html[content_start:body_end]
333-
333+
334334
# Fallback if we can't parse it properly
335335
return graph_html
336-
337-

src/axiomatic/axtract/interactive_table.py

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
import ipywidgets as widgets # type: ignore
2-
from IPython.display import display # type: ignore
2+
from IPython.display import display # type: ignore
33
import json # type: ignore
4-
import os # type: ignore
4+
import os # type: ignore
55
from .axtract_report import EquationExtractionResponse
66
from .models import VariableRequirement
77

8-
def _find_symbol(name, variable_dict):
98

10-
matching_keys = [
11-
key for key, value in variable_dict.items() if name in value["name"]
12-
]
9+
def _find_symbol(name, variable_dict):
10+
matching_keys = [key for key, value in variable_dict.items() if name in value["name"]]
1311

1412
if not matching_keys:
1513
matching_keys.append("unknown")
1614

1715
return matching_keys[0]
1816

19-
def _requirements_from_table(results, variable_dict):
20-
2117

18+
def _requirements_from_table(results, variable_dict):
2219
requirements = []
2320

2421
for key, value in results["values"].items():
@@ -36,6 +33,7 @@ def _requirements_from_table(results, variable_dict):
3633

3734
return requirements
3835

36+
3937
def interactive_table(loaded_equations, file_path="./custom_presets.json"):
4038
"""
4139
Creates an interactive table for IMAGING_TELESCOPE,
@@ -60,7 +58,7 @@ def interactive_table(loaded_equations, file_path="./custom_presets.json"):
6058
# ---------------------------------------------------------------
6159
IMAGING_TELESCOPE_template = {
6260
"Resolution (panchromatic)": 0,
63-
"Ground sampling distance (panchromatic)":0,
61+
"Ground sampling distance (panchromatic)": 0,
6462
"Resolution (multispectral)": 0,
6563
"Ground sampling distance (multispectral)": 0,
6664
"Altitude": 0,
@@ -228,16 +226,8 @@ def display_table(change):
228226
default_value = PAYLOAD_1.get(row_name, 0.0)
229227
default_unit = IMAGING_TELESCOPE_UNITS.get(row_name, "")
230228
elif selected_option in custom_presets:
231-
default_value = (
232-
custom_presets[selected_option]
233-
.get(row_name, {})
234-
.get("Value", 0.0)
235-
)
236-
default_unit = (
237-
custom_presets[selected_option]
238-
.get(row_name, {})
239-
.get("Units", "")
240-
)
229+
default_value = custom_presets[selected_option].get(row_name, {}).get("Value", 0.0)
230+
default_unit = custom_presets[selected_option].get(row_name, {}).get("Units", "")
241231
else:
242232
default_value = 0.0
243233
default_unit = ""
@@ -271,7 +261,7 @@ def display_table(change):
271261
# ---------------------------------------------------------------
272262
# Store the requirements to return later
273263
requirements_result = [None] # Using a list to store mutable reference
274-
264+
275265
def submit_values(_):
276266
updated_values = {}
277267
for k, widget in value_widgets.items():
@@ -282,19 +272,19 @@ def submit_values(_):
282272

283273
result["values"] = updated_values
284274
requirements_result[0] = _requirements_from_table(result, variable_dict)
285-
275+
286276
# Display a confirmation message
287277
with message_output:
288278
message_output.clear_output()
289279
print("Requirements submitted successfully!")
290-
280+
291281
return requirements_result[0]
292282

293283
# ---------------------------------------------------------------
294284
# 8) add_req(): Adds a new, blank row to the bottom
295285
# ---------------------------------------------------------------
296286
def add_req(_):
297-
unique_key = (f"req_{len([kk for kk in value_widgets if kk.startswith('req_')]) + 1}")
287+
unique_key = f"req_{len([kk for kk in value_widgets if kk.startswith('req_')]) + 1}"
298288

299289
variable_dropdown = widgets.Dropdown(
300290
options=variable_names,
@@ -341,9 +331,7 @@ def delete_req(_):
341331
# - Also updates custom_presets + JSON file,
342332
# - So it persists across restarts.
343333
# ---------------------------------------------------------------
344-
custom_count = len(
345-
[k for k in preset_options_dict if k.startswith("Custom-")]
346-
)
334+
custom_count = len([k for k in preset_options_dict if k.startswith("Custom-")])
347335

348336
def save_requirements(_):
349337
nonlocal custom_count
@@ -376,26 +364,19 @@ def save_requirements(_):
376364
# ---------------------------------------------------------------
377365
# 11) Create & display the buttons
378366
# ---------------------------------------------------------------
379-
submit_button = widgets.Button(
380-
description="Submit", button_style="success")
367+
submit_button = widgets.Button(description="Submit", button_style="success")
381368
submit_button.on_click(submit_values)
382369

383-
add_req_button = widgets.Button(
384-
description="Add Requirement", button_style="primary"
385-
)
370+
add_req_button = widgets.Button(description="Add Requirement", button_style="primary")
386371
add_req_button.on_click(add_req)
387372

388-
del_req_button = widgets.Button(
389-
description="Delete Requirement", button_style="danger"
390-
)
373+
del_req_button = widgets.Button(description="Delete Requirement", button_style="danger")
391374
del_req_button.on_click(delete_req)
392375

393376
save_req_button = widgets.Button(description="Save", button_style="info")
394377
save_req_button.on_click(save_requirements)
395378

396-
buttons_box = widgets.HBox(
397-
[submit_button, add_req_button, del_req_button, save_req_button]
398-
)
379+
buttons_box = widgets.HBox([submit_button, add_req_button, del_req_button, save_req_button])
399380
display(buttons_box)
400381

401382
# Return the requirements object directly - it will be updated when submit is clicked
@@ -423,16 +404,12 @@ def _create_variable_dict(equation_response: EquationExtractionResponse) -> dict
423404
}
424405
"""
425406
variable_dict = {}
426-
407+
427408
# Iterate through all equations and their symbols
428409
for equation in equation_response.equations:
429410
for symbol in equation.latex_symbols:
430411
# Only add if not already present (avoid duplicates)
431412
if symbol.key not in variable_dict:
432413
variable_dict[symbol.key] = {"name": symbol.value}
433-
434-
return variable_dict
435-
436-
437-
438414

415+
return variable_dict

src/axiomatic/axtract/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from pydantic import BaseModel
22

3+
34
class DictItem(BaseModel):
45
key: str
56
value: str
@@ -23,4 +24,4 @@ class VariableRequirement(BaseModel):
2324
name: str
2425
value: float
2526
units: str
26-
tolerance: float
27+
tolerance: float

0 commit comments

Comments
 (0)