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 first active subscription by id
def get_first_active_subscription(self): if self.has_active_subscription(): return self.subscriptions.filter(active=True)[0] else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_one(cls, sid):\n return Subscription.query.get_or_404(sid)", "def get_by_id(self, _id):\n return Subscription(self.context, ResourcePathServiceOperation(\"getById\", [_id], self.resource_path))", "def getSubscription(uniq):\n return Subscription(Cuebot.getStub('subscription').Get(\n ...
[ "0.7555253", "0.73221976", "0.6466023", "0.632846", "0.6229105", "0.6084679", "0.6083515", "0.603069", "0.5999968", "0.59402347", "0.59136426", "0.5903363", "0.5893972", "0.5842891", "0.5826261", "0.5789582", "0.570909", "0.5650244", "0.56212664", "0.56127733", "0.561177", ...
0.7979451
0
Returns a queryset with all the newsletters that this contact has subscriptions in.
def get_newsletters(self): return SubscriptionNewsletter.objects.filter(contact=self)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_subscriptions(self):\n return self.subscriptions.all()", "def get_all_subscriptions(cls, **kwargs):\n return Subscription.query.filter(**kwargs).all()", "def subscriptions(self):\r\n return subs.AccountSubscriptions(self)", "def getAllSubscriptions(self):\n return self.req...
[ "0.76563036", "0.72232264", "0.6919182", "0.66618294", "0.66575885", "0.66574", "0.6607653", "0.65924275", "0.6519385", "0.6455571", "0.6406239", "0.6384957", "0.6365558", "0.6332527", "0.62650865", "0.6246953", "0.6179742", "0.617221", "0.61497104", "0.6115057", "0.61131865"...
0.83896947
0
Returns the last paid invoice for this contact if it exists. Returns None if they have none.
def get_last_paid_invoice(self): try: return self.invoice_set.filter(Q(paid=True) | Q(debited=True)).latest("id") except Exception: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pending_invoice(self,org_id=None):\n if org_id is None:\n org_id = self.org_id\n return self.get('{}/orgs/{}/invoices/pending'.format(ApiVersion.A1.value,org_id))", "def get_latest_invoice(self) -> CreditorInvoice:\n\n LOGGER.info(\"Getting latest invoice from EON Romania\")\n\n sess...
[ "0.58459026", "0.56620586", "0.5511519", "0.5396463", "0.5305116", "0.52948034", "0.5150207", "0.51453376", "0.5130346", "0.51226276", "0.51226276", "0.51226276", "0.51226276", "0.51226276", "0.51183546", "0.5111227", "0.5106159", "0.5092524", "0.50849295", "0.50741434", "0.5...
0.82362366
0
Adds a product history for this contact on the ContactProductHistory table. This is used to keep record of how many times a Contact has been active or inactive, and when. Soon this will be improved.
def add_product_history( self, subscription, product, new_status, campaign=None, seller=None, override_date=None, ): # TODO: this method should be migrated to the Subscription model history_of_this_product = subscription.contactproducthistory_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append_history_record(self, history_record):\n self.history.append(history_record)\n self._increment_history_pointer()", "def insert(self, unhealthy_product, name, description, stores, url):\n self.database.query('''INSERT INTO History\n VALUES (NULL,\n ...
[ "0.57782525", "0.5642956", "0.56051624", "0.55821145", "0.5513348", "0.5411007", "0.53511876", "0.53429097", "0.53345805", "0.5299433", "0.5290899", "0.52849525", "0.5278879", "0.5265222", "0.52643013", "0.52299225", "0.5223089", "0.5205646", "0.51907194", "0.5183049", "0.517...
0.77234083
0
Returns the amount of products in this subscription
def get_product_count(self): return self.products.count()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def product_count(self) -> int:\n return self._product_count", "def getNumProducts(self):\n return _libsbml.Reaction_getNumProducts(self)", "def _grand_total(self):\n count = 0\n for product in self.products:\n count += product.price\n return count", "def __len__...
[ "0.75261235", "0.7410046", "0.73862386", "0.69536", "0.6936234", "0.6911655", "0.68340504", "0.66541094", "0.6592634", "0.65747774", "0.64729214", "0.64634186", "0.64480746", "0.6446529", "0.64411473", "0.6425942", "0.6403196", "0.6384714", "0.63453466", "0.62762976", "0.6241...
0.8000121
0
Simple function that shows a link to edit the current subscription under a list of products. It's used to reduce clutter in the admin panel, only showing a small amount of information.
def edit_products_field(self): text = '<table style="padding:5px;">' subscription_products = SubscriptionProduct.objects.filter(subscription=self) for sp in subscription_products: text += ( '<tr style="padding:5px;"><td style="padding:5px;">{}</td><td style="padding:5...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscriber_detail(self):\n model_name = Subscriber._meta.object_name.lower()\n app_label = self._meta.app_label\n link = '/admin/%s/%s/' % (app_label, model_name)\n link += '?campaign__id=%d' % self.id\n display_link = _(\"<a href='%(link)s'>%(name)s</a>\") % \\\n ...
[ "0.6159798", "0.5867929", "0.5686048", "0.5674001", "0.5663777", "0.5611686", "0.5566049", "0.5555919", "0.5525453", "0.55074465", "0.5486064", "0.5476782", "0.54587424", "0.54584545", "0.5458185", "0.54244345", "0.53984183", "0.53634214", "0.53292894", "0.5325081", "0.532345...
0.78890985
0
Used to add products to the current subscription. It is encouraged to always use this method when you want to add a product to a subscription, so you always have control of what happens here. This also creates a product history with the current subscription, product, and date, with the type 'A' (Activation).
def add_product( self, product, address, copies=1, message=None, instructions=None, route_id=None, order=None, seller_id=None, override_date=None, label_contact=None, ): sp = SubscriptionProduct.objects.create( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_product_history(\n self,\n subscription,\n product,\n new_status,\n campaign=None,\n seller=None,\n override_date=None,\n ):\n # TODO: this method should be migrated to the Subscription model\n\n history_of_this_product = subscription.contac...
[ "0.70489734", "0.68279564", "0.66193235", "0.6583986", "0.6343731", "0.6334137", "0.62367344", "0.61137897", "0.6008538", "0.5986317", "0.59798837", "0.59118116", "0.5888556", "0.58400524", "0.58222914", "0.5775853", "0.57492256", "0.5745395", "0.5666695", "0.56510544", "0.56...
0.71196955
0
Used to remove products from the current subscription. It is encouraged to always use this method when you want to remove a product from a subscription, so you always have control of what happens here. This also creates a product history with the current subscription, product, and date, with the type 'D' (Deactivation)
def remove_product(self, product): try: sp = SubscriptionProduct.objects.get(subscription=self, product=product) sp.delete() except SubscriptionProduct.DoesNotExist: pass else: self.contact.add_product_history(self, product, "D")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removeProduct(self, *args):\n return _libsbml.Reaction_removeProduct(self, *args)", "def remove_product(self, product_id):\n\n cur.execute(\"\"\"DELETE FROM catalogue WHERE productid = ? AND vendorname = ?\"\"\",\n (product_id, self.vendorname))", "def delete_product_from_g...
[ "0.6247508", "0.56590396", "0.55963165", "0.5595322", "0.5497862", "0.54530734", "0.54368997", "0.5419161", "0.52681804", "0.5264107", "0.52634674", "0.5261236", "0.52172333", "0.51957965", "0.5186334", "0.5185944", "0.5162035", "0.5155476", "0.5127499", "0.51182806", "0.5112...
0.7667853
0
Gets the billing name for the contact. If it doesn't have one, then the contact's name is returned. Used primarily in invoicing.
def get_billing_name(self): if self.billing_name: return self.billing_name else: return self.contact.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contact_name(self) -> str:\n return pulumi.get(self, \"contact_name\")", "def billing_contact(self):\n return self._billing_contact", "def billing_contact_user(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"billing_contact_user\")", "def customer_name(self):\n ...
[ "0.72753066", "0.6679072", "0.64184", "0.6281225", "0.6215214", "0.6215214", "0.61888754", "0.61753666", "0.61308825", "0.61308825", "0.61308825", "0.60813963", "0.60813963", "0.6053672", "0.59911233", "0.59021527", "0.59021527", "0.5865127", "0.5850656", "0.58192235", "0.581...
0.86943054
0
Gets the billing phone for the contact. If it doesn't have one, then the contact's phone is returned. Used primarily in invoicing.
def get_billing_phone(self): if self.billing_phone: return self.billing_phone else: return self.contact.phone
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def billing_contact(self):\n return self._billing_contact", "def getPhone(self):\n return self.phone", "def phone(self):\n return self._phone", "def phone(self):\n return self._phone", "def phone(self):\n return self._phone", "def phone(self):\n\n return self._ph...
[ "0.72117543", "0.69185233", "0.6816935", "0.6816935", "0.6816935", "0.68060094", "0.67518926", "0.6579222", "0.65608084", "0.6559647", "0.63917357", "0.6354833", "0.6352409", "0.63150704", "0.62963", "0.62963", "0.62078226", "0.62078226", "0.61214375", "0.6061901", "0.6044865...
0.8716133
0
Gets the billing id_document for the contact. It chooses between rut, id_document and the contact_id_document in that order. Used primarily in invoicing.
def get_billing_document(self): if self.rut: return self.rut elif self.billing_id_doc: return self.billing_id_doc else: return self.contact.id_document
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contact_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"contact_id\")", "def contact_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"contact_id\")", "def _getcontact(id):\n contact = {}\n idwrapper = {}\n \n try:\n contact[\"name\"] = r.get(\"uid:\" + ...
[ "0.5683501", "0.5683501", "0.56735724", "0.5603914", "0.5582864", "0.5566173", "0.55428797", "0.55278647", "0.55261034", "0.54602784", "0.5372517", "0.53609663", "0.5273999", "0.52701735", "0.52635944", "0.52564985", "0.52564985", "0.52452254", "0.5202236", "0.5181843", "0.51...
0.78684276
0
Gets the billing address for the contact. If there is none set, then it will return the first address. It will return None given the case there's no available address in any products of the subscription. Used primaily in invoicing.
def get_billing_address(self): if self.billing_address: return self.billing_address.address_1 else: subscription_products = SubscriptionProduct.objects.filter( subscription=self ) addresses = [sp.address for sp in subscription_products if s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def billing_contact(self):\n return self._billing_contact", "def get_address(self):\n if self.get_entity: # needs an entity to work\n if self.building:\n address = self.get_entity.get_institutional_address()\n address.extend(self.building.get_postal_address(...
[ "0.6749646", "0.6549209", "0.64370364", "0.63437635", "0.63437635", "0.62060183", "0.60846496", "0.6025994", "0.5972726", "0.59543216", "0.5943322", "0.5896184", "0.5877524", "0.5877524", "0.5877524", "0.5830147", "0.5830147", "0.5825068", "0.5797176", "0.5797176", "0.5722416...
0.8461856
0
Gets the billing state for the contact. If it doesn't have one, it will chose the contact's first address' state. Used primarily in invoicing.
def get_billing_state(self): if self.billing_address and self.billing_address.state: return self.billing_address.state else: sub_prods = SubscriptionProduct.objects.filter(subscription=self) addresses = [sp.address for sp in sub_prods] if addresses: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def billing_contact(self):\n return self._billing_contact", "def get_billing_name(self):\n if self.billing_name:\n return self.billing_name\n else:\n return self.contact.name", "def get_billing_phone(self):\n if self.billing_phone:\n return self.bill...
[ "0.6733393", "0.626571", "0.6247604", "0.6238033", "0.62253356", "0.60487026", "0.59813064", "0.59758586", "0.5958007", "0.59036", "0.5803874", "0.5803874", "0.5647028", "0.54867643", "0.54809517", "0.54809517", "0.5471374", "0.5471374", "0.5471374", "0.5344955", "0.52707523"...
0.79510605
0
Gets the billing city for the contact. If it doesn't have one, it will chose the contact's first address' city. Used primarily in invoicing.
def get_billing_city(self): if self.billing_address and self.billing_address.city: return self.billing_address.city else: sub_prods = SubscriptionProduct.objects.filter(subscription=self) addresses = [sp.address for sp in sub_prods] if addresses: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def city(self):\n if \"city\" in self._prop_dict:\n return self._prop_dict[\"city\"]\n else:\n return None", "def city(self):\n if \"city\" in self._prop_dict:\n return self._prop_dict[\"city\"]\n else:\n return None", "def city(self):\n\n...
[ "0.70806533", "0.70806533", "0.7044645", "0.6975406", "0.69381595", "0.67983896", "0.67983896", "0.67983896", "0.67983896", "0.67983896", "0.6758192", "0.6743508", "0.6390767", "0.63457286", "0.62552303", "0.62327105", "0.6232633", "0.62152445", "0.6163769", "0.6126078", "0.6...
0.82322896
0
Returns the first product by priority
def get_first_product_by_priority(self): products = self.products.filter(type="S").order_by("billing_priority") if products.exists(): return products.first() else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_priority(self, item):\n try:\n return self.set[item][0]\n except KeyError:\n print(\"Can't get priority of non-existing item\")", "def get_product(self, code):\n candidates = list(filter(lambda c: c.code == code, self.list_products()))\n if not len(candid...
[ "0.64809465", "0.64384234", "0.61902714", "0.6139843", "0.6105018", "0.59034294", "0.5887629", "0.58555615", "0.58348155", "0.5798752", "0.57809514", "0.57279134", "0.57052654", "0.5690262", "0.5687347", "0.56850964", "0.56675524", "0.5659207", "0.56436497", "0.5585878", "0.5...
0.87777555
0
This will order products by their billing_priority attribute, and billing data included in the first SubscriptionProduct that matches that priority will be returned in a dictionary. This is used to complete the billing information for when invoices are created. Used primarily in invoicing.
def get_billing_data_by_priority(self): result = {} product = self.get_first_product_by_priority() if product: sp = self.subscriptionproduct_set.filter(product=product).first() if sp.address: result = { "route": sp.route_id, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_products_in_subscription(self, subscription):\n path = 'katello/api/v2/subscriptions/{}'.format(subscription.id)\n subscription_json = satellite_get_response(path)\n name_dict = dict(\n (\n prod_json['name'],\n satellite_json_to_entity(prod_jso...
[ "0.5509737", "0.5395463", "0.53618896", "0.52143073", "0.5201712", "0.51797724", "0.51070535", "0.5086419", "0.50125146", "0.4921268", "0.4906881", "0.48464125", "0.47775888", "0.47718132", "0.47433048", "0.47264567", "0.469503", "0.46914676", "0.4672938", "0.46599743", "0.46...
0.78009915
0
Returns the amount discounted for when the subscription is more than one month. Requires these settings to be set on the local settings.
def get_frequency_discount(self): if self.frequency == 3: return getattr(settings, "DISCOUNT_3_MONTHS", 0) elif self.frequency == 6: return getattr(settings, "DISCOUNT_6_MONTHS", 0) elif self.frequency == 12: return getattr(settings, "DISCOUNT_12_MONTHS", 0) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def monthly_benefit(self):\n \"\"\"Calculate weekly benefit of this company from this day\"\"\"\n total_purchase_price = 0\n total_selling_price = 0\n last_thirty_days = timezone.now() - timedelta(days=30)\n items = self.item_set.filter(status=\"sold\", updated_at__gte=last_thirt...
[ "0.62877953", "0.61699164", "0.6105525", "0.60971224", "0.60436356", "0.5954913", "0.59418446", "0.5904847", "0.5889601", "0.5864517", "0.58445734", "0.5741317", "0.57061625", "0.5664976", "0.5655065", "0.5608308", "0.5596242", "0.55690736", "0.550031", "0.53721046", "0.53706...
0.7160672
0
Returns an integer representing the first weekday (based on isoweekday) on the products this subscription has.
def get_first_day_of_the_week(self): if SubscriptionProduct.objects.filter( subscription=self, product__weekday=1 ).exists(): return 1 elif SubscriptionProduct.objects.filter( subscription=self, product__weekday=2 ).exists(): return 2 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weekday(self):\n\n return func.extract('dow', self.start_date) + 1", "def locale_first_weekday():\n\tfirst_weekday = 6 #by default settle on monday\n\n\ttry:\n\t\tprocess = os.popen(\"locale first_weekday week-1stday\")\n\t\tweek_offset, week_start = process.read().split('\\n')[:2]\n\t\tprocess.close(...
[ "0.7634603", "0.72620153", "0.71937007", "0.7100606", "0.70940375", "0.70748067", "0.70052755", "0.696908", "0.696908", "0.686782", "0.68471444", "0.68352985", "0.6781707", "0.6761986", "0.67520535", "0.6745715", "0.6545274", "0.6521297", "0.65017974", "0.64915496", "0.642778...
0.83789855
0
Returns invoiceitems for each product
def get_invoiceitems(self): from invoicing.models import InvoiceItem invoiceitem_list = [] # First we get all the product invoiceitems for product in self.products: # TODO: SOLVE BUNDLED PRODUCTS! item = InvoiceItem() # Get the copies for this product, when used...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invoiceitems(self):\r\n return InvoiceItems(self)", "def return_items(self):\n cur = self.cursor\n cur.execute(f\"SELECT * FROM {self.product_name}\")\n products = cur.fetchall()\n return products", "def get_products(self):\n page = 1\n out = []\n whi...
[ "0.70017594", "0.66855896", "0.65207624", "0.6497684", "0.64442295", "0.64148694", "0.6395297", "0.63928103", "0.63620645", "0.63393635", "0.63169175", "0.63153607", "0.6256051", "0.6250157", "0.62497675", "0.62283736", "0.6215448", "0.61937636", "0.61726075", "0.6098233", "0...
0.7768776
0
Takes each product for this subscription and returns a list with the copies for each.
def product_summary(self): # products = self.products.filter(type='S') # TODO: explain the usage of this commented line or remove it from .utils import process_products subscription_products = SubscriptionProduct.objects.filter(subscription=self) dict_all_products = {} for sp i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ListProducts(self):\n return copy.deepcopy(self._products)", "def sum_copies_per_product(self, product=None, new=False):\n if product is None:\n subprods = SubscriptionProduct.objects.filter(route=self, subscription__active=True)\n else:\n subprods = SubscriptionPro...
[ "0.66389644", "0.6372359", "0.6192775", "0.6183691", "0.6012321", "0.6008919", "0.5960865", "0.59557086", "0.591539", "0.58433527", "0.5830497", "0.5779049", "0.5690014", "0.5670402", "0.56616014", "0.5647406", "0.5637686", "0.56343627", "0.56197554", "0.55755746", "0.5539333...
0.67118526
0
Returns two values, one for the start and one for the end of the period that's going to be paid on this subscription.
def get_current_period(self): if not self.next_billing: return None assert self.type == "N", _("Subscription must be normal to use this method") start = self.next_billing - relativedelta(months=self.frequency) end = self.next_billing return start, end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def amount_to_pay_in_period(self):\n assert self.type == \"N\", _(\"Subscription must be normal to use this method\")\n period_start, period_end = self.get_current_period()\n price_per_day = (\n self.get_price_for_full_period() / (period_end - period_start).days\n )\n ...
[ "0.6252857", "0.61863184", "0.6160721", "0.61561406", "0.60880554", "0.6087459", "0.6063793", "0.6032833", "0.6019768", "0.59712064", "0.59394836", "0.5904312", "0.57624906", "0.57588446", "0.5736884", "0.5725289", "0.56277066", "0.56106377", "0.5581673", "0.55783534", "0.555...
0.7761805
0
Divides the price of one period between the amount of days (frequency) to get the price for one day of this subscription. Then multiplies the value of this single day by the amount of days that have passed since the start of the period, giving as a result the amount that the customer has already paid. This is useful to...
def amount_already_paid_in_period(self): assert self.type == "N", _("Subscription must be normal to use this method") period_start, period_end = self.get_current_period() price_per_day = ( self.get_price_for_full_period() / (period_end - period_start).days ) days_alre...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def amount_to_pay_in_period(self):\n assert self.type == \"N\", _(\"Subscription must be normal to use this method\")\n period_start, period_end = self.get_current_period()\n price_per_day = (\n self.get_price_for_full_period() / (period_end - period_start).days\n )\n ...
[ "0.6303654", "0.6007813", "0.55935836", "0.5568597", "0.5533616", "0.5408784", "0.53791", "0.5367118", "0.5322472", "0.52189183", "0.51695794", "0.51471466", "0.5137264", "0.503475", "0.50263155", "0.50206846", "0.5014889", "0.5012917", "0.49996305", "0.4996481", "0.49523568"...
0.6241355
1
Divides the price of one period between the amount of days (frequency) to get the price for one day of this subscription. Then multiplies the value of this single day by the amount of days that have passed since the start of the period, giving as a result the amount that the customer has yet to pay.
def amount_to_pay_in_period(self): assert self.type == "N", _("Subscription must be normal to use this method") period_start, period_end = self.get_current_period() price_per_day = ( self.get_price_for_full_period() / (period_end - period_start).days ) days_not_used =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_price_for_full_period(self):\n from .utils import calc_price_from_products\n\n summary_of_products = self.product_summary()\n frequency = self.frequency\n price = calc_price_from_products(summary_of_products, frequency)\n return price", "def amount_already_paid_in_perio...
[ "0.63601166", "0.6031539", "0.57353836", "0.57038665", "0.5697343", "0.5652752", "0.562607", "0.56000257", "0.54350585", "0.53622705", "0.5336522", "0.5317782", "0.53067946", "0.5294332", "0.52442366", "0.5220777", "0.5146846", "0.51338613", "0.509506", "0.5093615", "0.507654...
0.66041255
0
Shows an asterisk depending on which weekdays the subscription has products in. This is used in logistics.
def render_weekdays(self): products = self.products.filter(type="S") response = "<table><tr>" if products.filter(weekday=1).exists(): response += "<td>*</td>" else: response += "<td></td>" if products.filter(weekday=2).exists(): response += "<t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def info():\n\n\t info = \"This package determines the day of the week.\"\n\t print(info)", "def weekly():", "def get_weekday(self):\n weekdays = dict(PRODUCT_WEEKDAYS)\n return weekdays.get(self.weekday, \"N/A\")", "def day_of_week(self):\n day_of_week_names = ['Monday', 'Tuesday', 'Wed...
[ "0.5607956", "0.5562305", "0.5316422", "0.52950746", "0.52692235", "0.513908", "0.512714", "0.5123601", "0.51166713", "0.5115938", "0.50918335", "0.506186", "0.50614196", "0.5032122", "0.49700102", "0.49646038", "0.49457192", "0.49457192", "0.49444526", "0.49432766", "0.49299...
0.6195554
0
Returns true if the subscription has a Tuesday product.
def has_tuesday(self): return self.products.filter(type="S", weekday=2).exists()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_wednesday(self):\n return self.products.filter(type=\"S\", weekday=3).exists()", "def has_weekend(self):\n return self.products.filter(type=\"S\", weekday=10).exists()", "def has_thursday(self):\n return self.products.filter(type=\"S\", weekday=4).exists()", "def has_monday(self)...
[ "0.79033303", "0.7433568", "0.7363184", "0.70281404", "0.66000545", "0.5900313", "0.5836925", "0.56731385", "0.55946356", "0.5543228", "0.55162776", "0.5497049", "0.5488144", "0.547877", "0.54727805", "0.5456891", "0.543672", "0.54349643", "0.54203504", "0.54126585", "0.54076...
0.83221126
0
Returns true if the subscription has a Wednesday product.
def has_wednesday(self): return self.products.filter(type="S", weekday=3).exists()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_thursday(self):\n return self.products.filter(type=\"S\", weekday=4).exists()", "def has_weekend(self):\n return self.products.filter(type=\"S\", weekday=10).exists()", "def has_tuesday(self):\n return self.products.filter(type=\"S\", weekday=2).exists()", "def has_friday(self):\...
[ "0.7999227", "0.77904016", "0.74677527", "0.6989771", "0.6985255", "0.6812778", "0.6110862", "0.5900883", "0.5791354", "0.5783273", "0.5782799", "0.57391125", "0.5735744", "0.56574214", "0.56529266", "0.5615679", "0.556945", "0.549226", "0.5433178", "0.5399697", "0.53904605",...
0.8656813
0
Returns true if the subscription has a Thursday product.
def has_thursday(self): return self.products.filter(type="S", weekday=4).exists()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_wednesday(self):\n return self.products.filter(type=\"S\", weekday=3).exists()", "def has_tuesday(self):\n return self.products.filter(type=\"S\", weekday=2).exists()", "def has_weekend(self):\n return self.products.filter(type=\"S\", weekday=10).exists()", "def has_friday(self):...
[ "0.8011751", "0.77116203", "0.7494331", "0.72076064", "0.68151414", "0.6368107", "0.61029273", "0.5982623", "0.57970923", "0.57579887", "0.56541497", "0.5562794", "0.55601287", "0.5555926", "0.55064213", "0.54724693", "0.54631317", "0.54424846", "0.54281855", "0.5418709", "0....
0.8805305
0
Returns true if the subscription has a Friday product.
def has_friday(self): return self.products.filter(type="S", weekday=5).exists()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_weekend(self):\n return self.products.filter(type=\"S\", weekday=10).exists()", "def has_wednesday(self):\n return self.products.filter(type=\"S\", weekday=3).exists()", "def has_thursday(self):\n return self.products.filter(type=\"S\", weekday=4).exists()", "def has_tuesday(self...
[ "0.7637973", "0.7567508", "0.75327075", "0.7065873", "0.65174216", "0.6368904", "0.6181212", "0.61077476", "0.5917382", "0.58119035", "0.57857114", "0.57834", "0.57660586", "0.5702861", "0.56998616", "0.5680689", "0.5678202", "0.5603491", "0.55724514", "0.5518139", "0.5485771...
0.8796624
0
Returns true if the subscription has a Weekend product.
def has_weekend(self): return self.products.filter(type="S", weekday=10).exists()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_wednesday(self):\n return self.products.filter(type=\"S\", weekday=3).exists()", "def has_thursday(self):\n return self.products.filter(type=\"S\", weekday=4).exists()", "def has_tuesday(self):\n return self.products.filter(type=\"S\", weekday=2).exists()", "def is_weekend() -> b...
[ "0.748854", "0.69645387", "0.68662715", "0.6862472", "0.6481014", "0.64291966", "0.6000979", "0.5917448", "0.57905054", "0.57651114", "0.57306504", "0.5691392", "0.5668606", "0.5651247", "0.56261396", "0.5589581", "0.55890775", "0.5559175", "0.5558002", "0.5557032", "0.555141...
0.82367826
0
Returns the unsubscription reason.
def get_unsubscription_reason(self): unsubscription_reasons = dict(settings.UNSUBSCRIPTION_REASON_CHOICES) return unsubscription_reasons.get(self.unsubscription_reason, "N/A")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_unsubscription_channel(self):\n unsubscription_channels = dict(settings.UNSUBSCRIPTION_CHANNEL_CHOICES)\n return unsubscription_channels.get(self.unsubscription_channel, \"N/A\")", "def reason(self) -> str:\n return pulumi.get(self, \"reason\")", "def get_unsubscription_type(self):...
[ "0.67562884", "0.6677292", "0.66479945", "0.66324896", "0.6481102", "0.6330465", "0.622456", "0.6197353", "0.61534196", "0.6085014", "0.6073488", "0.60605896", "0.6048066", "0.6036894", "0.60239834", "0.6007807", "0.5993624", "0.5964749", "0.59406304", "0.5928856", "0.5863522...
0.8568551
0
Returns the unsubscription reason.
def get_unsubscription_channel(self): unsubscription_channels = dict(settings.UNSUBSCRIPTION_CHANNEL_CHOICES) return unsubscription_channels.get(self.unsubscription_channel, "N/A")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_unsubscription_reason(self):\n unsubscription_reasons = dict(settings.UNSUBSCRIPTION_REASON_CHOICES)\n return unsubscription_reasons.get(self.unsubscription_reason, \"N/A\")", "def reason(self) -> str:\n return pulumi.get(self, \"reason\")", "def get_unsubscription_type(self):\n ...
[ "0.8568551", "0.6677292", "0.66479945", "0.66324896", "0.6481102", "0.6330465", "0.622456", "0.6197353", "0.61534196", "0.6085014", "0.6073488", "0.60605896", "0.6048066", "0.6036894", "0.60239834", "0.6007807", "0.5993624", "0.5964749", "0.59406304", "0.5928856", "0.5863522"...
0.67562884
1
Returns the payment type.
def get_payment_type(self): payment_types = dict(settings.SUBSCRIPTION_PAYMENT_METHODS) return payment_types.get(self.payment_type, "N/A")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def payment_type(self) -> str:\n return pulumi.get(self, \"payment_type\")", "def pay_type(self) -> str:\n return pulumi.get(self, \"pay_type\")", "def pay_type(self) -> str:\n return pulumi.get(self, \"pay_type\")", "def pay_type(self) -> pulumi.Output[str]:\n return pulumi.get(s...
[ "0.92547166", "0.843507", "0.843507", "0.82871956", "0.80102414", "0.8000726", "0.7407751", "0.7407751", "0.7096854", "0.6870054", "0.6848388", "0.6848388", "0.6848388", "0.6848388", "0.6848388", "0.6848388", "0.6848388", "0.6848388", "0.6848388", "0.6848388", "0.6848388", ...
0.8578038
1
Returns all the activities on this campaign, for a specific seller. Activities on a campaign imply that the contact has been scheduled to be called in the future.
def get_activities_by_seller(self, seller, status=None, type=None, datetime=None): acts = Activity.objects.filter(campaign=self, seller=seller).order_by('datetime') if status: acts = acts.filter(status__in=status) if type: acts = acts.filter(activity_type__in=type) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_activities(cls):\n objs = cls.objects\n return objs", "def activities(self):\r\n return v3.Activities(self)", "def activities(self):\n return self._activities", "def get_already_contacted(self, seller_id):\n return self.contactcampaignstatus_set.filter(\n ...
[ "0.59208065", "0.5899923", "0.5818823", "0.5736359", "0.5720688", "0.55833286", "0.5477893", "0.540893", "0.5273918", "0.52573407", "0.5247901", "0.5240242", "0.52282554", "0.5195234", "0.51873195", "0.5182521", "0.51658654", "0.501627", "0.5011079", "0.4955191", "0.48948267"...
0.68809056
0
Returns the ContactCampaignStatus objects for all Contacts that have not been called yet (status=1)
def get_not_contacted(self, seller_id): return self.contactcampaignstatus_set.filter(seller_id=seller_id, status__in=[1, 3])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_already_contacted(self, seller_id):\n return self.contactcampaignstatus_set.filter(\n seller_id=seller_id, status=2\n )", "def campaign_status(self):\n return self._campaign_status", "def get_active_contact(self):\n list_contact = Contact.objects.filter(phonebook_...
[ "0.6204409", "0.5799874", "0.5657505", "0.56244934", "0.5607043", "0.53916603", "0.53543097", "0.5330877", "0.5271085", "0.52295774", "0.5223064", "0.5221222", "0.52025133", "0.51303506", "0.51303506", "0.50963914", "0.50958073", "0.50875974", "0.50099576", "0.49826843", "0.4...
0.6219367
0
Returns the count of ContactCampaignStatus objects for all Contacts that have not been called yet (status=1)
def get_not_contacted_count(self, seller_id): return self.get_not_contacted(seller_id).count()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_subscribers(self):\n return self.request(\"count:Contact\", [ None ])", "def status_counts(self):\n return self._status_counts", "def get_already_contacted_count(self, seller_id):\n return self.get_already_contacted(seller_id).count()", "def campaign_status(self):\n retu...
[ "0.58729506", "0.5697539", "0.56552345", "0.5644677", "0.5614512", "0.55899376", "0.5523953", "0.5406303", "0.5382926", "0.53309304", "0.532123", "0.5316718", "0.53129387", "0.5263166", "0.5259178", "0.52466035", "0.5164468", "0.51618105", "0.5160587", "0.5086446", "0.5086372...
0.5831577
1
Returns the ContactCampaignStatus objects for all Contacts that have already been called yet (status=2, 3)
def get_already_contacted(self, seller_id): return self.contactcampaignstatus_set.filter( seller_id=seller_id, status=2 )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_active_contact(self):\n list_contact = Contact.objects.filter(phonebook__campaign=self.id,\n status=CONTACT_STATUS.ACTIVE).all()\n if not list_contact:\n return False\n return list_contact", "def find_campaigns_as_caller(caller)...
[ "0.57124084", "0.56400394", "0.5551901", "0.55213046", "0.55115336", "0.54854417", "0.54402715", "0.54215056", "0.5379803", "0.53058594", "0.53005534", "0.51895696", "0.51827735", "0.51389533", "0.50814724", "0.50814724", "0.505643", "0.5013041", "0.50040466", "0.49269885", "...
0.6468503
0
Returns the seller from the contact this activity is assigned for.
def get_contact_seller(self): return self.contact.seller
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seller(self):\n if \"seller\" in self._prop_dict:\n return self._prop_dict[\"seller\"]\n else:\n return None", "def seller_from_user(context: Dict[str, Any]) -> Optional[Seller]:\n user: User = context[\"user\"]\n if user.is_authenticated:\n try:\n ...
[ "0.7485591", "0.5901869", "0.58646476", "0.57309294", "0.5610337", "0.55715734", "0.55709654", "0.55709654", "0.5546228", "0.5507627", "0.5496031", "0.5492068", "0.5451132", "0.5379029", "0.5316402", "0.52811015", "0.52564305", "0.5247079", "0.5247", "0.5247", "0.52305055", ...
0.7961372
0
Returns a description of the direction of the activity. That can be In or Out.
def get_direction(self): directions = dict(ACTIVITY_DIRECTION_CHOICES) return directions.get(self.direction, "N/A")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def direction(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"direction\")", "def direction(self) -> str:\n return pulumi.get(self, \"direction\")", "def get_direction(self):\n return self.direction", "def get_direction(self):\r\n return self.__direction", "def directio...
[ "0.7737809", "0.7479199", "0.74217033", "0.7307552", "0.7224062", "0.7208195", "0.7044395", "0.70183897", "0.70051634", "0.6928032", "0.691956", "0.68777025", "0.6851188", "0.6831645", "0.6790336", "0.67377764", "0.6731791", "0.67219067", "0.67007256", "0.6678404", "0.6668446...
0.7751099
0
Returns the last activity for the contact, on this exact campaign.
def get_last_activity(self): return Activity.objects.filter(campaign=self.campaign, status="P", contact=self.contact).latest("id")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_last_activity(self):\n last_activities = self.get_last_activities(n=1)\n return last_activities[0]", "def last_activity(self):\n if self.activity_set.exists():\n return self.activity_set.latest(\"id\")\n else:\n return None", "def last_time(self) -> dat...
[ "0.8021665", "0.7515905", "0.68185985", "0.67223203", "0.6343814", "0.6304953", "0.63015753", "0.61637557", "0.6048075", "0.5997703", "0.59606355", "0.58743024", "0.57338977", "0.5712074", "0.5694064", "0.56693697", "0.5622185", "0.5594319", "0.55657274", "0.55362064", "0.551...
0.87714857
0
Returns a description of the resolution for this campaign on this contact.
def get_campaign_resolution(self): campaign_resolutions = dict(CAMPAIGN_RESOLUTION_CHOICES) return campaign_resolutions.get(self.campaign_resolution, "N/A")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Resolution(self):\n\t\treturn self._get_attribute('resolution')", "def resolution(self):\n return self._resolution", "def res_description(self):\n return self.get(\"res_description\", decode=True)", "def get_resolution(self):\n return self.__resolution", "def get_description(self):...
[ "0.66166127", "0.6521925", "0.6436431", "0.63877213", "0.62083656", "0.61682487", "0.596611", "0.5934394", "0.59258974", "0.5867041", "0.5824322", "0.578653", "0.57848024", "0.5735983", "0.5665601", "0.55896026", "0.558924", "0.556708", "0.55272025", "0.5522097", "0.5521857",...
0.73374283
0
Set the 'cancelled' flag so the thread exits.
def cancel(self): self.cancelled = True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel(self):\n self.cancelled.set()", "def mark_cancelled(self):\n self.status = STATUS_CANCELED", "def do_uncancel(self):\r\n self.write({'cancelled': False})", "def set_status_update_waiter_cancelled(self):\n self.set_state(CHANNEL_MOVE_STATE_CANCELLED)\n self.set_st...
[ "0.75206125", "0.73317796", "0.725674", "0.71834475", "0.71784335", "0.7120356", "0.7109169", "0.6906426", "0.69026905", "0.683166", "0.67981595", "0.67532504", "0.6739393", "0.66940963", "0.6657798", "0.6641062", "0.6619799", "0.6615156", "0.6611922", "0.6600137", "0.6600137...
0.74287105
1
Change the Node's sleep time between function calls.
def set_sleep_time(self, time): self.sleep_time = time
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sleep(self, amount: float):\n time.sleep(amount)", "def sleep(sleep_time=0.250):\n time.sleep(sleep_time)", "def deepsleep(time_ms: int = None) -> None:", "def sleep_for(timeToSleep):\r\n time.sleep(timeToSleep)", "async def sleep(cls, delay: float) -> None:", "def sleep(seconds):\n time....
[ "0.7682915", "0.7612475", "0.7465841", "0.73927754", "0.7347401", "0.7290041", "0.7290041", "0.7264841", "0.7252344", "0.71803594", "0.7167534", "0.7126728", "0.7065027", "0.7045028", "0.7004403", "0.69281256", "0.6792978", "0.67551804", "0.67542213", "0.6740669", "0.67119396...
0.76355064
1
Register environment selection flags.
def register_env_select_flags( parser: ArgumentParser, default: CliEnv | None, multiple: bool = True, # noqa: FBT001, FBT002 group_only: bool = False, # noqa: FBT001, FBT002 ) -> ArgumentParser: if multiple: group = parser.add_argument_group("select target environment(s)") add_to: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def env_callback(args):\n return {\n \"MY_CUSTOM_FLAG\": args.my_custom_flag\n }", "def register_globals ():\n\n # This feature is used to determine which OS we're on.\n # In future, this may become <target-os> and <host-os>\n # TODO: check this. Compatibility with bjam names? Subfeature fo...
[ "0.5905224", "0.56406796", "0.5604462", "0.55191755", "0.5496644", "0.5454322", "0.5442913", "0.54183125", "0.5416355", "0.53807175", "0.5366575", "0.53401583", "0.53310597", "0.5293394", "0.5283587", "0.52786773", "0.5274902", "0.52701205", "0.52452815", "0.52281153", "0.519...
0.66334325
0
epsilon decays as the current episode gets higher because we want the agent to explore more in earlier episodes (when it hasn't learned anything) explore less in later episodes (when it has learned something) i.e. assume that episode number is directly related to learning
def epsilon(current_episode, num_episodes): # return 1 - (current_episode/num_episodes) return .5 * .9**current_episode
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def q_learning(env, agent, num_episodes, batch_size, epsilon, epsilon_min, epsilon_decay, folder):\n \n # Keeps track of useful statistics\n stats = plotting.EpisodeStats(\n episode_lengths=np.zeros(num_episodes),\n episode_rewards=np.zeros(num_episodes))\n\n\n for i_episode in range(num_ep...
[ "0.7373344", "0.72590876", "0.71999145", "0.7132823", "0.70544076", "0.7023157", "0.69378114", "0.6925371", "0.6911052", "0.68459004", "0.6752915", "0.67482215", "0.668959", "0.6643346", "0.6621843", "0.66143537", "0.6612828", "0.6591157", "0.65705395", "0.65690637", "0.65672...
0.8238254
0
Parse an iPhoto AlbumData.xml file, keeping the interesting bits.
def parseAlbumData(self, filename): doc = parse(filename) stack = [] last_top_key = None if self.use_album: album_list_key = "List of Albums" else: album_list_key = "List of Rolls" for event, node in doc: if event == START_ELEMENT: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def album_parser(data):\n album_ids = []\n for item in data['data']:\n album_ids.append(item['id'])\n return album_ids", "def parse_data(self):\n\n msg = self.xml['dom'].childNodes[0]\n self.data = xml_to_dicts(msg, False)\n\n # Get some metadata together\n self.id = \...
[ "0.65253925", "0.59940094", "0.5880419", "0.5795567", "0.57881397", "0.5780533", "0.57344276", "0.57285273", "0.57080084", "0.5671317", "0.56547713", "0.56530684", "0.5651814", "0.56417334", "0.5634651", "0.5559751", "0.552812", "0.5520787", "0.5499363", "0.54895693", "0.5455...
0.74945784
0
Given a DOM node, convert the plist (fragment) it refers to and return the corresponding Python data structure. If interesting_keys is a list, "dict" keys will be filtered so that only those nominated are returned (for ALL descendant dicts). Numeric keys aren't filtered.
def dePlist(self, node, interesting_keys=None): ik = interesting_keys dtype = node.nodeName if dtype == 'string': return self.getText(node) elif dtype == 'integer': try: return int(self.getText(node)) except ValueError: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_plist(path: str) -> dict:\n return _read_plist(path, plistlib.FMT_XML)", "def __getitem__(self, key):\n if isinstance(key, list):\n return plist([self[k] for k in key], root=plist([KeyValue(k, self[k]) for k in key]))\n else:\n return dict.__getitem__(self, key)", "def elem2dict(nod...
[ "0.5124263", "0.5013636", "0.4812486", "0.4779492", "0.47377607", "0.4701311", "0.46952295", "0.4666734", "0.46113923", "0.45621026", "0.45284662", "0.45052168", "0.44883114", "0.44732088", "0.44579843", "0.44518983", "0.4401898", "0.438814", "0.43835205", "0.4365073", "0.435...
0.6786015
0
Walk through the events or albums (depending on the value of albums) in this library and apply each function in the list funcs to each
def walk(self, funcs): if self.use_album: targetName = "AlbumName" albums = [a for a in self.albums if a.get("Album Type", None) == "Regular"] else: targetName = "RollName" albums = self.albums i = 0 for folder in albu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def album_list(self):\n\n artist_id = self.addon_args[\"artist_id\"][0]\n\n xbmcplugin.setContent(self.addon_handle, \"albums\")\n\n for album in self.connection.walk_artist(artist_id):\n self.add_album(album)\n\n xbmcplugin.addSortMethod(\n self.addon_handle, xbmc...
[ "0.5338826", "0.5199902", "0.51033753", "0.508161", "0.5081003", "0.50747555", "0.50526106", "0.5039024", "0.50192744", "0.50101346", "0.49962336", "0.49476117", "0.49463356", "0.49420202", "0.49274322", "0.4924771", "0.49216843", "0.49067512", "0.48841634", "0.4882843", "0.4...
0.6805687
0
Copy an image from the library to a folder in the dest_dir. The name of the folder is based on folderName and folderDate; if folderDate is None, it's only based upon the folderName. If use_metadata is True, also write the image metadata from the library to the copy. If use_faces is True, faces will be saved as keywords...
def copyImage(self, imageId, folderName, folderDate, modified = False): try: image = self.images[imageId] except KeyError: raise iPhotoLibraryError, "Can't find image #%s" % imageId if not os.path.exists(folderName): try: if not self.test: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def form_sample_folder(self, input_folder, target_folder, sample_name):\n print(f'processing {sample_name} folder.')\n # first make a subfolder to contain the images - e.g. 'target_folder/sample_name'\n sample_dir = join(target_folder, sample_name)\n if not os.path.exists(sample_dir):\n...
[ "0.5375309", "0.51825666", "0.508288", "0.5036496", "0.49278748", "0.49242926", "0.49131545", "0.48717657", "0.4862905", "0.4858619", "0.48510352", "0.48286095", "0.48278707", "0.48068732", "0.47598246", "0.47391027", "0.47248337", "0.4705147", "0.47013077", "0.4696376", "0.4...
0.595224
0
Write the metadata from the library for imageId to filePath. If filePath is None, write it to the photo in the library. If use_faces is True, iPhoto face names will be written to keywords.
def writePhotoMD(self, imageId, filePath=None): try: image = self.images[imageId] except KeyError: raise iPhotoLibraryError, "Can't find image #%s" % imageId if not filePath: if self.originals: if "OriginalPath" in image: m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addPhoto(fileName, personName):\n\n #Check if image is a jpg\n if (fileName[-4:] != \".jpg\"):\n print(\"\\n[!] File extenstion must be .jpg!\\n\")\n return\n\n #Check image exists\n if (not os.path.isfile(fileName)):\n print(\"\\n[!] File does not exist!\\n\")\n return\...
[ "0.50928354", "0.50730085", "0.50216943", "0.4995194", "0.49944973", "0.49923807", "0.49398592", "0.49126682", "0.48790294", "0.48692298", "0.4854108", "0.47708428", "0.47395146", "0.4722252", "0.47185796", "0.47097844", "0.47096056", "0.46954182", "0.4680011", "0.46773535", ...
0.7204329
0
start(force_restart=0, timeout=60) Start remote slave processes. Description Start the remote slave interpreters in the cluster. The timeout value is specified in seconds and defaults to 60. The timeout starts counting down only after ssh/rsh has tried to start all the remote processes. This means the actual time in th...
def start(self,force_restart=0,timeout=60): if not force_restart and self.is_running(): return # start the worker processes. for worker in self.workers: worker.start_server() if not self.is_running(): print ' Starting Servers' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_slave_worker():\n print(\"Starting slave worker\")\n r = req.patch(f\"{SLAVE_API_URL}/formation/worker\", json=API_PAYLOAD_1, headers=SLAVE_API_HEADERS)\n if r.status_code != req.codes.ok:\n print(\"Unable to start the worker dyno on slave\")\n print(r.text)\n return False\n...
[ "0.59675866", "0.590452", "0.56354386", "0.56137675", "0.5592708", "0.5580869", "0.55625385", "0.5503754", "0.5502141", "0.5361299", "0.53241587", "0.53121626", "0.5281268", "0.52802044", "0.52685004", "0.5257645", "0.52353615", "0.52231896", "0.5218573", "0.52134603", "0.516...
0.67416304
0
stop() Tell all remote slaves to terminate. Description stop calls sys.exit(0) on all the slave processes so that they will terminate gracefully. Note that if, for some reason, you are unable to connect to a remote processes due to some socket error, you'll have to kill the slave process by hand.
def stop(self): for worker in self.workers: import sys; sys.stdout.flush() try: worker.exec_code('import sys;sys.exit(0)') except: #should really do something here to # trap non-SystemExit errors. pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def terminate_slaves(self):\n self.master.terminate_slaves()", "def stop_all():\n\twhile _running:\n\t\t_running[0].stop(noerror=True)", "def stop(self):\n self.log.info(\"Stopping servers\")\n if self.runner.job.yaml_params.is_nvme():\n self.kill()\n self.storage_res...
[ "0.7355106", "0.66860104", "0.6615295", "0.6604181", "0.65941006", "0.6561907", "0.65497446", "0.65311134", "0.64733106", "0.64280826", "0.635675", "0.6324678", "0.63125056", "0.6295344", "0.6278813", "0.62739265", "0.6267419", "0.6254669", "0.62507206", "0.6219218", "0.62020...
0.67412335
1
is_running(timeout=0) > 0 or 1 check all the slave processes in the cluster are up and running. if timeout is specified, is_running will continually check if the cluster is_running until it either gets a positive result or gives up and returns 0 after the specified number of seconds.
def is_running(self,timeout=0): # wait for them to start import time st = time.time() still_waiting = 1 while still_waiting: try: # Send a simple command to all workers # and wait till they handle it successfully self.e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_instance_running(self):\n try:\n self.instance.wait(timeout=1)\n except psutil.TimeoutExpired:\n pass\n return self.instance.is_running()", "def is_running(self) -> bool:\n return self.executor.is_alive() if self.executor else False", "async def running(...
[ "0.6553389", "0.6502707", "0.6413581", "0.6377632", "0.6294592", "0.6243133", "0.623014", "0.62272906", "0.616547", "0.61529255", "0.61501044", "0.61483437", "0.6140799", "0.60886705", "0.6068144", "0.6033086", "0.60108936", "0.59781617", "0.59781617", "0.59781617", "0.597500...
0.78950197
0
_send(package, addendum=None) send a package to all slaves. Description _send takes a package packed up by a packer object (see sync_cluster) and sends it to each of the slave processes. addendum is either None or a list with the same length as there are slave processes. Each entry is a small package of additional info...
def _send(self,package,addendum=None): if addendum: N = len(addendum) assert(N <= len(self.workers)) else: N = len(self.workers) self.send_exc = {} self.had_send_error = [] for i in range(N): try: if not addendum: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send(self, data, unitindices=None, confirm=False):\n\n # TEST\n confirm = False\n\n if unitindices is None:\n unitindices = xrange(self.workers)\n if not confirm:\n [self.parent_conns[i].send(data) for i in unitindices]\n else:\n while True:\n...
[ "0.61424744", "0.580894", "0.5774594", "0.5474106", "0.5426062", "0.5318972", "0.53153694", "0.5213522", "0.52068084", "0.5200758", "0.51669294", "0.5166509", "0.51515573", "0.5150636", "0.5056886", "0.50452703", "0.503232", "0.5028009", "0.5002065", "0.49930203", "0.49819425...
0.8050387
0
_recv() retreive results from slave processes. Description Retreive results from all slave processes that were successfully sent a package. If an error occurs while receiving from one of the slaves, the error is noted and the results from the other slaves are retreived. A tuple the results from all workers is returned ...
def _recv(self): self.had_recv_error = [] self.recv_exc = {} results = [] import sys; #only listen on workers involved in calculation. for worker in self.workers[:self.Nsent]: if worker in self.had_send_error: results.append(None) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recv(self, unitindices=None): # ,discard = None, keep = None):\n if unitindices is None:\n unitindices = xrange(self.workers)\n result = []\n i = 0\n# discarded = []\n# kept = []\n# log_debug((unitindices, self.parent_conns))\n while i < len(unitindi...
[ "0.62762433", "0.61129236", "0.56425345", "0.56387585", "0.5613972", "0.55644256", "0.5537771", "0.55095595", "0.54262745", "0.5399296", "0.53790534", "0.5372627", "0.53541785", "0.53327423", "0.53177756", "0.5311333", "0.52756435", "0.5241029", "0.5229062", "0.5167441", "0.5...
0.76762754
0
_send_recv(package,addendum=None) > results Description send a message to each worker in turn and then immediately began listening for the results. All sends are done before listening for results from any of the slave processes. See _send and _recv for more information. If an error occurs during either the send or recv...
def _send_recv(self,package,addendum=None): self._send(package,addendum) self.last_results = self._recv() if(len(self.send_exc) or len(self.recv_exc)): self.handle_error() return self.last_results
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _recv(self):\n\n self.had_recv_error = []\n self.recv_exc = {}\n results = []\n import sys;\n #only listen on workers involved in calculation.\n for worker in self.workers[:self.Nsent]:\n if worker in self.had_send_error:\n results.append(None...
[ "0.70221955", "0.6246846", "0.5740144", "0.5653335", "0.5544397", "0.54993975", "0.5496557", "0.54669386", "0.5269493", "0.525346", "0.52460265", "0.5244592", "0.5143056", "0.51325536", "0.51310486", "0.51261157", "0.5124277", "0.5101583", "0.5087944", "0.50807655", "0.504967...
0.7980371
0
handle_error() make sense of send and recv errors Description Error handling attempts to examine the errors that occuer during remote execution and report them in the least verbose manner. If the same error occurs on all slaves, it tries to only report it once. Otherwise it reports all the errors that occur on slaves a...
def handle_error(self): # perhaps do some nifty stuff here to # mark bad workers, try to restart, etc. msg = '' Nworkers = len(self.workers) Nsend_errors = len(self.had_send_error) Nsend_error_types = len(self.send_exc.keys()) Nrecv_errors = len(self.had_recv_erro...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error_handler(msg):\n print(\"Server Error: %s\" % msg)", "def error_handler(msg):\n print \"Server Error: %s\" % msg", "def error_handler(msg):\n print \"Server Error: %s\" % msg", "def handle_error(self):\n self.cmd_channel.debug(\"DTPHandler.handle_error()\")\n try:\n ...
[ "0.6415015", "0.6402821", "0.6402821", "0.63423985", "0.6236461", "0.6134316", "0.60176396", "0.59943914", "0.593466", "0.5901477", "0.5868321", "0.58462125", "0.58436084", "0.58391523", "0.58321005", "0.5793094", "0.5737886", "0.5730986", "0.57273734", "0.5706913", "0.570008...
0.70273113
0
load() print human readable load information for slave hosts Description The load value printed is the 1 minute load average that is commonly printed by uptime on Unix machines. load depends on the implementation of numpy_proc on each slave's host OS. It will not work for Windows slave processes. However, if you are us...
def load(self): import string import numpy.distutils.proc as numpy_proc results = self.load_list() for i in range(len(self.workers)): name = string.split(self.workers[i].host,'.')[0] res = results[i] s = "%6s: %1.2f," % (name[-6:], res['load_1']) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_load_data():\n proc_stat = open(\"/proc/stat\", \"r\")\n ret = []\n #times_since_startup = proc_stat.readline().strip().split()[1:]\n for line in proc_stat:\n line_split = line.strip().split()\n if(not (\"cpu\" in line_split[0])): #we have gone past the CPU lines\n brea...
[ "0.63688195", "0.62896323", "0.6152832", "0.5916168", "0.554287", "0.5534526", "0.5520359", "0.5466271", "0.5461817", "0.5458563", "0.54556566", "0.54010874", "0.53958553", "0.5371696", "0.53630465", "0.5356972", "0.53519404", "0.53291065", "0.5318139", "0.52881193", "0.52638...
0.7384944
0
info() print human readable info about the slave hosts Description Print out the each slave interpreters host name, number and type of processors, memory usage, and current load information in human readable form. info depends on the implementation of numpy_proc on each slave's host OS. It will not work for Windows sla...
def info(self): import string results = self.info_list() labels = "%-8s %-9s %-4s %-8s %-8s %-4s" % \ ('MACHINE','CPU','GHZ','MB TOTAL', 'MB FREE','LOAD') print labels for i in range(len(self.workers)): name = string.split(self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def info_list(self):\n import numpy.distutils.proc as numpy_proc\n res = self.apply(numpy_proc.machine_info,())\n return res", "def run_info(self):\n return \"MPI: %d, OMP: %d\" % (self.mpi_procs, self.omp_threads)", "def _get_core_membind_info():\n args = [\"lscpu\", \"--par...
[ "0.6628139", "0.6029541", "0.59994787", "0.59888726", "0.59654504", "0.5912724", "0.5873242", "0.584339", "0.57711625", "0.57645833", "0.5538665", "0.54950523", "0.5493533", "0.5452326", "0.54289675", "0.5418666", "0.54113436", "0.53924394", "0.53721255", "0.5360203", "0.5355...
0.63965917
1
load_list() Return a list of slave load information dictionaries Description Retreive a dictionary with information about the load on each host processor. The dictionaries have three keys, load1, load5, and load15 indicating the 1, 5, and 15 minute load averages for the processor. These could be useful for (as yet unim...
def load_list(self): import numpy.distutils.proc as numpy_proc res = self.apply(numpy_proc.load_avg,()) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_load_data():\n proc_stat = open(\"/proc/stat\", \"r\")\n ret = []\n #times_since_startup = proc_stat.readline().strip().split()[1:]\n for line in proc_stat:\n line_split = line.strip().split()\n if(not (\"cpu\" in line_split[0])): #we have gone past the CPU lines\n brea...
[ "0.65984374", "0.65468526", "0.62084115", "0.6062331", "0.57889664", "0.5767226", "0.55753046", "0.5543519", "0.55034167", "0.5493241", "0.5443097", "0.535275", "0.5327818", "0.53258514", "0.53239393", "0.5265224", "0.5229792", "0.5228068", "0.5143339", "0.5137199", "0.510357...
0.6565332
1
info() print human readable info about the slave hosts Description Print out the each slave interpreters host name, number and type of processors, memory usage, and current load information in human readable form. info depends on the implementation of numpy_proc on each slave's host OS. It will not work for Windows sla...
def info_list(self): import numpy.distutils.proc as numpy_proc res = self.apply(numpy_proc.machine_info,()) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def info(self):\n import string\n results = self.info_list()\n labels = \"%-8s %-9s %-4s %-8s %-8s %-4s\" % \\\n ('MACHINE','CPU','GHZ','MB TOTAL',\n 'MB FREE','LOAD')\n print labels\n for i in range(len(self.workers)):\n name = st...
[ "0.6398009", "0.6030625", "0.6001482", "0.5990546", "0.5967216", "0.59123135", "0.5875806", "0.5846", "0.57706267", "0.5767146", "0.5541231", "0.5497143", "0.54949677", "0.5453637", "0.5431881", "0.5421146", "0.54144233", "0.5394256", "0.53710485", "0.5361586", "0.53574234", ...
0.6628613
0
ps(sort_by='cpu',filters) list processes on slave machines. Description List all the processes on all remote slave machines. This is like a clusterwide Unix ps command and is output in a similar human readable form. The sort_by argument allows you to sore the process list by various fields including, pid, cpu, user, ma...
def ps(self,sort_by='cpu',**filters): psl = self.ps_list(sort_by,**filters) if len(psl): print psl[0].labels_with_name() for i in psl: print i.str_with_name()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ps_list(self,sort_by='cpu',**filters):\n import operator\n import numpy.distutils.proc as numpy_proc\n res = self.apply(numpy_proc.ps_list,())\n psl = reduce(operator.add,res)\n psl = numpy_proc.ps_sort(psl,sort_by,**filters)\n return psl", "def ListProcesses(self):\...
[ "0.66693133", "0.6300955", "0.62944216", "0.57963485", "0.5615728", "0.55979764", "0.55165416", "0.54790705", "0.54333967", "0.5377084", "0.5361904", "0.53616923", "0.5353906", "0.53328574", "0.5328634", "0.5282079", "0.52597374", "0.52357227", "0.5193442", "0.5173996", "0.51...
0.6801216
0
ps_list(self,sort_by='cpu',filters) get cluster processes Description Return a list containing one numpy_proc.process objects for each process running on the cluster host machines. process objects contain a ton of information about cpu, memory, etc. used by the process. See ps for more information.
def ps_list(self,sort_by='cpu',**filters): import operator import numpy.distutils.proc as numpy_proc res = self.apply(numpy_proc.ps_list,()) psl = reduce(operator.add,res) psl = numpy_proc.ps_sort(psl,sort_by,**filters) return psl
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ps(self,sort_by='cpu',**filters):\n psl = self.ps_list(sort_by,**filters)\n if len(psl):\n print psl[0].labels_with_name()\n for i in psl: print i.str_with_name()", "def ListProcesses(self):\n stdout, stderr = self.RunCmdOnDevice(\n ['/bin/ps', '--no-headers', '-A', ...
[ "0.7186785", "0.6677296", "0.6657441", "0.61431795", "0.6073727", "0.59592265", "0.58759093", "0.5791517", "0.5747416", "0.57362986", "0.5698524", "0.56719214", "0.5671053", "0.5671053", "0.5669222", "0.56527954", "0.5619255", "0.5599501", "0.5578112", "0.556991", "0.5557092"...
0.7327976
0
nice(increment=10) > success_list increment all slave interpreter's nice value by increment. hmmm. this doesn't seem to work. see os.nice()
def nice(self,increment=10): res = self.apply(os.nice,(increment,)) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_processes(self, new_value):", "def update_cpu_through_stress(ssh_client, num_stress=0):\n if num_stress < 0:\n invalid_resource_parameter(\"CPU Allocation\", limit)\n return\n \n #Separate CPU limit into several smaller increments of 10 instead of one larger one\n for x ...
[ "0.6036316", "0.5600162", "0.5561521", "0.5558175", "0.5384459", "0.53523105", "0.52948165", "0.5276893", "0.51638585", "0.5109805", "0.51070994", "0.50984627", "0.5059864", "0.50574064", "0.5056935", "0.5005578", "0.49772373", "0.49721122", "0.4970361", "0.4964796", "0.49635...
0.72512513
0
renice(process_list,level) set nice value multiple processes Description Change the nice level of multiple remote processes. process_list is a list of numpy_proc.process objects. level is the new nice value for the listed processes. Caveats Once niced down, a process cannot be reniced back up. This is a Linux issue.
def renice(self,process_list,level): res = [] pids = {} for process in process_list: if hasattr(process,'machine'): try: worker = self.worker_by_name[process.machine] except KeyError: worker = self.worker_by_name...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nice(self,increment=10):\n res = self.apply(os.nice,(increment,))\n return res", "def setNice(self, nice=0):\n self.nice = nice", "def _set_processes(self, processes: int = 1):\n self.__processes = processes", "def num_processes(self, new_value):", "def pim_vrrp_updown(self)...
[ "0.50437987", "0.4948403", "0.48628172", "0.48540446", "0.48317713", "0.4823909", "0.4634812", "0.4625937", "0.4610073", "0.45091096", "0.45026562", "0.44959944", "0.4490443", "0.44796947", "0.445953", "0.44437", "0.44412768", "0.44145095", "0.44009617", "0.4400679", "0.43849...
0.74223495
0
kill(self,process_list,signal = 'TERM') Signal process list. Description Send a signal to all of the numpy_proc.process objects in the process_list. This is usually used to kill the processes. The signal may be given as a signal name or number.
def kill(self,process_list,signal = 'TERM'): res = [] pids = {} for process in process_list: if hasattr(process,'machine'): try: worker = self.worker_by_name[process.machine] except KeyError: worker = self.worker...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kill_all_processes(self, signal=signal.SIGINT) -> None:\n for task_name, sp in self.process_queue:\n sp.send_signal(signal)", "def stop_all(self, signal, frame):\n for event in self.event_list:\n event.set()\n for process in self.process_list:\n process.j...
[ "0.6993041", "0.6301664", "0.6288038", "0.6048694", "0.59778625", "0.5973349", "0.5903882", "0.5890457", "0.5890336", "0.58836174", "0.57966644", "0.57964116", "0.5794382", "0.5788191", "0.5737244", "0.57180685", "0.56969357", "0.569088", "0.5687089", "0.56694955", "0.5639071...
0.8355109
0
system(cmd) execute cmd on all remote machines A list of all the remote responses is returned. Unlike os.system which returns the exit value of the cmd string, this function returns the text output by the command.
def system(self,cmd): code = 'import os;f=os.popen("%s");res = f.read(-1);f.close();' % cmd return self.exec_code(code,returns=['res'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def system(cmds):\n if isinstance(cmds, six.string_types):\n cmds = [cmds]\n\n output = None\n if isinstance(cmds, (tuple, list)):\n for cmd in cmds:\n logger.debug(cmd)\n\n try:\n output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT...
[ "0.694567", "0.6511475", "0.63991964", "0.63601625", "0.6340061", "0.63375807", "0.629912", "0.6257301", "0.61772144", "0.6161609", "0.61456496", "0.6145014", "0.6136143", "0.6066929", "0.6061483", "0.605223", "0.6043965", "0.60113454", "0.6006606", "0.59515357", "0.59413016"...
0.66030544
1
reload(module) reload module on all remote interpreters module can either be the name of a module or the actual module object.
def reload(self,module): try: code = 'import %s; reload(%s)' % ((module.__name__,)*2) except AttributeError: code = 'import %s; reload(%s)' % ((module,)*2) self.workers.exec_code(code)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reload(mod,larch=None,**kw):\n\n if isinstance(mod, str):\n return larch.import_module(mod, do_reload=True)\n\n for k,v in chain(larch.symtable._sys.modules.iteritems(), sys.modules.iteritems()):\n if v == mod:\n modname = k\n break\n try:\n return larch.imp...
[ "0.74145204", "0.7367877", "0.7293504", "0.7069121", "0.6777144", "0.66111887", "0.63678116", "0.6366045", "0.63599694", "0.63358724", "0.63288987", "0.6298444", "0.62526506", "0.6154786", "0.60551083", "0.60262233", "0.6022249", "0.5863082", "0.5854398", "0.58133113", "0.580...
0.75071913
0
exec_code(code,inputs=None,returns=None) Similar to Python's exec statement. Execute the same code fragment on all remote interpreter. inputs is a dictionary of variable values to use when executing the code. returns is a list of variable names that should be returned after executing the code. If one value is specified...
def exec_code(self,code,inputs=None,returns=None): #use the first worker to package up the cmd. package = self.workers[0].exec_code_pack(code,inputs,returns) return self._send_recv(package)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _exec(self, code):\n self._send_command('EXEC ' + code)", "def RunScript(code):\n with ScriptContext() as script_module:\n try:\n exec code in script_module.__dict__\n except:\n # Get exception output as close to exec as possible.\n # We don't take the first entry in the tracebac...
[ "0.65443575", "0.6386612", "0.63011175", "0.63011175", "0.63011175", "0.62941974", "0.62941974", "0.62941974", "0.62929505", "0.62840676", "0.6053061", "0.60476625", "0.5998702", "0.59937024", "0.59937024", "0.5916869", "0.58860344", "0.58178943", "0.57701963", "0.572192", "0...
0.777075
0
apply(function,args=(),keywords=None) Similar to Python's builtin apply method. Execute the given function with the argument list, args, and keyword arguments, keywords, on each of the slave processes. apply returns a list of the results from calling function, one result for each slave.
def apply(self,function,args=(),keywords=None): package = self.workers[0].apply_pack(function,args,keywords) return self._send_recv(package)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply(self, func, *args):\n import ray\n done_ids, undone_ids = ray.wait([shard.apply.remote(func, *args)\n for shard in self.shard_list],\n num_returns=len(self.shard_list))\n assert len(undone_ids) == 0\n ...
[ "0.66074944", "0.60110694", "0.59976894", "0.5838005", "0.5826872", "0.58206975", "0.5797238", "0.57299274", "0.56924593", "0.5683949", "0.5676245", "0.56597686", "0.5618988", "0.5606794", "0.5596438", "0.5573493", "0.5522505", "0.5522505", "0.5522505", "0.5522505", "0.552250...
0.6772759
0
loop_apply(function,loop_var, args=(),keywords=None) Description Call function with the given args and keywords. One of the arguments or keywords is actually a sequence of arguments. This sequence is looped over, calling function once for each value in the sequence. loop_var indicates which variable to loop over. If an...
def loop_apply(self,function,loop_var,args=(),keywords=None): #---------------------------------------------------- # Prepare main package for sending # almost verbatim from loop_apply_pack in sync_cluster #---------------------------------------------------- #if type(loop_var) =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply(self,function,args=(),keywords=None):\n package = self.workers[0].apply_pack(function,args,keywords)\n return self._send_recv(package)", "def basic_parallel_loop(func, *args, parallel=True):\n if parallel is True:\n results = Parallel(n_jobs=cpu_count())(delayed(func)(*a) for a ...
[ "0.6428172", "0.6072475", "0.5980121", "0.59507483", "0.5832301", "0.56668514", "0.5642099", "0.5402423", "0.53344244", "0.52769375", "0.5213421", "0.51631296", "0.5139644", "0.5095581", "0.50520253", "0.5027378", "0.5027378", "0.5027378", "0.5027378", "0.5027378", "0.5000567...
0.82264096
0
loop_code(code,loop_var,inputs=None,returns=None) Description Similar to exec_code and loop_apply. Here loop_var indicates the variable name in the inputs dictionary that is looped over.
def loop_code(self,code,loop_var,inputs=None,returns=None): the_inputs = {} the_inputs.update(inputs) loop_data = the_inputs[loop_var] the_inputs[loop_var] = None #make it small for packing package = self.workers[0].loop_code_pack(code,loop_var, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _eval_python(loop, context, params=None, add_boilerplate=False, namespace=None):\n params = params # pylint\n \n # Are we actually doing this?\n if (not context.do_jit):\n return False\n\n # Emulating full VB programs in Python is difficult, so for now skip loops\n # that Execute() dyn...
[ "0.6456923", "0.62488866", "0.6225537", "0.59651935", "0.5602554", "0.55333126", "0.5486385", "0.54698336", "0.5395104", "0.5374207", "0.53630006", "0.5345739", "0.5341821", "0.52655876", "0.52394456", "0.51990825", "0.5174573", "0.5164324", "0.5150377", "0.51400226", "0.5123...
0.837846
0
Split jobs into Nworkers equal groups. When an equal split is not possible, the larger groups occur at the front of the list.
def equal_balance(jobs,Nworkers): #no jobs to do - return empty group list. if not len(jobs): return () Ntotal_jobs = len(jobs) # find the number of jobs each wroker must do # for everyone to have equal work loads group_size = Ntotal_jobs / Nworkers # if there are jobs left over, some of ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_n_group_split(self):\n # Test 2 groups like HalfSplitter first\n hs = NGroupPartitioner(2)\n\n for isreversed, splitter in enumerate((hs, hs)):\n if isreversed:\n spl = Splitter(attr='partitions', reverse=True)\n else:\n spl = Splitt...
[ "0.7199404", "0.6824129", "0.6798619", "0.67813647", "0.65168804", "0.63456434", "0.62896436", "0.6288251", "0.6274654", "0.6268003", "0.6224157", "0.62179065", "0.62064743", "0.6132379", "0.6130663", "0.61159384", "0.61095643", "0.6088751", "0.60833097", "0.60803914", "0.607...
0.6846773
1
Used if val is an instance of numpy.float32.
def ts_float32(val): return np.float64(val)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_float(self, val):\n try:\n float(val)\n return True\n except ValueError:\n return False", "def is_float(space, w_obj):\n return space.wrap(w_obj.tp == space.tp_float)", "def floatval(space, w_obj):\n return space.newfloat(w_obj.float_w(space))", "de...
[ "0.6748577", "0.64464486", "0.6323974", "0.6297695", "0.62333214", "0.61988634", "0.6185714", "0.617719", "0.6106048", "0.6100606", "0.6089156", "0.6089081", "0.605124", "0.6049143", "0.59900147", "0.5979166", "0.58923584", "0.5887647", "0.5885443", "0.586517", "0.5850768", ...
0.71901006
0
Set the site to the current site when the record is first created, or the ``update_site`` argument is explicitly set to ``True``.
def save(self, update_site=False, *args, **kwargs): if update_site or not self.id: self.site_id = current_site_id() super(SiteRelated, self).save(*args, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_site(self, site):\n assert self.default_model is not None\n self.default_model.add_site(site)", "def add_site_to_context(self):\n g.current_site = self", "def save_site(self, site):\n raise NotImplementedError('save_site')", "def _update_site_configuration(self):\n ...
[ "0.7196496", "0.6944524", "0.6681965", "0.64669836", "0.6459213", "0.641109", "0.641109", "0.61772376", "0.61531913", "0.6105513", "0.6099537", "0.6084168", "0.6019811", "0.5998988", "0.59902525", "0.59790754", "0.594837", "0.59265506", "0.586496", "0.5850791", "0.5836316", ...
0.74763525
0
Initializes the node for the word given and creates and empty array for the children nodes.
def __init__(self, word): TreeNode.__init__(self) self.word = word self.children = []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.isEnd = False # whether this node is an end of a word\n self.children = dict() # map a char to the child node", "def __init__(self):\n self.children = {}\n self.is_a_word = (False,None)\n self.index = []", "def __init__(self):\n self.childr...
[ "0.7513591", "0.71971166", "0.7183556", "0.70607185", "0.7028913", "0.6879527", "0.68564075", "0.6843299", "0.6797169", "0.67595696", "0.67295927", "0.6657748", "0.66432583", "0.66254884", "0.65849876", "0.65723974", "0.6533535", "0.6515169", "0.64951223", "0.6384697", "0.635...
0.7939854
0
Returns a string representation of the node (with n whitespaces on the left).
def get_string(self, n): pad = self.get_pad(n) string = pad + self.word string += "\n" + self.children[0].get_string(n + 1) string += "\n" + self.children[1].get_string(n + 1) return string
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __repr__(self):\n lines = []\n nodes = [(self.root, 0)]\n while nodes:\n node, indent = nodes.pop()\n name = str(node) if node else 'None'\n lines.append(' ' * indent + name)\n if node:\n nodes.append((node.child[True], indent + 1)...
[ "0.7305593", "0.7293151", "0.7116349", "0.7059454", "0.70524126", "0.6998434", "0.6998368", "0.6985005", "0.6963303", "0.695356", "0.6935341", "0.69200206", "0.68946445", "0.6891254", "0.6884507", "0.6871171", "0.68657887", "0.68058807", "0.6788324", "0.67802215", "0.6766152"...
0.7496617
0
Initializes the classifier given the documents; it obtains the vocabulary and generates the tree.
def __init__(self, documents): Classifier.__init__(self, documents) documents = set(documents) term_document_matrix = TermDocumentMatrix(documents, compute_word_vectors=False, compute_document_vectors=False) self.vocabulary = set(term_document_matrix.vocabulary) self.tree = self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, documents_path):\n self.documents = []\n self.vocabulary = []\n self.likelihoods = []\n self.documents_path = documents_path\n self.term_doc_matrix = None \n self.document_topic_prob = None # P(z | d)\n self.topic_word_prob = None # P(w | z)\n ...
[ "0.70484084", "0.668634", "0.6647606", "0.6513024", "0.64845014", "0.64544755", "0.64532274", "0.64206356", "0.6389602", "0.6320153", "0.625024", "0.6242476", "0.6230974", "0.6218114", "0.62008655", "0.6198922", "0.6155165", "0.613072", "0.6127168", "0.61096436", "0.60994977"...
0.7993907
0
Returns the predicted class for the given document based on the previously generated decision tree.
def get_prediction(self, document): return self.classify(document, self.tree)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict(self, doc):\n # >>> YOUR ANSWER HERE\n # For each class c, calculate the corresponding score of the doc\n scores = [(self.score(doc, c), c) for c in self.classes]\n # after the sort by score, return the most likely class\n scores.sort(key=lambda x: x[0])\n retu...
[ "0.7630106", "0.69681805", "0.67407465", "0.6702287", "0.63191974", "0.6225889", "0.61062753", "0.6023611", "0.59961706", "0.5991221", "0.59716344", "0.59597355", "0.5931009", "0.5892068", "0.58535576", "0.580295", "0.57817346", "0.57742006", "0.57652587", "0.5760815", "0.575...
0.7826694
0
Returns the predicted class for the document; it is done recursively by passing child nodes until leaf.
def classify(self, document, tree): if type(tree) is ClassTreeNode: return tree.c else: if tree.word in document.bag_of_words: return self.classify(document, tree.children[0]) else: return self.classify(document, tree.children[1])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_prediction(self, document):\n return self.classify(document, self.tree)", "def _predict(self, inputs):\n node = self.tree_\n while node.left:\n if inputs[node.feature_index] < node.split:\n node = node.left\n else:\n node = node.rig...
[ "0.6648654", "0.66332334", "0.65360904", "0.6085024", "0.60096526", "0.588489", "0.58713436", "0.58331215", "0.58079845", "0.57918006", "0.5757257", "0.5716266", "0.5665098", "0.5609045", "0.5589136", "0.5566739", "0.55376923", "0.55265206", "0.55241597", "0.552298", "0.55194...
0.6998496
0
Returns the decision tree for the documents given the vocabulary; it is done recursively by passing the updated vocabulary at each call. Checks for the base cases first and returns a leaf node if they succeed; Otherwise, it finds the most informative word, splits the document and calls recursively for each child.
def get_tree(self, documents, vocabulary): if self.contain_one_class(documents): return ClassTreeNode(self.contain_one_class(documents)) elif len(vocabulary) == 0: return ClassTreeNode(self.get_majority_class(documents)) else: most_informative_word = self.get_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_binary_tree(self):\n heap = filter(lambda x: not self.index2word[x.index][0].isupper(), itervalues(self.vocab))\n treelen = len(heap)\n logger.info(\"constructing a huffman tree from %i words\" % treelen)\n\n # build the huffman tree\n \n heapq.heapify(heap)\n ...
[ "0.5787245", "0.56144047", "0.561384", "0.5368511", "0.53523356", "0.53232056", "0.51237017", "0.5088962", "0.5074895", "0.50748545", "0.50600576", "0.50482816", "0.50336653", "0.50259966", "0.5007876", "0.500019", "0.4998888", "0.4984954", "0.49779788", "0.49631277", "0.4940...
0.7309619
0
Returns None if the documents contain more than a class; returns the class otherwise.
def contain_one_class(self, documents): classes = [] for document in documents: if document.c not in classes: if len(classes) == 0: classes.append(document.c) else: return None if len(classes) == 1: r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def classes(self):\n if \"classes\" in self._prop_dict:\n return ClassesCollectionPage(self._prop_dict[\"classes\"])\n else:\n return None", "def get_majority_class(self, documents):\n counts = {}\n for document in documents:\n if document.c not in cou...
[ "0.7011527", "0.6548541", "0.6406779", "0.63441235", "0.62862873", "0.6231706", "0.6178137", "0.59199756", "0.59037054", "0.5901459", "0.5809205", "0.5763075", "0.57288665", "0.57082504", "0.5704252", "0.56695133", "0.56586176", "0.56074035", "0.55650353", "0.55374116", "0.55...
0.8311479
0
Returns the majority class for the documents.
def get_majority_class(self, documents): counts = {} for document in documents: if document.c not in counts: counts[document.c] = 0 counts[document.c] += 1 majority_class = None majority_class_count = -1 for c in counts: if coun...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def majority_cnt(class_list):\n counter = Counter(class_list)\n cls, _ = counter.most_common(1)\n\n return cls", "def majority_class(classes):\n num_pos = len(classes[np.where(classes == 1)])\n num_neg = len(classes) - num_pos\n return 1 if num_pos > num_neg else 0", "def majority_class (self...
[ "0.75053835", "0.7409201", "0.7204527", "0.7121844", "0.6862108", "0.6770251", "0.6752808", "0.659271", "0.6484694", "0.6423609", "0.63770854", "0.63620096", "0.63224113", "0.6277365", "0.6275072", "0.62714237", "0.6193381", "0.61306405", "0.60845435", "0.60079527", "0.592900...
0.89835906
0
Returns the word in the given vocabulary with the highest information gain for the given documents.
def get_most_informative_word(self, documents, vocabulary): most_informative_word = None most_informative_word_gain = 0 for word in vocabulary: gain = self.get_information_gain(word, documents) if most_informative_word == None or gain >= most_informative_word_gain: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_largest_freq():\n words_list = {word for line in lines for word in line} # all words possible\n word_freqs = [(find_freq(word), word) for word in words_list] # list of tuples of words and their frequencies\n max_freq = max(word_freqs)\n return max_freq[0], max_freq[1]", "def label(self, inpu...
[ "0.64055604", "0.6338901", "0.62634706", "0.62199146", "0.6138516", "0.5942008", "0.5939371", "0.5936942", "0.59077406", "0.58693826", "0.58556145", "0.5848381", "0.58483124", "0.5796463", "0.57938373", "0.5783461", "0.5780535", "0.5689964", "0.56706756", "0.5655299", "0.5653...
0.82679933
0
Returns the information gain of the given word for the documents; the subsets to subtract their entropies from the entropy of the original set are the sets with and without the word.
def get_information_gain(self, word, documents): gain = self.get_entropy(documents) with_word, without_word = self.get_split_data(word, documents) gain -= self.get_entropy(with_word) * len(with_word) / len(documents) gain -= self.get_entropy(without_word) * len(without_word) / len(docume...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def word_entropy(self, doc, lemmatized=False):\n # filter out words\n words = [token for token in doc if not token.is_punct and \"'\" not in token.text and not token.is_space]\n # create bag of words\n if lemmatized:\n list_words = [w.lemma_ for w in words]\n else:\n ...
[ "0.6584013", "0.6461961", "0.62527275", "0.6212763", "0.6181934", "0.603743", "0.5926501", "0.58806574", "0.58732754", "0.5852905", "0.58036405", "0.579155", "0.57895815", "0.57730293", "0.5754583", "0.57529724", "0.57256997", "0.57021683", "0.56705195", "0.5655812", "0.56313...
0.83862364
0
Returns the entropy of the given documents;
def get_entropy(self, documents): entropy = 0 for c in self.classes: count = 0 for document in documents: if document.c == c: count += 1 if count != 0 and len(documents) != 0: ratio = count / len(documents) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def entropy(doc_or_tokens: types.DocOrTokens) -> float:\n words = utils.get_words(doc_or_tokens)\n word_counts = itertoolz.frequencies(word.text for word in words)\n n_words = sum(word_counts.values())\n probs = (count / n_words for count in word_counts.values())\n return -sum(prob * math.log2(prob)...
[ "0.767517", "0.71636075", "0.7113853", "0.70761496", "0.69885343", "0.6926311", "0.68369186", "0.6734515", "0.6729236", "0.671758", "0.6712377", "0.6683987", "0.6650099", "0.6646317", "0.66449845", "0.664072", "0.6622492", "0.6620809", "0.6606008", "0.66057396", "0.6556798", ...
0.8374573
0
Scan for csvs in a source_dir recursively. Place each file in a path of //.csv
def collect_csv(source_dir, dest_dir): source_dir = Path(source_dir) dest_dir = Path(dest_dir) for csvfile in source_dir.rglob("*.csv"): species = normalized_species(csvfile) species_dir = dest_dir / species species_dir.mkdir(exist_ok=True, parents=True) date_time = normalize...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_directory_csv(d_in, d_out, target_column, merge_columns):\n\n INPUT_FILES = grab_files(\"*.csv\", d_in)\n\n if not INPUT_FILES:\n logger.warning(\"No matching CSV files found, exiting\")\n exit(2)\n\n for f_csv in INPUT_FILES:\n f_csv_out = os.path.join(d_out, os.path.basen...
[ "0.66698605", "0.66279465", "0.65627587", "0.65396017", "0.63316804", "0.6319263", "0.6246003", "0.6213397", "0.6184193", "0.6170909", "0.6162643", "0.6050794", "0.60200405", "0.5939705", "0.5917072", "0.5879509", "0.5850727", "0.5830297", "0.582743", "0.5807929", "0.5734628"...
0.71214396
0
Return the species of the column "species" of the csv_filename. Normalize it via lowercasing and transforming spaces into "_"
def normalized_species(csv_filename): with open(csv_filename) as csvfilename: reader = DictReader(csvfilename) first_row = next(reader) return first_row.get("species").lower().replace(" ", "_")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_species_name(fasta):\n name = fasta.description\n if ',' in name:\n name = ','.join(name.split(',')[:-1])\n name = ' '.join(name.split()[1:])\n if name.endswith(' '):\n name = name[:-1]\n if name.endswith(','):\n name = name[:-1]\n return name", "def species_name(se...
[ "0.5889498", "0.58427936", "0.5762657", "0.55987436", "0.55368763", "0.5307403", "0.53045946", "0.5302626", "0.5264975", "0.51979125", "0.514122", "0.5115525", "0.5044933", "0.50338084", "0.50125307", "0.49970248", "0.4994492", "0.49843335", "0.4976661", "0.49747512", "0.4940...
0.83327395
0
Return the datetime of the column "observation_date" of the csv_filename. Normalize it with the format YYYYMMDDHHMM
def normalized_datetime(csv_filename): with open(csv_filename) as csvfilename: reader = DictReader(csvfilename) first_row = next(reader) src_date_fmt = "%d/%m/%Y %H:%M" dst_date_fmt = "%Y%m%d%H%M" obs_date = datetime.strptime(first_row.get("observation_date"), src_date_fmt) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _resolve_date_from_csv_row(self, csv_row: dict):\n date_str = csv_row[CSV_SENSOR_MAP[CarSensorID.DATE]]\n return datetime.datetime.strptime(date_str, '%d-%b-%Y %H:%M:%S.%f')", "def extract_datetime(filename) -> datetime:\n date_part = filename[-26:-7]\n return datetime.strptime(date_part,...
[ "0.6497183", "0.56915534", "0.56462073", "0.562195", "0.5613925", "0.55695003", "0.5566172", "0.54354125", "0.5421051", "0.5420912", "0.5407202", "0.53834975", "0.53240067", "0.53164774", "0.5309389", "0.53038645", "0.529336", "0.52784854", "0.5274101", "0.52193314", "0.52185...
0.7952646
0
Backup a list of tables using pg_dump to a backup_filename Notify via Slack in case of failure
def backup_tables(tables, backup_filename): tables_switches = " ".join(f"-t {table}" for table in tables) jobs = cpu_count() cmd = f"pg_dump {tables_switches} -j {jobs} -Fc > {backup_filename}" pg_dump = run(cmd, shell=True, capture_output=True) if pg_dump.returncode != 0: webhook_url = envi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backup_database():\n logger.info(\"start database_backup\")\n management.call_command('dbbackup', compress=True)\n logger.info(\"end database_backup\")", "def backup_all_db():\n filename = BACKUP_DIR + \"/\" + str(datetime.datetime.now().isoformat()) + \".yaml\"\n with open(filename, 'w+') as ...
[ "0.669284", "0.6538053", "0.64016324", "0.63371104", "0.62812054", "0.6249745", "0.6203552", "0.6097536", "0.60546255", "0.6033636", "0.6009517", "0.5995691", "0.592359", "0.5910764", "0.5885135", "0.5865547", "0.58210963", "0.5818948", "0.58124495", "0.5811393", "0.58043474"...
0.8861323
0
Notify via Slack webhook url
def notify_via_slack(webhook_url, msg): slack_data = {"text": msg} post(webhook_url, json=slack_data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def webhook_sender(url=WEBHOOK_URL):\n data = runner()\n print(json.dumps(data))\n try:\n r = requests.post(url,json=data)\n print(r)\n except requests.exceptions.RequestException as e:\n raise SystemExit(e)", "def webhook(event, context):\n bot = configure_telegram()\n log...
[ "0.67908823", "0.6733161", "0.6709683", "0.6708932", "0.66876864", "0.668719", "0.6677454", "0.6653485", "0.6611078", "0.65982354", "0.6563635", "0.65241367", "0.65184104", "0.64943904", "0.64943904", "0.6471424", "0.64697933", "0.6464106", "0.6430812", "0.64093184", "0.63643...
0.77923703
0
Gets an image of arbitrary size and return an array of the same size containing 4 different versions of the image by filtering the rows and colums using a low pass or a high pass filter with the different combinations and quantized by the quantization array
def dwt(image_array, quantization_Array): # Create the high pass and low pass filters # both filters are non-causal # symmetric # [-2, -1, 0, 1, 2] LPF = [-0.125, 0.25, 0.75, 0.25, -0.125] LPF_center = 2 # [ -2,-1, 0] HPF = [-0.5, 1, -0.5] HPF_center = 2...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_array(image: Image, filter_id: str) -> Image:\n \n if filter_id == \"3\":\n image = three_tone(image,\"aqua\",\"blood\",\"lemon\")\n elif filter_id == \"X\":\n image = extreme_contrast(image)\n elif filter_id == \"T\":\n image = sepia_filter(image)\n elif filter_id ==...
[ "0.6416802", "0.6152852", "0.6090951", "0.60450697", "0.58665884", "0.57959175", "0.57541287", "0.5740798", "0.57349724", "0.57258534", "0.57112247", "0.56901896", "0.561851", "0.56069106", "0.5605767", "0.55927825", "0.5592644", "0.55604106", "0.5551992", "0.55455166", "0.55...
0.6429137
0
Gets an array of 4 elements (the output of the dwt function) and return an array by replacing the elements of the list that are addressed through the levels array by dwt versions of them (replace 1 element with a List of 4 elements)
def dwt_levels(filtered_image, levels, quantization_Array): assert len(levels) <= 4 for level in levels: filtered_image[level[0]] = dwt( filtered_image[level[0]], quantization_Array) try: # continue recursively dwt_levels(filtered_image[level[0]], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getLevels():", "def render_pyramid(pyr, levels):\n positionLst = []\n finalLst = []\n if levels > len(pyr):\n print(\"error. number of levels to display is more than max_levels\")\n width = 0\n\n for i in range(levels):\n # streching each layer\n pyr[i] = strech_helper(pyr...
[ "0.5550804", "0.53843755", "0.5264342", "0.5262979", "0.5254136", "0.5248846", "0.52218556", "0.52117604", "0.5206292", "0.51703376", "0.51466304", "0.5125481", "0.51155955", "0.5099238", "0.50898075", "0.5077054", "0.50622743", "0.5059354", "0.501936", "0.4992671", "0.498302...
0.71002924
0
This function takes the output of the dwt_levels and serializes the list. The serialization is done by order of apperance in the filtered_image
def dwt_serialize(filtered_image, output, length): for i in filtered_image: if isinstance(i, list): # append the output of the recursion to the main arguments (output, # length) output_temp, length_temp = dwt_serialize(i, [], []) output = output + output_temp ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dwt_levels(filtered_image, levels, quantization_Array):\n assert len(levels) <= 4\n for level in levels:\n filtered_image[level[0]] = dwt(\n filtered_image[level[0]], quantization_Array)\n try:\n # continue recursively\n dwt_levels(filtered_image[level[0]],\...
[ "0.670749", "0.51908505", "0.5164347", "0.51631737", "0.5148783", "0.5069291", "0.505505", "0.5051109", "0.50357753", "0.5027362", "0.49688357", "0.49663234", "0.49348238", "0.4930135", "0.48974124", "0.48842168", "0.4855037", "0.4851072", "0.48385602", "0.48064154", "0.48035...
0.6651616
1
Add a beam stop of the given radius. If outer, make an annulus.
def set_beam_stop(data, radius, outer=None): if hasattr(data, 'qx_data'): q = np.sqrt(data.qx_data**2 + data.qy_data**2) data.mask = (q < radius) if outer is not None: data.mask |= (q >= outer) else: data.mask = (data.x < radius) if outer is not None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_arc_piece(self, center, radius, start_angle, stop_angle):\r\n self.pieces.append(Arc(center, radius, start_angle, stop_angle))\r\n self.total_length += self.pieces[-1].get_length()", "def mzi_with_bend(radius: float = 10):\n c = gf.Component()\n mzi = c.add_ref(gf.components.mzi())\n ...
[ "0.5315736", "0.5069563", "0.50269866", "0.4964889", "0.49412605", "0.48725465", "0.48532206", "0.48426268", "0.48292616", "0.47962764", "0.4789855", "0.47101232", "0.47040084", "0.4683362", "0.46718004", "0.46376756", "0.46133748", "0.46002012", "0.45546836", "0.45401353", "...
0.6520495
0
Choose a parameter range based on parameter name and initial value.
def parameter_range(p, v): if p.endswith('_pd_n'): return [0, 100] elif p.endswith('_pd_nsigma'): return [0, 5] elif p.endswith('_pd_type'): return v elif any(s in p for s in ('theta', 'phi', 'psi')): # orientation in [-180,180], orientation pd in [0,45] if p.ends...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def range_params(self, ran, kw):\n specs = {\"range\": (SchemaNode(\"value\"),\n SchemaNode(\"param\").set_attr(\"name\",\"minInclusive\"),\n SchemaNode(\"param\").set_attr(\"name\",\"maxInclusive\")),\n \"length\": (SchemaNode(\"param\").s...
[ "0.63689256", "0.6123985", "0.6007537", "0.5822891", "0.5709171", "0.5673385", "0.56482494", "0.56261474", "0.5619638", "0.56101793", "0.5587491", "0.55766535", "0.5572528", "0.5567625", "0.5552738", "0.5534712", "0.55107725", "0.5504369", "0.54925025", "0.5484107", "0.548410...
0.6637906
0
Suppress theta_pd for now until the normalization is resolved. May also suppress complete polydispersity of the model to test models more quickly.
def suppress_pd(pars): pars = pars.copy() for p in pars: if p.endswith("_pd_n"): pars[p] = 0 return pars
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def du(self):\n du = setup_nonlinear_model_du() # Ux, Uy, theta_p\n return du", "def remove_norms(module_: \"WN\") -> \"WN\":\n module_.start = torch.nn.utils.remove_weight_norm(module_.start_conv)\n module_.cond_layer = torch.nn.utils.remove_weight_norm(module_.cond_layer)\n f...
[ "0.5372836", "0.5269935", "0.52588075", "0.5241501", "0.5218389", "0.5217096", "0.5178467", "0.5143914", "0.5118224", "0.5112162", "0.5072177", "0.5007369", "0.5006693", "0.5006693", "0.48975027", "0.4889109", "0.4889109", "0.48763412", "0.48687136", "0.48680446", "0.48546803...
0.5798115
0
Return a model calculator using the OpenCL calculation engine.
def eval_opencl(model_info, data, dtype='single', cutoff=0.): try: model = core.build_model(model_info, dtype=dtype, platform="ocl") except Exception as exc: print(exc) print("... trying again with single precision") model = core.build_model(model_info, dtype='single', platform="...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeCalc(self, dataSet):\n\n #cyl = sasmodels.core.load_model_info('cylinder')\n #hs = sasmodels.core.load_model_info('hardsphere')\n #cylhs = sasmodels.core.load_model_info('cylinder@hardsphere')\n cylhmsa = sasmodels.core.load_model_info('cylinder@hayter_msa')\n\n # Build u...
[ "0.70291424", "0.70197284", "0.6265564", "0.5914659", "0.5827897", "0.57237893", "0.57056856", "0.55929047", "0.55883527", "0.5585512", "0.5575414", "0.55035704", "0.54941154", "0.5486263", "0.5481206", "0.5464576", "0.5423178", "0.53772604", "0.53308785", "0.5314042", "0.531...
0.7391274
0
Generate an empty dataset, used with the model to set Q points and resolution. opts contains the options, with 'qmax', 'nq', 'res', 'accuracy', 'is2d' and 'view' parsed from the command line.
def make_data(opts): qmax, nq, res = opts['qmax'], opts['nq'], opts['res'] if opts['is2d']: data = empty_data2D(np.linspace(-qmax, qmax, nq), resolution=res) data.accuracy = opts['accuracy'] set_beam_stop(data, 0.0004) index = ~data.mask else: if opts['view'] == 'log'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dataset(options):\n pass", "def get_dataset(opts):\n dataset_type = opts.dataset_params.dataset_type\n if dataset_type in 'synth':\n return synthgraph.SynthGraphDataset(opts, opts.dataset_params)\n elif dataset_type in 'synthnoise':\n return synthgraph.SynthNoiseGraphDataset(opts, opts.dataset_pa...
[ "0.6061263", "0.56916666", "0.55919266", "0.54698056", "0.5453293", "0.53809595", "0.53586495", "0.5279866", "0.5200752", "0.5178504", "0.51729673", "0.5166292", "0.5101323", "0.5015216", "0.50128824", "0.49636617", "0.48968497", "0.4892959", "0.4892534", "0.48797497", "0.487...
0.6708323
0
Generate the appropriate calculation engine for the given datatype. Datatypes with '!' appended are evaluated using external C DLLs rather than OpenCL.
def make_engine(model_info, data, dtype, cutoff): if dtype == 'sasview': return eval_sasview(model_info, data) elif dtype.endswith('!'): return eval_ctypes(model_info, data, dtype=dtype[:-1], cutoff=cutoff) else: return eval_opencl(model_info, data, dtype=dtype, cutoff=cutoff)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eval_ctypes(model_info, data, dtype='double', cutoff=0.):\n if dtype == 'quad':\n dtype = 'longdouble'\n model = core.build_model(model_info, dtype=dtype, platform=\"dll\")\n calculator = DirectModel(data, model, cutoff=cutoff)\n calculator.engine = \"OMP%s\"%DTYPE_MAP[dtype]\n return cal...
[ "0.6674885", "0.63499874", "0.61020803", "0.52706206", "0.49951327", "0.49773255", "0.49654198", "0.4941015", "0.48718393", "0.48411128", "0.4809473", "0.47807318", "0.47564074", "0.47495553", "0.47205937", "0.47169065", "0.47130096", "0.46978438", "0.4689692", "0.46767172", ...
0.71022725
0
Preform a comparison using options from the command line. limits are the limits on the values to use, either to set the yaxis for 1D or to set the colormap scale for 2D. If None, then they are inferred from the data and returned. When exploring using Bumps, the limits are set when the model is initially called, and mai...
def compare(opts, limits=None): Nbase, Ncomp = opts['n1'], opts['n2'] pars = opts['pars'] data = opts['data'] # Base calculation if Nbase > 0: base = opts['engines'][0] try: base_value, base_time = time_calculation(base, pars, Nbase) base_value = np.ma.masked...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def determinePlotLimits(self):\n max_str = \"up99\"\n min_str = \"dn99\"\n if self.keywords.get(\"limit_type\",\"99per\") == \"minmax\":\n max_str = \"max\"\n min_str = \"min\"\n \n # Determine the min/max of variables over all models\n limits = {...
[ "0.5663375", "0.53814524", "0.5351617", "0.5318616", "0.5304712", "0.5269855", "0.518687", "0.5080418", "0.5079761", "0.5076662", "0.5063355", "0.50254184", "0.50113034", "0.50095356", "0.49927393", "0.49918455", "0.4990025", "0.49890125", "0.4981406", "0.4974337", "0.4938192...
0.64452285
0