Skip to content

Commit c70beb8

Browse files
committed
working
1 parent 141bc24 commit c70beb8

File tree

3 files changed

+42
-58
lines changed

3 files changed

+42
-58
lines changed

src/axiomatic/axtract/interactive_table.py

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -55,49 +55,35 @@ def interactive_table(loaded_equations: EquationProcessingResponse, file_path: s
5555
# ---------------------------------------------------------------
5656
# 1) Define built-in templates and units directly inside the function
5757
# ---------------------------------------------------------------
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-
}
7258

7359
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,
60+
"Resolved Ground Detail, Panchromatic": 1.23529,
61+
"Ground Sample Distance, Panchromatic": 0.61765,
62+
"Resolved Ground Detail, Multispectral": 1.81176,
63+
"Ground Sample Distance, Multispectral": 0.90588,
7864
"Altitude": 420000,
79-
"Half field of view": 0.017104227,
80-
"Mirror aperture": 0.85,
81-
"F-number": 6.0,
65+
"Horizontal Field of View": 0.017104227,
66+
"Aperture diameter": 0.85,
67+
"f-number": 6.0,
8268
"Focal length": 5.1,
83-
"Pixel size (panchromatic)": 7.5e-6,
84-
"Pixel size (multispectral)": 11e-6,
85-
"Swath width": 14368.95,
69+
"Pixel pitch": 7.5e-6,
70+
"Pixel pitch of the multispectral sensor": 11e-6,
71+
"Swath Width": 14368.95,
8672
}
8773

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

10389
PAYLOAD_1 = {
@@ -120,7 +106,6 @@ def interactive_table(loaded_equations: EquationProcessingResponse, file_path: s
120106
preset_options_dict = {
121107
"Select a template": [],
122108
"IMAGING TELESCOPE": list(IMAGING_TELESCOPE.keys()),
123-
"IMAGING TELESCOPE template": list(IMAGING_TELESCOPE_template.keys()),
124109
"PAYLOAD": list(PAYLOAD_1.keys()),
125110
}
126111

@@ -272,11 +257,6 @@ def submit_values(_):
272257
result["values"] = updated_values
273258
requirements_result[0] = _requirements_from_table(result, variable_dict)
274259

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

282262
# ---------------------------------------------------------------
@@ -406,9 +386,14 @@ def _create_variable_dict(equation_response: EquationProcessingResponse) -> dict
406386

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

414399
return variable_dict

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)

src/axiomatic/client.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .axtract.interactive_table import _create_variable_dict, VariableRequirement
1515
from .types.variable_requirement import VariableRequirement
1616
from .types.validate_equations_body import ValidateEquationsBody
17-
17+
from .types.equation_validation_result import EquationValidationResult
1818

1919
class Axiomatic(BaseClient):
2020
def __init__(self, *args, **kwargs):
@@ -118,9 +118,8 @@ def validate_equations(
118118
self,
119119
requirements: list[VariableRequirement],
120120
loaded_equations: EquationProcessingResponse,
121-
show_hypergraph: bool = True,
122121
include_internal_model: bool = False,
123-
):
122+
) -> EquationValidationResult:
124123
"""Validate equations against a set of variable requirements.
125124
126125
Args:
@@ -141,16 +140,13 @@ def validate_equations(
141140
include_internal_model=include_internal_model
142141
)
143142

144-
print(request_body.model_dump_json())
145-
146143
api_response = self._ax_client.document.equation.validate(request=request_body.model_dump())
147144

148-
if show_hypergraph:
149-
pass
150-
151145
return api_response
152146

153147

148+
def display_full_results(self, api_response: EquationValidationResult, user_choice):
149+
display_full_results(api_response, user_choice)
154150

155151

156152
def set_numerical_requirements(self, extracted_equations: EquationProcessingResponse):

0 commit comments

Comments
 (0)