Skip to content

Commit

Permalink
tutorial for unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
wbierbower committed Aug 19, 2015
1 parent 324e751 commit 8114306
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ Fauxgeo API

.. include:: ../../README.rst

Other Useful Info
=================

.. toctree::
:maxdepth: 1

tutorial.rst
history.rst

Indices and tables
==================

Expand Down
38 changes: 38 additions & 0 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Unit-Tests with Fauxgeo
=======================

.. code::
import unittest
from fauxgeo import RasterFactory, Raster
import pygeoprocessing as pygeo
class TestIO(unittest.TestCase):
def setUp(self):
# arguments for raster factory
pixel_size = 0.083333
size = 180/pixel_size
shape = (size, size*2)
affine = Affine(pixel_size, 0, -180, 0, -pixel_size, 90)
proj = 4326
datatype = gdal.GDT_Int32
nodata_val = NODATA_INT
# create raster factory
self.global_int_factory = RasterFactory(
proj, datatype, nodata_val, shape[0], shape[1], affine=affine)
def test(self):
# create test data
global_raster = global_int_factory.uniform(5)
# arguments for vectorize_datasets
dataset_uri_list = [global_raster.uri]
dataset_out_uri = pygeo.geoprocessing.temporary_filename()
# ... other inputs ...
pygeo.geoprocessing.vectorize_datasets(...)
# validate that output matches expected value
r = Raster.from_file(dataset_out_uri)
assert(r[0, 0] == 5)

0 comments on commit 8114306

Please sign in to comment.