goad-py 0.7.0__cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl → 0.8.0__cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of goad-py might be problematic. Click here for more details.

goad_py/convergence.py CHANGED
@@ -92,6 +92,7 @@ class Convergence:
92
92
  min_batches: int = 10,
93
93
  mueller_1d: bool = True,
94
94
  mueller_2d: bool = False,
95
+ log_file: Optional[str] = None,
95
96
  ):
96
97
  """
97
98
  Initialize a convergence study.
@@ -104,6 +105,7 @@ class Convergence:
104
105
  min_batches: Minimum number of batches before allowing convergence
105
106
  mueller_1d: Whether to collect 1D Mueller matrices
106
107
  mueller_2d: Whether to collect 2D Mueller matrices
108
+ log_file: Optional path to log file for convergence progress
107
109
  """
108
110
  self.settings = settings
109
111
  # Enable quiet mode to suppress Rust progress bars
@@ -172,6 +174,7 @@ class Convergence:
172
174
  min_batches=self.min_batches,
173
175
  convergence_type=self._get_convergence_type(),
174
176
  console=self._console,
177
+ log_file=log_file,
175
178
  )
176
179
 
177
180
  def _update_statistics(self, results: goad.Results, batch_size: int):
@@ -267,6 +267,7 @@ class ConvergenceDisplay:
267
267
  min_batches: int,
268
268
  convergence_type: str = "standard",
269
269
  console: Optional[Console] = None,
270
+ log_file: Optional[str] = None,
270
271
  ):
271
272
  """
272
273
  Initialize convergence display.
@@ -277,6 +278,7 @@ class ConvergenceDisplay:
277
278
  min_batches: Minimum batches before convergence check
278
279
  convergence_type: Display string for convergence mode
279
280
  console: Optional Rich console (creates one if None)
281
+ log_file: Optional path to log file for convergence progress
280
282
  """
281
283
  self.variables = variables
282
284
  self.batch_size = batch_size
@@ -284,6 +286,18 @@ class ConvergenceDisplay:
284
286
  self.convergence_type = convergence_type
285
287
  self._console = console or Console()
286
288
 
289
+ # File logging
290
+ self.log_file = log_file
291
+ self._file_console = None
292
+ self._file_handle = None
293
+ if self.log_file:
294
+ # Create a separate console for file output
295
+ self._file_handle = open(self.log_file, "w")
296
+ self._file_console = Console(file=self._file_handle, width=120)
297
+ # Write header
298
+ self._file_console.print(f"GOAD Convergence Log - {convergence_type}")
299
+ self._file_console.print("=" * 120)
300
+
287
301
  # Progress tracking
288
302
  self._progress: Optional[Progress] = None
289
303
  self._progress_tasks: Dict[str, int] = {}
@@ -463,8 +477,8 @@ class ConvergenceDisplay:
463
477
  )
464
478
  progress_lines.append(line)
465
479
 
466
- # Return full display
467
- return Group(
480
+ # Build full display
481
+ display = Group(
468
482
  separator,
469
483
  title,
470
484
  Text(""), # Blank line
@@ -473,6 +487,12 @@ class ConvergenceDisplay:
473
487
  *progress_lines,
474
488
  )
475
489
 
490
+ # Log to file if enabled
491
+ if self._file_console is not None:
492
+ self._file_console.print(display)
493
+
494
+ return display
495
+
476
496
  def _get_power_ratio_color(self, power_ratio: float) -> str:
477
497
  """Get color for power ratio based on threshold."""
478
498
  if power_ratio >= 0.99:
@@ -497,3 +517,16 @@ class ConvergenceDisplay:
497
517
  refresh_per_second=refresh_per_second,
498
518
  transient=False,
499
519
  )
520
+
521
+ def close(self):
522
+ """Close the log file if open."""
523
+ if self._file_handle is not None:
524
+ self._file_console.print("\n" + "=" * 120)
525
+ self._file_console.print("End of convergence log")
526
+ self._file_handle.close()
527
+ self._file_handle = None
528
+ self._file_console = None
529
+
530
+ def __del__(self):
531
+ """Cleanup when object is destroyed."""
532
+ self.close()
@@ -71,6 +71,7 @@ class PHIPSConvergence:
71
71
  batch_size: int = 24,
72
72
  max_orientations: int = 100_000,
73
73
  min_batches: int = 10,
74
+ log_file: Optional[str] = None,
74
75
  ):
75
76
  """
76
77
  Initialize a PHIPS convergence study.
@@ -81,6 +82,7 @@ class PHIPSConvergence:
81
82
  batch_size: Number of orientations per iteration
82
83
  max_orientations: Maximum total orientations before stopping
83
84
  min_batches: Minimum number of batches before allowing convergence
85
+ log_file: Optional path to log file for convergence progress
84
86
  """
