Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 3 compatibility for DofMapPlotter class #22

Merged
merged 1 commit into from
Sep 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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