function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def _get_text_amount(self, amount, currency_id):
es_regex = re.compile('es.*')
en_regex = re.compile('en.*')
lang = self.localcontext.get('lang')
if es_regex.match(lang):
from openerp.addons.l10n_cr_amount_to_text import amount_to_text
return amount_to_text.number... | ClearCorp/odoo-clearcorp | [
14,
44,
14,
5,
1400190481
] |
def test_anonymous_user_project_view(self):
self.open("")
self.wd.wait_for_css(".organizations")
self.wd.find_element_by_link_text("Organizations").click()
self.wd.wait_for_xpath("//h1[contains(text(), 'Organizations')]")
self.wd.find_element_by_link_text(
Organizatio... | Cadasta/cadasta-test | [
1,
7,
1,
18,
1481171870
] |
def test_merge_users_view(self):
user1 = create_user(get_student_dict(1))
user2 = create_user(get_student_dict(2))
response = self.c.get('/mergeusers/{0}/{1}/'.format(user1.pk, user2.pk))
self.assertEqual(response.status_code, 200) | troeger/opensubmit | [
30,
18,
30,
45,
1411388038
] |
def test_test_machine_list_view(self):
# one machine given
create_test_machine('127.0.0.1')
response = self.c.get('/teacher/opensubmit/testmachine/')
self.assertEqual(response.status_code, 200) | troeger/opensubmit | [
30,
18,
30,
45,
1411388038
] |
def _compute_template_task_id(self):
for rec in self:
rec.template_task_id = self.env['project.task'] | ingadhoc/project | [
8,
42,
8,
7,
1453129449
] |
def onchange_template(self):
if not self.template_task_id:
return
copy_data_default = {
'project_id': self.project_id.id,
'partner_id': self.partner_id.id,
'company_id': self.company_id.id,
'child_ids': False,
}
data = self.temp... | ingadhoc/project | [
8,
42,
8,
7,
1453129449
] |
def _get_photo(self, cr, uid, context=None):
photo_path = addons.get_module_resource('res_users_kanban', 'static/src/img', 'default_image.png')
return open(photo_path, 'rb').read().encode('base64') | iw3hxn/LibrERP | [
29,
16,
29,
1,
1402418161
] |
def _set_image(self, cr, uid, id, name, value, args, context=None):
return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context) | iw3hxn/LibrERP | [
29,
16,
29,
1,
1402418161
] |
def _get_default_image(self, cr, uid, context=None):
image_path = addons.get_module_resource('res_users_kanban', 'static/src/img', 'default_image.png')
return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64')) | iw3hxn/LibrERP | [
29,
16,
29,
1,
1402418161
] |
def AB06_BA08(C, vs30, imt, PGA760):
F = np.zeros_like(vs30)
F[vs30 >= 760.] = 10**np.interp(np.log10(vs30[vs30 >= 760.]),
np.log10([760.0, 2000.0]),
np.log10([1.0, C['c']]))
F[vs30 >= 760.] = 1./F[vs30 >= 760.]
C2 = BA08.COEFFS_S... | gem/oq-engine | [
291,
241,
291,
48,
1277737182
] |
def __init__(self, **kwargs):
# kwargs must contain the keys REQUIRES_DISTANCES,
# DEFINED_FOR_TECTONIC_REGION_TYPE, gmpe_table
fname = kwargs['gmpe_table']
if isinstance(fname, io.BytesIO):
# magic happening in the engine when reading the gsim from HDF5
pass
... | gem/oq-engine | [
291,
241,
291,
48,
1277737182
] |
def _make_rabbitmq_connection(url):
parse_result = urlparse(url)
# Parse host & user/password
try:
(authdata, host) = parse_result.netloc.split("@")
except Exception as e:
raise RuntimeError("Invalid url") from e
try:
(user, password) = authdata.split(":")
except Except... | taigaio/taiga-back | [
5787,
1103,
5787,
191,
1363706040
] |
def __init__(self, url):
self.url = url | taigaio/taiga-back | [
5787,
1103,
5787,
191,
1363706040
] |
def _unique_date_range(self):
for record in self:
record._unique_date_range_one() | OCA/l10n-spain | [
180,
456,
180,
97,
1403004087
] |
def set_resolution(self, curvename, value):
"""
Set resolution for tooth form representation
INPUT parameters:
curvename : segment of tooth flank (string)
one of the following: flank, fillet, tip, root, shaft, width
value : new value for number of points ... | efirvida/python-gearbox | [
17,
12,
17,
1,
1429804194
] |
def _make_unique(self, coords):
"""
Remove redundant entries from coordinate array
INPUT parameter:
coords : list of 2d-coordinate points (TColgp_Array1OfPnt2d, pythonOCC)
OUTPUT:
unique_coords : list of unique coordinates (TColgp_Array1OfPnt2d, pythonOCC)
"""
... | efirvida/python-gearbox | [
17,
12,
17,
1,
1429804194
] |
def __init__(self, geardata, flankmods=None):
"""
Initialization of GearWheel-object
Should be overwritten in derived classes
INPUT parameter:
geardata : data of gear wheel (dictionary)
flankmods : data of flank modifications (dictionary)
formcoords : list of ... | efirvida/python-gearbox | [
17,
12,
17,
1,
1429804194
] |
def set_gear_data(self, geardata):
"""
Set data-attribute of class, overwrite current value
INPUT parameter:
geardata : dictionary, containing geometric data of gear
for content, see method __init__
"""
self.__init__(geardata, self.modifications) | efirvida/python-gearbox | [
17,
12,
17,
1,
1429804194
] |
def get_flank_modifications(self):
"""
Return modifications-attribute of class
OUTPUT:
data attribute of class (dictionary)
"""
return self.modifications | efirvida/python-gearbox | [
17,
12,
17,
1,
1429804194
] |
def update_flank_modifications(self, flankmods):
"""
Set modifications-attribute of class, update current value
INPUT parameter:
flankmods : dictionary, containing flank modification data of gear
for content, see method __init__
"""
tempmods = self.m... | efirvida/python-gearbox | [
17,
12,
17,
1,
1429804194
] |
def _tooth_thickness(self, d_y):
"""
Tooth thickness in transverse cross-section (chord-length)
INPUT parameter:
d_y : two times coordinate of tooth flank in radial direction
(diameter of y-cylinder)
OUTPUT:
s_y : chord length of tooth thickness at d_y (n... | efirvida/python-gearbox | [
17,
12,
17,
1,
1429804194
] |
def __init__(self, geardata, flankmods=None, formcoords=None):
"""
Initialization of GearWheel-object.
All parameters in accordance to DIN 3960 and DIN 3967.
INPUT parameters:
z : number of teeth (numeric, integer)
m_n : normal module (numeric, positive)
... | efirvida/python-gearbox | [
17,
12,
17,
1,
1429804194
] |
def root_circle_center_func(phi):
return fil_end_point + self.data.get('rho_f') * np.array([sin(phi[0]), cos(phi[0])]) - (self.data.get(
'd_f') / 2 + self.data.get('rho_f')) * np.array([sin(phi[1]), cos(phi[1])]) | efirvida/python-gearbox | [
17,
12,
17,
1,
1429804194
] |
def __init__(self, pairdata):
"""
Initialization of GearPair-object
Should be overwritten in derived classes
:rtype : object
INPUT parameters:
pairdata : data of gear wheel pair (dictionary)
Pinion : pinion (GearWheel-instance)
Gear : gear (... | efirvida/python-gearbox | [
17,
12,
17,
1,
1429804194
] |
def __str__(self):
return "Id2" | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_empty_volume(self):
"""Empty volume is well-behaved"""
empty = volume.EmptyVolume()
test = 0.1
assert_equal(empty(test), False)
assert_equal((empty & volA)(test), False)
assert_equal((volA & empty)(test), False)
assert_equal((empty | volA)(test), True)
... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_full_volume(self):
"""Full volume is well-behaved"""
full = volume.FullVolume()
test = 0.1
assert_equal(full(test), True)
assert_equal((full & volA)(test), True)
assert_equal((volA & full)(test), True)
assert_equal((full | volA)(test), True)
asser... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_upper_boundary(self):
assert_equal(volA(0.49), True)
assert_equal(volA(0.50), False)
assert_equal(volA(0.51), False) | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_negation(self):
assert_equal((~volA)(0.25), False)
assert_equal((~volA)(0.75), True)
assert_equal((~volA)(0.5), True)
assert_equal((~volA)(-0.5), False) | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_and_combinations(self):
assert_equal((volA & volB), volume.CVDefinedVolume(op_id, 0.25, 0.5))
assert_equal((volA & volB)(0.45), True)
assert_equal((volA & volB)(0.55), False)
assert_equal((volB & volC), volume.EmptyVolume())
# go to VolumeCombination if order parameter i... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_xor_combinations(self):
assert_equal((volA ^ volB),
volume.UnionVolume(
volume.CVDefinedVolume(op_id, -0.5, 0.25),
volume.CVDefinedVolume(op_id, 0.5, 0.75)
))
assert_equal((volA ^ volA2),
... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_str(self):
assert_equal(volA.__str__(), "{x|Id(x) in [-0.5, 0.5]}")
assert_equal((~volA).__str__(), "(not {x|Id(x) in [-0.5, 0.5]})") | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def _vol_for_cv_type(inp):
if not HAS_SIMTK_UNIT and inp == 'simtk':
pytest.skip()
func = {
'float': lambda s: 1.0,
'array': lambda s: np.array([1.0, 2.0]),
'array1': lambda s: np.array([1.0]),
'simtk': None
}[inp]
if func is N... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_is_iterable(self, inp):
snap = make_1d_traj([0.0])[0]
volume = self._vol_for_cv_type(inp)
val = volume.collectivevariable(snap)
expected = inp in ['array', 'array1']
if expected:
with pytest.warns(UserWarning, match="returns an iterable"):
res... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_get_cv_float(self, inp):
snap = make_1d_traj([0.0])[0]
volume = self._vol_for_cv_type(inp)
val = volume._get_cv_float(snap)
expected = inp in ['float', 'array1']
assert isinstance(val, float) is expected | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def setup(self):
self.pvolA = volume.PeriodicCVDefinedVolume(op_id, -100, 75)
self.pvolA_ = volume.PeriodicCVDefinedVolume(op_id, 75, -100)
self.pvolB = volume.PeriodicCVDefinedVolume(op_id, 50, 100)
self.pvolC = volume.PeriodicCVDefinedVolume(op_id, -100, -50)
self.pvolD = volum... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_normal_implicit(self):
"""min<max, no periodic domain defined"""
lambda_min = -150
lambda_max = 70
vol = volume.PeriodicCVDefinedVolume(op_id,
lambda_min, lambda_max)
assert_equal(vol.__str__(),
"{x|Id(x) [periodic] i... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_wrapped_volume_implicit(self):
"""max<min, no periodic domain defined"""
lambda_min = 70
lambda_max = -150
vol = volume.PeriodicCVDefinedVolume(op_id,
lambda_min, lambda_max)
# out of state
assert_equal(False, vol(lambda_... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_volume_bigger_than_bounds(self):
'''max-min > pbc_range raises Exception'''
vol = volume.PeriodicCVDefinedVolume(op_id, 90, 720, -180, 180) | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_periodic_and_combos(self):
assert_equal((self.pvolA & self.pvolB),
volume.PeriodicCVDefinedVolume(op_id, 50, 75))
assert_equal((self.pvolA & self.pvolB)(60), True)
assert_equal((self.pvolA & self.pvolB)(80), False)
assert_equal((self.pvolB & self.pvolC), vol... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_periodic_xor_combos(self):
assert_equal(self.pvolA ^ self.pvolA_, volume.FullVolume())
assert_equal(self.pvolA ^ self.pvolA, volume.EmptyVolume())
assert_equal(self.pvolE ^ self.pvolD,
volume.UnionVolume(
volume.PeriodicCVDefinedVolume(op_id... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def test_periodic_sub_combos(self):
assert_equal(self.pvolA - self.pvolA_, self.pvolA)
assert_equal(self.pvolA_ - self.pvolA, self.pvolA_)
assert_equal(self.pvolD - self.pvolA,
volume.PeriodicCVDefinedVolume(op_id, 75, 100))
assert_equal((self.pvolD - self.pvolA)(80)... | choderalab/openpathsampling | [
87,
48,
87,
102,
1378303588
] |
def timestamp():
if on_windows:
rv = "%.6f" % (
(datetime.datetime.utcnow() -
datetime.datetime(1970, 1, 1)).total_seconds(),)
else:
rv = datetime.datetime.now().strftime("%s.%f")
return rv | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def code2string(code):
return "\n".join(
["%-4s %s" % (li+1, l) for li, l in enumerate(code.splitlines())]) | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def _store_return_value(func, queue):
while True:
queue.put(func()) | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def __init__(self, ns):
self.ns = ns
self._on_disconnect = []
self._on_drop = [] | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def local_nss(self):
"""List local namespaces
"""
return _g_local_namespaces.keys() | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def on_disconnect(self):
"""Return codes that will be executed when a client has disconnected.
"""
return self._on_disconnect | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def exec_on_disconnect(self, code, any_connection=False):
"""Add code that will be executed when client has disconnected.
"""
if not any_connection:
conn_id = _g_executing_pythonshare_conn_id
else:
conn_id = None
self._on_disconnect.append((conn_id, code)) | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def set_on_disconnect(self, list_of_code):
"""Replace all "on disconnect" codes with new list of codes.
"""
self._on_disconnect = list_of_code | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def call_on_disconnect(self, conn_id):
for setter_conn_id, code in self._on_disconnect:
if not setter_conn_id or setter_conn_id == conn_id:
exec_msg = messages.Exec(self.ns, code, None)
if opt_debug:
daemon_log("on disconnect %s: %s" % (conn_id, ex... | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def read_rv(self, async_rv):
"""Return and remove asynchronous return value.
"""
if self.ns != async_rv.ns:
raise ValueError("Namespace mismatch")
if (async_rv.ns in _g_async_rvs and
async_rv.rvid in _g_async_rvs[async_rv.ns]):
rv = _g_async_rvs[async_... | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def __init__(self, conn, to_remote, from_remote):
self.conn = conn
self.to_remote = to_remote
self.from_remote = from_remote | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def _init_local_namespace(ns, init_code=None, force=False):
if not ns in _g_local_namespaces:
if opt_allow_new_namespaces or force:
daemon_log('added local namespace "%s"' % (ns,))
_g_local_namespaces[ns] = {
"pythonshare_ns": Pythonshare_ns(ns),
"Asyn... | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def _drop_remote_namespace(ns):
daemon_log('drop remote namespace "%s"' % (ns,))
try:
rns = _g_remote_namespaces[ns]
del _g_remote_namespaces[ns]
rns.__del__()
except KeyError:
pass # already dropped
# send notification to all connections in _g_namespace_exports[ns]? | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def _register_exported_namespace(ns, conn):
if not ns in _g_namespace_exports:
_g_namespace_exports[ns] = []
_g_namespace_exports[ns].append(conn) | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def _local_async_execute(async_rv, exec_msg):
exec_rv = _local_execute(exec_msg)
_g_async_rvs[exec_msg.namespace][async_rv.rvid] = exec_rv | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def _remote_execute_and_forward(ns, exec_msg, to_client, peername=None):
"""returns (forward_status, info)
forward_status values:
True: everything successfully forwarded,
info contains pair (forwarded byte count, full length).
False: not everything forwarded,
info cont... | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def _serve_connection(conn, conn_opts):
global _g_async_rv_counter
global _g_server_shutdown
if isinstance(conn, client.Connection):
to_client = conn._to_server
from_client = conn._from_server
else: # conn is a connected socket
to_client = conn.makefile("w")
from_client =... | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def wake_server_function():
_g_waker_lock.release() # wake up server | 01org/fMBT | [
125,
72,
125,
3,
1340117584
] |
def assertExecutionSucceeded(self, exec_result):
returncode, stdout, stderr = exec_result
self.assertEquals(0, returncode) | xapi-project/sm | [
19,
82,
19,
27,
1371215820
] |
def test_lvcreate_is_mocked(self):
executable_injector = mock.Mock()
lvsubsystem = lvmlib.LVSubsystem(None, executable_injector)
self.assertTrue(
mock.call('/usr/sbin/lvcreate', lvsubsystem.fake_lvcreate)
in executable_injector.mock_calls
) | xapi-project/sm | [
19,
82,
19,
27,
1371215820
] |
def test_dmsetup_is_mocked(self):
executable_injector = mock.Mock()
lvsubsystem = lvmlib.LVSubsystem(None, executable_injector)
self.assertTrue(
mock.call('/sbin/dmsetup', lvsubsystem.fake_dmsetup)
in executable_injector.mock_calls
) | xapi-project/sm | [
19,
82,
19,
27,
1371215820
] |
def test_add_multiple_volume_groups(self):
lvsubsystem = lvmlib.LVSubsystem(None, mock.Mock())
lvsubsystem.add_volume_group('vg1')
lvsubsystem.add_volume_group('vg2')
lvsubsystem.add_volume_group('vg3')
vg1 = lvsubsystem.get_volume_group('vg1')
vg2 = lvsubsystem.get_volu... | xapi-project/sm | [
19,
82,
19,
27,
1371215820
] |
def test_fake_lvcreate_with_tags(self):
lvsubsystem = lvmlib.LVSubsystem(mock.Mock(), mock.Mock())
lvsubsystem.add_volume_group('vg')
exec_result = lvsubsystem.fake_lvcreate(
"someprog -n name --addtag tagg -L 100 vg".split(), '')
lv, = lvsubsystem.get_logical_volumes_with_... | xapi-project/sm | [
19,
82,
19,
27,
1371215820
] |
def test_fake_lvcreate_non_zeroed(self):
lvsubsystem = lvmlib.LVSubsystem(mock.Mock(), mock.Mock())
lvsubsystem.add_volume_group('vg')
exec_result = lvsubsystem.fake_lvcreate(
"someprog -n name --zero n -L 100 vg".split(), '')
lv, = lvsubsystem.get_logical_volumes_with_name... | xapi-project/sm | [
19,
82,
19,
27,
1371215820
] |
def test_fake_lvcreate_called_with_wrong_params(self):
lvsubsystem = lvmlib.LVSubsystem(mock.Mock(), mock.Mock())
lvsubsystem.add_volume_group('vg')
exec_result = lvsubsystem.fake_lvcreate(
"someprog --something-stupid -n name n -L 100 vg".split(), '')
self.assertExecutionF... | xapi-project/sm | [
19,
82,
19,
27,
1371215820
] |
def test_fake_lvremove(self):
lvsubsystem = lvmlib.LVSubsystem(mock.Mock(), mock.Mock())
lvsubsystem.add_volume_group('vg')
lvsubsystem.get_volume_group('vg').add_volume('lv', 100)
exec_result = lvsubsystem.fake_lvremove(
"someprog vg/lv".split(), '')
self.assertExe... | xapi-project/sm | [
19,
82,
19,
27,
1371215820
] |
def test_fake_lvremove_with_bad_params(self):
lvsubsystem = lvmlib.LVSubsystem(mock.Mock(), mock.Mock())
lvsubsystem.add_volume_group('vg')
lvsubsystem.get_volume_group('vg').add_volume('lv', 100)
exec_result = lvsubsystem.fake_lvremove(
"someprog -f vg/lv --stupid-parameter... | xapi-project/sm | [
19,
82,
19,
27,
1371215820
] |
def setUpModule():
'''
Set up the module for running tests.
'''
# Set the nonce store to the Django store after saving the current settings
# so they can be restored later.
global __old_nonce_settings
__old_nonce_settings = (settings.NONCE_STORE, settings.NONCE_STORE_ARGS)
settings.NONCE_STORE = 'wsse.server.d... | PrincetonUniversity/pywsse | [
7,
3,
7,
1,
1472563613
] |
def setUp(self):
'''
Set up the test cases.
'''
self.user = User.objects.create(username = 'username')
self.user_secret = UserSecret.objects.create(user = self.user)
self.auth = WSSEAuth('username', self.user_secret.secret)
self.base_url = '{}{}'.format(self.live_server_url, self.endpoint) | PrincetonUniversity/pywsse | [
7,
3,
7,
1,
1472563613
] |
def test_auth_reuse(self):
'''
Reuse the same authentication handler. Both requests should succeed.
'''
response_a = requests.get(self.base_url, auth = self.auth)
response_b = requests.get(self.base_url, auth = self.auth)
self.assertEqual(response_a.status_code, status.HTTP_200_OK)
self.assertEqual(respo... | PrincetonUniversity/pywsse | [
7,
3,
7,
1,
1472563613
] |
def advertise(cls, subparsers):
help_text = "print the program version"
description_text = "Print the program version."
subparsers.add_parser(cls._get_short_command_name(),
help=help_text,
description=description_text) | lueschem/edi | [
33,
13,
33,
16,
1480665730
] |
def f_pulls(coroutine):
for msg in coroutine:
print(msg) | NLeSC/noodles | [
21,
7,
21,
18,
1446464542
] |
def f_receives():
while True:
msg = yield
print(msg) | NLeSC/noodles | [
21,
7,
21,
18,
1446464542
] |
def coroutine(f):
@wraps(f)
def g(*args, **kwargs):
sink = f(*args, **kwargs)
sink.send(None)
return sink
return g | NLeSC/noodles | [
21,
7,
21,
18,
1446464542
] |
def __init__(self):
self._q = queue.Queue() | NLeSC/noodles | [
21,
7,
21,
18,
1446464542
] |
def sink(self):
while True:
msg = yield
self._q.put(msg) | NLeSC/noodles | [
21,
7,
21,
18,
1446464542
] |
def __init__(self):
super().__init__()
self.output = Endpoint(unsigned(32))
self.value = self.output.payload
self.new_en = Signal()
self.new_value = Signal(32) | google/CFU-Playground | [
357,
91,
357,
130,
1615325898
] |
def __init__(self):
super().__init__()
self.output_streams = {
i: Endpoint(
unsigned(32)) for i in self.REGISTER_IDS}
self.values = {i: Signal(32) for i in self.REGISTER_IDS}
self.write_strobes = {i: Signal(1) for i in self.REGISTER_IDS} | google/CFU-Playground | [
357,
91,
357,
130,
1615325898
] |
def testAddExistingComponent(self):
c = Label('abc')
tabSheet = TabSheet()
tabSheet.addComponent(c)
tabSheet.addComponent(c)
itr = tabSheet.getComponentIterator()
self.assertEquals(c, itr.next())
self.assertRaises(StopIteration, itr.next)
self.assertNotEqu... | rwl/muntjac | [
43,
14,
43,
5,
1316308871
] |
def testAddTabWithComponentOnly(self):
tabSheet = TabSheet()
tab1 = tabSheet.addTab(Label('aaa'))
tab2 = tabSheet.addTab(Label('bbb'))
tab3 = tabSheet.addTab(Label('ccc'))
# Check right order of tabs
self.assertEquals(0, tabSheet.getTabPosition(tab1))
self.assert... | rwl/muntjac | [
43,
14,
43,
5,
1316308871
] |
def testAddTabWithAllParameters(self):
tabSheet = TabSheet()
tab1 = tabSheet.addTab(Label('aaa'))
tab2 = tabSheet.addTab(Label('bbb'))
tab3 = tabSheet.addTab(Label('ccc'))
tab4 = tabSheet.addTab(Label('ddd'), 'ddd', None, 1)
tab5 = tabSheet.addTab(Label('eee'), 'eee', Non... | rwl/muntjac | [
43,
14,
43,
5,
1316308871
] |
def test_disconnect(self):
response_data = api.on_disconnect()
self.assertEqual(ErrorCodes.OK, response_data[0]) | thenetcircle/dino | [
139,
6,
139,
11,
1475559609
] |
def clean_first_name(self):
r = re.compile(u'^[А-ЯЁ][а-яё]*$', re.UNICODE)
res = r.match(self.cleaned_data['first_name'])
if res is None:
raise ValidationError(
_('Неверный формат имени: первыя буква должна быть заглавной, допустимы только русские символы.'))
... | IlyaGusev/PoetryCorpus | [
40,
6,
40,
11,
1477270169
] |
def clean_password(self):
l = len(self.cleaned_data['password'])
if l <= 5 or l >= 30:
raise ValidationError(
_('Неверная длина пароля.'))
return self.cleaned_data['password'] | IlyaGusev/PoetryCorpus | [
40,
6,
40,
11,
1477270169
] |
def with_lock(lock):
"""Make sure the lock is held while in this function."""
def decorator(func):
@functools.wraps(func)
def _with_lock(*args, **kwargs):
with lock:
return func(*args, **kwargs)
return _with_lock
return decorator | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def __new__(cls, ability, static_data):
specific_data = static_data[ability.ability_id]
if specific_data.remaps_to_ability_id:
general_data = static_data[specific_data.remaps_to_ability_id]
else:
general_data = specific_data
return super(_Ability, cls).__new__(
cls,
ability_i... | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def __init__(self, surf, surf_type, surf_rect, world_to_surf, world_to_obs,
draw):
"""A surface to display on screen.
Args:
surf: The actual pygame.Surface (or subsurface).
surf_type: A SurfType, used to tell how to treat clicks in that area.
surf_rect: Rect of the surface rela... | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def draw_arc(self, color, world_loc, world_radius, start_angle, stop_angle,
thickness=1):
"""Draw an arc using world coordinates, radius, start and stop angles."""
center = self.world_to_surf.fwd_pt(world_loc).round()
radius = max(1, int(self.world_to_surf.fwd_dist(world_radius)))
rect = ... | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def draw_rect(self, color, world_rect, thickness=0):
"""Draw a rectangle using world coordinates."""
tl = self.world_to_surf.fwd_pt(world_rect.tl).round()
br = self.world_to_surf.fwd_pt(world_rect.br).round()
rect = pygame.Rect(tl, br - tl)
pygame.draw.rect(self.surf, color, rect, thickness) | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def write_screen(self, font, color, screen_pos, text, align="left",
valign="top"):
"""Write to the screen in font.size relative coordinates."""
pos = point.Point(*screen_pos) * point.Point(0.75, 1) * font.get_linesize()
text_surf = font.render(str(text), True, color)
rect = text_surf.... | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def surf_pos(self):
return self.surf.world_to_surf.fwd_pt(self.world_pos) | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def obs_pos(self):
return self.surf.world_to_obs.fwd_pt(self.world_pos) | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def _get_desktop_size():
"""Get the desktop size."""
if platform.system() == "Linux":
try:
xrandr_query = subprocess.check_output(["xrandr", "--query"])
sizes = re.findall(r"\bconnected primary (\d+)x(\d+)", str(xrandr_query))
if sizes[0]:
return point.Point(int(sizes[0][0]), int(sizes... | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def __init__(self, fps=22.4, step_mul=1, render_sync=False,
render_feature_grid=True, video=None):
"""Create a renderer for use by humans.
Make sure to call `init` with the game info, or just use `run`.
Args:
fps: How fast should the game be run.
step_mul: How many game steps to... | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def init(self, game_info, static_data):
"""Take the game info and the static data needed to set up the game.
This must be called before render or get_actions for each game or restart.
Args:
game_info: A `sc_pb.ResponseGameInfo` object for this game.
static_data: A `StaticData` object for this ... | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def init_window(self):
"""Initialize the pygame window and lay out the surfaces."""
if platform.system() == "Windows":
# Enable DPI awareness on Windows to give the correct window size.
ctypes.windll.user32.SetProcessDPIAware() # pytype: disable=module-attr
pygame.init()
if self._render_r... | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def zoom(self, factor):
"""Zoom the window in/out."""
self._window_scale *= factor
if time.time() - self._last_zoom_time < 1:
# Avoid a deadlock in pygame if you zoom too quickly.
time.sleep(time.time() - self._last_zoom_time)
self.init_window()
self._last_zoom_time = time.time() | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
def clear_queued_action(self):
self._queued_hotkey = ""
self._queued_action = None | deepmind/pysc2 | [
7691,
1151,
7691,
50,
1501006617
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.