-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] [refactor] Fix test_element_wise.py long time (#1120)
* [test] [refactor] Fix test_element_wise.py long time * [skip ci] fix ident * [skip ci] Update python/taichi/main.py Co-authored-by: Chengchen(Rex) Wang <14366016+rexwangcc@users.noreply.github.com> * [skip ci] fix missing prog= * [skip ci] enforce code format * fix test_cli * [skip ci] enforce code format * fix test_minmax * [skip ci] enforce code format Co-authored-by: Chengchen(Rex) Wang <14366016+rexwangcc@users.noreply.github.com> Co-authored-by: Taichi Gardener <taichigardener@gmail.com>
- Loading branch information
1 parent
8c483a4
commit 022d3f4
Showing
11 changed files
with
366 additions
and
317 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
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,21 +1,25 @@ | ||
import taichi as ti | ||
|
||
def approx(expected, **kwargs): | ||
import taichi as ti | ||
from pytest import approx | ||
|
||
class boolean_integer: | ||
def __init__(self, value): | ||
self.value = value | ||
class boolean_integer: | ||
def __init__(self, value): | ||
self.value = value | ||
|
||
def __eq__(self, other): | ||
return bool(self.value) == bool(other) | ||
def __eq__(self, other): | ||
return bool(self.value) == bool(other) | ||
|
||
def __ne__(self, other): | ||
return bool(self.value) != bool(other) | ||
|
||
def approx(expected, **kwargs): | ||
if isinstance(expected, bool): | ||
return boolean_integer(expected) | ||
|
||
from pytest import approx | ||
|
||
if ti.cfg.arch == ti.opengl: | ||
kwargs['rel'] = max(kwargs.get('rel', 1e-6), 1e-3) | ||
|
||
return approx(expected, **kwargs) | ||
|
||
|
||
def allclose(x, y, **kwargs): | ||
return x == approx(y, **kwargs) |
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
Oops, something went wrong.