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

--pysparse --inline failures #294

Closed
guyer opened this issue Sep 19, 2014 · 3 comments
Closed

--pysparse --inline failures #294

guyer opened this issue Sep 19, 2014 · 3 comments

Comments

@guyer
Copy link
Member

guyer commented Sep 19, 2014

There are at least six --inline failures (there appear to be more on OS X, plus it [segfaults before it finishes](issue #293))

==================================================================h4. 
FAIL: variable (examples.diffusion)
Doctest: examples.diffusion.variable
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/doctest.py", line 2166, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for examples.diffusion.variable
  File ".../examples/diffusion/variable.py", line 6, in variable

----------------------------------------------------------------------
File ".../examples/diffusion/variable.py", line 18, in examples.diffusion.variable
Failed example:
print var.allclose(values, atol = 1e-8, rtol = 1e-8)
Expected:
1
Got:
False


==============================================================h4. 
FAIL: howToWriteAScript (examples.levelSet.electroChem)
Doctest: examples.levelSet.electroChem.howToWriteAScript
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/doctest.py", line 2166, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for examples.levelSet.electroChem.howToWriteAScript
  File ".../examples/levelSet/electroChem/howToWriteAScript.py", line 6, in howToWriteAScript

----------------------------------------------------------------------
File ".../examples/levelSet/electroChem/howToWriteAScript.py", line 418, in examples.levelSet.electroChem.howToWriteAScript
Failed example:
print catalystVar.allclose(numerix.loadtxt(filepath), rtol=1e-4)
Expected:
1
Got:
False


==============================================================h4. 
FAIL: simpleTrenchSystem (examples.levelSet.electroChem)
Doctest: examples.levelSet.electroChem.simpleTrenchSystem
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/doctest.py", line 2166, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for examples.levelSet.electroChem.simpleTrenchSystem
  File ".../examples/levelSet/electroChem/simpleTrenchSystem.py", line 6, in simpleTrenchSystem

----------------------------------------------------------------------
File ".../examples/levelSet/electroChem/simpleTrenchSystem.py", line 25, in examples.levelSet.electroChem.simpleTrenchSystem
Failed example:
runSimpleTrenchSystem(numberOfSteps=2, displayViewers=False)
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.7/doctest.py", line 1254, in __run
compileflags, 1) in test.globs
File "<doctest examples.levelSet.electroChem.simpleTrenchSystem[0]>", line 1, in <module>
runSimpleTrenchSystem(numberOfSteps=2, displayViewers=False)
File ".../examples/levelSet/electroChem/simpleTrenchSystem.py", line 314, in runSimpleTrenchSystem
bulkCatalystEquation.solve(bulkCatalystVar, dt = dt, solver=GeneralSolver(tolerance=1e-15, iterations=2000))
File ".../fipy/terms/term.py", line 215, in solve
solver._solve()
File ".../fipy/solvers/pysparse/pysparseSolver.py", line 108, in _solve
self._solve_(self.matrix, array, self.RHSvector)
File ".../fipy/solvers/pysparse/linearLUSolver.py", line 89, in _solve_
LU = superlu.factorize(L.matrix.to_csr())
RuntimeError: Factor is exactly singular
----------------------------------------------------------------------
File ".../examples/levelSet/electroChem/simpleTrenchSystem.py", line 37, in examples.levelSet.electroChem.simpleTrenchSystem
Failed example:
runSimpleTrenchSystem(numberOfSteps=2, catalystCoverage=0.1, displayViewers=False)
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.7/doctest.py", line 1254, in __run
compileflags, 1) in test.globs
File "<doctest examples.levelSet.electroChem.simpleTrenchSystem[1]>", line 1, in <module>
runSimpleTrenchSystem(numberOfSteps=2, catalystCoverage=0.1, displayViewers=False)
File ".../examples/levelSet/electroChem/simpleTrenchSystem.py", line 314, in runSimpleTrenchSystem
bulkCatalystEquation.solve(bulkCatalystVar, dt = dt, solver=GeneralSolver(tolerance=1e-15, iterations=2000))
File ".../fipy/terms/term.py", line 215, in solve
solver._solve()
File ".../fipy/solvers/pysparse/pysparseSolver.py", line 108, in _solve
self._solve_(self.matrix, array, self.RHSvector)
File ".../fipy/solvers/pysparse/linearLUSolver.py", line 89, in _solve_
LU = superlu.factorize(L.matrix.to_csr())
RuntimeError: Factor is exactly singular


