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 |
|---|---|---|---|---|---|---|
Returns the ``BatchStats`` for a specific batch. | def get_batch_stats(self, batch):
return self.batch_stats[batch] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_batch_stats():\n\n # We use the moving mean as an estimate of the mean in order to perform\n # a more numerically stable calculation of the batch mean.\n # Copy for better stability.\n shift = tf.add(self._moving_mean, 0)\n counts, shifted_sum_x, shifted_sum_x2, _ = tf.nn.suffici... | [
"0.65609884",
"0.65114206",
"0.65014577",
"0.6211535",
"0.59668744",
"0.5954246",
"0.58340657",
"0.5821755",
"0.57448745",
"0.57334435",
"0.57184416",
"0.5670613",
"0.56242794",
"0.560072",
"0.55778915",
"0.5565209",
"0.55386823",
"0.5498818",
"0.54651314",
"0.5450578",
"0.54... | 0.89985496 | 0 |
Convenience method that sums up all the sentences across all batches. | def get_total_sentences(self):
# loop through batches and add up all their individual sentence counts
total_sentences = 0
for batch in self.batch_stats:
total_sentences += self.batch_stats[batch].total_sentences
return total_sentences | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_texts(self) -> None:\n texts = []\n for text in self.texts:\n paragraphs = list(filter(lambda x: x != \"\", text.split(\"\\n\\n\")))\n for paragraph in paragraphs:\n text = paragraph.replace(\"\\n\", \" \").strip()\n if len(text) > sel... | [
"0.62009716",
"0.6035176",
"0.60308325",
"0.6027758",
"0.58148813",
"0.5691236",
"0.567909",
"0.5636329",
"0.562765",
"0.56133324",
"0.5553161",
"0.55471104",
"0.55366445",
"0.5535218",
"0.5534292",
"0.5531749",
"0.5505629",
"0.54945356",
"0.5477114",
"0.54692113",
"0.5455944... | 0.6880938 | 0 |
Adds ``documents`` to the document inventory, writing to disk in batches of 500,000. | def add_documents(self, documents):
# flag for StopIteration exceptions
more_documents = True
# loop while there are still documents in the iterator
while more_documents:
# increment batch number
batch = len(self.batch_stats) + 1
# count sentences
sentences_count = 0
# create temporary batch d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_documents(self, documents: list):\n requests = [\n {'PutRequest': {'Item': Item}} \n for Item in documents\n ]\n ticks = [d['symbol'] for d in documents]\n size = getsizeof(requests)\n exceptions = self.dynamo_client.exceptions\n errors = (e... | [
"0.74635196",
"0.68780833",
"0.6735508",
"0.66293705",
"0.65308714",
"0.64703435",
"0.6461322",
"0.6320846",
"0.6297765",
"0.6272216",
"0.61952156",
"0.618961",
"0.6179138",
"0.6159434",
"0.61464745",
"0.6131274",
"0.6127692",
"0.60197544",
"0.60097003",
"0.6002732",
"0.59492... | 0.73529315 | 1 |
Loads a document database with the specified version from the directory. | def load(db_path="data/documents/trigrams", version=None):
# create database at the desired path and with the desired version
db = DocumentDatabase(db_path, version)
# loop through batches
for batch in db._get_batches():
# get the path to the stats file
stats_file = db._get_batch_stat_file(batch)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_or_create_db(self):\n try:\n with open(self._filename, 'rb') as f:\n self.db = pickle.load(f)\n except FileNotFoundError:\n pass",
"def load_DB(self):\n\t\tprint 'Loadind Data Base...'\n\t\tstream = open(self.DB_file)\n\t\tself.DB = cPickle.load(stream)... | [
"0.6015772",
"0.59988827",
"0.59276336",
"0.5849796",
"0.5840075",
"0.5790545",
"0.5701773",
"0.56872916",
"0.5661583",
"0.56539536",
"0.56524754",
"0.5596583",
"0.5581138",
"0.5557227",
"0.5549356",
"0.5532614",
"0.55302",
"0.5490099",
"0.54712546",
"0.5464255",
"0.5438158",... | 0.7193331 | 0 |
Returns the latest version of the documents inventory at the specified path. | def get_latest_version(db_path):
# create a file system and return latest version
return VersionedFile(db_path).get_latest_version() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_version(self):\n try:\n return self.versions.latest()\n except DocumentVersion.DoesNotExist:\n return None",
"async def get_local_version(self, path):\n return_value = ''\n if os.path.isfile(path):\n with open(path, 'r') as local:\n ... | [
"0.64565796",
"0.59338427",
"0.59115607",
"0.5859803",
"0.58483046",
"0.5716326",
"0.5692346",
"0.5668634",
"0.56481016",
"0.5610619",
"0.56099266",
"0.556473",
"0.5553882",
"0.55534357",
"0.5535717",
"0.55330545",
"0.55328286",
"0.5523551",
"0.547328",
"0.54688823",
"0.54657... | 0.67488974 | 0 |
Returns OAuth2 credentials if we have valid credentials in the session. This is a 'truthy' value. Return None if we don't have credentials, or if they have expired or are otherwise invalid. This is a 'falsy' value. | def valid_credentials():
if 'credentials' not in flask.session:
return None
credentials = client.OAuth2Credentials.from_json(
flask.session['credentials'])
if (credentials.invalid or
credentials.access_token_expired):
return None
return credentials | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_credentials():\n if 'credentials' not in flask.session:\n return None\n\n credentials = client.OAuth2Credentials.from_json(\n flask.session['credentials'])\n\n if (credentials.invalid or credentials.access_token_expired):\n return None\n return credentials",
"def get_cr... | [
"0.8314805",
"0.67917407",
"0.66121364",
"0.6458647",
"0.644396",
"0.6412883",
"0.6292584",
"0.6262902",
"0.6216184",
"0.6159604",
"0.60996187",
"0.60749036",
"0.60712475",
"0.5996059",
"0.5910496",
"0.59005594",
"0.5890843",
"0.5890843",
"0.5890843",
"0.5890843",
"0.5890843"... | 0.83706456 | 1 |
Read time in a humancompatible format and interpret as ISO format with local timezone. May throw exception if time can't be interpreted. In that case it will also flash a message explaining accepted formats. | def interpret_time( text ):
app.logger.debug("Decoding time '{}'".format(text))
time_formats = ["ha", "h:mma", "h:mm a", "H:mm"]
try:
as_arrow = arrow.get(text, time_formats).replace(tzinfo=tz.tzlocal())
as_arrow = as_arrow.replace(year=2016) #HACK see below
app.logger.debug("Succe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpret_time(text):\n app.logger.debug(\"Decoding time '{}'\".format(text))\n time_formats = [\"ha\", \"h:mma\", \"h:mm a\", \"H:mm\"]\n try:\n as_arrow = arrow.get(text, time_formats).replace(tzinfo=tz.tzlocal())\n as_arrow = as_arrow.replace(year=2016) # HACK see below\n app... | [
"0.67903686",
"0.66916007",
"0.6613034",
"0.6586266",
"0.6439515",
"0.64221704",
"0.6381868",
"0.6360631",
"0.63137174",
"0.6284302",
"0.62411284",
"0.62141776",
"0.61804426",
"0.61793673",
"0.6178851",
"0.6156706",
"0.61117786",
"0.6111385",
"0.6104648",
"0.6101974",
"0.6100... | 0.6865028 | 0 |
Convert text of date to ISO format used internally, with the local time zone. | def interpret_date( text ):
try:
as_arrow = arrow.get(text, "MM/DD/YYYY").replace(
tzinfo=tz.tzlocal())
except:
flask.flash("Date '{}' didn't fit expected format 12/31/2001")
raise
return as_arrow.isoformat() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_to_iso(string):\r\n\r\n # disregard tokenisation, if it's there, to make this an easier conversion for GUTime\r\n string = re.sub(r'<([^~]*)~.+?>', r'\\1 ', string)\r\n\r\n # Defaults\r\n d = None\r\n m = None\r\n y = None\r\n h = None\r\n min = None\r\n s = None\r\n fs = Non... | [
"0.6905238",
"0.65572876",
"0.6553589",
"0.64506024",
"0.64370036",
"0.6369056",
"0.6347456",
"0.62363726",
"0.6200606",
"0.6184233",
"0.6160375",
"0.6148745",
"0.61423504",
"0.6141841",
"0.6125747",
"0.60974556",
"0.606667",
"0.60619223",
"0.6043991",
"0.60352457",
"0.603524... | 0.6582443 | 1 |
Given a google 'service' object, return a list of calendars. Each calendar is represented by a dict. The returned list is sorted to have the primary calendar first, and selected (that is, displayed in Google Calendars web app) calendars before unselected calendars. | def list_calendars(service):
app.logger.debug("Entering list_calendars")
calendar_list = service.calendarList().list().execute()["items"]
result = [ ]
for cal in calendar_list:
kind = cal["kind"]
id = cal["id"]
if "description" in cal:
desc = cal["description"]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_calendars(service):\n app.logger.debug(\"Entering list_calendars with service\")\n calendar_list = service.calendarList().list().execute()[\"items\"]\n app.logger.debug(\"Got calendar list\")\n result = []\n for cal in calendar_list:\n kind = cal[\"kind\"]\n id = cal[\"id\"]\n... | [
"0.82477534",
"0.6850524",
"0.6471131",
"0.63463163",
"0.63463163",
"0.63192886",
"0.62622386",
"0.6232313",
"0.61395335",
"0.61257684",
"0.6111868",
"0.61005104",
"0.603974",
"0.59506303",
"0.5812229",
"0.5798276",
"0.56924987",
"0.5668386",
"0.5658008",
"0.55682445",
"0.553... | 0.8079838 | 1 |
A helper method that generates a dictionary of arguments needed to instantiate a BaseBoto object. The purpose of this method is to abstract out the code to handle optional CLI arguments and not duplicate the None handling code. | def __get_arguments(args=None, logger=None, stats=None):
if not args:
parser = get_parser()
add_boto_cli_arguments(parser)
# Parse only the known arguments added by add_boto_cli_arguments().
# We only need those arguments to create Boto object, nothing else.
# parse_known_ar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_argdict(cls, toolchain, args):\n return {} # Empty must be overloaded (if required)",
"def GetArgs():\n \n UserArgs = {}\n UserArgs['help'] = False\n UserArgs['RsodFileName'] = \"\"\n UserArgs['BiosPathX64'] = \"\"\n\n for i in range(1,len(sys.argv)):\n if sys.argv[i].lo... | [
"0.64982295",
"0.6270005",
"0.60605526",
"0.6001975",
"0.5956914",
"0.5867535",
"0.586068",
"0.5848655",
"0.58337194",
"0.57882416",
"0.5759382",
"0.57521",
"0.5736829",
"0.57335955",
"0.572861",
"0.571756",
"0.5702735",
"0.5665511",
"0.5653056",
"0.5628118",
"0.5623889",
"... | 0.7327621 | 0 |
Return a usable Boto object without creating a class around it. In the context of a krux.cli (or similar) interface the 'args', 'logger' and 'stats' objects should already be present. If you don't have them, however, we'll attempt to provide usable ones for the boto setup. (If you omit the add_boto_cli_arguments() call... | def get_boto(args=None, logger=None, stats=None):
return Boto(**__get_arguments(args, logger, stats)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_boto3(args=None, logger=None, stats=None):\n return Boto3(**__get_arguments(args, logger, stats))",
"def __get_arguments(args=None, logger=None, stats=None):\n\n if not args:\n parser = get_parser()\n add_boto_cli_arguments(parser)\n # Parse only the known arguments added by ad... | [
"0.7120333",
"0.6446755",
"0.53901947",
"0.53732514",
"0.5315737",
"0.5265874",
"0.5252197",
"0.522644",
"0.5211605",
"0.521066",
"0.5205573",
"0.51422757",
"0.5054793",
"0.5037921",
"0.5032993",
"0.50301266",
"0.49558958",
"0.49513885",
"0.49364442",
"0.491438",
"0.49119216"... | 0.81121886 | 0 |
Return a usable Boto3 object without creating a class around it. In the context of a krux.cli (or similar) interface the 'args', 'logger' and 'stats' objects should already be present. If you don't have them, however, we'll attempt to provide usable ones for the boto setup. (If you omit the add_boto_cli_arguments() cal... | def get_boto3(args=None, logger=None, stats=None):
return Boto3(**__get_arguments(args, logger, stats)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_boto(args=None, logger=None, stats=None):\n return Boto(**__get_arguments(args, logger, stats))",
"def __get_arguments(args=None, logger=None, stats=None):\n\n if not args:\n parser = get_parser()\n add_boto_cli_arguments(parser)\n # Parse only the known arguments added by add_... | [
"0.767378",
"0.62587637",
"0.5730653",
"0.5656308",
"0.5650132",
"0.5583414",
"0.5518301",
"0.5486912",
"0.5486354",
"0.5425678",
"0.54201967",
"0.541126",
"0.5337484",
"0.5296419",
"0.5290054",
"0.52891475",
"0.52808595",
"0.5232185",
"0.52223915",
"0.5181535",
"0.5169401",
... | 0.81879747 | 0 |
Extract plastic class label from Image Name and return it | def ExtractLabel(ImgName):
# Each img has name notation "*****a0X*" where X is PlasticType
PlasticType = ImgName[7]
return {
'1': 0, # PET
'2': 1, # HDPE
'4': 2, # LDPE
'5': 3, # PP
'6': 4, # PS
'7': 5, # Other
}[PlasticType] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_to_label(self, name):\n\t\t\treturn self.classes[name]",
"def name_to_label(self, name):\n\t\treturn self.classes[name]",
"def get_imagenet_label(index):\n global _CLASS_INDEX\n if _CLASS_INDEX is None:\n with open(os.path.join(os.path.dirname(__file__), '../resources/imagenet_class_index... | [
"0.6750595",
"0.67307",
"0.6638844",
"0.6555292",
"0.6546279",
"0.65367347",
"0.64170223",
"0.6413202",
"0.6403757",
"0.6369213",
"0.63066596",
"0.6250891",
"0.6241231",
"0.6123709",
"0.6118442",
"0.61034334",
"0.60980034",
"0.6039952",
"0.6016841",
"0.60058093",
"0.5924414",... | 0.7817808 | 0 |
Support the following DHCP DeviceManager calls. self.plugin.release_dhcp_port(network.id, self.get_device_id(network)) | def release_dhcp_port(self, network_id, device_id):
LOG.debug("release_dhcp_port: %s %s", network_id, device_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release_dhcp_port(self, network_id, device_id):\n return self.call(self.context,\n self.make_msg('release_dhcp_port',\n network_id=network_id,\n device_id=device_id,\n ... | [
"0.8054723",
"0.71377176",
"0.6566923",
"0.6155076",
"0.5985578",
"0.59473217",
"0.58076227",
"0.5672177",
"0.5659102",
"0.5577378",
"0.5557",
"0.55073285",
"0.5491355",
"0.54843926",
"0.5454663",
"0.5447936",
"0.5415151",
"0.54091704",
"0.5385533",
"0.53768826",
"0.53333277"... | 0.84403765 | 0 |
Construct and return an empty network model. | def empty_network(network_id=NETWORK_ID):
return make_net_model({"id": network_id,
"subnets": [],
"ports": [],
"tenant_id": "calico",
"mtu": neutron_constants.DEFAULT_NETWORK_MTU}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_model():\n\n class Net(nn.Cell):\n def construct(self, x, y):\n return x\n\n net = Net()\n model_simple = Model(net)\n\n return model_simple",
"def create_network(self):\n\n print ('Creating network, changing data will have no effect beyond this point.')\n n... | [
"0.703458",
"0.6730677",
"0.6650045",
"0.66165984",
"0.65974486",
"0.65902346",
"0.6558993",
"0.645672",
"0.6456341",
"0.6397473",
"0.6397053",
"0.63881767",
"0.6345971",
"0.6332582",
"0.63210064",
"0.62721264",
"0.62575936",
"0.6252461",
"0.62491995",
"0.6246717",
"0.6237882... | 0.749267 | 0 |
Ensure that the cache has a NetModel and subnets for PORT. | def _ensure_net_and_subnets(self, port):
# Gather the subnet IDs that we need for this port, and get the
# NetModel if we already have it in the cache.
needed_subnet_ids = set()
net = None
for fixed_ip in port['fixed_ips']:
subnet_id = fixed_ip.get('subnet_id')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fix_network_cache_port_lookup(agent, network_id):\n\n # If there is an existing NetModel for this network ID, ensure that all\n # its ports are in the port_lookup dict.\n if network_id in agent.cache.cache:\n for port in agent.cache.cache[network_id].ports:\n agent.cache.port_lookup... | [
"0.5711651",
"0.5685266",
"0.5486034",
"0.5470297",
"0.53793174",
"0.53505814",
"0.52206916",
"0.520188",
"0.50624466",
"0.50617975",
"0.5060805",
"0.5031961",
"0.5029634",
"0.50271976",
"0.5011506",
"0.5004499",
"0.5002426",
"0.49931684",
"0.49833202",
"0.4974392",
"0.496706... | 0.7904054 | 0 |
Start/stop/restart Dnsmasq for NETWORK_ID. | def _update_dnsmasq(self, network_id):
# Check whether we should really do the following processing.
if self.suppress_dnsmasq_updates:
LOG.debug("Don't update dnsmasq yet;"
" must be processing a snapshot")
self.dirty_networks.add(network_id)
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def startServices():\n # dnsmasq\n out_dnsmasq = subprocess.run([\"systemctl\", \"restart\", \"dnsmasq\"], stdout=subprocess.PIPE)\n if out_dnsmasq.returncode == 0:\n logging.info(\"dnsmasq service started/restarted successfully\")\n else:\n logging.error(\"dnsmasq service start restart e... | [
"0.57506925",
"0.5736145",
"0.5705236",
"0.5628683",
"0.56053996",
"0.55890465",
"0.5588804",
"0.5274913",
"0.5227108",
"0.5199843",
"0.5196082",
"0.5161446",
"0.51592255",
"0.51375973",
"0.51361805",
"0.51020324",
"0.50229216",
"0.49852252",
"0.49827528",
"0.49735984",
"0.49... | 0.6410348 | 0 |
Fix NetworkCache before removing or replacing a network. neutron.agent.dhcp.agent is bugged in that it adds the DHCP port into the cache without updating the cache's port_lookup dict, but then NetworkCache.remove() barfs if there is a port in network.ports but not in that dict... NetworkCache.put() implicitly does a re... | def _fix_network_cache_port_lookup(agent, network_id):
# If there is an existing NetModel for this network ID, ensure that all
# its ports are in the port_lookup dict.
if network_id in agent.cache.cache:
for port in agent.cache.cache[network_id].ports:
agent.cache.port_lookup[port.id] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ensure_net_and_subnets(self, port):\n\n # Gather the subnet IDs that we need for this port, and get the\n # NetModel if we already have it in the cache.\n needed_subnet_ids = set()\n net = None\n for fixed_ip in port['fixed_ips']:\n subnet_id = fixed_ip.get('subne... | [
"0.6243899",
"0.5750837",
"0.55582297",
"0.5493871",
"0.54649335",
"0.53545606",
"0.5274179",
"0.52181244",
"0.51568764",
"0.51559347",
"0.5134361",
"0.51047474",
"0.5044345",
"0.5022658",
"0.50088584",
"0.50081223",
"0.50078607",
"0.49672914",
"0.4941016",
"0.49056178",
"0.4... | 0.7541457 | 0 |
Run the EtcdWatcher loop. | def run(self):
self.etcd.start() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n watcher = self._watcher(self.on_recv)\n watcher.loop()",
"def run(self):\n logging.basicConfig(level=logging.INFO,\n format='%(asctime)s - %(message)s',\n datefmt='%Y-%m-%d %H:%M:%S')\n\n event_handler = PatternMat... | [
"0.60920537",
"0.60423386",
"0.6004358",
"0.59458005",
"0.5935371",
"0.5914737",
"0.5896926",
"0.58915985",
"0.58893985",
"0.5884968",
"0.58668745",
"0.5844063",
"0.5844063",
"0.58165354",
"0.58041525",
"0.58041525",
"0.5799248",
"0.57745546",
"0.57614356",
"0.5740617",
"0.57... | 0.6893604 | 0 |
Compiles robot from given file and returns class object | def compile_robot(file_name, module_name = "contestant_module"):
global counter_module
module_name += str(counter_module)
counter_module += 1
mod = importCode(file_name, module_name)
compiled_class = None
for symbol in dir(mod):
if hasattr(getattr(mod, symbol), "act") and getattr(mod, s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepareRobot(self):\n f = StringIO.StringIO()\n f.write(self.zipfile)\n\n zip = zipfile.ZipFile(f)\n \n #modules of the form {\"robot\" : \"from sr import *...\", ...}\n modules = dict([(os.path.splitext(z.filename)[0], zip.open(z.filename).read())\n ... | [
"0.5830989",
"0.55374384",
"0.55307627",
"0.54860145",
"0.54444677",
"0.5422501",
"0.5409071",
"0.5406872",
"0.5393358",
"0.5390054",
"0.5387643",
"0.52916986",
"0.52400696",
"0.5232065",
"0.522042",
"0.5217083",
"0.52124226",
"0.52053887",
"0.5201384",
"0.5178366",
"0.517518... | 0.7441334 | 0 |
Prepare normalized image and label. | def _prepare_image_and_label(self, data):
image = tf.io.decode_image(data['image/encoded'], channels=3)
label = tf.io.decode_image(data['image/segmentation/class/encoded'],
channels=1)
height = data['image/height']
width = data['image/width']
image = tf.reshape(image, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(image, label):\n image -= settings.DATASET_MEAN\n image /= settings.DATASET_STD\n\n return image, label",
"def img_normalize(image, label):\n mean, std = ds_stats\n image -= tf.constant(mean, shape=[1, 1, num_channels], dtype=image.dtype)\n image /= tf.constant(std, shape=[1, 1, n... | [
"0.70676106",
"0.68583",
"0.66364515",
"0.65736663",
"0.6464647",
"0.64554685",
"0.6352765",
"0.6297984",
"0.625139",
"0.62383085",
"0.62295324",
"0.62290204",
"0.62271994",
"0.6218579",
"0.61705977",
"0.6143832",
"0.61042327",
"0.60809606",
"0.60745084",
"0.60027677",
"0.598... | 0.72255284 | 0 |
Parses data for prediction. | def _parse_predict_data(self, data):
image, labels = self._parse_eval_data(data)
return {
'images': image,
'labels': labels
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_dataset(self, data):\n pass",
"def predict(self, datafile):",
"def predict(self, data: List):",
"def predict(self, data):\n\t\traise NotImplementedError",
"def postprocess(self, data):\n all_predictions, all_nbest_json, scores_diff_json = predictions(self._dev_dataset,\n ... | [
"0.70179003",
"0.68369985",
"0.67741996",
"0.6700655",
"0.665754",
"0.6550395",
"0.6539271",
"0.6422481",
"0.6383678",
"0.63100535",
"0.6299874",
"0.62833273",
"0.6269634",
"0.6264631",
"0.6253759",
"0.62460303",
"0.62442476",
"0.621106",
"0.6204033",
"0.6197395",
"0.61885244... | 0.7601515 | 0 |
If an iteriter_op is given an iterator as input, no exception should be thrown, and we should return the wrapped function's output. | def test_iteriter_op_1():
@ops.iteriter_op
def f(x):
return iter([4, 5, 6])
result = f(iter([1, 2, 3])) # Passing in an iterator, as expected
assert(isinstance(result, collections.abc.Iterator)), f"{result}"
assert(list(result) == [4, 5, 6]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_iteriter_op_3():\n\n @ops.iteriter_op\n def f(x):\n return [4, 5, 6] # Returning a list instead of an iterator\n\n with pytest.raises(ValueError):\n result = f(iter([1, 2, 3]))",
"def test_iteriter_op_2():\n\n @ops.iteriter_op\n def f(x):\n return iter([4, 5, 6])\n\n... | [
"0.734651",
"0.7288327",
"0.6928596",
"0.6799886",
"0.66857606",
"0.6591529",
"0.6551025",
"0.6511721",
"0.63353145",
"0.59754914",
"0.5973058",
"0.59268594",
"0.5852119",
"0.58467436",
"0.5843037",
"0.583689",
"0.57858115",
"0.5740564",
"0.5712443",
"0.56730723",
"0.5633042"... | 0.74068475 | 0 |
If an iteriter_op is given something besides an iterator as input, raise a ValueError. | def test_iteriter_op_2():
@ops.iteriter_op
def f(x):
return iter([4, 5, 6])
with pytest.raises(ValueError):
f([1, 2, 3]) # Passing in a list instead of an iterator | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_iteriter_op_3():\n\n @ops.iteriter_op\n def f(x):\n return [4, 5, 6] # Returning a list instead of an iterator\n\n with pytest.raises(ValueError):\n result = f(iter([1, 2, 3]))",
"def test_listiter_op_2():\n\n @ops.listiter_op\n def f(x):\n return iter([4, 5, 6])\n\n... | [
"0.7217243",
"0.7193178",
"0.6957775",
"0.68198645",
"0.6498388",
"0.6485671",
"0.63076574",
"0.6105469",
"0.58576494",
"0.5822482",
"0.57532716",
"0.57530195",
"0.5725821",
"0.56677824",
"0.5644975",
"0.5638798",
"0.5572163",
"0.5566992",
"0.5561028",
"0.5558914",
"0.5509184... | 0.75408363 | 0 |
If an iteriter_op returns something besides an iterator as output, raise a ValueError. | def test_iteriter_op_3():
@ops.iteriter_op
def f(x):
return [4, 5, 6] # Returning a list instead of an iterator
with pytest.raises(ValueError):
result = f(iter([1, 2, 3])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_iteriter_op_2():\n\n @ops.iteriter_op\n def f(x):\n return iter([4, 5, 6])\n\n with pytest.raises(ValueError):\n f([1, 2, 3]) # Passing in a list instead of an iterator",
"def test_listiter_op_2():\n\n @ops.listiter_op\n def f(x):\n return iter([4, 5, 6])\n\n with... | [
"0.76426315",
"0.73116994",
"0.7197692",
"0.69156325",
"0.6845044",
"0.6789451",
"0.63753885",
"0.6361283",
"0.62555766",
"0.6095181",
"0.6085253",
"0.59735376",
"0.5929287",
"0.5857033",
"0.58470154",
"0.58267",
"0.57885355",
"0.57856303",
"0.57807213",
"0.576038",
"0.573720... | 0.7515847 | 1 |
If a listlist_op is given a list as input, no exception should be thrown, and we should return the wrapped function's output. | def test_listlist_op_1():
@ops.listlist_op
def f(x):
return [4, 5, 6]
result = f([1, 2, 3]) # Passing in a list, as expected
assert(isinstance(result, list)), f"{result}"
assert(result == [4, 5, 6]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_listlist_op_3():\n\n @ops.listlist_op\n def f(x):\n return iter([4, 5, 6]) # Returning an iterator instead of an list\n\n with pytest.raises(ValueError):\n result = f([1, 2, 3])",
"def test_listlist_op_2():\n\n @ops.listlist_op\n def f(x):\n return [4, 5, 6]\n\n w... | [
"0.7166146",
"0.71624446",
"0.7014189",
"0.6786135",
"0.6684333",
"0.6671589",
"0.6536824",
"0.6533272",
"0.6519165",
"0.64344203",
"0.6429467",
"0.64098346",
"0.6329758",
"0.6261592",
"0.6214731",
"0.61999166",
"0.6112252",
"0.6028815",
"0.6003266",
"0.5961093",
"0.5949775",... | 0.77922696 | 0 |
If a listlist_op is given something besides a list as input, raise a ValueError. | def test_listlist_op_2():
@ops.listlist_op
def f(x):
return [4, 5, 6]
with pytest.raises(ValueError):
f(iter([1, 2, 3])) # Passing in an iterator instead of an list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_listlist_op_3():\n\n @ops.listlist_op\n def f(x):\n return iter([4, 5, 6]) # Returning an iterator instead of an list\n\n with pytest.raises(ValueError):\n result = f([1, 2, 3])",
"def is_listing(op):\n return isinstance(op, (list, tuple))",
"def test_neg_operate_list_invalid_... | [
"0.6896146",
"0.6843723",
"0.6687192",
"0.66674805",
"0.6584861",
"0.650589",
"0.64047855",
"0.6385669",
"0.6318132",
"0.62996775",
"0.6293289",
"0.62533414",
"0.6251247",
"0.62425464",
"0.62239265",
"0.62199765",
"0.6166311",
"0.61608076",
"0.6119108",
"0.6056942",
"0.600924... | 0.71428686 | 0 |
If a listlist_op returns something besides a list as output, raise a ValueError. | def test_listlist_op_3():
@ops.listlist_op
def f(x):
return iter([4, 5, 6]) # Returning an iterator instead of an list
with pytest.raises(ValueError):
result = f([1, 2, 3]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_listlist_op_2():\n\n @ops.listlist_op\n def f(x):\n return [4, 5, 6]\n\n with pytest.raises(ValueError):\n f(iter([1, 2, 3])) # Passing in an iterator instead of an list",
"def test_listlist_op_1():\n\n @ops.listlist_op\n def f(x):\n return [4, 5, 6]\n\n result = ... | [
"0.73349303",
"0.71511084",
"0.6736014",
"0.66537863",
"0.6652018",
"0.6627136",
"0.65927994",
"0.6493474",
"0.6485327",
"0.6485104",
"0.64288867",
"0.6416885",
"0.6406958",
"0.63908684",
"0.63792086",
"0.6378879",
"0.63132125",
"0.6302996",
"0.6289423",
"0.62221825",
"0.6194... | 0.72641724 | 1 |
If a listiter_op is given a list as input, no exception should be thrown, and we should return the wrapped function's output. | def test_listiter_op_1():
@ops.listiter_op
def f(x):
return iter([4, 5, 6])
result = f([1, 2, 3]) # Passing in a list, as expected
assert(isinstance(result, collections.abc.Iterator)), f"{result}"
assert(list(result) == [4, 5, 6]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_iterlist_op_1():\n\n @ops.iterlist_op\n def f(x):\n return [4, 5, 6]\n\n result = f(iter([1, 2, 3])) # Passing in an iterator, as expected\n\n assert(isinstance(result, list)), f\"{result}\"\n assert(result == [4, 5, 6])",
"def test_listiter_op_3():\n\n @ops.listiter_op\n de... | [
"0.7756567",
"0.75442225",
"0.75318354",
"0.75228345",
"0.747424",
"0.74187565",
"0.7351864",
"0.71246946",
"0.6990763",
"0.6881843",
"0.68182045",
"0.66678816",
"0.65725154",
"0.65193516",
"0.62121695",
"0.6203566",
"0.59676445",
"0.5919752",
"0.5807262",
"0.5753957",
"0.565... | 0.76254886 | 1 |
If a listiter_op is given something besides a list as input, raise a ValueError. | def test_listiter_op_2():
@ops.listiter_op
def f(x):
return iter([4, 5, 6])
with pytest.raises(ValueError):
f(iter([1, 2, 3])) # Passing in an iterator instead of a list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_listlist_op_2():\n\n @ops.listlist_op\n def f(x):\n return [4, 5, 6]\n\n with pytest.raises(ValueError):\n f(iter([1, 2, 3])) # Passing in an iterator instead of an list",
"def test_iterlist_op_2():\n\n @ops.iterlist_op\n def f(x):\n return [4, 5, 6]\n\n with pyte... | [
"0.76405627",
"0.7451966",
"0.7407579",
"0.73711157",
"0.7272287",
"0.6842472",
"0.67784035",
"0.6713179",
"0.65655285",
"0.6331",
"0.62677497",
"0.62505025",
"0.6126729",
"0.6060513",
"0.60524344",
"0.60413057",
"0.5994478",
"0.5923151",
"0.5910163",
"0.5815476",
"0.5803793"... | 0.75528175 | 1 |
If an iterlist_op is given an iterator as input, no exception should be thrown, and we should return the wrapped function's output. | def test_iterlist_op_1():
@ops.iterlist_op
def f(x):
return [4, 5, 6]
result = f(iter([1, 2, 3])) # Passing in an iterator, as expected
assert(isinstance(result, list)), f"{result}"
assert(result == [4, 5, 6]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_listiter_op_2():\n\n @ops.listiter_op\n def f(x):\n return iter([4, 5, 6])\n\n with pytest.raises(ValueError):\n f(iter([1, 2, 3])) # Passing in an iterator instead of a list",
"def test_listiter_op_1():\n\n @ops.listiter_op\n def f(x):\n return iter([4, 5, 6])\n\n ... | [
"0.76466507",
"0.76008874",
"0.7570353",
"0.7508546",
"0.74234086",
"0.7396815",
"0.7382202",
"0.73407215",
"0.7291801",
"0.72297966",
"0.6824224",
"0.666192",
"0.6128793",
"0.60040385",
"0.5923186",
"0.58794075",
"0.58676404",
"0.57020146",
"0.56718487",
"0.5595165",
"0.5567... | 0.76173055 | 1 |
If a pool of size 3 is used, the first 3 individuals in the input iterator should be collected into a list. | def test_pool():
pop = iter([ 'a', 'b', 'c', 'd', 'e' ])
pop = ops.pool(pop, size=3)
assert(len(pop) == 3)
assert(pop == [ 'a', 'b', 'c' ]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lazy_groups_of(iterator: Iterator[A], group_size: int) -> Iterator[List[A]]:\n return iter(lambda: list(islice(iterator, 0, group_size)), [])",
"def construct(self, x):\n results = []\n x = self.pool0(x)\n results.append(x)\n x = self.pool1(x)\n results.append(x)\n ... | [
"0.640328",
"0.6058334",
"0.58099174",
"0.5747291",
"0.57104117",
"0.5681089",
"0.56514186",
"0.5616282",
"0.56008047",
"0.55808794",
"0.5538672",
"0.5503756",
"0.5503756",
"0.54849136",
"0.5432563",
"0.54290795",
"0.54290795",
"0.54163194",
"0.54163116",
"0.5399655",
"0.5391... | 0.7016338 | 0 |
Converts a wave to a vector of prosodic features. offset (in ms) determines where the signal will be sampled. window_len is ignored. | def wav_to_prosodic(path, sr=16000, offset=10):
sound = parselmouth.Sound(path)
pitch = sound.to_pitch() #timestep, pitch_floor, pitch_ceiling
intensity = sound.to_intensity()
features = []
max_time = sound.get_total_duration()
for time in np.arange(0, max_time, 0.001):
f0 = pitch.get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _choose_wavelength_slice(self, offset):\n if 'WAVE' not in self.axes_wcs.wcs.ctype:\n raise cu.CubeError(2, \"Spectral dimension not present\")\n if self.data.ndim == 4:\n raise cu.CubeError(4, \"Can only work with 3D cubes\")\n\n axis = -2 if self.axes_wcs.wcs.ctype[... | [
"0.5480287",
"0.5404212",
"0.5282063",
"0.50624555",
"0.50224143",
"0.50093454",
"0.4989605",
"0.49353826",
"0.486388",
"0.48465458",
"0.4828349",
"0.47970074",
"0.47777593",
"0.47630838",
"0.4727671",
"0.47226426",
"0.4674579",
"0.4674468",
"0.46724492",
"0.46629953",
"0.464... | 0.6025671 | 0 |
Print percentage of rows that have been processed. | def _print_stat_rows(title,rows_before,rows_after):
self.strprint(str(title)+" : Percent of processed rows = %1.2F"\
%(np.abs(rows_before-rows_after)*100/rows_before)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printProgress(self, percentage):\n #print '%s\\r' % ' '*20, # clean up row\n #print '%3d%% ' % percentage, # ending with comma prevents newline from being appended\n sys.stdout.flush()",
"def PrintProgress(self):\n print ' Examined %d nodes, found %d unique...' % (\n ... | [
"0.7295432",
"0.690456",
"0.6810523",
"0.65595317",
"0.64016294",
"0.63650185",
"0.63531333",
"0.6352935",
"0.6349985",
"0.6310579",
"0.6283685",
"0.6247981",
"0.6222485",
"0.6173231",
"0.61398053",
"0.61388904",
"0.61365205",
"0.6132179",
"0.61136687",
"0.61033106",
"0.60934... | 0.74636936 | 0 |
Remove raws with countries other then 'United Kingdom' then remove Country feature. | def _feature_country_process(self):
if 'Country' not in self._df_invoice_line.columns:
return
list_countries_keep = ['United Kingdom']
rows_before = self._df_invoice_line.shape[0]
df_invoice_line_new = pd.DataFrame()
for country in list_countries_keep :
df_invoic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_feature_filter(self):\n self.features = set()\n for language in self.data.values():\n features_in_data = set(language.keys())\n features_to_keep = features_in_data & self.feature_filter\n self.features |= features_to_keep\n features_to_remove = fe... | [
"0.59036386",
"0.5863824",
"0.5825038",
"0.5797917",
"0.5704074",
"0.5514831",
"0.55131525",
"0.5411934",
"0.5399952",
"0.53786814",
"0.53708786",
"0.53605676",
"0.5328933",
"0.53094655",
"0.51719415",
"0.5159425",
"0.51442134",
"0.5126341",
"0.51245403",
"0.50806504",
"0.506... | 0.70100856 | 0 |
Builds features issued from InvoiceDate. A dataframe is built per new feature and dumped into a file. Each one of the dataframe have encoded features issues from InvoiceDate. | def data_transform_timeFeature(self):
#-------------------------------------------------------------------------
# All new features are built into separate dataframes
# and each of them are dumped into a separate file.
#-------------------------------------------------------------------------
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_date_features(df = None, date = None):\n #TODO",
"def data_transform_rfm(self) :\n \n is_built_step = False\n if self._encoder_rfm is None:\n is_built_step = True \n \n #-------------------------------------------------------------------------\n # RFM feature ... | [
"0.6386668",
"0.6208587",
"0.62022436",
"0.60953605",
"0.60796374",
"0.60608006",
"0.6022764",
"0.5993953",
"0.5985361",
"0.59586924",
"0.5820426",
"0.5809583",
"0.58089864",
"0.58070034",
"0.5787359",
"0.575435",
"0.57058054",
"0.56917906",
"0.56418794",
"0.56213087",
"0.560... | 0.62781596 | 1 |
Builds for each customer, RFM scores and encode scores. When this method is called during building data_model step, then dataframe handling new RFM features is dumped into a file. | def data_transform_rfm(self) :
is_built_step = False
if self._encoder_rfm is None:
is_built_step = True
#-------------------------------------------------------------------------
# RFM feature is built
#--------------------------------------------------------------... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def df_customers_fileRead(self):\n \n #-------------------------------------------------------------------------\n # RFM features are restored\n #-------------------------------------------------------------------------\n df_customers_rfm \\\n = p5_util.object_load(self.df_customer... | [
"0.70747465",
"0.7067084",
"0.62919354",
"0.6007114",
"0.58264214",
"0.5718458",
"0.560313",
"0.56008935",
"0.55872756",
"0.55600125",
"0.5532584",
"0.5520967",
"0.55154175",
"0.5512787",
"0.54379237",
"0.53890693",
"0.53649795",
"0.5364341",
"0.53604376",
"0.53556436",
"0.53... | 0.724281 | 0 |
Creates new features from Description feature thanks to NLTK, a NLP package. NLP features are handled into a dataframe. A PCA reduction is applied on this dataframe. Features from dataframe are renamed with root ane w_nlp. When this method is called during building data_model step, then dataframe handling new NLP featu... | def data_transform_nlp(self):
df_invoice_line = None
is_build_step = False
if self._vectorizer_nlp is None:
is_build_step = True
list_no_words=['SET','PACK']
df_invoice_line, csr_matrix_weights, self._vectorizer_nlp \
= p5_util.nlp_process(self.df_invoice_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature_description_nlp(self):\n \n #-------------------------------------------------------------------------\n # Returned dataframe is aggregated with weights from self.vectorizer\n #-------------------------------------------------------------------------\n list_no_words=['SET','PAC... | [
"0.7509502",
"0.63895476",
"0.63655084",
"0.6190819",
"0.61304533",
"0.60974437",
"0.6039494",
"0.6013443",
"0.6001541",
"0.59564126",
"0.59309864",
"0.584246",
"0.58098847",
"0.5809157",
"0.5786593",
"0.57630605",
"0.57536405",
"0.57465136",
"0.57437116",
"0.5743342",
"0.574... | 0.6648716 | 1 |
Build dataframe df_customers from transformed data. Transformed data are issued from NLP, Time and RFM features. See data_transform(). These data are stored as dataframes attributes. | def df_customers_features_build(self):
df_customers_rfm = self._df_customers_rfm.copy()
df_customers_timeFeature = self._df_customers_timeFeature.copy()
df_customers_nlp = self._df_customers_pca_nlp.copy()
#-------------------------------------------------------------------------
# Dataf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def features_customers(df_customers):\n for i in PREMIER_VALS:\n k = 'premier_' + str(i)\n df_customers[k] = np.where(df_customers['premier'] == i, 1, 0)\n\n df_customers['age'] = datetime.now().date().year - df_customers['yearOfBirth']\n df_customers['male'] = np.where(df_customers['gender'... | [
"0.70902693",
"0.6727287",
"0.6064118",
"0.60265195",
"0.6024846",
"0.5994544",
"0.596741",
"0.58626324",
"0.584423",
"0.5838772",
"0.5787832",
"0.5785175",
"0.5773647",
"0.5766124",
"0.5743439",
"0.57312465",
"0.57225657",
"0.5721255",
"0.5717279",
"0.5693215",
"0.5649832",
... | 0.80397373 | 0 |
Build dataframe df_customers from transformed data. Transformed data are loaded from dumped files issued from NLP, Time and RFM features. See data_transform() | def df_customers_fileRead(self):
#-------------------------------------------------------------------------
# RFM features are restored
#-------------------------------------------------------------------------
df_customers_rfm \
= p5_util.object_load(self.df_customers_rfm_fileNa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def df_customers_features_build(self):\n\n df_customers_rfm = self._df_customers_rfm.copy()\n df_customers_timeFeature = self._df_customers_timeFeature.copy()\n df_customers_nlp = self._df_customers_pca_nlp.copy()\n\n #-------------------------------------------------------------------------\n ... | [
"0.78012073",
"0.70509386",
"0.6482284",
"0.6199711",
"0.5975251",
"0.5896229",
"0.58942175",
"0.5884299",
"0.5793099",
"0.57307404",
"0.5701118",
"0.568415",
"0.56560767",
"0.5655341",
"0.56509733",
"0.5625573",
"0.5603968",
"0.55976146",
"0.55959636",
"0.5586056",
"0.557069... | 0.7298348 | 1 |
Creates a new customer identifier from existing dataset. | def createCustomerID(self):
customerID = self._df_invoice_original.CustomerID.max()
customerID += 1
return int(customerID) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customer_id(uncapped_flatprice, uncapped_flatprice_finalizer, team_multisig) -> int:\n customer_id = int(uuid.uuid4().hex, 16) # Customer ids are 128-bit UUID v4\n return customer_id",
"def create_customer(cls, api, **data):\n return api.create_customer(**data)",
"def create_customer(data):\n... | [
"0.6462454",
"0.63013685",
"0.6199043",
"0.6019253",
"0.60129994",
"0.60011494",
"0.59338015",
"0.59171224",
"0.5879934",
"0.58377534",
"0.5820006",
"0.5756114",
"0.5745354",
"0.57360977",
"0.57085544",
"0.5678208",
"0.5672292",
"0.56669915",
"0.56526893",
"0.5649953",
"0.564... | 0.6483069 | 0 |
Drop from df_invoice_line dataframe features in list given as parameter. All elements from list are checked to be into dataframe columns. | def list_feature_drop(self):
list_to_drop = list()
list_not_in_df = list()
#-------------------------------------------------------------------------
# Columns are checked to be into df_invoice_line dataframe
#------------------------------------------------------------------... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_dfcol(self, drop_list):\n self.data = self.df\n for lbl in drop_list:\n self.data = self.data.drop(lbl, axis=1)\n self.n_features = np.shape(self.data)[1]",
"def drop(self,df, column_list):\n df.drop(columns = column_list, inplace = True)\n return df",
"de... | [
"0.6483683",
"0.61852366",
"0.61701894",
"0.61167115",
"0.5998328",
"0.5879889",
"0.5828969",
"0.57773757",
"0.57595223",
"0.56772375",
"0.55653924",
"0.55105036",
"0.5499361",
"0.5488699",
"0.5475562",
"0.54356617",
"0.5433665",
"0.5431893",
"0.54176056",
"0.5401929",
"0.537... | 0.7785573 | 0 |
Process df_invoice_line.Description with NLTK package. | def feature_description_nlp(self):
#-------------------------------------------------------------------------
# Returned dataframe is aggregated with weights from self.vectorizer
#-------------------------------------------------------------------------
list_no_words=['SET','PACK']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_process_deprecated(self, CustomerID, InvoiceDate, InvoiceNo, Description, Quantity\\\n , UnitPrice ):\n dict_invoice = {'InvoiceDate':InvoiceDate, 'Description':Description\\\n , 'Quantity':Quantity, 'UnitPrice':UnitPrice}\n dict_invoice['CustomerID'] = CustomerID\n dict_invoice['Inv... | [
"0.5984977",
"0.5817351",
"0.5476201",
"0.5464979",
"0.54381603",
"0.5437341",
"0.539142",
"0.5348691",
"0.53211063",
"0.5294485",
"0.5236899",
"0.51855206",
"0.51376784",
"0.51221997",
"0.50945246",
"0.50891274",
"0.5085302",
"0.50443596",
"0.5012782",
"0.5011681",
"0.493943... | 0.7215489 | 0 |
Standardize quantitatives features. Standardizer is stored as object attribute. It will be copied into P5_SegmentClassifier object. | def feature_scale(self):
#-------------------------------------------------------------------------
# List of quantitative features to be standardized
#-------------------------------------------------------------------------
list_quant_feature = ['Quantity','UnitPrice']
self._list_qua... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def standardiser(self):\n # Select only numeric features first\n\n #self.X = self.data.loc[:, self.data.columns != self.target].values\n numeric_columns = []\n for col in self.X.columns:\n if self.X[col].dtype!='object':\n numeric_columns.append(col)\n s... | [
"0.66549325",
"0.5813407",
"0.57823",
"0.57652164",
"0.57482",
"0.5628171",
"0.56227326",
"0.54852945",
"0.54692763",
"0.5413241",
"0.5376666",
"0.53717995",
"0.5229775",
"0.51795113",
"0.5171377",
"0.51348805",
"0.51237977",
"0.5088582",
"0.5076588",
"0.50762415",
"0.5056169... | 0.64846426 | 1 |
Returns market segment ID related to a customer thanks to customer invoices lines given as parameter. Features transformations are applied on data included into invoice lines. Once done, a machine learning algorithm is invocated in order to predict customer market segment. | def get_customer_marketSegment(self, df_invoice_line_customer):
#-------------------------------------------------------------------------
# Building data model
#-------------------------------------------------------------------------
self.data_transform(df_invoice_line_customer)
#-----... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_segment(self, df_invoice_line=None):\n if df_invoice_line is not None:\n self.data_transform(df_invoice_line) \n self.df_customers_features_build() \n else:\n pass\n X_test = self._df_customers.values\n y_pred = self._classifier_model.predict(X_test)\n... | [
"0.7056929",
"0.62926954",
"0.61490464",
"0.6014562",
"0.59545195",
"0.5511189",
"0.54317766",
"0.5338872",
"0.53378683",
"0.53256035",
"0.5227046",
"0.5198791",
"0.5182063",
"0.51410466",
"0.5138717",
"0.51151025",
"0.51103526",
"0.51066583",
"0.5078583",
"0.5048637",
"0.502... | 0.81526893 | 0 |
This function creates an invoice compounding invoices lines from data given as parameters. Once done, this function computes market segment customer belongs to. If customerID is None, then a new customer identifier is created before order process to take place. | def order_process(self, customerID, list_stockCode, list_quantity\
, orderDate=None):
segmentID = -1
#-------------------------------------------------------------------------
# A new customer is created and inserted into data-set.
#----------------------------------------------------------... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_customer_df_invoice_line(self, customerID, list_stockCode\\\n , list_quantity, invoiceDate):\n \n dict_invoice = dict()\n\n dict_invoice['Quantity'] = list_quantity\n dict_invoice['StockCode'] = list_stockCode\n\n #--------------------------------------------------------------... | [
"0.65959746",
"0.6386151",
"0.6226632",
"0.5918294",
"0.58827716",
"0.5865145",
"0.5850917",
"0.58120507",
"0.57048744",
"0.57040673",
"0.563682",
"0.56352204",
"0.5545573",
"0.55451196",
"0.5510552",
"0.5419621",
"0.54099417",
"0.5400348",
"0.53597164",
"0.5323142",
"0.53154... | 0.68115205 | 0 |
Return the segment identifier a customers is predicted to belongs to. | def predict_segment(self, df_invoice_line=None):
if df_invoice_line is not None:
self.data_transform(df_invoice_line)
self.df_customers_features_build()
else:
pass
X_test = self._df_customers.values
y_pred = self._classifier_model.predict(X_test)
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_customer_marketSegment(self, df_invoice_line_customer):\n #-------------------------------------------------------------------------\n # Building data model \n #-------------------------------------------------------------------------\n self.data_transform(df_invoice_line_customer)\n\n ... | [
"0.768172",
"0.6201237",
"0.61484486",
"0.5937784",
"0.5902539",
"0.5902539",
"0.58263624",
"0.57347125",
"0.5691365",
"0.56732774",
"0.5623136",
"0.55613863",
"0.5555856",
"0.5535719",
"0.5528222",
"0.55247766",
"0.5446849",
"0.54316",
"0.5398863",
"0.5389348",
"0.52877736",... | 0.63881826 | 1 |
Returns list of stock codes from list of items descriptions. | def getStockCodeList(self, list_description=None):
list_stockCode = list()
df = self._df_invoice_original
if list_description is None:
list_stockCode = list(df.StockCode.unique())
else :
for description in list_description:
stockCode = df[df.Description==desc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDescriptionList(self, list_stockCode=None):\n df = self._df_invoice_original\n\n list_description = list()\n if list_stockCode is None :\n list_description = list(df.Description.unique())\n else:\n for stockCode in list_stockCode:\n description = df[df.StockCod... | [
"0.63454723",
"0.5953065",
"0.58789575",
"0.5782579",
"0.5730202",
"0.551616",
"0.5417973",
"0.5402704",
"0.5288644",
"0.5257909",
"0.5255299",
"0.5200416",
"0.5199842",
"0.51931006",
"0.5064142",
"0.50508547",
"0.50235844",
"0.49738976",
"0.4950196",
"0.49323055",
"0.4927703... | 0.7344879 | 0 |
Returns list of imtes unit price from list of stock codes. | def getUnitPriceList(self, list_stockCode):
df = self._df_invoice_original
list_unitPrice = list()
for stockCode in list_stockCode:
unitPrice = df[df.StockCode==stockCode].UnitPrice.unique()[0]
list_unitPrice.append(unitPrice)
return list_unitPrice | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getStockCodeList(self, list_description=None):\n list_stockCode = list()\n df = self._df_invoice_original\n \n if list_description is None:\n list_stockCode = list(df.StockCode.unique())\n else :\n for description in list_description:\n stockCode = df[df.Desc... | [
"0.6023552",
"0.5827989",
"0.5810261",
"0.57817996",
"0.57182974",
"0.5632579",
"0.55539757",
"0.5493873",
"0.5484011",
"0.54804665",
"0.54708654",
"0.5443625",
"0.5422661",
"0.5405019",
"0.5299616",
"0.5295281",
"0.527327",
"0.5272383",
"0.52600485",
"0.52459085",
"0.5221727... | 0.8246834 | 0 |
Returns list of items descriptions from list of stock codes. | def getDescriptionList(self, list_stockCode=None):
df = self._df_invoice_original
list_description = list()
if list_stockCode is None :
list_description = list(df.Description.unique())
else:
for stockCode in list_stockCode:
description = df[df.StockCode==stockCode]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getStockCodeList(self, list_description=None):\n list_stockCode = list()\n df = self._df_invoice_original\n \n if list_description is None:\n list_stockCode = list(df.StockCode.unique())\n else :\n for description in list_description:\n stockCode = df[df.Desc... | [
"0.65685076",
"0.566973",
"0.5336407",
"0.5295758",
"0.51715976",
"0.51711005",
"0.5148782",
"0.5139008",
"0.508993",
"0.5061929",
"0.5032067",
"0.49966037",
"0.49956048",
"0.4957243",
"0.4957215",
"0.4956653",
"0.49447757",
"0.49301252",
"0.4907753",
"0.49050713",
"0.4902797... | 0.7398652 | 0 |
Creates new dataframe with invoices lines issued from given parameters. Once done, the new dataframe is aggregated with original one. | def create_customer_df_invoice_line(self, customerID, list_stockCode\
, list_quantity, invoiceDate):
dict_invoice = dict()
dict_invoice['Quantity'] = list_quantity
dict_invoice['StockCode'] = list_stockCode
#------------------------------------------------------------------------
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_purchase_invoice(self):\r\n active_id = self.env['purchase.order'].browse(self.env['purchase.order']._context.get('active_ids'))\r\n journal_id = self.env['account.journal'].search([('type', '=', 'purchase')]) \r\n active_id_count = 0\r\n active_count = 0\r\n exist_vend... | [
"0.58933586",
"0.58273345",
"0.5787141",
"0.5730418",
"0.57022715",
"0.56592727",
"0.5587117",
"0.5582993",
"0.5557562",
"0.55526274",
"0.55505604",
"0.55257595",
"0.5520605",
"0.54978883",
"0.5488627",
"0.5473216",
"0.5465187",
"0.54585433",
"0.54323196",
"0.53706306",
"0.53... | 0.61920017 | 0 |
Returns a dataframe with all invoice lines from customerID given as parameter. | def get_customer_history_df_invoice_line(self, customerID):
df_invoice_line \
= self._df_invoice_original[self._df_invoice_original.CustomerID \
== customerID]
return df_invoice_line | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_customer_df_invoice_line(self, customerID, list_stockCode\\\n , list_quantity, invoiceDate):\n \n dict_invoice = dict()\n\n dict_invoice['Quantity'] = list_quantity\n dict_invoice['StockCode'] = list_stockCode\n\n #--------------------------------------------------------------... | [
"0.6706535",
"0.637564",
"0.6069902",
"0.59014344",
"0.58117783",
"0.5807765",
"0.57650644",
"0.56994027",
"0.5648026",
"0.5595924",
"0.5531552",
"0.55192786",
"0.54935724",
"0.54334897",
"0.5429923",
"0.5344283",
"0.53376174",
"0.5330216",
"0.532311",
"0.5300056",
"0.5274764... | 0.76564085 | 0 |
Returns a list of customers that have been excluded of data sampling used for building model. By default, 10 customers identifier is returned. If customerCount value is None, or <= 0, then list of all customers that have been excluded of data sampling is returned. | def get_listCustomer_out_sample(self, customerCount=10):
if customerCount is None :
listCustomer= list(self._df_invoice_line_out_sample.CustomerID.unique())
else:
if customerCount <= 0 :
listCustomer \
= list(self._df_invoice_line_out_sample.CustomerID.unique... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_customers_count():\n data = user_obj.get_all_customers(\"1\")\n return data",
"def pdelements_num_customers(self) -> int:\n return self.dss_obj.PDElementsI(ctypes.c_int32(4), ctypes.c_int32(0))",
"def get_all_customer_ids():\n table = data_manager.get_table_from_file(\"sales/sales.c... | [
"0.5755343",
"0.5630526",
"0.5468172",
"0.5455088",
"0.5447088",
"0.53655386",
"0.5348006",
"0.5255881",
"0.52160037",
"0.5184504",
"0.5118855",
"0.51016146",
"0.50954854",
"0.5094486",
"0.50568765",
"0.50267607",
"0.49917355",
"0.49625525",
"0.49529928",
"0.49519303",
"0.493... | 0.7302814 | 0 |
Returns number of invoices from original dataset. | def get_invoice_count(self):
return self._df_invoice_original.InvoiceNo.unique().shape[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_no_of_invoices(self):\n for record in self:\n record.invoice_count = len(record.invoice_ids)",
"def get_invl_count(self):\n return self._df_invoice_original.index.unique().shape[0]",
"def invoices(self):\r\n return inv.Invoices(self)",
"def get_customer_count(self):... | [
"0.7744239",
"0.73818606",
"0.63354856",
"0.6231307",
"0.62079424",
"0.6154787",
"0.6135494",
"0.6101816",
"0.606694",
"0.6054052",
"0.60302943",
"0.5938585",
"0.5850497",
"0.58089167",
"0.57880515",
"0.56934583",
"0.568253",
"0.56357646",
"0.55606055",
"0.55459076",
"0.54968... | 0.7667302 | 1 |
Returns number of customers from original dataset. | def get_customer_count(self):
return self._df_invoice_original.CustomerID.unique().shape[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_of_sales_per_customer_ids():\n\n # your code",
"def get_all_customers_count():\n data = user_obj.get_all_customers(\"1\")\n return data",
"def customer_acccounting(customer_orders):",
"def pdelements_num_customers(self) -> int:\n return self.dss_obj.PDElementsI(ctypes.c_int32(4), ... | [
"0.7528541",
"0.741451",
"0.7031075",
"0.6915427",
"0.68836576",
"0.6863681",
"0.6667784",
"0.616603",
"0.61287034",
"0.6101881",
"0.59332806",
"0.5910718",
"0.5855194",
"0.58472735",
"0.58410436",
"0.5774803",
"0.57345396",
"0.57238173",
"0.572342",
"0.5717885",
"0.56658965"... | 0.8029719 | 0 |
Returns number of invoice lines (number of rows) from original dataset. | def get_invl_count(self):
return self._df_invoice_original.index.unique().shape[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_invoice_count(self):\n return self._df_invoice_original.InvoiceNo.unique().shape[0]",
"def getNumRows(self) -> int:\n ...",
"def _compute_no_of_invoices(self):\n for record in self:\n record.invoice_count = len(record.invoice_ids)",
"def getNoOfRows(self):\n retur... | [
"0.7554764",
"0.69679993",
"0.69573605",
"0.6792377",
"0.6672587",
"0.6513209",
"0.649585",
"0.6461261",
"0.63839567",
"0.63666666",
"0.62937206",
"0.62934756",
"0.62633395",
"0.6255323",
"0.62531394",
"0.6229491",
"0.62243587",
"0.62149376",
"0.6199522",
"0.61816734",
"0.614... | 0.7293856 | 1 |
Returns JSON structure issued form dataframe content given as parameter . | def json_df_builder(self, df, marketID, RFM=None):
#-------------------------------------------------------------------------
# Extract from dataframe content to be returned
#-------------------------------------------------------------------------
str_customerID = str(df.CustomerID.uniqu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(self):\n\t\treturn self._dataframe.reset_index().to_json(orient=\"records\")",
"def Mydata():\n\n stmt = db.session.query(Appsdata).statement\n df = pd.read_sql_query(stmt, db.session.bind)\n \n return jsonify(df.to_dict())",
"def get_data(dataframe,index=None):\n dflen = len(datafra... | [
"0.64720726",
"0.63688964",
"0.62659526",
"0.62423277",
"0.61731887",
"0.61728024",
"0.6165461",
"0.610696",
"0.608971",
"0.608501",
"0.60734797",
"0.6067765",
"0.60032827",
"0.5975856",
"0.59611905",
"0.5942278",
"0.5940992",
"0.59368914",
"0.5936283",
"0.5933788",
"0.591012... | 0.6871927 | 0 |
This function is used for validation process. It returns a list of stockCode items and a list of quantities for each item. | def get_order_lists(self, n_items, n_quantities):
arr_stock_code = self._df_invoice_original.StockCode.unique()
arr_stock_code = np.random.choice(arr_stock_code, n_items)
list_stockCode = list(arr_stock_code)
list_quantities = np.ones(arr_stock_code.shape[0])
list_quantities *=n_quantities... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_items(self):\n\n items = []\n\n params = self.request.query_params\n\n if 'items[]' in params:\n items = params.getlist('items[]', [])\n elif 'item' in params:\n items = [params.get('item', None)]\n\n if type(items) not in [list, tuple]:\n ... | [
"0.7183774",
"0.62451553",
"0.6027354",
"0.5956186",
"0.57162726",
"0.5646305",
"0.56151676",
"0.55878735",
"0.55574286",
"0.54344946",
"0.5425899",
"0.54236686",
"0.5393303",
"0.539217",
"0.5386628",
"0.53802747",
"0.5373666",
"0.5363041",
"0.53269744",
"0.52845365",
"0.5275... | 0.6709346 | 1 |
Sentence generator for an entire corpus directory. | def sentences_for_dir(path='./',separate=True,gzipped=True):
for filename in cowfiles(path):
for metadata, data in sentence_generator(filename,separate,gzipped):
yield metadata, data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data_sentences(dirname):\n sentence_list = []\n for fname in os.listdir(dirname):\n with open(os.path.join(dirname, fname)) as file:\n #sentence_list.append(gensim.models.word2vec.LineSentence(file))\n sentence_list.append(file)\n return sentence_list",
"def sents(s... | [
"0.6356309",
"0.6221751",
"0.6179384",
"0.595983",
"0.5889285",
"0.5882137",
"0.5873492",
"0.58633006",
"0.5855387",
"0.5792811",
"0.578709",
"0.5780858",
"0.5774546",
"0.5762869",
"0.5740365",
"0.5727936",
"0.5726981",
"0.5708242",
"0.56983536",
"0.56931585",
"0.569029",
"... | 0.71198934 | 0 |
Build each tree in the 'forest' of trees. After each iteration, evaluate the tree and reweight the input sample such that incorrect events are weighted up and correct events are weighted down | def build(self):
# weights to apply to training samples, updated on each
# iteration of the boosting algo, normalised to 1
sigWeights = np.ones(self.nSig, dtype=float)
bkgWeights = np.ones(self.nBkg, dtype=float)
reweight = 1.0/(np.sum(sigWeights)+np.sum(bkgWeights))
sigW... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_trees(tree, forest, X, Y, sample_weight, tree_idx, n_trees,\n n_samples_bootstrap=None):\n # Initialize the number of samples input data\n n_samples = X.shape[0]\n\n # If the samples are drawn with replacement, then,\n # weight the sample weights by the number of times\n #... | [
"0.7096626",
"0.6913265",
"0.6533237",
"0.6523216",
"0.63476014",
"0.6344354",
"0.61861014",
"0.61825013",
"0.6182119",
"0.61536306",
"0.6152425",
"0.61442596",
"0.608408",
"0.60710186",
"0.60495037",
"0.6023182",
"0.60046387",
"0.59995925",
"0.5979982",
"0.59393513",
"0.5876... | 0.75269973 | 0 |
classify a given event. Iterates over each tree in the forest and then returns the weighted average of the results | def classify(self, event):
results = np.zeros(self.ntrees, dtype=float)
for i,dt in enumerate(self.dTrees):
results[i] = self.treeWeights[i]*dt.classify(event)
return np.sum(results)*(1.0/np.sum(self.treeWeights)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _classify(tree, x):\n # YOUR CODE HERE\n # begin answer\n feature_name=list(tree.keys())[0] #first element\n secondDict=tree[feature_name] \n key=x.loc[feature_name] #extract value from x\n for key_val in secondDict:\n ... | [
"0.6027639",
"0.5959959",
"0.5897434",
"0.5878511",
"0.58665943",
"0.58361167",
"0.5765075",
"0.5708641",
"0.5605437",
"0.55976415",
"0.5585661",
"0.55516666",
"0.5534588",
"0.55194116",
"0.5513875",
"0.5391394",
"0.5380517",
"0.5374991",
"0.5372819",
"0.5360519",
"0.535744",... | 0.8286223 | 0 |
Node frontiers generator using breadthfirst search. | def bfs_nodes_generator(graph, source, reverse=...):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def breadthfirst(self):\n import os\n cwd = os.getcwd()\n os.chdir('/Users/raj/Documents/algorithms_in_python/linked_lists/')\n from linked_collections import LinkedQueue\n os.chdir(cwd) # change to cwd\n if not self.is_empty():\n lq = LinkedQueue()\n ... | [
"0.71898806",
"0.7085778",
"0.70385784",
"0.6970572",
"0.6837096",
"0.67863566",
"0.6713473",
"0.66816336",
"0.6657518",
"0.6647682",
"0.66333216",
"0.6629434",
"0.6573334",
"0.6550337",
"0.6511887",
"0.65066606",
"0.64886534",
"0.6471162",
"0.64685374",
"0.64553446",
"0.6401... | 0.74444324 | 0 |
Edges frontiers generator using breadthfirst search. | def bfs_edges_generator(graph, source, reverse=...):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bfs_nodes_generator(graph, source, reverse=...):\n ...",
"def breadthfirst(self):\n import os\n cwd = os.getcwd()\n os.chdir('/Users/raj/Documents/algorithms_in_python/linked_lists/')\n from linked_collections import LinkedQueue\n os.chdir(cwd) # change to cwd\n ... | [
"0.7032013",
"0.65871656",
"0.6558607",
"0.6494155",
"0.6486353",
"0.64773285",
"0.6464884",
"0.6462215",
"0.64562446",
"0.64025325",
"0.63937354",
"0.6391087",
"0.6381573",
"0.6365035",
"0.6322902",
"0.6297517",
"0.6248023",
"0.623094",
"0.6225877",
"0.62127507",
"0.6212067"... | 0.7154378 | 0 |
Node frontiers generator using topological traversal. | def topological_nodes_generator(graph, reverse=...):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bfs_nodes_generator(graph, source, reverse=...):\n ...",
"def _create_node_iterator(self) -> Iterator[GraphNode]:\n return\n yield",
"def pre_order(self):\n for node_data in self._pre_order_helper(self._root):\n yield node_data",
"def breadth_first_iterate(execution_gra... | [
"0.65818083",
"0.631488",
"0.60523885",
"0.60450137",
"0.60366327",
"0.5984799",
"0.59832644",
"0.5886222",
"0.5862201",
"0.5833745",
"0.57818055",
"0.5777673",
"0.57532954",
"0.5735733",
"0.5725604",
"0.5718208",
"0.5704789",
"0.5663648",
"0.5657863",
"0.56538856",
"0.564333... | 0.75308436 | 0 |
Edge frontiers generator using depthfirstsearch (DFS). Multiple source nodes can be specified to start the DFS traversal. One needs to make sure that each source node belongs to different connected component, so the frontiers can be easily merged. Otherwise, the behavior is undefined. | def dfs_edges_generator(graph, source, reverse=...):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bfs_nodes_generator(graph, source, reverse=...):\n ...",
"def main():\n n = int(input(\"Enter the number of nodes: \"))\n m = int(input(\"Enter the number of edges: \"))\n \n adjList = [[] for i in range(n)]\n \n print(\"Enter the edges: \")\n for i in range(m):\n x, y = input(... | [
"0.66623896",
"0.65276676",
"0.64679134",
"0.64623046",
"0.6430159",
"0.63167006",
"0.6277863",
"0.625629",
"0.625629",
"0.6231696",
"0.6226393",
"0.6226135",
"0.6202045",
"0.6167126",
"0.61345613",
"0.61269605",
"0.61263084",
"0.6116274",
"0.61129403",
"0.60858756",
"0.60563... | 0.71058327 | 0 |
find the feature to use for the next node split and also find where the plit should be in that feature This loops through the split options within a feature to find the best gini score, then it loops through each feature to compare optimal gini scores | def find_split(self, X, y):
choices = y.size
if choices <= 1:
return None, None
# find the number of each option in the current node.
options_parent = [np.sum(y == c) for c in range(self.num_outcomes)]
# find the gini of current node.
best_gini = 1.0 - sum((... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_split(data):\n \"\"\" gets the best feature, and best value \"\"\"\n\n best_feature = None\n best_value = 0.0\n columns = data.columns\n gini_base = gini_impurity(data)\n n_rows = len(data.index) # total number of rows of data before split\n\n # Fininding which split yie... | [
"0.7151503",
"0.64216876",
"0.6352301",
"0.6302367",
"0.62781364",
"0.62125915",
"0.6181519",
"0.6135771",
"0.60826075",
"0.6048427",
"0.5933168",
"0.590119",
"0.5873095",
"0.58700764",
"0.5845192",
"0.583579",
"0.5818668",
"0.5818668",
"0.58096075",
"0.5801238",
"0.5736901",... | 0.66302925 | 1 |
A class without the key_fields annotation should raise a RuntimeError | def testNoKeyFields():
with pytest.raises(RuntimeError):
class AnnotatedNode(Node):
x: str
y: int
def __init__(self, x: str, y: int):
self.x = x
self.y = y
@property
def _display(self) -> str:
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_key_no_data(self):\n key = Key({})\n\n assert key.warning is None\n assert key.in_car is None",
"def _validate(self):\n fields, schema = self.__dict__, self._def.default\n extra_fields = fields.viewkeys() - schema.viewkeys()\n if len(extra_fields) > 0:\n ... | [
"0.664005",
"0.64458597",
"0.63761204",
"0.63392276",
"0.620251",
"0.61894745",
"0.6169179",
"0.611666",
"0.60839826",
"0.60760987",
"0.6069411",
"0.6068303",
"0.60593605",
"0.60562086",
"0.6022622",
"0.60070866",
"0.5998208",
"0.59926015",
"0.59468085",
"0.59364104",
"0.5934... | 0.7018351 | 0 |
creates randomized colors of shape size_x by size_y | def create_world(size_x = 100, size_y=100):
colors = np.random.randint(0,2,(size_x,size_y)).tolist()
for row in range(len(colors)):
for col in range(len(colors[row])):
if (colors[row][col]== 1):
colors[row][col] = 'R'
else:
colors[row][col] = 'G'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randColor():\r\n return np.array([random.random(), random.random(), random.random()]).reshape((1, 1, 3))",
"def random_color_gen():\n r = randint(0, 255)\n g = randint(0, 255)\n b = randint(0, 255)\n return [r, g, b]",
"def random_color(num):\n # 为每个类别的边界框随机匹配相应颜色\n np.random.seed(80)\... | [
"0.72354615",
"0.681743",
"0.67759746",
"0.65923506",
"0.647772",
"0.6391293",
"0.6389239",
"0.6381156",
"0.63713896",
"0.6345931",
"0.6305542",
"0.62956303",
"0.62650055",
"0.62281466",
"0.6208814",
"0.6204611",
"0.61832035",
"0.617489",
"0.6139714",
"0.6136026",
"0.6124625"... | 0.7120646 | 1 |
Finds a dihedral angle adjacent to the selected atoms that includes a new atom | def _find_dihedral(selected):
atom_name = lambda atom: atom.fullName()
atom_mass = lambda atom: atom.mass()
# Loop over possible nearest neighbors
for a2 in selected:
# Find the new atom
attached_to_a2 = sorted([a for a in a2.bondedTo() \
if a not in selected], key=at... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dihedral_calculator():\n\n\t# Prime with first 3 points\n\tp1 = Vector3((yield None))\n\tp2 = Vector3((yield None))\n\tp3 = Vector3((yield None))\n\n\t# Set up for first angle\n\tlastpoint = p3\n\tlastdisp = p3 - p2\n\tlastnormal = ((p2 - p1) @ lastdisp).normalize()\n\n\tangle = None\n\n\t# For each point star... | [
"0.6646527",
"0.63952506",
"0.6240537",
"0.5905683",
"0.588075",
"0.5806025",
"0.5764874",
"0.56130666",
"0.5525293",
"0.5508618",
"0.5460365",
"0.53958726",
"0.535405",
"0.53534824",
"0.5297335",
"0.5294864",
"0.52534354",
"0.52349055",
"0.52014965",
"0.51829153",
"0.5158568... | 0.8237362 | 0 |
Conversion from (internal or extended) BondAngleTorsion to Cartesian coordinates | def Cartesian(self, BAT):
# Arrange BAT coordinates in convenient arrays
offset = 6 if len(BAT) == (3 * self.natoms) else 0
bonds = BAT[offset + 3::3]
angles = BAT[offset + 4::3]
phase_torsions = BAT[offset + 5::3]
torsions = [(phase_torsions[n] + phase_torsions[self._firstTorsionTInd[n]]) \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cartesian_to_internal(self, atom_position, bond_position, angle_position, torsion_position):\n # TODO: _cartesian_to_internal and _internal_to_cartesian should accept/return units and have matched APIs\n\n check_dimensionality(atom_position, unit.nanometers)\n check_dimensionality(bond_po... | [
"0.68272",
"0.68232924",
"0.6670016",
"0.6668133",
"0.6666709",
"0.66622704",
"0.6632937",
"0.6616939",
"0.6595138",
"0.6567005",
"0.6544198",
"0.65291274",
"0.6471032",
"0.6468995",
"0.63908124",
"0.63474804",
"0.63316333",
"0.63281065",
"0.631877",
"0.6312516",
"0.6256514",... | 0.68568003 | 0 |
Opens the molecule in VMD | def showMolecule(self, colorBy=None, label=False, dcdFN=None):
# Write PDB file
# To set Occupancy, change atom.occupancy
# To set Beta, change atom.temperature_factor
import os.path
pdbFN = os.path.join(MMTK.Database.molecule_types.directory,
'showMolecule.pdb')
outF = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def viewNMDinVMD(filename):\n\n vmd = pathVMD()\n if vmd:\n os.system('{0} -e {1}'.format(vmd, abspath(filename)))",
"def _vmd_script_molecule(mole, filename=\"molecule.xyz\"):\n output = \"# load new molecule\\n\"\n if len(mole.atom) == 0:\n raise ValueError(\"Need at least one molecul... | [
"0.612638",
"0.6115121",
"0.60250276",
"0.6011934",
"0.5911261",
"0.57081985",
"0.568981",
"0.5678963",
"0.5570185",
"0.5564583",
"0.5564583",
"0.5564583",
"0.5531796",
"0.5531796",
"0.54938924",
"0.54809994",
"0.5477402",
"0.5396461",
"0.5377517",
"0.5377517",
"0.5375009",
... | 0.6395765 | 0 |
Test read and write ints. | def test_message_int():
result = True
message = msg.Message()
for i in range(num_it):
message.appendInt(i)
if message.length != msg.HEADER_SIZE + (i+1)*msg.intStruct.size:
print("Size is ", message.length, " but should be ", msg.HEADER_SIZE + (i+1)*msg.intStruct.size)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(self) -> int:\n ...",
"def test_int_field():",
"def read(self) -> int:",
"def test_numbers_roundtrip():\n for num in (0, 1, 2, 178, 300, BIG_NUMBER):\n num2 = UnsignedInt.read(UnsignedInt.to_bytes(num))\n assert num2 == num",
"def test_integer(self):\n esnA = ESN(N_i... | [
"0.62519395",
"0.6250594",
"0.62442267",
"0.61574054",
"0.5960592",
"0.59363145",
"0.5931189",
"0.5928802",
"0.59218436",
"0.587367",
"0.5865747",
"0.58532387",
"0.57997644",
"0.5783584",
"0.57745636",
"0.5768972",
"0.5754527",
"0.57348996",
"0.57348996",
"0.57081896",
"0.569... | 0.625918 | 0 |
Handles a leave game request. Deletes the user from the game. | def leave_game(players_cursor, states_cursor, user, room_id):
leave_query = '''DELETE FROM players_table WHERE user = ? AND room_id = ?'''
players_cursor.execute(leave_query, (user, room_id))
FRAMES.append(display_game(players_cursor, states_cursor, user, room_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leave(msg: telebot.types.Message):\n if utils.in_menu(msg.from_user):\n bot.reply_to(\n msg,\n 'This command outside of game is useless.'\n )\n return\n\n game, user, opponent = utils.get_game_user_opponent(msg.from_user)\n if not game or not user:\n #... | [
"0.7001719",
"0.6419002",
"0.63921964",
"0.639108",
"0.6370939",
"0.633421",
"0.63169086",
"0.6268317",
"0.6229235",
"0.61546296",
"0.6119499",
"0.6118067",
"0.60932064",
"0.6045495",
"0.6015096",
"0.5974975",
"0.59517586",
"0.59031034",
"0.59014386",
"0.5897309",
"0.5892574"... | 0.66279423 | 1 |
Select Relationships associated with specified fact_id. | def select_by_fact_id(cls, fact_id):
return db.session.query(cls).filter_by(fact_id=fact_id).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_relationships(person_id):\n try:\n conn = sqlite3.connect(settings.database_name)\n conn.row_factory = sqlite3.Row\n c = conn.cursor()\n c.execute(\"PRAGMA foreign_keys = ON\")\n c.execute(relationship_query, (person_id,)) # note a tuple is needed as a parameter valu... | [
"0.58382934",
"0.514626",
"0.50882876",
"0.5030613",
"0.5016771",
"0.49949938",
"0.4898808",
"0.48690563",
"0.48584178",
"0.48120192",
"0.47925648",
"0.47674325",
"0.47505498",
"0.473037",
"0.473037",
"0.473037",
"0.47198808",
"0.47121876",
"0.46776888",
"0.46749067",
"0.4671... | 0.68101376 | 0 |
Select Relationship with specified subject, object and relationship type. | def select_by_foreign_keys(cls, subject_id=None, object_id=None, relationship_type_id=None):
filter_clause = sa.and_(
sa.and_(cls.subject_id == subject_id, cls.object_id == object_id),
cls.relationship_type_id == relationship_type_id)
return db.session.query(cls).filter(filter_cl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_by_values(cls, relationship_type_name=None, relationship_number=None,\n subject_name=None, object_name=None):\n query = db.session.query(cls).\\\n join(RelationshipType).\\\n filter(RelationshipType.relationship_type_name==relationship_type_name)\n ... | [
"0.6398576",
"0.59592456",
"0.58598846",
"0.5763038",
"0.5670848",
"0.56461585",
"0.5524951",
"0.5501221",
"0.5444976",
"0.5378021",
"0.53130275",
"0.5282662",
"0.5178828",
"0.51488453",
"0.5099441",
"0.50218856",
"0.501885",
"0.49724635",
"0.48888737",
"0.4885239",
"0.487039... | 0.72244817 | 0 |
Select Relationships with specified relationship_type, count, subject, and object. | def select_by_values(cls, relationship_type_name=None, relationship_number=None,
subject_name=None, object_name=None):
query = db.session.query(cls).\
join(RelationshipType).\
filter(RelationshipType.relationship_type_name==relationship_type_name)
if rela... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_by_foreign_keys(cls, subject_id=None, object_id=None, relationship_type_id=None):\n filter_clause = sa.and_(\n sa.and_(cls.subject_id == subject_id, cls.object_id == object_id),\n cls.relationship_type_id == relationship_type_id)\n return db.session.query(cls).filter(... | [
"0.6642475",
"0.6234097",
"0.61171645",
"0.5905707",
"0.573527",
"0.5697212",
"0.558768",
"0.55415577",
"0.5488156",
"0.5187914",
"0.5047478",
"0.50362355",
"0.5031117",
"0.5009696",
"0.5007061",
"0.4995968",
"0.4954581",
"0.49293298",
"0.49109417",
"0.48943478",
"0.4888402",... | 0.7105433 | 0 |
Validate requests decorator with Cerberus | def validate_request_cerberus(schema):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
body_json = request.get_json()
current_app.logger.info(body_json)
v = Validator(schema, require_all=True)
v.allow_unknown = True # TODO: allow reques... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_request(func):\n\n @wraps(func)\n def wrapper(*args, **kwargs):\n try:\n return func(*args, **kwargs)\n except BadRequest as e:\n raise InvalidRequest(description='request parameters, queries or body format are invalid.',\n code=e.... | [
"0.68247503",
"0.6648503",
"0.6610281",
"0.65511626",
"0.64839965",
"0.5961608",
"0.59245205",
"0.5921186",
"0.589062",
"0.5860312",
"0.5833157",
"0.5833084",
"0.5802698",
"0.57723325",
"0.5756725",
"0.5740091",
"0.57035977",
"0.5687878",
"0.5684185",
"0.5676626",
"0.5673376"... | 0.70384467 | 0 |
Plots the graph. If the nodes have a position, the nodes will be placed there. Otherwise, they will be placed in a random but elegant manner. | def plot_graph(self) -> None: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_graph(self) -> None:\n\n nodes_on_graph = self.dw_graph.get_all_v()\n for k, v in nodes_on_graph.items():\n if v.position is None:\n x_rand = random.uniform(0.5, self.dw_graph.v_size())\n y_rand = random.uniform(0.5, self.dw_graph.v_size())\n ... | [
"0.7539952",
"0.69758826",
"0.6917775",
"0.6841799",
"0.6772024",
"0.66144824",
"0.66071594",
"0.65934306",
"0.65229076",
"0.65064275",
"0.6494702",
"0.6480308",
"0.6477845",
"0.6361443",
"0.63394064",
"0.6281064",
"0.62662697",
"0.6260735",
"0.6240371",
"0.62216246",
"0.6214... | 0.7134664 | 1 |
Formats comparison as a strings | def format_comparison(objs):
def formatter(comp):
if not isinstance(comp, tuple):
return str(comp)
output = []
return "\n".join([comp.type] + [" "+errmessage for errmessage in output])
results = map(formatter,objs)
return "\n".join(results)
#obj1,obj2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comparison(self) -> str:\n return self._values.get('comparison')",
"def generate_comparison_output_string(comparisons: List[Dict[str, Any]]) -> str:\n result_dict = generate_comparison_dict(comparisons)\n result_string = json.dumps(result_dict, sort_keys=True, indent=4)\n return result_string... | [
"0.7065585",
"0.6774839",
"0.66851884",
"0.66676676",
"0.6445696",
"0.64411914",
"0.64020616",
"0.63991475",
"0.6312643",
"0.6112813",
"0.6112813",
"0.610843",
"0.6023886",
"0.6010248",
"0.59334326",
"0.5931873",
"0.59163105",
"0.5899037",
"0.5899037",
"0.5896669",
"0.5889875... | 0.69769394 | 1 |
Catches a difference when one or both of the objects are None (since it is handled the same across methods) | def none_comparison(func):
@functools.wraps(func)
def inner(obj1,obj2):
if obj1 is not None and obj2 is not None:
return func(obj1, obj2)
if obj1 is None and obj2 is None:
return []
if obj1 is not None and obj2 is None:
return Difference(f"Second {obj1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_none(self) -> PossibleResult[T]:\n if self.constructor == type(None):\n if not self.obj is None:\n raise DeserializeError(\n type(None), self.obj, self.new_depth, self.key\n )\n return self.obj # type: ignore\n return ... | [
"0.6248695",
"0.5997152",
"0.59885675",
"0.59798694",
"0.5903614",
"0.5886935",
"0.58787954",
"0.5814186",
"0.58113503",
"0.57685584",
"0.5712491",
"0.56863844",
"0.56762654",
"0.56702787",
"0.56702787",
"0.5659557",
"0.563092",
"0.5625755",
"0.5596324",
"0.55960506",
"0.5590... | 0.7289079 | 0 |
Compares Attributes between 2 objects via getattr, returning the attribute values as a tuple if they do not match | def attr_comparison(obj1,obj2,attrs):
return [Difference(f"{obj1.__class__.__name__}.{attr}",(result1,result2)) for attr in attrs if (result1 := getattr(obj1,attr)) != (result2 := getattr(obj2,attr))] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attrs_to_tuple(obj):\n return tuple(getattr(obj, a) for a in attrs)",
"def compare(current_formation):\n\n attribute_tuple = ()\n for attr in attributes:\n\n if attr in current_formation:\n attribute_tuple += (current_formation[attr],)\n ... | [
"0.6573749",
"0.64668816",
"0.6218231",
"0.61928684",
"0.61631376",
"0.6161874",
"0.61611706",
"0.61574703",
"0.5891995",
"0.58485514",
"0.5843817",
"0.5834111",
"0.57660866",
"0.57439977",
"0.5732433",
"0.5712868",
"0.56471366",
"0.5642409",
"0.5622416",
"0.5610146",
"0.5576... | 0.73285353 | 0 |
Given a list of tuples comparised of (subcomparison method, attr name for comparison), returns any Difference tuple retunred by each method using the given attr of obj1 and obj2 as arguments (if that method is not None) | def sub_comparison(obj1,obj2,translate):
return [Difference(f"{obj1.__class__.__name__} > {meth.__name__}",result) for (meth,attr) in translate if (result := meth(getattr(obj1,attr),getattr(obj2,attr))) is not None] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_comparison(obj1,obj2,attrs):\n return [Difference(f\"{obj1.__class__.__name__}.{attr}\",(result1,result2)) for attr in attrs if (result1 := getattr(obj1,attr)) != (result2 := getattr(obj2,attr))]",
"def with_cmp(attrs):\n def attrs_to_tuple(obj):\n \"\"\"\n Create a tuple of all valu... | [
"0.6840443",
"0.57526386",
"0.5622923",
"0.54995364",
"0.54768133",
"0.5458876",
"0.5385492",
"0.5371001",
"0.5325865",
"0.5241565",
"0.51938784",
"0.5181397",
"0.51578325",
"0.51564384",
"0.5137712",
"0.50981116",
"0.50660944",
"0.50567687",
"0.50435317",
"0.5015092",
"0.500... | 0.7408652 | 0 |
Postmortem, using a custom debug function if passed | def post_mortem(*args, debug_fn: Optional[Callable] = None, **kwargs) -> None:
if debug_fn is None:
import pdb
debug_fn = pdb.post_mortem
debug_fn() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug():",
"def debug_run(self):\n raise NotImplementedError",
"def xpm(Pdb=Pdb):\n info = sys.exc_info()\n print(traceback.format_exc())\n post_mortem(info[2], Pdb)",
"def after_step(context, step):\n if context.config.userdata.getbool(\"debug\") and step.status == \"failed\":\n ... | [
"0.7278622",
"0.69504553",
"0.68875915",
"0.6863419",
"0.6848077",
"0.6839908",
"0.6770106",
"0.66839147",
"0.66665906",
"0.66077083",
"0.660491",
"0.6530755",
"0.6507357",
"0.6416765",
"0.63856596",
"0.63856345",
"0.6353304",
"0.63263094",
"0.6322992",
"0.6319444",
"0.630869... | 0.8282989 | 0 |
Simple forward step with crossentropy loss. | def _cross_entropy_forward_step(batch, model):
timers = get_timers()
# Get the batch.
timers('batch-generator', log_level=2).start()
try:
batch_ = next(batch)
except BaseException:
batch_ = batch
tokens, types, labels, attention_mask = process_batch(batch_)
timers('batch-gen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward_train(self, preds_T: torch.Tensor) -> torch.Tensor:\n fake_label = preds_T.data.max(1)[1]\n return F.cross_entropy(preds_T, fake_label)",
"def train_step(self, X_batch: np.ndarray, Y_batch: np.ndarray):\n\n # Almost the same as previous task, calculates the cross entropy loss for... | [
"0.7079546",
"0.7007037",
"0.6882113",
"0.67776626",
"0.6773821",
"0.6759933",
"0.6734602",
"0.67251396",
"0.66867614",
"0.66795677",
"0.6665437",
"0.66561353",
"0.6633398",
"0.66322726",
"0.6624705",
"0.6619393",
"0.6619258",
"0.6606617",
"0.65844935",
"0.65608215",
"0.65534... | 0.7801202 | 0 |
Build a looped dataloader with infinite size. | def _build_infinite_size_dataloader(dataloader):
iterator = dataloader.__iter__()
while True:
try:
yield iterator.__next__()
except StopIteration:
iterator = dataloader.__iter__() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, len):\n self.data = []\n i = 0\n while i < len:\n i += 1\n self.data.append(self.Data())\n self.length = len",
"def __iter__(self):\n\t\tfor i, data in enumerate(self.dataloader):\n\t\t\tif i * self.opt.batch_size >= self.opt.max_dataset_size:\... | [
"0.62806386",
"0.62140703",
"0.62047887",
"0.6165703",
"0.6139719",
"0.5913532",
"0.5898376",
"0.58914024",
"0.5870807",
"0.58379287",
"0.5795319",
"0.5757869",
"0.5757244",
"0.57561076",
"0.57423776",
"0.5669886",
"0.5666476",
"0.5624543",
"0.5618841",
"0.5613911",
"0.560385... | 0.83487415 | 0 |
Construct solver from Caffe solver prototxt file. | def from_caffe_solver_protoxt(cls, caffe_solver_prototxt_file: Path):
solver_param = caffe_pb2.SolverParameter()
with open(caffe_solver_prototxt_file, 'rt') as f:
pb2.text_format.Merge(f.read(), solver_param)
dictionary = {'lr_policy': solver_param.lr_policy,
'b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_solver(self):\n # Create a temporary solver file.\n fname = '__solver__.prototxt'\n f = open(fname, 'w')\n f.write(self.to_proto())\n f.close()\n # Get solver from file.\n solver = caffe.get_solver_from_file(fname)\n # Remove the temporary solver file... | [
"0.6062727",
"0.5984447",
"0.5803342",
"0.57631385",
"0.55716205",
"0.5436299",
"0.54261035",
"0.53917223",
"0.532022",
"0.52781713",
"0.52740806",
"0.52685714",
"0.52685714",
"0.5249456",
"0.5244701",
"0.52160436",
"0.51900196",
"0.5182835",
"0.5182635",
"0.5168049",
"0.5160... | 0.78207666 | 0 |
Refreshes the Job's details by querying the workspace. | def refresh(self):
self.details = self.workspace.get_job(self.id).details | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh(self): # noqa\n data = self.connection.hgetall(self.key)\n if not data:\n raise NoSuchJobError('No such job: {0}'.format(self.key))\n self.restore(data)",
"def reload(self):\n self.job_proto = self.serving_stub.GetJob(GetJobRequest(job=self.job_proto)).job",
... | [
"0.7204651",
"0.6387912",
"0.5996785",
"0.5930605",
"0.58091706",
"0.5802573",
"0.5802573",
"0.5802573",
"0.5802573",
"0.5802385",
"0.57152075",
"0.5710763",
"0.5668991",
"0.5663364",
"0.56334144",
"0.5627976",
"0.5627976",
"0.5627976",
"0.56269634",
"0.56071436",
"0.56027734... | 0.80415493 | 0 |
Create a unique id for a new job. | def create_job_id() -> str:
return str(uuid.uuid1()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_job_id():\n # CAIP job id can contains only numbers, letters and underscores.\n unique_tag = str(uuid.uuid4()).replace(\"-\", \"_\")\n return \"tf_cloud_train_{}\".format(unique_tag)",
"def _get_job_id(self):\n return uuid.uuid4().hex",
"def create_task_id():\n return str(int(round... | [
"0.7751475",
"0.7743574",
"0.74370795",
"0.73037905",
"0.7232655",
"0.7232655",
"0.6982425",
"0.6982323",
"0.6908271",
"0.6889731",
"0.68492854",
"0.67642814",
"0.6763294",
"0.6702419",
"0.6602108",
"0.65147835",
"0.65133655",
"0.65115803",
"0.6507985",
"0.64827",
"0.6455972"... | 0.88138694 | 0 |
Applies post processing to all the outputs in the provided run results. This is a convenience function to avoid the need for manual iteration over the run_results dictionary. | def postprocess(run_results, postprocess_func):
G_LOGGER.start(f"Applying post-processing to outputs: {postprocess_func.__name__}")
for _, iteration_results in run_results:
for index, iter_res in enumerate(iteration_results):
iteration_results[index] = postprocess_func(iter_r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(self, results):\n raise NotImplementedError",
"def process_results(self, results=None, **value): # pragma: no cover\n return default_result_processor(results=results, **value)",
"def _post_process_result(result: Any) -> Any:\n return result",
"def process_results(self, respo... | [
"0.65581095",
"0.64528775",
"0.62099826",
"0.61681396",
"0.61681396",
"0.6150747",
"0.61191654",
"0.6098182",
"0.6078971",
"0.60327035",
"0.6017863",
"0.60096914",
"0.59998536",
"0.59641546",
"0.5962654",
"0.593701",
"0.5910838",
"0.5900604",
"0.5772284",
"0.5731572",
"0.5715... | 0.8450894 | 0 |
Turns Freshbooks tickets from the past x days into Toggl projects. | def sync(self, no_of_days=1):
zd = Zendesk()
tg = Toggl()
try:
self.print("Syncing...")
self.print_divider(30)
tickets = zd.get_tickets(no_of_days)
for ticket in tickets:
project_title = self.format_title(ticket.id, ticket.subject)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resume():\n # We now retrieve all entries in the previous month.\n # Getting the current date and the date from a month before.\n time_year = time.localtime()[0] \n time_month = time.localtime()[1]\n time_day = time.localtime()[2]\n if time_month == 1:\n prev_time_month = 12\n p... | [
"0.5335107",
"0.52704185",
"0.5256979",
"0.5130906",
"0.50964624",
"0.5023923",
"0.5006047",
"0.49849492",
"0.4897661",
"0.4888886",
"0.4882372",
"0.486753",
"0.4858375",
"0.48496896",
"0.4849528",
"0.48321384",
"0.48075008",
"0.47820213",
"0.47624293",
"0.4758167",
"0.475298... | 0.58926123 | 0 |
Starts interactive time tracking session. Updates Freshbooks based on Toggl entries. | def time_tracking(self):
fb = FreshBooks()
tg = Toggl()
self.print_splash()
self.print("Tip: You can always enter 'skip' when you want to skip a time entry.", format='warn')
days = self.get_interactive_days() # number of days to go back
self.print("OK, I'll run you throu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n # check database for tracking options\n # if empty prompt to add subject\n\n # present tracking options\n\n # calculate timedelta\n\n # printing/updating the time",
"def setTrackStartTime() :\n s.startTrack()",
"def time_automation_listener(now):\n action()",
"def mai... | [
"0.6347523",
"0.576873",
"0.5634519",
"0.56242204",
"0.56151354",
"0.5609387",
"0.56086725",
"0.55940264",
"0.5576316",
"0.5486407",
"0.54707676",
"0.5469594",
"0.5462939",
"0.54449016",
"0.5444178",
"0.5436368",
"0.54061335",
"0.53546655",
"0.53450114",
"0.5342797",
"0.53191... | 0.69116616 | 0 |
Starts interactive search, allows user to make a selection. Accepts array of strings and optional (user) query. Returns string chosen by user. | def interactive_search(self, choices, query=None):
if query:
match = self.get_interactive_match(choices, query)
if match:
self.print("Matched query to '%s'." % (match))
answer = input("Is that correct? (Y/n) ")
self.clear_lines(1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ask_query(self):\n self.__output = list()\n return input(form('What do you want to search?\\n> '))",
"def search():\n query = input('Please enter your search query\\n')\n # For now, we will just print the whole database\n #db_actions.display()\n db_actions.search(query)",
"def ... | [
"0.6945267",
"0.6146135",
"0.60944784",
"0.6077637",
"0.6019907",
"0.5902816",
"0.58127916",
"0.58041674",
"0.5797001",
"0.5792282",
"0.5770086",
"0.5716065",
"0.56671447",
"0.5661047",
"0.5658922",
"0.56546295",
"0.56507295",
"0.5648148",
"0.56405544",
"0.56253314",
"0.56142... | 0.67623794 | 1 |
Returns string that best matches query out of a list of choices. Prompts user if unsure about best match. | def get_interactive_match(self, choices, query):
if query in self.SKIP_KEYWORDS:
return None
results = process.extract(query, choices, limit=10) # fuzzy string matching
best_match = results[0]
second_best_match = results[1]
if best_match[1] == second_best_match[1] or... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interactive_search(self, choices, query=None):\n if query:\n match = self.get_interactive_match(choices, query)\n if match:\n self.print(\"Matched query to '%s'.\" % (match))\n answer = input(\"Is that correct? (Y/n) \")\n self.clear_lin... | [
"0.6642002",
"0.6545624",
"0.6269913",
"0.623575",
"0.6235035",
"0.62169236",
"0.6010412",
"0.60037553",
"0.6000231",
"0.59865594",
"0.5913682",
"0.59093326",
"0.5877843",
"0.5836029",
"0.5736314",
"0.57017106",
"0.5665372",
"0.56378025",
"0.5632232",
"0.5620297",
"0.55832994... | 0.7756389 | 0 |
Asks an user how many days to go back. Returns int. | def get_interactive_days(self):
answer = input("Press return to get entries of past day or input number of days to go back in time: ")
if answer == '':
days = 1
else:
try:
days = int(answer)
except:
print("You didn't enter a num... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decreases_remaining(self):\n return 2 - self.decreases_today",
"def remain():\r\n global total\r\n global user_pick\r\n total = int(total - user_pick)\r\n print(\"Remaining \" + str(total))",
"def remaining_days_in_cycle(self) -> int:\n if not self.expiration:\n return ... | [
"0.6136943",
"0.59328794",
"0.5877445",
"0.58612114",
"0.57502425",
"0.5743318",
"0.55419844",
"0.55365306",
"0.55009514",
"0.5493947",
"0.54851043",
"0.5480768",
"0.5478333",
"0.54070824",
"0.5393414",
"0.53924155",
"0.5386575",
"0.5374631",
"0.52890193",
"0.52890193",
"0.52... | 0.70395863 | 0 |
Hacky way to check if this function already made a Toggl project based on a Zendesk ticket ID. | def already_created(self, ticket_id, toggl_projects):
project_prepends = [p['name'].split()[0][1:] for p in toggl_projects]
if str(ticket_id) in project_prepends:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def check_if_is_ticket(ctx):\n channel : TextChannel = ctx.channel\n return 'ticket-' in channel.name",
"def sync(self, no_of_days=1):\n zd = Zendesk()\n tg = Toggl()\n try:\n self.print(\"Syncing...\")\n self.print_divider(30)\n tickets =... | [
"0.60784185",
"0.584883",
"0.56591004",
"0.55432487",
"0.5472561",
"0.5453476",
"0.5446431",
"0.54430735",
"0.54305506",
"0.54244524",
"0.54243267",
"0.5412555",
"0.53918374",
"0.5391034",
"0.5389106",
"0.5382748",
"0.53724587",
"0.53702873",
"0.535847",
"0.5357751",
"0.53424... | 0.7632334 | 0 |
Formats id and subject into a suitable (Freshbooks) title. | def format_title(self, ticket_id, subject):
# TODO: strip block tags?
title = "#%i %s" % (ticket_id, subject)
return title.strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_title(self):\n ret = self.properties['reason'].capitalize()\n ret += ' has been reported near ' + self.properties['address'].split(',')[0]\n time = datetime.strptime(self.properties['when'], '%Y-%m-%dT%H:%M:%S')\n times = [time.strftime(i).lstrip('0') for i in ('%m', '%d', '%I... | [
"0.63595736",
"0.6318129",
"0.6200423",
"0.61921966",
"0.6153127",
"0.60798085",
"0.6040445",
"0.6013723",
"0.6009649",
"0.59691554",
"0.59691554",
"0.5925276",
"0.58930725",
"0.5861564",
"0.5843622",
"0.5807595",
"0.57983005",
"0.57983005",
"0.5792964",
"0.57914525",
"0.5784... | 0.78905237 | 0 |
Formats Toggl project name and description into (Freshbooks) description. | def format_description(self, project_name, description):
description = description if description else ''
return "%s %s" % (project_name, '- ' + description) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def description():",
"def get_descriptive_name(self):\n description = (f\"{self.year} {self.manufacturer.title()} \"\n f\"{self.model.title()}\")\n\n return description",
"def get_describe_name(self):\n long_name = str(self.year)+ ' ' + self.make.title()+ ' ' +self.mo... | [
"0.6330707",
"0.5992437",
"0.59294826",
"0.59286237",
"0.58890724",
"0.584214",
"0.5832703",
"0.5818409",
"0.5808963",
"0.5762168",
"0.5734125",
"0.5720652",
"0.5715829",
"0.5715829",
"0.56770307",
"0.5670249",
"0.56625277",
"0.5661302",
"0.56451756",
"0.5631556",
"0.5621286"... | 0.7948996 | 0 |
Merges toggle time entries with same project name. Sums duration if billable. | def merge_toggl_time_entries(self, time_entries):
tg = Toggl()
d = {}
for entry in time_entries:
if entry.get('billable'):
if entry.get('tags') and tg.BOOKED_TAG in entry['tags']:
status = 'booked'
else:
status =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def break_time(self):\n\t\ts = timedelta()\n\t\tfor i in xrange(1, len(self.toggles)-1, 2):\n\t\t\ts += self.toggles[i+1] - self.toggles[i]\n\n\t\t# If not working need to add the last period of time\n\t\tif not self.status():\n\t\t\ts += datetime.now() - self.toggles[-1]\n\t\treturn s",
"def _task_data(self):\n... | [
"0.52670914",
"0.521612",
"0.5171499",
"0.49770486",
"0.49408284",
"0.49355707",
"0.47276974",
"0.47106627",
"0.4675955",
"0.4652707",
"0.46401706",
"0.46156195",
"0.45833963",
"0.4529443",
"0.45191568",
"0.44983798",
"0.44943383",
"0.4493547",
"0.4472287",
"0.44453704",
"0.4... | 0.6820048 | 0 |
Mark a class as Controller Resource | def add_resource(self, cls):
# check if the same controller was already used for another cls (Resource)
if (
hasattr(self, Controller.RESOURCE_CLASS_KEY)
and getattr(self, Controller.RESOURCE_CLASS_KEY) != cls
):
raise MultipleResourceException()
# ch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_resource():\n return wsgi.Resource(Controller())",
"def setController(self, controller):\n self.__controller = controller",
"def __init__(self, controller):\n self._controller = controller",
"def resource(self, prefix):\n def wrapper(cls):\n # Save the original i... | [
"0.6103949",
"0.6056706",
"0.59474033",
"0.5917977",
"0.58889747",
"0.58889747",
"0.5795911",
"0.5779954",
"0.57289934",
"0.5706962",
"0.5686955",
"0.5658022",
"0.55966556",
"0.55881155",
"0.5557832",
"0.55321854",
"0.5516671",
"0.55104506",
"0.5504374",
"0.5495111",
"0.54755... | 0.6852721 | 0 |
It returns the FastAPI router. Use it as if you are using the original one. | def route(self) -> APIRouter:
return self.router | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, req):\n return self._router",
"def create_router(self, environment, *, router=None):\n\n if router is None:\n router = self.router\n\n return utils.objects.ensure_instance(router, environment=environment)",
"def __parse_controller_router(cls):\n router ... | [
"0.75668126",
"0.62573475",
"0.6220323",
"0.61085886",
"0.6030978",
"0.602395",
"0.60006815",
"0.59523207",
"0.5933353",
"0.58949184",
"0.5879139",
"0.5846796",
"0.5825418",
"0.5804262",
"0.57789963",
"0.5770383",
"0.5753781",
"0.57239616",
"0.56978655",
"0.5636582",
"0.56365... | 0.81418586 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.