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 |
|---|---|---|---|---|---|---|
This defines the uniqueness of the individual An individual can be identified by the combination of its genes, just as in nature. For example, the string composed of the individual variable vectors. But this would be expensive and complicated to store in a database The hash compresses this information to an integer val... | def __hash__(self):
index_list = [allele.index for allele in self.genes]
return hash(tuple(index_list)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __hash__(self):\n return hash(('genes', tuple(self.genes), self.environment))",
"def __hash__(self):\n return hash(self.get_canonical_identifier())",
"def __hash__(self):\n obj = (self.make, self.model, self.year, self.mpg)\n return hash(obj)",
"def unique_hash(self):\n ... | [
"0.69617164",
"0.64695233",
"0.63753617",
"0.6323664",
"0.6319116",
"0.63028497",
"0.6299875",
"0.62495714",
"0.62479675",
"0.62255263",
"0.62255263",
"0.6224132",
"0.6224132",
"0.61693823",
"0.61693823",
"0.61693823",
"0.61693823",
"0.6160499",
"0.61550665",
"0.6140078",
"0.... | 0.64858 | 1 |
Check on the status of the process, update if necessary | def update(self):
if self.process:
retcode = self.process.poll()
# Windows exit code
if retcode is None:
# logging.debug("Update {}, Process: {}, RUNNING".format(self.hash,self.process))
self.status = "Running"
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _UpdateProcessingStatus(self, pid, process_status, used_memory):",
"async def _check_status(\n self, update: Update, context: ContextTypes.DEFAULT_TYPE\n ) -> None:\n self.system_status_lock.acquire()\n info = self.system_status_proxy._getvalue()\n self.system_status_lock.relea... | [
"0.7376041",
"0.7120535",
"0.6985662",
"0.6744803",
"0.673583",
"0.6724858",
"0.66267323",
"0.66235584",
"0.661456",
"0.6587562",
"0.65866846",
"0.6517083",
"0.6504459",
"0.6492997",
"0.6483846",
"0.64612955",
"0.64260006",
"0.64124054",
"0.6365277",
"0.63534266",
"0.6351622"... | 0.77873397 | 0 |
Create and place the clock widget into the parent element It's an ordinary Label element with two additional features. | def __init__(self, parent=None, seconds=True, colon=False):
tk.Label.__init__(self, parent)
self.display_seconds = seconds
if self.display_seconds:
self.time = time.strftime('%I:%M:%S %p')
else:
self.time = time.strftime('%I:%M:%S %p').lstrip('0')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, parent=None, seconds=True, colon=False):\r\n tkinter.Label.__init__(self, parent)\r\n\r\n self.display_seconds = seconds\r\n if self.display_seconds:\r\n self.time = time.strftime('%H:%M:%S')\r\n else:\r\n self.time = time.strftime('%I:%M %p').ls... | [
"0.6865375",
"0.66958445",
"0.62771356",
"0.6007648",
"0.58173424",
"0.5722867",
"0.56824654",
"0.5618196",
"0.56124157",
"0.5561427",
"0.5486574",
"0.54684067",
"0.54561365",
"0.54386383",
"0.542597",
"0.54212004",
"0.54184186",
"0.5417153",
"0.5415",
"0.5404665",
"0.5371785... | 0.67367035 | 1 |
Blink the colon every second | def blink_colon(self):
if ':' in self.display_time:
self.display_time = self.display_time.replace(':',' ')
else:
self.display_time = self.display_time.replace(' ',':',1)
self.config(text=self.display_time)
self.after(1000, self.blink_colon) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blink_colon(self):\r\n if ':' in self.display_time:\r\n self.display_time = self.display_time.replace(':', ' ')\r\n else:\r\n self.display_time = self.display_time.replace(' ', ':', 1)\r\n self.config(text=self.display_time)\r\n self.after(1000, self.blink_colo... | [
"0.7733094",
"0.76905394",
"0.69349957",
"0.6847326",
"0.67427564",
"0.6685767",
"0.66747737",
"0.66668457",
"0.66647846",
"0.6609761",
"0.658458",
"0.65551645",
"0.65437573",
"0.6462911",
"0.6400002",
"0.63868904",
"0.63295794",
"0.6321259",
"0.63024366",
"0.62783635",
"0.62... | 0.78344244 | 0 |
Make a test observation table. Create an observation table following a specific pattern. For the moment, only random observation tables are created. The observation table is created according to a specific observatory, and randomizing the observation pointingpositions in a specified azalt range. If a date_range is spec... | def make_test_observation_table(observatory_name='HESS', n_obs=10,
az_range=Angle([0, 360], 'deg'),
alt_range=Angle([45, 90], 'deg'),
date_range=(Time('2010-01-01'),
Time('2015-01-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_test_dataset(outdir, overwrite=False,\n observatory_name='HESS', n_obs=10,\n az_range=Angle([0, 360], 'deg'),\n alt_range=Angle([45, 90], 'deg'),\n date_range=(Time('2010-01-01'),\n Time('2... | [
"0.5961424",
"0.5544464",
"0.54481477",
"0.5431278",
"0.5330231",
"0.5319272",
"0.52401304",
"0.5229573",
"0.52290094",
"0.51920897",
"0.5171846",
"0.51415867",
"0.51415867",
"0.51362526",
"0.51124585",
"0.5109097",
"0.50791067",
"0.50767887",
"0.50683755",
"0.5064006",
"0.50... | 0.77679276 | 0 |
Make a test bg cube model. The background counts cube is created following a 2D symmetric gaussian model for the spatial coordinates (X, Y) and a powerlaw in energy. The gaussian width varies in energy from sigma/2 to sigma. The powerlaw slope in loglog representation is given by the spectral_index parameter. The norm ... | def make_test_bg_cube_model(detx_range=Angle([-10., 10.], 'deg'),
ndetx_bins=24,
dety_range=Angle([-10., 10.], 'deg'),
ndety_bins=24,
energy_band=Quantity([0.01, 100.], 'TeV'),
nen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def smooth(self):\n from scipy import ndimage\n\n # smooth images\n\n # integral of original images\n integral_images = self.background_cube.integral_images\n\n # number of times to smooth\n n_counts = self.counts_cube.data.sum()\n if n_counts >= 1.e6:\n ... | [
"0.5519833",
"0.5503235",
"0.5424007",
"0.5399416",
"0.5128134",
"0.50824505",
"0.5027042",
"0.5004923",
"0.49669912",
"0.48899314",
"0.4881596",
"0.48792392",
"0.48790324",
"0.48283985",
"0.48120263",
"0.48061755",
"0.47823942",
"0.47808954",
"0.47653082",
"0.47629404",
"0.4... | 0.7571534 | 0 |
Make a test event list for a specified observation. The observation can be specified with an observation table object and the observation ID pointing to the correct observation in the table. For now, only a very rudimentary event list is generated, containing only detector X, Y coordinates (a.k.a. nominal system) and e... | def make_test_eventlist(observation_table,
obs_id,
sigma=Angle(5., 'deg'),
spectral_index=2.7,
random_state='random-seed'):
from ..data import EventList
random_state = get_random_state(random_state)
# find obs r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_test_observation_table(observatory_name='HESS', n_obs=10,\n az_range=Angle([0, 360], 'deg'),\n alt_range=Angle([45, 90], 'deg'),\n date_range=(Time('2010-01-01'),\n Time(... | [
"0.59522456",
"0.5504977",
"0.519069",
"0.5143897",
"0.5140316",
"0.49749953",
"0.49136883",
"0.49133545",
"0.48834226",
"0.48583704",
"0.48471436",
"0.4814227",
"0.48070976",
"0.47922385",
"0.47751027",
"0.47720867",
"0.47573105",
"0.4748369",
"0.4719453",
"0.47043198",
"0.4... | 0.7818925 | 0 |
Loads the environment from file. | def load_environment(path: Optional[str] = None):
environment = deserialize_environment_from_file(path=path)
EnvironmentProvider().environment = environment | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_file(file_name: str) -> \"EnvironmentConfig\":\n return pickle.load(open(file_name, \"rb\"))",
"def load_envs_from_file(file_path=constants.ENV_FILE_DEFAULT_PATH.value):\n #pylint: disable=unspecified-encoding\n with open(file_path, \"r\") as file:\n for line in file:\n li... | [
"0.76441085",
"0.760974",
"0.7152548",
"0.7077226",
"0.7069875",
"0.6951707",
"0.6896937",
"0.68877673",
"0.6825524",
"0.67456716",
"0.67375165",
"0.6737238",
"0.67271346",
"0.6714671",
"0.6654536",
"0.6646665",
"0.6578962",
"0.6524361",
"0.65009046",
"0.63898426",
"0.6388524... | 0.7893428 | 0 |
Saves the environment to file. | def save_environment(path: Optional[str] = None):
environment = EnvironmentProvider().environment
serialize_environment_to_file(environment=environment,
path=path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save():\n\n env.config.save(env.config_file)",
"def save_to_env_file(self, envs, env_file_location):\n\n if not self.pre_initiated and envs:\n file_instance = PyFunceble.helpers.File(env_file_location)\n\n try:\n content = file_instance.read()\n excep... | [
"0.7672968",
"0.72407955",
"0.70484644",
"0.69485587",
"0.69476604",
"0.69340956",
"0.6897206",
"0.68504906",
"0.67581064",
"0.67163616",
"0.66987056",
"0.6667373",
"0.6648819",
"0.66321117",
"0.661414",
"0.65787506",
"0.6542631",
"0.6534146",
"0.6521091",
"0.6515022",
"0.650... | 0.77965045 | 0 |
Merges the current environment with the environment on cluster. | def pull_environment(cluster: Cluster,
path: Optional[str] = None):
log = get_logger(__name__)
with stage_info(log, "Pulling the environment from cluster."):
remote_environment = deserialize_environment_from_cluster(
cluster=cluster,
path=path)
local_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_local_fabric_env(self):\n env.sync_filename = '/tmp/{0}_env.txt'.format(time.time())\n env_copy = self.env\n env_copy.use_ssh_config = False\n env_copy.host = False\n env_copy.host_string = False\n env_copy.local_deployment = True\n # TODO: add context from... | [
"0.6252651",
"0.6053513",
"0.6027168",
"0.5989949",
"0.58727765",
"0.58275336",
"0.5784806",
"0.5781668",
"0.5668688",
"0.564595",
"0.55626947",
"0.5530955",
"0.5510136",
"0.5447263",
"0.53784347",
"0.53643125",
"0.5343327",
"0.5328848",
"0.5325904",
"0.5304727",
"0.52891433"... | 0.6118097 | 1 |
A unique key for given arguments args, useful for indexing into a cache. Each argument should either be already hashable (e.g. a primitive Python types), or an ndarray (which we make hashable here) | def _cache_key(self, *args):
return hash(tuple(hash(arg.data.tobytes()) if isinstance(arg, np.ndarray) else arg for arg in args)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_unique_key(*args, **kwargs):\n hashed_args = ['%s' % hash(arg) for arg in args]\n hashed_kwargs = ['%s ' % hash((key, value)) for (key, value) in kwargs.items()]\n # this is md5 hashed again to avoid the key growing too large for memcached\n return hashlib.md5(':'.join(hashed_args + hashed... | [
"0.7361639",
"0.708713",
"0.6670524",
"0.66519505",
"0.6602512",
"0.654696",
"0.64167464",
"0.64096814",
"0.63487726",
"0.6327257",
"0.63064504",
"0.6214404",
"0.62060946",
"0.6198701",
"0.61552864",
"0.6109364",
"0.60942304",
"0.607898",
"0.60185915",
"0.5997629",
"0.5992609... | 0.87209237 | 0 |
The probit distribution of the model, driven by a latent Gaussian field. | def probit_distribution(self, xi):
return Mvn(cov=(xi * self.R.cov) + (1.0 - xi) * np.eye(self.P)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pvalue_gaussian(self):\n \n pv = 2 * stats.norm.sf(abs(self.TS_prime_obs), loc=0, scale=1)\n return(pv)",
"def prob(x):\n\treturn 1. * bivariate_normal(x, (0., 1.2), (1., 1.), .8) + \\\n\t 1.05 * bivariate_normal(x, (.6, -1.), (1.3, .7), -.6)",
"def gaussian_prior(self):\n ... | [
"0.734257",
"0.6992546",
"0.649477",
"0.6469313",
"0.6403739",
"0.6326455",
"0.63044584",
"0.6302367",
"0.6290676",
"0.62570244",
"0.6196",
"0.616173",
"0.6142453",
"0.61330867",
"0.61068594",
"0.60900044",
"0.60720086",
"0.60561264",
"0.6025069",
"0.6014496",
"0.60027874",
... | 0.70214266 | 1 |
r""" The joint loglikelihood value of given model parameters. Returns float A scalar joint loglikelihood value of the entire model, given the model parameters and the true Y values stored in this model object. | def log_joint(self):
return sum([
self.log_marg_like(self.gamma, self.gamma0, self.lamb, self.nu),
self._gamma0_distribution.logpdf(self.gamma0),
self._nu_distribution.logpdf(self.nu),
self._lambda_distribution.logpdf(self.lamb),
self.probit_distributi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_likelihood(self, params):\n # extract the parameters\n m1 = params['m1']\n m2 = params['m2']\n DL = params['DL']\n Tc = params['Tc']\n iota = params['iota']\n phic = params['phic']\n psi = params['psi']\n thetaS = params['thetaS']\n phiS... | [
"0.68944037",
"0.6477333",
"0.6461905",
"0.6455405",
"0.6428418",
"0.64219177",
"0.64146054",
"0.64061934",
"0.639883",
"0.6398483",
"0.6397555",
"0.6379783",
"0.63410026",
"0.6331233",
"0.6307295",
"0.63034934",
"0.6262904",
"0.6256553",
"0.6243845",
"0.62360585",
"0.6228608... | 0.6488149 | 1 |
r""" Update all model parameters in a single MCMC step. Returns On return, the gamma, gamma0, lambda, nu and optionally the `xi` model parameter have been updated. | def update_parameters(self):
# We update gamma, gamma0, lambda and nu in turn (Bottolo et al, 2011)
self.update_gamma()
self.update_gamma0()
self.update_lambda()
self.update_nu()
if self.sample_xi:
self.update_xi() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def em_update_params(self):\n for name in self.likelihood_params:\n with self.elbo_check(name):\n self.update_param(name)",
"def _update(self):\n self.all_params = {}\n self._update_experiment_params()\n self._update_preprocessing_params()\n self._upda... | [
"0.6653522",
"0.6477869",
"0.6080687",
"0.6024899",
"0.59236777",
"0.5904601",
"0.59020025",
"0.58399814",
"0.5811473",
"0.58090514",
"0.57921237",
"0.57175773",
"0.568205",
"0.56608826",
"0.56567454",
"0.56558317",
"0.56475174",
"0.5633744",
"0.5628297",
"0.5615894",
"0.5605... | 0.74747205 | 0 |
{% get_admin_url object [as varname ]%} | def get_admin_url(parser, token):
argv = token.contents.split()
argc = len(argv)
varname = None
if argc == 0:
raise TemplateSyntaxError(
"%s requires an object passed as an argument." % argv[0]
)
elif argc == 3:
raise TemplateSyntaxError(
"%s requires ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(self, context):\n try:\n # Retrieve the object instance.\n obj = Variable(self.obj).resolve(context)\n except VariableDoesNotExist:\n obj = self.obj\n \n try:\n urlname = 'admin:%s_%s_change' % (\n obj._meta.app_label... | [
"0.6856947",
"0.6525016",
"0.623261",
"0.6198493",
"0.60248876",
"0.58967847",
"0.57631224",
"0.5760959",
"0.5743782",
"0.5710421",
"0.5703738",
"0.56791687",
"0.5652201",
"0.56023264",
"0.5597542",
"0.5580169",
"0.55411625",
"0.55295473",
"0.5518727",
"0.5504749",
"0.5423209... | 0.7639414 | 0 |
return emojis from tweets | def get_emojis(self):
return self.tweets.str.findall(r':{1}[\d\w\-]+:{1}') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def de_emojify(self, tweet):\n regrex_pattern = re.compile(\n pattern=\"[\"\n \"\\U0001F600-\\U0001F64F\" # emoticons\n \"\\U0001F300-\\U0001F5FF\" # symbols & pictographs\n \"\\U0001F680-\\U0001F6FF\" # transport & map symbols\n \"\\U0001F1E0-\\U000... | [
"0.71289325",
"0.6979217",
"0.66732603",
"0.65716875",
"0.64287204",
"0.6396741",
"0.6388213",
"0.6365893",
"0.63624686",
"0.6346038",
"0.62913287",
"0.62913287",
"0.6265444",
"0.6230787",
"0.6198683",
"0.61980563",
"0.61603206",
"0.6116763",
"0.60996956",
"0.60296535",
"0.60... | 0.7560154 | 0 |
Check tweets with highest sentiment polarity score (i.e. polarity=1) | def high_pol_tweets(self):
positive = sdf.loc[sdf.polarity == sdf.polarity.max(), ['text']].sample(5).values
[print(text[0], '\n') for text in positive]; | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predominant_sentiment(sentiment_aggregate_list):\r\n\r\n positive = int(sentiment_aggregate_list[0][1])\r\n neutral = int(sentiment_aggregate_list[1][1])\r\n negative = int(sentiment_aggregate_list[2][1])\r\n\r\n if positive > neutral and positive > negative:\r\n return \"positive\"\r\n e... | [
"0.70539516",
"0.6948548",
"0.6932769",
"0.6716728",
"0.670115",
"0.6696728",
"0.65879774",
"0.6551143",
"0.6425936",
"0.6417273",
"0.63419145",
"0.63322544",
"0.62687385",
"0.61988425",
"0.61981803",
"0.61734116",
"0.6109917",
"0.5996269",
"0.59818476",
"0.59360904",
"0.5930... | 0.6963815 | 1 |
Close the serial port and exit reader thread (uses lock) | def close(self):
# use the lock to let finish writing/reading
self._lock.lock()
# first stop reading, so that closing can be done on idle port
self.stop()
try:
self.serial.close()
except Exception as e:
logger.exception("Failed to close serial port... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self):\n self._stop.set()\n self.logger.debug('stop reading from serial port')\n if self.is_alive():\n self.join()\n self.logger.info('reader has terminated')",
"def close(self):\n logging.debug(\"Closing stream\")\n # pyserial cancel_read doesn't see... | [
"0.7482807",
"0.7425842",
"0.73682284",
"0.71893966",
"0.71707255",
"0.7139011",
"0.6920662",
"0.6906647",
"0.6849034",
"0.68222153",
"0.680914",
"0.6739457",
"0.66796887",
"0.6658015",
"0.66387033",
"0.6542484",
"0.65123385",
"0.6475145",
"0.64207655",
"0.63540304",
"0.62451... | 0.80160034 | 0 |
Given the two class arguments, data_frame and tc_list (test condition list), where tc_list is the important column headers of the DataFrame, iterate through the list and create a list of unique properties for each tc. Each dictionary value is accessible with data attributes. The data attributes return a tuple with the ... | def __init__(self, data_frame, tc_list, plot_dir):
cond_dict = {}
for i, condition in enumerate(tc_list):
cond_dict[condition] = list(data_frame[condition].unique())
self.cond_dict = cond_dict
# Data Attributes
self.dut = ('DUT', cond_dict['DUT'])
self.sn = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lists_to_data_frames(bc_class, temp_data):\n if 'bc_string_list' in temp_data:\n labels = ['CARD', 'ID', 'ID_0', 'ID_1']\n df = pd.DataFrame.from_records(temp_data['bc_string_list'], columns=labels)\n for x in range(1, len(labels)):\n df[labels[x]] = df[labels[x]].astype(dtyp... | [
"0.553577",
"0.53855306",
"0.5244138",
"0.5139128",
"0.5135252",
"0.5133226",
"0.5030541",
"0.50278074",
"0.49816406",
"0.49775428",
"0.49429473",
"0.49390382",
"0.48971066",
"0.48934624",
"0.48918056",
"0.48897317",
"0.4860627",
"0.48600215",
"0.48430625",
"0.48256487",
"0.4... | 0.68818724 | 0 |
Use the user account to get shop id from the website. Return the shop id. | def get_shopid_by_username(username):
url_shopid = 'https://shopee.tw/api/v1/shop_ids_by_username/'
payload = {
"usernames": [username]
}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0',
'Referer': 'https://shopee.tw/' + user... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_id():\n user_id = session.get(\"user_id\")\n return user_id if user_id else None",
"def get_id_from_user():\n from bokeh.io import curdoc\n try:\n name = curdoc().session_context.request.arguments.get('id')[0]\n if isinstance(name, bytes):\n wc_id = name.decode()... | [
"0.621742",
"0.6152591",
"0.60192984",
"0.598052",
"0.5935187",
"0.5909543",
"0.5888239",
"0.585097",
"0.585097",
"0.585097",
"0.5814822",
"0.5792665",
"0.5773558",
"0.576159",
"0.57224756",
"0.57104075",
"0.56945914",
"0.5692104",
"0.56770146",
"0.56708425",
"0.5670039",
"... | 0.7363099 | 0 |
Return whether two dicts of arrays are exactly equal | def isequal_dict_of_ndarray(first, second):
if first.keys() != second.keys():
return False
return all(np.array_equal(first[key], second[key]) for key in first) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_arr_eq(d1: DataDict, d2: DataDict):\n return (\n d1.keys() == d2.keys()\n and all(d1[k].shape == d2[k].shape for k in d1.keys())\n and all(np.allclose(d1[k], d2[k]) for k in d1.keys())\n )",
"def check_data_dict_identical(data_dict_1, data_dict_2):\n result = True # assume... | [
"0.8645211",
"0.7462472",
"0.7375997",
"0.7315742",
"0.73097223",
"0.72810876",
"0.72459555",
"0.71906126",
"0.7103892",
"0.70333445",
"0.6986169",
"0.6966609",
"0.6951346",
"0.69137293",
"0.68822247",
"0.6822148",
"0.67888135",
"0.6783117",
"0.6780517",
"0.67762315",
"0.6716... | 0.8633476 | 1 |
Encode a set of equal length peptides as a matrix of their amino acid indices. | def index_encoding(self, peptides, peptide_length):
X = np.zeros((len(peptides), peptide_length), dtype=int)
index_dict = self.index_dict()
for i, peptide in enumerate(peptides):
for j, amino_acid in enumerate(peptide):
X[i, j] = index_dict[amino_acid]
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hotshot_encoding(\n self,\n peptides,\n peptide_length):\n shape = (len(peptides), peptide_length, 20)\n index_dict = self.index_dict()\n X = np.zeros(shape, dtype=bool)\n for i, peptide in enumerate(peptides):\n for j, amino_acid in enume... | [
"0.6568228",
"0.59969974",
"0.59888685",
"0.5683163",
"0.54866403",
"0.5385961",
"0.5367735",
"0.527778",
"0.52764094",
"0.5272215",
"0.52362645",
"0.52194846",
"0.52126527",
"0.51921976",
"0.5158655",
"0.51073295",
"0.5084075",
"0.5078559",
"0.5071685",
"0.5054012",
"0.50444... | 0.74274945 | 0 |
Creates and return a server along with a source host and target host. | def _create_server(self):
server = super()._create_server(networks='none')
source_host = server['OS-EXT-SRV-ATTR:host']
target_host = 'host2' if source_host == 'host1' else 'host1'
return server, source_host, target_host | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_server(\n handle_event: EventCallback,\n host: str = \"0.0.0.0\",\n port: int = 0,\n ssl_context: Optional[SSLContext] = None,\n) -> Server:\n return Server(handle_event, host, port, ssl_context)",
"def create_server(host=None, port=None, new_loop=False, backend='tornado'):\n global ... | [
"0.6888337",
"0.66563684",
"0.65261495",
"0.6285431",
"0.6254806",
"0.62119794",
"0.6159919",
"0.60702604",
"0.6059764",
"0.5986918",
"0.59757435",
"0.5927125",
"0.59241205",
"0.5892274",
"0.5860786",
"0.5848868",
"0.5831156",
"0.5825508",
"0.5803257",
"0.57637876",
"0.574955... | 0.7676285 | 0 |
Tests a scenario where the LiveMigrationTask swaps the allocations for a live migration and then fails and rolls back allocations before RPC casting to live_migration on the source host. | def test_live_migration_task_rollback(self):
server, source_host, target_host = self._create_server()
self._disable_target_host(target_host)
self._stub_delete_server_during_scheduling(server)
# Now start the live migration which will fail due to NoValidHost.
body = {'os-migrateL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_post_live_migration_exc_on_dest_works_correctly(self):\n dest = 'desthost'\n srchost = self.compute.host\n srcnode = 'srcnode'\n\n # creating testdata\n c = context.get_admin_context()\n instance = self._create_fake_instance_obj({\n ... | [
"0.7256206",
"0.6906069",
"0.6898896",
"0.67031986",
"0.66736126",
"0.657574",
"0.6572478",
"0.64197874",
"0.63798773",
"0.6333615",
"0.6322457",
"0.6322457",
"0.63206536",
"0.6264102",
"0.6264102",
"0.62551105",
"0.6238344",
"0.616583",
"0.6113891",
"0.60431224",
"0.601284",... | 0.7256759 | 0 |
Tests a scenario where during the _prep_resize on the dest host the instance is gone which triggers a failure and revert of the migrationbased allocations created in conductor. | def test_migrate_on_compute_fail(self):
server, source_host, target_host = self._create_server()
# Wrap _prep_resize so we can concurrently delete the server.
original_prep_resize = compute_manager.ComputeManager._prep_resize
def wrap_prep_resize(*args, **kwargs):
self._del... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_prep_resize_instance_migration_error_on_none_host(self):\n instance = self._create_fake_instance_obj()\n\n self.compute.build_and_run_instance(self.context, instance, {}, {}, {},\n [], block_device_mapping=[])\n instance.host = None\n ... | [
"0.77237004",
"0.723508",
"0.71939445",
"0.69458383",
"0.6799761",
"0.6719068",
"0.6714028",
"0.6686909",
"0.6658462",
"0.6576752",
"0.65421546",
"0.64883745",
"0.6387951",
"0.6354252",
"0.6311323",
"0.62427276",
"0.6229559",
"0.61481935",
"0.61435497",
"0.6127806",
"0.611886... | 0.7320825 | 1 |
Find all C/C++ source files in the `folder` directory. | def get_c_sources(folder, include_headers=False):
allowed_extensions = [".c", ".C", ".cc", ".cpp", ".cxx", ".c++"]
if include_headers:
allowed_extensions.extend([".h", ".hpp"])
sources = []
for root, dirs, files in os.walk(folder):
for name in files:
ext = os.path.splitext(na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_case_3():\n print(\"*********Test_case_3***********\")\n result = find_files('.c', None)\n print(result)",
"def test_case_1():\n print(\"*********Test_case_1***********\")\n path = os.path.join(os.path.dirname(__file__), 'testdir')\n result = find_files('.c', path)\n for file in res... | [
"0.6515764",
"0.6434739",
"0.6326159",
"0.6260479",
"0.6224008",
"0.61766773",
"0.61337316",
"0.6051116",
"0.597322",
"0.5844667",
"0.57795376",
"0.5771132",
"0.57416326",
"0.5671642",
"0.56500787",
"0.5638098",
"0.5633748",
"0.56161606",
"0.5606276",
"0.5565417",
"0.5565417"... | 0.7384908 | 0 |
Send a telemetry message to the service. | def send_event(self, message, callback=None):
def pipeline_callback(call):
if call.error:
# TODO we need error semantics on the client
exit(1)
if callback:
callback()
self._pipeline.run_op(
pipeline_ops_iothub.SendTele... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sendServiceMessage(self, message):\n self.sendMessage(self.SERVICE_TO_SERVICE, message)",
"async def send_message(self, message):\n if message is None:\n return\n if isinstance(message, dict):\n message = json.dumps(message)\n if isinstance(message, Number):\... | [
"0.6135335",
"0.5724772",
"0.5702445",
"0.5695279",
"0.56871516",
"0.567314",
"0.55415463",
"0.5537796",
"0.55306464",
"0.5530367",
"0.5516932",
"0.55007434",
"0.54998916",
"0.54969984",
"0.5487889",
"0.547891",
"0.54731107",
"0.5446663",
"0.5443263",
"0.54309684",
"0.5428403... | 0.6128314 | 1 |
Enable the given feature by subscribing to the appropriate topics. | def enable_feature(self, feature_name, callback=None):
logger.info("enable_feature {} called".format(feature_name))
self.feature_enabled[feature_name] = True
def pipeline_callback(call):
if call.error:
# TODO we need error semantics on the client
exit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribe(self, topic):\n\t\tself.topic=topic\n\t\tself.client.subscribe(self.topic)",
"def enableFeaturesByName(self, **enabledFeatures):\n self.logger.debug('Updating enabled features with %s', enabledFeatures)\n self.enabledFeatures.update(enabledFeatures)\n self.logger.debug('Enabled features: %... | [
"0.59652096",
"0.59034383",
"0.5691525",
"0.5597786",
"0.55123365",
"0.54124236",
"0.5409628",
"0.5346474",
"0.52989036",
"0.5294302",
"0.52923644",
"0.5284812",
"0.52577066",
"0.5233054",
"0.52152157",
"0.52052975",
"0.5203645",
"0.520252",
"0.51971334",
"0.51957726",
"0.515... | 0.65942603 | 0 |
Disable the given feature by subscribing to the appropriate topics. | def disable_feature(self, feature_name, callback=None):
logger.info("disable_feature {} called".format(feature_name))
self.feature_enabled[feature_name] = False
def pipeline_callback(call):
if call.error:
# TODO we need error semantics on the client
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_disabled(self, feature):\n return not self.is_enabled(feature)",
"def do_disable_sensor(self, sensor):\n if hasattr(self, sensor) and sensor in self.active_sensors:\n del self.active_sensors[sensor]",
"def disable(self, subsystem=False):\n self.__dict__[\"enabled\"] = Fal... | [
"0.60269725",
"0.58263505",
"0.5669843",
"0.56325936",
"0.55808425",
"0.55704933",
"0.5547472",
"0.5510807",
"0.54516566",
"0.54427016",
"0.5394165",
"0.53376836",
"0.5327564",
"0.53093547",
"0.52994204",
"0.5294168",
"0.527174",
"0.52407175",
"0.52177984",
"0.5216431",
"0.52... | 0.6837938 | 0 |
Move all JPEG images from dirSrc to dirDest. Do not keep the directory structure. Change the extension to "jpg". | def move_images(dirSrc, dirDest):
usedFnames = set()
for path, dirs, files in os.walk(dirSrc):
for fname in files:
if re.search('\\.jpe?g', fname.lower()) is None:
continue
fnameNormalized = re.sub('\\.[^.]*$', '.jpg', fname)
if fnameNormalized in used... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def applyDir(self,srcDir,destDir,exts): \n for srcFile in os.listdir(srcDir):\n srcExt = os.path.splitext(srcFile)[-1].lower()\n srcPath = os.path.join(srcDir,srcFile)\n destPath = os.path.join(destDir,srcFile)\n if srcExt in exts:\n if not os.path... | [
"0.6791356",
"0.6684675",
"0.64462155",
"0.6427689",
"0.6402659",
"0.6152279",
"0.5987135",
"0.59821784",
"0.5981997",
"0.5977811",
"0.5938978",
"0.59214956",
"0.5911555",
"0.59015113",
"0.58764565",
"0.58511984",
"0.5831487",
"0.58202606",
"0.5805816",
"0.5802068",
"0.577929... | 0.8183764 | 0 |
Get CPU cache size in bytes at a given level. If no units are provided, assume source data is in KiB. | def _get_cache_size(level: int, cpuinfo_data: dict) -> t.Optional[int]:
raw_value = cpuinfo_data.get(
'l{}_data_cache_size'.format(level), cpuinfo_data.get('l{}_cache_size'.format(level), None))
if raw_value is None:
return None
if isinstance(raw_value, int):
return raw_value
ass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_total_n_cpu(self) -> int:",
"def calculate_cache_size(self):\n cache_size = self._total_chunk_size_left()\n N_l = self.N_l // self.conv_factor\n cache_sizes = []\n for lth in range(self.n_layers):\n cache_sizes.append(cache_size)\n if self.lc_bidir:\n ... | [
"0.6081995",
"0.5885079",
"0.5793031",
"0.5793031",
"0.5793031",
"0.5793031",
"0.5793031",
"0.5793031",
"0.5793031",
"0.57183194",
"0.5713756",
"0.5712487",
"0.5621723",
"0.56121916",
"0.55638057",
"0.5558014",
"0.5532178",
"0.5506182",
"0.54936963",
"0.54936963",
"0.54936963... | 0.7461401 | 0 |
Counts the number of unique words in bookx returns integer count | def unique_word_count(book):
count = unique_words(book)
return len(count) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_words_and_dublicates(novel):",
"def count(words):\n word_count = {}\n num_words = 0\n unique_words = 0\n for word in words:\n num_words += 1\n if word_count.has_key(word):\n word_count[word] += 1\n else:\n word_count[word] = 1\n unique_w... | [
"0.74273795",
"0.70119125",
"0.6944345",
"0.69200426",
"0.6842306",
"0.6841526",
"0.68274987",
"0.6744013",
"0.6736803",
"0.6709627",
"0.6701742",
"0.66909915",
"0.66520196",
"0.66218984",
"0.6591987",
"0.6566365",
"0.6563324",
"0.65560997",
"0.65526736",
"0.653285",
"0.65324... | 0.8519319 | 0 |
Returns total number of syllables in book. | def count_syllables(book):
d = dict(cmudict.entries())
with open(book, 'r') as myfile:
booky = myfile.read().lower()
tokenized_book = nltk.word_tokenize(booky)
count = 0
for word in tokenized_book:
count += ( nsly(word, d))
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_syllables(target_text):\n\n splited_text = target_text.split()\n count = 0\n for word in splited_text:\n count = count + word_syllables(word)\n return count",
"def count_syllables(words):\n\n\n count = 0\n\n for word in words:\n word_count = count_syllables_in_word(word)... | [
"0.7785605",
"0.7716621",
"0.7569649",
"0.74869156",
"0.7369434",
"0.7332177",
"0.71132255",
"0.7098898",
"0.6956114",
"0.6907962",
"0.67964697",
"0.67526793",
"0.65769607",
"0.6537315",
"0.633141",
"0.62938714",
"0.62645036",
"0.61257887",
"0.60993916",
"0.6010342",
"0.59880... | 0.83955956 | 0 |
Remove all traces of a user from the queue | def _purge_user(self, user):
self.user_order.remove(user)
del self.user_queue[user]
del self.user_skip[user] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, user_id):\n pass",
"def unfollowing_and_removing(self, user_id):\n if self.unfollowing(user_id):\n ind = [i for i, j in enumerate(self.monitored_users) if j.get('user', '') == user_id]\n if ind:\n self.monitored_users.remove(self.monitored_users... | [
"0.6166805",
"0.60952836",
"0.60174054",
"0.59812844",
"0.59786963",
"0.597253",
"0.5966084",
"0.58602285",
"0.5851618",
"0.5850941",
"0.58452314",
"0.5822956",
"0.5811353",
"0.5775017",
"0.57331306",
"0.572522",
"0.5713776",
"0.5689697",
"0.568827",
"0.5681412",
"0.5672758",... | 0.6335056 | 0 |
Remove an item from the queue The next item in the affected user's queue will take its place. | def dequeue(self, obj):
try:
item = self.obj_item.pop(obj)
self.user_queue[item.user].remove(item)
r = True
if self.user_skip[item.user] == 0 and not self.user_queue[item.user]:
self._purge_user(item.user)
self._normalise()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dequeue(self, irc, msg, args):\n pos = self._find_in_queue(msg.nick)\n if pos < 0:\n irc.reply(\"You're not in the queue, did your nick change?\")\n return\n self._queue.pop(pos)\n self._count -= 1\n self._dump_queue()\n irc.reply(\"Removed you fr... | [
"0.74197555",
"0.7177407",
"0.6872875",
"0.68107486",
"0.68043923",
"0.67581093",
"0.6740368",
"0.6699068",
"0.66915154",
"0.66560537",
"0.66503495",
"0.66246146",
"0.65605366",
"0.65185714",
"0.65149635",
"0.6511929",
"0.64895666",
"0.6484269",
"0.6484269",
"0.6474117",
"0.6... | 0.723028 | 1 |
Normalise skip data and clean out worthless users | def _normalise(self):
if len(self.user_skip) == 0:
return
m = min(self.user_skip.values())
for x in [k for k in self.user_skip]:
self.user_skip[x] -= m
if self.user_skip[x] == 0 and not self.user_queue[x]:
self._purge_user(x)
if not sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleaning (data):",
"def unusedFromKDOTDataPreparation():",
"def _common_preprocess(self, data):\n\n data = data.drop('id', axis=1) \n data = data.drop(['17', '488', 'B01AF', 'H01AB'], axis=1, errors='ignore')\n\n # drop age outliers\n idx = data[(data['age'] > 99)].index\... | [
"0.60702306",
"0.5964757",
"0.57487816",
"0.5714642",
"0.57103395",
"0.5650539",
"0.5572875",
"0.5482757",
"0.54645735",
"0.5414502",
"0.54078335",
"0.54051346",
"0.53764874",
"0.5359374",
"0.53582114",
"0.5342709",
"0.53066975",
"0.53064996",
"0.52803767",
"0.52551365",
"0.5... | 0.7307871 | 0 |
Init a Plist, optionally from parsing an existing file. | def __init__(self, filename=None):
if filename:
dict.__init__(self, self.read_file(filename))
else:
dict.__init__(self)
self.new_plist() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_plist(self, filename):\n file_path = self.get_file(filename)\n try:\n self._plist[filename] = readPlist(file_path)\n except:\n # Is binaryPlist?\n try:\n self._plist[filename] = readBinaryPlist(file_path)\n except:\n ... | [
"0.66032845",
"0.63391465",
"0.6151024",
"0.6071445",
"0.60496724",
"0.5956418",
"0.583471",
"0.5790385",
"0.57888365",
"0.574803",
"0.5746451",
"0.570029",
"0.56271285",
"0.5618639",
"0.5599978",
"0.55763674",
"0.55533844",
"0.55526125",
"0.55526125",
"0.5526523",
"0.5523987... | 0.709348 | 0 |
Write plist to path. | def write_plist(self, path):
plist_data, error = NSPropertyListSerialization.dataWithPropertyList_format_options_error_(
self,
NSPropertyListXMLFormat_v1_0,
0,
None)
if plist_data is None:
if error is None:
error = "Failed to se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_plist(data, output_path):\n with open(output_path, 'wb') as output_file:\n plistlib.writePlist(data, output_file)",
"def write(path):\n return mac_slideshow.preferences.write(KEY, path)",
"def write_output_plist(self):\n \n if self.env is None:\n return\n \n ... | [
"0.7439328",
"0.7135327",
"0.70129263",
"0.6339592",
"0.6227886",
"0.6227886",
"0.6149818",
"0.61224777",
"0.6042196",
"0.6009106",
"0.5951063",
"0.5933598",
"0.5847998",
"0.58222926",
"0.57671696",
"0.5756917",
"0.57156897",
"0.57021666",
"0.5649754",
"0.5647621",
"0.5621524... | 0.815537 | 0 |
Set up the jss connection class variable. If no connection argument is provided, setup will use the standard JSSPrefs preferences (com.github.sheagcraig.pythonjss). | def setup(cls, connection=None):
if not connection:
connection = {"jss_prefs": jss.JSSPrefs()}
cls._jss_prefs = connection
if isinstance(connection, jss.JSSPrefs):
cls._jss = jss.JSS(jss_prefs=cls._jss_prefs)
else:
cls._jss = jss.JSS(**cls._jss_prefs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_jssimporter_prefs(prefs):\n connection = {}\n connection[\"url\"] = prefs[\"JSS_URL\"]\n connection[\"user\"] = prefs[\"API_USERNAME\"]\n connection[\"password\"] = prefs[\"API_PASSWORD\"]\n connection[\"ssl_verify\"] = prefs.get(\"JSS_VERIFY_SSL\", True)\n connection[\"suppress_warnings\... | [
"0.58829176",
"0.57172173",
"0.5624873",
"0.5557188",
"0.5319529",
"0.5308637",
"0.5307695",
"0.52526957",
"0.5113209",
"0.51087064",
"0.5104662",
"0.50914526",
"0.50898284",
"0.50820714",
"0.50808316",
"0.50807774",
"0.50553083",
"0.50184214",
"0.49857706",
"0.49776542",
"0.... | 0.8684104 | 0 |
Return the shared JSS object. | def get(cls):
if not cls._jss:
cls.setup()
return cls._jss | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shared(self):\n return self._shared",
"def getinstance() :\n\t\treturn Jikji.instance",
"def shared_bitshares_instance():\n if not SharedInstance.instance:\n clear_cache()\n SharedInstance.instance = bts.BitShares()\n return SharedInstance.instance",
"def get_client():\n glo... | [
"0.6408332",
"0.63154894",
"0.57993156",
"0.558122",
"0.55672884",
"0.55544275",
"0.5547388",
"0.55371016",
"0.5508322",
"0.54990345",
"0.54590684",
"0.54590684",
"0.5426447",
"0.5363831",
"0.532959",
"0.5325028",
"0.5321425",
"0.5319908",
"0.5314332",
"0.5293714",
"0.519372"... | 0.66013074 | 0 |
Convert pythonjss preferences to JSSImporter preferences. | def map_jssimporter_prefs(prefs):
connection = {}
connection["url"] = prefs["JSS_URL"]
connection["user"] = prefs["API_USERNAME"]
connection["password"] = prefs["API_PASSWORD"]
connection["ssl_verify"] = prefs.get("JSS_VERIFY_SSL", True)
connection["suppress_warnings"] = prefs.get("JSS_SUPPRESS_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert():\n\n # deleting notifications\n var_notify.set('')\n\n # deleting commas if necessary\n value = active_var.get()\n if ',' in value:\n lst = value.split(',')\n value = ''.join(lst)\n\n # absorb values\n values_dol = list(map(lambda var: value if var == active_var els... | [
"0.50539076",
"0.5041467",
"0.49016288",
"0.48263264",
"0.47875127",
"0.47107252",
"0.46988916",
"0.46637982",
"0.4638697",
"0.4616283",
"0.45809683",
"0.45790067",
"0.45722347",
"0.45325038",
"0.45214942",
"0.44989887",
"0.44838688",
"0.44652528",
"0.4464581",
"0.4461703",
"... | 0.70145994 | 0 |
Report on the usage of objects contained in container objects. Find the used and unused jss_objects across a list of containing JSSContainerObjects. For example, Computers can have packages or scripts scoped to policies or configurations. | def build_container_report(containers_with_search_paths, jss_objects):
used_object_sets = []
for containers, search in containers_with_search_paths:
used_object_sets.append(
{(int(obj.findtext("id")), obj.findtext("name"))
for container in containers
for obj in cont... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_usages(self):\n return self.client._perform_json(\"GET\", \"/projects/%s/managedfolders/%s/usages\" % (self.project_key, self.odb_id))",
"def watch():\n\n try:\n headers = ('CONTAINER ID', 'NAME', 'CPU %', 'MEM USAGE / LIMIT',\n 'MEM %', 'NET I/O', 'BLOCK I/O', 'PIDS')\... | [
"0.5531353",
"0.5162634",
"0.4952077",
"0.49303415",
"0.489926",
"0.48761168",
"0.47810334",
"0.47637203",
"0.47286496",
"0.4717223",
"0.471553",
"0.47128794",
"0.46878293",
"0.46783108",
"0.46568364",
"0.46485493",
"0.4622924",
"0.4608489",
"0.45911953",
"0.456958",
"0.45662... | 0.6849218 | 0 |
Build a report of outofdate or unresponsive devices. Finds the newest OS version and looks for devices which are out of date. (Builds a histogram of installed OS versions). Compiles a list of devices which have not checked in for 'check_in_period' days. Finally, does a report on the hardware models present. | def build_device_report(check_in_period, devices):
check_in_period = validate_check_in_period(check_in_period)
device_name = device_type(devices)
report = Report(device_name, [], "%s Report" % device_name,
{"Cruftiness": {}})
# Out of Date results.
out_of_date_results = get_out_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_out_of_date_devices(check_in_period, devices):\n device_name = device_type(devices)\n strptime = datetime.datetime.strptime\n out_of_date = datetime.datetime.now() - datetime.timedelta(check_in_period)\n # Example computer contact time format: 2015-08-06 10:46:51\n # Example mobile device ti... | [
"0.66405267",
"0.59152424",
"0.5599958",
"0.5551001",
"0.5376166",
"0.52813804",
"0.5179384",
"0.5176116",
"0.51647896",
"0.5108412",
"0.50970274",
"0.5092708",
"0.50362945",
"0.50199556",
"0.49861524",
"0.4959381",
"0.49375078",
"0.49278867",
"0.4914031",
"0.491071",
"0.4903... | 0.6731036 | 0 |
Produce a report on devices not checked in since check_in_period. | def get_out_of_date_devices(check_in_period, devices):
device_name = device_type(devices)
strptime = datetime.datetime.strptime
out_of_date = datetime.datetime.now() - datetime.timedelta(check_in_period)
# Example computer contact time format: 2015-08-06 10:46:51
# Example mobile device time format:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_device_report(check_in_period, devices):\n check_in_period = validate_check_in_period(check_in_period)\n device_name = device_type(devices)\n report = Report(device_name, [], \"%s Report\" % device_name,\n {\"Cruftiness\": {}})\n\n # Out of Date results.\n out_of_date_re... | [
"0.6222224",
"0.5792777",
"0.5590743",
"0.5545013",
"0.5403961",
"0.53738457",
"0.5301319",
"0.5228013",
"0.51831585",
"0.5102697",
"0.50252724",
"0.49907428",
"0.49788463",
"0.4959644",
"0.4946723",
"0.49249208",
"0.4924457",
"0.49244145",
"0.4921769",
"0.49203768",
"0.49047... | 0.65678763 | 0 |
Generate Result of devices with no group memberships. Also, include a cruftiness result. | def get_orphaned_devices(devices):
device_name = device_type(devices)
orphaned_devices = [(device.id, device.name) for device in devices if
has_no_group_membership(device)]
description = ("This report collects %ss which do not belong to any "
"static or smart group... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_filter_device_group(self):\n pass",
"def test_get_device_groups1(self):\n pass",
"def test_get_device_groups(self):\n pass",
"def get_no_criteria_groups(full_groups):\n if isinstance(full_groups[0], jss.ComputerGroup):\n obj_type = (\"computers\", \"Computer\")\n el... | [
"0.61467594",
"0.60375166",
"0.5980249",
"0.5977337",
"0.59585506",
"0.59127957",
"0.564566",
"0.56084245",
"0.55932575",
"0.5588769",
"0.5467218",
"0.54549974",
"0.5379612",
"0.53621036",
"0.53509843",
"0.5339588",
"0.5339588",
"0.5322655",
"0.5289381",
"0.5289381",
"0.52797... | 0.68531436 | 0 |
Return a string type name for a list of devices. | def device_type(devices):
num_of_types = len({type(device) for device in devices})
if num_of_types == 1:
return devices[0].list_type.replace("_", " ").title()
elif num_of_types == 0:
return None
else:
raise ValueError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_key(self):\n # Disable this false positive\n # pylint: disable=comparison-with-callable\n if self == SimulatorControlType.DEVICE_TYPE:\n return \"devicetypes\"\n # pylint: enable=comparison-with-callable\n return self.value + \"s\"",
"def _get_types_string(t... | [
"0.68663234",
"0.68302613",
"0.67525816",
"0.67525816",
"0.672367",
"0.6685629",
"0.6634362",
"0.6559478",
"0.65497625",
"0.65267897",
"0.6487262",
"0.6464025",
"0.62769574",
"0.62418765",
"0.62371314",
"0.6230899",
"0.6222495",
"0.6182982",
"0.6177325",
"0.6144248",
"0.61317... | 0.75406253 | 0 |
Generate version spread metadata for device reports. | def get_version_and_model_spread(devices):
if isinstance(devices[0], jss.Computer):
os_type_search = "hardware/os_name"
os_type = "Mac OS X"
os_version_search = "hardware/os_version"
model_search = "hardware/model"
model_identifier_search = "hardware/model_identifier"
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_custom_metadata(uuid, version, update_proto):\n COMPONENTS = E.components\n COMPONENT = E.component\n ID = E.id\n NAME = E.name\n SUMMARY = E.summary\n PROVIDES = E.provides\n FIRMWARE = E.firmware\n CUSTOM = E.custom\n VALUE = E.value\n RELEASES = E.releases\n RELEASE... | [
"0.6098777",
"0.5953496",
"0.5707011",
"0.56587976",
"0.5645443",
"0.56236124",
"0.5622768",
"0.55712724",
"0.54770947",
"0.54495734",
"0.5444248",
"0.5390054",
"0.53840905",
"0.53538686",
"0.53225917",
"0.5256156",
"0.52495027",
"0.5236002",
"0.5211277",
"0.5209394",
"0.5176... | 0.59538454 | 1 |
Compare model identifier strings. | def model_identifier_cmp(model_string_one, model_string_two):
# pylint: disable=invalid-name
VersionIdentifier = namedtuple("VersionIdentifier",
("model", "major", "minor"))
# pylint: enable=invalid-name
model_string_one = model_string_one.split("/")[1].lstrip()
mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_model_identifier_value(self):\n \n model_identifier = get_model()[1]\n \n # Check to make sure the model_name is 'iMac14,2'\n self.assertEqual(model_identifier, 'iMac14,2')",
"def test_model__identifier_type(self):\n \n model_identifier = get_model()[1]\n... | [
"0.6978288",
"0.6195448",
"0.60066795",
"0.58812845",
"0.57837003",
"0.5781809",
"0.5748857",
"0.5743592",
"0.5714698",
"0.57058364",
"0.56209207",
"0.55575925",
"0.5555534",
"0.5514833",
"0.5497304",
"0.5472849",
"0.54555964",
"0.54188746",
"0.539017",
"0.5377118",
"0.537338... | 0.7887567 | 0 |
Build a report of outofdate or unresponsive computers. Finds the newest OS version and looks for computers which are out of date. (Builds a histogram of installed OS versions). Also, compiles a list of computers which have not checked in for 'check_in_period' days. Finally, does a report on the hardware models present. | def build_computers_report(check_in_period, **kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
all_computers = jss_connection.Computer().retrieve_all(
subset=["general", "hardware", "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_out_of_date_devices(check_in_period, devices):\n device_name = device_type(devices)\n strptime = datetime.datetime.strptime\n out_of_date = datetime.datetime.now() - datetime.timedelta(check_in_period)\n # Example computer contact time format: 2015-08-06 10:46:51\n # Example mobile device ti... | [
"0.59920573",
"0.5766287",
"0.5578741",
"0.5287282",
"0.52608496",
"0.5066685",
"0.50561553",
"0.5054898",
"0.50391996",
"0.5001956",
"0.4985311",
"0.4951431",
"0.49278352",
"0.49184254",
"0.49170458",
"0.48708752",
"0.48682904",
"0.48506495",
"0.48441875",
"0.48201138",
"0.4... | 0.59207517 | 1 |
Ensure check_in_period argument is correct. | def validate_check_in_period(check_in_period):
if not check_in_period:
check_in_period = 30
if not isinstance(check_in_period, int):
try:
check_in_period = int(check_in_period)
except ValueError:
print "Incorrect check-in period given. Setting to 30."
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def periodCheck(data):",
"def valid_period(request):\n return request.param",
"def test_assign_period():\n\n \"\"\" Period 1 is allowed for all allowable years yyyy \"\"\"\n args.period = 1\n args.yyyy = 1999\n assert assign_period(args) == None\n args.yyyy = 2000\n assert assign_period(ar... | [
"0.76204133",
"0.65650743",
"0.6252414",
"0.6153359",
"0.60349303",
"0.5993853",
"0.5923103",
"0.5915537",
"0.58885014",
"0.58746374",
"0.5777295",
"0.5738657",
"0.5705474",
"0.5683216",
"0.56798077",
"0.5668664",
"0.5638684",
"0.563559",
"0.5634773",
"0.5628551",
"0.5566266"... | 0.7803638 | 0 |
Report on package usage. Looks for packages which are not installed by any policies or computer configurations. | def build_packages_report(**kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
# We have to support the functioning subset and the (hopefully) fixed
# future subset name.
all_policies =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _print_missing(packages, verbose):\n if not packages:\n print(\"## No Rez packages were found.\")\n print(\"No data found\")\n\n return\n\n print(\"## Your command affects these Rez packages.\")\n\n template = \"{package.name}\"\n\n if verbose:\n template = \"{package.na... | [
"0.64060766",
"0.6358747",
"0.63560534",
"0.6239273",
"0.6162212",
"0.6095122",
"0.6014031",
"0.5975538",
"0.5974496",
"0.59375095",
"0.5911839",
"0.5911407",
"0.5786521",
"0.5742677",
"0.5721314",
"0.5698138",
"0.5680046",
"0.5671445",
"0.5659518",
"0.5652586",
"0.56472075",... | 0.64049906 | 1 |
Report on printer usage. Looks for printers which are not installed by any policies or computer configurations. | def build_printers_report(**kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
# We have to support the functioning subset and the (hopefully) fixed
# future subset name.
all_policies =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listPrinters(self):\n raise NotImplementedError(\"listPrinters not implemented\")",
"def list_cups_printer( ):\n\t\n\tprint( 'List CUPS printer' )\n\tprint( '-----------------' )\n\tmedium = PrinterCupsAdapter()\n\t\n\tmedium.open() # Open the media for transmission\n\ttry:\n\t\tmedium.dump_printers()... | [
"0.61006653",
"0.58798087",
"0.5682266",
"0.55651224",
"0.55009514",
"0.5361776",
"0.523017",
"0.5224572",
"0.5158952",
"0.5094803",
"0.50132334",
"0.49472964",
"0.48951277",
"0.48809516",
"0.48761594",
"0.48427108",
"0.48133987",
"0.4800226",
"0.47898397",
"0.4786051",
"0.47... | 0.6766165 | 0 |
Report on script usage. Looks for scripts which are not executed by any policies or computer configurations. | def build_scripts_report(**kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
all_policies = jss_connection.Policy().retrieve_all(
subset=["general", "scripts"])
all_configs = jss_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showUsage():\n None",
"def usage():",
"def usage():",
"def run_script_usage_tests(test_data_dir,\r\n scripts_dir,\r\n working_dir,\r\n verbose=False,\r\n tests=None,\r\n forc... | [
"0.60341805",
"0.5781918",
"0.5781918",
"0.5750167",
"0.5663251",
"0.5591564",
"0.5582304",
"0.5524998",
"0.5501363",
"0.54555154",
"0.53635734",
"0.5355437",
"0.53222656",
"0.53205407",
"0.5299533",
"0.5276258",
"0.5213177",
"0.5199869",
"0.5144101",
"0.51390857",
"0.5128365... | 0.64131975 | 0 |
Report on computer groups usage. Looks for computer groups with no members. This does not mean they neccessarily are inneedofdeletion. | def build_computer_groups_report(**kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
group_list = jss_connection.ComputerGroup()
if not group_list:
return Report("ComputerGroup", [... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __check_removed_groups(self) -> None:\n for group in Group.objects.all():\n if group.name not in main_app_groups:\n self.__delete_group(group)\n\n self.stdout.write(f'Removed {group} group')",
"def get_empty_groups(full_groups):\n if isinstance(full_groups[0... | [
"0.630231",
"0.62859136",
"0.59019065",
"0.58763844",
"0.5857278",
"0.58074534",
"0.56756496",
"0.5667059",
"0.56462455",
"0.5613199",
"0.56074417",
"0.55829805",
"0.5571659",
"0.5515767",
"0.5507596",
"0.5497145",
"0.5480888",
"0.5470643",
"0.5448858",
"0.5445323",
"0.542078... | 0.66101146 | 0 |
Report on computer extension attributes usage. Looks for computer extension attributes not being used as criteria in any smart groups. This does not mean they neccessarily are inneedofdeletion. | def build_computer_ea_report(**kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
all_eas = [(ea.id, ea.name) for ea in jss_connection.ComputerExtensionAttribute()]
if not all_eas:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_unused_attributes(self):\n all_attrs_read = collections.defaultdict(set)\n\n def _add_attrs(typ, attr_names_read):\n if typ is None:\n return\n all_attrs_read[typ] |= attr_names_read\n for base_cls in typ.__bases__:\n all_attrs_... | [
"0.561457",
"0.5579946",
"0.53668183",
"0.52292407",
"0.51689637",
"0.5166137",
"0.51531297",
"0.5120206",
"0.50485265",
"0.5033034",
"0.50206906",
"0.5002655",
"0.49945247",
"0.4981764",
"0.4976199",
"0.49753222",
"0.4938531",
"0.49315825",
"0.49217975",
"0.4919876",
"0.4910... | 0.6275437 | 0 |
Get the names of any extension attribute criteria in a group, or an empty set. | def get_all_criteria_names(group):
return (
criterion.findtext("name")
for criterion in group.findall("criteria/criterion") if
criterion.findtext("search_type") != "member of") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nested_groups_names(group):\n return (\n criterion.findtext(\"value\")\n for criterion in group.findall(\"criteria/criterion\") if\n criterion.findtext(\"name\") in (\"Computer Group\", \"Mobile Device Group\")\n and criterion.findtext(\"search_type\") == \"member of\")",
"... | [
"0.5985525",
"0.55007267",
"0.5477949",
"0.54677206",
"0.5466627",
"0.5295282",
"0.52827746",
"0.5270074",
"0.5269154",
"0.5261388",
"0.5136143",
"0.5136143",
"0.5109094",
"0.5091862",
"0.5085787",
"0.5061946",
"0.50275713",
"0.50243795",
"0.5012176",
"0.5012176",
"0.49958992... | 0.7168265 | 0 |
Report on mobile device groups usage. Looks for mobile device groups with no members. This does not mean they neccessarily are inneedofdeletion. | def build_device_groups_report(**kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
group_list = jss_connection.MobileDeviceGroup()
if not group_list:
return Report("MobileDeviceGro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_device_groups(self):\n pass",
"def test_get_device_groups1(self):\n pass",
"def has_no_group_membership(device):\n excluded_groups = (\"All Managed Clients\",\n \"All Managed Servers\",\n \"All Managed iPads\",\n \"... | [
"0.6512263",
"0.6233397",
"0.62163675",
"0.59948033",
"0.58691144",
"0.57853675",
"0.56302786",
"0.5604201",
"0.560174",
"0.55400896",
"0.5524247",
"0.5500654",
"0.54953706",
"0.54874474",
"0.5486278",
"0.54839945",
"0.5442685",
"0.54287916",
"0.5407603",
"0.54066026",
"0.538... | 0.69214374 | 0 |
Report on policy usage. Looks for policies which are not scoped to anything or are disabled. | def build_policies_report(**kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
all_policies = jss_connection.Policy().retrieve_all(
subset=["general", "scope"])
if not all_policies:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_policies():\r\n policy = policies.values()\r\n return policy",
"def enforce_policy(self, method_name, request):\n context_dict = request.context.to_dict()\n if method_name in [\"detail\", \"get_all\", \"get_one\"]:\n policy.authorize(event_log_policy.POLICY_ROOT % \"get\", ... | [
"0.57304597",
"0.5727719",
"0.5679195",
"0.56436646",
"0.56436646",
"0.5600632",
"0.5583132",
"0.554945",
"0.5544653",
"0.5524206",
"0.5440671",
"0.54272217",
"0.54014593",
"0.5395421",
"0.5387521",
"0.538306",
"0.53576374",
"0.5331527",
"0.5329771",
"0.53126657",
"0.5309067"... | 0.6355892 | 0 |
Report on computer configuration profile usage. Looks for profiles which are not scoped to anything. | def build_config_profiles_report(**kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
all_configs = jss_connection.OSXConfigurationProfile().retrieve_all(
subset=["general", "scope"])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def globalProfile():\n return context.profiles",
"def watch_profile(self):\r\n profile_parser = ProfileParser()\r\n databases = self._get_requested_databases()\r\n connection = pymongo.MongoClient(self._db_uri,\r\n document_class=OrderedDict,\r\n ... | [
"0.63542914",
"0.63512534",
"0.6249375",
"0.6175659",
"0.61486596",
"0.609686",
"0.60892475",
"0.6070348",
"0.59853566",
"0.5959964",
"0.5861681",
"0.5840508",
"0.57786965",
"0.57540923",
"0.57397395",
"0.5696793",
"0.56958383",
"0.5695081",
"0.5687763",
"0.5656808",
"0.56171... | 0.6988534 | 0 |
Report on mobile device configuration profile usage. Looks for profiles which are not scoped to anything. | def build_md_config_profiles_report(**kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
all_configs = (
jss_connection.MobileDeviceConfigurationProfile().retrieve_all(
subs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile_devices(request, pk):\n context = {}\n profile = get_object_or_404(ConfigurationProfile, pk=pk)\n to_remove = InstallationRecord.objects.filter(profile=profile, device__pending__in=[profile], active=True,\n version=\"RM\")\n pending = Laptop.... | [
"0.653743",
"0.6319439",
"0.618205",
"0.6031872",
"0.5896796",
"0.5794363",
"0.57560015",
"0.55032384",
"0.5487741",
"0.54852396",
"0.54670995",
"0.54497546",
"0.54336464",
"0.542768",
"0.54231167",
"0.53775775",
"0.53700525",
"0.5366112",
"0.53289986",
"0.53166604",
"0.53018... | 0.69151217 | 0 |
Report on out of date and unscoped mobile apps. | def build_apps_report(**kwargs):
# All report functions support kwargs to support a unified interface,
# even if they don't use them.
_ = kwargs
jss_connection = JSSConnection.get()
all_apps = (
jss_connection.MobileDeviceApplication().retrieve_all(
subset=["general", "scope"]))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_out_of_date_devices(check_in_period, devices):\n device_name = device_type(devices)\n strptime = datetime.datetime.strptime\n out_of_date = datetime.datetime.now() - datetime.timedelta(check_in_period)\n # Example computer contact time format: 2015-08-06 10:46:51\n # Example mobile device ti... | [
"0.5325341",
"0.5254728",
"0.5190017",
"0.5132387",
"0.5058777",
"0.4981782",
"0.49586028",
"0.4954484",
"0.4926468",
"0.48910227",
"0.48895437",
"0.48448268",
"0.47625425",
"0.47347778",
"0.4732106",
"0.47282615",
"0.472275",
"0.47199643",
"0.47178748",
"0.4710114",
"0.46672... | 0.6368101 | 0 |
Get all of the groups 'nested' in an iterable of groups. A smart group may include other groups with a Computer Group criterion. This function will find all of the groups nested within a provided iterable of jss.ComputerGroup objects (including nested groups that _also_ nest groups). | def get_nested_groups(groups, full_groups):
results = set()
for group in groups:
# Get the names of any nested groups.
nested_groups_names = get_nested_groups_names(group)
if nested_groups_names:
# Function needs full objects, and criteria only specify
# the name,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups(self, deep=False, exclude_prefix=None):\n\n for group in self._groups:\n if exclude_prefix is None or not group.startswith(exclude_prefix):\n yield group\n if deep:\n yield from (group + \"/\" + subgroup\n for subgroup... | [
"0.6530554",
"0.6260557",
"0.62522364",
"0.62397724",
"0.60761625",
"0.60443884",
"0.60277843",
"0.6021826",
"0.5879851",
"0.5776265",
"0.56839454",
"0.56079596",
"0.5585688",
"0.55675316",
"0.54569596",
"0.54451",
"0.5405377",
"0.5400066",
"0.5371834",
"0.5371529",
"0.534188... | 0.7137509 | 0 |
Get the names of any nested groups in a group, or an empty set. | def get_nested_groups_names(group):
return (
criterion.findtext("value")
for criterion in group.findall("criteria/criterion") if
criterion.findtext("name") in ("Computer Group", "Mobile Device Group")
and criterion.findtext("search_type") == "member of") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_group_names(self):\r\n return self.groups.keys()",
"def get_nested_groups(self, conn, group: str) -> typing.List[str]:\n nested_groups = list()\n conn.search(\n search_base=self.group_search_base,\n search_filter=self.group_search_filter.format(group=group),\n ... | [
"0.6943205",
"0.65895677",
"0.6354785",
"0.6294683",
"0.62127006",
"0.62059605",
"0.6205548",
"0.612196",
"0.61022216",
"0.60745037",
"0.6058621",
"0.60310787",
"0.5952286",
"0.59136707",
"0.5886393",
"0.58781046",
"0.58683187",
"0.584674",
"0.58396715",
"0.58263063",
"0.5823... | 0.7611141 | 0 |
Given a list a of group names, get the full objects. | def get_full_groups_from_names(groups, full_groups):
return [full_group for group in groups for full_group in
full_groups if full_group.name == group] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_groups(args):\n\n for group in get_groups(args):\n print(group)",
"def list_groups():\n return _list_tindyb_unique_values(\"group\", dbpath=__dbpath__)",
"def ObjectGroups(object_id):\n rhino_object = rhutil.coercerhinoobject(object_id, True, True)\n if rhino_object.GroupCount<1: re... | [
"0.6404853",
"0.63883924",
"0.6258863",
"0.6227452",
"0.59801507",
"0.59557396",
"0.59343624",
"0.5920263",
"0.59043056",
"0.583828",
"0.58316517",
"0.58143145",
"0.5795789",
"0.57565594",
"0.57480896",
"0.57447207",
"0.5737932",
"0.5705476",
"0.57011575",
"0.56908154",
"0.56... | 0.67174715 | 0 |
Return a list of object names provided list of full objects. | def get_names_from_full_objects(objects):
return [obj.name for obj in objects] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def named_objs(objlist):\n objs = []\n for k, obj in objlist:\n if hasattr(k, '__name__'):\n k = k.__name__\n else:\n k = as_unicode(k)\n objs.append((k, obj))\n return objs",
"def list_of_objects(objects):\r\n # Create a list of item_names.\r\n object_na... | [
"0.7249178",
"0.6960611",
"0.68843037",
"0.6576931",
"0.6415013",
"0.6301584",
"0.62816507",
"0.6214574",
"0.61904854",
"0.6176938",
"0.6173437",
"0.61701626",
"0.6092001",
"0.6068361",
"0.6066302",
"0.6018112",
"0.6018112",
"0.60056496",
"0.59658045",
"0.5922731",
"0.5920598... | 0.8803919 | 0 |
Return all groups with no members as a Result. | def get_empty_groups(full_groups):
if isinstance(full_groups[0], jss.ComputerGroup):
obj_type = ("computers", "Computer")
elif isinstance(full_groups[0], jss.MobileDeviceGroup):
obj_type = ("mobile_devices", "Mobile Device")
else:
raise TypeError("Incorrect group type.")
groups_w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_no_criteria_groups(full_groups):\n if isinstance(full_groups[0], jss.ComputerGroup):\n obj_type = (\"computers\", \"Computer\")\n elif isinstance(full_groups[0], jss.MobileDeviceGroup):\n obj_type = (\"mobile_devices\", \"Mobile Device\")\n else:\n raise TypeError(\"Incorrect ... | [
"0.73232704",
"0.66462886",
"0.64317214",
"0.6351195",
"0.6239607",
"0.6220463",
"0.6199725",
"0.6187921",
"0.5751504",
"0.57432973",
"0.5725468",
"0.57245916",
"0.56784964",
"0.56508595",
"0.56506467",
"0.5640674",
"0.56295484",
"0.5615797",
"0.56087446",
"0.5564751",
"0.548... | 0.7895626 | 0 |
Return a Result with all smart groups that have no criteria. | def get_no_criteria_groups(full_groups):
if isinstance(full_groups[0], jss.ComputerGroup):
obj_type = ("computers", "Computer")
elif isinstance(full_groups[0], jss.MobileDeviceGroup):
obj_type = ("mobile_devices", "Mobile Device")
else:
raise TypeError("Incorrect group type.")
gr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_empty_groups(full_groups):\n if isinstance(full_groups[0], jss.ComputerGroup):\n obj_type = (\"computers\", \"Computer\")\n elif isinstance(full_groups[0], jss.MobileDeviceGroup):\n obj_type = (\"mobile_devices\", \"Mobile Device\")\n else:\n raise TypeError(\"Incorrect group ... | [
"0.66721976",
"0.6332299",
"0.6165863",
"0.5915035",
"0.57111067",
"0.5706021",
"0.5591358",
"0.55882406",
"0.554927",
"0.55024695",
"0.54974145",
"0.5487512",
"0.54839265",
"0.54732335",
"0.5458939",
"0.5440637",
"0.54239595",
"0.53510934",
"0.53273237",
"0.52957785",
"0.526... | 0.778352 | 0 |
Test whether a computer or mobile device belongs to any groups. | def has_no_group_membership(device):
excluded_groups = ("All Managed Clients",
"All Managed Servers",
"All Managed iPads",
"All Managed iPhones",
"All Managed iPod touches")
if isinstance(device, jss.Computer):
x... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_group(self) -> bool:\n return (\n self.all_icon is not None and\n self.all_name is not None\n )",
"def is_group(self, group_name):\n\n return group_name in self._group",
"def _check_groups_support(self, groups=()):\n available_groups = set(self.df[self.col_... | [
"0.666216",
"0.6541967",
"0.63930845",
"0.6351154",
"0.63273305",
"0.62523836",
"0.62077874",
"0.62074536",
"0.61606187",
"0.60732967",
"0.6069908",
"0.6068061",
"0.60592157",
"0.60402966",
"0.6002687",
"0.5984734",
"0.59696704",
"0.5957372",
"0.59441864",
"0.5908097",
"0.588... | 0.72874963 | 0 |
Generate a horizontal text histogram. Given a dictionary of items, generate a list of column aligned, padded strings. | def get_histogram_strings(data, padding=0, hist_char="\xf0\x9f\x8d\x95"):
max_key_width = max([len(key) for key in data])
max_val_width = max([len(str(val)) for val in data.values()])
max_value = max(data.values())
_, width = get_terminal_size()
# Find the length we have left for the histogram bars.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def histogram(l):\n return \"\\n\".join(map(lambda ls: \"#\"*ls, l))",
"def ascii_histogram(seq) -> None:\n counted = count_elements(seq)\n for k in sorted(counted):\n print('{0:5d} {1}'.format(k, '+' * counted[k]))",
"def _pretty_table_line(self, items):\n padded_strings = []\n f... | [
"0.6436757",
"0.6322049",
"0.61814016",
"0.6119443",
"0.6116621",
"0.6113234",
"0.6112911",
"0.6081339",
"0.60407877",
"0.59951115",
"0.5885402",
"0.5874821",
"0.5871289",
"0.5866372",
"0.5841625",
"0.58241767",
"0.58156717",
"0.5794772",
"0.57508993",
"0.5748296",
"0.5719336... | 0.65159 | 0 |
Runs reports specified as commandline args to spruce. Runs each report specified as a commandline arguement, and outputs by default to stdout, or to a plist file specified with o/ofile. Shows report construction progress, and prints report after all data is crunched. | def run_reports(args):
# Define the types of reports we can accept.
# TODO: Roll this data structure into the Reports class.
reports = {}
reports["computers"] = {"heading": "Computer Report",
"func": build_computers_report,
"report": None}
repo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_report(*args):\n for report in args:\n os.startfile(report)",
"def reports_cli():",
"def __execute_reporter(self):\n if not self.__args.report:\n return\n reporter.HTMLReporter().generate_report_from_file(\n self.__lst_json_files)",
"def main():\n con... | [
"0.7241289",
"0.68302715",
"0.6795979",
"0.6542551",
"0.649967",
"0.6476061",
"0.635871",
"0.63278204",
"0.6311355",
"0.6302363",
"0.6295348",
"0.62949234",
"0.62890345",
"0.6286748",
"0.62530786",
"0.6210884",
"0.618931",
"0.6185009",
"0.61814487",
"0.6158017",
"0.61284643",... | 0.6898265 | 1 |
Remove desired objects from the JSS and distribution points. Given an XML file with subelement "Removals", remove each child object from the JSS. The child Element must have a tag name corresponding to the JSSObject class to delete (e.g. "Computer", or "Policy"), with an attribute of "id" containing the object's ID. Th... | def remove(removal_tree):
if not check_with_user():
sys.exit(0)
jss_connection = JSSConnection.get()
# Tag map is a dictionary mapping our Element tags to JSS factory
# methods.
tag_map = {"Computer": jss_connection.Computer,
"ComputerGroup": jss_connection.ComputerGroup,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eliminate(sv, nam):\r\n del sv.Object[nam] # from sv.Object dictionary\r\n sv.Object_list.remove(nam)",
"def manage_deleteRRDDataPoints(self, ids=(), REQUEST=None):\n\n def clean(rel, id):\n for obj in rel():\n ... | [
"0.5277047",
"0.5198695",
"0.519827",
"0.5175008",
"0.51062137",
"0.50937337",
"0.5011318",
"0.50102466",
"0.50032514",
"0.5003168",
"0.49951228",
"0.4956854",
"0.494873",
"0.49472287",
"0.49341163",
"0.49273363",
"0.49264982",
"0.4925676",
"0.49214685",
"0.48851037",
"0.4885... | 0.74171716 | 0 |
Find partner for supplier invoice. Problem is that either the sender (from), or the receiver (to, cc) must be a supplier, but this method is called first to determine the sender/author_id, and only later for the receiver (partner_ids). To handle this we will also search as a fallback partners that are not suppliers. On... | def message_find_partners(
self, cr, uid, message, header_fields=['From'], context=None):
# Find partners, taking company into account, and having a preference
# for suppliers.
# Each email will return one or zero partners. Unless an
# email address occurs in multiple head... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_supplier_(obj, line):\n \n iNo = 0\n strRet = None\n for item in obj.order_line:\n iNo += 1\n if (item.id == line.id):\n if (len(item.product_id.seller_ids)>0):\n strRet = item.product_id.seller_ids[0] and item.product_id.seller_ids[0].name.name or None\... | [
"0.6553606",
"0.5779786",
"0.5681386",
"0.5671942",
"0.56226736",
"0.5515012",
"0.54258615",
"0.5420251",
"0.53877586",
"0.5335899",
"0.5249747",
"0.5249747",
"0.51985383",
"0.5104403",
"0.51016796",
"0.509528",
"0.50797343",
"0.49883357",
"0.49823928",
"0.48089284",
"0.47882... | 0.66395336 | 0 |
This method is intended to be used with dim_lemmas_word_forms.db. It returns a list of all word forms of a given lemma (self.word) if it exists. | def _all_word_forms(self):
all_word_forms = []
for word in self.cursor.execute(f"""
SELECT word_form
FROM {self.table_name}
WHERE lemma='{self.word}'
"""):
all_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_forms(self, word):\n result = set()\n for dic_name in self.dictionaries.keys():\n for vector in self.dictionaries[dic_name].word_forms(word):\n result.add(tuple(vector))\n return filter(lambda x: len(x), result)",
"def get_words(self):\n words = self... | [
"0.68329525",
"0.6055824",
"0.60007685",
"0.5850711",
"0.5778205",
"0.57677305",
"0.57347554",
"0.5729986",
"0.5664245",
"0.5601554",
"0.55578226",
"0.5541538",
"0.5503891",
"0.550199",
"0.54905874",
"0.5450124",
"0.5429441",
"0.54178613",
"0.53761774",
"0.53449106",
"0.53449... | 0.833403 | 0 |
This method is intended to be used with the databases and returns True if a word form or a lemma exists in the database. Else it returns False. | def exists(self):
self.cursor.execute(f"""
SELECT 1
FROM {self.table_name}
WHERE {self.lookup_type}='{self.word}'
""")
return True if self.cursor.fetchone() else False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Has(cls, word_list):\n entity = WordList.get_by_id(word_list)\n if entity:\n return True\n return False",
"def exists(self, word):\n result = self.find(word)\n return False if result is None else result.is_word",
"def word_dict_contains (self,\r\n ... | [
"0.6386676",
"0.632327",
"0.62509954",
"0.62394166",
"0.6175888",
"0.6080661",
"0.605355",
"0.60444546",
"0.6023731",
"0.5959519",
"0.595463",
"0.59351635",
"0.58784974",
"0.586614",
"0.5829317",
"0.5821009",
"0.5805678",
"0.58021325",
"0.5791058",
"0.5726763",
"0.57180387",
... | 0.68287253 | 0 |
convert absolute coordonate to 4 Bytes value | def translateCoord(self,absX,absY):
rawConvertedX=hex(absX*(16**4-1)/self.maxX).upper()[2:]
rawConvertedY=hex(absY*(16**4-1)/self.maxY).upper()[2:]
return {'x':rawConvertedX,'y':rawConvertedY} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xyz_to_offset(x, y, z):\n\t\tv = y + (z % 16) * 128 + (x % 16) * 128 * 16\n\t\treturn v",
"def position_gazebo_to_px4(position_x, position_y, position_z):\n return (position_y, position_x, -position_z)",
"def to_pygame(coords):\r\n return (coords[0], HEIGHT - coords[1])",
"def _coord_byval(coord: ... | [
"0.66070604",
"0.6244187",
"0.61635894",
"0.6148397",
"0.611203",
"0.60815185",
"0.6060567",
"0.6018708",
"0.59008324",
"0.589413",
"0.5856754",
"0.58427817",
"0.5830466",
"0.5777125",
"0.57556987",
"0.5745004",
"0.57238126",
"0.57170296",
"0.56844836",
"0.56825894",
"0.56577... | 0.64513665 | 1 |
Looks up bzr version by calling bzr version. | def _get_bzr_version():
try:
value, output, _ = run_shell_command('bzr --version',
shell=True,
us_env=True)
if value == 0 and output is not None and len(output.splitlines()) > 0:
version = output.sp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_svn_version():\n return crds.__version__",
"def get_version():\n return '%d.%d.%d' % version_info",
"def _get_version(self):",
"def get_version():\n return 1",
"def version():\n\n version = None\n output = gitopen(['--version'])\n m = re.search(br\" version ([\\d\\.A-Za-z]+)\", ou... | [
"0.600255",
"0.5836464",
"0.5697323",
"0.5666968",
"0.56541026",
"0.5645986",
"0.560682",
"0.5604042",
"0.5574361",
"0.5557418",
"0.5542928",
"0.55390066",
"0.55259293",
"0.55192655",
"0.551549",
"0.5505616",
"0.5497229",
"0.5486416",
"0.54761577",
"0.5465808",
"0.5465808",
... | 0.7723596 | 0 |
Creating number with random `size` of random digits | def create_num_size(size):
rand.seed(datetime.now())
num = ''
size = rand.choice(size)
for _ in range(size):
a = rand.randint(0,9)
num += str(a)
return num | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_digits(generator, size) :\n return [int(generator.random()*10) for i in range(size)]",
"def generation_randomid(size, integer=False):\n digits = range(10)\n id = []\n for i in range(size):\n id.append(choice(digits))\n res = ''.join(map(str, id))\n if not integer:\n r... | [
"0.7733669",
"0.75930506",
"0.75637496",
"0.7236773",
"0.7206396",
"0.7193397",
"0.71810645",
"0.7167757",
"0.71489644",
"0.7141742",
"0.703528",
"0.7013211",
"0.7002152",
"0.6999689",
"0.6983391",
"0.6981569",
"0.69765943",
"0.69450825",
"0.6934113",
"0.6883091",
"0.6821397"... | 0.8464616 | 0 |
Get concatenation of `app_id` and `i` | def get_app_name(i):
return app_id + '-' + str(i) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"app_id\")",
"def ApplicationId(self) -> _n_0_t_0:",
"def _app_id(self):\n return '{}-{}'.format(self.config['app']['name'],\n self.config['app']['version'])",
"def app_id(self) -> pulumi.Input[str]:... | [
"0.63627243",
"0.6153944",
"0.611797",
"0.59687954",
"0.5968116",
"0.5925187",
"0.58031297",
"0.5783413",
"0.5710583",
"0.5690399",
"0.56722355",
"0.56629694",
"0.55801266",
"0.55772245",
"0.55503684",
"0.55082136",
"0.5471755",
"0.5465289",
"0.5410903",
"0.53902805",
"0.5379... | 0.79642195 | 0 |
Insert `header` to top of the `filename` | def add_header(header, filename, i):
with open(filename, 'r+') as f:
content = f.readlines()
content[0] = header
f.seek(0,0)
f.write(f'<!-- Generated with XMLGenerator.py {__ver__} | {get_app_name(i)} -->\n')
f.writelines(content) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepend_header(filename, header=None, drop=0):\n for no, line in enumerate(fileinput.input(filename, inplace=True)):\n # it's meaningless to set drop to -1, -2, ...\n if no == 0 and drop == 0:\n if header:\n print(header)\n print(line, end='')\n # re... | [
"0.7341343",
"0.7160395",
"0.69932836",
"0.6936791",
"0.6877494",
"0.68635404",
"0.68611443",
"0.6852462",
"0.68328446",
"0.6803247",
"0.67481995",
"0.6608636",
"0.65929586",
"0.6584658",
"0.65498143",
"0.65453106",
"0.6530421",
"0.6521435",
"0.6508888",
"0.6477595",
"0.64659... | 0.77616066 | 0 |
Receive a quality measurement and store it in the user interface | def _update_quality(self, quality:float):
if quality is not None:
self.quality_text.setText(str(quality)[0:5])
if quality > 0.9:
self.quality_text.setStyleSheet("QLabel { color : green }")
elif quality > 0.5:
self.quality_text.setStyleSheet("QL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quality(self):\n return self.plays * self.number",
"def quality(self, quality):\n\n self._quality = quality",
"def print_quality(self, quality):\n # Find the parameter dictionary for the desired quality level\n \n imu = self.get_parameters(quality)\n \n print '\... | [
"0.66441727",
"0.61838394",
"0.6160102",
"0.60730124",
"0.60181206",
"0.599992",
"0.59929544",
"0.5980153",
"0.59692895",
"0.5935434",
"0.59170395",
"0.5858585",
"0.5696049",
"0.56889856",
"0.56806594",
"0.5645944",
"0.5608517",
"0.5600007",
"0.5537317",
"0.5514785",
"0.55046... | 0.620713 | 1 |
Check whether the given string represents a valid python version | def _is_python_version(s: str) -> bool:
return s.startswith("2") or s.startswith("3") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_py_version(self, cur_version):\n\n # convert cur_version to string, in case of erroneous type being passed\n cur_version = str(cur_version)\n\n acceptable_python_versions_regex = r\"(^(2\\.[6-9])(\\.?\\d{1,2})?$)|(^(3\\.[3-9])(\\.?\\d{1,2})?$)\"\n pyversions_regex_compiled = r... | [
"0.74447066",
"0.7330632",
"0.7022275",
"0.6937966",
"0.6863343",
"0.6863179",
"0.6793033",
"0.677648",
"0.67668253",
"0.6706832",
"0.6671179",
"0.66470045",
"0.66288424",
"0.65482163",
"0.6381573",
"0.637296",
"0.6329869",
"0.6312826",
"0.6312826",
"0.6312826",
"0.62636757",... | 0.81249535 | 0 |
Get a list of all available python versions | def get_all_versions(cls) -> list[str]:
s = run([cls.command, "install", "-l"])
versions = s.split()
return list(filter(cls._is_python_version, versions)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_python_verlist(): \n l = []\n fv = []\n \n for pyexe in find_all_pythons():\n v = get_pyver_from_exe(pyexe)\n if v != None and v not in fv: # watch for duplicates\n l.append( (pyexe, v) )\n fv.append(v)\n\n return l",
"def available_python_versions():\n ... | [
"0.7817325",
"0.745999",
"0.7417876",
"0.72895813",
"0.69297564",
"0.6776516",
"0.6775578",
"0.67534393",
"0.6751643",
"0.6634243",
"0.6629811",
"0.6614957",
"0.6602321",
"0.65777767",
"0.65539575",
"0.64139557",
"0.6378665",
"0.6374513",
"0.6347862",
"0.63274246",
"0.6319375... | 0.78660536 | 0 |
Set the given python version as active in the given directory | def set_active(cls, directory: Path, ver: str) -> None:
if directory.is_dir() is False:
raise Failure(f"{directory} is not a valid directory")
if not cls.is_installed(ver):
raise Failure(f"{ver} is not installed, cannot set as active")
logger.info(f"Setting python vers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _venv_switcher(self, venv):\n venv_bin = os.path.join(venv, 'bin', 'activate_this.py')\n if sys.version_info[0:2] == (2, 7):\n execfile(venv_bin, dict(__file__ = venv_bin)) # python2 \n elif sys.version_info[0:2] >= (3, 0):\n # execfile(venv_bin, dict(__file__ ... | [
"0.5964548",
"0.56889033",
"0.568241",
"0.5536124",
"0.5491008",
"0.53533345",
"0.5297739",
"0.5276191",
"0.5257876",
"0.5227964",
"0.51751834",
"0.5164734",
"0.5102291",
"0.5088671",
"0.50717354",
"0.5051284",
"0.50431246",
"0.5017261",
"0.5016723",
"0.49796137",
"0.49727046... | 0.80779326 | 0 |
Check if the given directory is a valid git repository | def is_repository(cls, directory: Path) -> bool:
git_directory = directory / ".git"
return git_directory in filter(Path.is_dir, directory.iterdir()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_git_repo(directory):\n files = os.listdir(directory)\n if '.git' in files:\n return True\n return False",
"def checkGit(directory):",
"def validate(cls):\n for repository in cls.config['repositories']:\n if not os.path.isdir(repository['path']):\n LOGGER.... | [
"0.8190079",
"0.77559316",
"0.7456223",
"0.7358649",
"0.72832084",
"0.71543586",
"0.70857376",
"0.70857376",
"0.68753374",
"0.68374723",
"0.6762263",
"0.67413664",
"0.6736106",
"0.66773653",
"0.66704905",
"0.6562406",
"0.65506995",
"0.6547177",
"0.6515921",
"0.6444525",
"0.64... | 0.8022111 | 1 |
Initialize a virtual environment for the given directory | def init(cls, directory: Path) -> None:
if directory.is_dir() is False:
raise Failure(f"{directory} is not a valid directory")
path = PyEnv.get_path(directory)
logger.info(f"Initializing virtual environment against {path}")
os.chdir(directory)
run([cls.command, "en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def virtualenv():\n\n get_details()\n\n # Set up the virtualenv.\n with cd(env.paths[\"sites\"]):\n run(\"virtualenv %s\" % env.site_name)\n\n # Create directory structure\n with cd(posixpath.join(env.paths[\"sites\"], env.site_name)):\n run(\"mkdir logs media src tmp\")\n run(\... | [
"0.65611213",
"0.6554739",
"0.6489569",
"0.64182085",
"0.6416847",
"0.6409407",
"0.6271123",
"0.62556547",
"0.6248665",
"0.6200686",
"0.61376184",
"0.6136009",
"0.61199",
"0.6112994",
"0.610799",
"0.6088445",
"0.6056341",
"0.60484827",
"0.60343754",
"0.60111785",
"0.6001542",... | 0.85999995 | 0 |
Remove the virtual environment for the given directory | def remove(cls, directory: Path) -> None:
if directory.is_dir() is False:
raise Failure(f"{directory} is not a valid directory")
path = PyEnv.get_path(directory)
logger.info(f"Removing virtual environment against {path}")
os.chdir(directory)
run([cls.command, "env"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self):\n if self.exists():\n try:\n utils.run_in_bash(\n f'{CONDA_BIN} env remove -q -y -n {self.name}')\n except CalledProcessError as err:\n err_message = err.output.strip().decode('ascii')\n if 'CondaEnvironm... | [
"0.67711663",
"0.6752602",
"0.6649935",
"0.6610373",
"0.6538988",
"0.65204644",
"0.6483283",
"0.64435196",
"0.6424683",
"0.64058334",
"0.64054686",
"0.63704926",
"0.6329048",
"0.6328608",
"0.6321892",
"0.6314126",
"0.6295668",
"0.62781787",
"0.62646586",
"0.6239254",
"0.62149... | 0.8676213 | 0 |
Scrape project and perform git operations | def git_project(soup, github_user, github_pass, github_repo, github_name):
giturl = 'https://{user}:{password}@github.com/{user}/{repo}.git'.format(
user=github_user, password=github_pass, repo=github_repo
)
oldcwd = os.getcwd()
tmpdir = tempfile.mkdtemp()
gitdir = os.path.join(tmpdir, githu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __gitFetch(self):\n self.vcs.gitFetch(self.project.getProjectPath())",
"def git():\n pass",
"def project():",
"def project():",
"def project():",
"def checkGit(directory):",
"def __gitBundleFetch(self):\n self.vcs.gitBundleFetch(self.project.getProjectPath())",
"def main():\n\n ... | [
"0.73384327",
"0.6877343",
"0.6605568",
"0.6605568",
"0.6605568",
"0.6444735",
"0.6412853",
"0.6204654",
"0.61725265",
"0.6101883",
"0.6086974",
"0.60847545",
"0.6082945",
"0.60539126",
"0.6053194",
"0.6033475",
"0.60277474",
"0.6014488",
"0.60018015",
"0.5980792",
"0.5976634... | 0.716143 | 1 |
Pass the request's GET dictionary in to fn. If the response is not a dictionary, we know something went wrong, so just pass it back. Otherwise, convert the dictionary into a json response. | def use_GET_in(fn, request):
response = fn(request.GET)
if isinstance(response, dict):
return HttpResponse(json.dumps(response),
content_type='application/json')
else:
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_json(func):\n def wrapper(request):\n try:\n return get_json_response(func(request))\n except Exception as ex:\n return get_json_response({\n \"status\": \"error\",\n \"error_info\": str(ex),\n \"trace_back\": tracebac... | [
"0.6966883",
"0.68834406",
"0.6388175",
"0.6346596",
"0.6243913",
"0.62369144",
"0.61978704",
"0.61798203",
"0.60851073",
"0.6061016",
"0.60259813",
"0.59724575",
"0.5961023",
"0.59310824",
"0.59137416",
"0.5899801",
"0.5880168",
"0.5853704",
"0.58473605",
"0.5815728",
"0.579... | 0.8205918 | 0 |
Get a list of current values. Given an attribute, pull out all of the values in that attribute column from the database. Also calculate basic information about the attribute use. Returns int Number of BioSamples that have this attribute type int Number of BioProjects that have this attribute type list List of values th... | def get_examples(currAttr):
num_samples = len(list(Biometa.objects.aggregate(*[
{'$unwind': '$sample_attributes'},
{'$match': {'sample_attributes.name': currAttr}},
])))
# Count the number of projects that used attribute
num_projects = len(list(Biometa.objects.aggregate(*[
{'$un... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attribute(self, attribute):\n value = 3\n if self.age == \"child\":\n value -= 1\n if attribute == \"physique\" or attribute == \"phy\":\n if self.age == \"adult\":\n value += 1\n if self.gender == \"male\":\n value += 1\n ... | [
"0.57461804",
"0.5688926",
"0.56660724",
"0.5387812",
"0.5366918",
"0.52480537",
"0.52328885",
"0.52133155",
"0.51694494",
"0.5118955",
"0.50976604",
"0.5087453",
"0.5059003",
"0.50092787",
"0.4997842",
"0.49935892",
"0.49849018",
"0.49645418",
"0.49633342",
"0.49556494",
"0.... | 0.6992532 | 0 |
Run the attribute selector. Originally designed as a CLI, attribute selector is a way to look at all attribute types and decide if you want to keep, ignore, or rename. This page will iterate over all attribute types in the database and get user input about how to handle the type. | def attribute_selector(term=None):
# Build forms
form = AttributeSelectorForm()
pager = AttributePager()
# Get session info or build list of attributes.
session['attrIndex'] = session.get('attrIndex') or 0
session['attrList'] = session.get('attrList') or get_all_attrs()
# Get current attri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_attributes(self):\n\n self.attribute_case_ids = [] # TODO unsure here\n self.attribute_file_ids = []\n self.attributes_msg = \"\"\n ui = DialogSelectAttributeParameters(self.app)\n # ui.fill_parameters(self.attributes)\n ok = ui.exec()\n if not ok:\n ... | [
"0.5801941",
"0.5667818",
"0.53180385",
"0.5127753",
"0.50879866",
"0.5061622",
"0.50207126",
"0.50148124",
"0.49121046",
"0.4896487",
"0.48964453",
"0.47792777",
"0.47295463",
"0.47267857",
"0.47169015",
"0.47075206",
"0.47069672",
"0.46819353",
"0.46794116",
"0.4676231",
"0... | 0.5884322 | 0 |
Should return a list of monitorings successfully. | def test_list_monitorings_success(self):
project_id = util.MOCK_UUID_1
deployment_id = util.MOCK_UUID_1
rv = TEST_CLIENT.get(
f"/projects/{project_id}/deployments/{deployment_id}/monitorings"
)
result = rv.json()
expected = util.MOCK_MONITORING_LIST
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMonitors(self):\n return [self.monitor]",
"def monitor(self):\n logging.debug(\"monitor entered\")\n # monitor machines...\n # first, get a list of machine IDs\n res = progress_table(self.machines)\n return res",
"def list_health_monitors(self, retrieve_all=True... | [
"0.7243288",
"0.68006134",
"0.6614322",
"0.6491235",
"0.6469292",
"0.6340618",
"0.63044626",
"0.629212",
"0.6208673",
"0.6063526",
"0.602164",
"0.6018369",
"0.5987285",
"0.5957553",
"0.591304",
"0.5851934",
"0.58468205",
"0.581472",
"0.5797021",
"0.5779929",
"0.5743829",
"0... | 0.8117224 | 0 |
Should create and return a monitoring successfully. | def test_create_monitoring_success(
self,
mock_kfp_client,
):
project_id = util.MOCK_UUID_1
deployment_id = util.MOCK_UUID_1
task_id = util.MOCK_UUID_1
rv = TEST_CLIENT.post(
f"/projects/{project_id}/deployments/{deployment_id}/monitorings",
j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_monitoring(self):\n pass",
"def create_health_monitor(self, body=None):\r\n return self.post(self.health_monitors_path, body=body)",
"def create_health_monitor(request, **kwargs):\n data = request.DATA\n\n conn = get_sdk_connection(request)\n health_mon = conn.load_balancer... | [
"0.6371888",
"0.60621536",
"0.59505594",
"0.5927453",
"0.5918526",
"0.5877081",
"0.5870348",
"0.5797462",
"0.57042754",
"0.5700966",
"0.56873274",
"0.5677589",
"0.56728864",
"0.5644748",
"0.56444806",
"0.56338304",
"0.55778265",
"0.5546461",
"0.552895",
"0.55152917",
"0.54992... | 0.6633762 | 0 |
Should delete monitoring successfully. | def test_delete_monitoring_success(
self,
mock_load_config,
mock_custom_objects_api,
mock_kfp_client,
):
project_id = util.MOCK_UUID_1
deployment_id = util.MOCK_UUID_1
monitoring_id = util.MOCK_UUID_1
rv = TEST_CLIENT.delete(
f"/projects/{... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_device(self):\n pass",
"def test_delete_device(self):\n pass",
"def test_delete_run(self):\n pass",
"def test_issue_delete_stop_watch(self):\n pass",
"def test_delete_monitoring_monitoring_not_found(self):\n project_id = util.MOCK_UUID_1\n deploymen... | [
"0.70288885",
"0.70288885",
"0.68077004",
"0.673687",
"0.6700043",
"0.6625458",
"0.6574707",
"0.65526426",
"0.6545025",
"0.65376663",
"0.65326416",
"0.64995897",
"0.64590305",
"0.6441825",
"0.6433003",
"0.64298886",
"0.64234585",
"0.6422672",
"0.64132947",
"0.6405631",
"0.637... | 0.7385274 | 0 |
Parse pkg_info from a file on disk. | def ParsePkgInfoFile(filename, valid_keys=None, required_keys=None):
with open(filename) as f:
return ParsePkgInfo(f.read(), filename, valid_keys, required_keys) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __parsePackages__(self, f):\n\n\t\tp = apt_pkg.ParseTagFile(f)\n\n\t\t# Just load into memory the fields that are going to be useful\n\t\twhile p.Step() == 1:\n\t\t\tpkg = p.Section['Package']\n\n\t\t\tself.packages[pkg] = {}\n\n\t\t\tfor field in p.Section.keys():\n\t\t\t\tif field == 'Package':\n\t\t\t\t\tpa... | [
"0.67943674",
"0.6717216",
"0.6544474",
"0.5974887",
"0.58522767",
"0.5840895",
"0.5801031",
"0.57123756",
"0.56631035",
"0.5606324",
"0.5582678",
"0.5575308",
"0.5554415",
"0.551115",
"0.5487318",
"0.54830706",
"0.54532313",
"0.5439808",
"0.54110503",
"0.5407071",
"0.5407071... | 0.7727231 | 0 |
Get required permissions for method and view combo Given method and view, return the list of permission codes that the user is required to have. | def get_required_permissions(self, method, view):
perms_map = self.perms_map.copy()
if hasattr(view, "perms_map"):
perms_map.update(view.perms_map)
if method not in perms_map:
return []
return perms_map[method] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_permissions(self):\n if self.action in ['create', 'retrieve', 'react', 'reactions']:\n permissions = [IsAuthenticated, IsFriendPostOwner]\n elif self.action in ['update', 'partial_update']:\n permissions = [IsAuthenticated, IsCommentOwner]\n elif self.action in ['d... | [
"0.6499984",
"0.6484198",
"0.6464525",
"0.6402153",
"0.6306395",
"0.627946",
"0.6272795",
"0.620266",
"0.61652523",
"0.61506635",
"0.61425066",
"0.6131785",
"0.6131785",
"0.6131785",
"0.61277837",
"0.61101246",
"0.61101246",
"0.6105208",
"0.60963523",
"0.6082366",
"0.6072645"... | 0.8428004 | 0 |
Spec says outcome has an optional 'collection.name'. | def get_outcome_coll_name(self, outcome, collection):
return outcome["collection"].get("name", collection.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_collection_name(self):\n response = self.client.get(\n 'http://localhost:8000/webapp/api/collection/')\n self.assertEqual(response.status_code, 200)",
"def test_get_collection(self):\n pass",
"def test_get_collections(self):\n pass",
"def test_guess_and_set... | [
"0.6630997",
"0.6247963",
"0.60997677",
"0.59403425",
"0.58490866",
"0.5763121",
"0.5710572",
"0.5695765",
"0.5689197",
"0.5686581",
"0.5634714",
"0.5628015",
"0.5602263",
"0.55709225",
"0.5558651",
"0.5548572",
"0.55252486",
"0.5491839",
"0.547752",
"0.5439734",
"0.5431678",... | 0.7826756 | 0 |
Validate that feature number 'num_f' exist in feature collection if not, then make it | def _validate_or_make_feature(dic_fc, num_img):
# bol_found_numf = False
num_il = -999 # number in list initialise
if isinstance(dic_fc, dict):
if isinstance(num_img, int):
# print(f" = dic_fc: {dic_fc}")
if "type" in dic_fc.keys() and dic_fc["type"] == "FeatureCollection":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature_is_numerical(records, index):\n if index not in features_type:\n features_type[index] = True\n for r in records:\n try:\n a = float(r.features[index])\n except:\n features_type[index] = False\n return False\n return ... | [
"0.58270276",
"0.5786119",
"0.5726579",
"0.5589417",
"0.5519126",
"0.5437946",
"0.5434848",
"0.5431869",
"0.54314137",
"0.54314137",
"0.5427902",
"0.5419723",
"0.5419723",
"0.5419723",
"0.5419723",
"0.5419723",
"0.5419355",
"0.54161763",
"0.54161763",
"0.54161763",
"0.5403163... | 0.70839745 | 0 |
Adds a TAG (key, val) to feature number 'num_f', in a geojson (dic) feature collection returns the updated geojson (dic) feature collection. | def add_tag(tup_tag, dic_fc, num_f):
if isinstance(tup_tag, tuple) and len(tup_tag) == 2:
if isinstance(dic_fc, dict):
if isinstance(num_f, int):
# print(f"\tadd tag: {tup_tag}")
if tup_tag[0].lower() == "make" \
or tup_tag[0].lower() == "m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_tag_on_document(self, document, key, value):\n query = self.sql_session.query(Feature)\\\n .filter(Feature.document == document)\\\n .filter(Feature.key == key)\\\n .filter(Feature.value == json_encode(value))\n try:\n tag_entry = ... | [
"0.6009201",
"0.59143806",
"0.58079845",
"0.5793859",
"0.56701523",
"0.55766433",
"0.5557536",
"0.5483204",
"0.54762447",
"0.5437945",
"0.5418184",
"0.53959364",
"0.53729475",
"0.5340194",
"0.5327345",
"0.53250295",
"0.530148",
"0.52995926",
"0.5291187",
"0.5271049",
"0.52650... | 0.6149307 | 0 |
Visualize data by day of week | def visualize_days():
# grab our parsed data that we parsed earlier
data_file = parse(MY_FILE, ",")
counter = Counter(item['DayOfWeek'] for item in data_file)
data_list = [
counter['Monday'],
counter['Tuesday'],
counter['Wednesday'],
counter['Thursday'],
counter['Friday'],
counter['Sa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize_days():\n\t\n\t#grab our parsed data that we parsed earlier\n\tdata_file = parse(MY_FILE, \",\")\n\t\n\t#make a new variable, counter, from iterating through each line of\n\t#data in the parsed data, and count how many incidents happen on each\n\t#day of the week\n\tcounter = Counter(item[\"DayOfWee... | [
"0.737502",
"0.6982798",
"0.6977443",
"0.6280072",
"0.62752277",
"0.62326986",
"0.62164164",
"0.61257464",
"0.6047597",
"0.5908121",
"0.58833814",
"0.5868752",
"0.5849026",
"0.5792153",
"0.5778713",
"0.56907874",
"0.5683649",
"0.56659245",
"0.5661819",
"0.5660102",
"0.5656149... | 0.7642968 | 0 |
Get constraint command function object based on contraint type | def get_constraint_func(ntype):
func = None
if ntype == 'pointConstraint':
func = mc.pointConstraint
elif ntype == 'orientConstraint':
func = mc.orientConstraint
elif ntype == 'parentConstraint':
func = mc.parentConstraint
elif ntype == 'scaleConstraint':
func = m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_constraint(constraint):\n if isinstance(constraint, str) and constraint == \"array-like\":\n return _ArrayLikes()\n if isinstance(constraint, str) and constraint == \"sparse matrix\":\n return _SparseMatrices()\n if isinstance(constraint, str) and constraint == \"random_state\":\n ... | [
"0.59449553",
"0.58912265",
"0.57749546",
"0.5730417",
"0.5513448",
"0.5511506",
"0.5483417",
"0.5359876",
"0.5320943",
"0.53049296",
"0.52886385",
"0.525771",
"0.5174452",
"0.51415473",
"0.5100012",
"0.50988007",
"0.5066327",
"0.50484514",
"0.50143325",
"0.50116575",
"0.4987... | 0.7020769 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.