Skip to content

Add documentation for types: scalars, lists, and NumPy arrays#81

Open
PiotrPich2024 wants to merge 7 commits into
mainfrom
types_page
Open

Add documentation for types: scalars, lists, and NumPy arrays#81
PiotrPich2024 wants to merge 7 commits into
mainfrom
types_page

Conversation

@PiotrPich2024

Copy link
Copy Markdown

Added documentation about passed types and how they are converted into C variables.
Added warning inside documentation about passing wrong precision floating-point types numbers.

Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated

@grzanka grzanka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

see comments

Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated
Comment thread docs/python/types.md Outdated

@grzanka grzanka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

see comments

@PiotrPich2024 PiotrPich2024 marked this pull request as ready for review May 5, 2026 17:18
@grzanka grzanka requested a review from Copilot May 6, 2026 13:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the libamtrack documentation site to better describe Python↔C type conversions for the pyamtrack wrapper, and fixes the top-level README link to the hosted docs site.

Changes:

  • Fix README link to use the canonical https://libamtrack.github.io URL.
  • Add a new docs/python/types.md page documenting Python input/output conversions (scalars, lists, NumPy arrays) for fully ported functions.

Reviewed changes

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

File Description
README.md Fixes documentation site link to include the https:// scheme.
docs/python/types.md Adds a type conversion reference page for key pyamtrack functions/modules.

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

Comment thread docs/python/types.md Outdated
Comment on lines +5 to +8
# Type Conversion Tables for Ported Functions

This page shows input/output type conversions for all fully ported functions in pyamtrack.

Comment thread docs/python/types.md Outdated
| Python Input | → C Input | → C Output | → Python Output |
|---|---|---|---|
| `float` (energy in MeV) | `double` | `double` | `float` |
| `list` of floats | `double*` array | `double*` array | `np.ndarray` (float64) |
Comment thread docs/python/types.md Outdated
Comment on lines +43 to +44
| `list` of floats | `double*` array | `double*` array | `np.ndarray` (float64) |
| `np.ndarray` (float64) | `double*` array | `double*` array | `np.ndarray` (float64) |
Comment thread docs/python/types.md Outdated
Comment on lines +65 to +69
| Python Input | → C Input | → C Output | → Python Output |
|---|---|---|---|
| `float` (energy in MeV) | `double` | `double` | `float` |
| `list` of floats | `double*` array | `double*` array | `np.ndarray` (float64) |
| `np.ndarray` (float64) | `double*` array | `double*` array | `np.ndarray` (float64) |
Comment thread docs/python/types.md Outdated
Comment on lines +79 to +83
range_cm = pyamtrack.stopping.electron_range(150.0, material=1, model="tabata")

# Array (recommended for plots)
energies = np.linspace(10.0, 1000.0, 500, dtype=np.float64)
ranges = pyamtrack.stopping.electron_range(energies, material=1, model="tabata")
Comment thread docs/python/types.md Outdated
Comment on lines +103 to +107
# Query material property
density = pyamtrack.materials.get_density(1) # material ID 1

# List available materials
materials = pyamtrack.materials.list_materials()
@grzanka grzanka requested a review from Copilot June 24, 2026 13:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 2 out of 2 changed files in this pull request and generated 7 comments.

Comment thread docs/python/types.md
@@ -0,0 +1,258 @@
# pyamtrack — input types and vectorization behavior
Comment thread docs/python/types.md

This document describes which Python/NumPy types are accepted by `pyamtrack` functions and how `pyamtrack` interprets inputs (scalars, lists, `numpy.ndarray`) and what types it returns.

It specifically covers functions exported by modules (e.g. `pyamtrack.stopping`, `pyamtrack.converters`) that use the shared C++ wrappers in `src/wrapper/`.
Comment thread docs/python/types.md
Comment on lines +24 to +26
**Note:** `tuple` and `set` is not treated as array-like and will usually raise a `TypeError`. `NOT IMPLEMENTED YET`

**Note:** `0-d numpy.ndarray` and `0-d python lists` are treated as arrays-like type not scalars
Comment thread docs/python/types.md
In `pyamtrack`, a scalar is a Python object of type:
- `float`
- `int`
- `np.float64/32`
Comment thread docs/python/types.md
Most commonly accepted types are:
- `float`
- `int`
- `np.float64/32`
Comment thread docs/python/types.md

Many functions also work with mixed numeric elements inside lists (e.g. `[1, 2.0, 3]`), but this depends on the conversion path.

If an argument is not `float`, `int`, `list`, or `numpy.ndarray`, a type error will be raised.
Comment thread docs/python/types.md Outdated
Comment on lines +37 to +41
# returns nan
s.electron_range(x*0)

#return 0.0
s.electron_range(-1/x)
…prove clarity of input types for electron_range function
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