query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Sets all log arrays to a current value. | def reset_logs(self):
# reset log arrays
try:
bc = self.petra.BeamCurrent
except:
bc = numpy.nan
try:
pac = self.tserver.read_attribute('PosAndAvgCurr').value
except:
pac = numpy.array([numpy.nan, numpy.nan, numpy.nan])
serv... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_logging_arr(self):\n self.log_arr = []",
"def log_elements(self, log_elements):\n\n self._log_elements = log_elements",
"def _wipe_log(self):\n self.temp_log.clear()\n self.temp_log = [[], []] # init a 2D array",
"def reset_logger():\n for log in ALL_LEVELS:\n ... | [
"0.6752328",
"0.64241666",
"0.6055851",
"0.5979368",
"0.5926505",
"0.5659023",
"0.5599223",
"0.55467343",
"0.5533408",
"0.5506867",
"0.5502828",
"0.54892516",
"0.5484629",
"0.54787904",
"0.54655725",
"0.5448269",
"0.5432319",
"0.54243636",
"0.5422054",
"0.5410817",
"0.5402471... | 0.706452 | 0 |
Get list of requirements required for installation. | def install_requires():
return reqs('requirements.txt') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_requires():\n return reqs(\"requirements.txt\")",
"def get_install_requires() -> List[str]:\n return [\n \n ]",
"def requires():\n install_reqs = parse_requirements(join(CWD, 'requirements', 'base.txt'),\n session=False)\n return [str(ir.re... | [
"0.8409988",
"0.8359472",
"0.828312",
"0.8219742",
"0.81854343",
"0.81252146",
"0.8071705",
"0.80322313",
"0.7970809",
"0.7774683",
"0.7724761",
"0.76847386",
"0.7667431",
"0.76324123",
"0.76069945",
"0.76004237",
"0.75916094",
"0.75916094",
"0.74921674",
"0.7445241",
"0.7431... | 0.84131104 | 0 |
Return k closest points to the origin >>> kclosestpoints([(1,1), (0,0), (2,2), (1,2), (3,2)], 2) [((0, 0), 0), ((1, 1), 2)] | def kclosestpoints(points, k):
dist = {p : 0 for p in points}
for point in points:
dist[point] = point[0] ** 2 + point[1] ** 2
dist = sorted(dist.items(), key=lambda x : x[1], reverse=False)
return dist[:k] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_k_closest_points(point, data, k, distance_metric):\n points_and_scores = []\n k_closest_points = []\n for item in data:\n item_score = distance_metric(point, item)\n points_and_scores.append([item, item_score])\n points_and_scores = sorted(points_and_scores, key = lambda item:(ite... | [
"0.79715997",
"0.7098614",
"0.70486695",
"0.70407385",
"0.6972852",
"0.6917117",
"0.68956125",
"0.6822356",
"0.6779336",
"0.67348033",
"0.67085296",
"0.6700983",
"0.661611",
"0.64570594",
"0.64557004",
"0.6420059",
"0.6397378",
"0.63768524",
"0.6335915",
"0.6302754",
"0.62684... | 0.8524627 | 0 |
Test Scenario for following sequence. 1. Put metric alarm (period 60, evaluation_periods 1) 2. Put metric data which is over the threshold so that the alarm state would be 'ALARM' 3. Wait 2 minutes so that alarm state could be 'INSUFFICIENT_DATA' 4. Put metric data which is under the threshold so that the alarm state w... | def test_eval_alarm(self):
def get_state_update_value(h):
"""
"""
oldstate = h.data['oldState']['stateValue']
newstate = h.data['newState']['stateValue']
querydate = h.data['newState']['stateReasonData']['queryDate']
querydate ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alarm_in_setup_change():\n setup_write(\"!M1 meas interval\", \"00:01:00\")\n setup_write(\"!M2 meas interval\", \"00:01:00\")\n setup_write(\"!TX3 scheduled interval\", \"00:05:00\")",
"def test_alert_high(fd, formatter, event):\n ao = AlertObserver(3, fd=fd, formatter=formatter, event=event)\n ... | [
"0.6144483",
"0.613362",
"0.61275727",
"0.60468686",
"0.59062594",
"0.57918984",
"0.57610506",
"0.5745387",
"0.5712116",
"0.57005745",
"0.5697942",
"0.56855434",
"0.5667826",
"0.5645718",
"0.5632293",
"0.5605659",
"0.5582332",
"0.5570504",
"0.55398816",
"0.55327576",
"0.55220... | 0.80237985 | 0 |
determine the tuning which is symmetrically similar to target that can be reached from current, within the minimum number of half step modifications | def compute_optimal_tuning(target,current):
target = target.split(' ')
current = current.split(' ')
initial = [calculate_note_distance(current[i],target[i]) for i in range(min(len(current), len(target)))]
total_modifications = reduce(lambda x,y: abs(x) + abs(y), initial)
winner = []
min_sum = total_modifi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_allowed(self, base):\n x = base.copy()\n var_opt = None\n dim = x.shape[0]\n for i in range(dim):\n # Plus increment\n x[i] += self.step\n curr_obj = self.obj_wrap(x)\n # Check update feasible, obj improved\n # new point in... | [
"0.6273489",
"0.61885136",
"0.61885136",
"0.6086417",
"0.59578407",
"0.585661",
"0.5825039",
"0.5813893",
"0.5754839",
"0.5698001",
"0.56716925",
"0.56596774",
"0.5644322",
"0.56128955",
"0.56061",
"0.55671877",
"0.5557258",
"0.55553675",
"0.55381364",
"0.55143857",
"0.550565... | 0.6830949 | 0 |
Join several querysets by a UNION clause. Returns the SQL string and the list of parameters. | def union(self, querysets):
# union() is "New in Django 1.11." (docs site)
# but buggy in 2.0, with a backport in 1.11.8 ; my ticket 29229, fixed in 1.11.12 & 2.0.4.
# For simplicity, let's even ignore the usable 1.11.0-7 frame.
# Ticket 29286 reintroduced a bug in 1.11.13 & 2.0.5, by co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def union(self, list_or_stmt):\n if not isinstance(list_or_stmt, basestring) and not isinstance(list_or_stmt, mysqlstmt.Select):\n for c in list_or_stmt:\n self.union(c)\n else:\n self._selects.append(list_or_stmt)\n return self",
"def sql_merge(sqls=[],c... | [
"0.64259",
"0.6321942",
"0.6130795",
"0.61098236",
"0.60906136",
"0.5835884",
"0.58204424",
"0.5803518",
"0.57851565",
"0.56865054",
"0.5662633",
"0.5622609",
"0.5616906",
"0.55898374",
"0.55030537",
"0.54707825",
"0.5422362",
"0.5398607",
"0.53946865",
"0.534702",
"0.5294266... | 0.7916193 | 0 |
Configure Heatzy API using Home Assistant configuration and fetch all Heatzy devices. | async def async_setup_platform(hass, config, add_devices, discovery_info=None):
# retrieve platform config
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
session = aiohttp_client.async_get_clientsession(hass)
store = storage.Store(hass, STORAGE_VERSION, STORAGE_KEY)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(hass, base_config):\n from pyhusmow import API as HUSMOW_API\n\n config = base_config.get(DOMAIN)\n\n if hass.data.get(DOMAIN) is None:\n hass.data[DOMAIN] = { 'devices': [] }\n\n api = HUSMOW_API()\n api.login(config.get(CONF_USERNAME), config.get(CONF_PASSWORD))\n\n robots = ap... | [
"0.62153625",
"0.61709046",
"0.61675733",
"0.6046003",
"0.6033546",
"0.6017969",
"0.60002464",
"0.5992273",
"0.5990323",
"0.5985458",
"0.5971451",
"0.596242",
"0.59595805",
"0.5925293",
"0.59210336",
"0.5850367",
"0.5831101",
"0.582566",
"0.5823615",
"0.58009064",
"0.5798444"... | 0.68286645 | 0 |
Find Home Assistant implementation for the Heatzy device. Implementation search is based on device 'product_key'. If the implementation is not found, returns None. | def find_heatzy_device_implementation(device):
DeviceImplementation = PRODUCT_KEY_TO_DEVICE_IMPLEMENTATION.get(
device.get('product_key'))
if DeviceImplementation is None:
_LOGGER.warn('Device %s with product key %s is not supported',
device.get('did'), d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finddevice():\n\n return next((device for device in [\"xpu\"] if hasattr(torch, device) and getattr(torch, device).is_available()), None)",
"def version_homeassistant(self):\n return self._data.get(ATTR_HOMEASSISTANT)",
"def find_hardware(self, device_info=None):\n if os.name is not 'n... | [
"0.56770015",
"0.54674935",
"0.5386558",
"0.5367639",
"0.5356104",
"0.5310794",
"0.5292249",
"0.528761",
"0.5282866",
"0.52739716",
"0.5228391",
"0.5215351",
"0.51800424",
"0.514778",
"0.51102084",
"0.5108489",
"0.50883085",
"0.50771827",
"0.5076043",
"0.5057647",
"0.50539875... | 0.76875865 | 0 |
Parse a signed transaction document, check its validity, verify signature and add to local blockchain. Broadcast to the same endpoint for network if required. | def submit_transaction():
data = request.get_json()
# Create candidate transaction object
try:
tx = Transaction.from_dict(data['transaction'])
except (KeyError, TypeError):
response = dict(message='Improper transaction json provided.')
status_code = 400
return jsonify(re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_transaction_signature(sender_address, signature, transaction):\n public_key = RSA.importKey(binascii.unhexlify(sender_address))\n verifier = PKCS1_v1_5.new(public_key)\n h = SHA.new(str(transaction).encode('utf8'))\n return verifier.verify(h, binascii.unhexlify(signature))",
"def sign_tran... | [
"0.5823398",
"0.5507605",
"0.5499924",
"0.54724085",
"0.543781",
"0.5409771",
"0.5338388",
"0.5267575",
"0.5263092",
"0.5254972",
"0.52403116",
"0.52362233",
"0.52072877",
"0.5187738",
"0.5178956",
"0.51556087",
"0.512451",
"0.5109286",
"0.51000565",
"0.50987065",
"0.50754654... | 0.5765218 | 1 |
Return pyarrow.Array view of a numpy ndarray. In floating arrays, all nan values are interpreted as nulls. In complex arrays, if real or imaginary part of an array item value is nan, the value is interpreted as null. | def pyarrow_array(arr, nan_to_null=False):
import numpy as np
import pyarrow as pa
if nan_to_null and issubclass(arr.dtype.type,
(np.floating, np.complexfloating)):
isnan = np.isnan(arr)
if isnan.any():
pa_nul = pa.py_buffer(get_bitmap(isnan))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_array(self, fill_value: Optional[Any] = None) -> np.ndarray:\n if fill_value is None:\n fill_value = infer_nan(self.dtype)\n\n tmp = self.astype(float) if is_float(fill_value) else self\n return tmp.to_masked().filled(fill_value=fill_value)",
"def astype(self, dtype):\n ... | [
"0.62539476",
"0.6237079",
"0.62334555",
"0.61480075",
"0.6110793",
"0.61007154",
"0.5992015",
"0.5985517",
"0.59757584",
"0.5964086",
"0.5952105",
"0.5907571",
"0.5905403",
"0.58591914",
"0.58547294",
"0.584407",
"0.58131367",
"0.5769717",
"0.5739238",
"0.57200414",
"0.56952... | 0.83253616 | 0 |
Return pandas.Series view of a numpy ndarray. | def pandas_series(arr, nan_to_null=False):
import pandas as pd
return pd.Series(arr, copy=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_series(self, arraylike: Iterable) -> pd.Series:\n return pd.Series(arraylike, index=self.data.index)",
"def to_series(self) -> pd.Series:\n df = self.to_dataframe(\"* values *\")\n dims = self.dims_list\n if len(dims) == 1:\n dims = dims[0]\n return df.set_ind... | [
"0.75008994",
"0.6564477",
"0.6380644",
"0.63323957",
"0.6261605",
"0.6144519",
"0.61209697",
"0.60778224",
"0.59853053",
"0.5960021",
"0.57288134",
"0.5726076",
"0.56944275",
"0.56930923",
"0.5679621",
"0.56723833",
"0.5619051",
"0.560027",
"0.55883527",
"0.5580834",
"0.5561... | 0.7094817 | 1 |
Return xnd.xnd view of a numpy ndarray. | def xnd_xnd(arr, nan_to_null=False):
import numpy as np
import xnd
xd = xnd.xnd.from_buffer(arr)
if nan_to_null and issubclass(arr.dtype.type,
(np.floating, np.complexfloating)):
isnan = np.isnan(arr)
if isnan.any():
raise NotImplementedError... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_x(self):\n return self.x[:self.nump, :]",
"def xarray(shape, yx=[0, 0], dtype=int):\n\n y, x = np.indices(shape, dtype)[-2:]\n y -= yx[0]\n x -= yx[1]\n\n return x",
"def xvec(self):\n return np.array([self.x, self.y])",
"def get_X():\n metadata = get_dataset_metadata(['shape... | [
"0.64285505",
"0.6316943",
"0.60496306",
"0.60137516",
"0.5971376",
"0.5949019",
"0.59254515",
"0.5917849",
"0.5917849",
"0.58760124",
"0.5871833",
"0.5835483",
"0.5809457",
"0.57799095",
"0.5735253",
"0.5714293",
"0.5669488",
"0.562255",
"0.5617021",
"0.5584969",
"0.5580597"... | 0.7452788 | 0 |
Creates a new gene randomly inheriting attributes from its parents. | def crossover(self, gene2):
assert self.key == gene2.key
new_gene = self.__class__(self.key)
for a in self._gene_attributes:
if random() > 0.5:
setattr(new_gene, a.name, getattr(self, a.name))
else:
setattr(new_gene, a.name, g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def procreate(cls, *geneSeeds):\n assert len(geneSeeds) > 1, \"Specify at least 2 seeds\"\n # None gene leads to averaging; it occurs less often with many seeds to keep diversity\n genePool = geneSeeds + (None,)\n child = cls()\n for name, prop in properties(MushroomProps).items(... | [
"0.6713792",
"0.66021925",
"0.6351296",
"0.6316457",
"0.62280685",
"0.61375886",
"0.60927796",
"0.6087185",
"0.5995881",
"0.5975843",
"0.5962058",
"0.5929928",
"0.59042895",
"0.5847486",
"0.5844697",
"0.57921326",
"0.5765903",
"0.5764469",
"0.576404",
"0.5721603",
"0.5670374"... | 0.6677358 | 1 |
Converts an SDK generator object to a list of dictionaries. | def _sdk_object_to_list(object):
result_list = []
for item in object:
result_list.append(_get_sdk_object_dict(item))
return result_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feed_dict_generator(self):\n pass",
"def feed_dict_generator(self):\n pass",
"def generate(self) -> Dict[str, Any]:\n raise NotImplementedError",
"def __init__( self, generator):\n DictObject.__init__( self, generator.generate_dict())",
"def meta(self):\n return list(self... | [
"0.5913769",
"0.5913769",
"0.5789118",
"0.5718109",
"0.5672597",
"0.565475",
"0.5629378",
"0.5629203",
"0.55589277",
"0.55574167",
"0.5539112",
"0.55310833",
"0.5509818",
"0.54935837",
"0.5449725",
"0.54130375",
"0.5365224",
"0.5355766",
"0.5316992",
"0.52876484",
"0.52859634... | 0.6143716 | 0 |
Converts an SDK object to a dictionary. Fixes any SDK imposed object oddities. | def _get_sdk_object_dict(object):
item_dict = object.to_dict()
if 'is_admin_state_up' in item_dict:
item_dict['admin_state_up'] = item_dict['is_admin_state_up']
return item_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asdict():\n pass",
"def to_dict(cls) -> dict:\n raise NotImplementedError()",
"def cast_to_dict(self, obj):\n if type(obj) is dict:\n return obj\n elif type(obj) is tuple or type(obj) is list:\n # convert to dictionary\n return dict(zip(obj[0::2]... | [
"0.64806324",
"0.62011474",
"0.6196252",
"0.61945736",
"0.6145522",
"0.6134164",
"0.6110898",
"0.61091757",
"0.6108938",
"0.6048648",
"0.5996235",
"0.5911936",
"0.58756256",
"0.5848238",
"0.5840572",
"0.5840459",
"0.5820397",
"0.5816648",
"0.58105606",
"0.58056337",
"0.580087... | 0.68956816 | 0 |
Poll for the status of the load balancer. Polls for the status of the load balancer and calls a function when the status changes to a specified state. | def poll_loadbalancer_status(request, loadbalancer_id, callback,
from_state='PENDING_UPDATE', to_state='ACTIVE',
callback_kwargs=None):
interval = conf.HORIZON_CONFIG['ajax_poll_interval'] / 1000.0
status = from_state
while status == from_state:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def poll_for_active_status(self, server_id, req_status=\"ACTIVE\"):\n status = \"BUILDING\"\n iteration = 30\n while status.upper() != req_status.upper() \\\n or status.upper() != \"ERROR\":\n server_info = self.show_server(server_id)\n if not isinstance(se... | [
"0.62133944",
"0.6175639",
"0.6137733",
"0.6020755",
"0.5786416",
"0.5756918",
"0.57512337",
"0.56928927",
"0.568958",
"0.567798",
"0.5551411",
"0.5530037",
"0.5486613",
"0.5446558",
"0.54423386",
"0.5410045",
"0.5408748",
"0.5402765",
"0.53912175",
"0.5387205",
"0.5353605",
... | 0.8122314 | 0 |
Create a new l7 policy. | def create_l7_policy(request, **kwargs):
data = request.DATA
conn = get_sdk_connection(request)
l7_policy = conn.load_balancer.create_l7_policy(
action=data['l7policy']['action'],
admin_state_up=data['l7policy'].get('admin_state_up'),
description=data['l7policy'].get('description'),... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_l7_rule(request, **kwargs):\n data = request.DATA\n\n conn = get_sdk_connection(request)\n l7_rule = conn.load_balancer.create_l7_rule(\n admin_state_up=data['l7rule'].get('admin_state_up'),\n compare_type=data['l7rule']['compare_type'],\n invert=data['l7rule'].get('invert'... | [
"0.71313787",
"0.6708961",
"0.66281354",
"0.6562187",
"0.5976769",
"0.59415835",
"0.58462644",
"0.5843046",
"0.5654051",
"0.5594792",
"0.5545354",
"0.55239606",
"0.55046284",
"0.5478598",
"0.54642725",
"0.5444684",
"0.542711",
"0.53933513",
"0.53799",
"0.53317475",
"0.5290894... | 0.7716427 | 0 |
Create a new l7 rule. | def create_l7_rule(request, **kwargs):
data = request.DATA
conn = get_sdk_connection(request)
l7_rule = conn.load_balancer.create_l7_rule(
admin_state_up=data['l7rule'].get('admin_state_up'),
compare_type=data['l7rule']['compare_type'],
invert=data['l7rule'].get('invert'),
k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self, request, l7_policy_id):\n kwargs = {'l7_policy_id': l7_policy_id}\n return create_l7_rule(request, **kwargs)",
"def update_l7_rule(request, **kwargs):\n data = request.DATA\n l7_rule_id = data['l7rule'].get('id')\n\n conn = get_sdk_connection(request)\n l7_rule = conn.loa... | [
"0.6551737",
"0.6281853",
"0.6256196",
"0.5533587",
"0.5317884",
"0.51790553",
"0.5176982",
"0.51300806",
"0.5054435",
"0.50302255",
"0.50243175",
"0.50243175",
"0.50243175",
"0.50243175",
"0.50243175",
"0.5020988",
"0.5017123",
"0.49702477",
"0.49285138",
"0.49261418",
"0.49... | 0.7878783 | 0 |
Create a new health monitor for a pool. | def create_health_monitor(request, **kwargs):
data = request.DATA
conn = get_sdk_connection(request)
health_mon = conn.load_balancer.create_health_monitor(
type=data['monitor']['type'],
delay=data['monitor']['delay'],
timeout=data['monitor']['timeout'],
max_retries=data['mon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_healthmonitor(self, context, healthmonitor):\n LOG.info(\"Received request 'Create Pool Health Monitor' for\"\n \"Health monitor:%(hm)s\",\n {'hm': healthmonitor['id']})\n arg_dict = {'context': context,\n lb_const.HEALTHMONITOR: healthmon... | [
"0.7401438",
"0.7051553",
"0.69609606",
"0.66524464",
"0.62678564",
"0.6037645",
"0.5910251",
"0.5820596",
"0.5788904",
"0.5740553",
"0.5709624",
"0.5578223",
"0.5542494",
"0.5517016",
"0.55118424",
"0.54961306",
"0.5465203",
"0.54008526",
"0.5371732",
"0.53213763",
"0.529806... | 0.79059434 | 0 |
Create a new flavor profile. | def create_flavor_profile(request, **kwargs):
data = request.DATA
conn = get_sdk_connection(request)
flavor_profile = conn.load_balancer.create_flavor(
name=data['flavor_profile']['name'],
provider_name=data['flavor_profile']['provider_name'],
flavor_data=data['flavor_profile']['fla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self, request):\n kwargs = {\n 'flavor_profile': request.DATA.get('flavor_profile')\n }\n return create_flavor_profile(request, **kwargs)",
"def _create_flavor(self, context, flavor):\n flavor_dict = flavor.__dict__\n name = self.prefix + flavor.name\n ... | [
"0.7588814",
"0.7113851",
"0.7016141",
"0.6691254",
"0.6609089",
"0.6587327",
"0.6524055",
"0.65014654",
"0.64622223",
"0.6389659",
"0.638112",
"0.63053924",
"0.62853515",
"0.623517",
"0.6190537",
"0.6173143",
"0.61469984",
"0.61188585",
"0.61023474",
"0.6086395",
"0.606686",... | 0.81453323 | 0 |
Add a member to a pool. | def add_member(request, **kwargs):
data = request.DATA
members = data.get('members')
pool_id = kwargs.get('pool_id')
if kwargs.get('members_to_add'):
members_to_add = kwargs['members_to_add']
index = [members.index(member) for member in members
if member['id'] == member... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_pool ( self, pool ):\n self._pool_id += 1\n try:\n self._poolstack.append ( pool )\n except:\n self._pool_id -= 1\n raise\n\n self._update_resolver()",
"def create_member(self, context, member):\n LOG.info(\"Received request 'Create Member' for Pool:%(p... | [
"0.7209677",
"0.6895673",
"0.689446",
"0.67602986",
"0.660132",
"0.65374035",
"0.648779",
"0.64865744",
"0.6474529",
"0.64278823",
"0.63709176",
"0.635849",
"0.6333273",
"0.6296607",
"0.6255828",
"0.6253365",
"0.62174135",
"0.6187497",
"0.61844695",
"0.61722165",
"0.61623985"... | 0.73543555 | 0 |
Update a load balancer. | def update_loadbalancer(request, **kwargs):
data = request.DATA
loadbalancer_id = kwargs.get('loadbalancer_id')
conn = get_sdk_connection(request)
loadbalancer = conn.load_balancer.update_load_balancer(
loadbalancer_id,
name=data['loadbalancer'].get('name'),
description=data['lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, request, loadbalancer_id):\n kwargs = {'loadbalancer_id': loadbalancer_id}\n update_loadbalancer(request, **kwargs)",
"def update_loadbalancer(self, context, lb, old):\n LOG.debug(\"\\nupdate_loadbalancer({}): called\".format(lb.id))\n hostnames = self._get_hostname(lb)\... | [
"0.7603567",
"0.75081575",
"0.7132624",
"0.6622582",
"0.6482295",
"0.5973013",
"0.59142834",
"0.5895011",
"0.58677447",
"0.58624214",
"0.5861494",
"0.58360505",
"0.58234656",
"0.5724865",
"0.57089597",
"0.5703134",
"0.5689305",
"0.56433725",
"0.56244296",
"0.5590786",
"0.5572... | 0.7929236 | 0 |
Update a l7 policy. | def update_l7_policy(request, **kwargs):
data = request.DATA
l7_policy_id = data['l7policy'].get('id')
conn = get_sdk_connection(request)
l7_policy = conn.load_balancer.update_l7_policy(
action=data['l7policy']['action'],
admin_state_up=data['l7policy'].get('admin_state_up'),
de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, request, l7_policy_id):\n kwargs = {'l7_policy_id': l7_policy_id}\n update_l7_policy(request, **kwargs)",
"def put(self, request, l7_rule_id, l7_policy_id):\n kwargs = {'l7_rule_id': l7_rule_id, 'l7_policy_id': l7_policy_id}\n update_l7_rule(request, **kwargs)",
"def u... | [
"0.8157796",
"0.7380047",
"0.7321923",
"0.72552663",
"0.72434366",
"0.6903672",
"0.687366",
"0.660481",
"0.63835156",
"0.6328471",
"0.6318798",
"0.6145343",
"0.59935164",
"0.5969864",
"0.5870234",
"0.5857865",
"0.579704",
"0.5761515",
"0.57155144",
"0.55789167",
"0.5576889",
... | 0.83306193 | 0 |
Update a l7 rule. | def update_l7_rule(request, **kwargs):
data = request.DATA
l7_rule_id = data['l7rule'].get('id')
conn = get_sdk_connection(request)
l7_rule = conn.load_balancer.update_l7_rule(
admin_state_up=data['l7rule'].get('admin_state_up'),
compare_type=data['l7rule']['compare_type'],
inve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, request, l7_rule_id, l7_policy_id):\n kwargs = {'l7_rule_id': l7_rule_id, 'l7_policy_id': l7_policy_id}\n update_l7_rule(request, **kwargs)",
"def update_l7_policy(request, **kwargs):\n data = request.DATA\n l7_policy_id = data['l7policy'].get('id')\n\n conn = get_sdk_connect... | [
"0.7299374",
"0.6614859",
"0.65223616",
"0.58992857",
"0.57806516",
"0.57245296",
"0.56335515",
"0.56320626",
"0.56009996",
"0.5545236",
"0.55088514",
"0.54439205",
"0.54374593",
"0.54025745",
"0.53321713",
"0.5291471",
"0.52768487",
"0.5186999",
"0.51278824",
"0.51227224",
"... | 0.8170401 | 0 |
Update a flavor profile. | def update_flavor_profile(request, **kwargs):
data = request.DATA
flavor_profile_id = data['flavor_profile']['id']
conn = get_sdk_connection(request)
flavor_profile = conn.load_balancer.update_flavor_profile(
flavor_profile_id,
name=data['flavor_profile'].get('name'),
provider_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, request, flavor_profile_id):\n update_flavor_profile(request)",
"def update_flavor(cls, flavor_uuid, values):\n return cls.dbdriver.update_flavor(flavor_uuid, values)",
"def update(self, profile: Dict[datetime.time, float]) -> None:\n\n if self._profile is None:\n ... | [
"0.83874655",
"0.6720268",
"0.64170563",
"0.6350232",
"0.62681884",
"0.62541854",
"0.5983731",
"0.5891509",
"0.58709943",
"0.58603674",
"0.58362377",
"0.5781399",
"0.57701105",
"0.57553375",
"0.5744363",
"0.5706912",
"0.570035",
"0.5665021",
"0.5640496",
"0.56272614",
"0.5623... | 0.8229874 | 1 |
Update the list of members by adding or removing the necessary members. | def update_member_list(request, **kwargs):
data = request.DATA
loadbalancer_id = data.get('loadbalancer_id')
pool_id = kwargs.get('pool_id')
existing_members = kwargs.get('existing_members')
members_to_add = kwargs.get('members_to_add')
members_to_delete = kwargs.get('members_to_delete')
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_members(self, members):\n self.__add_remove_members(members)",
"def update_members(self, new_member_list):\n updated_members = 0\n request_list = list()\n\n # stale_members contains all old members at first, all current\n # members get then removed so that the remaining... | [
"0.7322556",
"0.7289237",
"0.69442546",
"0.68231875",
"0.6818597",
"0.6818597",
"0.6818597",
"0.6776591",
"0.6742535",
"0.67015535",
"0.6662517",
"0.65746605",
"0.6528248",
"0.6491567",
"0.64232713",
"0.6329506",
"0.621608",
"0.6207658",
"0.6158595",
"0.61513424",
"0.61500156... | 0.73280567 | 0 |
Add floating IP address info to each load balancer. | def add_floating_ip_info(request, loadbalancers):
floating_ips = neutron.tenant_floating_ip_list(request)
for lb in loadbalancers:
floating_ip = {}
associated_ip = next((fip for fip in floating_ips
if fip['port_id'] == lb['vip_port_id']), None)
if associated... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_host_floating_ips(self):\n\n admin_context = context.get_admin_context()\n try:\n floating_ips = objects.FloatingIPList.get_by_host(admin_context,\n self.host)\n except exception.NotFound:\n return\n\n ... | [
"0.61381817",
"0.598348",
"0.5813492",
"0.57341975",
"0.5732378",
"0.57311445",
"0.5620384",
"0.56031364",
"0.56030154",
"0.55562806",
"0.5500934",
"0.54350865",
"0.5413562",
"0.53627616",
"0.5329677",
"0.5325784",
"0.5312544",
"0.52665913",
"0.52376854",
"0.52365977",
"0.523... | 0.791662 | 0 |
Edit a load balancer. | def put(self, request, loadbalancer_id):
kwargs = {'loadbalancer_id': loadbalancer_id}
update_loadbalancer(request, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_loadbalancer(request, **kwargs):\n data = request.DATA\n loadbalancer_id = kwargs.get('loadbalancer_id')\n\n conn = get_sdk_connection(request)\n loadbalancer = conn.load_balancer.update_load_balancer(\n loadbalancer_id,\n name=data['loadbalancer'].get('name'),\n descrip... | [
"0.700744",
"0.66535103",
"0.6332974",
"0.61218095",
"0.6045121",
"0.58444375",
"0.57524234",
"0.5527921",
"0.54759747",
"0.5452721",
"0.54205173",
"0.53978443",
"0.53187937",
"0.53139496",
"0.5307594",
"0.5301771",
"0.5296107",
"0.52546227",
"0.5240936",
"0.52304596",
"0.522... | 0.74186695 | 0 |
Delete a specific load balancer. | def delete(self, request, loadbalancer_id):
conn = get_sdk_connection(request)
conn.load_balancer.delete_load_balancer(loadbalancer_id,
ignore_missing=True,
cascade=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_balancer(self):\n response = self.client.delete_load_balancer(\n LoadBalancerArn=self.get_balancer_arn()\n )\n assert response['ResponseMetadata']['HTTPStatusCode'] == 200",
"def delete(self, load_balancer):\n # type: (LoadBalancer) -> BoundAction\n self._... | [
"0.82724464",
"0.82108885",
"0.8187755",
"0.8121004",
"0.8085591",
"0.7962943",
"0.7837547",
"0.7503282",
"0.7202904",
"0.703992",
"0.6937303",
"0.6915725",
"0.6653849",
"0.6465005",
"0.6410816",
"0.64020866",
"0.639109",
"0.63578004",
"0.63545287",
"0.62534803",
"0.6184379",... | 0.82243186 | 1 |
Get a specific listener. If the param 'includeChildResources' is passed in as a truthy value, the details of all resources that exist under the listener will be returned along with the listener details. | def get(self, request, listener_id):
conn = get_sdk_connection(request)
listener = conn.load_balancer.find_listener(listener_id)
listener = _get_sdk_object_dict(listener)
if request.GET.get('includeChildResources'):
resources = {}
resources['listener'] = listener... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, request):\n loadbalancer_id = request.GET.get('loadbalancerId')\n conn = get_sdk_connection(request)\n listener_list = _sdk_object_to_list(conn.load_balancer.listeners(\n project_id=request.user.project_id))\n\n if loadbalancer_id:\n listener_list = s... | [
"0.5707967",
"0.5301975",
"0.4999579",
"0.49626032",
"0.49626032",
"0.49626032",
"0.48981005",
"0.48367912",
"0.47430673",
"0.47226316",
"0.47226316",
"0.47204754",
"0.46784675",
"0.46784675",
"0.46152645",
"0.45895073",
"0.45876774",
"0.4575969",
"0.45758468",
"0.45382637",
... | 0.75506186 | 0 |
Edit a listener as well as any resources below it. | def put(self, request, listener_id):
kwargs = {'listener_id': listener_id}
update_listener(request, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit(env, identifier, listener, **args):\n\n mgr = SoftLayer.LoadBalancerManager(env.client)\n uuid, _ = mgr.get_lbaas_uuid_id(identifier)\n\n new_listener = {\n 'listenerUuid': listener\n }\n\n arg_to_option = {\n 'frontprotocol': 'frontendProtocol',\n 'backprotocol': 'back... | [
"0.6823617",
"0.600671",
"0.577597",
"0.5750334",
"0.56320566",
"0.5572041",
"0.5471202",
"0.5394818",
"0.5374321",
"0.5368463",
"0.53638417",
"0.53259104",
"0.5251389",
"0.522504",
"0.5183015",
"0.5153863",
"0.51429737",
"0.51391524",
"0.5118935",
"0.5095881",
"0.50898105",
... | 0.62694657 | 1 |
Get a specific l7 policy. If the param 'includeChildResources' is passed in as a truthy value, the details of all resources that exist under the l7 policy will be returned along with the l7 policy details. | def get(self, request, l7_policy_id):
conn = get_sdk_connection(request)
l7_policy = conn.load_balancer.find_l7_policy(l7_policy_id)
l7_policy = _get_sdk_object_dict(l7_policy)
if request.GET.get('includeChildResources'):
resources = {}
if l7_policy.get('rules')... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, request, l7_rule_id, l7_policy_id):\n conn = get_sdk_connection(request)\n l7_rule = conn.load_balancer.find_l7_rule(l7_rule_id, l7_policy_id)\n return _get_sdk_object_dict(l7_rule)",
"def get(self, request, l7_policy_id):\n conn = get_sdk_connection(request)\n l7... | [
"0.6267911",
"0.57215685",
"0.56794816",
"0.5608188",
"0.5565996",
"0.54223526",
"0.53737026",
"0.5277922",
"0.52610373",
"0.5238874",
"0.5175136",
"0.5146227",
"0.5116967",
"0.51168495",
"0.5055844",
"0.50002635",
"0.4989549",
"0.49149385",
"0.490399",
"0.48882803",
"0.48582... | 0.8088022 | 0 |
Edit a l7 policy as well as any resources below it. | def put(self, request, l7_policy_id):
kwargs = {'l7_policy_id': l7_policy_id}
update_l7_policy(request, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_l7_policy(request, **kwargs):\n data = request.DATA\n l7_policy_id = data['l7policy'].get('id')\n\n conn = get_sdk_connection(request)\n l7_policy = conn.load_balancer.update_l7_policy(\n action=data['l7policy']['action'],\n admin_state_up=data['l7policy'].get('admin_state_up')... | [
"0.7356099",
"0.6932371",
"0.6876846",
"0.6712923",
"0.6301364",
"0.6158353",
"0.6146165",
"0.6069311",
"0.60549647",
"0.6009541",
"0.6009057",
"0.59801036",
"0.58342427",
"0.5770972",
"0.56784624",
"0.56772274",
"0.5657728",
"0.5577772",
"0.5536992",
"0.5461024",
"0.54436207... | 0.76575214 | 0 |
Delete a specific l7 policy. | def delete(self, request, l7_policy_id):
conn = get_sdk_connection(request)
retry_on_conflict(
conn, conn.load_balancer.delete_l7_policy,
l7_policy_id,
load_balancer_getter=l7_policy_get_load_balancer_id,
resource_id=l7_policy_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policy_delete(request, policy_id):\n neutronclient(request).delete_qos_policy(policy_id)",
"def delete(self, request, l7_rule_id, l7_policy_id):\n conn = get_sdk_connection(request)\n retry_on_conflict(\n conn, conn.load_balancer.delete_l7_rule,\n l7_rule_id, l7_policy_... | [
"0.7155855",
"0.7073564",
"0.7066619",
"0.69722295",
"0.66296524",
"0.659274",
"0.6546766",
"0.6512928",
"0.64337",
"0.62496746",
"0.61917585",
"0.61263865",
"0.6108714",
"0.60930246",
"0.6092611",
"0.60841596",
"0.60771275",
"0.6044096",
"0.60357344",
"0.60187685",
"0.596714... | 0.77358395 | 0 |
Create a new l7 rule. Creates a new l7 rule as well as other optional resources such as l7 rules. | def post(self, request, l7_policy_id):
kwargs = {'l7_policy_id': l7_policy_id}
return create_l7_rule(request, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_l7_rule(request, **kwargs):\n data = request.DATA\n\n conn = get_sdk_connection(request)\n l7_rule = conn.load_balancer.create_l7_rule(\n admin_state_up=data['l7rule'].get('admin_state_up'),\n compare_type=data['l7rule']['compare_type'],\n invert=data['l7rule'].get('invert'... | [
"0.8147097",
"0.63940793",
"0.62494886",
"0.56453776",
"0.5420765",
"0.5216677",
"0.52078986",
"0.51725924",
"0.5129113",
"0.50878996",
"0.5026985",
"0.5000985",
"0.5000185",
"0.49834046",
"0.49765438",
"0.49352294",
"0.49352294",
"0.49352294",
"0.49352294",
"0.49352294",
"0.... | 0.6611101 | 1 |
Get a specific l7 rule. | def get(self, request, l7_rule_id, l7_policy_id):
conn = get_sdk_connection(request)
l7_rule = conn.load_balancer.find_l7_rule(l7_rule_id, l7_policy_id)
return _get_sdk_object_dict(l7_rule) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, request, l7_policy_id):\n conn = get_sdk_connection(request)\n l7_rule_list = _sdk_object_to_list(conn.load_balancer.l7_rules(\n l7_policy_id))\n return {'items': l7_rule_list}",
"def _get_rule(self, rule):\n for kbrule in self.rules:\n if rule == k... | [
"0.6342875",
"0.6327162",
"0.6327162",
"0.6327162",
"0.626276",
"0.60649276",
"0.6019014",
"0.586598",
"0.57333195",
"0.5679398",
"0.5677424",
"0.5655824",
"0.5578348",
"0.54845756",
"0.5439656",
"0.54331386",
"0.54331386",
"0.54331386",
"0.54331386",
"0.54331386",
"0.5433138... | 0.6893091 | 0 |
Edit a specific l7 rule. | def put(self, request, l7_rule_id, l7_policy_id):
kwargs = {'l7_rule_id': l7_rule_id, 'l7_policy_id': l7_policy_id}
update_l7_rule(request, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_l7_rule(request, **kwargs):\n data = request.DATA\n l7_rule_id = data['l7rule'].get('id')\n\n conn = get_sdk_connection(request)\n l7_rule = conn.load_balancer.update_l7_rule(\n admin_state_up=data['l7rule'].get('admin_state_up'),\n compare_type=data['l7rule']['compare_type'],\... | [
"0.726384",
"0.6229128",
"0.5973603",
"0.59081304",
"0.57255226",
"0.5619726",
"0.56079495",
"0.54919493",
"0.54785186",
"0.5470105",
"0.5403452",
"0.53685534",
"0.5257742",
"0.5240305",
"0.52315074",
"0.52089244",
"0.5174361",
"0.51728857",
"0.5141247",
"0.51000416",
"0.5049... | 0.6922995 | 1 |
Delete a specific l7 rule. | def delete(self, request, l7_rule_id, l7_policy_id):
conn = get_sdk_connection(request)
retry_on_conflict(
conn, conn.load_balancer.delete_l7_rule,
l7_rule_id, l7_policy_id,
load_balancer_getter=l7_policy_get_load_balancer_id,
resource_id=l7_policy_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_rule(self, index):\n del self.rules[index]",
"def _delete_rule(cls, rule_suffix: str) -> None:\n delete_rule = cls._build_rule_string(IpTableCommandOption.DELETE, rule_suffix)\n log.info('Delete rule \"%s\"', delete_rule)\n utils.run_command(delete_rule, shell=True)",
"de... | [
"0.66611654",
"0.6327563",
"0.6271361",
"0.6203873",
"0.6158667",
"0.6153702",
"0.6061404",
"0.6053456",
"0.59814006",
"0.59674776",
"0.59412354",
"0.5924343",
"0.59201545",
"0.5894565",
"0.5891388",
"0.58845353",
"0.58808327",
"0.58054215",
"0.57890576",
"0.5766243",
"0.5753... | 0.7085398 | 0 |
Get a specific pool. If the param 'includeChildResources' is passed in as a truthy value, the details of all resources that exist under the pool will be returned along with the pool details. | def get(self, request, pool_id):
conn = get_sdk_connection(request)
pool = conn.load_balancer.find_pool(pool_id)
pool = _get_sdk_object_dict(pool)
if request.GET.get('includeChildResources'):
resources = {}
resources['pool'] = pool
if pool.get('membe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pool(self, name, dc, cluster):\n cluster_obj = self.get_cluster(cluster, dc)\n for rp in cluster_obj.resourcePool.resourcePool:\n if rp.name == name:\n return rp",
"def get_pool(self, pool_name=None, pool_id=None):\n\n id_or_name = pool_id if pool_id else po... | [
"0.6978908",
"0.6633539",
"0.6437803",
"0.6430661",
"0.636093",
"0.6309993",
"0.6266827",
"0.60692585",
"0.6041649",
"0.60270584",
"0.5997973",
"0.59675074",
"0.59316224",
"0.58240104",
"0.5701325",
"0.56308126",
"0.55841595",
"0.5570789",
"0.55605954",
"0.55356663",
"0.55098... | 0.7976712 | 0 |
Get a specific member belonging to a specific pool. | def get(self, request, member_id, pool_id):
conn = get_sdk_connection(request)
member = conn.load_balancer.find_member(member_id, pool_id)
return _get_sdk_object_dict(member) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMember(unique_name):",
"def getMember(unique_name):",
"def member(self, uid):\n try:\n member = self.search(uid=uid)[0]\n except IndexError:\n return None\n\n if self.objects:\n return member\n\n return member[1]",
"def get_member(self, name... | [
"0.708236",
"0.708236",
"0.66537815",
"0.6586724",
"0.6484308",
"0.64400035",
"0.6400656",
"0.6374163",
"0.6358884",
"0.6297418",
"0.6275908",
"0.6263685",
"0.62490386",
"0.6224761",
"0.618702",
"0.61346817",
"0.6080308",
"0.6012395",
"0.59983313",
"0.5996142",
"0.59809816",
... | 0.7321655 | 0 |
Delete a specific member belonging to a specific pool. | def delete(self, request, member_id, pool_id):
conn = get_sdk_connection(request)
retry_on_conflict(
conn, conn.load_balancer.delete_member,
member_id, pool_id,
load_balancer_getter=pool_get_load_balancer_id,
resource_id=pool_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_member(self, context, member):\n LOG.info(\"Received request 'Delete Member' for Pool:\"\n \"%(pool_id)s \",\n {'pool_id': member['pool_id']})\n arg_dict = {'context': context,\n lb_const.MEMBER: member,\n }\n sel... | [
"0.8120982",
"0.76730645",
"0.7627825",
"0.7410858",
"0.7356614",
"0.73075813",
"0.71536845",
"0.6852029",
"0.68129563",
"0.6670148",
"0.6619707",
"0.65564084",
"0.65563416",
"0.6519952",
"0.645955",
"0.64011204",
"0.6315733",
"0.62642276",
"0.6250975",
"0.62033415",
"0.62015... | 0.7731087 | 1 |
Edit a pool member. | def put(self, request, member_id, pool_id):
data = request.DATA
conn = get_sdk_connection(request)
monitor_address = data.get('monitor_address')
member = conn.load_balancer.update_member(
member_id, pool_id, weight=data.get('weight'),
monitor_address=monitor_addre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, request, pool_id):\n # Assemble the lists of member id's to add and remove, if any exist\n request_member_data = request.DATA.get('members', [])\n\n conn = get_sdk_connection(request)\n existing_members = _sdk_object_to_list(\n conn.load_balancer.members(pool_id... | [
"0.6425986",
"0.63002586",
"0.619265",
"0.6118293",
"0.608884",
"0.5876162",
"0.5841779",
"0.58345354",
"0.56993985",
"0.5678758",
"0.5619991",
"0.5610326",
"0.56079984",
"0.5544971",
"0.5526997",
"0.5516116",
"0.5471154",
"0.54462516",
"0.54318666",
"0.5422469",
"0.53969634"... | 0.6802564 | 0 |
Edit a health monitor. | def put(self, request, health_monitor_id):
update_monitor(request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_health_monitor(self, health_monitor, body=None):\r\n return self.put(self.health_monitor_path % (health_monitor), body=body)",
"def test_update_health_monitor(self):\r\n resource = 'health_monitor'\r\n cmd = healthmonitor.UpdateHealthMonitor(test_cli20.MyApp(sys.stdout),\r\n ... | [
"0.7318301",
"0.72835505",
"0.7035468",
"0.6422127",
"0.6017512",
"0.5552425",
"0.5524849",
"0.5474026",
"0.54440564",
"0.54111576",
"0.5367544",
"0.5276218",
"0.5227774",
"0.5200923",
"0.5196495",
"0.5196495",
"0.5196495",
"0.5196495",
"0.5122279",
"0.5118035",
"0.5062808",
... | 0.7851766 | 0 |
List of flavor profiles for the current project. The listing result is an object with property "items". | def get(self, request):
conn = get_sdk_connection(request)
flavor_profile_list = _sdk_object_to_list(
conn.load_balancer.flavor_profiles()
)
return {'items': flavor_profile_list} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_profiles(self):\n return self._get(\"posture\", box=BoxList)",
"def get_profiles(self):\n profiles = [['Profile name', 'GUID']]\n r = self.system_cursor.execute('{Call wtGetProfileList()}')\n for row in r.fetchall():\n profiles.a... | [
"0.7007203",
"0.6612687",
"0.6586266",
"0.65075374",
"0.64529777",
"0.63493913",
"0.62659556",
"0.6237638",
"0.6213668",
"0.6186253",
"0.61652416",
"0.6098566",
"0.6098566",
"0.5971148",
"0.5952143",
"0.58324105",
"0.5748105",
"0.57290924",
"0.57185817",
"0.569918",
"0.569253... | 0.68769735 | 1 |
Create a new flavor_profile. | def post(self, request):
kwargs = {
'flavor_profile': request.DATA.get('flavor_profile')
}
return create_flavor_profile(request, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_flavor_profile(request, **kwargs):\n data = request.DATA\n\n conn = get_sdk_connection(request)\n flavor_profile = conn.load_balancer.create_flavor(\n name=data['flavor_profile']['name'],\n provider_name=data['flavor_profile']['provider_name'],\n flavor_data=data['flavor_pr... | [
"0.82383496",
"0.71872705",
"0.70762885",
"0.66092575",
"0.6564234",
"0.6562639",
"0.6437814",
"0.63737965",
"0.63381845",
"0.633701",
"0.6322403",
"0.62916726",
"0.62406635",
"0.6178241",
"0.6152721",
"0.6128486",
"0.61260176",
"0.6100888",
"0.610016",
"0.6091575",
"0.607571... | 0.7608589 | 1 |
Get a specific flavor profile. | def get(self, request, flavor_profile_id):
conn = get_sdk_connection(request)
flavor_profile = conn.load_balancer.find_flavor_profile(
flavor_profile_id)
return _get_sdk_object_dict(flavor_profile) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_flavor(self, flavor):\n return self._get(_flavor.Flavor, flavor)",
"def get_flavor(self, flavor):\n return self._get(_flavor.Flavor, flavor)",
"def extract_profile(self, profile_name):\r\n for galaxy in self.galaxies:\r\n try:\r\n return galaxy.__dict__[pr... | [
"0.70800406",
"0.70800406",
"0.6608732",
"0.65897906",
"0.65892553",
"0.6582866",
"0.6535673",
"0.6515353",
"0.6513358",
"0.650227",
"0.6494548",
"0.6455354",
"0.64349127",
"0.6364045",
"0.6280376",
"0.62767255",
"0.61917675",
"0.6031149",
"0.6012957",
"0.5986818",
"0.5954201... | 0.73463917 | 0 |
Delete a specific flavor profile. | def delete(self, request, flavor_profile_id):
conn = get_sdk_connection(request)
conn.load_balancer.delete_flavor_profile(flavor_profile_id,
ignore_missing=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(profile, name):\n client = boto3client.get(\"iam\", profile)\n params = {}\n params[\"InstanceProfileName\"] = name\n return client.delete_instance_profile(**params)",
"def delete_flavor(self, flavor='del_flvr'):\n try:\n self.novaclient.flavors.delete(\n s... | [
"0.71852785",
"0.7161097",
"0.7055296",
"0.7039321",
"0.69454604",
"0.69354737",
"0.69235194",
"0.68888295",
"0.6755909",
"0.6731093",
"0.6639045",
"0.66346174",
"0.66286516",
"0.6616975",
"0.6566091",
"0.6523191",
"0.65105796",
"0.64986897",
"0.6495144",
"0.6456143",
"0.6422... | 0.8111144 | 0 |
Edit a flavor profile. | def put(self, request, flavor_profile_id):
update_flavor_profile(request) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_flavor_profile(request, **kwargs):\n data = request.DATA\n flavor_profile_id = data['flavor_profile']['id']\n\n conn = get_sdk_connection(request)\n flavor_profile = conn.load_balancer.update_flavor_profile(\n flavor_profile_id,\n name=data['flavor_profile'].get('name'),\n ... | [
"0.74378663",
"0.63604933",
"0.6213224",
"0.6136512",
"0.612196",
"0.611884",
"0.60730594",
"0.6056586",
"0.6027391",
"0.59156984",
"0.58968705",
"0.5880171",
"0.58693844",
"0.58434886",
"0.58420974",
"0.5836719",
"0.5831102",
"0.5829859",
"0.5799817",
"0.5710223",
"0.5654545... | 0.8109677 | 0 |
List of availability zones for the current project. The listing result is an object with property "items". | def get(self, request):
conn = get_sdk_connection(request)
availability_zone_list = _sdk_object_to_list(
conn.load_balancer.availability_zones()
)
return {'items': availability_zone_list} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_availability_zones(self, context, filters=None, fields=None,\n sorts=None, limit=None, marker=None,\n page_reverse=False):",
"def availability_zones(self) -> Optional[Sequence[str]]:\n return pulumi.get(self, \"availability_zones\")",
"... | [
"0.7386868",
"0.70580536",
"0.7010989",
"0.6928745",
"0.6770369",
"0.6770369",
"0.6770369",
"0.6770369",
"0.6770369",
"0.6770369",
"0.66694915",
"0.6653675",
"0.66517156",
"0.6599054",
"0.6586983",
"0.65651035",
"0.6550308",
"0.6516705",
"0.65091455",
"0.6504418",
"0.6469357"... | 0.7326057 | 1 |
Unfreeze layers Use something like "Optim([p for p in self.parameters() if p.requires_grad])" to be sure. | def unfreeze_layers(model: torch.nn.Module) -> None:
for param in model.parameters():
param.requires_grad = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unfreeze(net):\n for p in net.parameters():\n p.requires_grad_(True)\n return net",
"def unfreeze(self) -> None:\n self._set_requires_grad(True)",
"def __freeze(self):\r\n features_layer = self._model._net\r\n for param in features_layer.parameters():\r\n param.... | [
"0.8058317",
"0.77148205",
"0.75488114",
"0.7465948",
"0.7341107",
"0.73213917",
"0.71995574",
"0.7171278",
"0.7010951",
"0.69333744",
"0.67284983",
"0.66955847",
"0.66885394",
"0.6636516",
"0.65704834",
"0.6559106",
"0.65190375",
"0.6514125",
"0.6377716",
"0.63764316",
"0.63... | 0.7979869 | 1 |
Log all images in a dict as images to TensorBoard. | def log_images(self, image_dict,
iterations, step_in_epoch=None, cur_epoch=None,
save_to_outputs=True, include_iter=False):
if len(image_dict) != 0:
thing1 = f'/{step_in_epoch}' if step_in_epoch is not None else ""
thing2 = f'@Epoch {cur_epoch}' if c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_images(self, step, images):\n\n # Save\n with self.summary_writer.as_default():\n for name, batch in images.items():\n image = batch[0]\n image = tf.expand_dims(image, axis=0)\n tf.summary.image(name, image, step)",
"def write_weights... | [
"0.6842873",
"0.62515694",
"0.62474054",
"0.6194678",
"0.60632837",
"0.59421414",
"0.5922582",
"0.5918516",
"0.5903152",
"0.58775586",
"0.5871887",
"0.58621484",
"0.5861817",
"0.5815416",
"0.5804208",
"0.57724893",
"0.5751607",
"0.57250875",
"0.57229185",
"0.57109416",
"0.570... | 0.7405011 | 0 |
Log all text in a dict to TensorBoard. | def log_text(self, text_dict,
iterations, step_in_epoch=None, cur_epoch=None,
print_to_stdout=True):
if len(text_dict) != 0:
thing1 = f'/{step_in_epoch}' if step_in_epoch is not None else ""
thing2 = f'@Epoch {cur_epoch}' if cur_epoch is not None else ""
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_tensorboard_text(self, key: str, input_dict: Dict[str, Any]) -> None:\n try:\n with tf.Session() as sess:\n s_op = tf.summary.text(\n key,\n tf.convert_to_tensor(\n ([[str(x), str(input_dict[x])] for x in input_... | [
"0.7434491",
"0.67299134",
"0.6394467",
"0.63222766",
"0.61781824",
"0.6059231",
"0.5878002",
"0.5674671",
"0.56471145",
"0.54971224",
"0.5484033",
"0.54648966",
"0.54230785",
"0.54153043",
"0.54076815",
"0.53755504",
"0.5346531",
"0.5332499",
"0.5329605",
"0.5307764",
"0.527... | 0.69078577 | 1 |
Tests the packet `id`. | def test_id():
assert Packet40.id == 40 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_id():\n assert Packet106.id == 106",
"def test_id():\n assert Packet20.id == 20",
"def check_id(self, id):",
"def test_pnc(id):\n if id < int('0x10ffffff', 16): # 285212671\n return 'player'\n elif id < int('0x40ffffff', 16): # 1090519039\n return 'creature'\n elif id < ... | [
"0.78103393",
"0.7715128",
"0.7001969",
"0.6294706",
"0.6101701",
"0.5967647",
"0.5964849",
"0.5934389",
"0.5914396",
"0.59053135",
"0.5801665",
"0.579754",
"0.5779012",
"0.57742375",
"0.5641701",
"0.562879",
"0.5582393",
"0.55690616",
"0.55153644",
"0.55010813",
"0.547853",
... | 0.78331536 | 0 |
Tests the packet `size`. | def test_size():
assert Packet40.size == 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_size():\n assert Packet106.size == 12",
"def test_size():\n assert Packet20.size == 2",
"def checkPacketLength(self):\n return self.packetLength == len(self) - PRIMARY_HEADER_BYTE_SIZE - 1",
"def test_invalid_packet_size(self):\n p = (\n Ether(dst=self.src_if.local_mac, sr... | [
"0.7385397",
"0.73481655",
"0.6485774",
"0.6421407",
"0.6403327",
"0.634776",
"0.6263186",
"0.6178231",
"0.61623096",
"0.6134446",
"0.6119156",
"0.60726506",
"0.59411585",
"0.5907456",
"0.5892667",
"0.58187336",
"0.57345223",
"0.5726993",
"0.57237065",
"0.5696267",
"0.5662857... | 0.7417761 | 0 |
Restore the variable stack. | def pop(self):
self._variables = self._variable_stack.pop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore(self,):\n self.pos, self.dataptr, = self.stack.pop()",
"def pop(self):\n self.restore(self.stack.pop())",
"def restore_context(self):\r\n self.current_context = self.context_stack.pop()",
"def restore(self):\n self.nodes.restore()",
"def restore(self):\n self.... | [
"0.8118927",
"0.69744605",
"0.69486845",
"0.6639864",
"0.6619403",
"0.66180235",
"0.6612719",
"0.65348417",
"0.65342045",
"0.6508564",
"0.6504924",
"0.64735585",
"0.6442041",
"0.64363015",
"0.64261246",
"0.6354677",
"0.6338502",
"0.6303261",
"0.6299454",
"0.62333167",
"0.6191... | 0.7232237 | 1 |
Call a task object. | def calltask(self, name, **vars):
if name in self._tasks:
for entry in self._tasks[name]:
entry.execute(vars)
else:
raise Error("No such task: {0}".format(name)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(self, task, **options):\n pass",
"def __call__(self, *args, **kw):\n return Task(self, **self.__options)(*args, **kw)",
"def run_task(self) -> Task:",
"def execute_task(self, task):\n t = threading.Thread(target=task)\n t.start()",
"def run(self):\n task_func = g... | [
"0.79994476",
"0.73845327",
"0.73509413",
"0.7112236",
"0.7083711",
"0.7071007",
"0.6963635",
"0.6931252",
"0.6852798",
"0.68159956",
"0.6761331",
"0.6748111",
"0.66828847",
"0.6653501",
"0.6650906",
"0.6561055",
"0.65478855",
"0.6540533",
"0.6540533",
"0.6481358",
"0.6450701... | 0.74947923 | 1 |
Call a registered function. | def callfunc(self, name, *args, **kwargs):
if name in self._funcs:
return self._funcs[name](*args, **kwargs)
else:
raise Error("No such function: {0}".format(name)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callFunction(cmdname, far_args, far_kwargs, fn):\n ret = None\n if fn not in registered_functions:\n print(\"%s is not a registered function!\" % fn)\n return None\n try:\n funct = registered_functions[fn]\n ret = funct(*far_args,**far_kwargs)\n except:\n print(\... | [
"0.7237642",
"0.69940555",
"0.69778097",
"0.6803792",
"0.6746035",
"0.6448594",
"0.64403576",
"0.6399366",
"0.6324769",
"0.62205297",
"0.6144951",
"0.6141472",
"0.60906637",
"0.6085542",
"0.6026323",
"0.6018302",
"0.6010114",
"0.6005678",
"0.5979251",
"0.595394",
"0.59400034"... | 0.7133207 | 1 |
Call a filter with a value. | def callfilter(self, name, value):
if name in self._filters:
return self._filters[name](value)
else:
raise Error("No such filter: {0}".format(name)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_filter(\n self,\n name: str,\n value: t.Any,\n args: t.Optional[t.Sequence[t.Any]] = None,\n kwargs: t.Optional[t.Mapping[str, t.Any]] = None,\n context: t.Optional[Context] = None,\n eval_ctx: t.Optional[EvalContext] = None,\n ) -> t.Any:\n retur... | [
"0.76371175",
"0.6945337",
"0.66474724",
"0.6641272",
"0.6295771",
"0.62570554",
"0.6163652",
"0.6126321",
"0.6041286",
"0.6038569",
"0.5961211",
"0.5926597",
"0.5915547",
"0.5905825",
"0.58687717",
"0.5861561",
"0.58000666",
"0.5730729",
"0.5719642",
"0.5706328",
"0.56944907... | 0.8607307 | 0 |
Find the task file. | def find_taskfile(self):
filename = self.cmdline.file
curdir = self.cmdline.dir
if "load" in self.cmdline.verbose:
self.env.errorln("Taskrun search directory: {0}".format(curdir))
self.env.errorln("Taskrun search filename: {0}".format(filename))
self.env.erro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_taskfile(self, refobj):\n tfid = cmds.getAttr(\"%s.taskfile_id\" % refobj)\n try:\n return djadapter.taskfiles.get(pk=tfid)\n except djadapter.models.TaskFile.DoesNotExist:\n raise djadapter.models.TaskFile.DoesNotExist(\"Could not find the taskfile that was set o... | [
"0.6496904",
"0.64604664",
"0.64055175",
"0.62375754",
"0.62346745",
"0.6191733",
"0.61508954",
"0.61214113",
"0.608487",
"0.6081849",
"0.60280293",
"0.60252696",
"0.6012723",
"0.5995425",
"0.5991104",
"0.59663683",
"0.5947834",
"0.59477603",
"0.5941024",
"0.59160525",
"0.591... | 0.820012 | 0 |
Return the tasks and parameters. | def get_tasks_params(self):
params = {}
tasks = []
for cmdparam in self.cmdline.params:
if ":" in cmdparam:
# task:NAME=VALUE:NAME=VALUE:NAME=VALUE
parts = cmdparam.split(":")
taskparams = {}
for taskparam in parts[1:]:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tasks():",
"def get_tasks(self) -> Dict[str, Any]:\n\n ret = {}\n for k, id in self.required_tasks.items():\n ret[k] = self.storage_socket.get_procedures(id=id)[\"data\"][0]\n\n return ret",
"def get_task_info(self):\n\n print()\n employee_name = self.task.get_... | [
"0.74223137",
"0.7187272",
"0.7059916",
"0.6921149",
"0.6918603",
"0.69120604",
"0.6889255",
"0.6680344",
"0.66059226",
"0.6580175",
"0.6580175",
"0.65769786",
"0.65203404",
"0.6516762",
"0.6511607",
"0.64936393",
"0.64494795",
"0.6430884",
"0.63634413",
"0.63324594",
"0.6317... | 0.72699475 | 1 |
Construct an integer interval that includes both ends lb and ub. | def index_interval(lb: int, ub: int, nbits=None, graycode=False) -> List[int]:
if graycode:
assert nbits is not None
else:
assert lb <= ub
window = []
i = lb
while True:
window.append(i)
if i == ub:
break
i = increment_index(i, 1, nbits, graycode)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _bi_range(start, end):\n if start == end:\n return (start,)\n\n elif end < start:\n return reversed(range(end, start + 1))\n\n else:\n return range(start, end + 1)",
"def rangify(v, lb, ub):\n if lb >= ub:\n lb, ub = ub, lb\n return max(min(v, ub), lb)",
"def new_... | [
"0.6615083",
"0.65613925",
"0.6474376",
"0.642171",
"0.6403943",
"0.6369164",
"0.6296812",
"0.6278263",
"0.626915",
"0.6248147",
"0.62247044",
"0.6186229",
"0.61436677",
"0.6137699",
"0.61253625",
"0.6121021",
"0.61116767",
"0.60257053",
"0.60177577",
"0.5968685",
"0.5955275"... | 0.66095185 | 1 |
Increment a bitvector's value +1 or 1. | def increment_bv(bv, increment: int, graycode=False, saturate=False) -> BitVector:
assert increment == 1 or increment == -1
nbits = len(bv)
if graycode:
index = graytobin(bv2int(bv))
index = (index+increment) % 2**nbits
return int2bv(bintogray(index), nbits)
else:
if bv =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment(val):\n return coerce_to_int(val) + 1",
"def INC(self, value):\n result = (value + 1) & 0xff\n self.reg.N = result >> 7\n self.reg.Z = result == 0\n return result",
"def increment(self):\r\n return self.add(1)",
"def update(self, idx, x):\n while idx < l... | [
"0.70842975",
"0.6988396",
"0.69276345",
"0.6912323",
"0.6882834",
"0.66443974",
"0.6637201",
"0.6629569",
"0.660645",
"0.65473056",
"0.65456295",
"0.6478258",
"0.6445333",
"0.64219457",
"0.64066106",
"0.6358836",
"0.63567686",
"0.6297039",
"0.6286662",
"0.62488574",
"0.62181... | 0.7331502 | 0 |
Converts bitvector (list or tuple) with the standard binary encoding into an integer. | def bv2int(bv: BitVector) -> int:
nbits = len(bv)
index = 0
for i in range(nbits):
if bv[i]:
index += 2**(nbits - i - 1)
return index | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bitlist_to_int(bitlist):\n return sum([int(b) for b in bitlist])",
"def bin_to_int(bit_string):\r\n return int(''.join(bit_string), 2)",
"def _convert_to_int(backing: List[int]) -> int:\n return int.from_bytes(backing, byteorder=\"little\", signed=True)",
"def bitstring_to_int(bitstr):\n ... | [
"0.7799725",
"0.7070542",
"0.70149434",
"0.6703559",
"0.6688739",
"0.66736495",
"0.6657458",
"0.6641372",
"0.6465512",
"0.6444076",
"0.640635",
"0.6368258",
"0.63485277",
"0.6318946",
"0.6285462",
"0.62587655",
"0.6253048",
"0.6239362",
"0.6194942",
"0.61726755",
"0.6165641",... | 0.71379066 | 1 |
Convert a window [left, right] inclusive into a list of variable precision bitvectors. | def bvwindow(left: int, right: int, nbits: int) -> List[BitVector]:
assert left >= 0
assert right >= 0
assert right <= 2**nbits - 1
bvs: List[BitVector] = []
# Empty window
if right < left:
return bvs
while(True):
if nbits == 0:
return [(True,), (False,)]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bvwindowgray(left: int, right: int, nbits: int) -> List[BitVector]:\n bvs: List[BitVector] = []\n\n assert right <= 2**nbits - 1\n assert left <= 2**nbits - 1\n\n # Split window into [0,right] and [left, 2**nbits-1]\n if left > right:\n return bvwindowgray(left, 2**nbits-1, nbits) + bvwin... | [
"0.69015485",
"0.5978056",
"0.5879691",
"0.5801877",
"0.57723594",
"0.5686582",
"0.5606028",
"0.54982144",
"0.54739505",
"0.5461037",
"0.5431221",
"0.53940713",
"0.53511935",
"0.531862",
"0.5312564",
"0.53044176",
"0.5283519",
"0.5200857",
"0.51954573",
"0.5177205",
"0.517452... | 0.7558267 | 0 |
Convert a window [left, right] inclusive into a list of variable precision bitvectors. | def bvwindowgray(left: int, right: int, nbits: int) -> List[BitVector]:
bvs: List[BitVector] = []
assert right <= 2**nbits - 1
assert left <= 2**nbits - 1
# Split window into [0,right] and [left, 2**nbits-1]
if left > right:
return bvwindowgray(left, 2**nbits-1, nbits) + bvwindowgray(0, ri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bvwindow(left: int, right: int, nbits: int) -> List[BitVector]:\n assert left >= 0\n assert right >= 0\n assert right <= 2**nbits - 1\n\n bvs: List[BitVector] = []\n # Empty window\n if right < left:\n return bvs\n\n while(True):\n\n if nbits == 0:\n return [(True,... | [
"0.7557525",
"0.59776354",
"0.58777934",
"0.58019704",
"0.57729864",
"0.56873184",
"0.5606834",
"0.5500135",
"0.54751575",
"0.5459628",
"0.54305446",
"0.53928643",
"0.5351535",
"0.53192264",
"0.5311145",
"0.53046113",
"0.5281819",
"0.5200208",
"0.5194822",
"0.51761657",
"0.51... | 0.6901498 | 1 |
Receive the data from the HTML form, then save it to a disk file, then respond with a nice friendly message to the awaiting browser. | def save_data():
# python-name = html-name:
the_first = request.form["first"]
the_last = request.form["last"]
the_dob = request.form["dob"]
# So... now, use the python-names in your code:
with open("suckers.txt", "a") as sf:
print(f"{the_first}, {the_last}, {the_dob}", file=sf)
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_POST(self):\n self.send_response(200)\n self.send_header('Content-type','text/html')\n self.send_header('Access-Control-Allow-Origin','*')\n self.end_headers()\n # Send the html message\n self.wfile.write(\"Aivis Panovs, 161REB125\")\n return",
"def do_POST... | [
"0.623124",
"0.6209262",
"0.61119497",
"0.60251135",
"0.5977981",
"0.591255",
"0.5905254",
"0.5802934",
"0.5698746",
"0.569686",
"0.56939495",
"0.5654349",
"0.5610539",
"0.5597084",
"0.5577267",
"0.5563417",
"0.5550518",
"0.5540938",
"0.5534455",
"0.55296224",
"0.55229175",
... | 0.6650055 | 0 |
Devuelve la lista de socios que participan en el torneo | def get_socios(self):
return self.__socios | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comitentes(self):\n return self.expedientepersona_set.filter(comitente=True)",
"def getCubes():",
"def todos(self):\n socios = session.query(Socio).all()\n return socios",
"def get_tournament_list():\n database = TinyDB('db.json')\n tournament_list = database.table('tournaments... | [
"0.58589816",
"0.57218426",
"0.5660919",
"0.56461746",
"0.5478608",
"0.5461285",
"0.5444874",
"0.5443482",
"0.543834",
"0.5438139",
"0.5418964",
"0.539169",
"0.5383644",
"0.5374273",
"0.53655237",
"0.53620005",
"0.5355373",
"0.53489214",
"0.53374285",
"0.52937156",
"0.5281925... | 0.5800939 | 1 |
Devuelve los resultados del torneo | def get_resultados(self):
return self.__resultados | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getResults():",
"def results(self):\n pass",
"def results(self):\r\n pass",
"def _make_result_list(self,res):\n res_list = []\n for r in res:\n res_list.append(r)\n\n return res_list",
"def generarConsultasConexion(self):\n for parRec... | [
"0.70406973",
"0.6500303",
"0.64375544",
"0.6325507",
"0.6182129",
"0.61422825",
"0.61179465",
"0.610537",
"0.6095539",
"0.60648805",
"0.60397285",
"0.5990536",
"0.59894574",
"0.598081",
"0.59751135",
"0.595",
"0.5937014",
"0.5937014",
"0.5925529",
"0.5901702",
"0.5901702",
... | 0.70208097 | 1 |
Establece un resultado en un partido | def set_resultado(self, partido, dni):
self.__resultados[partido] = dni | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cargarProductosSinObra(self):\n\n self.limpiarTabla(self.tableProductos)\n\n ##Cnsulta para obtener todos los productos del sistema, con su correspondiente\n ##codigo de barra, monodroga, descuento, importe\n query=self.sesion.query(ProductoModel.codigo_barra,ProductoModel.id_medica... | [
"0.6009778",
"0.59987825",
"0.5782047",
"0.5738906",
"0.5730106",
"0.5718839",
"0.5662571",
"0.5583611",
"0.55691737",
"0.5564165",
"0.5527081",
"0.5526736",
"0.5526736",
"0.55092806",
"0.54842013",
"0.5460418",
"0.5451924",
"0.5433622",
"0.5415844",
"0.54150385",
"0.5374498"... | 0.6492181 | 0 |
Updates the item (requisition or aliquot) to indicate that it is packed. | def _update_item(self, item, user):
item.user_modified = user
try:
item.panel = item.panel
item.item_priority = item.priority
except AttributeError:
pass
item.is_packed = True
item.save()
return item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_starred(self, item):\n self.update_item(item)",
"def put(self, item):\n if self.closed:\n print \"Knapsack closed!\"\n else:\n Backpack.put(self, item)",
"def updateItem(self, object):\n pass",
"def carry(self, item):\r\n\r\n # If you can add ... | [
"0.612828",
"0.6083184",
"0.56750643",
"0.56587964",
"0.5611489",
"0.5564478",
"0.5563317",
"0.5547801",
"0.554539",
"0.5531961",
"0.5513932",
"0.5505557",
"0.5505557",
"0.5501193",
"0.5470519",
"0.541952",
"0.540039",
"0.5392359",
"0.5391287",
"0.53460723",
"0.5334588",
"0... | 0.6141786 | 0 |
Creates or updates the packing list item for this "item". | def _create_or_update_packinglistitem(self, item_identifier, item, user, optional_attrs={}):
try:
packing_list_item = self.packing_list.packing_list_item_model.objects.get(
packing_list=self.packing_list,
item_reference=item_identifier)
except self.packing_lis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\n # convert the text list of item identifiers into a list of parsed identifiers\n item_identifiers = filter(None, self.packing_list.list_items.replace('\\r', '').split('\\n'))\n # loop through list of parsed identifiers\n for item_identifier in item_identifiers:\n ... | [
"0.69560045",
"0.637883",
"0.6123722",
"0.60804576",
"0.58273536",
"0.5745075",
"0.56938714",
"0.56452906",
"0.56450784",
"0.5631005",
"0.55990785",
"0.5588541",
"0.5587934",
"0.55638516",
"0.5562925",
"0.5557327",
"0.55541205",
"0.5547544",
"0.5545593",
"0.5533263",
"0.55158... | 0.7180476 | 0 |
Return the default Inline code example directory path | def get_example():
ex_dir = os.path.join(app.config['TEMPLATE_DIR'], "inline_code")
app.logger.debug("Example directory is {}".format(ex_dir))
return ex_dir | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_notebooks():\n return os.path.abspath(\n os.path.join(os.path.dirname(__file__), os.path.pardir, \"examples\")\n )",
"def get_example_filepath(filename):\n # File is relative to calling file?\n callingfn = os.path.abspath(inspect.stack()[1].filename)\n return os.path.join(\n ... | [
"0.6818397",
"0.6614962",
"0.6478994",
"0.64300853",
"0.63773614",
"0.6267805",
"0.6079151",
"0.6002472",
"0.5951702",
"0.5929952",
"0.5910089",
"0.590533",
"0.5868618",
"0.5858667",
"0.5810373",
"0.57956874",
"0.57696295",
"0.57598346",
"0.57552767",
"0.5723426",
"0.572342",... | 0.8290392 | 0 |
gets all dcds in a root directory | def find_dcds(src):
dcd_paths = []
for root, dirs, files in os.walk(src):
for filename in files:
if filename.endswith(".dcd"):
dcd_paths.append(os.path.join(root, filename))
return dcd_paths | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all_dicom_files(root_path):\n dicoms = set()\n\n try:\n for fpath in get_all_files(root_path):\n if is_dicom_file(fpath):\n dicoms.add(fpath)\n except IOError as ioe:\n raise IOError('Error reading file {0}.'.format(fpath)) from ioe\n\n return dicoms",
... | [
"0.6467605",
"0.6281241",
"0.6223496",
"0.6196441",
"0.6150646",
"0.6143475",
"0.60883945",
"0.602333",
"0.6016977",
"0.5946605",
"0.59250385",
"0.58954626",
"0.58720845",
"0.5869424",
"0.58076346",
"0.5761363",
"0.57583165",
"0.57532775",
"0.57412195",
"0.57371",
"0.5716051"... | 0.69657594 | 0 |
Creates a list of Document tuples from all the lines of a file. | def create_document_list(lines_of_file):
document = []
documents = []
for line in lines_of_file:
document.append(line.rstrip())
# Either a newline of the last line
if line == '\n' or line == lines_of_file[-1]:
documents.append(create_document(document))
doc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_file(filename):\n\n all_documents = []\n document = []\n with tf.gfile.GFile(filename, \"r\") as reader:\n for line in reader:\n line = line.strip()\n line = tokenization.convert_to_unicode(line)\n line = line.replace(u\"\\u2018\", \"'\").replace(u\"\\u2019\", \"'\")\n sents = sp... | [
"0.67407095",
"0.6698694",
"0.6641464",
"0.6508077",
"0.6484047",
"0.6472933",
"0.6400455",
"0.63404316",
"0.6309761",
"0.62904716",
"0.6286486",
"0.62785584",
"0.6264917",
"0.6254483",
"0.6235207",
"0.6192921",
"0.6180794",
"0.6166221",
"0.6134856",
"0.6134638",
"0.613246",
... | 0.765414 | 0 |
Annotates and prints the sentences in CQP format | def print_cwb(document, tag='<s>'):
doc = NLP(document)
for sentence in doc.sents:
print(tag)
sent = NLP(sentence.text)
for token in sent:
print('{word}\t{pos}\t{lemma}'.format(
word=token.text,
pos=token.pos_,
lemma=token.lem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(args):\n corpus = read_corpus(args, verbose=True)\n for k in sorted(corpus, key=educe.stac.id_to_path):\n doc = corpus[k]\n print(\"========== %s ============\" % k)\n print()\n if args.edges:\n dialogues = sorted_first_widest(filter(is_dialogue, doc.units))\n ... | [
"0.6000715",
"0.56178945",
"0.55667776",
"0.5481114",
"0.54786646",
"0.54709184",
"0.54087317",
"0.5388897",
"0.53651917",
"0.5351183",
"0.53268975",
"0.53230166",
"0.53183377",
"0.5314303",
"0.53096277",
"0.5309273",
"0.5307908",
"0.5294618",
"0.52743316",
"0.5270597",
"0.52... | 0.5949153 | 1 |
Prints end of document. Just for symmetry. | def print_footer():
print('</text>') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_print(outfile: TextIO) -> None:\n outfile.write(\" </body>\\n\")\n outfile.write(\"</html>\\n\")",
"def doc_end(fdoc):\n fdoc.write('\\\\end{document}\\n')\n fdoc.close()",
"def endDocument(self):\n pass",
"def endDocument(self):\n pass",
"def latex_footer():\n print(\... | [
"0.73971003",
"0.6935334",
"0.6862355",
"0.6862355",
"0.6664187",
"0.6625865",
"0.6573202",
"0.647194",
"0.6466574",
"0.6457852",
"0.6382236",
"0.6350358",
"0.6328606",
"0.63048065",
"0.6239536",
"0.62013793",
"0.6198921",
"0.6173183",
"0.61691064",
"0.6136601",
"0.6112222",
... | 0.6966425 | 1 |
Return True if a windows system | def win():
if platform.system() in WINDOWS:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_windows():\n if os.name == \"nt\":\n return True\n return False",
"def os_is_windows():\n return platform.system() == \"Windows\"",
"def is_windows():\n return os.name == \"nt\"",
"def _on_windows() -> bool:\n return os.name == \"nt\"",
"def is_windows() -> bool:\n retur... | [
"0.88025236",
"0.8778063",
"0.8678572",
"0.8537766",
"0.85206264",
"0.84892493",
"0.84858257",
"0.8479225",
"0.8096643",
"0.7979381",
"0.7928705",
"0.7763643",
"0.7125087",
"0.7080894",
"0.6978872",
"0.6966665",
"0.69211066",
"0.68185973",
"0.6789719",
"0.6747324",
"0.6657324... | 0.88894486 | 0 |
When was the position of the current playing media valid. | def media_position_updated_at(self) -> datetime | None:
if self._device.movie.play_status in KALEIDESCAPE_PLAYING_STATES:
return utcnow()
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def media_position_updated_at(self):\n if not self._playing_liveinput and self._state == STATE_PLAYING:\n return self._position_updated_at\n else:\n return None",
"def media_position_updated_at(self):\n return self._table.active_track_remaining_time_as_of",
"def media... | [
"0.6990031",
"0.6919123",
"0.6813298",
"0.6809467",
"0.6739905",
"0.6636911",
"0.65889794",
"0.6545176",
"0.63453555",
"0.6325207",
"0.62560403",
"0.6117559",
"0.604486",
"0.6029453",
"0.5994394",
"0.59789467",
"0.5937526",
"0.586864",
"0.57936734",
"0.57936233",
"0.57310325"... | 0.70499295 | 0 |
Dump one symbol table showing, for each symbol, the result of the informational methods is_global() etc., and when the symbol table is for a function scope, the (nonempty) tuples of parameters, locals, frees, and globals. | def show_symbol_table(st):
print(st)
# Dump the name lists get_*()
if isinstance(st, symtable.Function):
for nlist in _NAME_LISTS:
names = getattr(st, "get_"+nlist)()
if names:
print(' {} : {!r}'.format(nlist, names))
# Dump the properties as short names ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSymbolTable(self) -> ghidra.app.util.bin.format.pe.debug.DebugCodeViewSymbolTable:\n ...",
"def build_gdb_symbol_table():\n\n tab = Symtab()\n n = gdb.parse_and_eval (\"symtab->nodes\")\n while (long(n)):\n if symtab_node_is_function (n):\n current_symbol = GdbFunction(ta... | [
"0.66534007",
"0.647754",
"0.63893914",
"0.627166",
"0.6266483",
"0.6264775",
"0.6150325",
"0.61372966",
"0.58902705",
"0.5874507",
"0.5810592",
"0.5732486",
"0.56901515",
"0.5665829",
"0.566502",
"0.56435275",
"0.56126845",
"0.55317366",
"0.5471905",
"0.5426554",
"0.54175854... | 0.696746 | 0 |
Gather all the symbol tables of a module by a depthfirst exploration of its symbol table tree. | def list_symbol_tables(mst):
stlist = []
def append_st(st):
#print(st)
stlist.append(st)
for s in st.get_symbols():
for ns in s.get_namespaces():
append_st(ns)
if not isinstance(mst, symtable.SymbolTable):
# Assume it is text of a program to compil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_symbol_table(root):\n\n set_depth(root, 0)\n #Initialize the stack, with the AST root\n stack = Stack(root)\n\n #the symbol table maps the name to the scope.\n #Any node can belong to multiple scopes, therefore this\n #is a list of scope\n symbol_table = STable()\n \n #this re... | [
"0.71760356",
"0.6239357",
"0.61453974",
"0.5924159",
"0.5663551",
"0.5595732",
"0.55535376",
"0.5506536",
"0.54608417",
"0.5396278",
"0.53505415",
"0.53426313",
"0.53191054",
"0.5296071",
"0.5238716",
"0.5165061",
"0.51395684",
"0.5098256",
"0.5091754",
"0.50009084",
"0.5000... | 0.6286266 | 1 |
Apply a function to all values in work_list in parallel. | def ApplyInParallel(function, work_list, on_failure=None):
if not work_list:
return
try:
# Note that this is speculatively halved as an attempt to fix
# crbug.com/953365.
cpu_count = multiprocessing.cpu_count() // 2
if sys.platform == 'win32':
# TODO(crbug.com/1190269) - we can't use more... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_same_job(self, func, input_list):\n task_submitted = []\n for data in input_list:\n task_submitted.append(self.executor.submit(func, *data))\n\n return [t.result() for t in task_submitted]",
"def split_calculation_to_threads(iterable, func, args):\n args_list = []\n b... | [
"0.72197735",
"0.6717606",
"0.66602266",
"0.66602266",
"0.66602266",
"0.66602266",
"0.66602266",
"0.6630425",
"0.66126955",
"0.6591178",
"0.6580101",
"0.65612894",
"0.6519424",
"0.6383438",
"0.6361531",
"0.63088477",
"0.6260933",
"0.624545",
"0.62317514",
"0.62278426",
"0.622... | 0.7662204 | 0 |
Split a test path into test suite name and test case name. Telemetry and Gtest have slightly different test path formats. Telemetry uses '{benchmark_name}/{story_name}', e.g. | def SplitTestPath(test_result, test_path_format):
if test_path_format == TELEMETRY_TEST_PATH_FORMAT:
separator = '/'
elif test_path_format == GTEST_TEST_PATH_FORMAT:
separator = '.'
else:
raise ValueError('Unknown test path format: %s' % test_path_format)
test_path = test_result['testPath']
if se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_test_name(base_path):\n name = p.basename(base_path)\n if name == \"test.py\":\n name = \"\"\n elif name.startswith(\"test_\") and name.endswith(\".py\"):\n name = name[len(\"test_\") : (len(name) - len(\".py\"))]\n return name",
"def split(test_name):\n recipe, simple_test... | [
"0.68393505",
"0.6673254",
"0.6028965",
"0.5967455",
"0.59407866",
"0.58373785",
"0.5818909",
"0.58015156",
"0.5758415",
"0.5726683",
"0.5719242",
"0.5698514",
"0.5678177",
"0.5632192",
"0.56196624",
"0.55810404",
"0.55484384",
"0.553336",
"0.551327",
"0.5507131",
"0.5493983"... | 0.7001524 | 0 |
Update fields of a test result in a case of processing failure. | def SetUnexpectedFailure(test_result):
test_result['status'] = 'FAIL'
test_result['expected'] = False
logging.error('Processing failed for test %s', test_result['testPath']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failure(self, result):\r\n raise NotImplementedError",
"def set_test_failed(self):\n self.set_result(Status.FAILED)",
"def addFailure(self, result):\n result.addFailure(self, (Exception, Exception(), None))\n # Since TAP will not provide assertion data, clean up the assertion\n ... | [
"0.66159004",
"0.65798354",
"0.6501041",
"0.6283665",
"0.61487025",
"0.61080235",
"0.6103907",
"0.60715514",
"0.604803",
"0.602537",
"0.6021293",
"0.60169196",
"0.6007215",
"0.59884024",
"0.5984656",
"0.59792066",
"0.5974906",
"0.59517866",
"0.5938297",
"0.5911561",
"0.590496... | 0.72470486 | 0 |
Extract features from a document and returns a dictionary of these features keyed by their abbreviation and document label. | def extract_features(self, doc):
features = dict()
bow = self.vectorize_doc_simple(doc)
charcount = self.char_count(doc)
wordcount = self.word_count(doc)
sentencecount = self.sentence_count(doc)
paragraphcount = self.paragraph_count(doc)
# extract characters f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_features(document):\n document_words = set(document)\n features = {}\n global word_features\t\n for word in word_features:\n features['contains(%s)' % word] = (word in document_words)\n return features",
"def extract(self, document):\n f_num = len(self.feature_list)\n ... | [
"0.7853346",
"0.6725468",
"0.65909344",
"0.6505441",
"0.64868176",
"0.647813",
"0.64510643",
"0.6434799",
"0.6289131",
"0.62880605",
"0.624365",
"0.6175479",
"0.61572194",
"0.6059686",
"0.60497266",
"0.60189444",
"0.60106367",
"0.59182346",
"0.58369625",
"0.5827985",
"0.57658... | 0.7537927 | 1 |
Returns the number of characters in a document. | def char_count(self, doc):
return len(doc) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wordCount(document):\n return float(len(document.split(None)))",
"def document_count(self):\n raise NotImplementedError",
"def n_chars(doc_or_tokens: types.DocOrTokens) -> int:\n # docs are hashable, so we can leverage the lru cache as-is\n if isinstance(doc_or_tokens, Doc):\n ncpw = n... | [
"0.75257236",
"0.6937436",
"0.6925974",
"0.6911785",
"0.690693",
"0.68599904",
"0.684804",
"0.683036",
"0.68129593",
"0.67984515",
"0.6772167",
"0.6742232",
"0.6719053",
"0.6689916",
"0.6672709",
"0.6668264",
"0.6640832",
"0.6592402",
"0.6561841",
"0.6555701",
"0.65335816",
... | 0.8615984 | 0 |
Returns the number of words in a document as defined by tokenize_doc_simple. | def word_count(self, doc):
return len(self.tokenize_doc_simple(doc)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wordCount(document):\n return float(len(document.split(None)))",
"def count_word(doc):\n count = count = 0\n for w in document.split(\" \"):\n count = count + 1\n return count",
"def n_words(doc_or_tokens: types.DocOrTokens) -> int:\n words = utils.get_words(doc_or_tokens)\n ... | [
"0.8413657",
"0.820246",
"0.81366116",
"0.7983112",
"0.7650385",
"0.7589769",
"0.72936594",
"0.72887063",
"0.7262047",
"0.7251532",
"0.72070163",
"0.7186378",
"0.7142346",
"0.70556736",
"0.6989334",
"0.6900884",
"0.68984294",
"0.6864594",
"0.6833796",
"0.6822127",
"0.67934525... | 0.87191725 | 0 |
Returns the number of sentences in a document. | def sentence_count(self, doc):
return len(sent_tokenize(doc)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wordCount(document):\n return float(len(document.split(None)))",
"def n_sents(doc: Doc) -> int:\n if not doc.has_annotation(\"SENT_START\"):\n LOGGER.warning(\n \"`doc` has not been segmented into sentences; applying spaCy's rule-based, \"\n \"`Sentencizer` pipeline component... | [
"0.78057086",
"0.77854717",
"0.7744078",
"0.7731899",
"0.768384",
"0.75315386",
"0.7376466",
"0.72666544",
"0.71705437",
"0.69727427",
"0.6744118",
"0.67347836",
"0.67204547",
"0.67012525",
"0.6697781",
"0.66801274",
"0.6676519",
"0.6667536",
"0.6627134",
"0.6607277",
"0.6591... | 0.8264526 | 0 |
Returns the number of paragraphs in a document. | def paragraph_count(self, doc):
paragraphs = doc.split("\n\n")
# remove the empty string
return len([paragraph for paragraph in paragraphs if paragraph]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paragraphs(self, path, filemoving, parser):\n root = parser.parsing_xml(path, filemoving)\n root_tag = root.tag[0:(root.tag.find('}')+1)]\n number_of_paragraphs = len(list(root.iter(root_tag + 'p')))\n return number_of_paragraphs",
"def get_number_of_paragraph(self):\n file... | [
"0.75929385",
"0.7505203",
"0.7096997",
"0.7019801",
"0.6537894",
"0.64200836",
"0.64090353",
"0.64065015",
"0.6323344",
"0.62945384",
"0.6270998",
"0.62400544",
"0.6229263",
"0.6203288",
"0.61751676",
"0.61185807",
"0.609336",
"0.60698295",
"0.6019978",
"0.60193443",
"0.6005... | 0.8642088 | 0 |
Returns the number of syllables in a word. | def num_of_syllables(self, word):
if word.lower() in self.cmu_dict:
return len([phoneme for phoneme in self.cmu_dict[word.lower()][0]
if phoneme[-1].isdigit()])
# If word is unknown, assume 1 syllable/3 letters (average for English)
else:
return l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_syllables(self, word):\n\n return 1",
"def count_syllables(words):\n\n\n count = 0\n\n for word in words:\n word_count = count_syllables_in_word(word)\n count = count + word_count\n return count",
"def num_syllables(self, word):\n # TODO: provide an implementation!\... | [
"0.8795304",
"0.8443985",
"0.83697945",
"0.81841797",
"0.8142234",
"0.80679905",
"0.8024609",
"0.7985044",
"0.79726994",
"0.7822673",
"0.7780589",
"0.77729857",
"0.77016985",
"0.75951684",
"0.755582",
"0.7286977",
"0.71906304",
"0.71053594",
"0.7016183",
"0.698643",
"0.691093... | 0.87104744 | 1 |
Finds the maximum value of y in a given range of x | def max_in_range(self, x, y, low, high):
data = np.vstack((x,y))
y_values = data[1][np.logical_and(low < data[0], data[0] < high)]
x_values = data[0][np.logical_and(low < data[0], data[0] < high)]
index_max_y = y_values.argmax()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maxx(x, y):\n if x >= y:\n return x\n else:\n return y",
"def maximum(x, y):\r\n # see decorator for function body\r",
"def d_max(x, y):\n axis = np.argmax(x.shape)\n return np.max(np.array([x, y]), axis=axis)",
"def getMaxima(x, y):\n# mx_x = (np.abs(np.min(x)) + np.max(x... | [
"0.81750053",
"0.7659551",
"0.7405532",
"0.73701066",
"0.71251947",
"0.70628524",
"0.7052693",
"0.7033928",
"0.69642556",
"0.6944658",
"0.690641",
"0.6903287",
"0.68960166",
"0.6878574",
"0.6813649",
"0.6787498",
"0.6747394",
"0.6733495",
"0.6732106",
"0.6720992",
"0.67063314... | 0.7968292 | 1 |
Returns a list of new 2theta values given a list of d_values and a wavelength via Braggs law | def bragg_law(self, d_list, wavelength):
new_twotheta = []
for d in d_list:
new_twotheta.append(2*math.degrees(np.arcsin(wavelength/(2*d))))
return new_twotheta | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_phase_law(N, d, wavelength, phi):\r\n phase_law = []\r\n for n in range(N):\r\n phase_law.append(-2 * np.pi * n * d / wavelength * np.sin(phi))\r\n return phase_law",
"def getVals(cdli):\n \n \n swh = calcOutProd(np.reshape(cdli.datain_h, (cdli.datain_h.shape[0],1)), np.reshape(c... | [
"0.5911583",
"0.55874676",
"0.5475578",
"0.5463497",
"0.53700536",
"0.53584486",
"0.5323669",
"0.5290384",
"0.52637976",
"0.52502567",
"0.521147",
"0.5211158",
"0.5162651",
"0.5139339",
"0.5113516",
"0.50975794",
"0.5091019",
"0.5085691",
"0.5038993",
"0.5032553",
"0.50317675... | 0.7509082 | 0 |
Trigger a new analysis batch given a wellformatted shapefile Upload file to the 'file' key in a multipart form. Each polygon/multipolygon feature in the shapefile will have a neighborhood created for it if it doesn't exist, and the job for each neighborhood will immediately be submitted. Each feature in the shapefile s... | def create(self, request, *args, **kwargs):
file_obj = request.data['file']
max_trip_distance = request.data.get('max_trip_distance')
client = boto3.client('s3', config=BotocoreClientConfig(signature_version='s3v4'))
organization = request.user.organization
file_name = '{}.zip'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self, request, *args, **kwargs):\n form_class = self.get_form_class()\n form = self.get_form(form_class)\n gw_location_file = request.FILES.get('gw_location_file')\n gw_level_file = request.FILES.get('gw_level_file')\n\n if form.is_valid():\n if gw_location_fi... | [
"0.53217494",
"0.5287444",
"0.52646697",
"0.5090431",
"0.49605402",
"0.49185672",
"0.49150816",
"0.48853952",
"0.48199537",
"0.48070318",
"0.47955486",
"0.4781198",
"0.4763215",
"0.47575787",
"0.47164455",
"0.47102332",
"0.4707916",
"0.47077137",
"0.46862623",
"0.46841776",
"... | 0.5521604 | 0 |
return every valid neighbors of a current_node in the maze | def neighbors(current_node, maze):
UP, DOWN, LEFT, RIGHT = -1, 1, -1, 1
neighbors = []
pos = [(0, UP), (0, DOWN), (LEFT, 0), (RIGHT, 0)]
diag = [(LEFT, UP), (RIGHT, DOWN), (LEFT, DOWN), (RIGHT, UP)]
if not args.disable_diagonal:
pos += diag
for new_position in pos:
node_position ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_neighbors(current_row, current_col, grid_size):\n neighbors = []\n for row_offset, col_offset in [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1),\n (1, -1), (1, 0), (1, 1)]:\n new_row = current_row + row_offset\n new_col = current_col + col_offset\n ... | [
"0.7035998",
"0.6925164",
"0.6904916",
"0.6853418",
"0.68220633",
"0.6815321",
"0.68057096",
"0.67877156",
"0.67551005",
"0.6739377",
"0.67376566",
"0.6728888",
"0.66979206",
"0.66303045",
"0.6626632",
"0.6601675",
"0.6586584",
"0.654938",
"0.6547735",
"0.6547735",
"0.6544422... | 0.81023574 | 0 |
Assert that array proxies return memory maps as expected | def check_mmap(hdr, offset, proxy_class,
has_scaling=False,
unscaled_is_view=True):
shape = hdr.get_data_shape()
arr = np.arange(np.prod(shape), dtype=hdr.get_data_dtype()).reshape(shape)
fname = 'test.bin'
# Whether unscaled array memory backed by memory map (regardless of... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_memmap():\n\n asflt = lambda x: as_float_array(x, copy=False)\n\n with NamedTemporaryFile(prefix='sklearn-test') as tmp:\n M = np.memmap(tmp, shape=100, dtype=np.float32)\n M[:] = 0\n\n for f in (array2d, np.asarray, asflt, safe_asarray):\n X = f(M)\n X[:] ... | [
"0.61014163",
"0.6063968",
"0.5974768",
"0.5952109",
"0.5929823",
"0.5922987",
"0.58732295",
"0.5863351",
"0.58366203",
"0.58331126",
"0.5743954",
"0.5739532",
"0.5704142",
"0.5667479",
"0.5648909",
"0.5646724",
"0.564385",
"0.56330293",
"0.56127864",
"0.56041855",
"0.5600273... | 0.61041445 | 0 |
Mean of bins This function takes two corresponding 2D arrays x and y, and calculates mean of y for specific range of x | def mean_relationship_twoD(x, y, bins_values):
sort_ind_x = np.argsort(x)
x = x[sort_ind_x]
y = y[:, sort_ind_x]
hist, bin_edges = np.histogram(x, bins=bins_values)
array_end = np.cumsum(hist)
array_start = np.cumsum(hist) - hist
y_x = np.zeros((len(y), len(array_start)))
for i i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binnedAverage(x, y, bins=20):\n xbins, step = np.linspace(np.min(x), np.max(x), num=bins, retstep=True)\n xbins = (xbins + step/2)[:-1]\n emptyBins = []\n ymeans = []\n for xbi, xb in enumerate(xbins):\n ytotal = 0\n ycount = 0\n for y_i, y_ in enumerate(y):\n if ... | [
"0.7400173",
"0.73563105",
"0.72301424",
"0.6754396",
"0.6561397",
"0.62552804",
"0.62478745",
"0.6227985",
"0.6172358",
"0.6170711",
"0.6138506",
"0.6102812",
"0.6051796",
"0.6045405",
"0.59922403",
"0.597935",
"0.59535205",
"0.5918458",
"0.5881802",
"0.58234376",
"0.5800687... | 0.7733718 | 0 |
check that configuration was successfully read | def test_successful_read(self):
self.assertTrue(self._configuration_ is not None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_config(self):",
"def loadSuccessful(self):\r\n\r\n return (self.config != None)",
"def check_config(cfg):",
"def check_config(config):\n pass",
"def read(self):\n return_code = W.config_read(self._ptr)\n if return_code == W.WEECHAT_CONFIG_READ_OK:\n return ... | [
"0.7841762",
"0.7464513",
"0.7274292",
"0.72680944",
"0.7267917",
"0.7208509",
"0.71730393",
"0.7005125",
"0.69394284",
"0.69394284",
"0.689093",
"0.6861136",
"0.68522793",
"0.68479437",
"0.680019",
"0.67950684",
"0.6774416",
"0.67588484",
"0.67401695",
"0.6729598",
"0.672494... | 0.7949921 | 0 |
check resource value is as expected | def test_resource_value(self):
self.assertTrue(self._configuration_.resources()["RemoveWordTaskRepeat"] == False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test(self, resource):\n return resource.meta.fields[self.name].present(resource)",
"def test_is_valid_resource():\n mock_name = \"rg-001\"\n output = sh.is_valid_resource(mock_name)\n assert output is True",
"def check_value(self, value):",
"def test_check_resource(self):\n s1 = Sy... | [
"0.69737214",
"0.6735116",
"0.6578639",
"0.6456517",
"0.6301914",
"0.6208396",
"0.6098021",
"0.6084837",
"0.60238314",
"0.6014339",
"0.5989801",
"0.5965249",
"0.5954599",
"0.5902951",
"0.58872235",
"0.586236",
"0.58403456",
"0.5814619",
"0.5813411",
"0.5809546",
"0.578816",
... | 0.7122248 | 0 |
check specified component has correct class and module name | def test_component_class_and_module(self):
self.assertTrue(self._configuration_["AddWordDefinitionTask"].class_name() == "AddWordDefinitionTask" and
self._configuration_["AddWordDefinitionTask"].module_name() == "TestPlugins") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isClassName(module, name):\n # search in classes\n if name in module.classes or name in module.structs:\n return True\n # check if name consistent\n res = dotre.split(name)\n if len(res) > 1:\n moduleName = res[0]\n className = res[1]\n # search in modules\n if moduleName in module.modules:... | [
"0.6484528",
"0.64189386",
"0.6209598",
"0.61298054",
"0.6046658",
"0.6008417",
"0.5990348",
"0.5964718",
"0.58850896",
"0.5874257",
"0.5827612",
"0.5805829",
"0.5802875",
"0.5790136",
"0.5754115",
"0.57177526",
"0.5713081",
"0.57058185",
"0.57042754",
"0.5684537",
"0.5661433... | 0.70710343 | 0 |
check that specific component specification has correct lifetime declaration | def test_component_specification_lifetime_declaration(self):
self.assertTrue(self._configuration_["ListWordDefinitionsTask"].lifetime() == "singleton") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_component_specification_lifetime_non_declaration(self):\r\n\t\tself.assertTrue(self._configuration_[\"RemoveWordDefinitionTask\"].lifetime() == \"\")",
"def _check_validity(self):\n pass",
"def needsResolution (self):\n return self.__unresolvedComponents is not None",
"def validate(sel... | [
"0.69758385",
"0.5321172",
"0.5216765",
"0.51183474",
"0.5083323",
"0.5078964",
"0.5065865",
"0.5039631",
"0.50140995",
"0.4987057",
"0.4973244",
"0.4964374",
"0.49469846",
"0.49224192",
"0.49184662",
"0.49132386",
"0.49099228",
"0.49026817",
"0.49012953",
"0.48861352",
"0.48... | 0.7212516 | 0 |
check that specific component specification has correct lifetime nondeclaration | def test_component_specification_lifetime_non_declaration(self):
self.assertTrue(self._configuration_["RemoveWordDefinitionTask"].lifetime() == "") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_component_specification_lifetime_declaration(self):\r\n\t\tself.assertTrue(self._configuration_[\"ListWordDefinitionsTask\"].lifetime() == \"singleton\")",
"def test_get_component_with_invalid_name():\n\n with pytest.raises(ComponentAttributeError):\n application_services.get_component('missin... | [
"0.7102292",
"0.5642984",
"0.5629605",
"0.56190115",
"0.54798615",
"0.5447566",
"0.5431498",
"0.53877485",
"0.5380172",
"0.53358746",
"0.53217614",
"0.5278221",
"0.52557147",
"0.52266574",
"0.5219754",
"0.52135813",
"0.5204345",
"0.5197856",
"0.5118836",
"0.5109223",
"0.50938... | 0.73026043 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.