Changeset 763 for mystic


Ignore:
Timestamp:
10/07/14 15:29:24 (20 months ago)
Author:
mmckerns
Message:

use numpy.seterr to ignore nan in measures.normalize and in greater/less bounds

Location:
mystic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • mystic/_math/measures.py

    r760 r763  
    380380  w = float(sum(weights)) 
    381381  if not w:  #XXX: is this the best behavior? 
    382     from numpy import inf 
     382    from numpy import inf, nan 
     383    weights[weights == 0.0] = nan 
    383384    return list(weights * inf)  # protect against ZeroDivision 
    384385  if float(mass) or not zsum: 
  • mystic/mystic/abstract_map_solver.py

    r713 r763  
    4141    >>> from pyina.launchers import Mpi as Pool 
    4242    >>> NNODES = 4 
    43     >>>> npts = 20 
     43    >>> npts = 20 
    4444    >>> 
    4545    >>> # instantiate and configure the solver 
    46     >>> from mystic.solvers import ScattershotSolver 
    47     >>> solver = ScattershotSolver(len(lb), npts) 
     46    >>> from mystic.solvers import BuckshotSolver 
     47    >>> solver = BuckshotSolver(len(lb), npts) 
    4848    >>> solver.SetMapper(Pool(NNODES).map) 
    4949    >>> solver.SetGenerationMonitor(stepmon) 
  • mystic/mystic/abstract_solver.py

    r760 r763  
    7777 
    7878import numpy 
    79 from numpy import inf, shape, asarray, absolute, asfarray 
     79from numpy import inf, shape, asarray, absolute, asfarray, seterr 
    8080from mystic.tools import wrap_function, wrap_nested, wrap_reducer 
    8181from mystic.tools import wrap_bounds, wrap_penalty, reduced 
     
    341341        hi = self._strictMax 
    342342        # crop x0 at bounds 
     343        settings = numpy.seterr(all='ignore') 
    343344        x0[x0<lo] = lo[x0<lo] 
    344345        x0[x0>hi] = hi[x0>hi] 
     346        numpy.seterr(**settings) 
    345347        return x0 
    346348 
  • mystic/mystic/scipy_optimize.py

    r758 r763  
    119119        val[bounded] = x0[bounded] + (hi[bounded]-lo[bounded])*radius 
    120120        # crop val at bounds 
     121        settings = numpy.seterr(all='ignore') 
    121122        val[val<lo] = lo[val<lo] 
    122123        val[val>hi] = hi[val>hi] 
     124        numpy.seterr(**settings) 
    123125        # handle collisions (when val[i] == x0[i]) 
    124126        collision = val==x0 
Note: See TracChangeset for help on using the changeset viewer.