Skip to content

Add transparent state to energy specific attenuation - #2248

Merged
CoePaul merged 4 commits into
mainfrom
dodal_2123_transp
Nov 17, 2026
Merged

CoePaul merged 4 commits into
mainfrom
dodal_2123_transp

Conversation

@CoePaul

@CoePaul CoePaul commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Several small updates for i19 attenuation

Contributes towards #2123

Namely:

  • The natural constant for transparency (ie 'not attenuating')
    is hereby included in the energy_specific_attenuation pairing class

  • String preparation of the message in a raised error was simplified
    (to drop declaring a local string variable before raising)

  • Improvement of checking energy suitability of a given absorber material:
    The spectrally modelled absorption - of a given material - only covers
    certain energy ranges and this code update improves the checking
    relating to energy eligibility, there's also a specific error type for energy ineligibility.

  • FloatInterval maths is extended
    a DirectedSegment is introduced ( since the interval types always go from a lower to upper value )
    allowing for the start to end ( of a segment ) to face in either direction
    Without this it's very awkward to use segment / interval types for bidirectional mapping
    between y and x via relations of the form y = mx + c

    But once we have the DirectedSegment type, not only is bidirectional mapping
    made simplier, but parameterised mapping to (and from) a 0 to 1 fractional range is also
    simple. This is particularly useful for mapping from lateral-position to thickness to absorption
    in a wedge absorber

Instructions to reviewer on how to test:

  1. Ensure variable names and added logic make sense / are readable
  2. Confirm linter happy and tests pass
  3. Suggest any missing tests if You feel these are warranted

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

@CoePaul
CoePaul requested a review from a team as a code owner October 26, 2026 12:27
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.31%. Comparing base (5da0183) to head (1c5f3af).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2248   +/-   ##
=======================================
  Coverage   99.30%   99.31%           
=======================================
  Files         379      379           
  Lines       14892    14941   +49     
=======================================
+ Hits        14789    14838   +49     
  Misses        103      103           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CoePaul
CoePaul force-pushed the dodal_2123_transp branch 3 times, most recently from 986fba6 to eb4edf4 Compare November 3, 2026 18:37
@CoePaul CoePaul self-assigned this Nov 3, 2026
@CoePaul CoePaul added python Pull requests that update Python code i19-1 i19-2 labels Nov 3, 2026
@CoePaul
CoePaul force-pushed the dodal_2123_transp branch 2 times, most recently from 7d50c3c to 755ccfb Compare November 6, 2026 22:51
The natural constant for not attenuating is hereby included in the energy_specific_attenuation pairing class
Raise error without predefining message string
* Widen use of dunder contains to ask if an energy lies inside
  a modelled absorption spectrum (or does not)

* Adjust affected production classes and tests
* Add span to provide interval length

* Add directed segment, an interval with directional sense
  - these can be used to perform 1:1 bidirectional mappings
    via y=mx+c style "straight" line mappings x <--> y

* Add parametric interpolation / extrapolation
  - whereby a fraction 0 to 1 runs along the interval
    (or, when strict interpolation mode is false,
     outside values are reached by fractions
     outside the 0 to 1 range)

* Tighten type checking for args of the FloatInterval dunder contains method
  - Motive
   Any check reporting the bool answer to
    Q: 'does this specific real number lies within this FloatInterval?'
   should not have to handle str or bool as spurious input arg types,
   henceforce they are excluded explicitly

   So this change will tighten up the checks

* Add tests to cover new tighter type checking
@CoePaul
CoePaul merged commit f556fea into main Nov 17, 2026
11 checks passed
@CoePaul
CoePaul deleted the dodal_2123_transp branch November 17, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i19-1 i19-2 python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants