From 17484c4d790d70e9faead725b130658e44421035 Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Thu, 25 Jul 2024 15:19:02 +0200 Subject: [PATCH 01/10] do not ignore pyproject file --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f7f6218..e967112 100644 --- a/.gitignore +++ b/.gitignore @@ -228,5 +228,4 @@ Temporary Items .docs/gen_modules .docs/gen_modules/ -doc_build/ -pyproject.toml \ No newline at end of file +doc_build/ \ No newline at end of file From 440ae007a95138fbf1f40c20733a76593d84531e Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Thu, 25 Jul 2024 15:42:35 +0200 Subject: [PATCH 02/10] create pyproject file --- pyproject.toml | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3175b4a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,90 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.version] +path = "pylhc/__init__.py" + +[tool.hatch.build.targets.sdist] +exclude = [ + "/.github", + "/doc", + "/tests", +] + +[tool.hatch.build.targets.wheel] +packages = ["pylhc"] + +[project] +name = "pylhc" +readme = "README.md" +description = "An accelerator physics script collection for the OMC team at CERN." +authors = [ + {name = "PyLHC", email = "pylhc@github.com"}, + {name = "Joschua Dilly", email = "joschua.dilly@cern.ch"}, + {name = "Felix Soubelet", email = "felix.soubelet@cern.ch"}, + {name = "Michael Hofer"}, + {name = "Yngve Levinsen"}, +] +license = "MIT" +dynamic = ["version"] +requires-python = ">=3.9" + +classifiers = [ + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Scientific/Engineering", + "Topic :: Software Development :: Libraries :: Python Modules", + "Typing :: Typed", +] + +dependencies = [ + "numpy >= 1.24", + "scipy >= 1.10", + "pandas >= 2.1", + "matplotlib >= 3.8", + "tfs-pandas >= 3.8", + "generic-parser >= 1.1", + "parse >= 1.15", + "omc3 >= 0.15", + "jpype1 >= 1.3", + "h5py >= 2.9.0", # same as tfs-pandas, do we need it here? + "tables >= 3.6.0", # same as tfs-pandas, do we need it here? +] + +[project.optional-dependencies] +cern = [ + "omc3[cern] >= 0.15", + "pjlsa >= 0.2", + "pytimber >= 3.0", # NXCALS support + "pyjapc", +] +test = [ + "pytest>=5.2", + "pytest-cov>=2.9", + "pytest-mpl>=0.15", +] +doc = [ + "sphinx >= 7.0", + "sphinx_rtd_theme >= 2.0", +] + +all = [ + "pylhc[cern]", + "pylhc[test]", + "pylhc[doc]", +] + +[project.urls] +homepage = "https://github.com/pylhc/PyLHC" +repository = "https://github.com/pylhc/PyLHC" +documentation = "https://pylhc.github.io/PyLHC/" +changelog = "https://github.com/pylhc/PyLHC/blob/master/CHANGELOG.md" From 33629da84d035204fe4ce0efec55492899ed9739 Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Thu, 25 Jul 2024 15:42:43 +0200 Subject: [PATCH 03/10] remove setup.py --- setup.py | 96 -------------------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 setup.py diff --git a/setup.py b/setup.py deleted file mode 100644 index 750339e..0000000 --- a/setup.py +++ /dev/null @@ -1,96 +0,0 @@ -import pathlib - -import setuptools - -# The directory containing this file -MODULE_NAME = "pylhc" -TOPLEVEL_DIR = pathlib.Path(__file__).parent.absolute() -ABOUT_FILE = TOPLEVEL_DIR / MODULE_NAME / "__init__.py" -README = TOPLEVEL_DIR / "README.md" - - -def about_package(init_posixpath: pathlib.Path) -> dict: - """ - Return package information defined with dunders in __init__.py as a dictionary, when - provided with a PosixPath to the __init__.py file. - """ - about_text: str = init_posixpath.read_text() - return { - entry.split(" = ")[0]: entry.split(" = ")[1].strip('"') - for entry in about_text.strip().split("\n") - if entry.startswith("__") - } - - -ABOUT_PYLHC = about_package(ABOUT_FILE) - -with README.open("r") as docs: - long_description = docs.read() - -# Dependencies for the module itself -DEPENDENCIES = [ - "numpy>=1.19", - "scipy>=1.4.0", - "pandas>=1.0,!=1.2", # not 1.2 because of https://github.com/pandas-dev/pandas/issues/39872 - "matplotlib>=3.2.0", - "tfs-pandas>=3.0.2", - "generic-parser>=1.0.8", - "parse>=1.15.0", - "omc3>=0.2.0", - "jpype1>=1.3.0", - "h5py>=2.9.0", - "tables>=3.6.0", -] - -EXTRA_DEPENDENCIES = { - "cern": [ - "omc3[cern]>=0.2.0", - "pjlsa>=0.0.14", - "pytimber>=3.0.0", # NXCALS support - "pyjapc", - ], - "test": [ - "pytest>=5.2", - "pytest-cov>=2.7", - "pytest-regressions>=2.0.0", - "pytest-mpl>=0.11", - "hypothesis>=5.0.0", - "attrs>=19.2.0", - ], - "doc": ["sphinx", "sphinx_rtd_theme"], -} -EXTRA_DEPENDENCIES.update( - {"all": [elem for list_ in EXTRA_DEPENDENCIES.values() for elem in list_]} -) - - -setuptools.setup( - name=ABOUT_PYLHC["__title__"], - version=ABOUT_PYLHC["__version__"], - description=ABOUT_PYLHC["__description__"], - long_description=long_description, - long_description_content_type="text/markdown", - author=ABOUT_PYLHC["__author__"], - author_email=ABOUT_PYLHC["__author_email__"], - url=ABOUT_PYLHC["__url__"], - python_requires=">=3.7", - license=ABOUT_PYLHC["__license__"], - classifiers=[ - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Topic :: Scientific/Engineering :: Physics", - "Topic :: Scientific/Engineering :: Visualization", - ], - packages=setuptools.find_packages(exclude=["tests*", "doc"]), - include_package_data=True, - install_requires=DEPENDENCIES, - tests_require=EXTRA_DEPENDENCIES["test"], - extras_require=EXTRA_DEPENDENCIES, -) From ceb191b7d33837498b0fec103a14717ca0ce9c9f Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Thu, 25 Jul 2024 15:49:21 +0200 Subject: [PATCH 04/10] pytest options from setup.cfg here, as that file is not recommended --- pyproject.toml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3175b4a..0203092 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,7 @@ cern = [ "pyjapc", ] test = [ - "pytest>=5.2", + "pytest>=7.0", "pytest-cov>=2.9", "pytest-mpl>=0.15", ] @@ -88,3 +88,13 @@ homepage = "https://github.com/pylhc/PyLHC" repository = "https://github.com/pylhc/PyLHC" documentation = "https://pylhc.github.io/PyLHC/" changelog = "https://github.com/pylhc/PyLHC/blob/master/CHANGELOG.md" + +# ----- Testing ----- # + +[tool.pytest.ini_options] +markers = [ + "cern_network: tests that require access to afs or the technical network", +] +# Helpful for pytest-debugging (leave commented out on commit): +# log_cli=true +# log_level=DEBUG From d4d4c35b81fac90e07a82cb967032b42ace1bb76 Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Thu, 25 Jul 2024 15:49:44 +0200 Subject: [PATCH 05/10] not needed anymore --- setup.cfg | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2436457..0000000 --- a/setup.cfg +++ /dev/null @@ -1,13 +0,0 @@ -[tool:pytest] -markers= - cern_network: tests that require access to afs or the technical network -; Helpful for pytest-debugging (leave commented out on commit): -;log_cli=true -;log_level=DEBUG - -[pycodestyle] -max-line-length = 100 -exclude = doc/conf.py - -[aliases] -test=pytest \ No newline at end of file From 3644c58520094f10a7117a6cff6432268695cb7b Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Thu, 25 Jul 2024 16:07:24 +0200 Subject: [PATCH 06/10] using common workflows --- .github/workflows/README.md | 11 +++-- .github/workflows/coverage.yml | 66 +++-------------------------- .github/workflows/cron.yml | 42 +++--------------- .github/workflows/documentation.yml | 48 +-------------------- .github/workflows/publish.yml | 43 +------------------ .github/workflows/tests.yml | 43 ++++--------------- 6 files changed, 28 insertions(+), 225 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 5cd5e77..ce6d514 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -1,29 +1,28 @@ # Continous Integration Workflows -This package implements different workflows for CI. +This package implements different workflows for CI, based on our organisation's common workflows. They are organised as follows. ### Documentation The `documentation` workflow triggers on any push to master, builds the documentation and pushes it to the `gh-pages` branch (if the build is successful). -It runs on `ubuntu-latest` and Python version, `Python 3.9`. ### Testing Suite Tests are ensured in the `tests` workflow, which triggers on all pushes. -It runs on a matrix of all supported operating systems (ubuntu-20.04, ubuntu-22.04, windows-latest and macos-latest) for all supported Python versions (currently `3.8`, `3.9` and `3.10`). +It runs on a matrix of all supported operating systems for all supported Python versions. ### Test Coverage Test coverage is calculated in the `coverage` wokflow, which triggers on pushes to `master` and any push to a `pull request`. -It runs on `ubuntu-latest` & the Python version (`Python 3.9`), and reports the coverage results of the test suite to `CodeClimate`. +It reports the coverage results of the test suite to `CodeClimate`. ### Regular Testing A `cron` workflow triggers every Monday at 3am (UTC time) and runs the full testing suite, on all available operating systems and supported Python versions. -It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically detected. +It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically included. ### Publishing -Publishing to `PyPI` is done through the `publish` workflow, which triggers anytime a `release` is made of the Github repository. +Publishing to `PyPI` is done through the `publish` workflow, which triggers anytime a `release` is made of the GitHub repository. It builds a `wheel`, checks it, and pushes to `PyPI` if checks are successful. diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index e5e83a2..6267c64 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,10 +1,6 @@ # Runs all tests and pushes coverage report to codeclimate name: Coverage -defaults: - run: - shell: bash - on: # Runs on all push events to master branch and any push related to a pull request push: branches: @@ -13,60 +9,8 @@ on: # Runs on all push events to master branch and any push related to a pull r jobs: coverage: - name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python-version: [3.9] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - - name: Install package - run: python -m pip install '.[test]' - - - name: Set up env for CodeClimate (push) - run: | - echo "GIT_BRANCH=${GITHUB_REF/refs\/heads\//}" >> $GITHUB_ENV - echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV - if: github.event_name == 'push' - - - name: Set up env for CodeClimate (pull_request) - env: - PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} - run: | - echo "GIT_BRANCH=$GITHUB_HEAD_REF" >> $GITHUB_ENV - echo "GIT_COMMIT_SHA=$PR_HEAD_SHA" >> $GITHUB_ENV - if: github.event_name == 'pull_request' - - - name: Prepare CodeClimate binary - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - run: | - curl -LSs 'https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64' >./cc-test-reporter; - chmod +x ./cc-test-reporter - ./cc-test-reporter before-build - - - name: Run tests - run: python -m pytest -m "not cern_network" --mpl --cov-report xml --cov=pylhc - - - name: Push Coverage to CodeClimate - if: ${{ success() }} # only if tests were successful - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - run: ./cc-test-reporter after-build + uses: pylhc/.github/.github/workflows/coverage.yml@master + with: + src-dir: pylhc + pytest-options: -m "not cern_network" --mpl + secrets: inherit diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 2f7ebf7..767769c 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -1,43 +1,13 @@ -# Runs all tests on master monday at 3 am (UTC time) +# Runs all tests on master on Mondays at 3 am (UTC time) name: Cron Testing -defaults: - run: - shell: bash -on: # Runs on master branch on Mondays at 3am UTC time +on: schedule: - cron: '* 3 * * mon' jobs: - tests: - name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04, ubuntu-22.04, macos-latest, windows-latest] - # Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser - python-version: [3.8, 3.9, "3.10", "3.11", 3.x] # crons should always run latest python hence 3.x - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - - name: Install package - run: python -m pip install '.[test]' - - - name: Run tests - run: python -m pytest -m "not cern_network" --mpl --cov-report xml --cov=pylhc + tests: + uses: pylhc/.github/.github/workflows/cron.yml@master + with: + pytest-options: -m "not cern_network" --mpl diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 87db6e5..e1195b9 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -3,10 +3,6 @@ # The build is published to github pages if the triggering event is a push to the master branch (PR merge) name: Build and upload documentation -defaults: - run: - shell: bash - on: # Runs on any push event in a PR or any push event to master pull_request: push: @@ -15,46 +11,4 @@ on: # Runs on any push event in a PR or any push event to master jobs: documentation: - name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python-version: [3.9] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - - name: Install package - run: python -m pip install '.[doc]' - - - name: Build documentation - run: python -m sphinx -b html doc ./doc_build -d ./doc_build - - - name: Upload build artifacts # upload artifacts so reviewers can have a quick look without building documentation from the branch locally - uses: actions/upload-artifact@v3 - if: success() && github.event_name == 'pull_request' # only for pushes in PR - with: - name: site-build - path: doc_build - retention-days: 5 - - - name: Upload documentation to gh-pages - if: success() && github.ref == 'refs/heads/master' # only for pushes to master - uses: JamesIves/github-pages-deploy-action@v4 - with: - folder: doc_build + uses: pylhc/.github/.github/workflows/documentation.yml@master diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b68c8c7..95fcfb7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,50 +1,11 @@ # Publishes to PyPI upon creation of a release name: Upload Package to PyPI -defaults: - run: - shell: bash - on: # Runs everytime a release is added to the repository release: types: [created] jobs: deploy: - name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python-version: [3.9] - - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - - name: Upgrade pip, setuptools, wheel, build and twine - run: python -m pip install --upgrade pip setuptools wheel build twine - - - name: Build and check build - run: | - python -m build - twine check dist/* - - - name: Publish - if: ${{ success() }} - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - twine upload dist/* + uses: pylhc/.github/.github/workflows/publish.yml@master + secrets: inherit diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6a298b3..df9f2e6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,42 +1,17 @@ -# Runs all tests not flagged as "cern_network" with a pytest marker -name: Tests +# Runs all tests +name: All Tests defaults: run: shell: bash -on: [push] # Runs on all push events to any branch - +on: # Runs on any push event to any branch except master (the coverage workflow takes care of that) + push: + branches-ignore: + - 'master' jobs: tests: - name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04, ubuntu-22.04, macos-latest, windows-latest] - # Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser - python-version: [3.8, 3.9, "3.10", "3.11"] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - - name: Install package - run: python -m pip install '.[test]' - - - name: Run basic tests - run: python -m pytest -m "not cern_network" --mpl + uses: pylhc/.github/.github/workflows/tests.yml@master + with: + pytest-options: -m "not cern_network" --mpl From e54c7faf6f559cddf2fefbcc686e9ccf76037462 Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Fri, 9 Aug 2024 15:10:19 +0200 Subject: [PATCH 07/10] unused imports --- pylhc/bpm_calibration.py | 3 --- pylhc/calibration/beta.py | 4 ++-- pylhc/calibration/dispersion.py | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/pylhc/bpm_calibration.py b/pylhc/bpm_calibration.py index 2d4760c..8e98fb4 100644 --- a/pylhc/bpm_calibration.py +++ b/pylhc/bpm_calibration.py @@ -52,10 +52,7 @@ default: ``beta`` """ from pathlib import Path -from typing import List, Tuple -import numpy as np -import pandas as pd import tfs from generic_parser import EntryPointParameters, entrypoint from omc3.optics_measurements.constants import EXT diff --git a/pylhc/calibration/beta.py b/pylhc/calibration/beta.py index d72fcb1..427760d 100644 --- a/pylhc/calibration/beta.py +++ b/pylhc/calibration/beta.py @@ -8,7 +8,7 @@ """ from pathlib import Path -from typing import Dict, List, Sequence, Tuple +from typing import Dict, Sequence, Tuple import numpy as np import pandas as pd @@ -17,7 +17,7 @@ from omc3.utils import logging_tools from scipy.optimize import curve_fit -from pylhc.constants.calibration import BETA_STAR_ESTIMATION, BPMS, IPS, LABELS, TFS_INDEX +from pylhc.constants.calibration import BETA_STAR_ESTIMATION, BPMS, LABELS, TFS_INDEX from pylhc.constants.general import PLANES LOG = logging_tools.get_logger(__name__) diff --git a/pylhc/calibration/dispersion.py b/pylhc/calibration/dispersion.py index 9faaf2d..f3cc331 100644 --- a/pylhc/calibration/dispersion.py +++ b/pylhc/calibration/dispersion.py @@ -26,12 +26,9 @@ BPMS, D_BPMS, D, - IPS, LABELS, - ND, TFS_INDEX, ) -from pylhc.constants.general import PLANES import tfs From 4327cf6f309cd30ad3f3ad19a0e87be10a4566fc Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Fri, 9 Aug 2024 15:11:07 +0200 Subject: [PATCH 08/10] not fstrings --- pylhc/bsrt_analysis.py | 2 +- pylhc/calibration/dispersion.py | 4 ++-- pylhc/data_extract/lsa.py | 2 +- pylhc/forced_da_analysis.py | 12 ++++++------ pylhc/kickgroups.py | 4 ++-- pylhc/lsa_to_madx.py | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pylhc/bsrt_analysis.py b/pylhc/bsrt_analysis.py index eba205a..f2e73eb 100644 --- a/pylhc/bsrt_analysis.py +++ b/pylhc/bsrt_analysis.py @@ -365,7 +365,7 @@ def plot_crosssection_for_timesteps(opt, bsrt_df): fig.suptitle(f"Timestamp: {timestamp}") ax[0].imshow(_reshaped_imageset(data_row), cmap="hot", interpolation="nearest") - ax[0].set_title(f"2D Pixel count") + ax[0].set_title("2D Pixel count") ax[1].plot(data_row["projPositionSet1"], data_row["projDataSet1"], color="darkred") ax[1].plot( diff --git a/pylhc/calibration/dispersion.py b/pylhc/calibration/dispersion.py index f3cc331..b641dd8 100644 --- a/pylhc/calibration/dispersion.py +++ b/pylhc/calibration/dispersion.py @@ -182,10 +182,10 @@ def get_calibration_factors_from_dispersion( dispersion = dict() normalised_dispersion = dict() - dispersion["amp"] = dispersion_tfs.reindex(bpms)[f"DX"] + dispersion["amp"] = dispersion_tfs.reindex(bpms)["DX"] dispersion["amp_err"] = dispersion_tfs.reindex(bpms)[f"{ERR}{D}X"] - dispersion["phase"] = norm_dispersion_tfs.reindex(bpms)[f"DX"] + dispersion["phase"] = norm_dispersion_tfs.reindex(bpms)["DX"] dispersion["phase_err"] = norm_dispersion_tfs.reindex(bpms)[f"{ERR}{D}X"] # Compute the calibration factors using the dispersion from phase and amp diff --git a/pylhc/data_extract/lsa.py b/pylhc/data_extract/lsa.py index 93359e6..eae9d89 100644 --- a/pylhc/data_extract/lsa.py +++ b/pylhc/data_extract/lsa.py @@ -155,7 +155,7 @@ def find_beamprocess_history( idx = fillnts.searchsorted(ts) - 1 filln = int(fillnv[idx]) fills.setdefault(filln, []).insert(0, (ts, name)) - LOG.debug(f"Beamprocess History extracted.") + LOG.debug("Beamprocess History extracted.") return fills def get_trim_history( diff --git a/pylhc/forced_da_analysis.py b/pylhc/forced_da_analysis.py index 88bfa31..32017e1 100644 --- a/pylhc/forced_da_analysis.py +++ b/pylhc/forced_da_analysis.py @@ -606,11 +606,11 @@ def _get_db(opt): if opt.fill is not None: raise EnvironmentError("'fill' can't be used with pagestore database.") else: - LOG.debug(f" Trying to load database from timber.") + LOG.debug(" Trying to load database from timber.") try: db = pytimber.LoggingDB(source=opt["timber_db"]) except AttributeError: - LOG.debug(f" Loading from timber failed.") + LOG.debug(" Loading from timber failed.") if not db: error_msg = "" @@ -1069,7 +1069,7 @@ def _plot_intensity(directory, beam, plane, kick_df, intensity_df): markersize=mpl.rcParams["lines.markersize"] * 0.5, fillstyle="full", color=colors.get_mpl_color(0), - label=f"Intensity", + label="Intensity", ) # plot losses per kick @@ -1137,7 +1137,7 @@ def _plot_emittances(directory, beam, plane, emittance_df, emittance_bws_df, kic marker="o", markeredgewidth=2, linestyle="None", - label=f"From BSRT", + label="From BSRT", ) ax.errorbar( @@ -1151,7 +1151,7 @@ def _plot_emittances(directory, beam, plane, emittance_df, emittance_bws_df, kic if emittance_bws_df is not None and len(emittance_bws_df.index): for d in BWS_DIRECTIONS: - label = "__nolegend__" if d == BWS_DIRECTIONS[1] else f"From BWS" + label = "__nolegend__" if d == BWS_DIRECTIONS[1] else "From BWS" color = ( bws_color if d == BWS_DIRECTIONS[1] @@ -1222,7 +1222,7 @@ def _plot_da_fit(directory, beam, plane, k_df, fit_type): yerr=intensity_err, marker=".", color=colors.get_mpl_color(0), - label=f"Kicks", + label="Kicks", ) # Plot Fit diff --git a/pylhc/kickgroups.py b/pylhc/kickgroups.py index 6d2d184..fa42f1b 100644 --- a/pylhc/kickgroups.py +++ b/pylhc/kickgroups.py @@ -133,7 +133,7 @@ def list_available_kickgroups(by: str = TIMESTAMP, root: Union[Path, str] = KICK df_info = df_info.sort_values(by=by).set_index(TIMESTAMP) if printout: - LOG.debug(f"Here is information about the loaded KickGroups") + LOG.debug("Here is information about the loaded KickGroups") print(df_info.to_string(index=False, formatters=_time_formatters(), justify="center")) return df_info @@ -228,7 +228,7 @@ def load_kickfile(kickfile: Union[Path, str]) -> pd.Series: data[AMPY] = kick["excitationSettings"][0]["acDipoleSettings"][idy]["amplitude"] data[AMPZ] = kick["excitationSettings"][0]["longitudinalRfSettings"]["excitationAmplitude"] else: - LOG.debug(f"Kick is 2D Excitation, longitudinal settings will be set as NaNs") + LOG.debug("Kick is 2D Excitation, longitudinal settings will be set as NaNs") idx = _get_plane_index(kick["excitationSettings"], "X") idy = _get_plane_index(kick["excitationSettings"], "Y") diff --git a/pylhc/lsa_to_madx.py b/pylhc/lsa_to_madx.py index c02b62a..c4b4fc1 100644 --- a/pylhc/lsa_to_madx.py +++ b/pylhc/lsa_to_madx.py @@ -323,7 +323,7 @@ def main(): exit(1) if options.knobs and options.file: - LOG.error(f"Either provide knobs at the command line or from a text file, but not both") + LOG.error("Either provide knobs at the command line or from a text file, but not both") exit(1) if options.file and Path(options.file).is_file(): From 150c09bbd6aaf00f3877204c2660cf7d007a9fb6 Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Mon, 12 Aug 2024 15:46:49 +0200 Subject: [PATCH 09/10] update authors metadata as discussed --- pyproject.toml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0203092..e695814 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,11 +20,7 @@ name = "pylhc" readme = "README.md" description = "An accelerator physics script collection for the OMC team at CERN." authors = [ - {name = "PyLHC", email = "pylhc@github.com"}, - {name = "Joschua Dilly", email = "joschua.dilly@cern.ch"}, - {name = "Felix Soubelet", email = "felix.soubelet@cern.ch"}, - {name = "Michael Hofer"}, - {name = "Yngve Levinsen"}, + {name = "OMC Team", email = "pylhc@github.com"}, # see zenodo file / commits for details ] license = "MIT" dynamic = ["version"] From a472f5f584f533d3e3f157ca324a9670f111b12f Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Tue, 13 Aug 2024 15:24:27 +0200 Subject: [PATCH 10/10] do not need pytables and h5py since 0.8.0, removed --- pyproject.toml | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e695814..2a62fe5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,40 +43,38 @@ classifiers = [ ] dependencies = [ - "numpy >= 1.24", - "scipy >= 1.10", - "pandas >= 2.1", - "matplotlib >= 3.8", - "tfs-pandas >= 3.8", - "generic-parser >= 1.1", - "parse >= 1.15", - "omc3 >= 0.15", - "jpype1 >= 1.3", - "h5py >= 2.9.0", # same as tfs-pandas, do we need it here? - "tables >= 3.6.0", # same as tfs-pandas, do we need it here? + "numpy >= 1.24", + "scipy >= 1.10", + "pandas >= 2.1", + "matplotlib >= 3.8", + "tfs-pandas >= 3.8", + "generic-parser >= 1.1", + "parse >= 1.15", + "omc3 >= 0.15", + "jpype1 >= 1.3", ] [project.optional-dependencies] cern = [ - "omc3[cern] >= 0.15", - "pjlsa >= 0.2", - "pytimber >= 3.0", # NXCALS support - "pyjapc", + "omc3[cern] >= 0.15", + "pjlsa >= 0.2", + "pytimber >= 3.0", # NXCALS support + "pyjapc", ] test = [ - "pytest>=7.0", - "pytest-cov>=2.9", - "pytest-mpl>=0.15", + "pytest>=7.0", + "pytest-cov>=2.9", + "pytest-mpl>=0.15", ] doc = [ - "sphinx >= 7.0", - "sphinx_rtd_theme >= 2.0", + "sphinx >= 7.0", + "sphinx_rtd_theme >= 2.0", ] all = [ - "pylhc[cern]", - "pylhc[test]", - "pylhc[doc]", + "pylhc[cern]", + "pylhc[test]", + "pylhc[doc]", ] [project.urls]