Skip to content

Commit

Permalink
Merge pull request #22 from francesco-ballarin/master
Browse files Browse the repository at this point in the history
python 3 compatibility for DofMapPlotter class
  • Loading branch information
MiroK authored Sep 29, 2017
2 parents dc994d1 + a5e5a30 commit cc47382
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions fenicstools/DofMapPlotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def plot(self, component=[], sub=None, order='global'):
# Convert component to list if necessary and perform validity check
component = component if type(component) is list else [component]
# If component is empty plot all dofmaps
component = component if component else range(self.num_dofmaps())
component = component if component else list(range(self.num_dofmaps()))
if not self._arg_check(component):
raise ValueError('Component is not list or in [0, %d)' %
self.num_dofmaps())
Expand All @@ -99,7 +99,7 @@ def plot(self, component=[], sub=None, order='global'):
assert (0 <= sub < self.num_subspaces()) and (type(sub) is int)

# Compute component of subspace
sub_component = range(self.bounds[sub], self.bounds[sub+1])
sub_component = list(range(self.bounds[sub], self.bounds[sub+1]))

# Plot
self.plot(component=sub_component, sub=None, order=order)
Expand Down
2 changes: 1 addition & 1 deletion fenicstools/dofmapplotter/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def bounds(V):
signature_ = V
signature_ = flat_signature(signature_)
trans = lambda x: x if x else x + 1
signature_ = map(trans, signature_)
signature_ = list(map(trans, signature_))
limits = partial_sum(signature_)
limits = [0] + limits

Expand Down
2 changes: 1 addition & 1 deletion fenicstools/dofmapplotter/dofhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _dof_plot(self, event):
elif (event.key == 'D') and not self.showing_all_dofs:
start = time.time()
self.printer('Processing ...', 'blue')
cell_indices = xrange(self.mesh.num_cells())
cell_indices = range(self.mesh.num_cells())
for cell_index in cell_indices:
self._cell_dof_plot(cell_index)
self.fig.canvas.draw()
Expand Down
2 changes: 1 addition & 1 deletion fenicstools/dofmapplotter/meshentityhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _mesh_entity_plot(self, event, local_key, global_key, tdim):
elif pressed_gc and not self.showing_all_mesh_entities[tdim]:
start = time.time()
self.printer('Processing ...', 'blue')
cell_indices = xrange(self.mesh.num_cells())
cell_indices = range(self.mesh.num_cells())

for cell_index in cell_indices:
self._single_mesh_entity_plot(cell_index, tdim)
Expand Down

0 comments on commit cc47382

Please sign in to comment.