SciTools/iris — pull request #888 by shoyer (2013-12-14 07:57:02+00:00)
Title: Refactored internals of iris.analysis.maths

The goal here was to reduce redundant code and consolidate functionality, to
facilitate future extensions of iris.analysis operators.

For example, I would like to be able to easily define new cube operations like
`>`, `<`, `>=`, `<=`, `&`, `|`, `^` and `%` that are analogous to the standard
numpy operations.

By putting binary operations that involving broadcasting a cube and another
object together, it should also be easier to extend the cube broadcasting
rules.

This change includes adjusted docstrings to reflect current functionality and
removal of code that wasn't doing anything (as caught by pylint). None of the
public facing API is changed. That will come next :).

The refactoring did reveal a few places where broadcasting rules differ for no
clear reason between add/subtract and multiply/divide. Arguably, the special
logic for add/subtract broadcasting should also be consolidated into
`_binary_op_common` so that it used for multiply/divide as well. Also, there
is a case for exposing a public interfaces to `_math_op_common` and
`_binary_op_common` to facilitate writing new cube operations, just like how
`iris.analaysis.Aggregator` facilitates writing new cube aggregations.