Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move python helpers #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Python
run: |
cd python
python petsird_generator.py | python petsird_analysis.py
python -m petsird.helpers.generator | python -m petsird.helpers.analysis
- name: cpp
run: |
mkdir cpp/build
Expand Down
9 changes: 5 additions & 4 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ pip install --editable ../python
The Python code shows piping the compact binary format to standard out and
reading it from standard in. This can be used as follows:

1. From the repo root `cd python`
1. `python petsird_generator.py | python petsird_analysis.py`
```sh
python -m petsird.helpers.generator | python -m petsird.helpers.analysis
```

There is also a very basic utility to plot the scanner geometry. For instance

```sh
python petsird_generator.py > test.bin
python petsird_plot_scanner.py < test.bin
python -m petsird.helpers.generator > test.bin
python -m petsird.helpers.plot_scanner < test.bin
```
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# Copyright (C) 2023-2024 University College London
#
# SPDX-License-Identifier: Apache-2.0

import sys

import petsird
Copy link
Member Author

Choose a reason for hiding this comment

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

btw I'm leaving this as an absolute import to make it easier for users to copy-paste

Copy link
Contributor

Choose a reason for hiding this comment

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

but wouldn't that apply to the line below as well?

Copy link
Member Author

@casperdcl casperdcl Nov 13, 2024

Choose a reason for hiding this comment

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

ish... depends on whether you expect users to do from petsird.helpers import ... (which sounds to me like a failure on yardl's part... isn't the point of yardl to not require boilerplate helpers?)

Copy link
Contributor

Choose a reason for hiding this comment

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

isn't the point of yardl to not require boilerplate helpers?

yes, but some of these helpers are a bit too complicated to be able to be auto-generated. (How would you encode matrix multiplications of rigid transformations and coordinates in yardl? Seems very hard...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Feel free to change as you see fit :)

from petsird_helpers import (get_detection_efficiency, get_module_and_element,
get_num_det_els)

from . import get_detection_efficiency, get_module_and_element, get_num_det_els

if __name__ == "__main__":
with petsird.BinaryPETSIRDReader(sys.stdin.buffer) as reader:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# Copyright (C) 2023-2024 University College London
#
# SPDX-License-Identifier: Apache-2.0

import math
import random
import sys
from collections.abc import Iterator

import numpy
import petsird
from petsird_helpers import get_module_and_element, get_num_det_els

from . import get_module_and_element, get_num_det_els

# these are constants for now
NUMBER_OF_ENERGY_BINS = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

# basic plotting of the scanner geometry
# preliminary code!

import sys

import matplotlib.pyplot as plt
Expand Down
Loading