Skip to content

Commit

Permalink
Merge pull request mantidproject#18738 from mantidproject/18730_Pytho…
Browse files Browse the repository at this point in the history
…nXrange

Changes to Direct reduction code to unwrap range into list and unit test for it
  • Loading branch information
martyngigg authored Feb 8, 2017
2 parents ddd36a5 + 181faba commit 1285d40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/Inelastic/Direct/RunDescriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@ def __set__(self,instance,value):
self._set_run_list(instance,run_num,file_path,fext)
else:
self._set_single_run(instance,run_num,file_path,fext)
elif isinstance(value,list):
elif isinstance(value, collections.Iterable): # xrange provided
value = list(value)
self._set_run_list(instance,value,"",None)
else:
self._set_single_run(instance,value,"",None)
Expand Down
6 changes: 6 additions & 0 deletions scripts/test/RunDescriptorTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ def test_get_run_list(self):
run_list = PropertyManager.sample_run.get_run_list()
self.assertEqual(len(run_list),1)

# check if run list can be set up using range
propman.sample_run = range(1,4)
run_list = PropertyManager.sample_run.get_run_list()
self.assertEqual(len(run_list),3)
self.assertTrue(isinstance(run_list,list))

def test_sum_runs(self):
propman = self.prop_man
propman.sample_run = [11001,11001]
Expand Down

0 comments on commit 1285d40

Please sign in to comment.