uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
66b09e122b404130a3cb22f1
train
class
class CreateCacheTableForDBCacheTests(TestCase): multi_db = True def test_createcachetable_observes_database_router(self): old_routers = router.routers try: router.routers = [DBCacheRouter()] # cache table should not be created on 'default' with self.assertNu...
class CreateCacheTableForDBCacheTests(TestCase):
multi_db = True def test_createcachetable_observes_database_router(self): old_routers = router.routers try: router.routers = [DBCacheRouter()] # cache table should not be created on 'default' with self.assertNumQueries(0, using='default'): man...
model, **hints): if model._meta.app_label == 'django_cache': return 'other' def allow_syncdb(self, db, model): if model._meta.app_label == 'django_cache': return db == 'other' class CreateCacheTableForDBCacheTests(TestCase):
64
64
181
11
53
wnyc/django
tests/regressiontests/cache/tests.py
Python
CreateCacheTableForDBCacheTests
CreateCacheTableForDBCacheTests
854
873
854
854
c0e0a0ccdb94f2a289a117b11d075705af26ad99
bigcode/the-stack
train
251aea646045caf945a76a7f
train
class
class DBCacheTests(BaseCacheTests, TransactionTestCase): backend_name = 'django.core.cache.backends.db.DatabaseCache' def setUp(self): # Spaces are used in the table name to ensure quoting/escaping is working self._table_name = 'test cache table' management.call_command('createcachetabl...
class DBCacheTests(BaseCacheTests, TransactionTestCase):
backend_name = 'django.core.cache.backends.db.DatabaseCache' def setUp(self): # Spaces are used in the table name to ensure quoting/escaping is working self._table_name = 'test cache table' management.call_command('createcachetable', self._table_name, verbosity=0, interactive=False) ...
.encode('utf-8')) self.assertEqual(get_cache_data.cookies, response.cookies) update_middleware.process_response(request, get_cache_data) get_cache_data = fetch_middleware.process_request(request) self.assertNotEqual(get_cache_data, None) self.assertEqual(get_cache_data.content, ...
131
131
438
13
118
wnyc/django
tests/regressiontests/cache/tests.py
Python
DBCacheTests
DBCacheTests
792
830
792
792
3400caf39896c4fbf4e1335d022e1470733f3961
bigcode/the-stack
train
b6f01096f206e3fcf0b3453e
train
class
@override_settings( CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'KEY_PREFIX': 'cacheprefix' }, }, ) class PrefixedCacheI18nTest(CacheI18nTest): pass
@override_settings( CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'KEY_PREFIX': 'cacheprefix' }, }, ) class PrefixedCacheI18nTest(CacheI18nTest):
pass
translation.deactivate() @override_settings( CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'KEY_PREFIX': 'cacheprefix' }, }, ) class PrefixedCacheI18nTest(CacheI18nTest):
64
64
62
59
5
wnyc/django
tests/regressiontests/cache/tests.py
Python
PrefixedCacheI18nTest
PrefixedCacheI18nTest
1,420
1,429
1,420
1,428
258fc2a39ab3f3f4b4bd6e9f1685d8c5276bf4e3
bigcode/the-stack
train
e32748ef7466fee4937e59ab
train
class
class DummyCacheTests(unittest.TestCase): # The Dummy cache backend doesn't really behave like a test backend, # so it has different test requirements. backend_name = 'django.core.cache.backends.dummy.DummyCache' def setUp(self): self.cache = get_cache(self.backend_name) def test_simple(se...
class DummyCacheTests(unittest.TestCase): # The Dummy cache backend doesn't really behave like a test backend, # so it has different test requirements.
backend_name = 'django.core.cache.backends.dummy.DummyCache' def setUp(self): self.cache = get_cache(self.backend_name) def test_simple(self): "Dummy cache backend ignores cache set calls" self.cache.set("key", "value") self.assertEqual(self.cache.get("key"), None) def...
import re import string import tempfile import time import warnings from django.conf import settings from django.core import management from django.core.cache import get_cache from django.core.cache.backends.base import (CacheKeyWarning, InvalidCacheBackendError) from django.db import router from django.http impo...
256
256
1,275
31
224
wnyc/django
tests/regressiontests/cache/tests.py
Python
DummyCacheTests
DummyCacheTests
46
175
46
48
100b2bd719defda633f8e4cad7d21d0934feca1b
bigcode/the-stack
train
885f68fab219aaa80f8d8841
train
class
class BaseCacheTests(object): # A common set of tests to apply to all cache backends def _get_request_cache(self, path): request = HttpRequest() request.META = { 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, } request.path = request.path_info = path ...
class BaseCacheTests(object): # A common set of tests to apply to all cache backends
def _get_request_cache(self, path): request = HttpRequest() request.META = { 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, } request.path = request.path_info = path request._cache_update_cache = True request.method = 'GET' return requ...
test_set_many(self): "set_many does nothing for the dummy cache backend" self.cache.set_many({'a': 1, 'b': 2}) self.cache.set_many({'a': 1, 'b': 2}, timeout=2, version='1') def test_delete_many(self): "delete_many does nothing for the dummy cache backend" self.cache.delete_...
256
256
6,938
21
235
wnyc/django
tests/regressiontests/cache/tests.py
Python
BaseCacheTests
BaseCacheTests
178
785
178
180
2e82427798c0802a486575a196659ac39a1551ba
bigcode/the-stack
train
b1d0b1effe13f5eb61182866
train
class
@override_settings( CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix', CACHE_MIDDLEWARE_SECONDS=1, CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', }, }, USE_I18N=False, ) class TestWithTemplateResponse(TestCase)...
@override_settings( CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix', CACHE_MIDDLEWARE_SECONDS=1, CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', }, }, USE_I18N=False, ) class TestWithTemplateResponse(TestCase)...
""" Tests various headers w/ TemplateResponse. Most are probably redundant since they manipulate the same object anyway but the Etag header is 'special' because it relies on the content being complete (which is not necessarily always the case with a TemplateResponse) """ def setUp(self)...
_prefix_view(request, '14') self.assertEqual(response.content, b'Hello World 4') # .. but a rapidly expiring cache won't hit response = other_view(request, '15') self.assertEqual(response.content, b'Hello World 15') # .. even if it has a prefix response = other_with_pre...
256
256
1,030
71
185
wnyc/django
tests/regressiontests/cache/tests.py
Python
TestWithTemplateResponse
TestWithTemplateResponse
1,677
1,772
1,677
1,687
6edd810da6a3270045a3ff18e5e04dbf1b79e3b2
bigcode/the-stack
train
559f82505f11c36e649e115d
train
class
@override_settings( CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'KEY_PREFIX': 'cacheprefix', }, }, ) class PrefixedCacheUtils(CacheUtils): pass
@override_settings( CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'KEY_PREFIX': 'cacheprefix', }, }, ) class PrefixedCacheUtils(CacheUtils):
pass
-Control'])) self.assertEqual(parts, expected_cc) @override_settings( CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'KEY_PREFIX': 'cacheprefix', }, }, ) class PrefixedCacheUtils(CacheUtils):
64
64
56
53
11
wnyc/django
tests/regressiontests/cache/tests.py
Python
PrefixedCacheUtils
PrefixedCacheUtils
1,170
1,179
1,170
1,178
8e3b5e30bbecbd3d9e560b04600d8206b9d5b325
bigcode/the-stack
train
81d2d6fb26ff302e97a2cfbf
train
class
class LocMemCacheTests(unittest.TestCase, BaseCacheTests): backend_name = 'django.core.cache.backends.locmem.LocMemCache' def setUp(self): self.cache = get_cache(self.backend_name, OPTIONS={'MAX_ENTRIES': 30}) self.prefix_cache = get_cache(self.backend_name, KEY_PREFIX='cacheprefix') se...
class LocMemCacheTests(unittest.TestCase, BaseCacheTests):
backend_name = 'django.core.cache.backends.locmem.LocMemCache' def setUp(self): self.cache = get_cache(self.backend_name, OPTIONS={'MAX_ENTRIES': 30}) self.prefix_cache = get_cache(self.backend_name, KEY_PREFIX='cacheprefix') self.v2_cache = get_cache(self.backend_name, VERSION=2) ...
_db = True def test_createcachetable_observes_database_router(self): old_routers = router.routers try: router.routers = [DBCacheRouter()] # cache table should not be created on 'default' with self.assertNumQueries(0, using='default'): management.c...
181
181
606
13
167
wnyc/django
tests/regressiontests/cache/tests.py
Python
LocMemCacheTests
LocMemCacheTests
876
932
876
876
2d96913ec433322d7c076e5c4a7c16ee064d603d
bigcode/the-stack
train
4da29f161f203ae829085c1c
train
class
class GetCacheTests(unittest.TestCase): def test_simple(self): cache = get_cache('locmem://') from django.core.cache.backends.locmem import LocMemCache self.assertTrue(isinstance(cache, LocMemCache)) from django.core.cache import cache self.assertTrue(isinstance(cache, get_...
class GetCacheTests(unittest.TestCase):
def test_simple(self): cache = get_cache('locmem://') from django.core.cache.backends.locmem import LocMemCache self.assertTrue(isinstance(cache, LocMemCache)) from django.core.cache import cache self.assertTrue(isinstance(cache, get_cache('default').__class__)) cac...
_backend://') # this key is both longer than 250 characters, and has spaces key = 'some key with spaces' * 15 val = 'a value' cache.set(key, val) self.assertEqual(cache.get(key), val) class GetCacheTests(unittest.TestCase):
64
64
181
8
56
wnyc/django
tests/regressiontests/cache/tests.py
Python
GetCacheTests
GetCacheTests
1,039
1,060
1,039
1,040
5ea4a6acc0093f4b66ecd40b3290e9bc8dee4091
bigcode/the-stack
train
9fdd836059765189fb438a36
train
class
@override_settings( CACHE_MIDDLEWARE_ALIAS='other', CACHE_MIDDLEWARE_KEY_PREFIX='middlewareprefix', CACHE_MIDDLEWARE_SECONDS=30, CACHE_MIDDLEWARE_ANONYMOUS_ONLY=False, CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', ...
@override_settings( CACHE_MIDDLEWARE_ALIAS='other', CACHE_MIDDLEWARE_KEY_PREFIX='middlewareprefix', CACHE_MIDDLEWARE_SECONDS=30, CACHE_MIDDLEWARE_ANONYMOUS_ONLY=False, CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', ...
def setUp(self): self.factory = RequestFactory() self.default_cache = get_cache('default') self.other_cache = get_cache('other') self.save_warnings_state() warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.views.decorators.cache') ...
reset the language translation.deactivate() @override_settings( CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'KEY_PREFIX': 'cacheprefix' }, }, ) class PrefixedCacheI18nTest(CacheI18nTest): pass ...
256
256
2,086
164
92
wnyc/django
tests/regressiontests/cache/tests.py
Python
CacheMiddlewareTest
CacheMiddlewareTest
1,436
1,674
1,436
1,456
52a466102df0c47208c4d6b683ef956edbc9a98b
bigcode/the-stack
train
98c3eea1559d3c82600c5f30
train
function
def inv(a): """Returns the inverse of A.""" try: return np.linalg.inv(a) except linalg.LinAlgError: return np.linalg.pinv(a)
def inv(a):
"""Returns the inverse of A.""" try: return np.linalg.inv(a) except linalg.LinAlgError: return np.linalg.pinv(a)
true(np.equal(X, 0.))) def solve(a, b): """Returns the solution of A X = B.""" try: return linalg.solve(a, b) except linalg.LinAlgError: return np.dot(linalg.pinv(a), b) def inv(a):
64
64
39
4
60
mattl1598/testing
editing files/Portable Python 3.2.5.1/App/Lib/site-packages/pandas/stats/math.py
Python
inv
inv
33
38
33
33
1386a9acab3edd35aefda1ee9c83a7b3f3a0dcd1
bigcode/the-stack
train
5de7211aac3615b136d63aa6
train
function
def newey_west(m, max_lags, nobs, df, nw_overlap=False): """ Compute Newey-West adjusted covariance matrix, taking into account specified number of leads / lags Parameters ---------- m: (N x K) max_lags: int nobs: int Number of observations in model df: int Degrees o...
def newey_west(m, max_lags, nobs, df, nw_overlap=False):
""" Compute Newey-West adjusted covariance matrix, taking into account specified number of leads / lags Parameters ---------- m: (N x K) max_lags: int nobs: int Number of observations in model df: int Degrees of freedom in explanatory variables nw_overlap: boolea...
inalg.LinAlgError: return np.dot(linalg.pinv(a), b) def inv(a): """Returns the inverse of A.""" try: return np.linalg.inv(a) except linalg.LinAlgError: return np.linalg.pinv(a) def is_psd(m): eigvals = linalg.eigvals(m) return np.isreal(eigvals).all() and (eigvals >= 0).a...
115
115
386
20
95
mattl1598/testing
editing files/Portable Python 3.2.5.1/App/Lib/site-packages/pandas/stats/math.py
Python
newey_west
newey_west
46
90
46
46
e4a9b740b23c459043d07ca3a394f0b99ed0cde0
bigcode/the-stack
train
afb403f8ed19cce5f9ead4a4
train
function
def is_psd(m): eigvals = linalg.eigvals(m) return np.isreal(eigvals).all() and (eigvals >= 0).all()
def is_psd(m):
eigvals = linalg.eigvals(m) return np.isreal(eigvals).all() and (eigvals >= 0).all()
linalg.LinAlgError: return np.dot(linalg.pinv(a), b) def inv(a): """Returns the inverse of A.""" try: return np.linalg.inv(a) except linalg.LinAlgError: return np.linalg.pinv(a) def is_psd(m):
64
64
38
6
58
mattl1598/testing
editing files/Portable Python 3.2.5.1/App/Lib/site-packages/pandas/stats/math.py
Python
is_psd
is_psd
41
43
41
41
3850e871c8da16b06a9c74a1ac03c68d92a37d4c
bigcode/the-stack
train
b65907321d6c637fd1d497c4
train
function
def calc_F(R, r, beta, var_beta, nobs, df): """ Computes the standard F-test statistic for linear restriction hypothesis testing Parameters ---------- R: ndarray (N x N) Restriction matrix r: ndarray (N x 1) Restriction vector beta: ndarray (N x 1) Estimated mode...
def calc_F(R, r, beta, var_beta, nobs, df):
""" Computes the standard F-test statistic for linear restriction hypothesis testing Parameters ---------- R: ndarray (N x N) Restriction matrix r: ndarray (N x 1) Restriction vector beta: ndarray (N x 1) Estimated model coefficients var_beta: ndarray (N x N)...
generated a non positive ' # 'semidefinite matrix, so using newey_west with max_lags of %d.' # % new_max_lags) return newey_west(m, new_max_lags, nobs, df) return Xeps def calc_F(R, r, beta, var_beta, nobs, df):
75
75
251
17
57
mattl1598/testing
editing files/Portable Python 3.2.5.1/App/Lib/site-packages/pandas/stats/math.py
Python
calc_F
calc_F
93
128
93
93
9b4794f164c07e7a378ffac55932e85883282310
bigcode/the-stack
train
3278e7455e54cfa93e76192e
train
function
def rank(X, cond=1.0e-12): """ Return the rank of a matrix X based on its generalized inverse, not the SVD. """ X = np.asarray(X) if len(X.shape) == 2: import scipy.linalg as SL D = SL.svdvals(X) result = np.add.reduce(np.greater(D / D.max(), cond)) return int(res...
def rank(X, cond=1.0e-12):
""" Return the rank of a matrix X based on its generalized inverse, not the SVD. """ X = np.asarray(X) if len(X.shape) == 2: import scipy.linalg as SL D = SL.svdvals(X) result = np.add.reduce(np.greater(D / D.max(), cond)) return int(result.astype(np.int32)) e...
# pylint: disable-msg=E1103 # pylint: disable-msg=W0212 import numpy as np import numpy.linalg as linalg def rank(X, cond=1.0e-12):
44
64
113
13
30
mattl1598/testing
editing files/Portable Python 3.2.5.1/App/Lib/site-packages/pandas/stats/math.py
Python
rank
rank
10
22
10
10
5cc155b4e2db364d61ae63e54222a0cdc4d03fcc
bigcode/the-stack
train
3f6fdc4861cf2fbb6c38eaff
train
function
def solve(a, b): """Returns the solution of A X = B.""" try: return linalg.solve(a, b) except linalg.LinAlgError: return np.dot(linalg.pinv(a), b)
def solve(a, b):
"""Returns the solution of A X = B.""" try: return linalg.solve(a, b) except linalg.LinAlgError: return np.dot(linalg.pinv(a), b)
scipy.linalg as SL D = SL.svdvals(X) result = np.add.reduce(np.greater(D / D.max(), cond)) return int(result.astype(np.int32)) else: return int(not np.alltrue(np.equal(X, 0.))) def solve(a, b):
63
64
50
6
57
mattl1598/testing
editing files/Portable Python 3.2.5.1/App/Lib/site-packages/pandas/stats/math.py
Python
solve
solve
25
30
25
25
cabf8c5934d37e046371b766c5eb885a19ace19b
bigcode/the-stack
train
d098a2ea6e99b15a1a85e480
train
function
def send_metrics(url: str, request_body: dict, custom_headers: dict, custom_options: dict) -> bool: """ Attempts to send metrics to Unleash server Notes: * If unsuccessful (i.e. not HTTP status code 200), message will be logged :param url: :pa...
def send_metrics(url: str, request_body: dict, custom_headers: dict, custom_options: dict) -> bool:
""" Attempts to send metrics to Unleash server Notes: * If unsuccessful (i.e. not HTTP status code 200), message will be logged :param url: :param app_name: :param instance_id: :param metrics_interval: :param custom_headers: :param custom_options: :return: true if registrat...
import json import requests from UnleashClient.constants import REQUEST_TIMEOUT, APPLICATION_HEADERS, METRICS_URL from UnleashClient.utils import LOGGER, log_resp_info # pylint: disable=broad-except def send_metrics(url: str, request_body: dict, custom_headers: dict, ...
74
80
267
28
45
asengardeon/unleash-client-python
her-unleash-client/api/metrics.py
Python
send_metrics
send_metrics
8
46
8
11
2c80bcd699c479abc45cbaca219a3de85417010a
bigcode/the-stack
train
8b7c07529bbbf1875fb0df3b
train
function
def plot_graph(graph, types=True, filename=None, parent_pos=None): """Plot graph with node colors corresponding to types.""" # if types: # color_list = colors_by_type(graph) # else: # color_list = None if not parent_pos: pos = nx.spring_layout(graph) else: pos = copy....
def plot_graph(graph, types=True, filename=None, parent_pos=None):
"""Plot graph with node colors corresponding to types.""" # if types: # color_list = colors_by_type(graph) # else: # color_list = None if not parent_pos: pos = nx.spring_layout(graph) else: pos = copy.deepcopy(parent_pos) random_pos = nx.spring_layout(graph) ...
]) ymax = max([ p[1] for _, p in labels.items() ]) plt.xlim([ xmin - margin * abs(xmax - xmin), xmax + margin * abs(xmax - xmin) ]) plt.ylim([ ymin - margin * abs(ymax - ymin), ymax + margin * abs(ymax - ymin) ]) return def plot_graph(graph, types=Tr...
96
96
322
15
80
y1ngyang/ReGraph
regraph/plotting.py
Python
plot_graph
plot_graph
50
92
50
50
60d72edcdb3826308b2c489be8694b3e0b31374e
bigcode/the-stack
train
8738fb53a62c27104f79aa75
train
function
def _set_limits(nodes, labels, margin=0.1): xmin = min([ p[0] for _, p in nodes.items() ]) xmax = max([ p[0] for _, p in nodes.items() ]) ymin = min([ p[1] for _, p in nodes.items() ]) ymax = max([ p[1] for _, p in labels.items() ]) plt.xlim([ ...
def _set_limits(nodes, labels, margin=0.1):
xmin = min([ p[0] for _, p in nodes.items() ]) xmax = max([ p[0] for _, p in nodes.items() ]) ymin = min([ p[1] for _, p in nodes.items() ]) ymax = max([ p[1] for _, p in labels.items() ]) plt.xlim([ xmin - margin * abs(xmax - xmin), x...
ticks are affected left='off', # ticks along the bottom edge are off right='off', # ticks along the top edge are off labelleft='off') # labels along the bottom edge are off def _set_limits(nodes, labels, margin=0.1):
64
64
151
14
49
y1ngyang/ReGraph
regraph/plotting.py
Python
_set_limits
_set_limits
25
47
25
25
fcc9ed82d0e4e3a44a28bc4cda6fffb9ff17154c
bigcode/the-stack
train
a17138cfb7806c7750f455b8
train
function
def plot_rule(rule, filename=None): plt.figure(figsize=(14, 3)) # generate colors p_colors_dict = {} p_colors = [] for node in rule.p.nodes(): lhs_node = rule.p_lhs[node] all_p_keys = keys_by_value(rule.p_lhs, lhs_node) if len(all_p_keys) > 1: found = None ...
def plot_rule(rule, filename=None):
plt.figure(figsize=(14, 3)) # generate colors p_colors_dict = {} p_colors = [] for node in rule.p.nodes(): lhs_node = rule.p_lhs[node] all_p_keys = keys_by_value(rule.p_lhs, lhs_node) if len(all_p_keys) > 1: found = None for p_key in all_p_keys: ...
graph, pos, node_color=new_colors, node_size=100, arrows=True) nx.draw_networkx_edges(graph, pos, alpha=0.4) # Draw pattern edges highlighted edgelist = [(instance[edge[0]], instance[edge[1]]) for edge in pattern.edges()] nx.draw_networkx_edges( graph, pos, ...
256
256
1,070
8
247
y1ngyang/ReGraph
regraph/plotting.py
Python
plot_rule
plot_rule
143
264
143
143
e562ff74f05cfccfeea21a34e131ad91b554b643
bigcode/the-stack
train
7aaf5394c733eb4887f7698f
train
function
def plot_instance(graph, pattern, instance, filename=None, parent_pos=None): """Plot the graph with instance of pattern highlighted.""" new_colors = ["g" if not graph.nodes()[i] in instance.values() else "r" for i, c in enumerate(graph.nodes())] if not parent_pos: pos = nx.spring_l...
def plot_instance(graph, pattern, instance, filename=None, parent_pos=None):
"""Plot the graph with instance of pattern highlighted.""" new_colors = ["g" if not graph.nodes()[i] in instance.values() else "r" for i, c in enumerate(graph.nodes())] if not parent_pos: pos = nx.spring_layout(graph) else: pos = copy.deepcopy(parent_pos) random...
labels_pos[p][1] += offset nx.draw_networkx_labels(graph, labels_pos, labels, font_size=11) _ticks_off() _set_limits(pos, labels_pos) # save to the file if filename is not None: # with open(filename, "w") as f: # plt.savefig(f) plt.savefig(filename) plt.c...
111
111
372
16
94
y1ngyang/ReGraph
regraph/plotting.py
Python
plot_instance
plot_instance
95
140
95
95
757a5a85a27ebcb5b9271cf27267fe5ff13a11ed
bigcode/the-stack
train
232011fd3c88b7a9dc1db431
train
function
def _ticks_off(): plt.tick_params( axis='x', # changes apply to the x-axis which='both', # both major and minor ticks are affected bottom='off', # ticks along the bottom edge are off top='off', # ticks along the top edge are off labelbottom='off...
def _ticks_off():
plt.tick_params( axis='x', # changes apply to the x-axis which='both', # both major and minor ticks are affected bottom='off', # ticks along the bottom edge are off top='off', # ticks along the top edge are off labelbottom='off') # labels along...
import copy import networkx as nx import numpy as np from regraph.utils import keys_by_value from matplotlib import pyplot as plt def _ticks_off():
35
64
165
5
29
y1ngyang/ReGraph
regraph/plotting.py
Python
_ticks_off
_ticks_off
10
22
10
10
5005b271fd21b13bd898d16e977e149bdad63a9f
bigcode/the-stack
train
49e511d5db887d699845a80c
train
function
def merge_types(name: str, types: Tuple[type, ...]) -> type: """Merge multiple Strawberry types into one For example, given two queries `A` and `B`, one can merge them into a super type as follows: merge_types("SuperQuery", (B, A)) This is essentially the same as: class SuperQuery(B,...
def merge_types(name: str, types: Tuple[type, ...]) -> type:
"""Merge multiple Strawberry types into one For example, given two queries `A` and `B`, one can merge them into a super type as follows: merge_types("SuperQuery", (B, A)) This is essentially the same as: class SuperQuery(B, A): ... """ if not types: raise...
import warnings from collections import Counter from itertools import chain from typing import Tuple import strawberry def merge_types(name: str, types: Tuple[type, ...]) -> type:
38
64
198
17
20
TheVinhLuong102/Strawberry
strawberry/tools/merge_types.py
Python
merge_types
merge_types
9
34
9
9
a805b23d6ffd160d844f219df1196d9b56ea95e3
bigcode/the-stack
train
ed856412b7002fd732ea95c8
train
function
def enforce_auth(*expected_args, **kwargs): if "laika_auth" not in kwargs: raise ValueError("laika_auth must be present to enforce authetication") laika_auth = kwargs["laika_auth"] def decorator_require_basic_auth(func): @functools.wraps(func) def wrapper_require_basic_auth(*args, **...
def enforce_auth(*expected_args, **kwargs):
if "laika_auth" not in kwargs: raise ValueError("laika_auth must be present to enforce authetication") laika_auth = kwargs["laika_auth"] def decorator_require_basic_auth(func): @functools.wraps(func) def wrapper_require_basic_auth(*args, **kwargs): user_agent = request.he...
not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDI...
188
188
629
10
177
sandialabs/laikaboss
laikarest/authentication/decorators.py
Python
enforce_auth
enforce_auth
32
104
32
32
76dfa3be33f01a3f3e7e0d25e829970bddc149dd
bigcode/the-stack
train
5d91da0b47fd494d0b668a45
train
function
@pytest.mark.parametrize((u'iterable', u'sequence'), [ # Regular types: ([], IO(())), ([IO(1)], IO((1,))), ([IO(1), IO(2)], IO((1, 2))), # Can fail: ([], Success(())), ([Success(1)], Success((1,))), ([Success(1), Success(2)], Success((1, 2))), ( [Failure(u'a'), Success(1),...
@pytest.mark.parametrize((u'iterable', u'sequence'), [ # Regular types: ([], IO(())), ([IO(1)], IO((1,))), ([IO(1), IO(2)], IO((1, 2))), # Can fail: ([], Success(())), ([Success(1)], Success((1,))), ([Success(1), Success(2)], Success((1, 2))), ( [Failure(u'a'), Success(1),...
u"""Iterable for regular types and ``Fold``.""" assert Fold.collect(iterable, sequence.from_value(())) == sequence
@pytest.mark.parametrize((u'iterable', u'sequence'), [ # Regular types: ([], IO(())), ([IO(1)], IO((1,))), ([IO(1), IO(2)], IO((1, 2))), # Can fail: ([], Success(())), ([Success(1)], Success((1,))), ([Success(1), Success(2)], Success((1, 2))), ( [Failure(u'a'), Success(1),...
343
111
370
343
0
internetimagery/returns
tests/test_iterables/test_fold/test_collect.py
Python
test_fold_collect
test_fold_collect
22
61
22
59
e2a21beb0ffcbd8f59a61e77203bd02bace51813
bigcode/the-stack
train
46ff948ed13806445a834a70
train
function
@pytest.mark.anyio() async def test_fold_collect_reader_future_result(subtests): u"""Iterable for ``ReaderFutureResult`` and ``Fold``.""" containers: List[Tuple[ # noqa: WPS234 Iterable[ReaderFutureResult[int, unicode, NoDeps]], ReaderFutureResult[Sequence[int], unicode, NoDeps], ]] = [ ...
@pytest.mark.anyio() async def test_fold_collect_reader_future_result(subtests):
u"""Iterable for ``ReaderFutureResult`` and ``Fold``.""" containers: List[Tuple[ # noqa: WPS234 Iterable[ReaderFutureResult[int, unicode, NoDeps]], ReaderFutureResult[Sequence[int], unicode, NoDeps], ]] = [ ([], ReaderFutureResult.from_value(())), ( [ReaderFuture...
ReaderIOResult.from_failure(u'b')], ReaderIOResult.from_failure(u'a'), ), ]) def test_fold_collect_reader(iterable, sequence): u"""Ensures that ``.collect`` works for readers.""" assert Fold.collect( iterable, sequence.from_value(()), )(...) == sequence(...) @pytest.mark.anyio()...
80
81
273
16
64
internetimagery/returns
tests/test_iterables/test_fold/test_collect.py
Python
test_fold_collect_reader_future_result
test_fold_collect_reader_future_result
122
161
122
123
e3abf1e4151e7a8fee165932a01dc85e8bc5bfbc
bigcode/the-stack
train
99d853ab86f4d2aa490b1c77
train
function
@pytest.mark.anyio() async def test_fold_collect_future_result(subtests): u"""Iterable for ``FutureResult`` and ``Fold``.""" containers: List[Tuple[ # noqa: WPS234 Iterable[FutureResult[int, unicode]], FutureResult[Sequence[int], unicode], ]] = [ ([], FutureSuccess(())), ([F...
@pytest.mark.anyio() async def test_fold_collect_future_result(subtests):
u"""Iterable for ``FutureResult`` and ``Fold``.""" containers: List[Tuple[ # noqa: WPS234 Iterable[FutureResult[int, unicode]], FutureResult[Sequence[int], unicode], ]] = [ ([], FutureSuccess(())), ([FutureSuccess(1)], FutureSuccess((1,))), ([FutureSuccess(1), Future...
2)), ), ] for iterable, sequence in containers: with subtests.test(iterable=iterable, sequence=sequence): assert await Fold.collect( iterable, sequence.from_value(()), ) == await sequence @pytest.mark.anyio() async def test_fold_collect_future_result(subte...
64
64
196
15
48
internetimagery/returns
tests/test_iterables/test_fold/test_collect.py
Python
test_fold_collect_future_result
test_fold_collect_future_result
185
205
185
186
ea2464dabd3048b46a6a47262bb28b71b3184a2f
bigcode/the-stack
train
a0e959eea9a5fe5cdb708c59
train
function
def test_fold_collect_recursion_limit(): u"""Ensures that ``.collect`` method is recurion safe.""" limit = sys.getrecursionlimit() + 1 iterable = (IO(1) for _ in xrange(limit)) expected = IO((1,) * limit) assert Fold.collect(iterable, IO(())) == expected
def test_fold_collect_recursion_limit():
u"""Ensures that ``.collect`` method is recurion safe.""" limit = sys.getrecursionlimit() + 1 iterable = (IO(1) for _ in xrange(limit)) expected = IO((1,) * limit) assert Fold.collect(iterable, IO(())) == expected
FutureFailure(u'b')], FutureFailure(u'a')), ] for iterable, sequence in containers: with subtests.test(iterable=iterable, sequence=sequence): assert await Fold.collect( iterable, sequence.from_value(()), ) == await sequence def test_fold_collect_recursion_limit()...
64
64
74
8
55
internetimagery/returns
tests/test_iterables/test_fold/test_collect.py
Python
test_fold_collect_recursion_limit
test_fold_collect_recursion_limit
208
213
208
208
77cc927b037055abe5b57d88d943861a0f935531
bigcode/the-stack
train
5087f3e3d838e18ef3003e6b
train
function
@pytest.mark.anyio() async def test_fold_collect_future(subtests): u"""Iterable for ``Future`` and ``Fold``.""" containers: List[Tuple[ # noqa: WPS234 Iterable[Future[int]], Future[Sequence[int]], ]] = [ ([], Future.from_value(())), ([Future.from_value(1)], Future.from_value...
@pytest.mark.anyio() async def test_fold_collect_future(subtests):
u"""Iterable for ``Future`` and ``Fold``.""" containers: List[Tuple[ # noqa: WPS234 Iterable[Future[int]], Future[Sequence[int]], ]] = [ ([], Future.from_value(())), ([Future.from_value(1)], Future.from_value((1,))), ( [Future.from_value(1), Future.from_v...
'), ), ] for iterable, sequence in containers: with subtests.test(iterable=iterable, sequence=sequence): assert await Fold.collect( iterable, sequence.from_value(()), )(...) == await sequence(...) @pytest.mark.anyio() async def test_fold_collect_future(sub...
63
64
154
14
49
internetimagery/returns
tests/test_iterables/test_fold/test_collect.py
Python
test_fold_collect_future
test_fold_collect_future
164
182
164
165
77f792ddb769531fb212f8d549171edaa3a1c6c3
bigcode/the-stack
train
e266285d0b814ebf12d64b18
train
function
@pytest.mark.parametrize((u'iterable', u'sequence'), [ # Regular types: ([], Reader.from_value(())), ([Reader.from_value(1)], Reader.from_value((1,))), ( [Reader.from_value(1), Reader.from_value(2)], Reader.from_value((1, 2)), ), # Can fail: ([], ReaderResult.from_value(()...
@pytest.mark.parametrize((u'iterable', u'sequence'), [ # Regular types: ([], Reader.from_value(())), ([Reader.from_value(1)], Reader.from_value((1,))), ( [Reader.from_value(1), Reader.from_value(2)], Reader.from_value((1, 2)), ), # Can fail: ([], ReaderResult.from_value(()...
u"""Ensures that ``.collect`` works for readers.""" assert Fold.collect( iterable, sequence.from_value(()), )(...) == sequence(...)
@pytest.mark.parametrize((u'iterable', u'sequence'), [ # Regular types: ([], Reader.from_value(())), ([Reader.from_value(1)], Reader.from_value((1,))), ( [Reader.from_value(1), Reader.from_value(2)], Reader.from_value((1, 2)), ), # Can fail: ([], ReaderResult.from_value(()...
350
115
384
350
0
internetimagery/returns
tests/test_iterables/test_fold/test_collect.py
Python
test_fold_collect_reader
test_fold_collect_reader
64
119
64
114
b03624f9bd1f6d4acc26810114ac871fbce88c12
bigcode/the-stack
train
f82c69dfdb527df9def3c62c
train
function
@trampoline def tree_sum(x, total=0): if not x: return done(total) elif isinstance(x, list): return doing(tree_sum, x[1:], tree_sum(x[0], total)) else: return done(total + x)
@trampoline def tree_sum(x, total=0):
if not x: return done(total) elif isinstance(x, list): return doing(tree_sum, x[1:], tree_sum(x[0], total)) else: return done(total + x)
0 else doing(odd, n - 1) ## odd(4200), even(4200) #. (False, True) # A Scheme example using both tail and nontail calls, though it's # unnatural for Python lists. @trampoline def tree_sum(x, total=0):
64
64
58
13
51
JaDogg/__py_playground
reference/sketchbook/misc/trampoline.py
Python
tree_sum
tree_sum
47
54
47
48
d97c7496c85744df395b88d7e8f7df09da97204f
bigcode/the-stack
train
e8198636160d73ec1dbe975c
train
function
@trampoline def odd(n): return done(False) if n == 0 else doing(even, n - 1)
@trampoline def odd(n):
return done(False) if n == 0 else doing(even, n - 1)
ined.f self.args = args self.kwargs = kwargs def bounce(self): return self.f(*self.args, **self.kwargs) class done(object): def __init__(self, result): self.result = result # Examples @trampoline def odd(n):
64
64
28
8
55
JaDogg/__py_playground
reference/sketchbook/misc/trampoline.py
Python
odd
odd
34
36
34
35
9e4c933b5450efa088128c6179890ac95ec8b0ec
bigcode/the-stack
train
5d409954756024c29cb5e851
train
class
class doing(object): def __init__(self, trampolined, *args, **kwargs): assert isinstance(trampolined, trampoline) self.f = trampolined.f self.args = args self.kwargs = kwargs def bounce(self): return self.f(*self.args, **self.kwargs)
class doing(object):
def __init__(self, trampolined, *args, **kwargs): assert isinstance(trampolined, trampoline) self.f = trampolined.f self.args = args self.kwargs = kwargs def bounce(self): return self.f(*self.args, **self.kwargs)
self, f): self.f = f def __call__(self, *args, **kwargs): state = self.f(*args, **kwargs) while isinstance(state, doing): state = state.bounce() assert isinstance(state, done) return state.result class doing(object):
64
64
71
4
59
JaDogg/__py_playground
reference/sketchbook/misc/trampoline.py
Python
doing
doing
19
26
19
19
d6b3a1859913077f17fdc543cb401e8cc6f5dc0c
bigcode/the-stack
train
54da3b7e8cc095898363c620
train
class
class trampoline(object): def __init__(self, f): self.f = f def __call__(self, *args, **kwargs): state = self.f(*args, **kwargs) while isinstance(state, doing): state = state.bounce() assert isinstance(state, done) return state.result
class trampoline(object):
def __init__(self, f): self.f = f def __call__(self, *args, **kwargs): state = self.f(*args, **kwargs) while isinstance(state, doing): state = state.bounce() assert isinstance(state, done) return state.result
/programming/tailcall.html turning into http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.45.5447 I give these classes lowercase names because the usual uppercase style becomes obtrusive in this use. """ class trampoline(object):
64
64
69
4
60
JaDogg/__py_playground
reference/sketchbook/misc/trampoline.py
Python
trampoline
trampoline
9
17
9
9
9b217cb92c1f1698ab84b839420864ff34ce1eaf
bigcode/the-stack
train
a3b3995d2c0727c00d2d5229
train
function
@trampoline def even(n): return done(True) if n == 0 else doing(odd, n - 1)
@trampoline def even(n):
return done(True) if n == 0 else doing(odd, n - 1)
, **self.kwargs) class done(object): def __init__(self, result): self.result = result # Examples @trampoline def odd(n): return done(False) if n == 0 else doing(even, n - 1) @trampoline def even(n):
64
64
28
8
56
JaDogg/__py_playground
reference/sketchbook/misc/trampoline.py
Python
even
even
38
40
38
39
75062f5195062047807a6b1c459a8f3b8f47a982
bigcode/the-stack
train
ecb7ed34d16d092ec641f7b2
train
class
class done(object): def __init__(self, result): self.result = result
class done(object):
def __init__(self, result): self.result = result
trampolined, *args, **kwargs): assert isinstance(trampolined, trampoline) self.f = trampolined.f self.args = args self.kwargs = kwargs def bounce(self): return self.f(*self.args, **self.kwargs) class done(object):
64
64
19
4
60
JaDogg/__py_playground
reference/sketchbook/misc/trampoline.py
Python
done
done
28
30
28
28
fc6a00580b03c9e0c27eab7cbe2eb8cf3b75d33b
bigcode/the-stack
train
356fd078a76725e9bb6aaded
train
function
@workflow def workflow_failed(inputs, *args, **kwargs): # get current context _ctx = kwargs.get('ctx', ctx) # dump current parameters _ctx.logger.info("called: {}/{}/{}" .format(repr(inputs), repr(args), repr(kwargs))) # get client from current manager client = manager.get...
@workflow def workflow_failed(inputs, *args, **kwargs): # get current context
_ctx = kwargs.get('ctx', ctx) # dump current parameters _ctx.logger.info("called: {}/{}/{}" .format(repr(inputs), repr(args), repr(kwargs))) # get client from current manager client = manager.get_rest_client() if ( # prefix of deployments for uninstall inp...
# See the License for the specific language governing permissions and # limitations under the License. from cloudify import ctx from cloudify import manager from cloudify.decorators import workflow # callback name from hooks config @workflow def workflow_failed(inputs, *args, **kwargs): # get current context
64
64
177
20
43
Cloudify-PS/cloudify-hooks-plugin
cloudify_hooks/tasks.py
Python
workflow_failed
workflow_failed
21
43
21
23
48d95ba29e3f6e1517102fbfae29f3faf4187978
bigcode/the-stack
train
9af5d8b6c7a972cebba32c3b
train
class
class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Brand', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('c...
class Migration(migrations.Migration):
initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Brand', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('create_time', models.DateTimeField(auto_n...
# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2019-04-29 08:22 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration):
61
256
2,019
7
53
921957877/meiduo_mall
meiduo_mall/meiduo_mall/apps/goods/migrations/0001_initial.py
Python
Migration
Migration
9
195
9
10
e43088750bb116300df4015e0582edcd87ad4670
bigcode/the-stack
train
76b221602109acc0ddefb63b
train
class
class ImagePool(): """This class implements an image buffer that stores previously generated images. This buffer enables us to update discriminators using a history of generated images rather than the ones produced by the latest generators. """ def __init__(self, pool_size): """Initialize ...
class ImagePool():
"""This class implements an image buffer that stores previously generated images. This buffer enables us to update discriminators using a history of generated images rather than the ones produced by the latest generators. """ def __init__(self, pool_size): """Initialize the ImagePool class...
import random import torch class ImagePool():
10
136
456
4
5
ibro45/a
ganslate/data/utils/image_pool.py
Python
ImagePool
ImagePool
5
60
5
5
15473f52d3f293681e38de93272e714f378a2973
bigcode/the-stack
train
9a05b551a10afb5d72016192
train
class
class ConfigFileParser: def __init__(self): self.elements_store = { # The list element stores the current active tags/Group as the configs are being parsed 'tag': ('<', '>', []), 'group': ('{', '}', []), } self.all_groups = set() def parse_cfg_file(se...
class ConfigFileParser:
def __init__(self): self.elements_store = { # The list element stores the current active tags/Group as the configs are being parsed 'tag': ('<', '>', []), 'group': ('{', '}', []), } self.all_groups = set() def parse_cfg_file(self, config_file): ...
128 # <> # category marking works like tags # e.g. # --lr 0.01 {generator} # --batch_size 0.01 {generator} # OR # {generator} # --lr 0.01 # --beta1 0.9 # {} # multiple tags/categories must be within the # same brackets separated by commas , # e.g. {generator, discriminator} or <hyper, super> # or # {generator} # {disc...
256
256
2,032
5
250
dmarnerides/boardom
boardom/config/cfg_file_parser.py
Python
ConfigFileParser
ConfigFileParser
69
284
69
69
4ed9b3d63610f36bab989f08e7da16a9d2856408
bigcode/the-stack
train
50111cfa9dbf25f057af626d
train
function
def _is_valid_config_file(x): ret = any([x.lower().endswith(y) for y in _CONFIG_EXTENSIONS]) return os.path.isfile(bd.process_path(x)) and ret
def _is_valid_config_file(x):
ret = any([x.lower().endswith(y) for y in _CONFIG_EXTENSIONS]) return os.path.isfile(bd.process_path(x)) and ret
# # ################################################################# # If a parameter was at any point added into a category then all # lookups of that parameter in the program will need a category # supplied. The default is suppressed # ################################################################# _CONFIG_EXTENS...
64
64
42
8
56
dmarnerides/boardom
boardom/config/cfg_file_parser.py
Python
_is_valid_config_file
_is_valid_config_file
64
66
64
64
e18ca7cdee3ab7a93db1a581ce4917c514bfe70b
bigcode/the-stack
train
ac5095ee72c9d9ed3cd32c1a
train
function
def multi_var(function, file): """ Calls the partial_diff, dbl_integral, and graph_3d functions. Keyword arguments: function -- a Sympy object representation of the user's math function """ partial_X, partial_Y = partial_diff(function) partial_XX, partial_XY = partial_diff(parti...
def multi_var(function, file):
""" Calls the partial_diff, dbl_integral, and graph_3d functions. Keyword arguments: function -- a Sympy object representation of the user's math function """ partial_X, partial_Y = partial_diff(function) partial_XX, partial_XY = partial_diff(partial_X) partial_YX, partial_Y...
""" from sympy import symbols, Integral x,y = symbols('x'), symbols('y') if type(function) == str: expr = preprocess(function) else: expr = function return Integral(expr, (x, y)) def multi_var(function, file):
63
64
157
7
56
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
multi_var
multi_var
252
266
252
252
ea0496072dd6d8357eef04800dea5c08a0052459
bigcode/the-stack
train
7c6e772f7b8a001a97d96a5e
train
function
def graph_2d(function, file): """ Graphs a math function on a 2 dimensional space. Keyword arguments: function -- a Sympy object representation of the user's math function file -- a filename to save the matplotlib figure """ import matplotlib.pyplot as plt import numpy as n...
def graph_2d(function, file):
""" Graphs a math function on a 2 dimensional space. Keyword arguments: function -- a Sympy object representation of the user's math function file -- a filename to save the matplotlib figure """ import matplotlib.pyplot as plt import numpy as np expr = preprocess(func...
expr = str(function) while True: if '**' in expr: expr = expr[:expr.index('**')] + '^' + expr[expr.index('**')+2:] else: break return expr def graph_2d(function, file):
63
64
187
9
53
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
graph_2d
graph_2d
50
77
50
50
7b37f4aa07cc60dd296f2262d734681b83f23d8e
bigcode/the-stack
train
88ff575248f5264cc9357d59
train
function
def diff(function): """ Differentiates a math function. Keyword arguments: function -- a Sympy object representation of the user's math function """ import sympy x = sympy.symbols('x') if type(function) == str: expr = preprocess(function) else: ...
def diff(function):
""" Differentiates a math function. Keyword arguments: function -- a Sympy object representation of the user's math function """ import sympy x = sympy.symbols('x') if type(function) == str: expr = preprocess(function) else: expr = function ...
x_axis[i]) fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x_axis, y_axis) ax.set_xlabel('X') ax.set_ylabel('Y') if file != None: plt.savefig(file) plt.close() def diff(function):
64
64
81
4
60
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
diff
diff
80
96
80
80
81c97b7d084b50e9959e00421a9089bd3730fe63
bigcode/the-stack
train
c82d4097332358b55a46bcb4
train
function
def partial_diff(function): """ Differentiates a math function of two variables (x and y) Keyword arguments: function -- a Sympy object representation of the user's math function """ from sympy import symbols, diff x,y = symbols('x'), symbols('y') if type(functi...
def partial_diff(function):
""" Differentiates a math function of two variables (x and y) Keyword arguments: function -- a Sympy object representation of the user's math function """ from sympy import symbols, diff x,y = symbols('x'), symbols('y') if type(function) == str: expr = p...
[i][j] = expr.subs([(x, X[i][j]), (y, Y[i][j])]) ax.plot_surface(X, Y, Z, cmap='coolwarm_r') if file != None: plt.savefig(file) plt.close() def partial_diff(function):
64
64
113
5
59
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
partial_diff
partial_diff
189
207
189
189
ea998aadaf303cce16312244e867430ab94f489b
bigcode/the-stack
train
2175b49d096d40fc8b63e494
train
function
def preprocess(function): """ Converts a given function from type str to a Sympy object. Keyword arguments: function -- a string type representation of the user's math function """ import sympy expr = function while True: if '^' in expr: expr =...
def preprocess(function):
""" Converts a given function from type str to a Sympy object. Keyword arguments: function -- a string type representation of the user's math function """ import sympy expr = function while True: if '^' in expr: expr = expr[:expr.index('^')] + '...
# -*- coding: utf-8 -*- """ Graphing Calculator For a given math function, the program: Graphs Differentiates Integrates """ def preprocess(function):
41
64
106
4
37
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
preprocess
preprocess
11
29
11
11
61748c1fc487fe3c160010034d83887b6780b672
bigcode/the-stack
train
36966fd1d7d37e994c7f4003
train
function
def postprocess(function): """ Converts a given function from a Sympy object to a string type. Keyword arguments: function -- a Sympy object representation of the user's math function """ expr = str(function) while True: if '**' in expr: expr = ex...
def postprocess(function):
""" Converts a given function from a Sympy object to a string type. Keyword arguments: function -- a Sympy object representation of the user's math function """ expr = str(function) while True: if '**' in expr: expr = expr[:expr.index('**')] + '^' ...
= function while True: if '^' in expr: expr = expr[:expr.index('^')] + '**' + expr[expr.index('^')+1:] else: break expr = sympy.sympify(expr) return expr def postprocess(function):
64
64
97
5
58
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
postprocess
postprocess
32
47
32
32
18894b82759db069853445f6f3e2a939d2e0258d
bigcode/the-stack
train
9df3c428446ea63c200d1934
train
function
def integral(function): """ Integrates a single variable math function. Keyword arguments: function -- a Sympy object representation of the user's math function """ from sympy import symbols, Integral x = symbols('x') if type(function) == str: expr = prepro...
def integral(function):
""" Integrates a single variable math function. Keyword arguments: function -- a Sympy object representation of the user's math function """ from sympy import symbols, Integral x = symbols('x') if type(function) == str: expr = preprocess(function) else:...
for point in extrema: if subs(diff(slope), point) < 0: maxima.append(point) elif subs(diff(slope), point) > 0: minima.append(point) else: saddle.append(point) return minima, maxima, saddle def integral(function):
64
64
82
4
59
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
integral
integral
118
134
118
118
58e5fe83c930cb90458d42b6ace2bced3bd5f22b
bigcode/the-stack
train
194dfda6d6e218077fe01b14
train
function
def graph_3d(function, file): """ Graphs a math function on a 3 dimensional space. Keyword arguments: function -- a Sympy object representation of the user's math function file -- a filename to save the matplotlib figure """ from sympy import symbols import numpy as np ...
def graph_3d(function, file):
""" Graphs a math function on a 3 dimensional space. Keyword arguments: function -- a Sympy object representation of the user's math function file -- a filename to save the matplotlib figure """ from sympy import symbols import numpy as np from mpl_toolkits.mplot3d impo...
second_deriv = diff(first_deriv) third_deriv = diff(second_deriv) integ = integral(function) graph_2d(function, file) return [postprocess(first_deriv), postprocess(second_deriv), postprocess(third_deriv), integ, postprocess(integ.doit())] def graph_3d(function, file):
76
77
258
9
67
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
graph_3d
graph_3d
153
187
153
153
6c2f86c47d259828cfd539879b77ff310cd171c3
bigcode/the-stack
train
1908bfbeb113b1049e013fbc
train
function
def extrema(function): from sympy import symbols, solveset, Eq, subs x = symbols('x') slope = diff(function) extrema = solveset(Eq(slope, 0), x) minima, maxima, saddle = [], [], [] for point in extrema: if subs(diff(slope), point) < 0: maxima.append(poin...
def extrema(function):
from sympy import symbols, solveset, Eq, subs x = symbols('x') slope = diff(function) extrema = solveset(Eq(slope, 0), x) minima, maxima, saddle = [], [], [] for point in extrema: if subs(diff(slope), point) < 0: maxima.append(point) elif subs(diff...
-- a Sympy object representation of the user's math function """ import sympy x = sympy.symbols('x') if type(function) == str: expr = preprocess(function) else: expr = function return sympy.diff(expr, x) def extrema(function):
64
64
116
4
60
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
extrema
extrema
98
115
98
99
002fc24f3256ee7c35def46d052d5b86d0c03e6e
bigcode/the-stack
train
77232f0bbbf8d4d25cf39813
train
function
def multi_extrema(function): from sympy import symbols, sympify, linsolve x, y = symbols('x'), symbols('y') partial_X, partial_Y = partial_diff(function) solve_set = linsolve([partial_X, partial_Y], (x,y)) partial_XX, partial_XY = partial_diff(partial_X) partial_YY = partial_di...
def multi_extrema(function):
from sympy import symbols, sympify, linsolve x, y = symbols('x'), symbols('y') partial_X, partial_Y = partial_diff(function) solve_set = linsolve([partial_X, partial_Y], (x,y)) partial_XX, partial_XY = partial_diff(partial_X) partial_YY = partial_diff(partial_Y)[1] discrimi...
= symbols('x'), symbols('y') if type(function) == str: expr = preprocess(function) else: expr = function partial_X = diff(expr, x) partial_Y = diff(expr, y) return partial_X, partial_Y def multi_extrema(function):
64
64
207
6
57
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
multi_extrema
multi_extrema
210
230
210
210
34b947a557d02cd4795427998b6e84825e186fbd
bigcode/the-stack
train
2f98e70d58f5a588d725b21b
train
function
def dbl_integral(function): """ Evaluates a double integral of a math function with variables x and y. Keyword arguments: function -- a Sympy object representation of the user's math function """ from sympy import symbols, Integral x,y = symbols('x'), symbols('y') i...
def dbl_integral(function):
""" Evaluates a double integral of a math function with variables x and y. Keyword arguments: function -- a Sympy object representation of the user's math function """ from sympy import symbols, Integral x,y = symbols('x'), symbols('y') if type(function) == str: ...
[1])) < 0: maxima.append(pair) elif discriminant.subs((x, pair[0]), (y, pair[1])) > 0: minima.append(pair) else: saddle.append(pair) return minima, maxima, saddle def dbl_integral(function):
64
64
98
6
57
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
dbl_integral
dbl_integral
233
249
233
233
e3d71d2be314289a99e198fc137b87daa63731f6
bigcode/the-stack
train
ce9f71a7b660048d107efe64
train
function
def single_var(function, file): """ Calls the diff, integral, and graph_2d functions. Keyword arguments: function -- a Sympy object representation of the user's math function """ first_deriv = diff(function) second_deriv = diff(first_deriv) third_deriv = diff(second_deriv) ...
def single_var(function, file):
""" Calls the diff, integral, and graph_2d functions. Keyword arguments: function -- a Sympy object representation of the user's math function """ first_deriv = diff(function) second_deriv = diff(first_deriv) third_deriv = diff(second_deriv) integ = integral(function) ...
object representation of the user's math function """ from sympy import symbols, Integral x = symbols('x') if type(function) == str: expr = preprocess(function) else: expr = function return Integral(expr, (x)) def single_var(function, file):
63
64
120
7
56
jkjean19/GraphingCalc
app/GraphingCalc.py
Python
single_var
single_var
137
150
137
137
1cd0f45fa244b3a084fab404741173fc140dc132
bigcode/the-stack
train
e17dd435753fe39cb98a697a
train
function
def get_distributions_with_entry_point(working_set, entry_point_name): """ Return all distributions that contribute to an entry point. """ distributions = [] for distribution in working_set: if len(distribution.get_entry_map(entry_point_name)) > 0: distributions.append(distribution...
def get_distributions_with_entry_point(working_set, entry_point_name):
""" Return all distributions that contribute to an entry point. """ distributions = [] for distribution in working_set: if len(distribution.get_entry_map(entry_point_name)) > 0: distributions.append(distribution) return distributions
_distributions_in_egg_order(working_set, distributions) entry_points = [] for distribution in distributions: entry_map = distribution.get_entry_map(entry_point_name) entry_points.extend(list(entry_map.values())) return entry_points def get_distributions_with_entry_point(working_set, entry_...
64
64
66
15
48
robmcmullen/envisage
envisage/egg_utils.py
Python
get_distributions_with_entry_point
get_distributions_with_entry_point
53
63
53
53
d32297fef28f53fc8fd28562f8227c4cfe215505
bigcode/the-stack
train
cab11537c53d8739ab0091c8
train
function
def get_requires(working_set, distribution): """ Return all of the other distributions that a distribution requires. """ requires = [] for requirement in distribution.requires(): required = working_set.find(requirement) # fixme: For some reason, the resolution of requirements sometimes ...
def get_requires(working_set, distribution):
""" Return all of the other distributions that a distribution requires. """ requires = [] for requirement in distribution.requires(): required = working_set.find(requirement) # fixme: For some reason, the resolution of requirements sometimes # results in 'None' being returned instea...
_set # Build a dependency graph. graph = {} for distribution in distributions: arcs = graph.setdefault(distribution, []) arcs.extend(get_requires(working_set, distribution)) distributions = topological_sort(graph) distributions.reverse() return distributions def get_requires(w...
64
64
93
9
54
robmcmullen/envisage
envisage/egg_utils.py
Python
get_requires
get_requires
86
97
86
86
91d31b52c519e8ed1da24faf9a4dcddda85f36f7
bigcode/the-stack
train
c5b95238b64b5e2c9c765433
train
function
def add_eggs_on_path(working_set, path, on_error=None): """ Add all eggs found on the path to a working set. """ environment = pkg_resources.Environment(path) # 'find_plugins' identifies those distributions that *could* be added # to the working set without version conflicts or missing requirements. ...
def add_eggs_on_path(working_set, path, on_error=None):
""" Add all eggs found on the path to a working set. """ environment = pkg_resources.Environment(path) # 'find_plugins' identifies those distributions that *could* be added # to the working set without version conflicts or missing requirements. distributions, errors = working_set.find_plugins(envi...
""" Utility functions for working with Python Eggs. """ # Standard library imports. import pkg_resources # Enthought library imports. from traits.util.toposort import topological_sort def add_eggs_on_path(working_set, path, on_error=None):
54
64
157
17
36
robmcmullen/envisage
envisage/egg_utils.py
Python
add_eggs_on_path
add_eggs_on_path
11
30
11
11
739e0db0fe820f56f491ab53b48955b4549e6d54
bigcode/the-stack
train
1af6ddd315974aa228966bfa
train
function
def get_entry_points_in_egg_order(working_set, entry_point_name): """ Return entry points in Egg dependency order. """ # Find all distributions that actually contain contributions to the # entry point. distributions = get_distributions_with_entry_point( working_set, entry_point_name ) ...
def get_entry_points_in_egg_order(working_set, entry_point_name):
""" Return entry points in Egg dependency order. """ # Find all distributions that actually contain contributions to the # entry point. distributions = get_distributions_with_entry_point( working_set, entry_point_name ) # Order them in dependency order (i.e. ordered by their requiremen...
eggs %s' % errors) # Add the distributions to the working set (this makes any Python # modules in the eggs available for importing). for distribution in distributions: working_set.add(distribution) return def get_entry_points_in_egg_order(working_set, entry_point_name):
64
64
133
16
47
robmcmullen/envisage
envisage/egg_utils.py
Python
get_entry_points_in_egg_order
get_entry_points_in_egg_order
33
50
33
33
c210fe0df11cf6f2846e706e8d0c5105f666f181
bigcode/the-stack
train
8ed705fe82925582e6e74973
train
function
def get_distributions_in_egg_order(working_set, distributions=None): """ Return all distributions in Egg dependency order. """ # If no specific list of distributions is specified then use all # distributions in the working set. if distributions is None: distributions = working_set # Build ...
def get_distributions_in_egg_order(working_set, distributions=None):
""" Return all distributions in Egg dependency order. """ # If no specific list of distributions is specified then use all # distributions in the working set. if distributions is None: distributions = working_set # Build a dependency graph. graph = {} for distribution in distributi...
Return all distributions that contribute to an entry point. """ distributions = [] for distribution in working_set: if len(distribution.get_entry_map(entry_point_name)) > 0: distributions.append(distribution) return distributions def get_distributions_in_egg_order(working_set, di...
64
64
113
15
48
robmcmullen/envisage
envisage/egg_utils.py
Python
get_distributions_in_egg_order
get_distributions_in_egg_order
66
83
66
66
45d22b950f7cddc14bd9cc130797e166d899c799
bigcode/the-stack
train
722678e1e4ccb456bb19fe24
train
class
class TFGeneric(ops.Operation): """A generic op that can represent any keras layer.""" @unique class AttrName(base_op.AutoName): LAYER_CLASS = auto() def __init__(self, *args, **kwargs): super(TFGeneric, self).__init__(OpTypes.GENERIC, *args, **kwargs) self._define_attr(self.AttrName.LAYER_CLASS, ...
class TFGeneric(ops.Operation):
"""A generic op that can represent any keras layer.""" @unique class AttrName(base_op.AutoName): LAYER_CLASS = auto() def __init__(self, *args, **kwargs): super(TFGeneric, self).__init__(OpTypes.GENERIC, *args, **kwargs) self._define_attr(self.AttrName.LAYER_CLASS, value_type=type, size=1)
from __future__ import print_function from enum import Enum, unique, auto from tf_nndct.graph import OpTypes from tf_nndct.graph import base_op from tf_nndct.graph import dtypes from tf_nndct.graph import ops class TFGeneric(ops.Operation):
64
64
96
7
56
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFGeneric
TFGeneric
27
36
27
27
e935609f54e4a801e0b26d7c0889679c543af82f
bigcode/the-stack
train
4bcfef0adb4b4f03f9db00bd
train
class
class TFInput(ops.Operation): @unique class AttrName(ops.AutoName): SHAPE = auto() DTYPE = auto() def __init__(self, *args, **kwargs): super(TFInput, self).__init__(OpTypes.INPUT, *args, **kwargs) self._attr_value_mem = {self.AttrName.SHAPE: [], self.AttrName.DTYPE: []} self._attrs[self.Att...
class TFInput(ops.Operation): @unique
class AttrName(ops.AutoName): SHAPE = auto() DTYPE = auto() def __init__(self, *args, **kwargs): super(TFInput, self).__init__(OpTypes.INPUT, *args, **kwargs) self._attr_value_mem = {self.AttrName.SHAPE: [], self.AttrName.DTYPE: []} self._attrs[self.AttrName.SHAPE] = ops.Attr( name=sel...
LAYER_CLASS = auto() def __init__(self, *args, **kwargs): super(TFGeneric, self).__init__(OpTypes.GENERIC, *args, **kwargs) self._define_attr(self.AttrName.LAYER_CLASS, value_type=type, size=1) #TODO(yuwang): Use _define_attr to define attr. class TFInput(ops.Operation): @unique
89
89
298
11
78
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFInput
TFInput
39
79
39
41
b61b0c3a21a57f5faf07b14fef5ab402b77a4cc0
bigcode/the-stack
train
c01079a7776aba4ab9c5359d
train
class
class TFSimpleRNN(ops.Operation): @unique class ParamName(ops.AutoName): KERNEL = 'kernel' RECURRENT_KERNEL = 'recurrent_kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFSimpleRNN, self).__init__(OpTypes.SIMPLE_RNN, *args, **kwargs)
class TFSimpleRNN(ops.Operation): @unique
class ParamName(ops.AutoName): KERNEL = 'kernel' RECURRENT_KERNEL = 'recurrent_kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFSimpleRNN, self).__init__(OpTypes.SIMPLE_RNN, *args, **kwargs)
StackedRNNCells, self).__init__(OpTypes.STACKED_RNN_CELLS, *args, **kwargs) self._define_attr(self.AttrName.CELLS, value_type=ops.Operation, size=None) class TFSimpleRNN(ops.Operation): @unique
64
64
85
14
50
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFSimpleRNN
TFSimpleRNN
282
291
282
284
3da30d72826e003220d357995009e3536dd31109
bigcode/the-stack
train
c42f850dd53b76ff8e76b76e
train
class
class TFBatchNorm(base_op.BatchNorm): @unique class ParamName(base_op.AutoName): GAMMA = auto() BETA = auto() MOVING_MEAN = auto() MOVING_VAR = 'moving_variance' def __init__(self, *args, **kwargs): super(TFBatchNorm, self).__init__(OpTypes.BATCH_NORM, *args, **kwargs) @property def eps...
class TFBatchNorm(base_op.BatchNorm): @unique
class ParamName(base_op.AutoName): GAMMA = auto() BETA = auto() MOVING_MEAN = auto() MOVING_VAR = 'moving_variance' def __init__(self, *args, **kwargs): super(TFBatchNorm, self).__init__(OpTypes.BATCH_NORM, *args, **kwargs) @property def epsilon(self): return self.attr['epsilon'] @e...
def use_bias(self, value): self.attr['bias_term'] = value @property def units(self): return self.attr['out_dim'] @units.setter def units(self, value): self.attr['out_dim'] = value class TFBatchNorm(base_op.BatchNorm): @unique
71
71
238
14
56
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFBatchNorm
TFBatchNorm
115
157
115
117
223b15bf8746afa23496883153c3fc7d4b8307ae
bigcode/the-stack
train
b418976bf8178732e64632c6
train
class
class TFDense(base_op.Dense): @unique class AttrName(ops.AutoName): BIAS_TERM = auto() IN_DIM = auto() OUT_DIM = auto() ACTIVATION = auto() @unique class ParamName(ops.AutoName): WEIGHTS = 'kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFDense, self).__init__(...
class TFDense(base_op.Dense): @unique
class AttrName(ops.AutoName): BIAS_TERM = auto() IN_DIM = auto() OUT_DIM = auto() ACTIVATION = auto() @unique class ParamName(ops.AutoName): WEIGHTS = 'kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFDense, self).__init__(OpTypes.DENSE, *args, **kwargs) self....
def shape(self, value): self.attr['shape'] = value @property def dtype(self): return self.attr['dtype'] @dtype.setter def dtype(self, value): self.attr['dtype'] = value class TFDense(base_op.Dense): @unique
64
64
209
12
51
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFDense
TFDense
81
113
81
83
91ed2e8a69a20cc5c0ad1911cb0e49ea4c4d0939
bigcode/the-stack
train
2e304e9ccaeb114c6caf28af
train
class
class TFEmbedding(ops.Operation): @unique class ParamName(ops.AutoName): EMBEDDINGS = 'embeddings' def __init__(self, *args, **kwargs): super(TFEmbedding, self).__init__(OpTypes.EMBEDDING, *args, **kwargs)
class TFEmbedding(ops.Operation): @unique
class ParamName(ops.AutoName): EMBEDDINGS = 'embeddings' def __init__(self, *args, **kwargs): super(TFEmbedding, self).__init__(OpTypes.EMBEDDING, *args, **kwargs)
value): self.attr['group'] = value @property def use_bias(self): return self.attr['bias_term'] @use_bias.setter def use_bias(self, value): self.attr['bias_term'] = value class TFEmbedding(ops.Operation): @unique
64
64
65
11
52
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFEmbedding
TFEmbedding
241
248
241
243
e17ee0b6c0cdc55a240573966759b15ebe6f8e49
bigcode/the-stack
train
cb07e57692c15eafd625a711
train
class
class TFBidirectional(ops.Operation): def __init__(self, *args, **kwargs): super(TFBidirectional, self).__init__(OpTypes.BIDIRECTIONAL_RNN, *args, **kwargs)
class TFBidirectional(ops.Operation):
def __init__(self, *args, **kwargs): super(TFBidirectional, self).__init__(OpTypes.BIDIRECTIONAL_RNN, *args, **kwargs)
'kernel' RECURRENT_KERNEL = 'recurrent_kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFGRU, self).__init__(OpTypes.GRU, *args, **kwargs) class TFBidirectional(ops.Operation):
64
64
49
9
55
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFBidirectional
TFBidirectional
315
319
315
316
5f7b9c3d2ef8124ec606735934c616e818235f99
bigcode/the-stack
train
d1baa6ac742d478ee5b9f3d2
train
class
class TFConv2D(base_op.Conv2d): @unique class AttrName(ops.AutoName): KERNEL = auto() STRIDE = auto() DILATION = auto() PAD_MODE = auto() PAD = auto() GROUP = auto() BIAS_TERM = auto() IN_DIM = auto() OUT_DIM = auto() ACTIVATION = auto() @unique class ParamName(ops.Auto...
class TFConv2D(base_op.Conv2d): @unique
class AttrName(ops.AutoName): KERNEL = auto() STRIDE = auto() DILATION = auto() PAD_MODE = auto() PAD = auto() GROUP = auto() BIAS_TERM = auto() IN_DIM = auto() OUT_DIM = auto() ACTIVATION = auto() @unique class ParamName(ops.AutoName): WEIGHTS = 'kernel' BIAS = 'b...
.setter def epsilon(self, value): self.attr['epsilon'] = value @property def scale(self): return self.attr['scale'] @scale.setter def scale(self, value): self.attr['scale'] = value @property def center(self): return self.attr['center'] @center.setter def center(self, value): se...
144
144
480
15
128
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFConv2D
TFConv2D
159
239
159
161
05ce455e07da8b2196bac5b60cd8cc319caf9f7e
bigcode/the-stack
train
382b8cf056c5156c4d128e8c
train
class
class TFStackedRNNCells(ops.Operation): @unique class AttrName(ops.AutoName): CELLS = auto() def __init__(self, *args, **kwargs): super(TFStackedRNNCells, self).__init__(OpTypes.STACKED_RNN_CELLS, *args, **kwargs) self._define_attr(self.AttrName.CELLS, va...
class TFStackedRNNCells(ops.Operation): @unique
class AttrName(ops.AutoName): CELLS = auto() def __init__(self, *args, **kwargs): super(TFStackedRNNCells, self).__init__(OpTypes.STACKED_RNN_CELLS, *args, **kwargs) self._define_attr(self.AttrName.CELLS, value_type=ops.Operation, size=None)
*args, **kwargs): super(TFRNN, self).__init__(OpTypes.RNN, *args, **kwargs) self._define_attr(self.AttrName.CELL, value_type=ops.Operation, size=1) class TFStackedRNNCells(ops.Operation): @unique
64
64
97
15
49
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFStackedRNNCells
TFStackedRNNCells
270
280
270
272
7c5bafed63ebb94eb63f79d3b10e495ab8b8ad72
bigcode/the-stack
train
6676003df38db4d5d5b044b2
train
class
class TFGRU(ops.Operation): @unique class ParamName(ops.AutoName): KERNEL = 'kernel' RECURRENT_KERNEL = 'recurrent_kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFGRU, self).__init__(OpTypes.GRU, *args, **kwargs)
class TFGRU(ops.Operation): @unique
class ParamName(ops.AutoName): KERNEL = 'kernel' RECURRENT_KERNEL = 'recurrent_kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFGRU, self).__init__(OpTypes.GRU, *args, **kwargs)
' RECURRENT_KERNEL = 'recurrent_kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFLSTM, self).__init__(OpTypes.LSTM, *args, **kwargs) class TFGRU(ops.Operation): @unique
64
64
80
12
52
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFGRU
TFGRU
304
313
304
306
f7b9ebd69d7221506ce6848c9ee48367360bb776
bigcode/the-stack
train
59dc0d35aa42bbcb8d7ec34f
train
class
class TFRNNLayer(ops.Operation): @unique class AttrName(ops.AutoName): LAYER_CLASS = auto() def __init__(self, *args, **kwargs): super(TFRNNLayer, self).__init__(OpTypes.RNN_LAYER, *args, **kwargs) self._define_attr(self.AttrName.LAYER_CLASS, value_type=type, size=1)
class TFRNNLayer(ops.Operation): @unique
class AttrName(ops.AutoName): LAYER_CLASS = auto() def __init__(self, *args, **kwargs): super(TFRNNLayer, self).__init__(OpTypes.RNN_LAYER, *args, **kwargs) self._define_attr(self.AttrName.LAYER_CLASS, value_type=type, size=1)
Name(ops.AutoName): EMBEDDINGS = 'embeddings' def __init__(self, *args, **kwargs): super(TFEmbedding, self).__init__(OpTypes.EMBEDDING, *args, **kwargs) class TFRNNLayer(ops.Operation): @unique
64
64
87
13
51
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFRNNLayer
TFRNNLayer
250
258
250
252
e15f3204b2e1481065bbaa98c49993b063558d31
bigcode/the-stack
train
71a934de5bc2f9eab0dd3163
train
class
class TFLSTM(ops.Operation): @unique class ParamName(ops.AutoName): KERNEL = 'kernel' RECURRENT_KERNEL = 'recurrent_kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFLSTM, self).__init__(OpTypes.LSTM, *args, **kwargs)
class TFLSTM(ops.Operation): @unique
class ParamName(ops.AutoName): KERNEL = 'kernel' RECURRENT_KERNEL = 'recurrent_kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFLSTM, self).__init__(OpTypes.LSTM, *args, **kwargs)
_KERNEL = 'recurrent_kernel' BIAS = 'bias' def __init__(self, *args, **kwargs): super(TFSimpleRNN, self).__init__(OpTypes.SIMPLE_RNN, *args, **kwargs) class TFLSTM(ops.Operation): @unique
64
64
79
12
52
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFLSTM
TFLSTM
293
302
293
295
b14a796a5d6fac1b33a652aa9f70ab10527b6936
bigcode/the-stack
train
6cb2c957ed207a7c4efff297
train
class
class TFRNN(ops.Operation): @unique class AttrName(ops.AutoName): CELL = auto() def __init__(self, *args, **kwargs): super(TFRNN, self).__init__(OpTypes.RNN, *args, **kwargs) self._define_attr(self.AttrName.CELL, value_type=ops.Operation, size=1)
class TFRNN(ops.Operation): @unique
class AttrName(ops.AutoName): CELL = auto() def __init__(self, *args, **kwargs): super(TFRNN, self).__init__(OpTypes.RNN, *args, **kwargs) self._define_attr(self.AttrName.CELL, value_type=ops.Operation, size=1)
, *args, **kwargs): super(TFRNNLayer, self).__init__(OpTypes.RNN_LAYER, *args, **kwargs) self._define_attr(self.AttrName.LAYER_CLASS, value_type=type, size=1) class TFRNN(ops.Operation): @unique
64
64
82
12
52
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFRNN
TFRNN
260
268
260
262
a7227c665f52607eccad49a263998a86d78f0cc9
bigcode/the-stack
train
a4f8b6be424b99ec9cd87c31
train
class
class TFMultiply(base_op.BinaryOp): def __init__(self, *args, **kwargs): super(TFMultiply, self).__init__(OpTypes.MULTIPLY, *args, **kwargs)
class TFMultiply(base_op.BinaryOp):
def __init__(self, *args, **kwargs): super(TFMultiply, self).__init__(OpTypes.MULTIPLY, *args, **kwargs)
, *args, **kwargs) class TFBidirectional(ops.Operation): def __init__(self, *args, **kwargs): super(TFBidirectional, self).__init__(OpTypes.BIDIRECTIONAL_RNN, *args, **kwargs) class TFMultiply(base_op.BinaryOp):
64
64
43
8
56
hito0512/Vitis-AI
tools/RNN/rnn_quantizer/tensorflow/tf_nndct/graph/op_def.py
Python
TFMultiply
TFMultiply
321
324
321
322
b0ed1c4c4eb52ceba2ddcf0ae6f8fc4db4fac4a8
bigcode/the-stack
train
4787232d0459691a2d48117d
train
class
class soundSpace(ShowBase): voiceSourceList = [] #List of voice source objects (sound stream from mics) musicSource = None #Source of room music (music streaming service) musicMgr = None seatCoord = [] #List of calculated x,y coordinates of "seats" #On init calculates all seat postions #builds...
class soundSpace(ShowBase):
voiceSourceList = [] #List of voice source objects (sound stream from mics) musicSource = None #Source of room music (music streaming service) musicMgr = None seatCoord = [] #List of calculated x,y coordinates of "seats" #On init calculates all seat postions #builds an audio object at each virt...
import math from math import pi,sin,cos from direct.showbase.ShowBase import ShowBase from direct.task import Task from direct.showbase.Audio3DManager import Audio3DManager #creates a room object, requires parameter of max number of voice users #author: kevin good #to run create instance of class followed by soundSpa...
94
201
670
7
86
Prakshal-Jain/CodeAura
Algorithms/Multi-Dimentional_Audio/CodeAura_SoundSpace.py
Python
soundSpace
soundSpace
12
76
12
13
ef6d13a530674f449183e8a3a64dfca115fee0fe
bigcode/the-stack
train
874e4754a08891e19e69630c
train
function
def main(): print("Start Hybrid A* planning") ox, oy = [], [] for i in range(60): ox.append(i) oy.append(0.0) for i in range(60): ox.append(60.0) oy.append(i) for i in range(61): ox.append(i) oy.append(60.0) for i in range(61): ox.append(...
def main():
print("Start Hybrid A* planning") ox, oy = [], [] for i in range(60): ox.append(i) oy.append(0.0) for i in range(60): ox.append(60.0) oy.append(i) for i in range(61): ox.append(i) oy.append(60.0) for i in range(61): ox.append(0.0) ...
if xind >= c.minx and xind <= c.maxx and yind >= c.miny \ and yind <= c.maxy: return True return False def calc_index(node, c): ind = (node.yawind - c.minyaw) * c.xw * c.yw + \ (node.yind - c.miny) * c.xw + (node.xind - c.minx) if ind <= 0: print("Error(calc_inde...
120
120
400
3
116
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
main
main
409
460
409
409
ceb0dd30458d340b0d6a2e19a49dfe044e58030c
bigcode/the-stack
train
45f33ebaa49e5ca4f5a6cc4e
train
class
class KDTree: """ Nearest neighbor search class with KDTree """ def __init__(self, data): # store kd-tree self.tree = scipy.spatial.cKDTree(data) def search(self, inp, k=1): """ Search NN inp: input data, single frame or multi frame """ if l...
class KDTree:
""" Nearest neighbor search class with KDTree """ def __init__(self, data): # store kd-tree self.tree = scipy.spatial.cKDTree(data) def search(self, inp, k=1): """ Search NN inp: input data, single frame or multi frame """ if len(inp.shape) ...
def __init__(self, xlist, ylist, yawlist, directionlist, cost): self.xlist = xlist self.ylist = ylist self.yawlist = yawlist self.directionlist = directionlist self.cost = cost class KDTree:
64
64
198
4
59
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
KDTree
KDTree
68
103
68
68
47b968367fb15eeb68a70105bc6e7ea93fbfb03c
bigcode/the-stack
train
0eab7e9fbfe93358620fd506
train
function
def analytic_expantion(current, goal, c, ox, oy, kdtree): sx = current.xlist[-1] sy = current.ylist[-1] syaw = current.yawlist[-1] gx = goal.xlist[-1] gy = goal.ylist[-1] gyaw = goal.yawlist[-1] max_curvature = math.tan(MAX_STEER) / WB paths = rs.calc_paths(sx, sy, syaw, gx, gy, gyaw,...
def analytic_expantion(current, goal, c, ox, oy, kdtree):
sx = current.xlist[-1] sy = current.ylist[-1] syaw = current.yawlist[-1] gx = goal.xlist[-1] gy = goal.ylist[-1] gyaw = goal.yawlist[-1] max_curvature = math.tan(MAX_STEER) / WB paths = rs.calc_paths(sx, sy, syaw, gx, gy, gyaw, max_curvature, step_size=MOTION_...
n2): if n1.xind == n2.xind and n1.yind == n2.yind and n1.yawind == n2.yawind: return True return False def analytic_expantion(current, goal, c, ox, oy, kdtree):
64
64
208
19
44
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
analytic_expantion
analytic_expantion
194
220
194
195
dd6b03fe4d8f8ab5c3777df552d99f1bd55d18ec
bigcode/the-stack
train
4b61b566857d75eeee3a4e04
train
function
def get_neighbors(current, config, ox, oy, kdtree): for steer, d in calc_motion_inputs(): node = calc_next_node(current, steer, d, config, ox, oy, kdtree) if node and verify_index(node, config): yield node
def get_neighbors(current, config, ox, oy, kdtree):
for steer, d in calc_motion_inputs(): node = calc_next_node(current, steer, d, config, ox, oy, kdtree) if node and verify_index(node, config): yield node
.minyaw) def calc_motion_inputs(): for steer in np.linspace(-MAX_STEER, MAX_STEER, N_STEER): for d in [1, -1]: yield [steer, d] def get_neighbors(current, config, ox, oy, kdtree):
64
64
61
15
49
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
get_neighbors
get_neighbors
139
144
139
140
63d90c65c4aa5e700f40361f95871046e18c3477
bigcode/the-stack
train
37b8ec6f0164900f8eaf38b3
train
function
def calc_index(node, c): ind = (node.yawind - c.minyaw) * c.xw * c.yw + \ (node.yind - c.miny) * c.xw + (node.xind - c.minx) if ind <= 0: print("Error(calc_index):", ind) return ind
def calc_index(node, c):
ind = (node.yawind - c.minyaw) * c.xw * c.yw + \ (node.yind - c.miny) * c.xw + (node.xind - c.minx) if ind <= 0: print("Error(calc_index):", ind) return ind
c): xind, yind = node.xind, node.yind if xind >= c.minx and xind <= c.maxx and yind >= c.miny \ and yind <= c.maxy: return True return False def calc_index(node, c):
64
64
76
7
56
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
calc_index
calc_index
399
406
399
399
95e4992d4b2c2da42b09b0f2ed8a2414c3006850
bigcode/the-stack
train
30d293f8db20a584bac653b5
train
function
def calc_motion_inputs(): for steer in np.linspace(-MAX_STEER, MAX_STEER, N_STEER): for d in [1, -1]: yield [steer, d]
def calc_motion_inputs():
for steer in np.linspace(-MAX_STEER, MAX_STEER, N_STEER): for d in [1, -1]: yield [steer, d]
self.yw = round(self.maxy - self.miny) self.minyaw = round(- math.pi / yawreso) - 1 self.maxyaw = round(math.pi / yawreso) self.yaww = round(self.maxyaw - self.minyaw) def calc_motion_inputs():
64
64
45
5
59
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
calc_motion_inputs
calc_motion_inputs
132
136
132
133
e906277a2398d5e4dfe45f8a3d0c2a35ba3901eb
bigcode/the-stack
train
9fa3f4310f1fcaea52502915
train
function
def hybrid_a_star_planning(start, goal, ox, oy, xyreso, yawreso): """ start goal ox: x position list of Obstacles [m] oy: y position list of Obstacles [m] xyreso: grid resolution [m] yawreso: yaw angle resolution [rad] """ start[2], goal[2] = rs.pi_2_pi(start[2]), rs.pi_2_pi(goal[2]...
def hybrid_a_star_planning(start, goal, ox, oy, xyreso, yawreso):
""" start goal ox: x position list of Obstacles [m] oy: y position list of Obstacles [m] xyreso: grid resolution [m] yawreso: yaw angle resolution [rad] """ start[2], goal[2] = rs.pi_2_pi(start[2]), rs.pi_2_pi(goal[2]) tox, toy = ox[:], oy[:] obkdtree = KDTree(np.vstack((to...
penalyty for ctype in rspath.ctypes: if ctype != "S": # curve cost += STEER_COST * abs(MAX_STEER) # ==steer change penalty # calc steer profile nctypes = len(rspath.ctypes) ulist = [0.0] * nctypes for i in range(nctypes): if rspath.ctypes[i] == "R": uli...
195
195
652
20
174
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
hybrid_a_star_planning
hybrid_a_star_planning
284
351
284
284
7c233f02d67af271502b666243c1406b8362cf9c
bigcode/the-stack
train
b2340a07e92117c39144954a
train
class
class Node: def __init__(self, xind, yind, yawind, direction, xlist, ylist, yawlist, directions, steer=0.0, pind=None, cost=None): self.xind = xind self.yind = yind self.yawind = yawind self.direction = direction self.xlist = xlist s...
class Node:
def __init__(self, xind, yind, yawind, direction, xlist, ylist, yawlist, directions, steer=0.0, pind=None, cost=None): self.xind = xind self.yind = yind self.yawind = yawind self.direction = direction self.xlist = xlist self.ylist = y...
5.0 # backward penalty cost STEER_CHANGE_COST = 5.0 # steer angle change penalty cost STEER_COST = 1.0 # steer angle change penalty cost H_COST = 5.0 # Heuristic cost show_animation = True class Node:
64
64
129
3
60
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
Node
Node
40
55
40
41
8b3cf5904d66471d82b04f837de08f3a3f867d33
bigcode/the-stack
train
55e748adbcf6cb93046d845d
train
function
def get_final_path(closed, ngoal, nstart, config): rx, ry, ryaw = list(reversed(ngoal.xlist)), list( reversed(ngoal.ylist)), list(reversed(ngoal.yawlist)) direction = list(reversed(ngoal.directions)) nid = ngoal.pind finalcost = ngoal.cost while nid: n = closed[nid] rx.exten...
def get_final_path(closed, ngoal, nstart, config):
rx, ry, ryaw = list(reversed(ngoal.xlist)), list( reversed(ngoal.ylist)), list(reversed(ngoal.yawlist)) direction = list(reversed(ngoal.directions)) nid = ngoal.pind finalcost = ngoal.cost while nid: n = closed[nid] rx.extend(list(reversed(n.xlist))) ry.extend(list(r...
c.xw + (n.xind - c.minx) if ind not in h_dp: return n.cost + 999999999 # collision cost return n.cost + H_COST * h_dp[ind].cost def get_final_path(closed, ngoal, nstart, config):
64
64
212
15
48
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
get_final_path
get_final_path
361
387
361
361
99c25befcfdddbd16bbc83a24184f3d043cd4ff7
bigcode/the-stack
train
97c5abf190a970cc2143d980
train
function
def verify_index(node, c): xind, yind = node.xind, node.yind if xind >= c.minx and xind <= c.maxx and yind >= c.miny \ and yind <= c.maxy: return True return False
def verify_index(node, c):
xind, yind = node.xind, node.yind if xind >= c.minx and xind <= c.maxx and yind >= c.miny \ and yind <= c.maxy: return True return False
ry)) ryaw = list(reversed(ryaw)) direction = list(reversed(direction)) # adjust first direction direction[0] = direction[1] path = Path(rx, ry, ryaw, direction, finalcost) return path def verify_index(node, c):
64
64
62
7
56
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
verify_index
verify_index
390
396
390
390
3d19c3844c96e509ae7dd0d8a7f6d2789a376b86
bigcode/the-stack
train
53b4470a15c3792119f65858
train
function
def calc_cost(n, h_dp, goal, c): ind = (n.yind - c.miny) * c.xw + (n.xind - c.minx) if ind not in h_dp: return n.cost + 999999999 # collision cost return n.cost + H_COST * h_dp[ind].cost
def calc_cost(n, h_dp, goal, c):
ind = (n.yind - c.miny) * c.xw + (n.xind - c.minx) if ind not in h_dp: return n.cost + 999999999 # collision cost return n.cost + H_COST * h_dp[ind].cost
pq, (calc_cost(neighbor, h_dp, ngoal, config), neighbor_index)) openList[neighbor_index] = neighbor path = get_final_path(closedList, fpath, nstart, config) return path def calc_cost(n, h_dp, goal, c):
64
64
74
12
51
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
calc_cost
calc_cost
354
358
354
354
8d7f062dc6e70cee128dc217d94f1fc4a119b989
bigcode/the-stack
train
3801013c82428cc88e3fe10a
train
function
def calc_rs_path_cost(rspath): cost = 0.0 for l in rspath.lengths: if l >= 0: # forward cost += l else: # back cost += abs(l) * BACK_COST # swich back penalty for i in range(len(rspath.lengths) - 1): if rspath.lengths[i] * rspath.lengths[i + 1] < 0.0: ...
def calc_rs_path_cost(rspath):
cost = 0.0 for l in rspath.lengths: if l >= 0: # forward cost += l else: # back cost += abs(l) * BACK_COST # swich back penalty for i in range(len(rspath.lengths) - 1): if rspath.lengths[i] * rspath.lengths[i + 1] < 0.0: # switch back cost ...
]: fd.append(d >= 0) fsteer = 0.0 fpath = Node(current.xind, current.yind, current.yawind, current.direction, fx, fy, fyaw, fd, cost=fcost, pind=fpind, steer=fsteer) return True, fpath return False, None def calc_rs_path_cost(rspath):
87
87
293
8
78
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
calc_rs_path_cost
calc_rs_path_cost
249
281
249
250
240ca938564943cee59dadbd3ed8933abaf28ecd
bigcode/the-stack
train
4afa14d974909f0c7383d56f
train
function
def calc_next_node(current, steer, direction, config, ox, oy, kdtree): x, y, yaw = current.xlist[-1], current.ylist[-1], current.yawlist[-1] arc_l = XY_GRID_RESOLUTION * 1.5 xlist, ylist, yawlist = [], [], [] for dist in np.arange(0, arc_l, MOTION_RESOLUTION): x, y, yaw = move(x, y, yaw, MOTIO...
def calc_next_node(current, steer, direction, config, ox, oy, kdtree):
x, y, yaw = current.xlist[-1], current.ylist[-1], current.yawlist[-1] arc_l = XY_GRID_RESOLUTION * 1.5 xlist, ylist, yawlist = [], [], [] for dist in np.arange(0, arc_l, MOTION_RESOLUTION): x, y, yaw = move(x, y, yaw, MOTION_RESOLUTION * direction, steer) xlist.append(x) ylist.a...
for d in [1, -1]: yield [steer, d] def get_neighbors(current, config, ox, oy, kdtree): for steer, d in calc_motion_inputs(): node = calc_next_node(current, steer, d, config, ox, oy, kdtree) if node and verify_index(node, config): yield node def calc_next_node(curre...
99
99
331
20
78
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
calc_next_node
calc_next_node
147
185
147
148
0e12f3dca5cd2a789fa95d7834eb82227575a799
bigcode/the-stack
train
96d0b2bf8061a172db0cf041
train
function
def update_node_with_analystic_expantion(current, goal, c, ox, oy, kdtree): apath = analytic_expantion(current, goal, c, ox, oy, kdtree) if apath: plt.plot(apath.x, apath.y) fx = apath.x[1:] fy = apath.y[1:] fyaw = apath.yaw[1:] ...
def update_node_with_analystic_expantion(current, goal, c, ox, oy, kdtree):
apath = analytic_expantion(current, goal, c, ox, oy, kdtree) if apath: plt.plot(apath.x, apath.y) fx = apath.x[1:] fy = apath.y[1:] fyaw = apath.yaw[1:] fcost = current.cost + calc_rs_path_cost(apath) fpind = calc_index(current, c) fd = [] for d...
kdtree): cost = calc_rs_path_cost(path) if not best or best > cost: best = cost best_path = path return best_path def update_node_with_analystic_expantion(current, goal, c, ox, oy, kdtree):
64
64
211
26
37
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
update_node_with_analystic_expantion
update_node_with_analystic_expantion
223
246
223
224
92e85c10f06157e28ca64c9bf53a0ca60c3a43db
bigcode/the-stack
train
008247816a2416f4c30b65be
train
class
class Path: def __init__(self, xlist, ylist, yawlist, directionlist, cost): self.xlist = xlist self.ylist = ylist self.yawlist = yawlist self.directionlist = directionlist self.cost = cost
class Path:
def __init__(self, xlist, ylist, yawlist, directionlist, cost): self.xlist = xlist self.ylist = ylist self.yawlist = yawlist self.directionlist = directionlist self.cost = cost
yawind self.direction = direction self.xlist = xlist self.ylist = ylist self.yawlist = yawlist self.directions = directions self.steer = steer self.pind = pind self.cost = cost class Path:
64
64
63
3
60
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
Path
Path
58
65
58
59
d6dec53b1e5852752eab27d5c76f68efaf01f378
bigcode/the-stack
train
24f8ef8705e63a6269148b12
train
class
class Config: def __init__(self, ox, oy, xyreso, yawreso): min_x_m = min(ox) min_y_m = min(oy) max_x_m = max(ox) max_y_m = max(oy) ox.append(min_x_m) oy.append(min_y_m) ox.append(max_x_m) oy.append(max_y_m) self.minx = round(min_x_m / xyreso...
class Config:
def __init__(self, ox, oy, xyreso, yawreso): min_x_m = min(ox) min_y_m = min(oy) max_x_m = max(ox) max_y_m = max(oy) ox.append(min_x_m) oy.append(min_y_m) ox.append(max_x_m) oy.append(max_y_m) self.minx = round(min_x_m / xyreso) self....
dist dist, index = self.tree.query(inp, k=k) return index, dist def search_in_distance(self, inp, r): """ find points with in a distance r """ index = self.tree.query_ball_point(inp, r) return index class Config:
64
64
209
3
60
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
Config
Config
106
129
106
107
f4e55b23a1cbb4319416c5fe5645f9e19db4f94e
bigcode/the-stack
train
672aca7991f9abcf23b73f7d
train
function
def is_same_grid(n1, n2): if n1.xind == n2.xind and n1.yind == n2.yind and n1.yawind == n2.yawind: return True return False
def is_same_grid(n1, n2):
if n1.xind == n2.xind and n1.yind == n2.yind and n1.yawind == n2.yawind: return True return False
arc_l node = Node(xind, yind, yawind, d, xlist, ylist, yawlist, [d], pind=calc_index(current, config), cost=cost, steer=steer) return node def is_same_grid(n1, n2):
64
64
52
10
53
c964309085/PythonRobotics
PathPlanning/HybridAStar/hybrid_a_star.py
Python
is_same_grid
is_same_grid
188
191
188
188
40bbd1789dc1a26c4c182d57284ad5b03b3698ae
bigcode/the-stack
train
89df23771c6afe31d6d62948
train
function
def get_dataset(file_path): return tf.data.experimental.make_csv_dataset( file_path, batch_size=12, label_name='label', na_value="0", num_epochs=1, ignore_errors=True )
def get_dataset(file_path):
return tf.data.experimental.make_csv_dataset( file_path, batch_size=12, label_name='label', na_value="0", num_epochs=1, ignore_errors=True )
ensorflow_models/data/trainingSamples.csv") ## Testing samples path test_samples_file_path = tf.keras.utils.get_file(fname="testSamples.csv", origin="file:///Users/sabo/PycharmProjects/tensorflow_models/data/testSamples.csv") # load data as tf dataset def get_dataset(f...
64
64
50
6
57
jaykay233/tensorflow_models
rec_models/Embedding_MLP.py
Python
get_dataset
get_dataset
12
20
12
12
7c2ad378eb9439e036dcafedaa5dd26b33fad364
bigcode/the-stack
train
b9a97df99d479bd6abf8f009
train
class
class YumRepo(object): def __init__(self, repourl, content='', dst_repos_dir=YUM_REPOS_DIR, add_hash=True): self.add_hash = add_hash self.repourl = repourl self.dst_repos_dir = dst_repos_dir self._content = None self.content = content self.config = None @propert...
class YumRepo(object):
def __init__(self, repourl, content='', dst_repos_dir=YUM_REPOS_DIR, add_hash=True): self.add_hash = add_hash self.repourl = repourl self.dst_repos_dir = dst_repos_dir self._content = None self.content = content self.config = None @property def filename(self...
""" Copyright (c) 2018 Red Hat, Inc All rights reserved. This software may be modified and distributed under the terms of the BSD license. See the LICENSE file for details. Utility functions to manipulate a yum repo. Guarantees that a yum repo will have a unique name and the .repo suffix. """ from atomic_reactor.con...
145
164
547
5
140
SalatskySal/atomic-reactor
atomic_reactor/utils/yum.py
Python
YumRepo
YumRepo
28
101
28
28
7fc5b2f419a447e347c879f8226399ed9a17d533
bigcode/the-stack
train
6cfe40fe75c84246bcd3b96b
train
function
def register(mf): mf.register_default_module("bottleneck_pyramid", required_event="resblock") mf.load("..pyramidnet_defaults") mf.set_scope("...") mf.overwrite_defaults({ "num_blocks": [3, 24, 36, 3], })
def register(mf):
mf.register_default_module("bottleneck_pyramid", required_event="resblock") mf.load("..pyramidnet_defaults") mf.set_scope("...") mf.overwrite_defaults({ "num_blocks": [3, 24, 36, 3], })
def register(mf):
5
64
64
5
0
JGU-VC/activation-pattern-analysis
grp_modules/model/resnet/imgnet_variants/pyramidnet200/__init__.py
Python
register
register
1
7
1
1
95601401a7fad4bc47fd6b7697ff29e79af2827a
bigcode/the-stack
train
f0e9f3b2908699e1c8789d37
train
class
class D4PGBuilder(builders.ActorLearnerBuilder): """D4PG Builder.""" def __init__( self, config: d4pg_config.D4PGConfig, logger_fn: Callable[[], loggers.Logger] = lambda: None, ): """Creates a D4PG learner, a behavior policy and an eval actor. Args: config: a config with D4PG hps...
class D4PGBuilder(builders.ActorLearnerBuilder):
"""D4PG Builder.""" def __init__( self, config: d4pg_config.D4PGConfig, logger_fn: Callable[[], loggers.Logger] = lambda: None, ): """Creates a D4PG learner, a behavior policy and an eval actor. Args: config: a config with D4PG hps logger_fn: a logger factory for the learne...
the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """D4PG Builder.""" from typing import Callable, Iterator, List, Optional import acme from ...
256
256
923
12
243
ostap-viniavskyi/acme
acme/agents/jax/d4pg/builder.py
Python
D4PGBuilder
D4PGBuilder
40
146
40
40
333f8a3e301668bc0577bbdef05b748028b5c8fb
bigcode/the-stack
train
d2019e252edfae00cc2d28e3
train
function
def test_filter_dagster_events_from_pod_logs_coalesce(): logs = ''' {"__class__": "DagsterEvent", "event_specific _data": {"__class__": "StepSuccessData", "duration_ms": 13.923579000000075}, "event_typ e_value": "STEP_SUCCESS", "logging_tags": {"pipeline": "foo", "so lid": "do_input", "solid_definit...
def test_filter_dagster_events_from_pod_logs_coalesce():
logs = ''' {"__class__": "DagsterEvent", "event_specific _data": {"__class__": "StepSuccessData", "duration_ms": 13.923579000000075}, "event_typ e_value": "STEP_SUCCESS", "logging_tags": {"pipeline": "foo", "so lid": "do_input", "solid_definition": "do_input", "step_key": "do_input.compute"}, "messa...
' ) res = utils.filter_dagster_events_from_pod_logs(sameple_output) assert len(res) == 7 last_event = res[-1] check.inst(last_event, DagsterEvent) check.inst(last_event.event_specific_data, StepSuccessData) def test_filter_dagster_events_from_pod_logs_coalesce():
75
75
250
14
61
johannkm/dagster-okteto
python_modules/libraries/dagster-k8s/dagster_k8s_tests/unit_tests/test_utils.py
Python
test_filter_dagster_events_from_pod_logs_coalesce
test_filter_dagster_events_from_pod_logs_coalesce
70
84
70
70
4c1fba4322b2f4a24707f8eb25258fe69f153072
bigcode/the-stack
train
5cc78f0df70b7283f39a47cc
train
function
def test_filter_dagster_events_from_pod_logs(): sameple_output = ''' 2020-07-17 11:31:58 - dagster - DEBUG - foo - new_run - STEP_START - Started execution of step "do_something.compute". pid = 2467 solid = "do_something" solid_definition = "do_something" step_ke...
def test_filter_dagster_events_from_pod_logs():
sameple_output = ''' 2020-07-17 11:31:58 - dagster - DEBUG - foo - new_run - STEP_START - Started execution of step "do_something.compute". pid = 2467 solid = "do_something" solid_definition = "do_something" step_key = "do_something.compute" {"__class__": "Dagster...
from dagster_k8s import utils from dagster import check from dagster.core.events import DagsterEvent from dagster.core.execution.plan.objects import StepSuccessData def test_filter_dagster_events_from_pod_logs():
49
256
1,974
12
36
johannkm/dagster-okteto
python_modules/libraries/dagster-k8s/dagster_k8s_tests/unit_tests/test_utils.py
Python
test_filter_dagster_events_from_pod_logs
test_filter_dagster_events_from_pod_logs
8
67
8
9
928d57f800fd76fae3271e5dfccd5183f10d1151
bigcode/the-stack
train
0fa74a984f81728d2206fa4f
train
function
def main(): contents = urllib.request.urlopen(TEST_VECTORS_URL).read() test_vectors = json.loads(contents) print(f"""// this file is generated by {__file__} package pt.kcry.blake3 import pt.kcry.blake3 import org.scalatest.matchers.should import org.scalatest.wordspec.AnyWordSpec class OfficialTestVector...
def main():
contents = urllib.request.urlopen(TEST_VECTORS_URL).read() test_vectors = json.loads(contents) print(f"""// this file is generated by {__file__} package pt.kcry.blake3 import pt.kcry.blake3 import org.scalatest.matchers.should import org.scalatest.wordspec.AnyWordSpec class OfficialTestVectorsTest extend...
#! /usr/bin/env python3 import json import urllib.request TEST_VECTORS_URL = "https://github.com/BLAKE3-team/BLAKE3/raw/master/test_vectors/test_vectors.json" def main():
46
83
278
3
43
scala-steward/scala-blake3
shared/src/test/scripts/convertTestVectorsCases.py
Python
main
main
9
47
9
9
3daad3068d3b5c80e90e6ee8aaa75c28febfeca2
bigcode/the-stack
train
4ff3586f924c50dba8cb3692
train
function
@callback def _entry_dict(entry): """Convert entry to API format.""" return { "config_entries": list(entry.config_entries), "connections": list(entry.connections), "manufacturer": entry.manufacturer, "model": entry.model, "name": entry.name, "sw_version": entry.sw...
@callback def _entry_dict(entry):
"""Convert entry to API format.""" return { "config_entries": list(entry.config_entries), "connections": list(entry.connections), "manufacturer": entry.manufacturer, "model": entry.model, "name": entry.name, "sw_version": entry.sw_version, "entry_type": en...
command.""" registry = await async_get_registry(hass) msg.pop("type") msg_id = msg.pop("id") entry = registry.async_update_device(**msg) connection.send_message(websocket_api.result_message(msg_id, _entry_dict(entry))) @callback def _entry_dict(entry):
63
64
129
9
54
erogleva/core
homeassistant/components/config/device_registry.py
Python
_entry_dict
_entry_dict
64
80
64
65
1def4ae72e455ba5c476cf587f5c4c80f345d720
bigcode/the-stack
train
49cb4fdfdca73c3731dd44ca
train
function
@require_admin @async_response async def websocket_update_device(hass, connection, msg): """Handle update area websocket command.""" registry = await async_get_registry(hass) msg.pop("type") msg_id = msg.pop("id") entry = registry.async_update_device(**msg) connection.send_message(websocket_a...
@require_admin @async_response async def websocket_update_device(hass, connection, msg):
"""Handle update area websocket command.""" registry = await async_get_registry(hass) msg.pop("type") msg_id = msg.pop("id") entry = registry.async_update_device(**msg) connection.send_message(websocket_api.result_message(msg_id, _entry_dict(entry)))
command.""" registry = await async_get_registry(hass) connection.send_message( websocket_api.result_message( msg["id"], [_entry_dict(entry) for entry in registry.devices.values()] ) ) @require_admin @async_response async def websocket_update_device(hass, connection, msg):
64
64
80
20
44
erogleva/core
homeassistant/components/config/device_registry.py
Python
websocket_update_device
websocket_update_device
50
61
50
52
5090feb7bde16d830146027ac5d65a30f2baf7b5
bigcode/the-stack
train
b931f932211d968829caadd3
train
function
@async_response async def websocket_list_devices(hass, connection, msg): """Handle list devices command.""" registry = await async_get_registry(hass) connection.send_message( websocket_api.result_message( msg["id"], [_entry_dict(entry) for entry in registry.devices.values()] ) ...
@async_response async def websocket_list_devices(hass, connection, msg):
"""Handle list devices command.""" registry = await async_get_registry(hass) connection.send_message( websocket_api.result_message( msg["id"], [_entry_dict(entry) for entry in registry.devices.values()] ) )
_register_command( WS_TYPE_LIST, websocket_list_devices, SCHEMA_WS_LIST ) hass.components.websocket_api.async_register_command( WS_TYPE_UPDATE, websocket_update_device, SCHEMA_WS_UPDATE ) return True @async_response async def websocket_list_devices(hass, connection, msg):
64
64
65
16
47
erogleva/core
homeassistant/components/config/device_registry.py
Python
websocket_list_devices
websocket_list_devices
39
47
39
40
41471133879f50f62120a0522c2f7e299faa9238
bigcode/the-stack
train