Skip to content

Commit

Permalink
updated changelog & docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
ungarj committed Oct 19, 2017
1 parent 1d66b12 commit 54b4c6a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -2,6 +2,19 @@
Changelog
#########

----
0.10
----
* better memory handling by detatching process output data from ``BufferedTile`` objects
* breaking API changes:
* Mapchete.execute() returns raw data instead of tile with data attribute
* Mapchete.read() returns raw data instead of tile with data attribute
* Mapchete.get_raw_output() returns raw data instead of tile with data attribute
* Mapchete.write() requires process_tile and data as arguments
* same valid for all other read() and write() functions in drivers & MapcheteProcess object
* new MapcheteNodataTile exception to indicate an empty process output


---
0.9
---
Expand Down
35 changes: 15 additions & 20 deletions mapchete/__init__.py
Expand Up @@ -200,10 +200,8 @@ def execute(self, process_tile):
Returns
-------
BufferedTile
Process output is stored in the ``data`` attribute. If
there is no process output, data is ``None`` and there is
information on the process status in the message attribute.
data : NumPy array or features
process output
"""
if self.config.mode not in ["memory", "continue", "overwrite"]:
raise ValueError(
Expand All @@ -230,8 +228,8 @@ def read(self, output_tile):
Returns
-------
BufferedTile
Tile with appended data.
data : NumPy array or features
process output
"""
if self.config.mode not in ["readonly", "continue", "overwrite"]:
raise ValueError(
Expand Down Expand Up @@ -423,19 +421,17 @@ def _execute(self, process_tile):
# interpolate from other zoom levels.
if self.config.baselevels:
if process_tile.zoom < min(self.config.baselevels["zooms"]):
process_data = self._interpolate_from_baselevel(
process_tile,
"lower"
return self._streamline_output(
self._interpolate_from_baselevel(
process_tile, "lower"
)
)
# Analyze proess output.
return self._streamline_output(process_data)
elif process_tile.zoom > max(self.config.baselevels["zooms"]):
process_data = self._interpolate_from_baselevel(
process_tile,
"higher"
return self._streamline_output(
self._interpolate_from_baselevel(
process_tile, "higher"
)
)
# Analyze proess output.
return self._streamline_output(process_data)
# Otherwise, load process source and execute.
try:
user_process_py = imp.load_source(
Expand Down Expand Up @@ -497,7 +493,6 @@ def _execute(self, process_tile):

def _streamline_output(self, process_data):
if isinstance(process_data, str) and process_data == "empty":
# TODO find better solution to handle nodata tiles
raise MapcheteNodataTile
elif isinstance(process_data, (np.ndarray, ma.MaskedArray)):
return process_data
Expand Down Expand Up @@ -555,9 +550,9 @@ def __enter__(self):
def __exit__(self, t, v, tb):
"""Clear cache on close."""
if self.with_cache:
del self.process_tile_cache
del self.current_processes
del self.process_lock
self.process_tile_cache = None
self.current_processes = None
self.process_lock = None


class MapcheteProcess(object):
Expand Down

0 comments on commit 54b4c6a

Please sign in to comment.