Skip to content

Commit e62f5fe

Browse files
committed
Fix setup.py dependency, fix rf_rasterize signature regression in unit test
Signed-off-by: Jason T. Brown <jason@astraea.earth>
1 parent e69c5df commit e62f5fe

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

pyrasterframes/src/main/python/setup.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ def _divided(msg):
4747
return divider + '\n' + msg + '\n' + divider
4848

4949

50-
from pweave import PwebPandocFormatter
51-
52-
class PegdownMarkdownFormatter(PwebPandocFormatter):
53-
def __init__(self, *args, **kwargs):
54-
super().__init__(*args, **kwargs)
55-
56-
# Pegdown doesn't support the width and label options.
57-
def make_figure_string(self, figname, width, label, caption=""):
58-
return "![%s](%s)" % (caption, figname)
59-
6050
class PweaveDocs(distutils.cmd.Command):
6151
"""A custom command to run documentation scripts through pweave."""
6252
description = 'Pweave PyRasterFrames documentation scripts'
@@ -67,6 +57,16 @@ class PweaveDocs(distutils.cmd.Command):
6757
('quick=', 'q', 'Check to see if the source file is newer than existing output before building. Defaults to `False`.')
6858
]
6959

60+
from pweave import PwebPandocFormatter
61+
62+
class PegdownMarkdownFormatter(PwebPandocFormatter):
63+
def __init__(self, *args, **kwargs):
64+
super().__init__(*args, **kwargs)
65+
66+
# Pegdown doesn't support the width and label options.
67+
def make_figure_string(self, figname, width, label, caption=""):
68+
return "![%s](%s)" % (caption, figname)
69+
7070
def initialize_options(self):
7171
"""Set default values for options."""
7272
# Each user option must be listed here with their default value.

pyrasterframes/src/main/python/tests/VectorTypesTests.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def some_point(g):
9797
pandas_df_out.poly_len.values
9898
)
9999

100-
def test_rasterize(self):
100+
def test_geometry_udf(self):
101101
from geomesa_pyspark.types import PolygonUDT
102102
# simple test that raster contents are not invalid
103103

@@ -117,12 +117,25 @@ def area(g):
117117
area_result = area.collect()
118118
self.assertTrue(all([r[0] for r in area_result]))
119119

120-
cols = 194
121-
rows = 250
122-
with_raster = with_poly.withColumn('rasterized', rf_rasterize('poly', 'geometry', lit(16), cols, rows))
123-
# expect a 4 by 4 cell
120+
def test_rasterize(self):
121+
from geomesa_pyspark.types import PolygonUDT
122+
123+
@udf(PolygonUDT())
124+
def buffer(g, d):
125+
return g.buffer(d)
126+
127+
# start with known polygon, the tile extents, **negative buffered** by 10 cells
128+
buf_cells = 10
129+
with_poly = self.rf.withColumn('poly', buffer(self.rf.geometry, lit(-15 * buf_cells))) # cell res is 15x15
130+
131+
# rasterize value 16 into buffer shape.
132+
cols = 194 # from dims of tile
133+
rows = 250 # from dims of tile
134+
with_raster = with_poly.withColumn('rasterized',
135+
rf_rasterize('poly', 'geometry', lit(16), lit(cols), lit(rows)))
124136
result = with_raster.select(rf_tile_sum(rf_local_equal_int(with_raster.rasterized, 16)),
125137
rf_tile_sum(with_raster.rasterized))
138+
#
126139
expected_burned_in_cells = (cols - 2 * buf_cells) * (rows - 2 * buf_cells)
127140
self.assertEqual(result.first()[0], float(expected_burned_in_cells))
128141
self.assertEqual(result.first()[1], 16. * expected_burned_in_cells)

0 commit comments

Comments
 (0)