-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement hash methods in C++ (#610)
- Loading branch information
Showing
10 changed files
with
117 additions
and
56 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
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 |
---|---|---|
@@ -1,25 +1,33 @@ | ||
import QuantLib as ql | ||
import unittest | ||
|
||
|
||
class DayCountersTest(unittest.TestCase): | ||
def test_bus252(self): | ||
"""Test Business252 daycounter""" | ||
|
||
calendar = ql.UnitedStates(ql.UnitedStates.GovernmentBond) | ||
|
||
# | ||
# Check that SWIG signature for Business252 calendar allows to | ||
# pass custom calendar into the class constructor. Old | ||
# QuantLib-SWIG versions allow only to create Business252 | ||
# calendar with default constructor parameter (Brazil | ||
# calendar), and generate an exception when trying to pass a | ||
# custom calendar as a parameter. So we just check here that | ||
# no exception occurs. | ||
# | ||
ql.Business252(calendar) | ||
|
||
|
||
if __name__ == "__main__": | ||
print("testing QuantLib", ql.__version__) | ||
unittest.main(verbosity=2) | ||
import QuantLib as ql | ||
import unittest | ||
|
||
|
||
class DayCountersTest(unittest.TestCase): | ||
def test_bus252(self): | ||
"""Test Business252 daycounter""" | ||
|
||
calendar = ql.UnitedStates(ql.UnitedStates.GovernmentBond) | ||
|
||
# | ||
# Check that SWIG signature for Business252 calendar allows to | ||
# pass custom calendar into the class constructor. Old | ||
# QuantLib-SWIG versions allow only to create Business252 | ||
# calendar with default constructor parameter (Brazil | ||
# calendar), and generate an exception when trying to pass a | ||
# custom calendar as a parameter. So we just check here that | ||
# no exception occurs. | ||
# | ||
ql.Business252(calendar) | ||
|
||
def test_hash(self): | ||
for dc1 in (ql.Actual360(), ql.Thirty365()): | ||
for dc2 in (ql.Actual360(), ql.Thirty365()): | ||
expected = dc1.name() == dc2.name() | ||
self.assertEqual(dc1 == dc2, expected) | ||
self.assertEqual(dc1 != dc2, not expected) | ||
self.assertEqual(hash(dc1) == hash(dc2), expected) | ||
|
||
|
||
if __name__ == "__main__": | ||
print("testing QuantLib", ql.__version__) | ||
unittest.main(verbosity=2) |
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