Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
Remove redundant parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Pål Grønås Drange authored and Pål Grønås Drange committed Oct 17, 2017
1 parent 800a06c commit 2b9691e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
16 changes: 8 additions & 8 deletions python/sunbeam/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ def __init__(self, _, schedule, timestep):
def __getitem__(self, name):
return Group(self._schedule._group(name), self._schedule, self.timestep)

def wells(self, timestep):
names = self._wellnames(timestep)
wells = {well.name: well for well in self._schedule.wells}
return map(wells.__getitem__, filter(wells.__contains__, names))
@property
def wells(self):
names = self._wellnames(self.timestep)
return [w for w in self._schedule.wells if w.name in names]

@property
def parent(self):
Expand All @@ -100,8 +100,8 @@ def parent(self):

@property
def children(self):
l = []
chl = self._schedule._group_tree(self.timestep)._children(self.name)
for elem in chl:
l.append(Group(self._schedule._group(elem), self._schedule, self.timestep))
return l
g = lambda elt : Group(self._schedule._group(elt),
self._schedule,
self.timestep)
return [g(elem) for elem in chl]
9 changes: 6 additions & 3 deletions tests/group_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ def test_group(self):
self.assertEqual(None, gr.parent.parent)

def test_timestep_groups(self):
total = 0
for group in self.es.schedule.groups(timestep=3):
for child in group.children:
self.assertIsNotNone(child.name)
total += 1
self.assertEqual(13, total)

group = self.es.schedule.group(timestep=3)['PROD']
children = ['MANI-B1', 'MANI-B2', 'MANI-D1', 'MANI-D2', 'MANI-E1', 'MANI-E2']
for child in group.children:
self.assertIn(child.name, children)

names = [child.name for child in group.children]
self.assertEqual(sunbeam.schedule.Group, type(child))
self.assertEqual(set(children), set(names))

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion tests/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def testTimesteps(self):
self.assertEqual(dt.date(2015, 12, 31), timesteps[7])

def testGroups(self):
g1 = self.sch.group()['G1'].wells(0)
g1 = self.sch.group()['G1'].wells
self.assertEqual(2, len(g1))

def head(xs): return next(iter(xs))
Expand Down

0 comments on commit 2b9691e

Please sign in to comment.