pypest / pyemu

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

RuntimeError when adjusting weights with some groups zero-weighted #414

Closed aleaf closed 1 year ago

aleaf commented 1 year ago

This error can be reproduced with the following code (from the pst_tests::reweight_test function):

import os
import numpy as np
from pyemu import Pst
pst_dir = os.path.join("pst")
p = Pst(os.path.join(pst_dir, "pest.pst"))
obsgrp_dict = {"pred": 0., "head": 1.0, "conc": 1.0}
p.adjust_weights(obsgrp_dict=obsgrp_dict)

which results in:

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/Users/aleaf/Documents/GitHub/pyemu/pyemu/pst/pst_handler.py", line 2588, in adjust_weights
    for grp, contrib in obsgrp_dict.items():
RuntimeError: dictionary changed size during iteration