#555

Request to merge #555 into the master branch.
Makes sense. I made the change as you suggested.

On Tue, Dec 16, 2014 at 8:16 PM, Mike Jarvis <notifications@github.com>
wrote:
>
> In galsim/detectors.py
> <https://github.com/GalSim-developers/GalSim/pull/615#discussion-diff-21946632>
> :
>
> > +    """
> > +
> > +    # IPC kernel has to be a 3x3 numpy array
> > +    if not isinstance(IPC_kernel,numpy.ndarray):
> > +        raise ValueError("IPC_kernel must be a NumPy array.")
> > +    if not IPC_kernel.shape==(3,3):
> > +        raise ValueError("IPC kernel must be a NumPy array of size 3x3.")
> > +
> > +    # Check for non-negativity of the kernel
> > +    if kernel_nonnegativity is True:
> > +        if (IPC_kernel<0).any() is True:
> > +            raise ValueError("IPC kernel must not contain negative entries")
> > +
> > +    # Check and enforce correct normalization for the kernel
> > +    if kernel_normalization is True:
> > +        if IPC_kernel.sum() != 1.0:
>
> It only alters the kernel by a small amount, but the user sees a warning
> that implies that it didn't add up to 1. This could be confusing if they
> thought they had made sure that it would. e.g.
>
> >>> kernel = numpy.array( [[ 1., 4., 1. ], [ 4., 8., 4. ], [ 1., 4., 1. ]] )
> >>> kernel /= kernel.sum()
> >>> kernel.sum() == 1.0
> False
>
> So I think the warning should only issue if the discrepancy is more than
> you would expect from rounding errors. e.g.
>
> >>> numpy.abs(kernel.sum() - 1.0) < 10. * numpy.finfo(kernel.dtype.type).eps
> True
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/GalSim-developers/GalSim/pull/615/files#r21946632>.
>


-- 
Regards

Arun Kannawadi Jayaraman
PhD candidate, Dept. of Physics,
Carnegie Mellon University,
Pittsburgh, PA 15213