Skip to content

Commit

Permalink
a few minor fixes related to Python 2 to 3 conversion and new Phoenix…
Browse files Browse the repository at this point in the history
… api
  • Loading branch information
giumas committed Aug 4, 2017
1 parent 6876fef commit c38ed45
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 59 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# The short X.Y version.
version = '0.7'
# The full version, including alpha/beta/rc tags.
release = '0.7.b3'
release = '0.7.b5'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
63 changes: 20 additions & 43 deletions hdf_compass/bag_model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
Implementation of compass_model classes for BAG files.
"""
from itertools import groupby
import sys
import os.path as op
import posixpath as pp
import h5py
Expand Down Expand Up @@ -93,6 +92,7 @@ def can_handle(url):
return True

def __init__(self, url):
super().__init__(url=url)
if not self.can_handle(url):
raise ValueError(url)
self._url = url
Expand Down Expand Up @@ -129,12 +129,14 @@ def _names(self):
self._xnames = list(self._group)

# Natural sort is expensive
# noinspection PyTypeChecker
if len(self._xnames) < 1000:
self._xnames.sort(key=sort_key)

return self._xnames

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
self._group = store.f[key]
Expand Down Expand Up @@ -167,6 +169,7 @@ def __len__(self):
return len(self._group)

def __iter__(self):
# noinspection PyTypeChecker
for name in self._names:
yield self.store[pp.join(self.key, name)]

Expand All @@ -192,12 +195,14 @@ def _names(self):
self._xnames = list(self._group)

# Natural sort is expensive
# noinspection PyTypeChecker
if len(self._xnames) < 1000:
self._xnames.sort(key=sort_key)

return self._xnames

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
self._group = store.f[key]
Expand Down Expand Up @@ -228,6 +233,7 @@ def __len__(self):
return len(self._group)

def __iter__(self):
# noinspection PyTypeChecker
for name in self._names:
yield self.store[pp.join(self.key, name)]

Expand All @@ -245,6 +251,7 @@ def can_handle(store, key):
return key in store and isinstance(store.f[key], h5py.Dataset)

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
self._dset = store.f[key]
Expand Down Expand Up @@ -295,6 +302,7 @@ def can_handle(store, key):
return (key == "/BAG_root/elevation") and (key in store) and (isinstance(store.f[key], h5py.Dataset))

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
self._dset = store.f.elevation(mask_nan=True)
Expand Down Expand Up @@ -341,6 +349,7 @@ def can_handle(store, key):
return (key == "/BAG_root/elevation") and (key in store) and (isinstance(store.f[key], h5py.Dataset))

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
self._dset = store.f.elevation(mask_nan=True)
Expand Down Expand Up @@ -398,6 +407,7 @@ def can_handle(store, key):
return (key == "/BAG_root/elevation") and (key in store) and (isinstance(store.f[key], h5py.Dataset))

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
self._dset = store.f.elevation(mask_nan=True)
Expand Down Expand Up @@ -436,47 +446,6 @@ def __getitem__(self, args):
return self._dset[args]


class BAGUncertaintyArray(compass_model.Array):
""" Represents an uncertainty array. """
class_kind = "BAG Uncertainty [array]"

@staticmethod
def can_handle(store, key):
return (key == "/BAG_root/uncertainty") and (key in store) and (isinstance(store.f[key], h5py.Dataset))

def __init__(self, store, key):
self._store = store
self._key = key
self._dset = store.f.uncertainty(mask_nan=True)

@property
def key(self):
return self._key

@property
def store(self):
return self._store

@property
def display_name(self):
return pp.basename(self.key)

@property
def description(self):
return 'Dataset "%s"' % (self.display_name,)

@property
def shape(self):
return self._dset.shape

@property
def dtype(self):
return self._dset.dtype

def __getitem__(self, args):
return self._dset[args]


class BAGTrackinList(compass_model.Array):
""" Represents a BAG tracking list. """
class_kind = "BAG Tracking List"
Expand All @@ -486,6 +455,7 @@ def can_handle(store, key):
return (key == "/BAG_root/tracking_list") and (key in store) and (isinstance(store.f[key], h5py.Dataset))

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
self._dset = store.f.tracking_list()
Expand Down Expand Up @@ -527,6 +497,7 @@ def can_handle(store, key):
return (key == "/BAG_root/metadata") and (key in store) and (isinstance(store.f[key], h5py.Dataset))

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
self._dset = store.f.metadata(as_string=False, as_pretty_xml=False)
Expand Down Expand Up @@ -578,6 +549,7 @@ def can_handle(store, key):
return (key == "/BAG_root/metadata") and (key in store) and (isinstance(store.f[key], h5py.Dataset))

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
try:
Expand Down Expand Up @@ -621,6 +593,7 @@ def has_validation(self):
return True

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
try:
Expand Down Expand Up @@ -664,6 +637,7 @@ def can_handle(store, key):
return (key == "/BAG_root/uncertainty") and (key in store) and (isinstance(store.f[key], h5py.Dataset))

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
self._dset = store.f.uncertainty(mask_nan=True)
Expand Down Expand Up @@ -710,6 +684,7 @@ def can_handle(store, key):
return (key == "/BAG_root/uncertainty") and (key in store) and (isinstance(store.f[key], h5py.Dataset))

def __init__(self, store, key):
super().__init__(store=store, key=key)
self._store = store
self._key = key
self._dset = store.f.uncertainty(mask_nan=True)
Expand Down Expand Up @@ -757,7 +732,8 @@ def can_handle(store, key):
return key in store.f

def __init__(self, store, key):
logger.debug("init")
super().__init__(store=store, key=key)
# logger.debug("init")
self._store = store
self._key = key
self._obj = store.f[key]
Expand Down Expand Up @@ -806,6 +782,7 @@ def can_handle(store, key):
return True

def __init__(self, store, key):
super().__init__(store=store, key=key)
logger.debug("init")
self._store = store
self._key = key
Expand Down
5 changes: 3 additions & 2 deletions hdf_compass/compass_model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def valid(self):
def __init__(self, url):
""" Open the resource.
"""
raise NotImplementedError
pass

def close(self):
""" Discontinue access to the resource.
Expand Down Expand Up @@ -260,12 +260,13 @@ def can_handle(store, key):
"""
raise NotImplementedError

@abstractmethod
def __init__(self, store, key):
""" Create an instance of this class.
Subclasses must not modify the signature.
"""
raise NotImplementedError
pass

@property
def key(self):
Expand Down
6 changes: 3 additions & 3 deletions hdf_compass/compass_viewer/array/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def get_selected_data(self):
else:
# The data is compound
if self.node.dtype.names is not None:
names = [self.grid.GetColLabelValue(x) for x in xrange(self.grid.GetNumberCols())]
names = [self.grid.GetColLabelValue(x) for x in range(self.grid.GetNumberCols())]
data = [data[n] for n in names]
return data, names, True

Expand Down Expand Up @@ -308,7 +308,7 @@ def indices(self):
"""
l = []
for x in xrange(len(self.node.shape)):
for x in range(len(self.node.shape)):
if x == self.row or x == self.col:
continue
l.append(x)
Expand Down Expand Up @@ -389,7 +389,7 @@ def __init__(self, parent, shape, hasfields):
infotext = wx.StaticText(self, wx.ID_ANY, "Array Indexing: ")
sizer.Add(infotext, 0, flag=wx.EXPAND | wx.ALL, border=10)

for idx in xrange(rank - visible_rank):
for idx in range(rank - visible_rank):
maxVal = shape[idx] - 1
if not hasfields:
maxVal = shape[self.parent.indices[idx]] - 1
Expand Down
2 changes: 1 addition & 1 deletion hdf_compass/compass_viewer/container/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def __init__(self, parent, node):
self.il = wx.GetApp().imagelists[64]
self.SetImageList(self.il, wx.IMAGE_LIST_NORMAL)

for item in xrange(len(self.node)):
for item in range(len(self.node)):
subnode = self.node[item]
image_index = self.il.get_index(type(subnode))
self.InsertImageStringItem(item, subnode.display_name, image_index)
Expand Down
5 changes: 3 additions & 2 deletions hdf_compass/compass_viewer/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,15 @@ def on_plugin_info(self, evt):

def on_about(self, evt):
""" Display an "About" dialog """
info = wx.adv.AboutDialogInfo()
from wx import adv
info = adv.AboutDialogInfo()
info.Name = "HDF Compass"
info.Version = __version__
info.Copyright = "(c) 2014-%d The HDF Group" % date.today().year
icon_48 = wx.Icon()
icon_48.CopyFromBitmap(wx.Bitmap(os.path.join(self.icon_folder, "favicon_48.png"), wx.BITMAP_TYPE_ANY))
info.SetIcon(icon_48)
wx.adv.AboutBox(info)
adv.AboutBox(info)

