Skip to content

Commit

Permalink
further towards #340 (and removed a print statement from the neighbou…
Browse files Browse the repository at this point in the history
…rhood analysis code that was previously used in debugging)
  • Loading branch information
carlhiggs committed Jul 4, 2023
1 parent b7dbfc0 commit fb21bce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion process/subprocesses/_02_create_osm_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create_poly_boundary_file(config):
db_pwd = config['db_pwd']
feature = f"""PG:"dbname={db} host={db_host} port={db_port} user={db_user} password={db_pwd}" {config['buffered_urban_study_region']}"""
print('Create poly file, using command: '),
command = f'python ogr2poly.py {feature} -f "db"'
command = f'python /home/ghsci/process/subprocesses/ogr2poly.py {feature} -f "db"'
print(command)
sp.call(command, shell=True)
command = f'mv {os.path.basename(config["codename_poly"])} {config["codename_poly"]}'
Expand Down
1 change: 0 additions & 1 deletion process/subprocesses/_11_neighbourhood_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ def calculate_sample_point_indicators(
/ sample_points[columns].std()
).sum(axis=1)
# grid_id and edge_ogc_fid are integers
print(sample_points.query('grid_id.isna()'))
sample_points[sample_points.columns[0:2]] = sample_points[
sample_points.columns[0:2]
].astype(int)
Expand Down
29 changes: 7 additions & 22 deletions process/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@
class tests(unittest.TestCase):
"""A collection of tests to help ensure functionality."""

def test_global_indicators_shell(self):
def test_1_global_indicators_shell(self):
"""Unix shell script should only have unix-style line endings."""
counts = calculate_line_endings('../global-indicators.sh')
lf = counts.pop(b'\n')
self.assertTrue(sum(counts.values()) == 0 and lf > 0)

def test_project_setup(self):
def test_2_project_setup(self):
"""Check if _project_setup.py imported successfully."""
self.assertTrue(project_setup)

def test_load_example_region(self):
def test_3_load_example_region(self):
"""Load example region."""
codename = 'example_ES_Las_Palmas_2023'
r = ghsci.Region(codename)

def test_example_analysis(self):
def test_4_example_analysis(self):
"""Analyse example region."""
codename = 'example_ES_Las_Palmas_2023'
r = ghsci.Region(codename)
Expand All @@ -68,13 +68,13 @@ def test_example_analysis(self):
r._neighbourhood_analysis()
r._area_analysis()

def test_example_generate(self):
def test_5_example_generate(self):
"""Generate resources for example region."""
codename = 'example_ES_Las_Palmas_2023'
r = ghsci.Region(codename)
r.generate()

def test_sensitivity(self):
def test_6_sensitivity(self):
"""Test sensitivity analysis of urban intersection parameter."""
reference = 'example_ES_Las_Palmas_2023'
comparison = 'ES_Las_Palmas_2023_test_not_urbanx'
Expand Down Expand Up @@ -117,20 +117,5 @@ def calculate_line_endings(path):
return counts


def suite():
suite = unittest.TestSuite()
for t in [
'test_global_indicators_shell',
'test_project_setup',
'test_load_example_region',
'test_example_analysis',
'test_example_generate',
'test_sensitivity',
]:
suite.addTest(tests(t))
return suite


if __name__ == '__main__':
runner = unittest.TextTestRunner()
runner.run(suite())
unittest.main()

0 comments on commit fb21bce

Please sign in to comment.