Skip to content

Commit

Permalink
Updated raster example and added test cases for utility functions inc…
Browse files Browse the repository at this point in the history
…luding loading raster data.
  • Loading branch information
makyol committed Aug 10, 2024
1 parent dd9603b commit 1091c62
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 0 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ If you want to display the input raster data, the following code snippet demonst
# Output:
# Display the raster image in a matplotlib plot.
Adjust the size of the image

.. image:: raster_new.png
:alt: An example raster image
:align: center
Expand Down
2 changes: 1 addition & 1 deletion landusemix/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def load_sample_shapefile():
Returns:
geopandas.GeoDataFrame: The loaded sample GeoDataFrame.
"""
sample_path = os.path.join(os.path.dirname(__file__), 'data', 'shapefiles', 'multiple', 'multiple.shp')
sample_path = os.path.join(os.path.dirname(__file__), 'data', 'shapefiles', 'multiple.shp')
return load_shapefile(sample_path)


Expand Down
13 changes: 13 additions & 0 deletions tests/test_landusemix.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
from landusemix import LandUseMixIndices
import math
from landusemix.utils import *


class TestLandUseMixIndices(unittest.TestCase):
Expand Down Expand Up @@ -69,6 +70,18 @@ def test_herfindahl_hirschman_index_equal_area(self):
self.assertAlmostEqual(
indices.herfindahl_hirschman_index(), round(expected, 2))

# Test Cases for loading data via utility functions
def test_load_sample_geojson(self):
self.assertIsNotNone(load_sample_geojson())

def test_load_sample_shapefile(self):
self.assertIsNotNone(load_sample_shapefile())

def test_load_sample_csv(self):
self.assertIsNotNone(load_sample_csv())

def test_load_sample_raster(self):
self.assertIsNotNone(load_sample_raster())

if __name__ == "__main__":
unittest.main()

0 comments on commit 1091c62

Please sign in to comment.