Skip to content

MemoryReader copy creates new Timestep object #2081

@richardjgowers

Description

@richardjgowers

Expected behavior

MemoryReader.copy should return a working-as-intended MemoryReader

Actual behavior

The Timestep attached to the MemoryReader is disjointed from the stored arrays on MemoryReader. Modifying the Timestep then doesn't update the underlying arrays

Code to reproduce the behavior

from MDAnalysis.coordinates.memory import MemoryReader
import numpy as np

coords = np.arange(60).reshape(2, 10, 3).astype(np.float32)
mr = MemoryReader(coords)
mr.coordinate_array
mr2 = mr.copy()

# assign value to positions
# as this is a  memoryreader, this change should be permanent
mr2.ts.positions = -1

mr2[0]

assert mr2.ts.positions == -1  # will fail

# not saved to master array
mr2.coordinate_array

Currently version of MDAnalysis

  • Which version are you using? (run python -c "import MDAnalysis as mda; print(mda.__version__)")
  • Which version of Python (python -V)?
  • Which operating system?

0.18.0

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions