|
13 | 13 |
|
14 | 14 | # Check for backend override via environment variable |
15 | 15 | # DIFF_DIFF_BACKEND can be: 'auto' (default), 'python', or 'rust' |
16 | | -_backend_env = os.environ.get('DIFF_DIFF_BACKEND', 'auto').lower() |
| 16 | +_backend_env = os.environ.get("DIFF_DIFF_BACKEND", "auto").lower() |
17 | 17 |
|
18 | 18 | # Try to import Rust backend for accelerated operations |
19 | 19 | try: |
|
38 | 38 | # Diagnostics |
39 | 39 | rust_backend_info as _rust_backend_info, |
40 | 40 | ) |
| 41 | + |
41 | 42 | _rust_available = True |
42 | 43 | except ImportError: |
43 | 44 | _rust_available = False |
|
61 | 62 | _rust_backend_info = None |
62 | 63 |
|
63 | 64 | # Determine final backend based on environment variable and availability |
64 | | -if _backend_env == 'python': |
| 65 | +if _backend_env == "python": |
65 | 66 | # Force pure Python mode - disable Rust even if available |
66 | 67 | HAS_RUST_BACKEND = False |
67 | 68 | _rust_bootstrap_weights = None |
|
82 | 83 | _rust_compute_noise_level = None |
83 | 84 | _rust_sc_weight_fw = None |
84 | 85 | _rust_backend_info = None |
85 | | -elif _backend_env == 'rust': |
| 86 | +elif _backend_env == "rust": |
86 | 87 | # Force Rust mode - fail if not available |
87 | 88 | if not _rust_available: |
88 | 89 | raise ImportError( |
@@ -111,23 +112,23 @@ def rust_backend_info(): |
111 | 112 |
|
112 | 113 |
|
113 | 114 | __all__ = [ |
114 | | - 'HAS_RUST_BACKEND', |
115 | | - 'rust_backend_info', |
116 | | - '_rust_bootstrap_weights', |
117 | | - '_rust_synthetic_weights', |
118 | | - '_rust_project_simplex', |
119 | | - '_rust_solve_ols', |
120 | | - '_rust_compute_robust_vcov', |
| 115 | + "HAS_RUST_BACKEND", |
| 116 | + "rust_backend_info", |
| 117 | + "_rust_bootstrap_weights", |
| 118 | + "_rust_synthetic_weights", |
| 119 | + "_rust_project_simplex", |
| 120 | + "_rust_solve_ols", |
| 121 | + "_rust_compute_robust_vcov", |
121 | 122 | # TROP estimator acceleration (local method) |
122 | | - '_rust_unit_distance_matrix', |
123 | | - '_rust_loocv_grid_search', |
124 | | - '_rust_bootstrap_trop_variance', |
| 123 | + "_rust_unit_distance_matrix", |
| 124 | + "_rust_loocv_grid_search", |
| 125 | + "_rust_bootstrap_trop_variance", |
125 | 126 | # TROP estimator acceleration (global method) |
126 | | - '_rust_loocv_grid_search_global', |
127 | | - '_rust_bootstrap_trop_variance_global', |
| 127 | + "_rust_loocv_grid_search_global", |
| 128 | + "_rust_bootstrap_trop_variance_global", |
128 | 129 | # SDID weights (Frank-Wolfe matching R's synthdid) |
129 | | - '_rust_sdid_unit_weights', |
130 | | - '_rust_compute_time_weights', |
131 | | - '_rust_compute_noise_level', |
132 | | - '_rust_sc_weight_fw', |
| 130 | + "_rust_sdid_unit_weights", |
| 131 | + "_rust_compute_time_weights", |
| 132 | + "_rust_compute_noise_level", |
| 133 | + "_rust_sc_weight_fw", |
133 | 134 | ] |
0 commit comments