Skip to content

Fix error when analyzing CSVs with empty time metrics#923

Open
hbierlee wants to merge 1 commit into
masterfrom
fix/xcsp3-analysis-all-na
Open

Fix error when analyzing CSVs with empty time metrics#923
hbierlee wants to merge 1 commit into
masterfrom
fix/xcsp3-analysis-all-na

Conversation

@hbierlee
Copy link
Copy Markdown
Contributor

@hbierlee hbierlee commented Apr 16, 2026

If you analyze a CSV file with an empty time_* metric (which happens for me currently, only total_time is recorded for gurobi, which may be a different issue), the following error occurs:

> python cpmpy/tools/xcsp3/analyze.py results/expr.csv/xcsp3_2025_COP25_gurobi_20260416_185126.csv --time_limit 600  --output analysis/
Traceback (most recent call last):
  File "/cw/dtailocal/henk/Projects/cpmpy-master/cpmpy/tools/xcsp3/analyze.py", line 235, in <module>
    main()
  File "/cw/dtailocal/henk/Projects/cpmpy-master/cpmpy/tools/xcsp3/analyze.py", line 220, in main
    xcsp3_stats(merged_df)
  File "/cw/dtailocal/henk/Projects/cpmpy-master/cpmpy/tools/xcsp3/analyze.py", line 177, in xcsp3_stats
    slowest_idx = df[f'time_{phase}'].idxmax()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/cw/dtailocal/henk/miniforge3/envs/cpmpy/lib/python3.12/site-packages/pandas/core/series.py", line 2545, in idxmax
    iloc = self.argmax(axis, skipna, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/cw/dtailocal/henk/miniforge3/envs/cpmpy/lib/python3.12/site-packages/pandas/core/base.py", line 814, in argmax
    result = nanops.nanargmax(delegate, skipna=skipna)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/cw/dtailocal/henk/miniforge3/envs/cpmpy/lib/python3.12/site-packages/pandas/core/nanops.py", line 1158, in nanargmax
    result = _maybe_arg_null_out(result, axis, mask, skipna)  # type: ignore[arg-type]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/cw/dtailocal/henk/miniforge3/envs/cpmpy/lib/python3.12/site-packages/pandas/core/nanops.py", line 1473, in _maybe_arg_null_out
    raise ValueError("Encountered all NA values")
ValueError: Encountered all NA values

This PR fixes this error.

@hbierlee hbierlee requested a review from ThomSerg April 16, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant