Skip to content

Add example notebook on implementing custom elements to documentation - #522

Merged
jank324 merged 21 commits into
masterfrom
396-add-example-on-how-to-implement-custom-elements
Jul 17, 2026
Merged

Add example notebook on implementing custom elements to documentation#522
jank324 merged 21 commits into
masterfrom
396-add-example-on-how-to-implement-custom-elements

Conversation

@jank324

@jank324 jank324 commented Jul 24, 2025

Copy link
Copy Markdown
Member

Description

Add a notebook that guides people along the implementation of new elements in Cheetah.

Motivation and Context

  • I have raised an issue to propose this change (required for new features and bug fixes)

Closes #396.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

Checklist

  • I have updated the changelog accordingly (required).
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.
  • I have reformatted the code and checked that formatting passes (required).
  • I have have fixed all issues found by flake8 (required).
  • I have ensured that all pytest tests pass (required).
  • I have run pytest on a machine with a CUDA GPU and made sure all tests pass (required).
  • I have checked that the documentation builds (required).

Note: We are using a maximum length of 88 characters per line.

@jank324 jank324 linked an issue Jul 24, 2025 that may be closed by this pull request
@jank324 jank324 self-assigned this Jul 24, 2025
@jank324 jank324 added the documentation Improvements or additions to documentation label Jul 24, 2025
@jank324
jank324 requested review from Hespe and Copilot July 24, 2025 15:39
@jank324
jank324 marked this pull request as ready for review July 24, 2025 15:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive documentation for implementing custom elements in the Cheetah accelerator physics library. The documentation consists of a Jupyter notebook that provides detailed guidance on extending Cheetah with user-defined elements.

  • Adds a complete tutorial notebook showing how to subclass the Element base class
  • Provides extensive code examples with TODO comments explaining each implementation step
  • Includes guidelines for contributing new elements back to the main repository

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
docs/index.rst Adds the new custom elements example to the documentation table of contents
docs/examples/custom_elements.ipynb Complete tutorial notebook with detailed implementation guidance and code templates
CHANGELOG.md Documents the addition of the new example notebook
.vscode/ltex.dictionary.en-GB.txt Adds "subclassing" to the spell-check dictionary

Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb Outdated
@jank324

jank324 commented Jul 24, 2025

Copy link
Copy Markdown
Member Author

@Hespe, when you review this, can you check the result in the built documentation. Can you also check if this matches the current version of Cheetah? I modelled this after when we did in #406.

I'm not sure if we should go ahead and merge this PR when it's ready, or wait for #476, because that will change some things.

Anyways, @frankmayet can have a look at this already.

@Hespe

Hespe commented Jul 25, 2025

Copy link
Copy Markdown
Member

Notebooks on readthedocs don't seem to use the full screen width. Of course you can scroll horizontally, but this makes the docstrings anoying to read:

grafik

Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb
Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb
Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb Outdated
@Hespe

Hespe commented Jul 25, 2025

Copy link
Copy Markdown
Member

I'm not sure if we should go ahead and merge this PR when it's ready, or wait for #476, because that will change some things.

I would be in favour of merging #476 first. Otherwise, I think its likely that we will not update this example soon enough. If we merge this PR first, #476 should in best case also update the example.

@jank324

jank324 commented Aug 4, 2025

Copy link
Copy Markdown
Member Author

I'm not sure if we should go ahead and merge this PR when it's ready, or wait for #476, because that will change some things.

I would be in favour of merging #476 first. Otherwise, I think its likely that we will not update this example soon enough. If we merge this PR first, #476 should in best case also update the example.

Seconded!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb Outdated
Comment thread docs/examples/custom_elements.ipynb Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
jank324 and others added 2 commits July 3, 2026 13:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@jank324
jank324 requested a review from Hespe July 3, 2026 11:24
@jank324

jank324 commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

@Hespe, small reminder.

@Hespe Hespe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me. However, the example did not talk at all about serialization and converters. I think we should at least mention that.

@jank324

jank324 commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

Looks mostly good to me. However, the example did not talk at all about serialization and converters. I think we should at least mention that.

Like the latest revision?

@Hespe

Hespe commented Jul 17, 2026

Copy link
Copy Markdown
Member

Looks mostly good to me. However, the example did not talk at all about serialization and converters. I think we should at least mention that.

Like the latest revision?

Yes, but the formatting is not consistent with the rest of the document. They are the only bold headers throughout.

@jank324

jank324 commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

Looks mostly good to me. However, the example did not talk at all about serialization and converters. I think we should at least mention that.

Like the latest revision?

Yes, but the formatting is not consistent with the rest of the document. They are the only bold headers throughout.

Now it matches?

@jank324
jank324 merged commit fdb0fa2 into master Jul 17, 2026
10 checks passed
@jank324
jank324 deleted the 396-add-example-on-how-to-implement-custom-elements branch July 17, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add example on how to implement custom elements

3 participants