lisa-lab/pylearn2 — pull request #1091 by SuperElectric (2014-08-22 15:56:45+00:00)
Title: NORB bugfix

Fixed a bug in NORB that was only visible when the NORB object was given memmaps instantiated with mode='w+' as its .X or .y fields.

When pickling NORB files, its __getstate__ would replace .X and .y with argument lists for instantiating the memmap files, used to load the memmaps when unpickling. The bug was that these argument lists contained `mode='w+'` if the memmap was originally created with `mode='w+'`. When unpickling, this mode was used, causing the memmap to be overwritten. This bug is now fixed (repaced 'w+' with 'r+').

Also, there was a risk that, after pickling a NORB object, a user could still edit its memmaps, causing changes to the "saved" data. To prevent this, when a NORB is pickled, it now automatically switches its memmaps to be read-only. The user must now explicitly switch the memmaps back to read-write if they want to.