From 8c6b0137c4b785c2f5f603a905603446d5c0b658 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Wed, 9 Feb 2022 14:55:35 -0500 Subject: [PATCH 1/5] Check for infinite values in the Quality Factors. --- pyEPR/core_quantum_analysis.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyEPR/core_quantum_analysis.py b/pyEPR/core_quantum_analysis.py index 558a09f..cba4187 100644 --- a/pyEPR/core_quantum_analysis.py +++ b/pyEPR/core_quantum_analysis.py @@ -894,7 +894,9 @@ def plot_hamiltonian_results(self, Qs.plot(ax=ax, lw=0, marker=markerf1, ms=4, legend=True, zorder=20, color=cmap) Qs.plot(ax=ax, lw=1, alpha=0.2, color='grey', legend=False) - if not (len(Qs) == 0): + + Qs_inf = np.isinf(Qs).values.sum() + if not (len(Qs) == 0 or Qs_inf > 0): ax.set_yscale('log') ############################################################################ From fb6f384314b6af52224f091ac0b878dd526675a2 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Wed, 9 Feb 2022 16:23:17 -0500 Subject: [PATCH 2/5] Change syntax to pass pylint. In particular, separate numpy from pandas. --- pyEPR/core_quantum_analysis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyEPR/core_quantum_analysis.py b/pyEPR/core_quantum_analysis.py index cba4187..5eaeebd 100644 --- a/pyEPR/core_quantum_analysis.py +++ b/pyEPR/core_quantum_analysis.py @@ -895,7 +895,8 @@ def plot_hamiltonian_results(self, legend=True, zorder=20, color=cmap) Qs.plot(ax=ax, lw=1, alpha=0.2, color='grey', legend=False) - Qs_inf = np.isinf(Qs).values.sum() + df_Qs = np.isinf(Qs) + Qs_inf = df_Qs.values.sum() if not (len(Qs) == 0 or Qs_inf > 0): ax.set_yscale('log') From 345ba655c949d595acb5abc04f7321d117afcf60 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Wed, 9 Feb 2022 17:03:25 -0500 Subject: [PATCH 3/5] Add int cast to pass pylint. --- pyEPR/core_quantum_analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyEPR/core_quantum_analysis.py b/pyEPR/core_quantum_analysis.py index 5eaeebd..7ba46de 100644 --- a/pyEPR/core_quantum_analysis.py +++ b/pyEPR/core_quantum_analysis.py @@ -896,7 +896,7 @@ def plot_hamiltonian_results(self, Qs.plot(ax=ax, lw=1, alpha=0.2, color='grey', legend=False) df_Qs = np.isinf(Qs) - Qs_inf = df_Qs.values.sum() + Qs_inf = int(df_Qs.values.sum()) if not (len(Qs) == 0 or Qs_inf > 0): ax.set_yscale('log') From 1622b7309dfeaa1740cd9fc376148bc0f9512bef Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Wed, 9 Feb 2022 17:20:38 -0500 Subject: [PATCH 4/5] Change syntax to pass pylint. --- pyEPR/core_quantum_analysis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyEPR/core_quantum_analysis.py b/pyEPR/core_quantum_analysis.py index 7ba46de..74f0b14 100644 --- a/pyEPR/core_quantum_analysis.py +++ b/pyEPR/core_quantum_analysis.py @@ -896,7 +896,8 @@ def plot_hamiltonian_results(self, Qs.plot(ax=ax, lw=1, alpha=0.2, color='grey', legend=False) df_Qs = np.isinf(Qs) - Qs_inf = int(df_Qs.values.sum()) + Qs_val = df_Qs.values + Qs_inf = Qs_val.sum() if not (len(Qs) == 0 or Qs_inf > 0): ax.set_yscale('log') From 427bc7d653f829726c83bb43be40706610d20d12 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Wed, 9 Feb 2022 17:28:18 -0500 Subject: [PATCH 5/5] Disable the pylint warning. --- pyEPR/core_quantum_analysis.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyEPR/core_quantum_analysis.py b/pyEPR/core_quantum_analysis.py index 74f0b14..b03780e 100644 --- a/pyEPR/core_quantum_analysis.py +++ b/pyEPR/core_quantum_analysis.py @@ -896,6 +896,8 @@ def plot_hamiltonian_results(self, Qs.plot(ax=ax, lw=1, alpha=0.2, color='grey', legend=False) df_Qs = np.isinf(Qs) + # pylint: disable=E1101 + # Instance of 'ndarray' has no 'values' member (no-member) Qs_val = df_Qs.values Qs_inf = Qs_val.sum() if not (len(Qs) == 0 or Qs_inf > 0):