function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def test_search_dirs_sysroot(self):
with mock.patch('bfg9000.shell.execute', mock_execute):
ld = LdLinker(None, self.env, ['ld'], 'version')
self.assertEqual(ld.search_dirs(sysroot='/sysroot'),
[abspath('/dir1'), abspath('/sysroot/dir2')]) | jimporter/bfg9000 | [
68,
20,
68,
13,
1424839632
] |
def mock_bad_execute(*args, **kwargs):
raise OSError() | jimporter/bfg9000 | [
68,
20,
68,
13,
1424839632
] |
def taylor(fx, xs, order, x_range=(0, 1), n=200):
x0, x1 = x_range
x = np.linspace(float(x0), float(x1), n)
fy = sy.lambdify(xs, fx, modules=['numpy'])(x)
tx = fx.series(xs, n=order).removeO()
if tx.is_Number:
ty = np.zeros_like(x)
ty.fill(float(tx))
else:
ty = sy.lambd... | bokeh/bokeh | [
17326,
4066,
17326,
698,
1332776401
] |
def update():
try:
expr = sy.sympify(text.value, dict(x=xs))
except Exception as exception:
errbox.text = str(exception)
else:
errbox.text = ""
x, fy, ty = taylor(expr, xs, slider.value, (-2*sy.pi, 2*sy.pi), 200)
p.title.text = "Taylor (n=%d) expansion comparison for: %s" % ... | bokeh/bokeh | [
17326,
4066,
17326,
698,
1332776401
] |
def setUp(self):
# Mock the device
self.mock_device = mock.Mock(spec=device_utils.DeviceUtils)
self.mock_device.build_product = 'blueline'
self.mock_device.adb = mock.Mock(spec=adb_wrapper.AdbWrapper)
self.mock_device.FileExists.return_value = True
self.cpu_temp = cpu_temperature.CpuTemperature... | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def testInitWithDeviceUtil(self):
d = mock.Mock(spec=device_utils.DeviceUtils)
d.build_product = 'blueline'
c = cpu_temperature.CpuTemperature(d)
self.assertEqual(d, c.GetDeviceForTesting()) | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def testGetThermalDeviceInformation_noneWhenIncorrectLabel(self):
invalid_device = mock.Mock(spec=device_utils.DeviceUtils)
invalid_device.build_product = 'invalid_name'
c = cpu_temperature.CpuTemperature(invalid_device)
c.InitThermalDeviceInformation()
self.assertEqual(c.GetDeviceInfoForTesting(), ... | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def testIsSupported_returnsTrue(self):
d = mock.Mock(spec=device_utils.DeviceUtils)
d.build_product = 'blueline'
d.FileExists.return_value = True
c = cpu_temperature.CpuTemperature(d)
self.assertTrue(c.IsSupported()) | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def testIsSupported_returnsFalse(self):
d = mock.Mock(spec=device_utils.DeviceUtils)
d.build_product = 'blueline'
d.FileExists.return_value = False
c = cpu_temperature.CpuTemperature(d)
self.assertFalse(c.IsSupported()) | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def testLetBatteryCoolToTemperature_coolWithin24Calls(self):
self.mock_device.ReadFile = mock.Mock(side_effect=self.cooling_down0)
self.cpu_temp.LetCpuCoolToTemperature(42)
self.mock_device.ReadFile.assert_called()
self.assertEquals(self.mock_device.ReadFile.call_count, 24) | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def testLetBatteryCoolToTemperature_coolWithin16Calls(self):
self.mock_device.ReadFile = mock.Mock(side_effect=self.cooling_down1)
self.cpu_temp.LetCpuCoolToTemperature(42)
self.mock_device.ReadFile.assert_called()
self.assertEquals(self.mock_device.ReadFile.call_count, 16) | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def testLetBatteryCoolToTemperature_timeoutAfterThree(self):
self.mock_device.ReadFile = mock.Mock(side_effect=self.constant_temp)
self.cpu_temp.LetCpuCoolToTemperature(42)
self.mock_device.ReadFile.assert_called()
self.assertEquals(self.mock_device.ReadFile.call_count, 24) | endlessm/chromium-browser | [
21,
16,
21,
3,
1435959644
] |
def __init__(self, expression, separator, distinct=False, ordering=None, **extra):
self.separator = separator
super(Sql_GroupConcat, self).__init__(expression,
distinct='DISTINCT ' if distinct else '',
ordering='... | rackerlabs/django-DefectDojo | [
2681,
1254,
2681,
272,
1424368427
] |
def extractKoreanovelsCom(item):
'''
Parser for 'koreanovels.com'
'''
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or "preview" in item['title'].lower():
return None
if item['title'].startswith("Link ") and item['tags'] == ['RSS']:
return buildReleaseMessageW... | fake-name/ReadableWebProxy | [
191,
16,
191,
3,
1437712243
] |
def _make_random_patches(x, y, patch_size, permutations, size=3):
batch_size = x.get_shape().as_list()[0]
crop_size = x.get_shape().as_list()[1]
perm_idx = tf.expand_dims(y, 1)
perm = tf.gather_nd(permutations, perm_idx)
WINDOW_SIZE = crop_size // size
N = x.get_shape().as_list()[0]
C = ... | gustavla/self-supervision | [
29,
5,
29,
7,
1492017767
] |
def __init__(self, name, basenet, loader, patch_size=75, size=3,
reduce_channels=128, use_scalers=False):
self.name = name
self.basenet = basenet
self._size = size
self._patch_size = patch_size
self._loader = loader
self._reduce_channels = reduce_channels... | gustavla/self-supervision | [
29,
5,
29,
7,
1492017767
] |
def basenet_settings(self):
return {'convolutional': False} | gustavla/self-supervision | [
29,
5,
29,
7,
1492017767
] |
def build_network(self, network, extra, phase_test, global_step):
info = selfsup.info.create(scale_summary=True)
if self._size == 3:
z = network['activations']['pool5']
else:
z = network['activations']['top']
#z = tf.squeeze(z, [1, 2])
z = tf.reshape(z, ... | gustavla/self-supervision | [
29,
5,
29,
7,
1492017767
] |
def create(kernel):
result = Tangible()
result.template = "object/tangible/component/weapon/shared_reinforcement_core.iff"
result.attribute_template_id = -1
result.stfName("craft_weapon_ingredients_n","reinforcement_core") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def register_in(router):
router.register(
r'booking-resources', views.ResourceViewSet, basename='booking-resource'
)
router.register(
r'booking-offerings', views.OfferingViewSet, basename='booking-offering'
) | opennode/nodeconductor-assembly-waldur | [
39,
35,
39,
3,
1484854426
] |
def create(kernel):
result = Tangible()
result.template = "object/tangible/loot/loot_schematic/shared_chemical_recycler_schematic.iff"
result.attribute_template_id = -1
result.stfName("craft_item_ingredients_n","chemical_recycler") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def reset():
global _PROPERTIES_DICT
_PROPERTIES_DICT = None | cloudera/hue | [
804,
271,
804,
38,
1277149611
] |
def has_sqoop_has_security():
return get_props().get(_CONF_SQOOP_AUTHENTICATION_TYPE, 'SIMPLE').upper() == 'KERBEROS' | cloudera/hue | [
804,
271,
804,
38,
1277149611
] |
def ReturnNumbersAsDecimal(cursor, name, defaultType, size, precision, scale):
if defaultType == cx_Oracle.NUMBER:
return cursor.var(str, 9, cursor.arraysize, outconverter = decimal.Decimal) | cloudera/hue | [
804,
271,
804,
38,
1277149611
] |
def test_oserror(self, macos_version, lenient_run_command_output):
lenient_run_command_output.return_value = (None, None, None)
self.assertFalse(signing._linker_signed_arm64_needs_force(None))
lenient_run_command_output.assert_called_once() | ric2b/Vivaldi-browser | [
131,
27,
131,
3,
1490828945
] |
def test_not_linker_signed(self, macos_version, lenient_run_command_output):
lenient_run_command_output.return_value = (0, b'', b'''Executable=test | ric2b/Vivaldi-browser | [
131,
27,
131,
3,
1490828945
] |
def test_linker_signed_10_15(self, macos_version,
lenient_run_command_output):
lenient_run_command_output.return_value = (0, b'', b'''Executable=test | ric2b/Vivaldi-browser | [
131,
27,
131,
3,
1490828945
] |
def test_linker_signed_10_16(self, macos_version,
lenient_run_command_output):
# 10.16 is what a Python built against an SDK < 11.0 will see 11.0 as.
macos_version.return_value = [10, 16]
lenient_run_command_output.return_value = (0, b'', b'''Executable=test | ric2b/Vivaldi-browser | [
131,
27,
131,
3,
1490828945
] |
def test_linker_signed_11_0(self, macos_version,
lenient_run_command_output):
macos_version.return_value = [11, 0]
lenient_run_command_output.return_value = (0, b'', b'''Executable=test | ric2b/Vivaldi-browser | [
131,
27,
131,
3,
1490828945
] |
def setUp(self):
self.paths = model.Paths('/$I', '/$O', '/$W')
self.config = test_config.TestConfig() | ric2b/Vivaldi-browser | [
131,
27,
131,
3,
1490828945
] |
def test_sign_part_needs_force(self, run_command,
linker_signed_arm64_needs_force):
linker_signed_arm64_needs_force.return_value = True
part = model.CodeSignedProduct('Test.app', 'test.signing.app')
signing.sign_part(self.paths, self.config, part)
run_c... | ric2b/Vivaldi-browser | [
131,
27,
131,
3,
1490828945
] |
def test_sign_part_no_identifier_requirement(
self, run_command, linker_signed_arm64_needs_force):
part = model.CodeSignedProduct(
'Test.app', 'test.signing.app', identifier_requirement=False)
signing.sign_part(self.paths, self.config, part)
run_command.assert_called_once... | ric2b/Vivaldi-browser | [
131,
27,
131,
3,
1490828945
] |
def test_sign_with_identifier_no_requirement(
self, run_command, linker_signed_arm64_needs_force):
part = model.CodeSignedProduct(
'Test.app',
'test.signing.app',
sign_with_identifier=True,
identifier_requirement=False)
signing.sign_part(self.p... | ric2b/Vivaldi-browser | [
131,
27,
131,
3,
1490828945
] |
def test_sign_part_with_entitlements(self, run_command,
linker_signed_arm64_needs_force):
part = model.CodeSignedProduct(
'Test.app',
'test.signing.app',
entitlements='entitlements.plist',
identifier_requirement=False)
... | ric2b/Vivaldi-browser | [
131,
27,
131,
3,
1490828945
] |
def url_for_version(self, ver):
return "https://ftp.ncbi.nih.gov/toolbox/ncbi_tools/converters/by_program/tbl2asn/linux.tbl2asn.gz" | LLNL/spack | [
3244,
1839,
3244,
2847,
1389172932
] |
def freeze_graph_with_def_protos(
input_graph_def,
input_saver_def,
input_checkpoint,
output_node_names,
restore_op_name,
filename_tensor_name,
clear_devices,
initializer_nodes,
variable_names_blacklist=''):
"""Converts all variables in a graph and checkpoint into constants."""
d... | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def _tf_example_input_placeholder():
tf_example_placeholder = tf.placeholder(
tf.string, shape=[], name='tf_example')
tensor_dict = tf_example_decoder.TfExampleDecoder().decode(
tf_example_placeholder)
image = tensor_dict[fields.InputDataFields.image]
return tf.expand_dims(image, axis=0) | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def _encoded_image_string_tensor_input_placeholder():
image_str = tf.placeholder(dtype=tf.string,
shape=[],
name='encoded_image_string_tensor')
image_tensor = tf.image.decode_image(image_str, channels=3)
image_tensor.set_shape((None, None, 3))
return tf.... | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def _add_output_tensor_nodes(postprocessed_tensors):
"""Adds output nodes for detection boxes and scores.
Adds the following nodes for output tensors -
* num_detections: float32 tensor of shape [batch_size].
* detection_boxes: float32 tensor of shape [batch_size, num_boxes, 4]
containing detected box... | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def _write_saved_model(inference_graph_path, inputs, outputs,
checkpoint_path=None, use_moving_averages=False):
"""Writes SavedModel to disk.
If checkpoint_path is not None bakes the weights into the graph thereby
eliminating the need of checkpoint files during inference. If the model
wa... | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def create_reports_service(self, user_email):
"""Build and returns an Admin SDK Reports service object authorized with
the service accounts that act on behalf of the given user.
Args:
user_email: The email of the user. Needs permissions to access
the Admin APIs.
Returns:
A... | chromium/chromium | [
14247,
5365,
14247,
62,
1517864132
] |
def __init__(self, message, is_infra_error=False):
super(BaseError, self).__init__(message)
self._is_infra_error = is_infra_error
self.message = message | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def __ne__(self, other):
return not self == other | catapult-project/catapult | [
1835,
570,
1835,
1039,
1429033745
] |
def line2d(p0, p1):
"""
Return 2D equation of line in the form ax+by+c = 0
"""
# x + x1 = 0
x0, y0 = p0[:2]
x1, y1 = p1[:2]
#
if x0 == x1:
a = -1
b = 0
c = x1
elif y0 == y1:
a = 0
b = 1
c = -y1
else:
a = (y0-y1)
b =... | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def line2d_seg_dist(p1, p2, p0):
"""distance(s) from line defined by p1 - p2 to point(s) p0
p0[0] = x(s)
p0[1] = y(s)
intersection point p = p1 + u*(p2-p1)
and intersection point lies within segment if u is between 0 and 1
"""
x21 = p2[0] - p1[0]
y21 = p2[1] - p1[1]
x01 = np.asarr... | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def mod(v):
"""3d vector length"""
return np.sqrt(v[0]**2+v[1]**2+v[2]**2) | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def test_world():
xmin, xmax = 100, 120
ymin, ymax = -100, 100
zmin, zmax = 0.1, 0.2
M = world_transformation(xmin, xmax, ymin, ymax, zmin, zmax)
print(M) | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def persp_transformation(zfront, zback):
a = (zfront+zback)/(zfront-zback)
b = -2*(zfront*zback)/(zfront-zback)
return np.array([[1,0,0,0],
[0,1,0,0],
[0,0,a,b],
[0,0,-1,0]
]) | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def proj_transform_vec_clip(vec, M):
vecw = np.dot(M, vec)
w = vecw[3]
# clip here..
txs, tys, tzs = vecw[0]/w, vecw[1]/w, vecw[2]/w
tis = (vecw[0] >= 0) * (vecw[0] <= 1) * (vecw[1] >= 0) * (vecw[1] <= 1)
if np.sometrue(tis):
tis = vecw[1] < 1
return txs, tys, tzs, tis | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def vec_pad_ones(xs, ys, zs):
try:
try:
vec = np.array([xs,ys,zs,np.ones(xs.shape)])
except (AttributeError,TypeError):
vec = np.array([xs,ys,zs,np.ones((len(xs)))])
except TypeError:
vec = np.array([xs,ys,zs,1])
return vec | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def proj_transform_clip(xs, ys, zs, M):
"""
Transform the points by the projection matrix
and return the clipping result
returns txs,tys,tzs,tis
"""
vec = vec_pad_ones(xs, ys, zs)
return proj_transform_vec_clip(vec, M) | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def proj_points(points, M):
return list(zip(*proj_trans_points(points, M))) | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def proj_trans_clip_points(points, M):
xs, ys, zs = list(zip(*points))
return proj_transform_clip(xs, ys, zs, M) | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def test_proj_make_M(E=None):
# eye point
E = E or np.array([1, -1, 2]) * 1000
#E = np.array([20,10,20])
R = np.array([1, 1, 1]) * 100
V = np.array([0, 0, 1])
viewM = view_transformation(E, R, V)
perspM = persp_transformation(100, -100)
M = np.dot(perspM, viewM)
return M | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def rot_x(V, alpha):
cosa, sina = np.cos(alpha), np.sin(alpha)
M1 = np.array([[1,0,0,0],
[0,cosa,-sina,0],
[0,sina,cosa,0],
[0,0,0,0]])
return np.dot(M1, V) | unnikrishnankgs/va | [
1,
5,
1,
10,
1496432585
] |
def __init__(self, machine: "MachineController") -> None:
"""Initialise Fadecandy.
Args:
----
machine: The main ``MachineController`` object.
"""
super().__init__(machine)
self.log = logging.getLogger("FadeCandy")
self.log.debug("Configuring FadeCand... | missionpinball/mpf | [
176,
127,
176,
108,
1403853986
] |
def __init__(self, machine, config):
"""Initialise Fadecandy client.
Args:
----
machine: The main ``MachineController`` instance.
config: Dictionary which contains configuration settings for the
OPC client.
"""
super().__init__(machine, co... | missionpinball/mpf | [
176,
127,
176,
108,
1403853986
] |
def __repr__(self):
"""Return str representation."""
return '<Platform.FadeCandyOPClient>' | missionpinball/mpf | [
176,
127,
176,
108,
1403853986
] |
def _ls(item, recursive=False, groups=False, level=0):
keys = []
if isinstance(item, h5.Group):
if groups and level > 0:
keys.append(item.name)
if level == 0 or recursive:
for key in list(item.keys()):
keys.extend(_ls(item[key], recursive, groups, level + ... | cangermueller/deepcpg | [
130,
68,
130,
18,
1474306651
] |
def write_data(data, filename):
"""Write data in dict `data` to HDF5 file."""
is_root = isinstance(filename, str)
group = h5.File(filename, 'w') if is_root else filename
for key, value in six.iteritems(data):
if isinstance(value, dict):
key_group = group.create_group(key)
... | cangermueller/deepcpg | [
130,
68,
130,
18,
1474306651
] |
def reader(data_files, names, batch_size=128, nb_sample=None, shuffle=False,
loop=False):
if isinstance(names, dict):
names = hnames_to_names(names)
else:
names = to_list(names)
# Copy, since list will be changed if shuffle=True
data_files = list(to_list(data_files))
# Ch... | cangermueller/deepcpg | [
130,
68,
130,
18,
1474306651
] |
def read_from(reader, nb_sample=None):
from .utils import stack_dict
data = dict()
nb_seen = 0
is_dict = True
for data_batch in reader:
if not isinstance(data_batch, dict):
data_batch = _to_dict(data_batch)
is_dict = False
for key, value in six.iteritems(dat... | cangermueller/deepcpg | [
130,
68,
130,
18,
1474306651
] |
def __init__(self, plotly_name="delta", parent_name="indicator", **kwargs):
super(DeltaValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
data_class_str=kwargs.pop("data_class_str", "Delta"),
data_docs=kwargs.pop(
"data_do... | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def test_distribute(tmp_path):
"""
Check that the scripts to compute a trajectory are generated correctly
"""
cmd1 = "distribute_jobs.py -i test/test_files/input_test_distribute_derivative_couplings.yml"
cmd2 = "distribute_jobs.py -i test/test_files/input_test_distribute_absorption_spectrum.yml"
... | felipeZ/nonAdiabaticCoupling | [
7,
10,
7,
9,
1465559023
] |
def check_scripts():
"""
Check that the distribution scripts were created correctly
"""
paths = fnmatch.filter(os.listdir('.'), "chunk*")
# Check that the files are created correctly
files = ["launch.sh", "chunk_xyz*", "input.yml"]
for p in paths:
p = Path(p)
for f in files:... | felipeZ/nonAdiabaticCoupling | [
7,
10,
7,
9,
1465559023
] |
def id(self):
"""Gets a value that specifies the member identifier for the user or group.
:rtype: int or None
"""
return self.properties.get('Id', None) | vgrem/Office365-REST-Python-Client | [
816,
246,
816,
181,
1454945091
] |
def title(self):
"""Gets a value that specifies the name of the principal.
:rtype: str or None
"""
return self.properties.get('Title', None) | vgrem/Office365-REST-Python-Client | [
816,
246,
816,
181,
1454945091
] |
def title(self, value):
self.set_property('Title', value) | vgrem/Office365-REST-Python-Client | [
816,
246,
816,
181,
1454945091
] |
def login_name(self):
"""Gets the login name of the principal.
:rtype: str or None
"""
return self.properties.get('LoginName', None) | vgrem/Office365-REST-Python-Client | [
816,
246,
816,
181,
1454945091
] |
def user_principal_name(self):
"""Gets the UPN of the principal.
:rtype: str or None
"""
return self.properties.get('UserPrincipalName', None) | vgrem/Office365-REST-Python-Client | [
816,
246,
816,
181,
1454945091
] |
def is_hidden_in_ui(self):
"""Gets the login name of the principal.
:rtype: bool or None
"""
return self.properties.get('IsHiddenInUI', None) | vgrem/Office365-REST-Python-Client | [
816,
246,
816,
181,
1454945091
] |
def principal_type(self):
"""Gets the login name of the principal.
:rtype: int or None
"""
return self.properties.get('PrincipalType', None) | vgrem/Office365-REST-Python-Client | [
816,
246,
816,
181,
1454945091
] |
def __init__(self, *args):
# type: (Any) -> None
"""__init__(o, sentinel=None)"""
self._iterable = iter(*args) # type: Iterable
self._cache = collections.deque() # type: collections.deque
if len(args) == 2:
self.sentinel = args[1]
else:
se... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def __next__(self, n=None):
# type: (int) -> Any
# note: prevent 2to3 to transform self.next() in next(self) which
# causes an infinite loop !
return getattr(self, 'next')(n) | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def has_next(self):
# type: () -> bool
"""Determine if iterator is exhausted.
Returns
-------
bool
True if iterator has more items, False otherwise.
Note
----
Will never raise :exc:`StopIteration`.
"""
return self.peek() != s... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def peek(self, n=None):
# type: (int) -> Any
"""Preview the next item or `n` items of the iterator.
The iterator is not advanced when peek is called.
Returns
-------
item or list of items
The next item or `n` items of the iterator. If `n` is None, the
... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def __init__(self, *args, **kwargs):
# type: (Any, Any) -> None
"""__init__(o, sentinel=None, modifier=lambda x: x)"""
if 'modifier' in kwargs:
self.modifier = kwargs['modifier']
elif len(args) > 2:
self.modifier = args[2]
args = args[:2]
else:... | ajbouh/tfi | [
154,
12,
154,
3,
1505258255
] |
def test___doc__(self):
self.assertEqual(
ctds.Cursor.fetchmany.__doc__,
'''\ | zillow/ctds | [
79,
13,
79,
21,
1457558644
] |
def test_closed(self):
with self.connect() as connection:
cursor = connection.cursor()
cursor.close()
try:
cursor.fetchmany()
except ctds.InterfaceError as ex:
self.assertEqual(str(ex), 'cursor closed')
else:
... | zillow/ctds | [
79,
13,
79,
21,
1457558644
] |
def test_invalid_size(self):
with self.connect() as connection:
with connection.cursor() as cursor:
self.assertRaises(TypeError, cursor.fetchmany, size='123') | zillow/ctds | [
79,
13,
79,
21,
1457558644
] |
def test_fetchmany(self):
with self.connect() as connection:
with connection.cursor() as cursor:
cursor.execute(
'''
DECLARE @{0} TABLE(i INT);
INSERT INTO @{0}(i) VALUES (1),(2),(3);
SELECT *... | zillow/ctds | [
79,
13,
79,
21,
1457558644
] |
def test_empty_resultset(self):
with self.connect() as connection:
with connection.cursor() as cursor:
cursor.execute(
'''
DECLARE @{0} TABLE(i INT);
INSERT INTO @{0}(i) VALUES (1),(2),(3);
SE... | zillow/ctds | [
79,
13,
79,
21,
1457558644
] |
def __init__(self, phaseSide1="C", phaseSide2="C", normalOpen=False, Switch=None, *args, **kw_args):
"""Initialises a new 'SwitchPhase' instance.
@param phaseSide1: Phase of this SwitchPhase on the “from” (Switch.Terminal.sequenceNumber=1) side. Should be a phase contained in that terminal&... | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def getSwitch(self): | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def setSwitch(self, value):
if self._Switch is not None:
filtered = [x for x in self.Switch.SwitchPhases if x != self]
self._Switch._SwitchPhases = filtered
self._Switch = value
if self._Switch is not None:
if self not in self._Switch._SwitchPhases:
... | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def __init__(self, path, map_size=1000000000, code_size=8, writeonly=False):
super(HammingDb, self).__init__()
self.writeonly = writeonly
if not os.path.exists(path):
os.makedirs(path)
self.path = path
self.env = lmdb.open(
self.path,
max_db... | JohnVinyard/zounds | [
22,
6,
22,
26,
1458698104
] |
def __del__(self):
self.close() | JohnVinyard/zounds | [
22,
6,
22,
26,
1458698104
] |
def __exit__(self, exc_type, exc_val, exc_tb):
self.close() | JohnVinyard/zounds | [
22,
6,
22,
26,
1458698104
] |
def get_metadata(self, key):
with self.env.begin() as txn:
return txn.get(key, db=self.metadata) | JohnVinyard/zounds | [
22,
6,
22,
26,
1458698104
] |
def __len__(self):
with self.env.begin() as txn:
lmdb_size = txn.stat(self.index)['entries']
if not lmdb_size:
return 0
return lmdb_size | JohnVinyard/zounds | [
22,
6,
22,
26,
1458698104
] |
def _initialize_in_memory_store(self):
if self.writeonly:
return
if self._codes is not None:
return
initial_size = max(int(1e6), len(self))
self._codes = Growable(self._recarray(initial_size)) | JohnVinyard/zounds | [
22,
6,
22,
26,
1458698104
] |
def _validate_code_size(self, code):
code_len = len(code)
if code_len != self.code_size:
fmt = '''code must be equal to code_size
({self.code_size}), but was {code_len}'''
raise ValueError(fmt.format(**locals())) | JohnVinyard/zounds | [
22,
6,
22,
26,
1458698104
] |
def _check_for_external_modifications(self):
if self.__len__() != self._codes.logical_size:
self._catch_up_on_in_memory_store() | JohnVinyard/zounds | [
22,
6,
22,
26,
1458698104
] |
def append(self, code, data):
self._validate_code_size(code)
self._initialize_in_memory_store()
with self.env.begin(write=True) as txn:
_id = self._new_id()
try:
code = code.encode()
except AttributeError:
pass
try:... | JohnVinyard/zounds | [
22,
6,
22,
26,
1458698104
] |
def random_search(self, n_results, multithreaded=False, sort=False):
code = self._random_code()
return code, self.search(code, n_results, multithreaded, sort=sort) | JohnVinyard/zounds | [
22,
6,
22,
26,
1458698104
] |
def __init__(self, parent, color):
wx.Window.__init__(self, parent, -1, style = wx.SIMPLE_BORDER)
self.SetBackgroundColour(color)
if wx.Platform == '__WXGTK__':
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) | dnxbjyj/python-basic | [
1,
4,
1,
11,
1501510345
] |
def __init__(self, data):
self._string = data | ActiveState/code | [
1884,
686,
1884,
41,
1500923597
] |
def unobfuscate(self):
""" Reverse of obfuscation """
out = ""
data = self._string | ActiveState/code | [
1884,
686,
1884,
41,
1500923597
] |
def main(): | ActiveState/code | [
1884,
686,
1884,
41,
1500923597
] |
def __init__(self, plotly_name="hoverlabel", parent_name="scattermapbox", **kwargs):
super(HoverlabelValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
data_class_str=kwargs.pop("data_class_str", "Hoverlabel"),
data_docs=kwargs.pop(
... | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.