85
87
  self.settings = settings
86
88
  # Enable quiet mode to suppress Rust progress bars
@@ -136,6 +138,7 @@ class PHIPSConvergence:
136
138
  min_batches=self.min_batches,
137
139
  convergence_type=self._get_convergence_type(),
138
140
  console=self._console,
141
+ log_file=log_file,
139
142
  )
140
143
 
141
144
  def _compute_phips_dscs_from_mueller2d(self, results: goad.Results) -> np.ndarray:
@@ -444,6 +447,7 @@ class PHIPSEnsembleConvergence(PHIPSConvergence):
444
447
  batch_size: int = 24,
445
448
  max_orientations: int = 100_000,
446
449
  min_batches: int = 10,
450
+ log_file: Optional[str] = None,
447
451
  ):
448
452
  """
449
453
  Initialize a PHIPS ensemble convergence study.
@@ -455,6 +459,7 @@ class PHIPSEnsembleConvergence(PHIPSConvergence):
455
459
  batch_size: Number of orientations per iteration
456
460
  max_orientations: Maximum total orientations before stopping
457
461
  min_batches: Minimum number of batches before allowing convergence
462
+ log_file: Optional path to log file for convergence progress
458
463
  """
459
464
  # Discover all .obj files in directory
460
465
  geom_path = Path(geom_dir)
@@ -480,6 +485,7 @@ class PHIPSEnsembleConvergence(PHIPSConvergence):
480
485
  batch_size=batch_size,
481
486
  max_orientations=max_orientations,
482
487
  min_batches=min_batches,
488
+ log_file=log_file,
483
489
  )
484
490
 
485
491
  def run(self) -> ConvergenceResults:
@@ -15,28 +15,28 @@ Features:
15
15
  - Reproducible results via random seed control
