-
Notifications
You must be signed in to change notification settings - Fork 62
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 #351 from mdekstrand/tweak/drop-deprecated-random
Remove legacy random code
- Loading branch information
Showing
13 changed files
with
64 additions
and
272 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,59 +1,35 @@ | ||
import logging | ||
from pytest import fixture | ||
|
||
import numpy as np | ||
from seedbank import numpy_rng, initialize | ||
|
||
from lenskit import util | ||
logging.getLogger("numba").setLevel(logging.INFO) | ||
|
||
logging.getLogger('numba').setLevel(logging.INFO) | ||
|
||
_log = logging.getLogger('lenskit.tests') | ||
_log = logging.getLogger("lenskit.tests") | ||
|
||
|
||
@fixture | ||
def rng(): | ||
return util.rng(42) | ||
|
||
|
||
@fixture | ||
def legacy_rng(): | ||
return util.rng(42, legacy_rng=True) | ||
return numpy_rng(42) | ||
|
||
|
||
@fixture(autouse=True) | ||
def init_rng(request): | ||
util.init_rng(42) | ||
initialize(42) | ||
|
||
|
||
@fixture(autouse=True) | ||
def log_test(request): | ||
modname = request.module.__name__ if request.module else '<unknown>' | ||
funcname = request.function.__name__ if request.function else '<unknown>' | ||
_log.info('running test %s:%s', modname, funcname) | ||
|
||
|
||
@fixture(autouse=True, scope='session') | ||
def carbon(request): | ||
try: | ||
from codecarbon import EmissionsTracker | ||
except ImportError: | ||
yield True # we do nothing | ||
return | ||
|
||
tracker = EmissionsTracker("lkpy-tests", 5) | ||
tracker.start() | ||
try: | ||
yield True | ||
finally: | ||
emissions = tracker.stop() | ||
_log.info('test suite used %.3f kgCO2eq', emissions) | ||
modname = request.module.__name__ if request.module else "<unknown>" | ||
funcname = request.function.__name__ if request.function else "<unknown>" | ||
_log.info("running test %s:%s", modname, funcname) | ||
|
||
|
||
def pytest_collection_modifyitems(items): | ||
# add 'slow' to all 'eval' tests | ||
for item in items: | ||
evm = item.get_closest_marker('eval') | ||
slm = item.get_closest_marker('slow') | ||
evm = item.get_closest_marker("eval") | ||
slm = item.get_closest_marker("slow") | ||
if evm is not None and slm is None: | ||
_log.debug('adding slow mark to %s', item) | ||
item.add_marker('slow') | ||
_log.debug("adding slow mark to %s", item) | ||
item.add_marker("slow") |
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
Oops, something went wrong.