==============================================================h4. 
FAIL: gold (examples.levelSet.electroChem)
Doctest: examples.levelSet.electroChem.gold
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/doctest.py", line 2166, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for examples.levelSet.electroChem.gold
  File ".../examples/levelSet/electroChem/gold.py", line 6, in gold

----------------------------------------------------------------------
File ".../examples/levelSet/electroChem/gold.py", line 25, in examples.levelSet.electroChem.gold
Failed example:
runGold(numberOfSteps=10, displayViewers=False) # doctest: +GMSH
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.7/doctest.py", line 1254, in __run
compileflags, 1) in test.globs
File "<doctest examples.levelSet.electroChem.gold[0]>", line 1, in <module>
runGold(numberOfSteps=10, displayViewers=False) # doctest: +GMSH
File ".../examples/levelSet/electroChem/gold.py", line 226, in runGold
advectionEquation.solve(distanceVar, dt = dt)
File ".../fipy/terms/term.py", line 215, in solve
solver._solve()
File ".../fipy/solvers/pysparse/pysparseSolver.py", line 108, in _solve
self._solve_(self.matrix, array, self.RHSvector)
File ".../fipy/solvers/pysparse/linearLUSolver.py", line 89, in _solve_
LU = superlu.factorize(L.matrix.to_csr())
RuntimeError: Factor is exactly singular


==============================================================h4. 
FAIL: leveler (examples.levelSet.electroChem)
Doctest: examples.levelSet.electroChem.leveler
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/doctest.py", line 2166, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for examples.levelSet.electroChem.leveler
  File ".../examples/levelSet/electroChem/leveler.py", line 6, in leveler

----------------------------------------------------------------------
File ".../examples/levelSet/electroChem/leveler.py", line 25, in examples.levelSet.electroChem.leveler
Failed example:
runLeveler(numberOfSteps=10, displayViewers=False, cellSize=0.25e-7) # doctest: +GMSH
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.7/doctest.py", line 1254, in __run
compileflags, 1) in test.globs
File "<doctest examples.levelSet.electroChem.leveler[0]>", line 1, in <module>
runLeveler(numberOfSteps=10, displayViewers=False, cellSize=0.25e-7) # doctest: +GMSH
File ".../examples/levelSet/electroChem/leveler.py", line 419, in runLeveler
eqn.solve(var, boundaryConditions = BCs, dt = dt, solver=solver)
File ".../fipy/terms/term.py", line 215, in solve
solver._solve()
File ".../fipy/solvers/pysparse/pysparseSolver.py", line 108, in _solve
self._solve_(self.matrix, array, self.RHSvector)
File ".../fipy/solvers/pysparse/linearLUSolver.py", line 89, in _solve_
LU = superlu.factorize(L.matrix.to_csr())
RuntimeError: Factor is exactly singular


==================================================================
FAIL: stokesCavity (examples.flow)
Doctest: examples.flow.stokesCavity
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/doctest.py", line 2166, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for examples.flow.stokesCavity
  File ".../examples/flow/stokesCavity.py", line 6, in stokesCavity

----------------------------------------------------------------------
File ".../examples/flow/stokesCavity.py", line 294, in examples.flow.stokesCavity
Failed example:
print numerix.allclose(pressure.globalValue[...,-1], 162.790867927)
Expected:
1
Got:
False
----------------------------------------------------------------------
File ".../examples/flow/stokesCavity.py", line 296, in examples.flow.stokesCavity
Failed example:
print numerix.allclose(xVelocity.globalValue[...,-1], 0.265072740929)
Expected:
1
Got:
False
----------------------------------------------------------------------
File ".../examples/flow/stokesCavity.py", line 298, in examples.flow.stokesCavity
Failed example:
print numerix.allclose(yVelocity.globalValue[...,-1], -0.150290488304)
Expected:
1
Got:
False

Imported from trac ticket #395, created by guyer on 12-02-2011 at 18:47, last modified: 01-10-2012 at 13:07

@guyer
Copy link
Member Author

guyer commented Sep 19, 2014

Moved ~/.python27_compiled out of the way and ran PYTHONCOMPILED=MODULE python examples/diffusion/variable.py --inline obtaining

