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

Updated install instructions #2

Merged
merged 6 commits into from
Sep 12, 2023
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
21 changes: 15 additions & 6 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ jobs:

- name: install apt dependencies
run: |
sudo apt update
sudo apt-get update
# gfortran ... currently for mad-ng gtpsa library
sudo apt install g++ gfortran cmake make bison flex libarmadillo-dev
sudo apt-get install g++ gfortran cmake make bison flex libarmadillo-dev
# deliberatly only installing a subset of boost
sudo apt install libboost-chrono-dev libboost-thread-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev libboost-test-dev
# for building the python interface ... hopefully python3-xarray is not needed this rather heavy
sudo apt install pybind11-dev python3-pytest python3-pip python3-pybind11 # python3-xarray
sudo apt-get install libboost-chrono-dev libboost-thread-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev libboost-test-dev
# for building the python interface ... hopefully python3-xarray is not needed this is rather heavy
sudo apt-get install pybind11-dev python3-pytest python3-pip python3-pybind11

- name: Configure cmake for gtpsa-cpp
run: cmake gtpsa-cpp -B ${{github.workspace}}/gtpsa-cpp/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
Expand Down Expand Up @@ -82,5 +82,14 @@ jobs:
- name : thor-scsi-lib build and install python package
run: gtpsa_PREFIX=/usr/local thor_scsi_PREFIX=/usr/local pip3 install -v ./python/

- name: install apt test dependencies
run: |
# xarray are heavy packages ... deliberatley only installed here
# as required for the tests
sudo apt-get install python3-pandas python3-scipy python3-xarray

- name : thor-scsi-lib test python package
run: pytest-3 python
# consider removing tests ....
# so more tests will be run
# bba_test needs scikit-learn ... don't want to blow that image
run: pytest-3 python/tests/
29 changes: 8 additions & 21 deletions install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ python wrapper.
Dependencies
------------

- `gtpsa-cpp` provided by https://github.com/hz-b/gtpsa-cpp.git

- modern c++ compiler C++17 or better

- std::shared_ptr
Expand All @@ -26,6 +28,7 @@ Dependencies

- flex and bison


- modern python3

Packages to be installed on Ubuntu 22 LTS
Expand All @@ -52,7 +55,7 @@ First clone the repository using

.. code:: shell

git clone https://github.com/jbengtsson/thor-scsi-lib.git
git clone https://github.com/hz-b/thor-scsi-lib.git


change to the directory (persumably) `thor-scsi-lib`.
Expand All @@ -63,16 +66,14 @@ Then initialise submodules using the following command

git submodule update --init

*NB*: this command currently will pull a subrepository (`cmake4epics`).
This repository currently does not support (llvm/clang). Thus build on
MAC currently fails. A fix is currently worked on.



Getting ready to build
----------------------

create a directory "build"
Please install first gtpsa-cpp. Have a look to the installation
instructions provided there.

Create a directory "build"

.. code:: shell

Expand Down Expand Up @@ -144,20 +145,6 @@ python install procedure.
Before you can use this script, you need to build the c++ library and install it
to some path (called `/path/to/install/to` above).

Directories with python modules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Two python modules are provided

* gtpsa: directory src/gtpsa/python
* thor_scsi: directory python/

Recommandation is to first build gtpsa and then thor scsi.
The description below refers to both of them. Both directories are
refered to as `python` directory below.

Installation instruction for one of the packages
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The process of building the python package depends on the C++ headers and libraries.
Thus it needs to know where these are installed. The process described below will
Expand Down
32 changes: 0 additions & 32 deletions python/examples/mat_test.py

This file was deleted.

2 changes: 2 additions & 0 deletions python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Using PyBind11Extension
pybind11>=2.6.0
gtpsa
pandas
6 changes: 3 additions & 3 deletions python/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = thor_scsi
version = 0.0.0
version = 0.0.2
url = https://github.com/jbengtson/thor-scsi-lib/
author = Johan Bengtsson, Pierre Schnizer
author_email = johan.bengtsson@helmholtz-berlin.de
Expand All @@ -23,6 +23,6 @@ requires = setup_tools

[build_sphinx]
project = 'thor_scsi'
version = 0.0.0
release = 0.0.0
version = 0.0.2
release = 0.0.2
# source-dir = 'doc'
17 changes: 9 additions & 8 deletions python/tests/knobbable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dataclasses import dataclass
import numpy as np

@pytest.mark.skip
#@pytest.mark.skip
def test_knob_quadrupole():
length = 0.2
K = 1.2
Expand All @@ -28,7 +28,6 @@ def test_knob_quadrupole():
assert K_check == pytest.approx(K, rel=1e-12)


@pytest.mark.skip
def test_knob_horizontal_steerer():
length = 0.0
K = 0.1
Expand All @@ -51,7 +50,7 @@ def test_knob_horizontal_steerer():
knobs.make_magnet_knobbable(nh_st, po=1, desc=desc, named_index=named_index)


@pytest.mark.skip
#@pytest.mark.skip
def test_knob_vertical_steerer():
length = 0.0
K = 0.2
Expand Down Expand Up @@ -90,7 +89,6 @@ def analytic_x(*, K, length):
return RMatrix(m11=m11, m12=m12, m21=m21, m22=m22)


# @pytest.mark.skip
def test_quadrupole_dependence_on_offset():
"""check that the parameter dependence on dx works as expected

Expand Down Expand Up @@ -136,12 +134,16 @@ def test_quadrupole_dependence_on_offset():
{r_analytic.m21}, {r_analytic.m22}
"""
print("analytic\n", txt)

for a_tpsa in [ps.x, ps.px]:
print(gtpsa.utils_df.tpsa2df(a_tpsa))

# assert ps.x.get(dx=1) == pytest.approx(expected_dx_dependence, rel=1e-12)
# fmt: on
assert ps.x.get(x=1) == pytest.approx(r_analytic.m11, rel=1e-3)
assert ps.x.get(dx=1) == pytest.approx(r_analytic.m12, rel=1e-3)
assert ps.dx.get(x=1) == pytest.approx(r_analytic.m21, rel=1e-3)
assert ps.dx.get(dx=1) == pytest.approx(r_analytic.m21, rel=1e-3)
assert ps.x.get(px=1) == pytest.approx(r_analytic.m12, rel=1e-2)
assert ps.px.get(x=1) == pytest.approx(r_analytic.m21, rel=1e-2)
assert ps.px.get(px=1) == pytest.approx(r_analytic.m22, rel=1e-2)
# fmt: off

# Estimate effect based on propagation
Expand All @@ -153,4 +155,3 @@ def test_quadrupole_dependence_on_offset():
ps.set_zero()
quad.propagate(calc_config, ps)
print(ps.x, ps.px)
assert False