-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add rename_dependent function * Blacken * Simplify rename, add tests for behavior
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import attune | ||
import numpy as np | ||
import pytest | ||
|
||
|
||
def test_rename(): | ||
d = attune.Dependent(np.linspace(0, 10, 21), "d1") | ||
s = attune.Setpoints(np.linspace(120, 240, 21), "s1") | ||
c = attune.Curve(s, d, "c") | ||
|
||
c.rename_dependent("d1", "d2") | ||
|
||
assert "d2" in c.dependents | ||
assert "d1" not in c.dependents | ||
assert np.allclose(c["d2"][:], d[:]) | ||
assert c["d2"].name == "d2" | ||
|
||
|
||
def test_rename_not_present(): | ||
d = attune.Dependent(np.linspace(0, 10, 21), "d1") | ||
s = attune.Setpoints(np.linspace(120, 240, 21), "s1") | ||
c = attune.Curve(s, d, "c") | ||
|
||
with pytest.raises(ValueError): | ||
c.rename_dependent("d2", "d1") |