-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve addition for snowpack and atmosphere. The order of the additi…
…on is important and checked more carefully.
- Loading branch information
Showing
2 changed files
with
29 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
|
||
|
||
from .error import SMRTError | ||
from .snowpack import Snowpack | ||
|
||
|
||
# this is a temporary solution to deal with Atmosphere. | ||
# user should not rely on this object. For temporary internal use only !! | ||
|
||
class AtmosphereBase(object): | ||
# has no special properties yet, we just use the type. | ||
pass | ||
|
||
def __add__(self, other): | ||
"""Return a new snowpack made by setting the atmosphere | ||
:param other: the snowpack to add. | ||
""" | ||
|
||
if not isinstance(other, Snowpack): | ||
raise SMRTError("Attempt to add an incorrect object to an atmopsher. Only adding an atmosphere and a snowpack (in that order)" | ||
" is a valid operation.") | ||
|
||
return Snowpack(layers=other.layers, | ||
interfaces=other.interfaces, | ||
substrate=other.substrate, | ||
atmosphere=self) | ||
|
||
def __iadd__(self, other): | ||
raise SMRTError("Inplace addition with an atmosphere is not a valid operation.") |
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