Skip to content

fix: guard against empty peak array in get_ignition_delay#24

Merged
kyleniemeyer merged 9 commits into
pr-omethe-us:masterfrom
LekiaAnonim:master
May 12, 2026
Merged

fix: guard against empty peak array in get_ignition_delay#24
kyleniemeyer merged 9 commits into
pr-omethe-us:masterfrom
LekiaAnonim:master

Conversation

@LekiaAnonim
Copy link
Copy Markdown
Contributor

get_ignition_delay crashed with ValueError: attempt to get argmax of an empty sequence when detect_peaks returned no peaks (e.g. flat/non-igniting signal). Added peak_inds.size == 0 guards in all four ignition type branches so execution falls through to the existing sentinel return. Also relaxes upper version bounds on pyyaml/pint/numpy in setup.py and adds python_requires>=3.7.

get_ignition_delay crashed with ValueError: attempt to get argmax of an empty sequence when detect_peaks returned no peaks (e.g. flat/non-igniting signal). Added peak_inds.size == 0 guards in all four ignition type branches so execution falls through to the existing sentinel return. Also relaxes upper version bounds on pyyaml/pint/numpy in setup.py and adds python_requires>=3.7.
Copilot AI review requested due to automatic review settings April 2, 2026 22:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a crash in get_ignition_delay when detect_peaks returns no peaks (e.g., flat/non-igniting signals), and updates packaging/example artifacts.

Changes:

  • Add peak_inds.size == 0 guards in all ignition-type branches of get_ignition_delay to avoid argmax on an empty array.
  • Relax dependency upper bounds in setup.py and declare python_requires>=3.7.
  • Update the H2O2 shock tube example invocation and add an example results YAML output file; add a markdown write-up of the crash scenario.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pyteck/simulation.py Adds empty-peak guards to prevent ValueError when no peaks are detected.
setup.py Removes dependency upper bounds and adds python_requires.
examples/h2o2-shocktube/main.py Wraps the example execution in a __main__ guard and sets skip_validation=True.
examples/h2o2-shocktube/h2o2-results.yaml Adds a committed example output artifact.
pyteck_issue_get_ignition_delay_crash.md Documents the crash and reproducer/fix rationale.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyteck/simulation.py Outdated
Comment thread pyteck/simulation.py
Comment thread pyteck/simulation.py
Comment thread setup.py Outdated
Comment thread examples/h2o2-shocktube/main.py Outdated
Comment thread examples/h2o2-shocktube/h2o2-results.yaml Outdated
…d trigger the ign_delay.size==0 condition, that writes target-data-.out files, and could cause some noisy dumps. Instead, a no ignition delay of 0 array is return if peak_inds.size==0
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread pyteck/simulation.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

setup.py:36

  • Dependency upper bounds were removed here, but the repo’s conda environment specs still pin numpy<2.0, pyyaml<4.0, and pint<0.9 (see build-environment.yaml and test-environment.yaml). This creates divergent dependency sets between pip installs (setup.py) and conda-based CI/docs builds; consider either relaxing the conda pins too or keeping consistent bounds across packaging files.
install_requires = [
    'pyyaml>=3.12',
    'pint>=0.7.2',
    'numpy>=1.13.0',
    'tables',
    'pyked>=0.4.1',
    'scipy>=1.0.0',
    'cantera>=2.3.0'
]

Comment thread setup.py
Comment thread pyteck/simulation.py Outdated
Comment thread pyteck_issue_get_ignition_delay_crash.md Outdated
LekiaAnonim and others added 3 commits May 12, 2026 12:39
Correct comment spelling

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Merge comment spelling error resolved on GitHub
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

setup.py:36

  • install_requires now allows unbounded major upgrades for pyyaml, pint, and numpy, but the conda/test environments in this repo still pin older upper bounds (e.g., numpy<2.0, pint<0.9, pyyaml<4.0). As a result, CI won’t exercise the newer versions that pip users can now receive. Either keep the upper bounds here, or update the conda/test environment constraints (and CI matrix) to match the versions you intend to support.
install_requires = [
    'pyyaml>=3.12',
    'pint>=0.7.2',
    'numpy>=1.13.0',
    'tables',
    'pyked>=0.4.1',
    'scipy>=1.0.0',
    'cantera>=2.3.0'
]

Comment thread pyteck/simulation.py
Comment on lines +99 to +100
no_ignition_delay = np.array([0.0])

Comment on lines +334 to +346
cwd = os.getcwd()
with TemporaryDirectory() as temp_dir:
os.chdir(temp_dir)
try:
ignition_delays = simulation.get_ignition_delay(
times, target, 'species', ignition_type
)
dumped_files = [
filename for filename in os.listdir(temp_dir)
if filename.startswith('target-data-') and filename.endswith('.out')
]
finally:
os.chdir(cwd)
Comment thread conda.recipe/meta.yaml
Comment on lines +17 to 23
- python >=3.7,<3.10
- setuptools
- pip

run:
- python
- python >=3.7,<3.10
- pyyaml >=3.12,<4.0
@kyleniemeyer
Copy link
Copy Markdown
Member

@LekiaAnonim let me know when this is ready for my final review - however, doesn't need to fix everything (e.g., the whole build system/CI needs to be updated)

@LekiaAnonim
Copy link
Copy Markdown
Contributor Author

@LekiaAnonim let me know when this is ready for my final review - however, doesn't need to fix everything (e.g., the whole build system/CI needs to be updated)

Alright. That's true. The major fixes have been made.

@kyleniemeyer
Copy link
Copy Markdown
Member

OK, I think this looks good

@kyleniemeyer kyleniemeyer merged commit f8da37a into pr-omethe-us:master May 12, 2026
3 of 4 checks passed
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.

3 participants