Skip to content

Commit 00b6a74

Browse files
authored
Merge pull request #38 from Axiomatic-AI/test
fixing issues that appeared due to new endpoints
2 parents a8fce51 + 3356671 commit 00b6a74

File tree

10 files changed

+204
-92
lines changed

10 files changed

+204
-92
lines changed

client_db.pkl

9.4 KB
Binary file not shown.

src/axiomatic/axtract/axtract_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .relation_graph import generate_relation_graph
2-
from .. import EquationExtractionResponse
2+
from .. import EquationProcessingResponse
33
import os
44
import re
55

@@ -190,7 +190,7 @@
190190
"""
191191

192192

193-
def create_report(report_data: EquationExtractionResponse, report_path: str = "./report.html"):
193+
def create_report(report_data: EquationProcessingResponse, report_path: str = "./report.html"):
194194
"""
195195
Creates an HTML report for the extracted equations.
196196
"""

src/axiomatic/axtract/interactive_table.py

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from IPython.display import display # type: ignore
33
import json # type: ignore
44
import os # type: ignore
5-
from .. import EquationExtractionResponse, VariableRequirement
5+
from .. import EquationProcessingResponse, VariableRequirement
6+
from typing import Dict, Any
67

78

89
def _find_symbol(name, variable_dict):
@@ -33,15 +34,15 @@ def _requirements_from_table(results, variable_dict):
3334
return requirements
3435

3536

36-
def interactive_table(loaded_equations, file_path="./custom_presets.json"):
37+
def interactive_table(loaded_equations: EquationProcessingResponse, file_path: str = "./custom_presets.json"):
3738
"""
3839
Creates an interactive table for IMAGING_TELESCOPE,
3940
PAYLOAD, and user-defined custom templates.
4041
Adds or deletes rows, and can save custom templates persistently in JSON.
4142
4243
Parameters
4344
----------
44-
loaded_equations : EquationExtractionResponse
45+
loaded_equations : EquationProcessingResponse
4546
The extracted equations containing variable information
4647
file_path : str, optional
4748
JSON file path where we load and save user-created custom templates.
@@ -55,49 +56,35 @@ def interactive_table(loaded_equations, file_path="./custom_presets.json"):
5556
# ---------------------------------------------------------------
5657
# 1) Define built-in templates and units directly inside the function
5758
# ---------------------------------------------------------------
58-
IMAGING_TELESCOPE_template = {
59-
"Resolution (panchromatic)": 0,
60-
"Ground sampling distance (panchromatic)": 0,
61-
"Resolution (multispectral)": 0,
62-
"Ground sampling distance (multispectral)": 0,
63-
"Altitude": 0,
64-
"Half field of view": 0,
65-
"Mirror aperture": 0,
66-
"F-number": 0,
67-
"Focal length": 0,
68-
"Pixel size (panchromatic)": 0,
69-
"Pixel size (multispectral)": 0,
70-
"Swath width": 0,
71-
}
7259

7360
IMAGING_TELESCOPE = {
74-
"Resolution (panchromatic)": 1.23529,
75-
"Ground sampling distance (panchromatic)": 0.61765,
76-
"Resolution (multispectral)": 1.81176,
77-
"Ground sampling distance (multispectral)": 0.90588,
61+
"Resolved Ground Detail, Panchromatic": 1.23529,
62+
"Ground Sample Distance, Panchromatic": 0.61765,
63+
"Resolved Ground Detail, Multispectral": 1.81176,
64+
"Ground Sample Distance, Multispectral": 0.90588,
7865
"Altitude": 420000,
79-
"Half field of view": 0.017104227,
80-
"Mirror aperture": 0.85,
81-
"F-number": 6.0,
66+
"Horizontal Field of View": 0.017104227,
67+
"Aperture diameter": 0.85,
68+
"f-number": 6.0,
8269
"Focal length": 5.1,
83-
"Pixel size (panchromatic)": 7.5e-6,
84-
"Pixel size (multispectral)": 11e-6,
85-
"Swath width": 14368.95,
70+
"Pixel pitch": 7.5e-6,
71+
"Pixel pitch of the multispectral sensor": 11e-6,
72+
"Swath Width": 14368.95,
8673
}
8774

8875
IMAGING_TELESCOPE_UNITS = {
89-
"Resolution (panchromatic)": "m",
90-
"Ground sampling distance (panchromatic)": "m",
91-
"Resolution (multispectral)": "m",
92-
"Ground sampling distance (multispectral)": "m",
76+
"Resolved Ground Detail, Panchromatic": "m",
77+
"Ground Sample Distance, Panchromatic": "m",
78+
"Resolved Ground Detail, Multispectral": "m",
79+
"Ground Sample Distance, Multispectral": "m",
9380
"Altitude": "m",
94-
"Half field of view": "rad",
95-
"Mirror aperture": "m",
96-
"F-number": "dimensionless",
81+
"Horizontal Field of View": "rad",
82+
"Aperture diameter": "m",
83+
"f-number": "dimensionless",
9784
"Focal length": "m",
98-
"Pixel size (panchromatic)": "m",
99-
"Pixel size (multispectral)": "m",
100-
"Swath width": "m",
85+
"Pixel pitch": "m",
86+
"Pixel pitch of the multispectral sensor": "m",
87+
"Swath Width": "m",
10188
}
10289

