@Override public void __setattr__(final String name, final PyObject value)
            throws PyException {
        if (name == "shape") {
            if (!this.isContiguous) { throw Py
                    .ValueError("reshape only works on contiguous matrices"); }
            final int[] shape = (int[]) value.__tojava__(this.dimensions
                    .getClass());
            this.dimensions = PyMultiarray.fixedShape(
                    shape,
                    PyMultiarray.shapeToNItems(this.dimensions));
            this.strides = PyMultiarray.shapeToStrides(
                    shape,
                    PyMultiarray.typeToNElements(this._typecode));
            return;
        }
        if (name == "imag" || name == "imaginary") {
            final PyMultiarray imag = this.getImag();
            if (imag != null) {
                imag.__setitem__(new PySlice(null, null, null), value);
                return;
            }
        }
        if (name == "real") {
            this.getReal().__setitem__(new PySlice(null, null, null), value);
            return;
        }
        super.__setattr__(name, value);
    }