From 162bc384f9c6aa3c16e1022260a3a957a0343543 Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Wed, 14 Aug 2024 23:22:26 +0800 Subject: [PATCH 1/3] print things correctly --- src/diffpy/srmise/baselines/nanospherical.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/diffpy/srmise/baselines/nanospherical.py b/src/diffpy/srmise/baselines/nanospherical.py index b45113b..84d8084 100644 --- a/src/diffpy/srmise/baselines/nanospherical.py +++ b/src/diffpy/srmise/baselines/nanospherical.py @@ -88,7 +88,7 @@ def _jacobianraw(self, pars, r, free): emsg = "Argument free must have " + str(self.npars) + " elements." raise ValueError(emsg) jacobian = [None for p in range(self.npars)] - if (free is False).sum() == self.npars: + if np.sum(np.logical_not(free)) == self.npars: return jacobian if np.isscalar(r): @@ -247,7 +247,8 @@ def getmodule(self): for tup in zip(r, val, *outjac): for t in tup: if t is None: - print("%s" % None).ljust(10), + formatted_t = "%s" % None + print(formatted_t.ljust(10)) else: - print("% .3g" % t).ljust(10), - print + formatted_t = "%.3g" % t + print(formatted_t.ljust(10)) From 5ce07d63ee09b3e7c36186994735254d247b72e4 Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Thu, 15 Aug 2024 00:18:03 +0800 Subject: [PATCH 2/3] change to f string --- src/diffpy/srmise/baselines/nanospherical.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffpy/srmise/baselines/nanospherical.py b/src/diffpy/srmise/baselines/nanospherical.py index 84d8084..df9ee62 100644 --- a/src/diffpy/srmise/baselines/nanospherical.py +++ b/src/diffpy/srmise/baselines/nanospherical.py @@ -247,8 +247,8 @@ def getmodule(self): for tup in zip(r, val, *outjac): for t in tup: if t is None: - formatted_t = "%s" % None + formatted_t = f"{None}" print(formatted_t.ljust(10)) else: - formatted_t = "%.3g" % t - print(formatted_t.ljust(10)) + formatted_t = f"{t:.3g}".ljust(10) + print(formatted_t) From 381053cd2872b8470fbad7008a23c4572737199c Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Thu, 15 Aug 2024 00:43:46 +0800 Subject: [PATCH 3/3] reduce print to one line --- src/diffpy/srmise/baselines/nanospherical.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/diffpy/srmise/baselines/nanospherical.py b/src/diffpy/srmise/baselines/nanospherical.py index df9ee62..8c5ae12 100644 --- a/src/diffpy/srmise/baselines/nanospherical.py +++ b/src/diffpy/srmise/baselines/nanospherical.py @@ -247,8 +247,6 @@ def getmodule(self): for tup in zip(r, val, *outjac): for t in tup: if t is None: - formatted_t = f"{None}" - print(formatted_t.ljust(10)) + print(f"{None}".ljust(10)) else: - formatted_t = f"{t:.3g}".ljust(10) - print(formatted_t) + print(f"{t:.3g}".ljust(10))