I've run into this problem countless times and I've tried to just overlook it but it's infuriating. About 25% of the time that I use the python debugger (usually on the command line, haven't tested elsewhere) it will report that an exception occurred in a location where it obviously didn't occur... (e.g. on the very first line of code importing a module).
Then I have to manually enter 'n' (for next) like 50-100 times until the error actually occurs and then it realizes that the error actually occurred somewhere else. Why does this happen? Is there a workaround? Should I report it as a bug, and how haven't other people noticed it yet?
Example -- Incorrect Reporting (line 6) after continue:
python -m pdb ablate_LHS_MMA.py
> /projects/academic/chrest/dwyerdei/CMAME_Final/sampling/ablate_LHS_MMA.py(6)<module>()
-> import lhsmdu
(Pdb) c
/projects/academic/chrest/dwyerdei/CMAME_Final/sampling/ablate_LHS_MMA.py:6: DeprecationWarning:
Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0),
(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries)
but was not found to be installed on your system.
If this would cause problems for you,
please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466
import lhsmdu
Traceback (most recent call last):
File "/user/dwyerdei/big_home/mambaforge/envs/Alex_UQ_Ensembles/lib/python3.9/pdb.py", line 1726, in main
pdb._runscript(mainpyfile)
File "/user/dwyerdei/big_home/mambaforge/envs/Alex_UQ_Ensembles/lib/python3.9/pdb.py", line 1586, in _runscript
self.run(statement)
File "/user/dwyerdei/big_home/mambaforge/envs/Alex_UQ_Ensembles/lib/python3.9/bdb.py", line 580, in run
exec(cmd, globals, locals)
File "<string>", line 1, in <module>
File "/projects/academic/chrest/dwyerdei/CMAME_Final/sampling/ablate_LHS_MMA.py", line 6, in <module>
import lhsmdu
ValueError: operands could not be broadcast together with shapes (6,) (250,5)
Example -- Correct Reporting (line 52) after next-stepping:
(Pdb)
> /projects/academic/chrest/dwyerdei/CMAME_Final/sampling/ablate_LHS_MMA.py(52)<module>()
-> lhs_scaled = (min_params + (max_params - min_params) * np.array(lhs).T)
(Pdb) n
ValueError: operands could not be broadcast together with shapes (6,) (250,5)
> /projects/academic/chrest/dwyerdei/CMAME_Final/sampling/ablate_LHS_MMA.py(52)<module>()
-> lhs_scaled = (min_params + (max_params - min_params) * np.array(lhs).T)
P.S. Notice the line number is next to the file name: ablate_LHS_MMA.py(52)