.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp: In functionPyObject* compiled_func(PyObject*, PyObject*)’:
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: error: ambiguous overload foroperator*inpy::object::operator[](int)(((j * ni) + i)) *#### pyobject::operator[](int)(((j * ni) + i))’
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note: candidates are: operator*(int, int) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(int, float) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(int, double) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(float, int) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(float, float) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(float, double) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(double, int) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(double, float) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(double, double) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp: In functionPyObject* compiled_func(PyObject*, PyObject*)’:
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: error: ambiguous overload foroperator*inpy::object::operator[](int)(((j * ni) + i)) *#### pyobject::operator[](int)(((j * ni) + i))’
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note: candidates are: operator*(int, int) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(int, float) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(int, double) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(float, int) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(float, float) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(float, double) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(double, int) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(double, float) <built-in>
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: note:                 operator*(double, double) <built-in>
Traceback (most recent call last):
  File "examples/diffusion/variable.py", line 65, in <module>
mesh = Tri2D(dx, dy, nx, ny)
  File ".../fipy/meshes/tri2D.py", line 100, in __init__
Mesh2D.__init__(self, vertices, faces, cells)
  File ".../fipy/meshes/mesh.py", line 84, in __init__
self._setGeometry(scaleLength = 1.)
  File ".../fipy/meshes/mesh.py", line 157, in _setGeometry
self._faceAreas = self._calcFaceAreas()
  File ".../fipy/meshes/mesh2D.py", line 79, in _calcFaceAreas
return numerix.sqrtDot(tangent, tangent)
  File ".../fipy/tools/numerix.py", line 421, in sqrtDot
""",result1=result1, a1=a1, a2=a2, ni=ni, NJ=NJ)
  File ".../fipy/tools/inline.py", line 111, in _runInline
extra_compile_args =['-O3'])
  File "/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave/inline_tools.py", line 355, in inline
**kw)
  File "/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave/inline_tools.py", line 482, in compile_function
verbose=verbose, **kw)
  File "/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave/ext_tools.py", line 367, in compile
verbose = verbose, **kw)
  File "/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave/build_tools.py", line 272, in build_extension
setup(name = module_name, ext_modules = [ext],verbose=verb)
  File "/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/numpy/distutils/core.py", line 186, in setup
return old_setup(**new_attr)
  File "/Users/guyer/.homebrew/Cellar/python/2.7.2/lib/python2.7/distutils/core.py", line 169, in setup
raise SystemExit, "error: " + str(msg)
scipy.weave.build_tools.CompileError: error: Command "/usr/bin/g++-4.2 -fno-strict-aliasing -O3 -march=core2 -msse4.1 -w -pipe -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave -I/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave/scxx -I/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/numpy/core/include -I/Users/guyer/.homebrew/Cellar/python/2.7.2/include/python2.7 -c .../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp -o .../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.o -O3" failed with exit status 1

I've run back to r3000 and still get the same error, so I think something has changed in SciPy (I'm running 0.9.0 now).

Trac comment by guyer on 12-03-2011 at 17:38

@guyer
Copy link
Member Author

guyer commented Sep 19, 2014

Replying to guyer:

Moved ~/.python27_compiled out of the way and ran PYTHONCOMPILED=MODULE python examples/diffusion/variable.py --inline obtaining

.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp: In functionPyObject* compiled_func(PyObject*, PyObject*)’:
.../fipy/tools/sc_8be0cdeed8d598d898ca8ab97055fc790.cpp:706: error: ambiguous overload foroperator*inpy::object::operator[](int)(((j * ni) + i)) *#### pyobject::operator[](int)(((j * ni) + i))’

Oops. That one I'd already figured out by patching sqrtDot:

#diff
--- fipy/tools/numerix.py   (revision 4996)
+++ fipy/tools/numerix.py   (working copy)
@@ -400,12 +400,22 @@
Usually used with v1==v2 to return magnitude of v1.
"""
unit1 = unit2 = 1
-        if _isPhysical(a1):
-            unit1 = a1.inBaseUnits().getUnit()
-            a1 = a1.numericValue
-        if _isPhysical(a2):
-            unit2 = a2.inBaseUnits().getUnit()
-            a2 = a2.numericValue
+        
+        def dimensionlessUnmasked(a):
+            unit = 1
+            mask = False
+            if _isPhysical(a):
+                unit = a.inBaseUnits().getUnit()
+                a = a.numericValue
+            if MA.isMaskedArray(a):
+                mask = a.mask
+                a = a.filled(fill_value=1)
+                
+            return (a, unit, mask)
+            
+        a1, unit1, mask1 = dimensionlessUnmasked(a1)
+        a2, unit2, mask2 = dimensionlessUnmasked(a2)
+        
NJ, ni = NUMERIX.shape(a1)
result1 = NUMERIX.zeros((ni,),'d')

