Skip to content
Merged
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/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A clear and concise description of what you want to happen.
A clear and concise description of any alternative solutions or features you've considered. An argument for why this solution is not the preferred one.

**Example**
Give a concise example of the envisioned featured.
Give a concise example of the envisioned featured.

**Additional context**
Add any other context or screenshots about the feature request here.
Expand Down
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Describe the changes that had to be made to an existing functionality (if they w
- [ ] ...

## Testing
The following tests (compatible with pytest) were added:
The following tests (compatible with pytest) were added:
- [ ] first test
- [ ] second test
- ...

## Verify that your checklist complies with the project
- [ ] New and existing unit tests pass locally
- [ ] Tests were added to prove that all features/changes are effective
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
deploy:

runs-on: ubuntu-latest

#environment: release
Expand All @@ -25,7 +25,7 @@ jobs:
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip
pip install hatch
- name: Build package
run: hatch build
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ permissions: write-all
jobs:
documentation:
name: ${{ matrix.os }} / ${{ matrix.python-version }}

runs-on: ${{ matrix.os }}

strategy:
matrix: # only lowest supported Python on latest ubuntu
os: [ubuntu-latest]
python-version: [3.14]

permissions:
issues: write
pull-requests: write
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:

- name: Install dependencies
run: pip install -r ./docs/requirements.txt

- name: Build documentation
run: python -m sphinx -b html docs ./docs/_build -d ./docs/_build

Expand Down Expand Up @@ -81,6 +81,3 @@ jobs:
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: docs/_build/html



2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ coverage.xml
.pytest_cache/
cover/

# DS
# DS
**/.DS_Store

# Translations
Expand Down
1 change: 0 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ sphinx:
python:
install:
- requirements: docs/requirements.txt

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Documentation Status](https://readthedocs.org/projects/pyaml/badge/?version=latest)](https://pyaml.readthedocs.io/en/latest/?badge=latest)
[![Documentation Status](https://readthedocs.org/projects/pyaml/badge/?version=latest)](https://pyaml.readthedocs.io/en/latest/?badge=latest)
![Current release](https://img.shields.io/github/v/tag/python-accelerator-middle-layer/pyaml)

# pyAML: Python Accelerator Middle Layer
Expand All @@ -10,7 +10,7 @@ Disclaimer: the pyAML software is still under development.
1. Clone the repository
2. Create a virtual environment and activate it
3. Install the package. For editable installation:

```
cd pyaml
pip install -e .
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ linkcheck:
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
"results in $(BUILDDIR)/doctest/output.txt."
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ API
:toctree: generated
:recursive:

pyaml
pyaml
11 changes: 5 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pyAML documentation
===================

Introduction
------------

Expand All @@ -14,12 +14,12 @@ With pyAML, it WILL be possible to (the software is at conceptualization stage):
- **compute statistical properties for several lattice instances with errors**
- **flexible complex unit conversions**
- **easy and friendly configuration**
- many more features
- many more features

Installation
------------
pip support will be provided later.
for the time being:
pip support will be provided later.
for the time being:

git clone https://github.com/python-accelerator-middle-layer/pyaml.git

Expand Down Expand Up @@ -57,7 +57,7 @@ Discussion
Shared documents
~~~~~~~~~~~~~~~~

to access the shared documents please ask S.Liuzzo for access rigths.
to access the shared documents please ask S.Liuzzo for access rigths.

The pyAML "software requirement specification" document is visible here:
https://www.overleaf.com/read/hnrqzhfpbvpp#ef8935
Expand All @@ -76,4 +76,3 @@ Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

2 changes: 1 addition & 1 deletion docs/modules/bpm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ BPMS
:members:

.. automodule:: pyaml.bpm.bpm_simple_model
:members:
:members:
4 changes: 2 additions & 2 deletions docs/modules/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Configuration

.. automodule:: pyaml.configuration.factory
:members:

.. automodule:: pyaml.configuration.matrix
:members:

Expand All @@ -18,7 +18,7 @@ Configuration

.. automodule:: pyaml.configuration.matrix
:members:

.. automodule:: pyaml.configuration.csvmatrix
:members:

Expand Down
4 changes: 1 addition & 3 deletions docs/modules/lattice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lattice

.. automodule:: pyaml.lattice.attribute_linker
:members:

.. automodule:: pyaml.lattice.element_holder
:members:

Expand All @@ -21,5 +21,3 @@ lattice

.. automodule:: pyaml.lattice.simulator
:members:


1 change: 0 additions & 1 deletion docs/modules/pyaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ pyaml
.. toctree::
:maxdepth: 2
:caption: Contents:

1 change: 0 additions & 1 deletion docs/modules/rf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ RF

.. automodule:: pyaml.rf.rf_transmitter
:members:

2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ accelerator-toolbox==0.7.1
matplotlib==3.10.7
ipykernel==7.1.0
myst-nb==1.3.0
pydata-sphinx-theme==0.16.1
pydata-sphinx-theme==0.16.1
5 changes: 5 additions & 0 deletions pyaml/common/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
PyAML global constants
"""

HORIZONTAL_KICK_SIGN: float = -1.0
38 changes: 28 additions & 10 deletions pyaml/lattice/abstract_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ def __init__(
self.__model = model
self.__elements = elements
self.__poly = elements[0].__getattribute__(poly.attName)
self.__sign = poly.sign
self.__polyIdx = poly.index

def get(self) -> float:
s = self.__poly[self.__polyIdx] * self.__elements[0].Length
s = self.__poly[self.__polyIdx] * self.__sign * self.__elements[0].Length
return self.__model.compute_hardware_values([s])[0]

def set(self, value: float):
s = self.__model.compute_strengths([value])[0]
self.__poly[self.__polyIdx] = s / self.__elements[0].Length
self.__poly[self.__polyIdx] = s / (self.__elements[0].Length * self.__sign)

def set_and_wait(self, value: float):
raise NotImplementedError("Not implemented yet.")
Expand All @@ -59,15 +60,16 @@ def __init__(
self.__model = model
self.__elements = elements
self.__poly = elements[0].__getattribute__(poly.attName)
self.__sign = poly.sign
self.__polyIdx = poly.index

# Gets the value
def get(self) -> float:
return self.__poly[self.__polyIdx] * self.__elements[0].Length
return self.__poly[self.__polyIdx] * self.__sign * self.__elements[0].Length

# Sets the value
def set(self, value: float):
self.__poly[self.__polyIdx] = value / self.__elements[0].Length
self.__poly[self.__polyIdx] = value / (self.__elements[0].Length * self.__sign)

# Sets the value and wait that the read value reach the setpoint
def set_and_wait(self, value: float):
Expand All @@ -93,25 +95,33 @@ def __init__(
self.__elements = elements
self.__poly = []
self.__polyIdx = []
self.__sign = []
self.__model = model
for p in poly:
self.__poly.append(elements[0].__getattribute__(p.attName))
self.__polyIdx.append(p.index)
self.__sign.append(p.sign)

# Gets the value
def get(self) -> np.array:
nbStrength = len(self.__poly)
s = np.zeros(nbStrength)
for i in range(nbStrength):
s[i] = self.__poly[i][self.__polyIdx[i]] * self.__elements[0].Length
s[i] = (
self.__poly[i][self.__polyIdx[i]]
* self.__sign[i]
* self.__elements[0].Length
)
return self.__model.compute_hardware_values(s)

# Sets the value
def set(self, value: np.array):
nbStrength = len(self.__poly)
s = self.__model.compute_strengths(value)
for i in range(nbStrength):
self.__poly[i][self.__polyIdx[i]] = s[i] / self.__elements[0].Length
self.__poly[i][self.__polyIdx[i]] = s[i] / (
self.__elements[0].Length * self.__sign[i]
)

# Sets the value and wait that the read value reach the setpoint
def set_and_wait(self, value: np.array):
Expand All @@ -136,25 +146,33 @@ def __init__(
self.__elements = elements
self.__poly = []
self.__polyIdx = []
self.__sign = []
self.__model = model
for p in poly:
self.__poly.append(elements[0].__getattribute__(p.attName))
self.__polyIdx.append(p.index)
self.__sign.append(p.sign)

# Gets the value
def get(self) -> np.array:
nbStrength = len(self.__poly)
s = np.zeros(nbStrength)
for i in range(nbStrength):
s[i] = self.__poly[i][self.__polyIdx[i]] * self.__elements[0].Length
s[i] = (
self.__poly[i][self.__polyIdx[i]]
* self.__sign[i]
* self.__elements[0].Length
)
return s

# Sets the value
def set(self, value: np.array):
nbStrength = len(self.__poly)
s = np.zeros(nbStrength)
for i in range(nbStrength):
self.__poly[i][self.__polyIdx[i]] = value[i] / self.__elements[0].Length
self.__poly[i][self.__polyIdx[i]] = value[i] / (
self.__elements[0].Length * self.__sign[i]
)

# Sets the value and wait that the read value reach the setpoint
def set_and_wait(self, value: np.array):
Expand All @@ -173,11 +191,11 @@ class BPMScalarAggregator(ScalarAggregator):
BPM simulator aggregator
"""

def __init__(self, ring:at.Lattice):
def __init__(self, ring: at.Lattice):
self.lattice = ring
self.refpts = []

def add_elem(self,elem:at.Element):
def add_elem(self, elem: at.Element):
self.refpts.append(self.lattice.index(elem))

def set(self, value: NDArray[np.float64]):
Expand Down
3 changes: 2 additions & 1 deletion pyaml/lattice/polynom_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PolynomInfo:
Polynom information
"""

def __init__(self, attName: str, index: int):
def __init__(self, attName: str, index: int, sign: float = 1.0):
"""
Construct a polynom information object

Expand All @@ -21,3 +21,4 @@ def __init__(self, attName: str, index: int):
"""
self.attName = attName
self.index = index
self.sign = sign
30 changes: 30 additions & 0 deletions pyaml/magnet/corrector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import numpy as np

from ..common import abstract
from .magnet import Magnet


class RWCorrectorAngle(abstract.ReadWriteFloatScalar):
"""
Set the angle of a horizontal or vertical corrector.
KickAngle sign convention is defined the a global PyAML constant
(see pyaml.common.constant.HORIZONATL_KICK_SIGN).
To change the convention, you have execute the code below prior to everything:
import pyaml.common.constants
pyaml.common.constants.HORIZONTAL_KICK_SIGN = -1.0
"""

def __init__(self, corr: Magnet):
self._mag = corr

def get(self) -> float:
return np.arctan(self._mag.strength.get())

def set(self, value: float):
self._mag.strength.set(np.tan(value))

def set_and_wait(self, value: float):
raise NotImplementedError("Not implemented yet.")

def unit(self) -> str:
return "rad"
Loading
Loading