Skip to content

Commit

Permalink
Merge pull request #6 from 3dem/jmrt-addrow
Browse files Browse the repository at this point in the history
Hotfix of a bug in addRow
  • Loading branch information
azazellochg authored May 19, 2021
2 parents 8cd0738 + d487bec commit 0d1c918
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
3 changes: 2 additions & 1 deletion emtable/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# *
# **************************************************************************

__version__ = '0.0.7'
__version__ = '0.0.8'
__author__ = 'Jose Miguel de la Rosa Trevin'


Expand Down Expand Up @@ -340,6 +340,7 @@ def readStar(self, inputFile, tableName=None, guessType=True):
reader = _Reader(inputFile, tableName=tableName, guessType=guessType)
self._columns = reader._columns
self._rows = reader.readAll()
self.Row = reader.Row

def read(self, fileName, tableName=None):
with open(fileName) as f:
Expand Down
4 changes: 0 additions & 4 deletions emtable/tests/strings_star_relion.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
except ImportError:
from io import StringIO # for Python 3

import unittest
from metadata import Table


particles_3d_classify = """
data_Particles
Expand Down
26 changes: 24 additions & 2 deletions emtable/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
from io import StringIO # for Python 3
import unittest

from metadata import Table
from .strings_star_relion import particles_3d_classify, one_micrograph_mc
from emtable import Table
from strings_star_relion import particles_3d_classify, one_micrograph_mc

here = os.path.abspath(os.path.dirname(__file__))

Expand Down Expand Up @@ -296,6 +296,28 @@ def _values(colName):
print("Writing to: ", tmpOutput)
table.write(tmpOutput, tableName='sampling_directions')

def test_addRows(self):
t1 = Table()
f1 = StringIO(particles_3d_classify)

t1.readStar(f1)
nRows = len(t1)
lastRow = t1[-1]

values = [1, 307.000, 195.000, "14sep05c_00024sq_00003hl_00002es.frames.out.mrc",
0, 1, "000001@Runs/000632_XmippProtExtractParticles/extra/14sep05c_00024sq_00003hl_00002es.frames_aligned_mic_DW.stk",
12339.183594, 12294.791992, 99.198835, 0.100000, 2.7000, 300.000, 1, 1, 68.622382, 83.727084,
-61.370416, 1.791925, 6.791925, 4, 0.663729, 28037.624716, 0.973726, 7
]

for i in range(1, 4):
values[4] = nRows + 1
t1.addRow(*values)

self.assertEqual(nRows + 3, len(t1))
newLastRow = t1[-1]
self.assertEqual(len(lastRow), len(newLastRow))


N = 100

Expand Down

0 comments on commit 0d1c918

Please sign in to comment.