Hi Daniel,

Sorry for the somewhat long delay. I couldn't work on the
problem for a while.

On 2014-10-20 16:25, Daniel Wheeler wrote:
> On Sun, Oct 19, 2014 at 4:57 PM, Stefan Schwarzer <[email protected] 
> wrote:
>> I gave it a try and installed Anaconda3. When running
>> `python setup.py install`, I still have/had some issues.
>>
>> For one, a few files have mixed indentation (mixed spaces
>> and tabs) which Python 3 doesn't like:
>>
>>   Sorry: TabError: inconsistent use of tabs and spaces in indentation
>> (testBase.py, line 47)
>>   Sorry: TabError: inconsistent use of tabs and spaces in indentation
>> (trilinosSolver.py, line 148)
>>   Sorry: TabError: inconsistent use of tabs and spaces in indentation
>> (gistVectorViewer.py, line 70)
> 
> I've never seen that before when installing with Python 3 in Anaconda.
> Which version of FiPy are you using?

I saw this both in FiPy 3.1 and in the Git repository I
fetched today.

You don't see the problem in Python 2, but Python 3
complains if you mix tabs and spaces in one file.

>> After fixing the files, I got that far:
>>
>>   The required module(s) ['pysparse'] cannot be loaded.
>>   FiPy will not work properly until these modules are installed.
>>   ------
>>   The optional module(s) ['gist', 'mayavi'] cannot be loaded.
>>   FiPy will have improved capabilities if these modules are installed.
>>
>> It seems `pysparse` is only available for Python 2. Is this
>> correct? Is it indeed needed?
> 
> You don't need PySparse. It isn't available for Python 3 yet. The Scipy
> solvers are adequate to get started. None of the solvers are required
> packages, but you obviously need one of them.

I suggest fixing the message then because it says `pysparse`
is required. :-)

> Gist is a very old package that we need to remove from the dependencies.
> It's a viewer. You don't actually need any of the viewers to use FiPy.
> However to see stuff interactively while the simulation is running, it is
> good to have one of them. I would suggest using Matplotlib to get started.
> Mayavi is just optional.

I've set up an Anaconda environment and installed FiPy from
Git (I tried with FiPy 3.1 first), matplotlib 1.4.2 and
NumPy 1.9.0.

I tried to run the following code,

  mesh = fipy.Grid2D(dx=1.0, dy=1.0, nx=10, ny=10)
  initial_value = 0.0
  concentration = fipy.CellVariable(
                    mesh, "concentration", value=initial_value)
  x, y = mesh.cellCenters
  concentration.setValue(10.0, where=(x<3.0) & (y<3.0))
  eq = fipy.TransientTerm() == fipy.DiffusionTerm(coeff=1.0)
  import ipdb; ipdb.set_trace()
  viewer = fipy.MatplotlibViewer(vars=concentration,
                                 xmin=0, xmax=1.0, ymin=0, ymax=1.0,
                                 datamin=0.0, datamax=10.0)
  # Solve.
  time_step = 0.01
  steps = 1000
  for step in range(steps):
      eq.solve(var=concentration, dt=time_step)
      viewer.plot()

but it fails when setting up the viewer:

  /home/schwa/sd/python/diffusion/diffusion.py in _set_up(self)
       88         eq = fipy.TransientTerm() == fipy.DiffusionTerm(coeff=1.0)
       89         import ipdb; ipdb.set_trace()
  ---> 90         viewer = fipy.MatplotlibViewer(vars=concentration,
       91                                        xmin=0, xmax=1.0, ymin=0, 
ymax=1.0,
       92                                        datamin=0.0, datamax=10.0)

  
/home/schwa/sd/anaconda3/envs/diffusion/lib/python3.4/site-packages/FiPy-3.1-py3.4.egg/fipy/viewers/matplotlibViewer/__init__.py
 in MatplotlibViewer(vars, title, limits, cmap, colorbar, axes, **kwlimits)
      115         try:
      116             from fipy.viewers.matplotlibViewer.matplotlib2DGridViewer 
import Matplotlib2DGridViewer
  --> 117             return Matplotlib2DGridViewer(vars=vars, title=title, 
cmap=cmap, colorbar=colorbar, axes=axes, **kwlimits)
      118         except MeshDimensionError:
      119             try:

  
