Skip to content

Commit

Permalink
Fixed a few issues discovered in testing on python3 (#260)
Browse files Browse the repository at this point in the history
* gwsumm.archive: copy table before archiving

so that things aren't broken when we try to use the same table for data processing

* gwsumm.tabs: cast `map` to `list`

so that we can index it with python3

* gwsumm.tabs: fixed broken HTML for SEI tabs
  • Loading branch information
duncanmmacleod authored and Alex L. Urban committed Apr 29, 2019
1 parent 29fdde7 commit 4bf6b29
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
3 changes: 3 additions & 0 deletions gwsumm/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ def archive_table(table, key, parent):
the h5py group in which to add this dataset
"""
# copy table so we can modify meta without impacting anything
table = table.copy(copy_data=False)

if len(table) == 0:
warnings.warn("%r table is empty and will not be archived" % key)
return
Expand Down
15 changes: 9 additions & 6 deletions gwsumm/tabs/etg.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,23 @@ def from_ini(cls, config, section, **kwargs):
]
# override from config
if config.has_option(section, 'loudest-columns'):
new.loudest['columns'] = map(
new.loudest['columns'] = list(map(
lambda s: re_quote.sub('', s),
config.get(section, 'loudest-columns').split(','))
config.get(section, 'loudest-columns').split(',')
))
if config.has_option(section, 'loudest-labels'):
new.loudest['labels'] = map(
new.loudest['labels'] = list(map(
lambda s: re_quote.sub('', s),
config.get(section, 'loudest-labels').split(','))
config.get(section, 'loudest-labels').split(',')
))
else:
new.loudest['labels'] = [' '.join(map(str.title, s.split('_')))
for s in new.loudest['columns']]
if config.has_option(section, 'loudest-rank'):
new.loudest['rank'] = map(
new.loudest['rank'] = list(map(
lambda c: re_quote.sub('', c),
config.get(section, 'loudest-rank').split(','))
config.get(section, 'loudest-rank').split(',')
))
if config.has_option(section, 'loudest-dt'):
new.loudest['dt'] = config.getfloat(section, 'loudest-dt')
else:
Expand Down
11 changes: 7 additions & 4 deletions gwsumm/tabs/sei.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@

import numpy

from MarkupPy import markup

from gwpy.time import Time

from gwdetchar.io import html as gwhtml

from .registry import (get_tab, register_tab)
from .. import (globalv, html)
from ..config import GWSummConfigParser
Expand Down Expand Up @@ -297,7 +301,7 @@ def write_state_html(self, state):
totals[i][j] = c
# add row total
totals[i][-1] = totals[i].sum()
page.th(totals[i][-1])
page.th(str(totals[i][-1]))
page.tr.close()
page.tbody.close()

Expand All @@ -306,8 +310,7 @@ def write_state_html(self, state):
page.tr(class_='header')
page.th('Totals')
for i in range(totals.shape[1]):
t = totals[:, i].sum()
page.th(t)
page.th(str(totals[:, i].sum()))
page.tr.close()
page.thead.close()
page.table.close()
Expand Down Expand Up @@ -381,7 +384,7 @@ def write_state_html(self, state):
rows[-1].append('<br>'.join(assoc))
else:
rows[-1].append('-')
page.add(str(html.table(
page.add(str(gwhtml.table(
headers, rows,
caption=('List of %s watch-dog trips in interval [%d .. %d) - '
'trips are considered \'associated\' if they fall within '
Expand Down

0 comments on commit 4bf6b29

Please sign in to comment.