Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -68,31 +68,60 @@ except ImportError as e:
|
|
| 68 |
cpp_available = False
|
| 69 |
# Use C++ implementations if available, otherwise use Python implementations
|
| 70 |
if cpp_available:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
try:
|
| 72 |
-
#
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
if hasattr(cubic_cpp, "generate_eigenvalue_distribution"):
|
| 86 |
generate_eigenvalue_distribution = lambda beta, y, z_a, n=1000, seed=42: cubic_cpp.generate_eigenvalue_distribution(beta, y, z_a, n, seed)
|
| 87 |
-
else:
|
| 88 |
-
generate_eigenvalue_distribution = generate_eigenvalue_distribution_py
|
| 89 |
|
| 90 |
print("Using C++ acceleration for available functions")
|
| 91 |
except Exception as e:
|
| 92 |
print(f"Error setting up C++ functions: {e}")
|
| 93 |
-
# Fall back to all Python implementations
|
| 94 |
-
cpp_available = False
|
| 95 |
else:
|
|
|
|
| 96 |
discriminant_func = discriminant_func_py
|
| 97 |
find_z_at_discriminant_zero = find_z_at_discriminant_zero_py
|
| 98 |
sweep_beta_and_find_z_bounds = sweep_beta_and_find_z_bounds_py
|
|
|
|
| 68 |
cpp_available = False
|
| 69 |
# Use C++ implementations if available, otherwise use Python implementations
|
| 70 |
if cpp_available:
|
| 71 |
+
# Start with all Python implementations
|
| 72 |
+
discriminant_func = discriminant_func_py
|
| 73 |
+
find_z_at_discriminant_zero = find_z_at_discriminant_zero_py
|
| 74 |
+
sweep_beta_and_find_z_bounds = sweep_beta_and_find_z_bounds_py
|
| 75 |
+
compute_eigenvalue_support_boundaries = compute_eigenvalue_support_boundaries_py
|
| 76 |
+
compute_cubic_roots = compute_cubic_roots_py
|
| 77 |
+
compute_high_y_curve = compute_high_y_curve_py
|
| 78 |
+
compute_alternate_low_expr = compute_alternate_low_expr_py
|
| 79 |
+
compute_max_k_expression = compute_max_k_expression_py
|
| 80 |
+
compute_min_t_expression = compute_min_t_expression_py
|
| 81 |
+
compute_derivatives = compute_derivatives_py
|
| 82 |
+
generate_eigenvalue_distribution = generate_eigenvalue_distribution_py
|
| 83 |
+
|
| 84 |
+
# Now override with C++ implementations if they exist
|
| 85 |
try:
|
| 86 |
+
# Check each C++ function individually
|
| 87 |
+
if hasattr(cubic_cpp, "discriminant_func"):
|
| 88 |
+
discriminant_func = cubic_cpp.discriminant_func
|
| 89 |
+
|
| 90 |
+
if hasattr(cubic_cpp, "find_z_at_discriminant_zero"):
|
| 91 |
+
find_z_at_discriminant_zero = cubic_cpp.find_z_at_discriminant_zero
|
| 92 |
+
|
| 93 |
+
if hasattr(cubic_cpp, "sweep_beta_and_find_z_bounds"):
|
| 94 |
+
sweep_beta_and_find_z_bounds = cubic_cpp.sweep_beta_and_find_z_bounds
|
| 95 |
+
|
| 96 |
+
if hasattr(cubic_cpp, "compute_eigenvalue_support_boundaries"):
|
| 97 |
+
compute_eigenvalue_support_boundaries = cubic_cpp.compute_eigenvalue_support_boundaries
|
| 98 |
+
|
| 99 |
+
if hasattr(cubic_cpp, "compute_cubic_roots"):
|
| 100 |
+
compute_cubic_roots = cubic_cpp.compute_cubic_roots
|
| 101 |
+
|
| 102 |
+
if hasattr(cubic_cpp, "compute_high_y_curve"):
|
| 103 |
+
compute_high_y_curve = cubic_cpp.compute_high_y_curve
|
| 104 |
+
|
| 105 |
+
if hasattr(cubic_cpp, "compute_alternate_low_expr"):
|
| 106 |
+
compute_alternate_low_expr = cubic_cpp.compute_alternate_low_expr
|
| 107 |
+
|
| 108 |
+
if hasattr(cubic_cpp, "compute_max_k_expression"):
|
| 109 |
+
compute_max_k_expression = cubic_cpp.compute_max_k_expression
|
| 110 |
+
|
| 111 |
+
if hasattr(cubic_cpp, "compute_min_t_expression"):
|
| 112 |
+
compute_min_t_expression = cubic_cpp.compute_min_t_expression
|
| 113 |
+
|
| 114 |
+
if hasattr(cubic_cpp, "compute_derivatives"):
|
| 115 |
+
compute_derivatives = cubic_cpp.compute_derivatives
|
| 116 |
+
|
| 117 |
if hasattr(cubic_cpp, "generate_eigenvalue_distribution"):
|
| 118 |
generate_eigenvalue_distribution = lambda beta, y, z_a, n=1000, seed=42: cubic_cpp.generate_eigenvalue_distribution(beta, y, z_a, n, seed)
|
|
|
|
|
|
|
| 119 |
|
| 120 |
print("Using C++ acceleration for available functions")
|
| 121 |
except Exception as e:
|
| 122 |
print(f"Error setting up C++ functions: {e}")
|
|
|
|
|
|
|
| 123 |
else:
|
| 124 |
+
# Use all Python implementations
|
| 125 |
discriminant_func = discriminant_func_py
|
| 126 |
find_z_at_discriminant_zero = find_z_at_discriminant_zero_py
|
| 127 |
sweep_beta_and_find_z_bounds = sweep_beta_and_find_z_bounds_py
|