Skip to content

Commit

Permalink
adding tests for polygons and data_io
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushpatnaikgit committed Jul 23, 2021
1 parent 700fbf6 commit 08ce1da
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
12 changes: 12 additions & 0 deletions test/data_io.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

@test "testing input output functions" begin
package_path = pathof(NighttimeLights)
path_len = length(package_path)
assets_path = package_path[1:path_len-22] * "assets"
map_path = assets_path * "/mumbai_map/mumbai_districts.shp"
radiance_jld_path = assets_path * "/mumbai_ntl/datacube/mumbai_radiance.jld"
radiance_img_path = assets_path * "/mumbai_ntl/img/april2012.tif"
@test length(size(load_datacube(radiance_jld_path))) == 3
@test length(size(load_img(radiance_img_path))) == 2
@test sizeof(load_shapefile(map_path)) > 0
end
17 changes: 17 additions & 0 deletions test/polygons.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@testset "Testing functions on polygons and shapefiles" begin
package_path = pathof(NighttimeLights)
path_len = length(package_path)
assets_path = package_path[1:path_len-22] * "assets"
map_path = assets_path * "/mumbai_map/mumbai_districts.shp"

radiance_datacube = rand(1:100, 156, 85, 95)
mumbai_districts = load_shapefile(map_path)
mumbai_districts_ntl = aggregate_dataframe(MUMBAI_COORDINATE_SYSTEM, radiance_datacube, mumbai_districts, "DISTRICT")
@test sizeof(mumbai_districts_ntl) > 0

district1 = mumbai_dists[1,:] # Select the first district
district1_mask = polygon_mask(my_coordinate_system, district1)

@test sum(district1_mask) >=0

end
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fatalerrors = length(ARGS) > 0 && ARGS[1] == "-f"
quiet = length(ARGS) > 0 && ARGS[1] == "-q"
anyerrors = false

my_tests = ["aggregate.jl", "sparse_cube.jl", "data_cleaning/bias_correction.jl", "data_cleaning/interpolation.jl", "data_cleaning/outlier_removal.jl", "data_cleaning/background_noise_removal.jl", "other/nan_functions.jl", "other/rank_correlation.jl", "other/weighted_mean.jl", "other/detrend.jl"]
my_tests = ["aggregate.jl", "sparse_cube.jl", "polygons.jl", "data_io.jl", "data_cleaning/bias_correction.jl", "data_cleaning/interpolation.jl", "data_cleaning/outlier_removal.jl", "data_cleaning/background_noise_removal.jl", "other/nan_functions.jl", "other/rank_correlation.jl", "other/weighted_mean.jl", "other/detrend.jl"]

println("Running tests:")

Expand Down

0 comments on commit 08ce1da

Please sign in to comment.