Skip to content

Commit

Permalink
Added ability to recognize long and lon for longitude, and a test for…
Browse files Browse the repository at this point in the history
… the long change.
  • Loading branch information
egrace479 committed Aug 31, 2023
1 parent c14bd04 commit 280b916
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ def parse_contents(contents, filename):
for feature in features:
if feature not in list(df.columns):
if feature == 'lat' or feature == 'lon':
mapping = False
if feature == 'lon':
if 'long' not in list(df.columns):
mapping = False
else:
df = df.rename(columns = {"long": "lon"})
included_features.append('lon')
else:
mapping = False
elif feature == 'file_url':
img_urls = False
elif feature == 'Image_filename':
Expand Down
11 changes: 11 additions & 0 deletions test_data/HCGSD_test_latLong.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NHM_Specimen,Image_filename,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,in_reduced,locality,lat,long,speciesdesig,file_url
10429021,10429021_V_lowres.png,,erato,notabilis,,f._notabilis,,subspecies synonym,1,,-1.583333333,-77.75,e. notabilis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/
10428972,10428972_V_lowres.png,ventral,erato,petiverana,male,petiverana,,valid subspecies,1,Songolica (= Zongolica) MEX VC,18.66666667,-96.98333333,e. petiverana,
10429172,,ventral,,petiverana,male,petiverana,,valid subspecies,1,San Ramon NIC ZE,89,-84.68333333,e. petiverana,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/
10428595,10428595_D_lowres.png,dorsal,erato,phyllis,male,f._phyllis,,subspecies synonym,1,Resistencia ARG CH,-27.45,-58.98333333,e. phyllis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/
10428140,10428140_V_lowres.png,ventral,,plesseni,male,plesseni,,valid subspecies,1,Banos ECD TU,-1.4,-74,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/
10428250,10428250_V_lowres.png,ventral,melpomene,,male,ab._rubra,,subspecies synonym,1,Caradoc (Hda) PER CU,-13.36666667,-70.95,m. schunkei,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/
10427979,,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,-83.63333333,m. rosina,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/
10428803,10428803_D_lowres.png,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,-74.36666667,e. guarica,
10428169,10428169_V_lowres.png,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,73,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/
10428321,10428321_D_lowres.png,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/
9 changes: 9 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ def generate_mock_upload(filepath):
"expected_mapping": True,
"expected_images": True
},
{ # Check with full columns expected, but 'long' instead of 'lon'
"filepath": "test_data/HCGSD_test_latLong.csv",
"filename": "HCGSD_test_latLong.csv",
"expected_columns": ['Species', 'Subspecies', 'View', 'Sex', 'hybrid_stat', 'lat', 'lon',
'file_url', 'Image_filename', 'locality', 'lat-lon',
'Samples_at_locality', 'Species_at_locality', 'Subspecies_at_locality'],
"expected_mapping": True,
"expected_images": True
},
]

def test_parse_contents():
Expand Down

0 comments on commit 280b916

Please sign in to comment.