Skip to content

MayaviClient not compatible with Python 3 #726

Description

@divico

It seems that MayaviClient can't be used with python 3. Running

from fipy import *
mesh = Grid3D(nx=50, ny=100, nz=10, dx=0.1, dy=0.01, dz=0.1)
x, y, z = mesh.cellCenters
xyzVar = CellVariable(mesh=mesh, name=r"x y z", value=x * y * z)
k = Variable(name="k", value=0.)
viewer = MayaviClient(vars=numerix.sin(k * xyzVar),
                     limits={'ymin': 0.1, 'ymax': 0.9},
                     datamin=-0.9, datamax=2.0,
                     title="MayaviClient test")

from builtins import range
for kval in range(10):
     k.setValue(kval)
     viewer.plot()
viewer._promptForOpinion()

gives the following error

NameError                                 Traceback (most recent call last)
<ipython-input-2-5f5075ddbc20> in <module>
      4 xyzVar = CellVariable(mesh=mesh, name=r"x y z", value=x * y * z)
      5 k = Variable(name="k", value=0.)
----> 6 viewer = MayaviClient(vars=numerix.sin(k * xyzVar),
      7                      limits={'ymin': 0.1, 'ymax': 0.9},
      8                      datamin=-0.9, datamax=2.0,

/usr/lib/python3.8/site-packages/fipy/viewers/mayaviViewer/mayaviClient.py in __init__(self, vars, title, daemon_file, fps, **kwlimits)
     73         AbstractViewer.__init__(self, vars=cell_vars + face_vars, title=title, **kwlimits)
     74 
---> 75         self.plot()
     76 
     77         from pkg_resources import Requirement, resource_filename

/usr/lib/python3.8/site-packages/fipy/viewers/mayaviViewer/mayaviClient.py in plot(self, filename)
    147                 if self.vtkFaceViewer is not None:
    148                     self.vtkFaceViewer.plot(filename=self.vtkfacefname)
--> 149                 lock = file(self.vtklockfname, 'w')
    150                 if filename is not None:
    151                     lock.write(filename)

NameError: name 'file' is not defined

replacing lock = file(self.vtklockfname, 'w') with lock = open(self.vtklockfname, 'w') works.

fipy.__version__ '3.4.1'
mayavi.__version__ '4.7.1'
sys.version_info sys.version_info(major=3, minor=8, micro=2, releaselevel='final', serial=0)

Please let me know if I can do some more testing

Thank you

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions