def test_analytics_empty(): analytics = Analytics('nengo.simulator.analytics', 'nengo.utils.tests.test_testing', 'test_analytics_empty') with analytics: pass path = analytics.get_filepath(ext='npz') assert not os.path.exists(path)
def test_analytics_empty(): analytics = Analytics('nengo.simulator.analytics', 'nengo.utils.tests.test_testing', 'test_analytics_empty') with analytics: pass path = analytics.get_filepath(ext='npz') assert not os.path.exists(path)
def test_analytics_norecord(): analytics = Analytics(None, 'nengo.utils.tests.test_testing', 'test_analytics_norecord') with analytics: analytics.add_data('test', 1, "Test analytics implementation") assert 'test' not in analytics.data assert 'test' not in analytics.doc with pytest.raises(ValueError): analytics.get_filepath(ext='npz')
def test_analytics_empty(): analytics = Analytics( "nengo.simulator.analytics", "nengo.utils.tests.test_testing", "test_analytics_empty", ) with analytics: pass path = analytics.get_filepath(ext="npz") assert not os.path.exists(path)
def analytics_data(request): paths = request.config.getvalue("compare") function_name = parametrize_function_name( request, re.sub("^test_[a-zA-Z0-9]*_", "test_", request.function.__name__, count=1), ) return [Analytics.load(p, request.module.__name__, function_name) for p in paths]
def analytics(request): """An object to store data for analytics. Please use this if you're concerned that accuracy or speed may regress. This will keep saved data organized in a simulator-specific folder, with an automatically generated name. Raw data (for later processing) can be saved with ``analytics.add_raw_data``; these will be saved in separate compressed ``.npz`` files. Summary data can be saved with ``analytics.add_summary_data``; these will be saved in a single ``.csv`` file. """ dirname = recorder_dirname(request, 'analytics') analytics = Analytics( dirname, request.module.__name__, parametrize_function_name(request, request.function.__name__)) request.addfinalizer(lambda: analytics.__exit__(None, None, None)) return analytics.__enter__()
def analytics(request): """an object to store data for analytics. Please use this if you're concerned that accuracy or speed may regress. This will keep saved data organized in a simulator-specific folder, with an automatically generated name. Raw data (for later processing) can be saved with ``analytics.add_raw_data``; these will be saved in separate compressed ``.npz`` files. Summary data can be saved with ``analytics.add_summary_data``; these will be saved in a single ``.csv`` file. """ dirname = recorder_dirname(request, 'analytics') analytics = Analytics( dirname, request.module.__name__, parametrize_function_name(request, request.function.__name__)) request.addfinalizer(lambda: analytics.__exit__(None, None, None)) return analytics.__enter__()
def test_analytics_norecord(): analytics = Analytics(None, 'nengo.utils.tests.test_testing', 'test_analytics_norecord') with analytics: analytics.add_data('test', 1, "Test analytics implementation") assert 'test' not in analytics.data assert 'test' not in analytics.doc with pytest.raises(ValueError): analytics.get_filepath(ext='npz')
def test_analytics_norecord(): analytics = Analytics(None, "nengo.utils.tests.test_testing", "test_analytics_norecord") with analytics: analytics.add_data("test", 1, "Test analytics implementation") assert "test" not in analytics.data assert "test" not in analytics.doc with pytest.raises(ValueError): analytics.get_filepath(ext="npz")
def test_analytics_record(): analytics = Analytics('nengo.simulator.analytics', 'nengo.utils.tests.test_testing', 'test_analytics_record') with analytics: analytics.add_data('test', 1, "Test analytics implementation") assert analytics.data['test'] == 1 assert analytics.doc['test'] == "Test analytics implementation" with pytest.raises(ValueError): analytics.add_data('documentation', '') path = analytics.get_filepath(ext='npz') assert os.path.exists(path) os.remove(path) # This will remove the analytics directory, only if it's empty try: os.rmdir(analytics.dirname) except OSError as ex: assert ex.errno == errno.ENOTEMPTY
def test_analytics_record(): analytics = Analytics('nengo.simulator.analytics', 'nengo.utils.tests.test_testing', 'test_analytics_record') with analytics: analytics.add_data('test', 1, "Test analytics implementation") assert analytics.data['test'] == 1 assert analytics.doc['test'] == "Test analytics implementation" with pytest.raises(ValueError): analytics.add_data('documentation', '') path = analytics.get_filepath(ext='npz') assert os.path.exists(path) os.remove(path) # This will remove the analytics directory, only if it's empty try: os.rmdir(analytics.dirname) except OSError as ex: assert ex.errno == errno.ENOTEMPTY
def analytics_data(request): paths = request.config.getvalue('compare') function_name = parametrize_function_name(request, re.sub( '^test_[a-zA-Z0-9]*_', 'test_', request.function.__name__, count=1)) return [Analytics.load( p, request.module.__name__, function_name) for p in paths]