From 15ca7d5b16b58bde115423dc4fb645a3fb7afd61 Mon Sep 17 00:00:00 2001 From: Stephen Nneji Date: Wed, 30 Jul 2025 13:48:18 +0100 Subject: [PATCH 1/2] Renames RATapi to ratapi --- .github/workflows/build_docs.yml | 4 ++-- .gitignore | 2 +- source/_ext/snippets.py | 6 +++--- source/advanced/events.rst | 4 ++-- source/calcTypes/data/domains_example.py | 2 +- source/conf.py | 16 ++++++++-------- source/install.rst | 4 ++-- source/reference/python/classlist.rst | 2 +- source/reference/python/controls.rst | 2 +- source/reference/python/core.rst | 2 +- source/reference/python/enums.rst | 4 ++-- source/reference/python/events.rst | 2 +- source/reference/python/examples.rst | 2 +- source/reference/python/inputs.rst | 2 +- source/reference/python/models.rst | 2 +- source/reference/python/outputs.rst | 2 +- source/reference/python/plotting.rst | 4 ++-- source/reference/python/project.rst | 2 +- source/reference/python/run.rst | 2 +- source/reference/python/wrappers.rst | 2 +- source/tutorial/introduction.rst | 4 ++-- source/tutorial/project.rst | 4 ++-- source/utilities/conversionFuncs.rst | 6 +++--- 23 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index aeae5e5e..9b36cdba 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -36,10 +36,10 @@ jobs: python -m pip install --upgrade pip if [ ${VERSION} == 'dev' ]; then wget https://github.com/RascalSoftware/RAT/releases/download/nightly/Linux.zip - pip install RATapi + pip install ratapi --upgrade else wget "https://github.com/RascalSoftware/RAT/releases/download/${VERSION}/Linux.zip" - pip install RATapi==${VERSION} || pip install RATapi + pip install ratapi==${VERSION} || pip install ratapi --upgrade fi unzip Linux.zip -d API/ rm API/utilities/mockFunction.m # as otherwise the MATLAB reference fails to parse it diff --git a/.gitignore b/.gitignore index 73092706..170894d6 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,7 @@ source/_outputs/ .envrc # autogenerated documentation -source/reference/python/RATapi.* +source/reference/python/ratapi.* source/python_examples/data/ source/matlab_examples/*.html source/python_examples/notebooks/* diff --git a/source/_ext/snippets.py b/source/_ext/snippets.py index 43e404d5..353d7ae4 100644 --- a/source/_ext/snippets.py +++ b/source/_ext/snippets.py @@ -5,7 +5,7 @@ from docutils import nodes -import RATapi +import ratapi from sphinx.application import Sphinx from sphinx.util.docutils import SphinxDirective @@ -44,7 +44,7 @@ def setup(app: Sphinx) -> ExtensionMetadata: def setup_envs(*ignore): """Initialise Python/MATLAB environments.""" - app.env.snippets_env = {"RAT": RATapi} + app.env.snippets_env = {"RAT": ratapi} app.env.matlab_engine = setup_matlab() app.env.matlab_engine.eval( "cd('API'); addPaths; cd('..'); ratVars = who;", nargout=0 @@ -52,7 +52,7 @@ def setup_envs(*ignore): def clear_envs(*ignore): """Clear Python/MATLAB environments from the build environment.""" - app.env.snippets_env = {"RAT": RATapi} + app.env.snippets_env = {"RAT": ratapi} app.env.matlab_engine.eval( r"clearvars('-except', 'ratVars', ratVars{:});", nargout=0 ) diff --git a/source/advanced/events.rst b/source/advanced/events.rst index 7c124ef2..3f910c4c 100644 --- a/source/advanced/events.rst +++ b/source/advanced/events.rst @@ -19,7 +19,7 @@ The example below registers a function to listen for the ``Plot`` event: .. code-block:: Python - import RATapi as RAT + import ratapi as RAT RAT.events.register(RAT.events.EventTypes.Plot, update_plot) The event listener function is also shown below, it uses one of the plot functions provided by RAT to display the event data. The plot event data contains the current state of the reflectivity and SLDs, along with a number of other items which is detailed below. @@ -71,7 +71,7 @@ Register a function as an event listener by providing the event type and the lis .. code-block:: Python - import RATapi as RAT + import ratapi as RAT RAT.events.register(RAT.events.EventTypes.Message, handle_event) # Message Event RAT.events.register(RAT.events.EventTypes.Plot, handle_event) # Plot Event diff --git a/source/calcTypes/data/domains_example.py b/source/calcTypes/data/domains_example.py index 340a2c84..c153089f 100644 --- a/source/calcTypes/data/domains_example.py +++ b/source/calcTypes/data/domains_example.py @@ -1,4 +1,4 @@ -import RATapi as RAT +import ratapi as RAT import numpy as np problem = RAT.Project(calculation='domains') diff --git a/source/conf.py b/source/conf.py index 11bdab68..5907b5b8 100644 --- a/source/conf.py +++ b/source/conf.py @@ -29,8 +29,8 @@ 'Please download and extract the RAT release to the API folder.') sys.path.insert(0, matlab_src_dir) -import RATapi -sys.path.insert(0, os.path.dirname(os.path.abspath(RATapi.__file__))) +import ratapi +sys.path.insert(0, os.path.dirname(os.path.abspath(ratapi.__file__))) project = 'RAT' copyright = u'2022-{}, ISIS Neutron and Muon Source'.format(datetime.date.today().year) author = 'Arwel Hughes, Sethu Pastula, Alex Room, Rabiya Farooq, Paul Sharp, Stephen Nneji' @@ -52,7 +52,7 @@ templates_path = ['_templates'] # -- Setup example files ----------------------------------------------------- -PYTHON_RAT_RELEASE = metadata.version("RATapi") +PYTHON_RAT_RELEASE = metadata.version("ratapi") MATLAB_AVAILABLE = True try: @@ -67,14 +67,14 @@ zf.extractall() print("Copying Jupyter notebooks...") for directory in ['normal_reflectivity', 'domains', 'absorption']: - for file in Path(f"./python-RAT-{PYTHON_RAT_RELEASE}/RATapi/examples/{directory}/").glob('*'): + for file in Path(f"./python-RAT-{PYTHON_RAT_RELEASE}/ratapi/examples/{directory}/").glob('*'): shutil.copy(file, "./python_examples/notebooks/") if MATLAB_AVAILABLE: # convert_rascal example requires matlab engine - for file in Path(f"./python-RAT-{PYTHON_RAT_RELEASE}/RATapi/examples/convert_rascal_project/").glob('*'): + for file in Path(f"./python-RAT-{PYTHON_RAT_RELEASE}/ratapi/examples/convert_rascal_project/").glob('*'): shutil.copy(file, "./python_examples/notebooks/") - shutil.copytree(f"./python-RAT-{PYTHON_RAT_RELEASE}/RATapi/examples/data", "./python_examples/data", dirs_exist_ok=True) + shutil.copytree(f"./python-RAT-{PYTHON_RAT_RELEASE}/ratapi/examples/data", "./python_examples/data", dirs_exist_ok=True) shutil.rmtree(f"./python-RAT-{PYTHON_RAT_RELEASE}") @@ -149,7 +149,7 @@
This page was generated from the notebook {{ env.docname.split('/')|last|e + '.ipynb' }} found in - the Python-RAT repository. + the Python-RAT repository. Download notebook.
@@ -159,7 +159,7 @@ .. code-block:: python - from RATapi.examples import {{ env.docname.split('/')|last|e }} + from ratapi.examples import {{ env.docname.split('/')|last|e }} project, results = {{ env.docname.split('/')|last|e }}() ------------------------------------------------------------------------------------- diff --git a/source/install.rst b/source/install.rst index 17573186..9a5d3b08 100644 --- a/source/install.rst +++ b/source/install.rst @@ -47,7 +47,7 @@ This section provides more detailed information about installing RAT for MATLAB .. code-block:: console - pip install RATapi + pip install ratapi ``matlabengine`` is an optional dependency only required for MATLAB related actions such as running MATLAB custom functions and converting RasCAL-1 projects. The version of ``matlabengine`` must match the version of MATLAB installed on the computer. For example, if MATLAB 2023a is installed on the computer, @@ -55,7 +55,7 @@ This section provides more detailed information about installing RAT for MATLAB .. code-block:: console - pip install RATapi[Matlab-2023a] + pip install ratapi[Matlab-2023a] .. note:: diff --git a/source/reference/python/classlist.rst b/source/reference/python/classlist.rst index dda787e0..783fb13d 100644 --- a/source/reference/python/classlist.rst +++ b/source/reference/python/classlist.rst @@ -1,4 +1,4 @@ ClassList --------- -.. autoclass:: RATapi.ClassList +.. autoclass:: ratapi.ClassList diff --git a/source/reference/python/controls.rst b/source/reference/python/controls.rst index 2b1b8997..25538870 100644 --- a/source/reference/python/controls.rst +++ b/source/reference/python/controls.rst @@ -5,5 +5,5 @@ The ``Controls`` class details control parameters for the RAT run. Note that man specific to certain procedures: the relevant procedure is listed in square brackets before the field description. -.. autopydantic_model:: RATapi.Controls +.. autopydantic_model:: ratapi.Controls :members: diff --git a/source/reference/python/core.rst b/source/reference/python/core.rst index 89dd82f1..f4a4b961 100644 --- a/source/reference/python/core.rst +++ b/source/reference/python/core.rst @@ -4,5 +4,5 @@ RAT Core This module contains the `Pybind11 `_ objects which are used to interface with RAT's C++ code. -.. automodule:: RATapi.rat_core +.. automodule:: ratapi.rat_core :members: diff --git a/source/reference/python/enums.rst b/source/reference/python/enums.rst index 1851b39f..9cb93802 100644 --- a/source/reference/python/enums.rst +++ b/source/reference/python/enums.rst @@ -1,9 +1,9 @@ Enums ----- -This utility module (found in ``RATapi.utils.enums``) contains the Enum objects +This utility module (found in ``ratapi.utils.enums``) contains the Enum objects which are used under the hood to represent arguments given as string options, such as those for control parameters or background types. -.. automodule:: RATapi.utils.enums +.. automodule:: ratapi.utils.enums :members: diff --git a/source/reference/python/events.rst b/source/reference/python/events.rst index c9bc625d..923c7551 100644 --- a/source/reference/python/events.rst +++ b/source/reference/python/events.rst @@ -1,5 +1,5 @@ Events ------ -.. automodule:: RATapi.events +.. automodule:: ratapi.events :members: diff --git a/source/reference/python/examples.rst b/source/reference/python/examples.rst index 3adb0baa..c2071b86 100644 --- a/source/reference/python/examples.rst +++ b/source/reference/python/examples.rst @@ -1,5 +1,5 @@ Examples -------- -.. automodule:: RATapi.examples +.. automodule:: ratapi.examples :members: diff --git a/source/reference/python/inputs.rst b/source/reference/python/inputs.rst index bfa32587..382917bb 100644 --- a/source/reference/python/inputs.rst +++ b/source/reference/python/inputs.rst @@ -4,5 +4,5 @@ Inputs This module contains the objects used to organise input data to RAT to be fed into the C++ module. -.. automodule:: RATapi.inputs +.. automodule:: ratapi.inputs :members: diff --git a/source/reference/python/models.rst b/source/reference/python/models.rst index a8b66b1b..fc28e49d 100644 --- a/source/reference/python/models.rst +++ b/source/reference/python/models.rst @@ -1,7 +1,7 @@ Models ------ -.. automodule:: RATapi.models +.. automodule:: ratapi.models :members: :inherited-members: RATModel :exclude-members: RATModel, Signal diff --git a/source/reference/python/outputs.rst b/source/reference/python/outputs.rst index 29930c70..d0d84484 100644 --- a/source/reference/python/outputs.rst +++ b/source/reference/python/outputs.rst @@ -4,5 +4,5 @@ Outputs This module contains the Results objects and the relevant objects to retrieve results data from the C++ module. -.. automodule:: RATapi.outputs +.. automodule:: ratapi.outputs :members: diff --git a/source/reference/python/plotting.rst b/source/reference/python/plotting.rst index df0d2914..62ce6d01 100644 --- a/source/reference/python/plotting.rst +++ b/source/reference/python/plotting.rst @@ -1,10 +1,10 @@ Plotting -------- -Plotting functionality for RAT results objects is available through the ``RATapi.utils.plotting`` module. +Plotting functionality for RAT results objects is available through the ``ratapi.utils.plotting`` module. .. note: plot_bayes is currently excluded because its docstring is not valid RST! -.. automodule:: RATapi.utils.plotting +.. automodule:: ratapi.utils.plotting :members: :exclude-members: plot_errorbars, plot_ref_sld_helper, assert_bayesian, name_to_index, panel_plot_helper, plot_bayes diff --git a/source/reference/python/project.rst b/source/reference/python/project.rst index 521529d4..19e4d401 100644 --- a/source/reference/python/project.rst +++ b/source/reference/python/project.rst @@ -1,6 +1,6 @@ Project ------- -.. autopydantic_model:: RATapi.Project +.. autopydantic_model:: ratapi.Project :members: diff --git a/source/reference/python/run.rst b/source/reference/python/run.rst index db45a6c1..3c659467 100644 --- a/source/reference/python/run.rst +++ b/source/reference/python/run.rst @@ -3,4 +3,4 @@ Run The core function to run RAT. -.. autofunction:: RATapi.run +.. autofunction:: ratapi.run diff --git a/source/reference/python/wrappers.rst b/source/reference/python/wrappers.rst index 3b76c277..0f58d400 100644 --- a/source/reference/python/wrappers.rst +++ b/source/reference/python/wrappers.rst @@ -4,5 +4,5 @@ Wrappers This module contains the wrappers for interfacing with MATLAB custom functions, such as those for custom layers models or function backgrounds. -.. automodule:: RATapi.wrappers +.. automodule:: ratapi.wrappers :members: diff --git a/source/tutorial/introduction.rst b/source/tutorial/introduction.rst index e293e9a5..1d4552ce 100644 --- a/source/tutorial/introduction.rst +++ b/source/tutorial/introduction.rst @@ -53,7 +53,7 @@ The code block below shows how to set up each object for each language, as well .. code-block:: Python - import RATapi as RAT + import ratapi as RAT # Create project and controls objects project = RAT.Project() @@ -135,7 +135,7 @@ definition and explain what it describes. .. output:: Python - import RATapi as RAT + import ratapi as RAT problem = RAT.Project.load("source/tutorial/data/two_contrast_example.json") print(problem) diff --git a/source/tutorial/project.rst b/source/tutorial/project.rst index 3fbe7bef..f19e1df6 100644 --- a/source/tutorial/project.rst +++ b/source/tutorial/project.rst @@ -853,7 +853,7 @@ and our new dataset appears in the table: from importlib.resources import files import numpy as np - data_path = files("RATapi.examples.data") + data_path = files("ratapi.examples.data") myData = np.loadtxt(data_path / 'c_PLP0016596.dat', delimiter=',') problem.data.append(name='My new datafile', data=myData) print(problem.data) @@ -953,7 +953,7 @@ To start, we first make an instance of the **Project** class: .. code-block:: Python - import RATapi as RAT + import ratapi as RAT problem = RAT.Project(name='DSPC monolayers') Then we need to define the parameters we need. We'll do this by making a parameters block, and adding these to the project: diff --git a/source/utilities/conversionFuncs.rst b/source/utilities/conversionFuncs.rst index e63057f8..2966dccf 100644 --- a/source/utilities/conversionFuncs.rst +++ b/source/utilities/conversionFuncs.rst @@ -28,7 +28,7 @@ To convert this, simply navigate to the project directory, and run the following .. code-block:: Python - from RATapi.utils.convert import r1_to_project_class + from ratapi.utils.convert import r1_to_project_class problem = r1_to_project_class('monolayer_8_contrasts.mat') @@ -45,7 +45,7 @@ This produces a **Project** object containing the R1 project, which can then be .. code-block:: Python - import RATapi as RAT + import ratapi as RAT controls = RAT.Controls(procedure='de', parallel='contrasts') problem, results = RAT.run(problem, controls) @@ -83,7 +83,7 @@ It is also possible to do the opposite conversion, and convert any RAT **Project .. code-block:: Python - from RATapi.utils.convert import project_class_to_r1 + from ratapi.utils.convert import project_class_to_r1 project_class_to_r1(problem, "./testProject/myConvertedProject") From 9f9e9adf8c65e9e9c3e8568724b0d4d7b6eeeaa4 Mon Sep 17 00:00:00 2001 From: Stephen Nneji Date: Wed, 30 Jul 2025 14:24:10 +0100 Subject: [PATCH 2/2] Adds numSimulationPoints description to control page --- source/tutorial/controls.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/tutorial/controls.rst b/source/tutorial/controls.rst index 6b3c3776..8679aa0a 100644 --- a/source/tutorial/controls.rst +++ b/source/tutorial/controls.rst @@ -137,3 +137,6 @@ See the :ref:`resampling page` for more details. In short: - ``resampleNPoints``: The initial number of domain points (layers) sampled by the algorithm at the start. +``numSimulationPoints`` +^^^^^^^^^^^^^^^^^^^^^^^ +The number of points used for a reflectivity simulation where no data is present.