@@ -420,6 +430,11 @@
result1[i] = sqrt(result1[i]);
""",result1=result1, a1=a1, a2=a2, ni=ni, NJ=NJ)

  •    if NUMERIX.any(mask1) or NUMERIX.any(mask2):
    
  •        result1 = MA.array(result1, mask=NUMERIX.logical_or(mask1, mask2))
    
  •    print >>sys.stderr, "result1", type(result1)
    
    if unit1 != 1 or unit2 != 1:
    from fipy.tools.dimensions.physicalField import PhysicalField
    result1 = PhysicalField(value=result, unit=(unit1 * unit2)**0.5)
but then I get 
```python
.../fipy/tools/sc_32ebf90cbece946e767b6ffbe4bfa2100.cpp: In function ‘PyObject* compiled_func(PyObject*, PyObject*)’:
.../fipy/tools/sc_32ebf90cbece946e767b6ffbe4bfa2100.cpp:854: error: ‘normals_array’ was not declared in this scope
.../fipy/tools/sc_32ebf90cbece946e767b6ffbe4bfa2100.cpp: In function ‘PyObject* compiled_func(PyObject*, PyObject*)’:
.../fipy/tools/sc_32ebf90cbece946e767b6ffbe4bfa2100.cpp:854: error: ‘normals_array’ was not declared in this scope
Traceback (most recent call last):
  File "examples/diffusion/variable.py", line 86, in <module>
exec(fipy.tests.doctestPlus._getScript())
  File "<string>", line 6, in <module>
  File ".../fipy/terms/term.py", line 213, in solve
solver = self._prepareLinearSystem(var, solver, boundaryConditions, dt)
  File ".../fipy/terms/term.py", line 175, in _prepareLinearSystem
buildExplicitIfOther=self._buildExplcitIfOther)
  File ".../fipy/terms/unaryTerm.py", line 98, in _buildAndAddMatrices
diffusionGeomCoeff=diffusionGeomCoeff)
  File ".../fipy/terms/baseDiffusionTerm.py", line 334, in _buildMatrix
nthCoeffFaceGrad = coeff[numerix.newaxis] * var.faceGrad[:,numerix.newaxis]
  File ".../fipy/variables/variable.py", line 1555, in __getitem__
unit=self.unit,
  File ".../fipy/variables/variable.py", line 257, in _getUnit
return self._extractUnit(self.value)
  File ".../fipy/variables/variable.py", line 521, in _getValue
value = self._calcValue()
  File ".../fipy/variables/faceGradVariable.py", line 80, in _calcValue
return self._calcValueInline()
  File ".../fipy/variables/faceGradVariable.py", line 129, in _calcValueInline
shape=numerix.array(numerix.shape(tangents1)))
  File ".../fipy/tools/inline.py", line 185, in _runIterateElementInline
""")
  File "/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave/inline_tools.py", line 355, in inline
**kw)
  File "/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave/inline_tools.py", line 482, in compile_function
verbose=verbose, **kw)
  File "/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave/ext_tools.py", line 367, in compile
verbose = verbose, **kw)
  File "/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave/build_tools.py", line 272, in build_extension
setup(name = module_name, ext_modules = [ext],verbose=verb)
  File "/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/numpy/distutils/core.py", line 186, in setup
return old_setup(**new_attr)
  File "/Users/guyer/.homebrew/Cellar/python/2.7.2/lib/python2.7/distutils/core.py", line 169, in setup
raise SystemExit, "error: " + str(msg)
scipy.weave.build_tools.CompileError: error: Command "/usr/bin/g++-4.2 -fno-strict-aliasing -O3 -march=core2 -msse4.1 -w -pipe -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave -I/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/scipy/weave/scxx -I/Users/guyer/.virtualenvs/virtualbrew/lib/python2.7/site-packages/numpy/core/include -I/Users/guyer/.homebrew/Cellar/python/2.7.2/include/python2.7 -c .../fipy/tools/sc_32ebf90cbece946e767b6ffbe4bfa2100.cpp -o .../fipy/tools/sc_32ebf90cbece946e767b6ffbe4bfa2100.o -O0" failed with exit status 1

and, indeed, normals is defined by

#cpp
py::object normals = convert_to_catchall(py_normals,"normals");

which seems to happen with MaskedArrays. Did weave stop handling those?

Trac comment by guyer on 12-03-2011 at 17:51

@wd15
Copy link
Contributor

wd15 commented Sep 19, 2014

Inline issues have been fixed with changset:5095 and changset:5103.

Trac comment by wd15 on 01-10-2012 at 13:07

@guyer guyer closed this as completed Sep 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants