From 31313b34928bdc8c3e3f6ca1fdb54186b9213452 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Sat, 23 Jun 2018 01:04:30 -0700 Subject: [PATCH] Allow tests to pass using Python 3 These tests failed on Python 3 only because they used Python 2-specific syntax. --- pyext/src/io/xltable.py | 4 ++-- test/expensive_test_input.py | 8 +++++--- test/expensive_test_replica_exchange.py | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pyext/src/io/xltable.py b/pyext/src/io/xltable.py index edbaa3e0..31e04fae 100644 --- a/pyext/src/io/xltable.py +++ b/pyext/src/io/xltable.py @@ -267,7 +267,7 @@ def save_maps(self,maps_fn): maxlen=max(len(self.index_dict[key]) for key in self.index_dict) cnames=[] idxs=[] - for cname,idx in self.index_dict.iteritems(): + for cname,idx in self.index_dict.items(): cnames.append(cname) idxs.append(idx+[-1]*(maxlen-len(idx))) idx_array=np.array(idxs) @@ -851,7 +851,7 @@ def plot_table(self, prot_listx=None, # display and write to file fig.set_size_inches(0.002 * nresx, 0.002 * nresy) - [i.set_linewidth(2.0) for i in ax.spines.itervalues()] + [i.set_linewidth(2.0) for i in ax.spines.values()] if cbar_labels is not None: cbar = fig.colorbar(cax, ticks=[0.5,1.5,2.5,3.5]) cbar.ax.set_yticklabels(cbar_labels)# vertically oriented colorbar diff --git a/test/expensive_test_input.py b/test/expensive_test_input.py index a9735e05..ddd4d6f5 100644 --- a/test/expensive_test_input.py +++ b/test/expensive_test_input.py @@ -58,7 +58,7 @@ def test_get_best_models(self): self.assertEqual(len(rmf_file_list),8) self.assertEqual(len(rmf_file_frame_list),8) self.assertEqual(len(score_list),8) - for k,l in feature_keyword_list_dict.iteritems(): + for k,l in feature_keyword_list_dict.items(): self.assertEqual(len(l),8) def test_read_coordinates_of_rmfs(self): @@ -86,8 +86,10 @@ def test_read_coordinates_of_rmfs(self): self.assertEqual(len(all_coordinates),8) self.assertEqual(len(alignment_coordinates),8) self.assertEqual(len(rmsd_coordinates),8) - self.assertEqual(rmsd_coordinates[0].keys(),['med2']) - self.assertEqual(cmp(alignment_coordinates,[{}]*8),0) + self.assertEqual(list(rmsd_coordinates[0].keys()), ['med2']) + ltmp = [{}] * 8 + self.assertEqual((alignment_coordinates > ltmp) - + (alignment_coordinates < ltmp), 0) # testing first coordinate of med2 for each frame check_coords=[[17.23349762, 27.99548721,-8.91260719], diff --git a/test/expensive_test_replica_exchange.py b/test/expensive_test_replica_exchange.py index ae4a0c54..49f8eb4b 100644 --- a/test/expensive_test_replica_exchange.py +++ b/test/expensive_test_replica_exchange.py @@ -145,7 +145,7 @@ def test_macro(self): rmf_file_index]) nframes=len(d[mc_nframe_key]) self.assertNotEqual(float(d[mc_nframe_key][-1]), 0) - self.assertEqual(map(float,d[mc_temp_key]), [1.0]*nframes) + self.assertEqual(list(map(float,d[mc_temp_key])), [1.0]*nframes) self.assertGreater(float(d[rex_min_temp_key][-1]), 0.0) # always fails #self.assertGreater(float(d[rex_max_temp_key][-1]), 0.0) @@ -283,7 +283,7 @@ def test_macro_rmf_stat(self): rmf_file_index]) nframes=len(d[mc_nframe_key]) self.assertNotEqual(float(d[mc_nframe_key][-1]), 0) - self.assertEqual(map(float,d[mc_temp_key]), [1.0]*nframes) + self.assertEqual(list(map(float,d[mc_temp_key])), [1.0]*nframes) self.assertGreater(float(d[rex_min_temp_key][-1]), 0.0) # always fails #self.assertGreater(float(d[rex_max_temp_key][-1]), 0.0)