Skip to content

Commit

Permalink
Changed test_binary to work differently
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Blumberg committed Jan 10, 2019
1 parent c681828 commit 1c8b927
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 32 deletions.
72 changes: 42 additions & 30 deletions runsharp/full_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,44 +1046,56 @@ def newerRelease(latest):
if ret_code == QMessageBox.Yes:
QDesktopServices.openUrl(QUrl(latest[2]))

@crasher(exit=True)
def createWindow(file_names, collect=False, close=True):
main_win = Main()
for fname in file_names:
print("Creating image for '%s' ..." % fname)
main_win.picker.skewApp(filename=fname)
if not collect:
fpath, fbase = os.path.split(fname)

if '.' in fbase:
img_base = ".".join(fbase.split(".")[:-1] + ['png'])
else:
img_base = fbase + '.png'

img_name = os.path.join(fpath, img_base)
main_win.picker.skew.spc_widget.pixmapToFile(img_name)
if fname != file_names[-1] or close:
main_win.picker.skew.close()

if collect:
main_win.picker.skew.spc_widget.toggleCollectObserved()
img_name = collect[0]
main_win.picker.skew.spc_widget.pixmapToFile(img_name)
if close:
main_win.picker.skew.close()

return main_win

def test(fn):
# Run the binary and output a test profile
if QApplication.instance() is None:
app = QApplication([])
else:
app = QApplication.instance()
win = createWindow([fn])
win.close()

def main():
ap = argparse.ArgumentParser()
ap.add_argument('file_names', nargs='*')
ap.add_argument('--debug', dest='debug', action='store_true')
ap.add_argument('--collect', dest='collect', nargs=1, default=None)
ap.add_argument('--noclose', dest='close', action='store_false')
args = ap.parse_args()

@crasher(exit=True)
def createWindow(file_names, collect=False, close=True):
main_win = Main()
for fname in file_names:
print("Creating image for '%s' ..." % fname)
main_win.picker.skewApp(filename=fname)
if not collect:
fpath, fbase = os.path.split(fname)

if '.' in fbase:
img_base = ".".join(fbase.split(".")[:-1] + ['png'])
else:
img_base = fbase + '.png'

img_name = os.path.join(fpath, img_base)
main_win.picker.skew.spc_widget.pixmapToFile(img_name)
if fname != file_names[-1] or close:
main_win.picker.skew.close()

if collect:
main_win.picker.skew.spc_widget.toggleCollectObserved()
img_name = collect[0]
main_win.picker.skew.spc_widget.pixmapToFile(img_name)
if close:
main_win.picker.skew.close()

return main_win


# Create an application
app = QApplication([])
if QApplication.instance() is None:
app = QApplication([])
else:
app = QApplication.instance()

# Alert the user that there's a newer version on Github (and by extension through CI also on pip and conda)
if latest[0] is False:
Expand Down
10 changes: 9 additions & 1 deletion sharppy/tests/test_binary.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import os
import sys
import pytest
import runsharp.full_gui as full_gui
#from runsharp import full_gui

@pytest.mark.skipif("DISPLAY_AVAIL" in os.environ and os.environ["DISPLAY_AVAIL"] == 'NO', reason="DISPLAY not set")
def test_main_entry_pt():
os.system('python runsharp/full_gui.py examples/data/14061619.OAX')
#sys.argv = []
#print(full_gui.sys.argv)
#full_gui.sys.argv.append('examples/data/14061619.OAX')
full_gui.test('examples/data/14061619.OAX')

#test_main_entry_pt()

3 changes: 2 additions & 1 deletion sharppy/viz/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def segmentPath(b, lb_lat, ub_lat):
# numpy array (first column is lons, second is lats).
polystring = bdatfile.read(bytecount)
# binary data is little endian.
b = np.array(np.fromstring(polystring,dtype='<f4'),'f8')
#b = np.array(np.fromstring(polystring,dtype='<f4'),'f8')
b = np.array(np.frombuffer(polystring,dtype='<f4'),'f8')
b.shape = (npts, 2)

if np.any(b[:, 0] > 180):
Expand Down

0 comments on commit 1c8b927

Please sign in to comment.