def on_file_open(self, evt):
""" Request to open a file via the Open entry in the File menu """
Expand Down
4 changes: 2 additions & 2 deletions hdf_compass/compass_viewer/geo_array/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def on_plot(self, evt):

# The data is compound
if self.node.dtype.names is not None:
names = [self.grid.GetColLabelValue(x) for x in xrange(self.grid.GetNumberCols())]
names = [self.grid.GetColLabelValue(x) for x in range(self.grid.GetNumberCols())]
data = [data[n] for n in names]
f = LinePlotFrame(data, names)
f.Show()
Expand Down Expand Up @@ -213,7 +213,7 @@ def __init__(self, parent, shape, hasfields):
infotext = wx.StaticText(self, wx.ID_ANY, "Array Indexing: ")
sizer.Add(infotext, 0, flag=wx.EXPAND | wx.ALL, border=10)

for idx in xrange(rank - visible_rank):
for idx in range(rank - visible_rank):
sc = wx.SpinCtrl(self, max=shape[idx] - 1, value="0", min=0)
sizer.Add(sc, 0, flag=wx.EXPAND | wx.ALL, border=10)
sc.Disable()
Expand Down
4 changes: 2 additions & 2 deletions hdf_compass/compass_viewer/geo_surface/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def on_plot(self, evt):

# The data is compound
if self.node.dtype.names is not None:
names = [self.grid.GetColLabelValue(x) for x in xrange(self.grid.GetNumberCols())]
names = [self.grid.GetColLabelValue(x) for x in range(self.grid.GetNumberCols())]
data = [data[n] for n in names]
f = LinePlotFrame(data, names)
f.Show()
Expand Down Expand Up @@ -214,7 +214,7 @@ def __init__(self, parent, shape, hasfields):
infotext = wx.StaticText(self, wx.ID_ANY, "Array Indexing: ")
sizer.Add(infotext, 0, flag=wx.EXPAND | wx.ALL, border=10)

for idx in xrange(rank - visible_rank):
for idx in range(rank - visible_rank):
sc = wx.SpinCtrl(self, max=shape[idx] - 1, value="0", min=0)
sizer.Add(sc, 0, flag=wx.EXPAND | wx.ALL, border=10)
sc.Disable()
Expand Down
2 changes: 1 addition & 1 deletion hdf_compass/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
from hdf_compass.utils.utils import is_darwin, is_win, is_linux, url2path, path2url, data_url


__version__ = "0.7.b4"
__version__ = "0.7.b5"
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.b3
current_version = 0.7.b5
files = setup.py hdf_compass/utils/__init__.py docs/conf.py HDFCompass.1file.spec

[bdist_wheel]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def txt_read(*paths):

setup_args['name'] = 'hdf_compass'
# The adopted versioning scheme follow PEP40
setup_args['version'] = '0.7.b3'
setup_args['version'] = '0.7.b5'
setup_args['url'] = 'https://github.com/HDFGroup/hdf-compass/'
setup_args['license'] = 'BSD-like license'
setup_args['author'] = 'HDFGroup'
Expand Down

0 comments on commit c38ed45

Please sign in to comment.