pypest / pyemu

python modules for model-independent uncertainty analyses, data-worth analyses, and interfacing with PEST(++)
BSD 3-Clause "New" or "Revised" License
169 stars 94 forks source link

Attribute error in apply_genericlist_pars #443

Closed aleaf closed 12 months ago

aleaf commented 12 months ago

Hi, I am getting this error (below) when trying to call apply_genericlist_pars in helpers.py with the following dataframe:

org_file model_file use_cols index_cols fmt sep head_rows upper_bound lower_bound operator zone_file mlt_file zero_based
51 org/riv_000.dat external/riv_000.dat [4] [6] free 1 [1e+30] [-1e+30] m nan mult/rivcond-mult-constant_inst0_grid.csv False

I am running the latest commit on the develop branch. The error is in this block of code.

assert len(common_idx) == mlt.chkpar, (
    "Probable miss-alignment in tpl indices and original file:\n"
    f"mult idx[:10] : {mlts.index.sort_values().tolist()[:10]}\n"
    f"org file idx[:10]: {new_df.index.sort_values().to_list()[:10]}\n"
    f"n common: {len(common_idx)}, n cols: {len(mlt_cols)}, "
    f"expected: {mlt.chkpar}."
)

Can't figure out where chkpar is supposed to come from, or what it may have gotten replaced by. Thanks for taking a look!

'Pandas' object has no attribute 'chkpar'
  File "/Users/aleaf/Documents/GitHub/pyemu/pyemu/utils/helpers.py", line 2175, in _process_list_file
    assert len(common_idx) == mlt.chkpar, (
                              ^^^^^^^^^^
  File "/Users/aleaf/Documents/GitHub/pyemu/pyemu/utils/helpers.py", line 2046, in _process_chunk_list_files
    raise e
  File "/Users/aleaf/Documents/GitHub/pyemu/pyemu/utils/helpers.py", line 2046, in _process_chunk_list_files
    raise e
  File "/Users/aleaf/Documents/GitHub/pyemu/pyemu/utils/helpers.py", line 2027, in apply_genericlist_pars
    _process_chunk_list_files(chunks[0], 0, df)
  File "/Users/aleaf/Documents/GitHub/pyemu/pyemu/utils/helpers.py", line 1597, in apply_list_and_array_pars
    apply_genericlist_pars(list_pars, chunk_len=chunk_len)
  File "/Users/aleaf/Documents/Kenai/beavercreek-pest/modflow/forward_run.py", line 8, in main
    pyemu.helpers.apply_list_and_array_pars(arr_par_file='mult2model_info.csv',chunk_len=50)
  File "/Users/aleaf/Documents/Kenai/beavercreek-pest/modflow/forward_run.py", line 12, in <module>
    main()
AttributeError: 'Pandas' object has no attribute 'chkpar'
jtwhite79 commented 12 months ago

Hey Andy. We added that chkpar recently to make sure the expected number of files is being processed. So I'm wondering if you have updated pyemu but not rerun your pstfrom script? Maybe?

aleaf commented 12 months ago

doh! That was it. Thanks for the tip.