#57: allclose() broken in various ways for variables
----------------------+-----------------------------------------------------
  Reporter:  wd15     |       Owner:  nobody
      Type:  defect   |      Status:  closed
  Priority:  5        |   Component:  None  
   Version:  None     |    Severity:  Bugs  
Resolution:  wontfix  |    Keywords:        
----------------------+-----------------------------------------------------
Changes (by wd15):

  * resolution:  None => wontfix
  * status:  assigned => closed
  * type:  => defect

Old description:

> {{{
> Following test is broken in allcose() for Variable. The first print
> statemnet returns 1 as it is uspposed too but the second returns 1 also
> >>> from fipy.variables.variable import Variable >>> var = Variable((1,
> 1)) >>> print var.allclose((1, 1)) 1 >>> print var.allclose((1,)) 0 The
> next problem is a memory problem. This is most probably due to the
> formation of a collosall matrix. The result should be 0. >>> from
> fipy.meshes.grid1D import Grid1D >>> nx = 10000 >>> mesh = Grid1D(nx =
> nx) >>> from fipy.variables.cellVariable import CellVariable >>> var =
> CellVariable(mesh = mesh) >>> from fipy.tools import numerix >>> print
> var.allclose(numerix.ones(nx + 1)) Traceback (most recent call last):
> File &/users/wd15/tmp.py&, line 9, in ? print
> var.allclose(numerix.ones(nx + 1)) File &/users/wd15/pkg/python/fipy
> /HEAD-i686/fipy/variables/ variable.py&, line 1844, in allclose opShape =
> &number&) File &/users/wd15/pkg/python/fipy/HEAD-i686/fipy/variables/
> variable.py&, line 1519, in _getBinaryOperatorVariable (var0, var1) =
> _rotateShape(var0, var1, selfArray, otherArray) File
> &/users/wd15/pkg/python/fipy/HEAD-i686/fipy/variables/ variable.py&, line
> 1500, in _rotateShape if numerix.getShape(op(var0array, var1array[...,
> numerix.NewAxis])) != opShape: File &/users/wd15/pkg/python/fipy/HEAD-
> i686/fipy/variables/ variable.py&, line 1841, in <lambda> return
> self._getBinaryOperatorVariable(lambda a,b: numerix.allclose(a, b, atol =
> atol, rtol = rtol), File &/users/wd15/pkg/python/fipy/HEAD-
> i686/fipy/tools/ numerix.py&, line 934, in allclose return
> MA.allclose(first, second, atol = atol, rtol = rtol) File
> &/usr/lib/python2.3/site-packages/Numeric/MA/MA.py&, line 1402, in
> allclose d = Numeric.less_equal(Numeric.absolute(x-y), atol + rtol *
> Numeric.absolute(y)) MemoryError: cant allocate memory for array &&&
> }}}

New description:

 {{{
 Following test is broken in allcose() for Variable. The first print
 statemnet returns 1 as it is uspposed too but the second returns 1 also
 >>> from fipy.variables.variable import Variable >>> var = Variable((1,
 1)) >>> print var.allclose((1, 1)) 1 >>> print var.allclose((1,)) 0 The
 next problem is a memory problem. This is most probably due to the
 formation of a collosall matrix. The result should be 0. >>> from
 fipy.meshes.grid1D import Grid1D >>> nx = 10000 >>> mesh = Grid1D(nx = nx)
 >>> from fipy.variables.cellVariable import CellVariable >>> var =
 CellVariable(mesh = mesh) >>> from fipy.tools import numerix >>> print
 var.allclose(numerix.ones(nx + 1)) Traceback (most recent call last): File
 &/users/wd15/tmp.py&, line 9, in ? print var.allclose(numerix.ones(nx +
 1)) File &/users/wd15/pkg/python/fipy/HEAD-i686/fipy/variables/
 variable.py&, line 1844, in allclose opShape = &number&) File
 &/users/wd15/pkg/python/fipy/HEAD-i686/fipy/variables/ variable.py&, line
 1519, in _getBinaryOperatorVariable (var0, var1) = _rotateShape(var0,
 var1, selfArray, otherArray) File &/users/wd15/pkg/python/fipy/HEAD-
 i686/fipy/variables/ variable.py&, line 1500, in _rotateShape if
 numerix.getShape(op(var0array, var1array[..., numerix.NewAxis])) !=
 opShape: File &/users/wd15/pkg/python/fipy/HEAD-i686/fipy/variables/
 variable.py&, line 1841, in <lambda> return
 self._getBinaryOperatorVariable(lambda a,b: numerix.allclose(a, b, atol =
 atol, rtol = rtol), File &/users/wd15/pkg/python/fipy/HEAD-
 i686/fipy/tools/ numerix.py&, line 934, in allclose return
 MA.allclose(first, second, atol = atol, rtol = rtol) File
 &/usr/lib/python2.3/site-packages/Numeric/MA/MA.py&, line 1402, in
 allclose d = Numeric.less_equal(Numeric.absolute(x-y), atol + rtol *
 Numeric.absolute(y)) MemoryError: cant allocate memory for array &&&
 }}}
 {{{

 ==
 ----

 {{{
 ''''
 }}}
  ==

 }}}

Comment:

 I think that the results actually make sense.

     >>> from fipy.variables.variable import Variable
     >>> var = Variable((1, 1))
     >>> print var.allclose((1, 1))
     >>> var.allclose((1,))
     1

 The above is not a bad answer. As for the memory problem, I think that is
 inevitable.

-- 
Ticket URL: <http://matdl-osi.org:9000/fipy/ticket/57>
FiPy <http://www.ctcms.nist.gov/fipy>
A Finite Volume PDE Solver Using Python

Reply via email to