Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
407 changes: 0 additions & 407 deletions docs/dev/implementation-plans/progress-activity-indicator.md

This file was deleted.

5 changes: 4 additions & 1 deletion docs/dev/package-structure-full.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
│ │ │ └── 🏷️ class FitResults
│ │ └── 📄 tracking.py
│ │ ├── 🏷️ class SamplerProgressUpdate
│ │ ├── 🏷️ class _TerminalLiveHandle
│ │ └── 🏷️ class FitProgressTracker
│ ├── 📁 minimizers
│ │ ├── 📄 __init__.py
Expand Down Expand Up @@ -385,6 +384,10 @@
│ │ ├── 🏷️ class _PosteriorPairsLegendState
│ │ ├── 🏷️ class Plotter
│ │ └── 🏷️ class PlotterFactory
│ ├── 📄 progress.py
│ │ ├── 🏷️ class _TerminalLiveHandle
│ │ ├── 🏷️ class ActivityIndicator
│ │ └── 🏷️ class _ActivityIndicatorContext
│ ├── 📄 tables.py
│ │ ├── 🏷️ class TableEngineEnum
│ │ ├── 🏷️ class TableRenderer
Expand Down
1 change: 1 addition & 0 deletions docs/dev/package-structure-short.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
│ ├── 📄 __init__.py
│ ├── 📄 base.py
│ ├── 📄 plotting.py
│ ├── 📄 progress.py
│ ├── 📄 tables.py
│ └── 📄 utils.py
├── 📁 io
Expand Down
6 changes: 1 addition & 5 deletions docs/docs/tutorials/ed-21.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -734,11 +734,7 @@
"metadata": {},
"outputs": [],
"source": [
"project.display.posterior.predictive(\n",
" expt_name='hrpt',\n",
" x_min=92,\n",
" x_max=93,\n",
")"
"project.display.posterior.predictive(expt_name='hrpt', x_min=92, x_max=93)"
]
}
],
Expand Down
6 changes: 1 addition & 5 deletions docs/docs/tutorials/ed-21.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,4 @@
# after the Bayesian run.

# %%
project.display.posterior.predictive(
expt_name='hrpt',
x_min=92,
x_max=93,
)
project.display.posterior.predictive(expt_name='hrpt', x_min=92, x_max=93)
62 changes: 34 additions & 28 deletions src/easydiffraction/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
from easydiffraction.analysis.categories.fit import FitFactory
from easydiffraction.analysis.categories.fit import FitModeEnum
from easydiffraction.analysis.categories.joint_fit_experiments import JointFitExperiments
from easydiffraction.analysis.fit_helpers.tracking import _make_display_handle
from easydiffraction.analysis.fitting import Fitter
from easydiffraction.core.singleton import ConstraintsHandler
from easydiffraction.core.variable import NumericDescriptor
from easydiffraction.core.variable import Parameter
from easydiffraction.core.variable import StringDescriptor
from easydiffraction.display.progress import make_display_handle
from easydiffraction.display.tables import TableRenderer
from easydiffraction.io.cif.serialize import analysis_to_cif
from easydiffraction.utils.enums import VerbosityEnum
Expand Down Expand Up @@ -614,37 +614,43 @@ def _fit_single(

short_display_handle = self._fit_single_print_header(verb, expt_names, mode)
short_rows: list[list[str]] = []
self.fitter.minimizer.tracker._set_shared_display_handle(short_display_handle)

for expt_name in expt_names:
if verb is VerbosityEnum.FULL:
console.print(f"📋 Using experiment 🔬 '{expt_name}' for '{mode.value}' fitting")
try:
for expt_name in expt_names:
if verb is VerbosityEnum.FULL:
console.print(
f"📋 Using experiment 🔬 '{expt_name}' for '{mode.value}' fitting"
)

experiment = experiments[expt_name]
self.fitter.fit(
structures,
[experiment],
analysis=self,
verbosity=verb,
use_physical_limits=use_physical_limits,
random_seed=random_seed,
)
experiment = experiments[expt_name]
self.fitter.fit(
structures,
[experiment],
analysis=self,
verbosity=verb,
use_physical_limits=use_physical_limits,
random_seed=random_seed,
)

# After fitting, snapshot parameter values before
# they get overwritten by the next experiment's fit
results = self.fitter.results
self._snapshot_params(expt_name, results)
self.fit_results = results
# After fitting, snapshot parameter values before
# they get overwritten by the next experiment's fit
results = self.fitter.results
self._snapshot_params(expt_name, results)
self.fit_results = results

# Short mode: append one summary row and update in-place
if verb is VerbosityEnum.SHORT:
self._fit_single_update_short_table(
short_rows, expt_name, results, short_display_handle
)
# Short mode: append one summary row and update in-place
if verb is VerbosityEnum.SHORT:
self._fit_single_update_short_table(
short_rows, expt_name, results, short_display_handle
)
finally:
self.fitter.minimizer.tracker._set_shared_display_handle(None)

# Short mode: close the display handle
if short_display_handle is not None and hasattr(short_display_handle, 'close'):
with suppress(Exception):
short_display_handle.close()
# Short mode: close the display handle
if short_display_handle is not None and hasattr(short_display_handle, 'close'):
with suppress(Exception):
short_display_handle.close()

@staticmethod
def _fit_single_print_header(
Expand Down Expand Up @@ -680,7 +686,7 @@ def _fit_single_print_header(
)
console.print("🚀 Starting fit process with 'lmfit'...")
console.print('📈 Goodness-of-fit (reduced χ²) per experiment:')
return _make_display_handle()
return make_display_handle()

def _snapshot_params(self, expt_name: str, results: object) -> None:
"""
Expand Down
Loading
Loading