Skip to content

Commit 0945e88

Browse files
authored
Merge pull request #208 from PhysFoley/bugfix/nerdss-write-to-readonly-array
Fix writing to read-only array bug in nerdss_converter.py
2 parents 66166e8 + ecfd75b commit 0945e88

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

simulariumio/nerdss/nerdss_converter.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from MDAnalysis import Universe
22
import os
33

4+
import numpy as np
5+
46
from ..trajectory_converter import TrajectoryConverter
57
from ..data_objects import (
68
AgentData,
@@ -131,6 +133,10 @@ def _read_pdb_files(self, input_data: NerdssData) -> AgentData:
131133
"bonds", input_data.display_data
132134
)
133135
next_uid = agent_data.unique_ids.max() + 1
136+
137+
# need our own write-able n_subpoints array
138+
n_subpoints = np.zeros_like(agent_data.n_subpoints)
139+
134140
for timestep in range(n_timesteps):
135141
n_fibers = len(fiber_positions[timestep])
136142
n_atoms = int(agent_data.n_agents[timestep])
@@ -139,7 +145,7 @@ def _read_pdb_files(self, input_data: NerdssData) -> AgentData:
139145
agent_data.subpoints[timestep][agent_index + n_atoms] = fiber_positions[
140146
timestep
141147
][agent_index]
142-
agent_data.n_subpoints[timestep][agent_index + n_atoms] = (
148+
n_subpoints[timestep][agent_index + n_atoms] = (
143149
VALUES_PER_3D_POINT * 2
144150
)
145151
agent_data.viz_types[timestep][agent_index + n_atoms] = VIZ_TYPE.FIBER
@@ -149,6 +155,7 @@ def _read_pdb_files(self, input_data: NerdssData) -> AgentData:
149155
agent_data.types[timestep].append(bonds_display_data.name)
150156
agent_data.unique_ids[timestep][agent_index + n_atoms] = next_uid
151157
next_uid += 1
158+
agent_data.n_subpoints = n_subpoints # overwrite with our own array
152159
return agent_data
153160

154161
def _read(self, input_data: NerdssData) -> TrajectoryData:

0 commit comments

Comments
 (0)