Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1059,18 +1059,71 @@ def generate_eigenvalue_distribution_plot(beta, y, z_a, n=1000, seed=42):
|
|
| 1059 |
return fig, eigenvalues
|
| 1060 |
# Use C++ implementations if available, otherwise use Python implementations
|
| 1061 |
if cpp_available:
|
| 1062 |
-
|
| 1063 |
-
|
| 1064 |
-
|
| 1065 |
-
|
| 1066 |
-
|
| 1067 |
-
|
| 1068 |
-
|
| 1069 |
-
|
| 1070 |
-
|
| 1071 |
-
|
| 1072 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1073 |
else:
|
|
|
|
| 1074 |
discriminant_func = discriminant_func_py
|
| 1075 |
find_z_at_discriminant_zero = find_z_at_discriminant_zero_py
|
| 1076 |
sweep_beta_and_find_z_bounds = sweep_beta_and_find_z_bounds_py
|
|
|
|
| 1059 |
return fig, eigenvalues
|
| 1060 |
# Use C++ implementations if available, otherwise use Python implementations
|
| 1061 |
if cpp_available:
|
| 1062 |
+
# First check which functions actually exist in the C++ module
|
| 1063 |
+
available_cpp_functions = []
|
| 1064 |
+
for func_name in dir(cubic_cpp):
|
| 1065 |
+
if not func_name.startswith('_'):
|
| 1066 |
+
available_cpp_functions.append(func_name)
|
| 1067 |
+
|
| 1068 |
+
print(f"Available C++ functions: {available_cpp_functions}")
|
| 1069 |
+
|
| 1070 |
+
# Now assign functions based on what's available
|
| 1071 |
+
if "discriminant_func" in available_cpp_functions:
|
| 1072 |
+
discriminant_func = cubic_cpp.discriminant_func
|
| 1073 |
+
else:
|
| 1074 |
+
discriminant_func = discriminant_func_py
|
| 1075 |
+
|
| 1076 |
+
if "find_z_at_discriminant_zero" in available_cpp_functions:
|
| 1077 |
+
find_z_at_discriminant_zero = cubic_cpp.find_z_at_discriminant_zero
|
| 1078 |
+
else:
|
| 1079 |
+
find_z_at_discriminant_zero = find_z_at_discriminant_zero_py
|
| 1080 |
+
|
| 1081 |
+
if "sweep_beta_and_find_z_bounds" in available_cpp_functions:
|
| 1082 |
+
sweep_beta_and_find_z_bounds = cubic_cpp.sweep_beta_and_find_z_bounds
|
| 1083 |
+
else:
|
| 1084 |
+
sweep_beta_and_find_z_bounds = sweep_beta_and_find_z_bounds_py
|
| 1085 |
+
|
| 1086 |
+
if "compute_eigenvalue_support_boundaries" in available_cpp_functions:
|
| 1087 |
+
compute_eigenvalue_support_boundaries = cubic_cpp.compute_eigenvalue_support_boundaries
|
| 1088 |
+
else:
|
| 1089 |
+
compute_eigenvalue_support_boundaries = compute_eigenvalue_support_boundaries_py
|
| 1090 |
+
|
| 1091 |
+
if "compute_cubic_roots" in available_cpp_functions:
|
| 1092 |
+
compute_cubic_roots = cubic_cpp.compute_cubic_roots
|
| 1093 |
+
else:
|
| 1094 |
+
compute_cubic_roots = compute_cubic_roots_py
|
| 1095 |
+
|
| 1096 |
+
if "compute_high_y_curve" in available_cpp_functions:
|
| 1097 |
+
compute_high_y_curve = cubic_cpp.compute_high_y_curve
|
| 1098 |
+
else:
|
| 1099 |
+
compute_high_y_curve = compute_high_y_curve_py
|
| 1100 |
+
|
| 1101 |
+
if "compute_alternate_low_expr" in available_cpp_functions:
|
| 1102 |
+
compute_alternate_low_expr = cubic_cpp.compute_alternate_low_expr
|
| 1103 |
+
else:
|
| 1104 |
+
compute_alternate_low_expr = compute_alternate_low_expr_py
|
| 1105 |
+
|
| 1106 |
+
if "compute_max_k_expression" in available_cpp_functions:
|
| 1107 |
+
compute_max_k_expression = cubic_cpp.compute_max_k_expression
|
| 1108 |
+
else:
|
| 1109 |
+
compute_max_k_expression = compute_max_k_expression_py
|
| 1110 |
+
|
| 1111 |
+
if "compute_min_t_expression" in available_cpp_functions:
|
| 1112 |
+
compute_min_t_expression = cubic_cpp.compute_min_t_expression
|
| 1113 |
+
else:
|
| 1114 |
+
compute_min_t_expression = compute_min_t_expression_py
|
| 1115 |
+
|
| 1116 |
+
if "compute_derivatives" in available_cpp_functions:
|
| 1117 |
+
compute_derivatives = cubic_cpp.compute_derivatives
|
| 1118 |
+
else:
|
| 1119 |
+
compute_derivatives = compute_derivatives_py
|
| 1120 |
+
|
| 1121 |
+
if "generate_eigenvalue_distribution" in available_cpp_functions:
|
| 1122 |
+
generate_eigenvalue_distribution = lambda beta, y, z_a, n=1000, seed=42: cubic_cpp.generate_eigenvalue_distribution(beta, y, z_a, n, seed)
|
| 1123 |
+
else:
|
| 1124 |
+
generate_eigenvalue_distribution = generate_eigenvalue_distribution_py
|
| 1125 |
else:
|
| 1126 |
+
# Use all Python implementations
|
| 1127 |
discriminant_func = discriminant_func_py
|
| 1128 |
find_z_at_discriminant_zero = find_z_at_discriminant_zero_py
|
| 1129 |
sweep_beta_and_find_z_bounds = sweep_beta_and_find_z_bounds_py
|