# Buggy code
def _single_frame(self):
    mobile_com = self.mobile_atoms.center(self.weights).astype(np.float64)
    self._mobile_coordinates64[:] = self.mobile_atoms.positions
    self._mobile_coordinates64 -= mobile_com

    self.rmsd[self._frame_index, :2] = self._ts.frame, self._trajectory.time

    if self._groupselections_atoms:
        # superimpose structures: MDAnalysis qcprot needs Nx3 coordinate
        # array with float64 datatype (float32 leads to errors up to 1e-3 in
        # RMSD). Note that R is defined in such a way that it acts **to the
        # left** so that we can easily use broadcasting and save one
        # expensive numpy transposition.

        self.rmsd[self._frame_index, 2] = qcp.CalcRMSDRotationalMatrix(
            self._ref_coordinates_64,
            self._mobile_coordinates64,
            self._n_atoms,
            self._rot,
            self.weights,
        )

        self._R[:, :] = self._rot.reshape(3, 3)
        # Transform each atom in the trajectory (use inplace ops to
        # avoid copying arrays) (Marginally (~3%) faster than
        # "ts.positions[:] = (ts.positions - x_com) * R + ref_com".)
        self._ts.positions[:] -= mobile_com

        # R acts to the left & is broadcasted N times.
        self._ts.positions[:, :] = self._mobile_coordinates64[:] * self._R
        self._ts.positions[:] += self._ref_com

        # 2) calculate secondary RMSDs
        for igroup, (refpos, atoms) in enumerate(
            zip(self._groupselections_ref_coords_64, self._groupselections_atoms), 3
        ):
            self.rmsd[self._frame_index, igroup] = qcp.CalcRMSDRotationalMatrix(
                refpos,
                atoms["mobile"].positions.astype(np.float64),
                atoms["mobile"].n_atoms,
                None,
                self.weights,
            )
    else:
        # only calculate RMSD by setting the Rmatrix to None (no need
        # to carry out the rotation as we already get the optimum RMSD)
        self.rmsd[self._frame_index, 2] = qcp.CalcRMSDRotationalMatrix(
            self._ref_coordinates_64,
            self._mobile_coordinates64,
            self._n_atoms,
            None,
            self.weights,
        )

    self._pm.rmsd = self.rmsd[self._frame_index, 2]


# Traceback (ValueError)
R = MDAnalysis.analysis.rms.RMSD(atomgroup=u, reference=u, select='backbone', groupselections=['backbone and resid 1:10','backbone and resid 10:20'])
R.run()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-e54575231350> in <module>()
1 R = MDAnalysis.analysis.rms.RMSD(atomgroup=u, reference=u, select='backbone', groupselections=['backbone and resid 1:10','backbone and resid 10:20'], FIX = False)
----> 2 R.run()

/home/user/anaconda3/envs/py27/lib/python2.7/site-packages/MDAnalysis/analysis/base.pyc in run(self)
179             self._ts = ts
180             # logger.info("--> Doing frame {} of {}".format(i+1, self.n_frames))
--> 181             self._single_frame()
182             self._pm.echo(self._frame_index)
183         logger.info("Finishing up")

/home/user/anaconda3/envs/py27/lib/python2.7/site-packages/MDAnalysis/analysis/rms.pyc in _single_frame(self)
542                 self._ts.positions = (self._ts.positions * self._R)
543             else:
--> 544                 self._ts.positions[:,:] = (self._mobile_coordinates64[:] * self._R)
545             self._ts.positions[:] += self._ref_com
546

ValueError: could not broadcast input array from shape (855,3) into shape (3341,3)

# Fixed code
def _single_frame(self):
    mobile_com = self.mobile_atoms.center(self.weights).astype(np.float64)
    self._mobile_coordinates64[:] = self.mobile_atoms.positions
    self._mobile_coordinates64 -= mobile_com

    self.rmsd[self._frame_index, :2] = self._ts.frame, self._trajectory.time

    if self._groupselections_atoms:
        # superimpose structures: MDAnalysis qcprot needs Nx3 coordinate
        # array with float64 datatype (float32 leads to errors up to 1e-3 in
        # RMSD). Note that R is defined in such a way that it acts **to the
        # left** so that we can easily use broadcasting and save one
        # expensive numpy transposition.

        self.rmsd[self._frame_index, 2] = qcp.CalcRMSDRotationalMatrix(
            self._ref_coordinates_64,
            self._mobile_coordinates64,
            self._n_atoms,
            self._rot,
            self.weights,
        )

        self._R[:, :] = self._rot.reshape(3, 3)
        # Transform each atom in the trajectory (use inplace ops to
        # avoid copying arrays) (Marginally (~3%) faster than
        # "ts.positions[:] = (ts.positions - x_com) * R + ref_com".)
        self._ts.positions[:] -= mobile_com

        # R acts to the left & is broadcasted N times.
        self._ts.positions[:, :] = self._ts.positions * self._R
        self._ts.positions[:] += self._ref_com

        # 2) calculate secondary RMSDs
        for igroup, (refpos, atoms) in enumerate(
            zip(self._groupselections_ref_coords_64, self._groupselections_atoms), 3
        ):
            self.rmsd[self._frame_index, igroup] = qcp.CalcRMSDRotationalMatrix(
                refpos,
                atoms["mobile"].positions.astype(np.float64),
                atoms["mobile"].n_atoms,
                None,
                self.weights,
            )
    else:
        # only calculate RMSD by setting the Rmatrix to None (no need
        # to carry out the rotation as we already get the optimum RMSD)
        self.rmsd[self._frame_index, 2] = qcp.CalcRMSDRotationalMatrix(
            self._ref_coordinates_64,
            self._mobile_coordinates64,
            self._n_atoms,
            None,
            self.weights,
        )

    self._pm.rmsd = self.rmsd[self._frame_index, 2]