-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shyue Ping Ong
committed
Sep 5, 2023
1 parent
380799b
commit acdfeb4
Showing
9 changed files
with
62 additions
and
68 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,12 +1,11 @@ | ||
from monty.bisect import find_ge, find_gt, find_le, find_lt, index | ||
|
||
|
||
class TestFunc: | ||
def test_funcs(self): | ||
l = [0, 1, 2, 3, 4] | ||
assert index(l, 1) == 1 | ||
assert find_lt(l, 1) == 0 | ||
assert find_gt(l, 1) == 2 | ||
assert find_le(l, 1) == 1 | ||
assert find_ge(l, 2) == 2 | ||
# assert index([0, 1, 1.5, 2], 1.501, atol=0.1) == 4 | ||
def test_funcs(): | ||
l = [0, 1, 2, 3, 4] | ||
assert index(l, 1) == 1 | ||
assert find_lt(l, 1) == 0 | ||
assert find_gt(l, 1) == 2 | ||
assert find_le(l, 1) == 1 | ||
assert find_ge(l, 2) == 2 | ||
# assert index([0, 1, 1.5, 2], 1.501, atol=0.1) == 4 |
Binary file not shown.
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,7 @@ | ||
from monty.fnmatch import WildCard | ||
|
||
|
||
class TestFunc: | ||
def test_match(self): | ||
wc = WildCard("*.pdf") | ||
assert wc.match("A.pdf") | ||
assert not wc.match("A.pdg") | ||
def test_match(): | ||
wc = WildCard("*.pdf") | ||
assert wc.match("A.pdf") | ||
assert not wc.match("A.pdg") |
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,9 +1,9 @@ | ||
from monty.math import nCr, nPr | ||
|
||
|
||
class TestFunc: | ||
def test_nCr(self): | ||
assert nCr(4, 2) == 6 | ||
def test_nCr(): | ||
assert nCr(4, 2) == 6 | ||
|
||
def test_deprecated_property(self): | ||
assert nPr(4, 2) == 12 | ||
|
||
def test_nPr(): | ||
assert nPr(4, 2) == 12 |
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,17 +1,15 @@ | ||
import unittest | ||
from math import sqrt | ||
|
||
from monty.multiprocessing import imap_tqdm | ||
|
||
|
||
class FuncCase(unittest.TestCase): | ||
def test_imap_tqdm(self): | ||
results = imap_tqdm(4, sqrt, range(10000)) | ||
assert len(results) == 10000 | ||
assert results[0] == 0 | ||
assert results[400] == 20 | ||
assert results[9999] == 99.99499987499375 | ||
results = imap_tqdm(4, sqrt, (i**2 for i in range(10000))) | ||
assert len(results) == 10000 | ||
assert results[0] == 0 | ||
assert results[400] == 400 | ||
def test_imap_tqdm(): | ||
results = imap_tqdm(4, sqrt, range(10000)) | ||
assert len(results) == 10000 | ||
assert results[0] == 0 | ||
assert results[400] == 20 | ||
assert results[9999] == 99.99499987499375 | ||
results = imap_tqdm(4, sqrt, (i**2 for i in range(10000))) | ||
assert len(results) == 10000 | ||
assert results[0] == 0 | ||
assert results[400] == 400 |
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,6 +1,5 @@ | ||
from monty.operator import operator_from_str | ||
|
||
|
||
class TestOperator: | ||
def test_something(self): | ||
assert operator_from_str("==")(1, 1) and operator_from_str("+")(1, 1) == 2 | ||
def test_operator_from_str(): | ||
assert operator_from_str("==")(1, 1) and operator_from_str("+")(1, 1) == 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