function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def test_none_str(self):
assert convert_vector_catch('none') == 0 | mbedmicro/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def test_none_b(self):
assert convert_vector_catch(b'none') == 0 | mbedmicro/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def test_vc_str(self, vc, msk):
assert convert_vector_catch(vc) == msk | mbedmicro/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def test_vc_b(self, vc, msk):
assert convert_vector_catch(vc) == msk | mbedmicro/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def test_empty(self):
assert convert_session_options([]) == {} | mbedmicro/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def test_unknown_option(self):
assert convert_session_options(['dumkopf']) == {} | mbedmicro/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def test_bool(self):
assert convert_session_options(['auto_unlock']) == {'auto_unlock': True}
assert convert_session_options(['no-auto_unlock']) == {'auto_unlock': False}
assert convert_session_options(['auto_unlock=1']) == {'auto_unlock': True}
assert convert_session_options(['auto_unlo... | mbedmicro/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def test_noncasesense(self):
# Test separate paths for with and without a value.
assert convert_session_options(['AUTO_Unlock']) == {'auto_unlock': True}
assert convert_session_options(['AUTO_Unlock=0']) == {'auto_unlock': False} | mbedmicro/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def test_int(self):
# Non-bool with no value is ignored (and logged).
assert convert_session_options(['frequency']) == {}
# Invalid int value is ignored and logged
assert convert_session_options(['frequency=abc']) == {}
# Ignore with no- prefix
assert convert_session_opti... | mbedmicro/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def test_str(self):
# Ignore with no value
assert convert_session_options(['test_binary']) == {}
# Ignore with no- prefix
assert convert_session_options(['no-test_binary']) == {}
# Valid
assert convert_session_options(['test_binary=abc']) == {'test_binary': 'abc'} | mbedmicro/pyOCD | [
883,
424,
883,
228,
1382710205
] |
def __init__(self, args):
"""
Args:
args: parameters of the model
"""
self.args = args | Conchylicultor/MusicGenerator | [
295,
76,
295,
8,
1472483765
] |
def init_state(self):
""" Return the initial cell state
"""
return None | Conchylicultor/MusicGenerator | [
295,
76,
295,
8,
1472483765
] |
def get_module_id():
return 'rnn' | Conchylicultor/MusicGenerator | [
295,
76,
295,
8,
1472483765
] |
def build(self):
""" Initialize the weights of the model
"""
self.rnn_cell = tfutils.get_rnn_cell(self.args, "deco_cell")
self.project_key = tfutils.single_layer_perceptron([self.args.hidden_size, 1],
'project_key') | Conchylicultor/MusicGenerator | [
295,
76,
295,
8,
1472483765
] |
def get_cell(self, prev_keyboard, prev_state_enco):
""" a RNN decoder
See parent class for arguments details
"""
axis = 1 # The first dimension is the batch, we split the keys
assert prev_keyboard.get_shape()[axis].value == music.NB_NOTES
inputs = tf.split(axis, music.N... | Conchylicultor/MusicGenerator | [
295,
76,
295,
8,
1472483765
] |
def get_module_id():
return 'perceptron' | Conchylicultor/MusicGenerator | [
295,
76,
295,
8,
1472483765
] |
def build(self):
""" Initialize the weights of the model
"""
# For projecting on the keyboard space
self.project_hidden = tfutils.single_layer_perceptron([music.NB_NOTES, self.args.hidden_size],
'project_hidden')
# Fo... | Conchylicultor/MusicGenerator | [
295,
76,
295,
8,
1472483765
] |
def get_module_id():
return 'lstm' | Conchylicultor/MusicGenerator | [
295,
76,
295,
8,
1472483765
] |
def build(self):
""" Initialize the weights of the model
"""
# TODO: Control over the the Cell using module arguments instead of global arguments (hidden_size and num_layer) !!
# RNN network
rnn_cell = tf.nn.rnn_cell.BasicLSTMCell(self.args.hidden_size, state_is_tuple=True) # Or... | Conchylicultor/MusicGenerator | [
295,
76,
295,
8,
1472483765
] |
def __init__(self, *args, **kwargs):
pass | cuemacro/chartpy | [
510,
98,
510,
7,
1470261601
] |
def auto_set_key(self):
self.twitter = Twython(cc.TWITTER_APP_KEY, cc.TWITTER_APP_SECRET,
cc.TWITTER_OAUTH_TOKEN, cc.TWITTER_OAUTH_TOKEN_SECRET) | cuemacro/chartpy | [
510,
98,
510,
7,
1470261601
] |
def dict(self):
"""
Return a python dictionary which could be jsonified.
"""
return {key: value.dict for key, value in self.items()} | ef-ctx/tornwamp | [
7,
3,
7,
1,
1415799047
] |
def __init__(self, websocket, **details):
"""
Create a connection object provided:
- websocket (tornado.websocket.WebSocketHandler instance
- details: dictionary of metadata associated to the connection
"""
self.id = create_global_id()
# set connection attributes... | ef-ctx/tornwamp | [
7,
3,
7,
1,
1415799047
] |
def peer(self):
try:
ip, port = self._websocket.ws_connection.stream.socket.getpeername()
except (AttributeError, OSError, socket.error) as error:
if not hasattr(error, 'errno') or error.errno in (errno.EBADF, errno.ENOTCONN):
# Expected errnos:
# ... | ef-ctx/tornwamp | [
7,
3,
7,
1,
1415799047
] |
def add_subscription_channel(self, subscription_id, topic_name):
"""
Add topic as a subscriber.
"""
self.topics["subscriber"][topic_name] = subscription_id | ef-ctx/tornwamp | [
7,
3,
7,
1,
1415799047
] |
def add_publishing_channel(self, subscription_id, topic_name):
"""
Add topic as a publisher.
"""
self.topics["publisher"][topic_name] = subscription_id | ef-ctx/tornwamp | [
7,
3,
7,
1,
1415799047
] |
def get_publisher_topics(self):
"""
Return list of topics to which this connection has subscribed.
"""
return list(self.topics["publisher"]) | ef-ctx/tornwamp | [
7,
3,
7,
1,
1415799047
] |
def topics_by_subscription_id(self):
return {subscription_id: topic for topic, subscription_id in self.get_topics().items()} | ef-ctx/tornwamp | [
7,
3,
7,
1,
1415799047
] |
def dict(self):
"""
Return dict representation of the current Connection, keeping only data
that could be exported to JSON (convention: attributes which do not
start with _).
"""
return {k: v for k, v in self.__dict__.items() if not k.startswith('_')} | ef-ctx/tornwamp | [
7,
3,
7,
1,
1415799047
] |
def __init__(self):
pass | lesommer/oocgcm | [
36,
12,
36,
27,
1458817850
] |
def map_apply(func,scalararray):
"""Return a xarray dataarray with value func(scalararray.data)
Parameters
----------
func : function
Any function that works on numpy arrays such that input and output
arrays have the same shape.
scalararray : xarray.DataArray
Returns
------... | lesommer/oocgcm | [
36,
12,
36,
27,
1458817850
] |
def is_numpy(array):
"""Return True if array is a numpy array
Parameters
----------
array : array-like
array is either a numpy array, a masked array, a dask array or a xarray.
Returns
-------
test : bool
"""
test = bool( isinstance(array,np.ndarray)
+ isin... | lesommer/oocgcm | [
36,
12,
36,
27,
1458817850
] |
def is_daskarray(array):
"""Return True if array is a dask array
Parameters
----------
array : array-like
Returns
-------
test : bool
"""
return isinstance(array,da.core.Array) | lesommer/oocgcm | [
36,
12,
36,
27,
1458817850
] |
def _append_dataarray_extra_attrs(xarr,**extra_kwargs):
"""Update the dictionnary of attributes a xarray dataarray (xarr.attrs).
Parameters
----------
xarr : xarray.DataArray
The function will add extra arguments to xarr.attrs
**extra_kwargs
not used
Returns
-------
da ... | lesommer/oocgcm | [
36,
12,
36,
27,
1458817850
] |
def _chunks_are_compatible(chunks1=None,chunks2=None,ndims=None):
"""Return True when two chunks are aligned over their common dimensions.
Parameters
----------
chunks1 : list-like of list-like object
chunks associated to a xarray data array
chunks2 : list-like of list-like object
c... | lesommer/oocgcm | [
36,
12,
36,
27,
1458817850
] |
def _assert_and_set_grid_location_attribute(xarr,grid_location=None):
"""Assert whether xarr holds an extra attribute 'grid_location' that
equals grid_location. If xarr does not have such extra-attribute, create
one with value grid_location.
Parameters
----------
xarr : xarray.DataArray
... | lesommer/oocgcm | [
36,
12,
36,
27,
1458817850
] |
def __init__(self):
Exception.__init__(self,"incompatible chunk size") | lesommer/oocgcm | [
36,
12,
36,
27,
1458817850
] |
def __init__(self, ctx: Context, client: BaseHTTPClientConnection):
self.ctx = ctx
self._client = client
self._ws = WSConnection(ConnectionType.SERVER) | asphalt-framework/asphalt-web | [
7,
1,
7,
1,
1430740193
] |
def begin_request(self, request: HTTPRequest):
trailing_data = self._client.upgrade()
self._ws.receive_bytes(trailing_data)
self._process_ws_events() | asphalt-framework/asphalt-web | [
7,
1,
7,
1,
1430740193
] |
def send_message(self, payload: Union[str, bytes]) -> None:
"""
Send a message to the client.
:param payload: either a unicode string or a bytestring
"""
self._ws.send_data(payload)
bytes_to_send = self._ws.bytes_to_send()
self._client.write(bytes_to_send) | asphalt-framework/asphalt-web | [
7,
1,
7,
1,
1430740193
] |
def on_connect(self) -> None:
"""Called when the websocket handshake has been done.""" | asphalt-framework/asphalt-web | [
7,
1,
7,
1,
1430740193
] |
def PlotGene(label, X, Y, s=3, alpha=1.0, ax=None):
fig = None
if ax is None:
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
for li in np.unique(label):
idxN = (label == li).flatten()
ax.scatter(X[idxN], Y[idxN], s=s, alpha=alpha, label=int(np.round(li)))
return fig, ax | ManchesterBioinference/BranchedGP | [
25,
7,
25,
17,
1474552399
] |
def FitGene(g, ns=20): # for quick results subsample data
t = time.time()
Bsearch = list(np.linspace(0.05, 0.95, 5)) + [
1.1
] # set of candidate branching points
GPy = (Y[g].iloc[::ns].values - Y[g].iloc[::ns].values.mean())[
:, None
] # remove mean from gene expression data
... | ManchesterBioinference/BranchedGP | [
25,
7,
25,
17,
1474552399
] |
def _div_maybe_zero(total_loss, num_present):
"""Normalizes the total loss with the number of present pixels."""
return tf.cast(num_present > 0, tf.float32) * tf.math.divide(
total_loss, tf.maximum(1e-5, num_present)) | googleinterns/wss | [
142,
21,
142,
9,
1597440534
] |
def compute_cam_v2(
end_points,
logits,
cls_label,
num_class=21,
use_attention=True,
attention_dim=128,
strides=(15, 16),
is_training=True,
valid_mask=None,
net='xception_65', | googleinterns/wss | [
142,
21,
142,
9,
1597440534
] |
def compute_self_att_v2(
end_points,
logits,
num_class=21,
attention_dim=128,
strides=(15, 16),
is_training=True,
linformer=True,
valid_mask=None,
factor=8,
downsample_type='nearest',
net='xception_65'):
"""Compute self-attention for segmentation head.
Args:
end_poin... | googleinterns/wss | [
142,
21,
142,
9,
1597440534
] |
def prepend_ctes(self, prepended_ctes: List[InjectedCTE]):
self.extra_ctes_injected = True
self.extra_ctes = prepended_ctes
if self.compiled_sql is None:
raise RuntimeException(
'Cannot prepend ctes to an unparsed node', self
)
self.injected_sql = ... | fishtown-analytics/dbt | [
6645,
1178,
6645,
457,
1457577480
] |
def empty(self):
""" Seeds are never empty"""
return False | fishtown-analytics/dbt | [
6645,
1178,
6645,
457,
1457577480
] |
def _inject_ctes_into_sql(sql: str, ctes: List[InjectedCTE]) -> str:
"""
`ctes` is a list of InjectedCTEs like:
[
InjectedCTE(
id="cte_id_1",
sql="__dbt__CTE__ephemeral as (select * from table)",
),
InjectedCTE(
id="cte... | fishtown-analytics/dbt | [
6645,
1178,
6645,
457,
1457577480
] |
def compiled_type_for(parsed: ParsedNode) -> CompiledType:
if type(parsed) in COMPILED_TYPES:
return COMPILED_TYPES[type(parsed)]
else:
return type(parsed) | fishtown-analytics/dbt | [
6645,
1178,
6645,
457,
1457577480
] |
def smart_concat(v1, v2):
if isinstance(v1, tf.Tensor) or isinstance(v2, tf.Tensor):
return tf.concat([v1, v2], 0)
else:
return v1 + v2 | deepmind/sonnet | [
9523,
1351,
9523,
33,
1491219275
] |
def __init__(self,
num_spatial_dims: int,
output_channels: int,
kernel_shape: Union[int, Sequence[int]],
output_shape: Optional[types.ShapeLike] = None,
stride: Union[int, Sequence[int]] = 1,
rate: Union[int, Sequence[int]] = 1,
... | deepmind/sonnet | [
9523,
1351,
9523,
33,
1491219275
] |
def _initialize(self, inputs):
utils.assert_rank(inputs, self._num_spatial_dims + 2)
self.input_channels = inputs.shape[self._channel_index]
if self.input_channels is None:
raise ValueError("The number of input channels must be known")
self._dtype = inputs.dtype
if self._output_shape is not N... | deepmind/sonnet | [
9523,
1351,
9523,
33,
1491219275
] |
def _get_output_shape(self, inputs):
input_shape = inputs.shape if inputs.shape.is_fully_defined() else tf.shape(
inputs)
if self._channel_index == 1:
input_size = input_shape[2:]
else:
input_size = input_shape[1:-1]
stride = utils.replicate(self._stride, self._num_spatial_dims, "st... | deepmind/sonnet | [
9523,
1351,
9523,
33,
1491219275
] |
def __init__(self,
output_channels: int,
kernel_shape: Union[int, Sequence[int]],
output_shape: Optional[types.ShapeLike] = None,
stride: Union[int, Sequence[int]] = 1,
rate: Union[int, Sequence[int]] = 1,
padding: str = "SAME",
... | deepmind/sonnet | [
9523,
1351,
9523,
33,
1491219275
] |
def __init__(self,
output_channels: int,
kernel_shape: Union[int, Sequence[int]],
output_shape: Optional[types.ShapeLike] = None,
stride: Union[int, Sequence[int]] = 1,
rate: Union[int, Sequence[int]] = 1,
padding: str = "SAME",
... | deepmind/sonnet | [
9523,
1351,
9523,
33,
1491219275
] |
def setup_loader_modules(self):
return {x509: {"__opts__": {"fips_mode": False}}} | saltstack/salt | [
13089,
5388,
13089,
3074,
1298233016
] |
def setup_loader_modules(self):
self.file_managed_mock = MagicMock()
self.file_managed_mock.return_value = {"changes": True}
return {
x509: {
"__opts__": {"fips_mode": True},
"__salt__": {
"x509.get_pem_entry": x509_mod.get_pem_ent... | saltstack/salt | [
13089,
5388,
13089,
3074,
1298233016
] |
def test_private_key_fips_mode(self):
"""
:return:
"""
test_key = dedent(
"""
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDx7UUt0cPi5G51
FmRBhAZtZb5x6P0PFn7GwnLmSvLNhCsOcD/vq/yBUU62pknzmOjM5pgWTACZj66O
GOFmWBg0... | saltstack/salt | [
13089,
5388,
13089,
3074,
1298233016
] |
def execute(self, src_proto_path, import_proto_path,
organization_name):
self._organization_name = organization_name
# Treat google.protobuf, google.iam as a common proto package, even
# though they are not included in the common-protos we generate.
#
# TODO (gei... | googleapis/artman | [
133,
85,
133,
12,
1459375772
] |
def _transform(self, pkg, sep, common_protos):
"""Transform to the appropriate proto package layout.
Works with arbitrary separator (e.g., '/' for import statements,
'.' for proto package statements, os.path.sep for filenames)
"""
if sep != '.' and pkg.endswith('.proto'):
... | googleapis/artman | [
133,
85,
133,
12,
1459375772
] |
def _copy_and_transform_directories(
self, src_directories, destination_directory, common_protos,
paths=None):
for path in src_directories:
protos = list(protoc_utils.find_protos([path], []))
for proto in protos:
src_base_dirs = self._extract_base_... | googleapis/artman | [
133,
85,
133,
12,
1459375772
] |
def execute(self, grpc_code_dir, gapic_code_dir):
"""Move the protos into the GAPIC structure.
This copies the ``x/y/z/proto/`` directory over to be a sibling
of ``x/y/z/gapic/`` in the GAPIC code directory. In the event of
an inconsistency on the prefix, the GAPIC wins.
Args:
... | googleapis/artman | [
133,
85,
133,
12,
1459375772
] |
def main(): # pragma: no cover
execute(os.environ, sys.argv[1:], sys.stdout) | google/gif-for-cli | [
2858,
162,
2858,
18,
1528989105
] |
def __init__(
self,
address: Address,
kwargs: Optional[Dict[str, Any]] = None,
msg_id: Optional[UID] = None,
reply_to: Optional[Address] = None,
reply: bool = False, | OpenMined/PySyft | [
8617,
1908,
8617,
143,
1500410476
] |
def payload(self) -> Payload:
kwargs_dict = {}
if hasattr(self.kwargs, "upcast"):
kwargs_dict = self.kwargs.upcast() # type: ignore
else:
kwargs_dict = self.kwargs # type: ignore
try:
# If it's not a reply message then load kwargs as a proper reque... | OpenMined/PySyft | [
8617,
1908,
8617,
143,
1500410476
] |
def get_permissions(self) -> List:
"""Returns the list of permission classes applicable to the given message."""
raise NotImplementedError | OpenMined/PySyft | [
8617,
1908,
8617,
143,
1500410476
] |
def __init__(self, local_hostname, logger):
logger.debug("Creating CommandRunner with Args - local_hostname: {local_hostname}, logger: {logger}".format(**locals()))
self.local_hostname = local_hostname
self.logger = logger | teamclairvoyant/airflow-scheduler-failover-controller | [
220,
63,
220,
7,
1475000288
] |
def run_command(self, host, base_command):
self.logger.debug("Running Command: " + str(base_command))
if host == self.local_hostname or host in self.HOST_LIST_TO_RUN_LOCAL:
return self._run_local_command(base_command)
else:
return self._run_ssh_command(host, base_command) | teamclairvoyant/airflow-scheduler-failover-controller | [
220,
63,
220,
7,
1475000288
] |
def _run_local_command(self, base_command):
self.logger.debug("Running command as Local command")
output = os.popen(base_command).read()
if output:
output = output.split("\n")
self.logger.debug("Run Command output: " + str(output))
return True, output | teamclairvoyant/airflow-scheduler-failover-controller | [
220,
63,
220,
7,
1475000288
] |
def __init__(self, jvalue=None, **kwargs):
super(Sequential, self).__init__(jvalue, **kwargs) | intel-analytics/analytics-zoo | [
2553,
722,
2553,
534,
1493951250
] |
def is_built(self):
try:
self.get_output_shape()
return True
except:
return False | intel-analytics/analytics-zoo | [
2553,
722,
2553,
534,
1493951250
] |
def from_jvalue(jvalue, bigdl_type="float"):
"""
Create a Python Model base on the given java value
:param jvalue: Java object create by Py4j
:return: A Python Model
"""
model = Sequential(jvalue=jvalue)
model.value = jvalue
return model | intel-analytics/analytics-zoo | [
2553,
722,
2553,
534,
1493951250
] |
def __init__(self, input, output, jvalue=None, **kwargs):
super(Model, self).__init__(jvalue,
to_list(input),
to_list(output),
**kwargs) | intel-analytics/analytics-zoo | [
2553,
722,
2553,
534,
1493951250
] |
def new_graph(self, outputs):
value = callZooFunc(self.bigdl_type, "newGraph", self.value, outputs)
return self.from_jvalue(value) | intel-analytics/analytics-zoo | [
2553,
722,
2553,
534,
1493951250
] |
def unfreeze(self, names):
callZooFunc(self.bigdl_type, "unFreeze", self.value, names) | intel-analytics/analytics-zoo | [
2553,
722,
2553,
534,
1493951250
] |
def env(tmpdir, redis_cache):
basedir = tmpdir
conffile = tmpdir.join('flask-resize-conf.py')
conffile.write(
""" | jmagnusson/Flask-Resize | [
47,
11,
47,
6,
1384049068
] |
def run(env, *args):
return subprocess.check_output(args, env=env).decode().splitlines() | jmagnusson/Flask-Resize | [
47,
11,
47,
6,
1384049068
] |
def test_bin_usage(env):
assert 'usage: flask-resize' in run(env, 'flask-resize', '--help')[0] | jmagnusson/Flask-Resize | [
47,
11,
47,
6,
1384049068
] |
def test_bin_list_images_empty(env):
assert run(env, 'flask-resize', 'list', 'images') == [] | jmagnusson/Flask-Resize | [
47,
11,
47,
6,
1384049068
] |
def test_bin_list_has_images(
env,
resizetarget_opts,
image1_name,
image1_data,
image1_key | jmagnusson/Flask-Resize | [
47,
11,
47,
6,
1384049068
] |
def test_bin_list_cache_empty(env, redis_cache):
assert run(env, 'flask-resize', 'list', 'cache') == [] | jmagnusson/Flask-Resize | [
47,
11,
47,
6,
1384049068
] |
def test_bin_list_has_cache(env, redis_cache):
redis_cache.add('hello')
redis_cache.add('buh-bye')
assert set(run(env, 'flask-resize', 'list', 'cache')) == \
{'hello', 'buh-bye'} | jmagnusson/Flask-Resize | [
47,
11,
47,
6,
1384049068
] |
def test_bin_clear_images(
env,
resizetarget_opts,
image1_name,
image1_data | jmagnusson/Flask-Resize | [
47,
11,
47,
6,
1384049068
] |
def test_bin_clear_cache(env, redis_cache):
redis_cache.add('foo bar')
assert run(env, 'flask-resize', 'clear', 'cache') == [] | jmagnusson/Flask-Resize | [
47,
11,
47,
6,
1384049068
] |
def test_bin_sync_cache(
env,
resizetarget_opts,
image1_name,
image1_data,
image1_key,
redis_cache | jmagnusson/Flask-Resize | [
47,
11,
47,
6,
1384049068
] |
def dict_for_mongo_without_userform_id(parsed_instance):
d = parsed_instance.to_dict_for_mongo()
# remove _userform_id since its not returned by the API
d.pop(ParsedInstance.USERFORM_ID)
return d | makinacorpus/formhub | [
1,
3,
1,
1,
1415368669
] |
def setUp(self):
MainTestCase.setUp(self)
self._create_user_and_login()
self._publish_transportation_form_and_submit_instance()
self.api_url = reverse(api, kwargs={
'username': self.user.username,
'id_string': self.xform.id_string
}) | makinacorpus/formhub | [
1,
3,
1,
1,
1415368669
] |
def test_api_with_query(self):
# query string
query = '{"transport/available_transportation_types_to_referral_facility":"none"}'
data = {'query': query}
response = self.client.get(self.api_url, data)
self.assertEqual(response.status_code, 200)
d = dict_for_mongo_without_u... | makinacorpus/formhub | [
1,
3,
1,
1,
1415368669
] |
def test_handle_bad_json(self):
response = self.client.get(self.api_url, {'query': 'bad'})
self.assertEqual(response.status_code, 400)
self.assertEqual(True, 'JSON' in response.content) | makinacorpus/formhub | [
1,
3,
1,
1,
1415368669
] |
def test_api_with_query_start_limit(self):
# query string
query = '{"transport/available_transportation_types_to_referral_facility":"none"}'
data = {'query': query, 'start': 0, 'limit': 10}
response = self.client.get(self.api_url, data)
self.assertEqual(response.status_code, 200)... | makinacorpus/formhub | [
1,
3,
1,
1,
1415368669
] |
def test_api_count(self):
# query string
query = '{"transport/available_transportation_types_to_referral_facility":"none"}'
data = {'query': query, 'count': 1}
response = self.client.get(self.api_url, data)
self.assertEqual(response.status_code, 200)
find_d = json.loads(r... | makinacorpus/formhub | [
1,
3,
1,
1,
1415368669
] |
def test_api_decode_from_mongo(self):
field = "$section1.group01.question1"
encoded = _encode_for_mongo(field)
self.assertEqual(encoded, ("%(dollar)ssection1%(dot)sgroup01%(dot)squestion1" % \
{"dollar": base64.b64encode("$"), \
... | makinacorpus/formhub | [
1,
3,
1,
1,
1415368669
] |
def testIncomplete(self):
self.fail("Add header tests for <CoreGraphics/CGPDFDictionary.h>") | albertz/music-player | [
483,
61,
483,
16,
1345772141
] |
def __init__(self, con, query_templates, schema, table, name, dtype, keys_per_column):
self._con = con
self._query_templates = query_templates
self.schema = schema
self.table = table
self.name = name
self.type = dtype
self.keys_per_column = keys_per_column
... | yhat/db.py | [
1220,
116,
1220,
33,
1414337817
] |
def __str__(self):
return "Column({0})<{1}>".format(self.name, self.__hash__()) | yhat/db.py | [
1220,
116,
1220,
33,
1414337817
] |
def _str_foreign_keys(self):
keys = []
for col in self.foreign_keys:
keys.append("%s.%s" % (col.table, col.name))
if self.keys_per_column is not None and len(keys) > self.keys_per_column:
keys = keys[0:self.keys_per_column] + ['(+ {0} more)'.format(len(keys) - self.keys_p... | yhat/db.py | [
1220,
116,
1220,
33,
1414337817
] |
def head(self, n=6):
"""
Returns first n values of your column as a DataFrame. This is executing:
SELECT
<name_of_the_column>
FROM
<name_of_the_table>
LIMIT <n>
Parameters
----------
n: int
number of... | yhat/db.py | [
1220,
116,
1220,
33,
1414337817
] |
def unique(self):
"""
Returns all unique values as a DataFrame. This is executing:
SELECT
DISTINCT
<name_of_the_column>
FROM
<name_of_the_table>
Examples
--------
>>> from db import DemoDB
>>> db... | yhat/db.py | [
1220,
116,
1220,
33,
1414337817
] |
def to_dict(self):
"""
Serialize representation of the column for local caching.
"""
return {'schema': self.schema, 'table': self.table, 'name': self.name, 'type': self.type} | yhat/db.py | [
1220,
116,
1220,
33,
1414337817
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.