Skip to content

Implement electron range module with bindings and model definitions#189

Open
PiotrPich2024 wants to merge 3 commits into
masterfrom
188-design-structure-for-stopping-powerrange-and-other-similar-modules
Open

Implement electron range module with bindings and model definitions#189
PiotrPich2024 wants to merge 3 commits into
masterfrom
188-design-structure-for-stopping-powerrange-and-other-similar-modules

Conversation

@PiotrPich2024
Copy link
Copy Markdown
Contributor

WIP
Added electron range module and moved electron range from stopping to new module, updated cmakelist and init

@PiotrPich2024 PiotrPich2024 marked this pull request as ready for review May 4, 2026 16:28
@grzanka grzanka requested a review from Copilot May 4, 2026 18:32
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

This PR splits electron-range functionality out of the stopping extension into a dedicated pyamtrack.electron_range module, updates package exports/build targets, and retargets several tests to the new entry point. In the codebase, this is a public-API refactor around how electron range calculations and model helpers are exposed to Python.

Changes:

  • Added a new electron_range extension module with bindings, model helpers, and a max_range() API plus an in-module electron_range() alias.
  • Removed the old electron-range bindings from pyamtrack.stopping and updated package/build wiring to ship the new module.
  • Migrated most tests to import from pyamtrack.electron_range, while the old stopping tests were commented out.

Reviewed changes

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

Show a summary per file
File Description
tests/test_stopping.py Legacy stopping electron-range tests were commented out.
tests/test_stopping_models.py Legacy stopping model-helper tests were commented out.
tests/test_multidim_input.py Switched multidimensional-input tests to the new module.
tests/test_function_behavior.py Switched behavior tests to the new module.
tests/test_electron_range_models.py Added model tests for the new electron-range module.
tests/test_cartesian_product.py Switched cartesian-product tests to the new module.
src/stopping/stopping_bindings.cpp Replaced previous stopping bindings with an empty placeholder module.
src/pyamtrack/__init__.py Exported the new electron_range module from the package.
src/electron_range/electron_range.h Renamed model map/function declaration to the new module terminology.
src/electron_range/electron_range.cpp Renamed implementation symbols from electron_range to max_range.
src/electron_range/electron_range_bindings.cpp Added the new Python bindings and docs for the electron-range module.
CMakeLists.txt Added electron_range to the extension build/install targets.

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

Comment on lines +9 to +10
// Placeholder: stopping power functions will be added here later
// For now, the module is empty but must be defined for the build system to work
Comment on lines +84 to +87
Raises
------
ValueError
If the model name is not recognized.
Comment thread tests/test_stopping.py
Comment on lines +1 to +34
# import numpy as np
# import pytest

# import pyamtrack.stopping


# @pytest.fixture
# def electron_energy_MeV():
# """Fixture providing the electron energy in MeV for tests."""
# return 1000.0


# def test_electron_range(electron_energy_MeV):
# """Test the electron_range function for various inputs."""
# range_m = pyamtrack.stopping.electron_range(electron_energy_MeV)
# assert range_m > 0.01, "Expected positive range for positive energy."


# def test_electron_range_air_vs_water(electron_energy_MeV):
# """Test the electron_range function for air and water."""
# range_air = pyamtrack.stopping.electron_range(electron_energy_MeV, pyamtrack.materials.air)
# range_water = pyamtrack.stopping.electron_range(electron_energy_MeV, pyamtrack.materials.water_liquid)
# assert range_air > range_water, "Expected range in air to be larger than in water."


# def test_material_assignment(electron_energy_MeV):
# """Test the material assignment by ID."""
# range_default = pyamtrack.stopping.electron_range(electron_energy_MeV)
# range_material_name = pyamtrack.stopping.electron_range(electron_energy_MeV, pyamtrack.materials.water_liquid)
# assert range_default == range_material_name, "Expected range to be the same for default and material name."
# range_material_id = pyamtrack.stopping.electron_range(electron_energy_MeV, 1)
# assert range_default == range_material_id, "Expected range to be the same for default and material ID."


Comment on lines +1 to +5
# import numpy as np
# import pytest

import pyamtrack.materials
import pyamtrack.stopping as stopping
# import pyamtrack.materials
# import pyamtrack.stopping as stopping
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.

Design structure for stopping power/range and other similar modules

2 participants