def test_nothing_is_correct(): norec, nomean = get_sightings(filename, 'NotPresent') assert norec == 0, 'Biosignature missing should return zero records' assert nomean == 0, 'Biosignature missing should return zero mean'
def test_animal_not_present(): animrec, animmean = get_sightings(filename, 'NotPresent') assert animrec == 0, 'Animal missing should return zero records' assert animmean == 0, 'Animal missing should return zero mean'
def test_owl_is_correct(): owlrec, owlmean = get_sightings(filename, 'Owl') # assert test_statement message_if_test_is_false assert owlrec == 2, 'Number of records for owl is wrong' assert owlmean == 17#, 'Mean sightings for owl is wrong'
def test_arg_capitalization_wrong(): owlrec, owlmean = get_sightings(filename, 'oWl') assert owlrec == 2, 'Number of records for owl is wrong' assert owlmean == 17, 'Mean sightings for owl is wrong'
def test_pig_is_correct(): pigrec, pigmean = get_sightings(filename, 'Pig') assert pigrec == 1, 'Number of records for Pig is wrong' assert pigmean == 4, 'Mean sightings for Pig is wrong'
def test_water_is_correct(): watrec, watmean = get_sightings(filename,'water') assert watrec==2, 'Number of records for water is wrong' assert watmean==17, 'Mean for water is wrong'
def test_owl_is_correct(): owlrec, owlmean = get_sightings(filename, 'Owl') assert owlrec == 2, 'Number of records for owl is wrong' assert owlmean == 17, 'Mean sightings for owl is wrong'
def test_bay_is_correct(): bayrec, baymean = get_sightings(filename, 'Nazan Bay') assert bayrec == 2, 'Number of records for Nazan Bay is wrong' assert baymean == 17, 'Mean Tidal wave sightings for owl is wrong'
def test_fireisland_is_correct(): oxrec, oxmean = get_sightings(filename, 'Fire Island') assert oxrec == 2, 'Number of records for Fire Island is wrong' assert oxmean == 25.5, 'Mean Tidal wave sightings for Fire Island is wrong'
def test_clay_is_corrrect(): clayrec,claymean = get_sightings(filename,"Clay") assert clayrec==2, "number of records for clay is wrong" assert claymean==25.5, "clay mean is wrong"
figFILE = os.path.join(outDIR,'spp_fig.png') # Set names of species to count spp_names = ['Fox', 'Wolf', 'Grizzly', 'Wolverine'] # ------------------------------------------------------------------------ # Perform analysis # ------------------------------------------------------------------------ # Declare empty list to hold counts of records spp_recs = [] # Get total number of records for each species for spp in spp_names: totalrecs, meancount = get_sightings(dataFILE, spp) spp_recs.append(totalrecs) print('spp_names') print( spp_names ) print('spp_recs') print( spp_recs ) print('[spp_names, spp_recs]') print( [spp_names, spp_recs] ) print('np.transpose([spp_names, spp_recs])') print( np.transpose([spp_names, spp_recs]) ) # ------------------------------------------------------------------------
def test_water_is_corrrect(): watrec,watmean = get_sightings(filename,"Water") assert watrec==2, "number of records for water is wrong" assert watmean==17, "water mean is wrong"
def test_not_present(): norec,nomean = get_sightings(filename, "not present") assert norec==0, "Biosig not present" assert nomean ==0, "mean is not present"
def test_not_present(): norec, nomean = get_sightings(filename, 'Not Present') assert norec == 0, 'Biosigniture not present' assert nomean==0, 'Mean is not present'
def test_anonymouse_is_correct(): anirec, animean = get_sightings(filename, 'NotPresent') assert anirec == 0, 'Number of anonymous records is wrong' assert animean == 0 , 'Mean for anonymous animal rec is wrong'
def test_station_not_present(): statrec, statmean = get_sightings(filename, 'NotPresent') print statrec, statmmean assert statrec == 0, 'Station`s data missing should return zero records' assert statmean == 0, 'Station`s data missing should return zero mean'
def test_Mouse_is_correct(): mouserec, mousemean = get_sightings(filename, 'Mouse') assert mouserec == 12, 'Mouse number wrong' assert mousemean == 1, 'Mouse mean wrong'
def test_arg_capitalization_wrong(): bayrec, baymean = get_sightings(filename, 'Nazan bAy') assert bayrec == 2, 'Number of records for Nazan Bay is wrong' assert baymean == 17, 'Mean Tidal wave sightings for Nazan Bay is wrong'
# --- data_path = '../data/' results_path = '../results/' data_name = 'sightings_tab_lg.csv' table_name = 'spp_table.csv' fig_name = 'spp_fig.png' spp_names = ['Fox', 'Wolf', 'Wolverine'] # Generate reesutls spp_recs = [] for spp in spp_names: n_records, mu_sightings = ms.get_sightings(data_path + data_name, spp) spp_recs.append(n_records) print spp_names print spp_recs # Save table table = pd.DataFrame({'species': spp_names, 'recs': spp_recs}) table.to_csv(results_path + table_name, index=False) # Save figure fig, ax = plt.subplots(1,1) ax.bar([0,1,2], spp_recs) ax.set_xticklabels(spp_names) fig.savefig(results_path + fig_name)
fig_name = 'spp_fig.png' # Set names of species to count spp_names = ['Fox', 'Wolf', 'Grizzly', 'Wolverine'] # ------------------------------------------------------------------------ # Perform analysis # ------------------------------------------------------------------------ # Declare empty list to hold counts of records spp_recs = [] # Get total number of records for each species for spp in spp_names: totalrecs, meancount = get_sightings(data_dir + data_name, spp) spp_recs.append(totalrecs) print spp_names print spp_recs # ------------------------------------------------------------------------ # Save results as table # ------------------------------------------------------------------------ # Put two lists into a pandas DataFrame table = pd.DataFrame(np.array(zip(spp_names, spp_recs), dtype=[('species', 'S12'), ('recs', int)])) # Save DataFrame as csv table.to_csv(results_dir + table_name, index=False)
def test_muskox_is_correct(): oxrec, oxmean = get_sightings(filename, 'Muskox') assert oxrec == 2, 'Number of records for muskox is wrong' assert oxmean == 25.5, 'Mean sightings for muskox is wrong'
def test_Muskox_is_correct(): muskrec, muskmean = get_sightings(filename, 'Muskox') assert muskrec == 2, 'Number of records for Muskox is wrong' assert muskmean == 25.5, 'Mean sightings for Muskox is wrong'
def test_lion_is_correct(): lionrec, lionmean = get_sightings(filename, 'Lion') assert lionrec == 2, 'Number of records for Lion is wrong' assert lionmean == 25.5, 'Mean sightings for Lion is wrong'
def test_not_present(): norec,nomean = get_sightings(file,'Not present') assert norec == 0, 'Biosignature not present, has zero recs.' assert nomean == 0, 'Mean is not present for missing Biosig.'
def test_cow_is_correct(): cowrec, cowmean = get_sightings(filename, 'Cow') assert cowrec == 2, 'Number of records for Cow is wrong' assert cowmean == 17, 'Mean sightings for Cow is wrong'
def test_water(): watrec,watmean = get_sightings(file,'Water') assert watrec == 2, 'Number of records for water is wrong.' assert watmean == 17, 'Mean for water is wrong'
def test_animal_case(): animrec, animmean = get_sightings(filename, 'oWL') assert animrec == 2 assert animmean == 17
def test_Clay(): clayrec,claymean = get_sightings(file,'Clay') assert clayrec == 2, 'Number of records for clay is wrong.' assert claymean == 25.5, 'Mean for clay is wrong'
def test_muskox_is_correct(): muskoxrec, muskoxmean = get_sightings(filename, 'Muskox') # assert test_statement message_if_test_is_false assert muskoxrec == 2, 'Number of records for muskox is wrong' assert muskoxmean == 25.5#, 'Mean sightings for muskox is wrong'
def test_not_present(): notrec, notmean = get_sightings(filename,'Not present') assert notrec==0, "Number of records for Not present is null" assert notmean==0, 'Mean for Not present is null'
def test_pig_is_correct(): pigrec, pigmean = get_sightings(filename, 'Pig') #See mean_sightings for explaination of how this works assert pigrec == 1, 'Number of records for Pig is wrong' assert pigmean == 4, 'Mean sightings for pig is wrong'
def test_animal_not_present(): animrec, animmean = get_sightings(filename, 'NotPresent') print animrec, animmean assert animrec == 0, 'Animal missing should return zero records' assert animmean == 0, 'Animal missing should return zero mean'
def test_not_presemt(): norec, nomean = get_sightings(filename, 'Not Present') assert norec==0, 'Biosignature not present has zero recs' assert nomean==0, 'Mean is not present for missing biosig'
def test_clay_is_correct(): clayrec, claymean = get_sightings(filename,'Clay') assert clayrec==2, 'Number of records for clay is wrong' assert claymean==25.5, 'Mean for clay is wrong'
fig_name = 'spp_fig.png' # Set names of species to count spp_names = ['Fox', 'Wolf', 'Grizzly', 'Wolverine'] # --------------------------------------------------------------------------- # Perform analysis # --------------------------------------------------------------------------- # Declare empty list to hold counts of records spp_recs = [] # Get total number of records for each species for spp in spp_names: totalrecs, meancount = get_sightings(data_dir + data_name, spp) spp_recs.append(totalrecs) print spp_names print spp_recs # --------------------------------------------------------------------------- # Save results as table # --------------------------------------------------------------------------- # Put two lists into a recarray table table = np.array(zip(spp_names, spp_recs), dtype=[('species', 'S12'), ('recs', int)]) # Save recarray as csv ml.rec2csv(table, results_dir + table_name)