Skip to content

Commit

Permalink
modified factory methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Bierbower authored and Will Bierbower committed Mar 16, 2015
1 parent 758481d commit 2618f95
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ The RasterFactory Class
factory = RasterFactory(proj, datatype, nodata_val, shape[0], shape[1], affine=affine)
# create test rasters
test_raster_1 = factory.filled_value(5) # returns raster with 1 band filled with 5's
test_raster_2 = factory.filled_alternating_values(0, 1)
test_raster_3 = factory.filled_random()
test_raster_3 = factory.filled_ramp_across_cols(1, 10) # interpolated from 1 to 10 across columns
test_raster_1 = factory.uniform(5) # returns raster with 1 band filled with 5's
test_raster_2 = factory.alternating(0, 1)
test_raster_3 = factory.random()
test_raster_3 = factory.horizontal_ramp(1, 10) # interpolated from 1 to 10 across columns
Tests
-----
Expand Down
10 changes: 5 additions & 5 deletions fauxgeo/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,27 +292,27 @@ def _create_raster(self, array, uri):
r.init(array, self.affine, self.proj, self.datatype, self.nodata_val)
return r

def filled_value(self, val, uri=None):
def uniform(self, val, uri=None):
a = np.ones((self.rows, self.cols)) * val
return self._create_raster(a, uri)

def filled_alternating_values(self, val1, val2, uri=None):
def alternating(self, val1, val2, uri=None):
a = np.ones((self.rows, self.cols)) * val2
a[::2, ::2] = val1
a[1::2, 1::2] = val1
return self._create_raster(a, uri)

def filled_random(self, uri=None):
def random(self, uri=None):
a = np.random.rand(self.rows, self.cols)
return self._create_raster(a, uri)

def filled_ramp_across_cols(self, val1, val2, uri=None):
def horizontal_ramp(self, val1, val2, uri=None):
a = np.zeros((self.rows, self.cols))
col_vals = np.linspace(val1, val2, self.cols)
a[:] = col_vals
return self._create_raster(a, uri)

def filled_ramp_across_rows(self, val1, val2, uri=None):
def vertical_ramp(self, val1, val2, uri=None):
a = np.zeros((self.cols, self.rows))
row_vals = np.linspace(val1, val2, self.rows)
a[:] = row_vals
Expand Down
4 changes: 2 additions & 2 deletions tests/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ def setUp(self):
affine=self.affine)

def test_raster_creation(self):
r = self.Factory.filled_ramp_across_rows(10, 6)
r = self.Factory.horizontal_ramp(10, 6)
assert(r.get_band(1)[0, 0] == 10)

def test_raster_deletion(self):
r = self.Factory.filled_value(5)
r = self.Factory.uniform(5)
uri = r.uri
assert(os.path.exists(uri))
del r
Expand Down

0 comments on commit 2618f95

Please sign in to comment.