[hdf-compass] 17/295: fixed initialization of data to None. dtype function now returns float, without needing to pass it an existing array. nrows and ncols are now called in the constructor, rather than the shape function.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun May 8 10:35:20 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository hdf-compass.

commit f0a4325dd35883da68858feebc5f11092632229e
Author: Matt Comerford <matthew.comerford at colorado.edu>
Date:   Tue Jul 8 09:31:40 2014 -0600

    fixed initialization of data to None. dtype function now returns float, without needing to pass it an existing array. nrows and ncols are now called in the constructor, rather than the shape function.
---
 asc_model/__init__.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/asc_model/__init__.py b/asc_model/__init__.py
index bf6404e..2cb0b79 100644
--- a/asc_model/__init__.py
+++ b/asc_model/__init__.py
@@ -21,7 +21,7 @@ class Filesystem(compass_model.Store):
 	"""
 
 	def __contains__(self, key):
-		return op.exists(key)
+	    return op.exists(key)
 
 	@property
 	def url(self):
@@ -127,7 +127,9 @@ class ASCFile(compass_model.Array):
 	def __init__(self, store, key):
 		self._store = store
 		self._key = key
-		self._data = np.arange(0, dtype=float)
+		self._nrows = int(linecache.getline(self._key, 1).lstrip("ncols"))
+		self._ncols = int(linecache.getline(self._key, 2).lstrip("nrows"))
+		self._data = None
 
 	@property
 	def key(self):
@@ -147,17 +149,15 @@ class ASCFile(compass_model.Array):
 
 	@property
 	def shape(self):
-		nrows = int(linecache.getline(self._key, 1).lstrip("ncols"))
-		ncols = int(linecache.getline(self._key, 2).lstrip("nrows"))
-		return (nrows, ncols)
+		return (self._nrows, self._ncols)
 
 	@property
 	def dtype(self):
-		return self._data.dtype
+		return np.dtype('float')
 
 	def __getitem__(self, args):
-		if self._data.size is 0:
-			self._data = np.loadtxt(self._key, skiprows=6, unpack=True, dtype=float)
+		if self._data is None:
+		    self._data = np.loadtxt(self._key, skiprows=6, unpack=True)
 		return self._data[args]
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/hdf-compass.git



More information about the debian-science-commits mailing list