Skip to content

Commit

Permalink
Add more complete diff to conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
brandynlucca committed Apr 10, 2024
1 parent b6ca6cb commit 5305b11
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
6 changes: 6 additions & 0 deletions echopop/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import pytest
from pathlib import Path
from echopop import Survey
from _pytest.assertion.util import assertrepr_compare

def pytest_assertrepr_compare( config , op , left , right ):
# hack the verbosity so we always show full diffs on assertion failures,
# even if we're otherwise not fully verbose
config.option.verbose = 2
return assertrepr_compare( config , op , left , right)

# Set up path to test_data folder
HERE = Path(__file__).parent.absolute()
Expand Down
16 changes: 11 additions & 5 deletions echopop/tests/test_data_transect_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,30 +569,36 @@ def test_nasc_to_biomass_conversion( mock_survey ):
#----------------------------------
# ---- Set evaluated dataframes from function
eval_number_density_df = objS.biology[ 'population' ][ 'areal_density' ][ 'number_density_df' ]
eval_number_density_df.reset_index( drop = True , inplace = True )
eval_biomass_density_df = objS.biology[ 'population' ][ 'areal_density' ][ 'biomass_density_df' ]
eval_biomass_density_df.reset_index( drop = True , inplace = True )
eval_abundance_df = objS.biology[ 'population' ][ 'abundance' ][ 'abundance_df' ]
eval_abundance_df.reset_index( drop = True , inplace = True )
eval_biomass_df = objS.biology[ 'population' ][ 'biomass' ][ 'biomass_df' ]
eval_biomass_df.reset_index( drop = True , inplace = True )
eval_biomass_age_df = objS.biology[ 'population' ][ 'biomass' ][ 'biomass_age_df' ]
eval_biomass_age_df.reset_index( drop = True , inplace = True )

# ---- Extract expected dataframes to appropriately set indices
expected_number_density_df = (
expected_output[ 'areal_density' ][ 'number_density' ]
.set_index( pd.Index( list( expected_output[ 'areal_density' ][ 'number_density' ].index ) ) )
# .set_index( pd.Index( list( expected_output[ 'areal_density' ][ 'number_density' ].index ) ) )
)
expected_biomass_density_df = (
expected_output[ 'areal_density' ][ 'biomass_density' ]
.set_index( pd.Index( list( expected_output[ 'areal_density' ][ 'biomass_density' ].index ) ) )
# .set_index( pd.Index( list( expected_output[ 'areal_density' ][ 'biomass_density' ].index ) ) )
)
expected_abundance_df = (
expected_output[ 'abundance' ][ 'abundance' ]
.set_index( pd.Index( list( expected_output[ 'abundance' ][ 'abundance' ].index ) ) )
# .set_index( pd.Index( list( expected_output[ 'abundance' ][ 'abundance' ].index ) ) )
)
expected_biomass_df = (
expected_output[ 'biomass' ][ 'biomass' ]
.set_index( pd.Index( list( expected_output[ 'biomass' ][ 'biomass' ].index ) ) )
# .set_index( pd.Index( list( expected_output[ 'biomass' ][ 'biomass' ].index ) ) )
)
expected_biomass_age_df = (
expected_output[ 'biomass' ][ 'biomass_age' ]
.set_index( pd.Index( list( expected_output[ 'biomass' ][ 'biomass_age' ].index ) ) )
# .set_index( pd.Index( list( expected_output[ 'biomass' ][ 'biomass_age' ].index ) ) )
)
### Check shape
assert eval_number_density_df.shape == expected_dimensions[ 'areal_density' ][ 'number_density' ]
Expand Down
2 changes: 1 addition & 1 deletion echopop/tests/test_transect_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_index_transect_age_sex_proportions( mock_survey ):
'NASC_all_ages': np.repeat( [ 1e1 , 1e2 , 1e2 , 1e3 ] , 2 ) ,
'NASC_no_age1': np.repeat( [ 0.0 , 1e1 , 1e2 , 1e3 ] , 2 ) ,
'fraction_hake': np.repeat( [ 1.0 , 0.5 ] , 4 ) ,
'species_id': np.repeat( 8675309 , 8 ).astype( np.int64 ) ,
'species_id': np.repeat( 8675309 , 8 ).astype( np.int32 ) ,
'sigma_bs_mean': np.repeat( 1.630277e-8 , 8 ) ,
'proportion_female': np.repeat( [ 0.592593 , 0.407407 ] , 4 ) ,
'proportion_male': np.repeat( [ 0.407407 , 0.592593 ] , 4 ) ,
Expand Down

0 comments on commit 5305b11

Please sign in to comment.