10390
PAYLOAD_1 = {
@@ -120,7 +107,6 @@ def interactive_table(loaded_equations, file_path="./custom_presets.json"):
120107
preset_options_dict = {
121108
"Select a template": [],
122109
"IMAGING TELESCOPE": list(IMAGING_TELESCOPE.keys()),
123-
"IMAGING TELESCOPE template": list(IMAGING_TELESCOPE_template.keys()),
124110
"PAYLOAD": list(PAYLOAD_1.keys()),
125111
}
126112

@@ -170,7 +156,7 @@ def save_custom_presets(custom_data, file_path):
170156
name_label_width = ["150px"]
171157

172158
# Dictionary to keep track of row widget references
173-
value_widgets = {}
159+
value_widgets: Dict[str, Any] = {}
174160

175161
# ---------------------------------------------------------------
176162
# 6) display_table(change): Re-populate rows when user selects a template
@@ -272,11 +258,6 @@ def submit_values(_):
272258
result["values"] = updated_values
273259
requirements_result[0] = _requirements_from_table(result, variable_dict)
274260

275-
# Display a confirmation message
276-
with message_output:
277-
message_output.clear_output()
278-
print("Requirements submitted successfully!")
279-
280261
return requirements_result[0]
281262

282263
# ---------------------------------------------------------------
@@ -382,14 +363,14 @@ def save_requirements(_):
382363
return requirements_result
383364

384365

385-
def _create_variable_dict(equation_response: EquationExtractionResponse) -> dict:
366+
def _create_variable_dict(equation_response: EquationProcessingResponse) -> dict:
386367
"""
387-
Creates a variable dictionary from an EquationExtractionResponse object
368+
Creates a variable dictionary from an EquationProcessingResponse object
388369
for use with the interactive_table function.
389370
390371
Parameters
391372
----------
392-
equation_response : EquationExtractionResponse
373+
equation_response : EquationProcessingResponse
393374
The equation extraction response containing equations and their symbols
394375
395376
Returns
@@ -406,9 +387,14 @@ def _create_variable_dict(equation_response: EquationExtractionResponse) -> dict
406387

407388
# Iterate through all equations and their symbols
408389
for equation in equation_response.equations:
409-
for symbol in equation.latex_symbols:
390+
391+
wolfram_symbols = equation.wolfram_symbols
392+
latex_symbols = [equation.latex_symbols[i].key for i in range(len(equation.latex_symbols))]
393+
names = [equation.latex_symbols[i].value for i in range(len(equation.latex_symbols))]
394+
395+
for symbol, name in zip(wolfram_symbols, names):
410396
# Only add if not already present (avoid duplicates)
411-
if symbol.key not in variable_dict:
412-
variable_dict[symbol.key] = {"name": symbol.value}
397+
if symbol not in variable_dict:
398+
variable_dict[symbol] = {"name": name}
413399

414400
return variable_dict

src/axiomatic/axtract/relation_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import List
2-
from .. import EquationExtraction
2+
from ..types.equation_processing import ResponseEquation
33
from pyvis.network import Network # type: ignore
44

55

@@ -20,7 +20,7 @@ def normalize_latex_symbol(symbol: str) -> str:
2020
return symbol
2121

2222

23-
def generate_relation_graph(equations: List[EquationExtraction]) -> str:
23+
def generate_relation_graph(equations: List[ResponseEquation]) -> str:
2424
"""
2525
Generates HTML code for a bipartite graph visualization.
2626
Green nodes represent equations, red nodes represent variables.
@@ -41,7 +41,7 @@ def generate_relation_graph(equations: List[EquationExtraction]) -> str:
4141
# Add equation nodes (green) and variable nodes (red)
4242
for eq in equations:
4343
# Add equation node with unique identifier
44-
eq_name = f"Eq: {eq.name} ({eq.id})" # Add ID to make each node unique
44+
eq_name = f"Eq: {eq.name}" # Add ID to make each node unique
4545
net.add_node(
4646
eq_name,
4747
label=eq.name,

src/axiomatic/axtract/validation_results.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
def display_full_results(validation_results, requirements=None, show_hypergraph=True):
88
"""Display equation validation results optimized for dark theme notebooks."""
9-
validations = validation_results.get("validations", {})
9+
# If validation_results is already a dict, use it directly
10+
validations = validation_results if isinstance(validation_results, dict) else validation_results.validations
1011

1112
matching = []
1213
non_matching = []
@@ -15,13 +16,15 @@ def display_full_results(validation_results, requirements=None, show_hypergraph=
1516
equation_data = {
1617
"name": eq_name,
1718
"latex": value.get("original_format", ""),
18-
"lhs": value.get("lhs_value"),
19-
"rhs": value.get("rhs_value"),
20-
"diff": abs(value.get("lhs_value", 0) - value.get("rhs_value", 0)),
21-
"percent_diff": abs(value.get("lhs_value", 0) - value.get("rhs_value", 0))
22-
/ max(abs(value.get("rhs_value", 0)), 1e-10)
19+
"lhs": float(value.get("lhs_value", 0)),
20+
"rhs": float(value.get("rhs_value", 0)),
21+
"diff": abs(float(value.get("lhs_value", 0)) - float(value.get("rhs_value", 0))),
22+
"percent_diff": abs(float(value.get("lhs_value", 0)) - float(value.get("rhs_value", 0)))
23+
/ max(abs(float(value.get("rhs_value", 0))), 1e-10)
2324
* 100,
24-
"used_values": value.get("used_values", {}),
25+
"used_values": {k: float(v.split('*^')[0]) * (10 ** float(v.split('*^')[1]))
26+
if '*^' in v else float(v)
27+
for k, v in value.get("used_values", {}).items()},
2528
}
2629
if value.get("is_valid"):
2730
matching.append(equation_data)

0 commit comments

Comments
 (0)