Skip to content

Commit

Permalink
Merge pull request #144 from wright-group/workup_units
Browse files Browse the repository at this point in the history
Actually use the units in attune.intensity
  • Loading branch information
kameyer226 committed Oct 21, 2021
2 parents 8387518 + 454e598 commit db3093c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
## [Unreleased]

### Fixed
- Units on attune.intensity are set according to the axis they are referencing
- Resolve some issues discovered by CodeQL which could result in unexpected behavior

## [0.4.3]
Expand Down
9 changes: 8 additions & 1 deletion attune/_intensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ def intensity(
units = None

if instrument is not None:
# Note, assumes units can be converted here... which I hope so
if units is not None:
offsets = wt.units.convert(
offsets,
units,
old_instrument["arrangements"][arrangement]["tunes"][tune]["dep_units"],
)
old_instrument["arrangements"][arrangement]["tunes"][tune]["independent"] = setpoints
old_instrument["arrangements"][arrangement]["tunes"][tune]["dependent"] += offsets
try:
Expand All @@ -139,7 +146,7 @@ def intensity(
pass
new_instrument = Instrument(**old_instrument, transition=transition)
else:
arr = Arrangement(arrangement, {tune: Tune(setpoints, offsets)})
arr = Arrangement(arrangement, {tune: Tune(setpoints, offsets, dep_units=units)})
new_instrument = Instrument(
{arrangement: arr}, {tune: Setable(tune)}, transition=transition
)
Expand Down

0 comments on commit db3093c

Please sign in to comment.