From 4172a9a11a04e5c4e309dafd5d7c66e70f304c44 Mon Sep 17 00:00:00 2001 From: allevitan Date: Tue, 24 Mar 2026 19:30:14 +0100 Subject: [PATCH] A few small changes to revert unimportant edits and fix linting issues --- examples/fancy_ptycho.py | 2 +- examples/near_field_ptycho.py | 2 +- examples/simple_ptycho.py | 2 +- src/cdtools/models/fancy_ptycho.py | 5 +---- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/fancy_ptycho.py b/examples/fancy_ptycho.py index 1ca88fe..d6dfc74 100644 --- a/examples/fancy_ptycho.py +++ b/examples/fancy_ptycho.py @@ -13,7 +13,7 @@ model = cdtools.models.FancyPtycho.from_dataset( probe_support_radius=120, # Force the probe to 0 outside a radius of 120 pix propagation_distance=5e-3, # Propagate the initial probe guess by 5 mm units='mm', # Set the units for the live plots - obj_view_crop=-50, # Expands the field of view in the object plot by 50 pix, + obj_view_crop=-50, # Expands the field of view in the object plot by 50 pix ) if t.cuda.is_available(): diff --git a/examples/near_field_ptycho.py b/examples/near_field_ptycho.py index 4534ee5..af0012d 100644 --- a/examples/near_field_ptycho.py +++ b/examples/near_field_ptycho.py @@ -27,7 +27,7 @@ model = cdtools.models.FancyPtycho.from_dataset( propagation_distance=3.65e-3, # 3.65 downstream from focus units='um', # Set the units for the live plots obj_view_crop=-35, - panel_plot_mode=True, + panel_plot_mode=True, # Set to False to get individual figures ) if t.cuda.is_available(): diff --git a/examples/simple_ptycho.py b/examples/simple_ptycho.py index 8218a22..41c0c6c 100644 --- a/examples/simple_ptycho.py +++ b/examples/simple_ptycho.py @@ -26,7 +26,7 @@ if t.cuda.is_available(): model.inspect(dataset) # We run the reconstruction -for loss in model.Adam_optimize(30, dataset, batch_size=10): +for loss in model.Adam_optimize(100, dataset, batch_size=10): # We print a quick report of the optimization status print(model.report()) # And liveplot the updates to the model as they happen diff --git a/src/cdtools/models/fancy_ptycho.py b/src/cdtools/models/fancy_ptycho.py index 58f4f2a..3387b15 100644 --- a/src/cdtools/models/fancy_ptycho.py +++ b/src/cdtools/models/fancy_ptycho.py @@ -7,8 +7,6 @@ from cdtools.tools import analysis from matplotlib import pyplot as plt from datetime import datetime import numpy as np -from scipy import linalg as sla -from copy import copy __all__ = ['FancyPtycho'] @@ -557,7 +555,7 @@ class FancyPtycho(CDIModel): else: try: Ws = t.ones(len(index)) # I'm positive this introduced a bug - except: + except TypeError: Ws = 1 if self.weights is None or len(self.weights[0].shape) == 0: @@ -782,7 +780,6 @@ class FancyPtycho(CDIModel): # First we treat the incoherent but stable case, where the weights are # just one per-shot overall weight if self.weights.dim() == 1: - probe = self.probe.detach().cpu().numpy() ortho_probes = analysis.orthogonalize_probes(self.probe.detach()) self.probe.data = ortho_probes return