16
16
  """
17
17
 
18
- from dataclasses import dataclass, field, asdict
19
- from typing import List, Dict, Optional, Union, Any, Tuple
18
+ import json
19
+ from abc import ABC, abstractmethod
20
+ from dataclasses import asdict, dataclass, field
20
21
  from pathlib import Path
22
+ from typing import Any, Dict, List, Optional, Tuple, Union
23
+
21
24
  import numpy as np
22
- import json
23
25
  import toml
24
- from abc import ABC, abstractmethod
25
26
 
26
27
  from . import _goad_py as goad
27
28
  from .convergence import (
28
- Convergence,
29
29
  Convergable,
30
+ Convergence,
30
31
  ConvergenceResults,
31
32
  EnsembleConvergence,
32
33
  )
33
34
  from .phips_convergence import (
34
- PHIPSConvergence,
35
35
  PHIPSConvergable,
36
+ PHIPSConvergence,
36
37
  PHIPSEnsembleConvergence,
37
38
  )
38
39
 
39
-
40
40
  # ============================================================================
41
41
  # Convergence Modes
42
42
  # ============================================================================
@@ -373,6 +373,7 @@ class ConvergenceConfig:
373
373
 
374
374
  # Output options
375
375
  output_dir: Optional[str] = None
376
+ log_file: Optional[str] = None
376
377
 
377
378
  def __post_init__(self):
378
379
  """Validate configuration after initialization."""
@@ -872,6 +873,7 @@ class UnifiedConvergence:
872
873
  min_batches=self.config.min_batches,
873
874
  mueller_1d=self.config.mueller_1d,
874
875
  mueller_2d=False,
876
+ log_file=self.config.log_file,
875
877
  )
876
878
  else:
877
879
  self._convergence = Convergence(
@@ -882,6 +884,7 @@ class UnifiedConvergence:
882
884
  min_batches=self.config.min_batches,
883
885
  mueller_1d=self.config.mueller_1d,
884
886
  mueller_2d=False,
887
+ log_file=self.config.log_file,
885
888
  )
886
889
 
887
890
  def _setup_phips(self, settings):
@@ -903,6 +906,7 @@ class UnifiedConvergence:
903
906
  batch_size=self.config.batch_size,
904
907
  max_orientations=self.config.max_orientations,
905
908
  min_batches=self.config.min_batches,
909
+ log_file=self.config.log_file,
906
910
  )
907
911
  else:
908
912
  self._convergence = PHIPSConvergence(
@@ -911,6 +915,7 @@ class UnifiedConvergence:
911
915
  batch_size=self.config.batch_size,
912
916
  max_orientations=self.config.max_orientations,
913
917
  min_batches=self.config.min_batches,
918
+ log_file=self.config.log_file,
914
919
  )
915
920
 
916
921
  def run(self) -> UnifiedResults:
@@ -1092,6 +1097,9 @@ def run_convergence(
1092
1097
  # Reproducibility
1093
1098
  - seed: Random seed for orientations (optional)
1094
1099
 
1100
+ # Output options
1101
+ - log_file: Path to log file for convergence progress (optional)
1102
+
1095
1103
  Returns:
1096
1104
  UnifiedResults object
1097
1105
 
@@ -1157,8 +1165,9 @@ def run_convergence(
1157
1165
  fov_factor=kwargs.pop("fov_factor", None),
1158
1166
  )
1159
1167
 
1160
- # Extract seed
1168
+ # Extract seed and log_file
1161
1169
  seed = kwargs.pop("seed", None)
1170
+ log_file = kwargs.pop("log_file", None)
1162
1171
 
1163
1172
  # Normalize targets to list of dicts
1164
1173
  target_dicts = _normalize_targets(targets, tolerance, tolerance_type)
@@ -1190,6 +1199,7 @@ def run_convergence(
1190
1199
  geometry_transform=geometry_transform,
1191
1200
  advanced_config=advanced_config,
1192
1201
  seed=seed,
1202
+ log_file=log_file,
1193
1203
  **kwargs, # Remaining kwargs (wavelength, particle_refr_index_re, etc.)
1194
1204
  )
1195
1205
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: goad-py
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Science/Research
6
6
  Classifier: Topic :: Scientific/Engineering :: Physics
@@ -0,0 +1,10 @@
1
+ goad_py-0.8.0.dist-info/METADATA,sha256=A3QnubU86DsTw06KrjvyGV6duTvqJMveIg8MkXcX_S4,3266
2
+ goad_py-0.8.0.dist-info/WHEEL,sha256=cqfH6P_NujaeOc1olR46J5a7YgoxWJnrr5iZ1_DMqps,129
3
+ goad_py/__init__.py,sha256=iGJg-Oj9btk4I4GITkE7olNRm38uFRjENMJqXaDJmpM,1083
4
+ goad_py/_goad_py.abi3.so,sha256=LauIBxD05jiyclyP1bjhVdmD8AUMLZIUWm9xWzFis_E,2116304
5
+ goad_py/convergence.py,sha256=2VBhavlI5Oh99GxiZLq4qHHLeU-WttuAMTzXvPzLE9E,32826
6
+ goad_py/convergence_display.py,sha256=j3l9lpy1JZgySfAOA0Gqufq_DryJx9cczm-ZPVOKDUc,17861
7
+ goad_py/goad_py.pyi,sha256=7Y79-TV-NjEN8DWPEqSRGQ7alCrkylL6y1ZK8d6FYSg,14502
8
+ goad_py/phips_convergence.py,sha256=Ypgs0LpxC2-rh-AEDeEkiFn0dV41cL8PCJiU2pW447w,23053
9
+ goad_py/unified_convergence.py,sha256=5rcqk1XX1AuRcMEaxxIx-rVyg_P3_6FjpfQI9Uc_HNg,49626
10
+ goad_py-0.8.0.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- goad_py-0.7.0.dist-info/METADATA,sha256=0_d3FTncDZ9MrOT3XWx-LpLlVW_kRzyVm8D3Bd2PH1Q,3266
2
- goad_py-0.7.0.dist-info/WHEEL,sha256=cqfH6P_NujaeOc1olR46J5a7YgoxWJnrr5iZ1_DMqps,129
3
- goad_py/__init__.py,sha256=iGJg-Oj9btk4I4GITkE7olNRm38uFRjENMJqXaDJmpM,1083
4
- goad_py/_goad_py.abi3.so,sha256=LauIBxD05jiyclyP1bjhVdmD8AUMLZIUWm9xWzFis_E,2116304
5
- goad_py/convergence.py,sha256=gbf8-uQTpCltCO3MrhVckobSP-uM2lxOiYocB6YSBTs,32682
6
- goad_py/convergence_display.py,sha256=2V_kyARZ504-pJNjiWO-Zqd5S1z8leTJ-A86c4r382w,16672
7
- goad_py/goad_py.pyi,sha256=7Y79-TV-NjEN8DWPEqSRGQ7alCrkylL6y1ZK8d6FYSg,14502
8
- goad_py/phips_convergence.py,sha256=U_2r40lDza6FO0VDo-FD6KxaKjo9gDdVfm01StqYKMU,22765
9
- goad_py/unified_convergence.py,sha256=3R4D_bVD-u-XbkaZ4R_BcVGZpwKoq8S0OZ-My-Nlxm0,49212
10
- goad_py-0.7.0.dist-info/RECORD,,