GalSim-developers/GalSim — pull request #128 by rmjarvis (2012-05-01 01:30:08+00:00)
Title: Big Image class overhaul -- #82, #114, #117, #123, #124, #125

I think my big Image overhaul is ready for code review.

- The main thing is to implement the syntax that became known as [option D](https://github.com/GalSim-developers/GalSim/issues/117#issuecomment-5390358) in the "epic discussion" for issue #117.
- Also from #117: removed `redefine` method which Gary pointed out problematic, and Jim himself described as dangerous.
- Added `setValue` method as a way to set pixel values in python.
- Changed name of `move` method to `setOrigin`.
- Also added `setCenter` method for convenience.
- Changed semantics of `copyFrom` and all arithmetic ops to expect images to be the same shape, but not necessarily the same origin. The old behavior was to act on the overlap of the two bounds. The old behavior can be recovered by `im[im.bounds & im2.bounds] = im2[im.bounds & im2.bounds]` which is probably clearer as to the intent.
- #82: I haven't separated out the image resize from the draw command, so this issue shouldn't be closed yet. But it does implement the basic syntax of `draw(im,dx,wmult)` in addition to `im = draw(dx,wmult)` in python.
- #114: Added `im[bounds] = im2` syntax for sub-images plus a bunch of unit tests to check this syntax does the right thing.
- #123: The arithmetic in python now passes through to arithmetic on the numpy arrays, so mixed arithmetic works fine on the python side. I added this to the unit tests to check and all is well. I didn't implement it for C++. We can decide if that's worth doing or not. (I suspect we don't need it.)
- #124: Added im * 2, im / 2, etc. And added units tests for these.
- #125: Using numpy arithmetic means that there are no ugly C++ exceptions leading to crashes when we hit a division by zero. However, numpy doesn't throw a ZerDivisionError exception. For floats, it silently computes a Nan or Inf as appropriate. For ints, anything divided by 0 is 0. Weird, but we decided that was ok, since it probably won't ever matter.