Skip to content

Commit b7a9d28

Browse files
authored
Removes replication in tutorial and adds workflow dispatch to build action (#45)
1 parent ba89e2b commit b7a9d28

File tree

5 files changed

+25
-167
lines changed

5 files changed

+25
-167
lines changed

.github/workflows/build_docs.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: 'Version to build (default: dev)'
12+
default: 'dev'
813

914
jobs:
1015
build:
1116
env:
1217
RAT_URL: "https://rascalsoftware.github.io/RAT-Docs/"
13-
RAT_VERSION: "dev"
18+
RAT_VERSION: "${{ github.event.inputs.version }}"
1419
runs-on: Linux
1520

1621
steps:
@@ -26,14 +31,23 @@ jobs:
2631
export DISPLAY=':99.0'
2732
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
2833
29-
wget https://github.com/RascalSoftware/RAT/releases/download/nightly/Linux.zip
34+
VERSION=${RAT_VERSION:-"dev"}
35+
36+
python -m pip install --upgrade pip
37+
if [ ${VERSION} == 'dev' ]; then
38+
wget https://github.com/RascalSoftware/RAT/releases/download/nightly/Linux.zip
39+
pip install RATapi
40+
else
41+
wget "https://github.com/RascalSoftware/RAT/releases/download/${VERSION}/Linux.zip"
42+
pip install RATapi==${VERSION} || pip install RATapi
43+
fi
3044
unzip Linux.zip -d API/
3145
rm API/utilities/mockFunction.m # as otherwise the MATLAB reference fails to parse it
3246
3347
# we get pandoc from web as apt version is outdated
3448
wget https://github.com/jgm/pandoc/releases/download/3.6.2/pandoc-3.6.2-1-amd64.deb
3549
sudo apt install -y ./pandoc-3.6.2-1-amd64.deb
36-
python -m pip install --upgrade pip
50+
3751
pip install matlabengine==24.1.*
3852
pip install -r requirements.txt
3953
python build_docs.py

.github/workflows/deploy_docs.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ sphinx_design==0.6.0
55
sphinx-copybutton==0.5.2
66
jupyter==1.0.0
77
nbsphinx==0.9.6
8-
RATapi==0.0.0.dev4
98
autodoc_pydantic==2.2.0
109
enum-tools[sphinx]==0.12.0

source/tutorial/introduction.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,22 @@ The code block below shows how to set up each object for each language, as well
4444
.. tab-set-code::
4545
.. code-block:: Matlab
4646
47-
% to create a project and controls:
47+
% Create project and controls objects
4848
project = projectClass();
4949
controls = controlsClass();
5050
51-
% to run:
51+
% Run after populating the project
5252
[project, results] = RAT(project, controls);
5353
5454
.. code-block:: Python
5555
5656
import RATapi as RAT
5757
58-
# to create a project and controls:
58+
# Create project and controls objects
5959
project = RAT.Project()
6060
controls = RAT.Controls()
6161
62-
# to run:
62+
# Run after populating the project
6363
project, results = RAT.run(project, controls)
6464
6565

source/tutorial/project.rst

Lines changed: 4 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -11,112 +11,9 @@ once our model is defined, we can interact with it in various ways without needi
1111
So we can try out different types of analysis and explore the landscape of solutions
1212
by simply modifying the **Controls** object, leaving the **Project** object alone.
1313

14-
As well as having two inputs, RAT always provides two outputs, so the call to the toolbox is always of this form:
15-
16-
.. tab-set-code::
17-
.. code-block:: Matlab
18-
19-
[problem, results] = RAT(problem, controls)
20-
21-
.. code-block:: Python
22-
23-
problem, results = RAT.run(problem, controls)
24-
25-
26-
In this case we have called our inputs ``problem`` and ``controls``, and we have called our outputs ``problem`` and ``results``,
27-
but we are free to call them anything we like. We will look at the outputs in more detail in the next section.
28-
29-
The first input, ``problem``, is an instance of the **Project** class:
30-
31-
.. tab-set-code::
32-
.. code-block:: Matlab
33-
34-
>> empty_problem = createProject(name='my project');
35-
>> class(empty_problem)
36-
37-
ans =
38-
'projectClass'
39-
40-
.. code-block:: Python
41-
:force:
42-
43-
>>> empty_problem = RAT.Project(name='my project')
44-
>>> type(empty_problem)
45-
46-
<class 'RAT.project.Project'>
47-
48-
The structure of the class is a collection of settings and tables defining things like calculation type,
49-
model type, parameters, data, contrasts, and so on. These define all we need for our analysis.
50-
51-
.. tab-set::
52-
:class: tab-label-hidden
53-
:sync-group: code
54-
55-
.. tab-item:: Matlab
56-
:sync: Matlab
57-
58-
.. output:: Matlab
59-
60-
empty_problem = createProject(name='my project');
61-
disp(empty_problem)
62-
63-
.. tab-item:: Python
64-
:sync: Python
65-
66-
.. output:: Python
67-
68-
empty_problem = RAT.Project(name='my project')
69-
print(empty_problem)
70-
71-
In the following sections, we will look at how to build a standard layer slab model with this class. It is also
14+
In the following sections, we will look at how to build a standard layer slab model with the **Project** class. It is also
7215
possible to define a custom model using a function; this is seen in the :ref:`customModels` tutorial.
7316

74-
.. note::
75-
If you have a model from RasCAL-1, this model can be imported as a RAT project. See the following example
76-
pages for how to do this in :ref:`MATLAB<convertR1Matlab>` and :ref:`Python<convert_rascalIPYNB>`.
77-
78-
79-
When we run RAT, the first of the two outputs is another **Project**, but updated with the results of the calculation.
80-
So, if we run a fit, the fitted parameters will be updated with the best fit values of our procedure.
81-
82-
.. tab-set-code::
83-
.. code-block:: Matlab
84-
85-
[outputProblem, results] = RAT(problem, controls);
86-
87-
.. code-block:: Python
88-
89-
output_problem, results = RAT.run(problem, controls)
90-
91-
The second output is a class containing the simulated reflectivities, SLDs and so on
92-
using the parameters from the procedure given in the **Controls** object:
93-
94-
.. tab-set::
95-
:class: tab-label-hidden
96-
:sync-group: code
97-
98-
.. tab-item:: Matlab
99-
:sync: Matlab
100-
101-
.. output:: Matlab
102-
103-
controls = controlsClass;
104-
controls.display = 'off';
105-
[~, ~, results] = evalc('RAT(load("source/tutorial/data/twoContrastExample.mat").problem, controls);');
106-
disp(results)
107-
108-
.. tab-item:: Python
109-
:sync: Python
110-
111-
.. output:: Python
112-
113-
controls = RAT.Controls(display='off')
114-
problem = RAT.Project.load("source/tutorial/data/two_contrast_example.json")
115-
p, results = RAT.run(problem, controls)
116-
print(results)
117-
118-
In the following sections, we will discuss the methods of the **Project** class, and see how they allow us to build up a model by populating the various sections.
119-
12017
***********************************
12118
The Components of the Project Class
12219
***********************************
@@ -1314,14 +1211,15 @@ Now we'll calculate this to check the agreement with the data. We need an instan
13141211

13151212
.. output:: Matlab
13161213

1317-
controls.display = 'iter';
1214+
controls = controlsClass();
13181215
disp(controls)
13191216

13201217
.. tab-item:: Python
13211218
:sync: Python
13221219

13231220
.. output:: Python
1324-
1221+
1222+
controls = RAT.Controls()
13251223
print(controls)
13261224

13271225
We then send all of this to RAT, and plot the output:

0 commit comments

Comments
 (0)