Skip to content

Commit

Permalink
clean: make frame_slice_list private (#1258)
Browse files Browse the repository at this point in the history
* clean

* add pca example readme

* minor
  • Loading branch information
hainm committed May 28, 2016
1 parent 1f22b35 commit bbf3923
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ How to get started?
```python
import pytraj as pt
traj = pt.iterload("data.nc", "top.parm7")
pt.rmsd(traj, ref=0, mask='@CA')
pt.dssp(traj, ':2-16')
pt.rmsd(traj, mask='@CA', ref=0)
pt.dssp(traj, mask=':2-16')
pt.pca(traj, mask='!@H=', n_vecs=2)
```
- check our website: [http://amber-md.github.io/pytraj] (http://amber-md.github.io/pytraj)

Expand Down
2 changes: 1 addition & 1 deletion pytraj/core/c_core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def _load_batch(txt, traj=None):
if traj is not None:
lines_0 = ['parm %s' % traj.top.filename]

for fname, frame_slice in zip(traj.filelist, traj.frame_slice_list):
for fname, frame_slice in zip(traj.filelist, traj._frame_slice_list):
if len(frame_slice) == 3:
start, stop, step = frame_slice
elif len(frame_slice) == 2:
Expand Down
2 changes: 1 addition & 1 deletion pytraj/sandbox/TrajectoryBaseIterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def filelist(self):

@property
@abstractmethod
def frame_slice_list(self):
def _frame_slice_list(self):
pass

@abstractmethod
Expand Down
12 changes: 6 additions & 6 deletions pytraj/trajectory_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(self, filename=None, top=None, *args, **kwd):
else:
raise ValueError("Topology must be None/string/Topology")

self.frame_slice_list = []
self._frame_slice_list = []

if filename:
if self.top.is_empty():
Expand All @@ -134,7 +134,7 @@ def __init__(self, filename=None, top=None, *args, **kwd):
self.__dict__.update({
'_top_filename': self.top.filename,
'filelist': self.filelist,
'frame_slice_list': self.frame_slice_list,
'_frame_slice_list': self._frame_slice_list,
})

def __setstate__(self, state):
Expand All @@ -144,7 +144,7 @@ def __setstate__(self, state):
else:
# faster
self.top = _load_Topology(state['_top_filename'])
self._load(state['filelist'], frame_slice=state['frame_slice_list'])
self._load(state['filelist'], frame_slice=state['_frame_slice_list'])

def __getstate__(self):
'''
Expand Down Expand Up @@ -180,7 +180,7 @@ def copy(self):
other = self.__class__()
other.top = self.top.copy()

for fname, frame_slice in zip(self.filelist, self.frame_slice_list):
for fname, frame_slice in zip(self.filelist, self._frame_slice_list):
other._load(fname, frame_slice=frame_slice)
return other

Expand All @@ -201,7 +201,7 @@ def _load(self, filename=None, top=None, frame_slice=(0, -1, 1), stride=None):

if isinstance(filename, string_types) and os.path.exists(filename):
super(TrajectoryIterator, self)._load(filename, top_, frame_slice_)
self.frame_slice_list.append(frame_slice_)
self._frame_slice_list.append(frame_slice_)
elif isinstance(filename,
string_types) and not os.path.exists(filename):

Expand All @@ -221,7 +221,7 @@ def _load(self, filename=None, top=None, frame_slice=(0, -1, 1), stride=None):
full_frame_slice = [(0, -1, stride),] * len(flist)

for fname, fslice in zip(flist, full_frame_slice):
self.frame_slice_list.append(frame_slice)
self._frame_slice_list.append(frame_slice)
super(TrajectoryIterator, self)._load(fname,
top_,
frame_slice=fslice)
Expand Down

0 comments on commit bbf3923

Please sign in to comment.