/home/schwa/sd/anaconda3/envs/diffusion/lib/python3.4/site-packages/FiPy-3.1-py3.4.egg/fipy/viewers/matplotlibViewer/matplotlib2DGridViewer.py
 in __init__(self, vars, title, limits, cmap, colorbar, axes, figaspect, 
**kwlimits)
       80         AbstractMatplotlib2DViewer.__init__(self, vars=vars, 
title=title,
       81                                             cmap=cmap, 
colorbar=colorbar, axes=axes, figaspect=figaspect,
  ---> 82                                             **kwlimits)
       83
       84         self.image = self.axes.imshow(self._data,

  
/home/schwa/sd/anaconda3/envs/diffusion/lib/python3.4/site-packages/FiPy-3.1-py3.4.egg/fipy/viewers/matplotlibViewer/matplotlibViewer.py
 in __init__(self, vars, title, figaspect, cmap, colorbar, axes, log, 
**kwlimits)
      108
      109         if colorbar:
  --> 110             self.colorbar = _ColorBar(viewer=self)
      111         else:
      112             self.colorbar = None

  
/home/schwa/sd/anaconda3/envs/diffusion/lib/python3.4/site-packages/FiPy-3.1-py3.4.egg/fipy/viewers/matplotlibViewer/matplotlibViewer.py
 in __init__(self, viewer, vmin, vmax, orientation)
      194         # and labels.
      195         self._cb = matplotlib.colorbar.ColorbarBase(cbax, 
cmap=viewer.cmap,
  --> 196                                                     
orientation=orientation)
      197         self._cb.set_label(viewer.vars[0].name)
      198

  
/home/schwa/sd/anaconda3/envs/diffusion/lib/python3.4/site-packages/matplotlib/colorbar.py
 in __init__(self, ax, cmap, norm, alpha, values, boundaries, orientation, 
ticklocation, extend, spacing, ticks, format, drawedges, filled, extendfrac, 
extendrect, label)
      319         # The rest is in a method so we can recalculate when clim 
changes.
      320         self.config_axis()
  --> 321         self.draw_all()
      322
      323     def _extend_lower(self):

  
/home/schwa/sd/anaconda3/envs/diffusion/lib/python3.4/site-packages/matplotlib/colorbar.py
 in draw_all(self)
      340         and do all the drawing.
      341         '''
  --> 342         self._process_values()
      343         self._find_range()
      344         X, Y = self._mesh()

  
/home/schwa/sd/anaconda3/envs/diffusion/lib/python3.4/site-packages/matplotlib/colorbar.py
 in _process_values(self, b)
      656             self.norm.vmin, self.norm.vmax = 
mtrans.nonsingular(self.norm.vmin,
      657                                                                 
self.norm.vmax,
  --> 658                                                                 
expander=0.1)
      659             if not self.norm.scaled():
      660                 self.norm.vmin = 0

  
/home/schwa/sd/anaconda3/envs/diffusion/lib/python3.4/site-packages/matplotlib/transforms.py
 in nonsingular(vmin, vmax, expander, tiny, increasing)
     2641     returns -*expander*, *expander*.
     2642     '''
  -> 2643     if (not np.isfinite(vmin)) or (not np.isfinite(vmax)):
     2644         return -expander, expander
     2645     swapped = False

  TypeError: ufunc 'isfinite' not supported for the input types, and the inputs 
could not be safely coerced to any supported types according to the casting 
rule ''safe''

As I found with the debugger, `vmin` and `vmax` are `None`
here. I suppose, their values should have been picked from
the `kwlimits` keyword arguments. If I remember the
documentation correctly, it should even have worked without
the keyword limits as FiPy should have figured out sensible
defaults on its own.

The diffusion code above looks a lot like the FiPy example
in `FiPy-3.1/examples/diffusion/mesh20x20.py` and when I run
this file, I indeed get

  Traceback (most recent call last):
    File "examples/diffusion/mesh20x20.py", line 141, in <module>
      exec(fipy.tests.doctestPlus._getScript())
    File "<string>", line 52, in <module>
    File 
"/home/schwa/sd/anaconda3/envs/diffusion/lib/python3.4/site-packages/FiPy-3.1-py3.4.egg/fipy/viewers/__init__.py",
 line 136, in Viewer
      raise ImportError("Failed to import a viewer: %s" % str(errors))
  ImportError: Failed to import a viewer: ["gnuplot: __call__() missing 1 
required positional argument: 'func'", "matplotlib: ufunc 'isfinite' not 
supported for the input types, and the inputs could not be safely coerced to 
any supported types according to the casting rule ''safe''", "mayavi: No module 
named 'enthought'", "gist: __call__() missing 1 required positional argument: 
'func'"]

Look at the part, "matplotlib: ufunc 'isfinite' not
supported for the input types, and the inputs could not be
safely coerced to any supported types according to the
casting rule ''safe''". This is the same exception message I
got above.

I compared the `matplotlibViewer` directories of FiPy 3.1
and the Git version of today with `diff -r`, but didn't see
any differences.

>> By the way, when I execute the code from
>>
>> http://www.ctcms.nist.gov/fipy/fipy/generated/fipy.viewers.matplotlibViewer.html#matplotlibviewer-package
>> up to and including the `viewer1 = MatplotlibViewer(...)`
>> call and
>>
>>   >>> viewer = MultiViewer(viewers=(viewer1,))
>>   >>> for kval in range(10):
>>   ...   k.setValue(kval)
>>   ...   viewer.plot()
>>
>> I get several diagram plotted in the top left figure. So it
>> seems that Matplotlib is working in this environment. Also
>> it seems to cooperate with FiPy.
> 
> That's good at least.

I guess the difference between the working and the
non-working plots is that the latter try to create a
`ColorbarBase` instance and fail with the above exception.
The other examples I tried and that worked only plotted
curves, if I remember correctly.

> There are certianly some rough edges with FiPy and
> Python 3 that we need to address.

The first thing I'd like to see

> Good luck.

Um, wish me more. :-)

Best regards,
Stefan
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to