-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #520 from riclarsson/copy-workspace
Beginning to deepcopy workspace
- Loading branch information
Showing
9 changed files
with
227 additions
and
2 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,52 @@ | ||
""" | ||
Test handling of workspace of the Python interface. | ||
""" | ||
import copy | ||
import pytest | ||
import pyarts | ||
from pyarts.workspace import Workspace, arts_agenda | ||
from pyarts.arts import Index | ||
|
||
class TestWorkspace: | ||
def setup_method(self): | ||
pass | ||
|
||
def test_copy(self): | ||
ws = Workspace() | ||
ws.aaavar = Index(5) | ||
|
||
ws2 = copy.copy(ws) | ||
ws2.aaavar = 6 | ||
|
||
assert ws2.aaavar.value == ws.aaavar.value | ||
|
||
def test_deepcopy(self): | ||
ws = Workspace() | ||
ws.aaavar = Index(5) | ||
|
||
ws2 = copy.deepcopy(ws) | ||
ws2.aaavar = 6 | ||
|
||
assert ws2.aaavar.value != ws.aaavar.value | ||
|
||
def test_copy_agenda(self): | ||
ws = Workspace() | ||
ws.aaavar = Index(5) | ||
|
||
@arts_agenda(ws=ws, set_agenda=True) | ||
def test_agenda(ws): | ||
ws.Print(ws.aaavar, 0) | ||
ws.AgendaExecute(ws.test_agenda) | ||
|
||
ws2 = copy.deepcopy(ws) | ||
ws2.aaavar = 4 | ||
ws2.AgendaExecute(ws2.test_agenda) | ||
|
||
|
||
if __name__ == "__main__": | ||
ta = TestWorkspace() | ||
ta.setup_method() | ||
ta.test_copy() | ||
ta.test_deepcopy() | ||
ta.test_copy_agenda() | ||
|
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
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
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
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