pandegroup/openmm — pull request #750 by swails (2014-12-06 23:33:20+00:00)
Title: Fix small bug in `simtk.unit` related to mutable sequences.

This is highly related to #536, #537, and #538. The issue raised in those issues and fixed in #538 was the following:

```Python
>>> from simtk import unit as u
>>> l = [1, 2, 3] * u.angstroms
>>> k = l.value_in_unit(u.angstroms)
>>> k[0] = 2
>>> print l
[2, 2, 3] A
```

The problem was that `l._value` was being returned as an inappropriate optimization, meaning changes to `k` also changed `l`. This was fixed by @peastman in #538 by returning a `copy.deepcopy` of `self._value` instead of returning `self._value` itself.

However, what we apparently missed there is that the syntax that _should_ behave equivalently actually follows a different code path. For example, the above bug still exists when cast as:

```Python
>>> from simtk import unit as u
>>> l = [1, 2, 3] * u.angstroms
>>> k = l / u.angstroms
>>> k
[1, 2, 3]
>>> k[0] = 2
>>> l
[2, 2, 3] A
```

This PR fixes the above such that it behaves the same way that `value_in_unit` does.