def merge_all(FILE_1, FILE_2, FILE_3, FILE_4): A, B, C, D = load(FILE_1), load(FILE_2), load(FILE_3), load(FILE_4) G = {} for chrom in A: if chrom in C and chrom in B and chrom in D: a, b, c, d = A[chrom], B[chrom], C[chrom], D[chrom] G[chrom] = list() for l in (a, b, c, d): for I in l: G[chrom].append((I.startN, I)) G[chrom].sort() for chrom in G: G[chrom] = [I for i, I in G[chrom]] IS = {} for chrom in G: I = info(chrom, G[chrom][0].start, G[chrom][0].stop) i = 1 A = G[chrom] N = len(A) IS[chrom] = list() while i < N: while i < N and A[i].start < I.stop and A[i].stop > I.start: I.update_bounds(A[i].start, A[i].stop) i += 1 IS[chrom].append(I) if i < N: I = info(chrom, A[i].start, A[i].stop) i += 1 return IS pass
def merge_all(FILE_1,FILE_2,FILE_3,FILE_4): A,B,C,D = load(FILE_1),load(FILE_2),load(FILE_3),load(FILE_4) G = {} for chrom in A: if chrom in C and chrom in B and chrom in D: a,b,c,d = A[chrom], B[chrom], C[chrom], D[chrom] G[chrom] = list() for l in (a,b,c,d): for I in l: G[chrom].append((I.startN, I)) G[chrom].sort() for chrom in G: G[chrom] = [I for i, I in G[chrom]] IS = {} for chrom in G: I = info(chrom, G[chrom][0].start, G[chrom][0].stop) i = 1 A = G[chrom] N = len(A) IS[chrom] = list() while i < N: while i < N and A[i].start < I.stop and A[i].stop > I.start: I.update_bounds(A[i].start, A[i].stop) i+=1 IS[chrom].append(I) if i < N: I = info(chrom, A[i].start, A[i].stop) i+=1 return IS pass
def test_load(env): obj_mock = Mock() with patch("{{cookiecutter.project_slug}}.config.settings_loader") as settings_loader_mock: load(obj_mock, env=env) settings_loader_mock.assert_called_once_with( obj_mock, filename=f"{env.lower()}.yml" )
def transform(event): try: change = json.loads(event.data) if (change['bot'] == False): print(json.dumps(change, indent=4, sort_keys=True)) load(change) except ValueError: pass
def dispatch(self, request, *args, **kwargs): module_str = "%s:%s" % (request.GET.get("module"), request.GET.get("model")) self.return_url = reverse("E-Commerce_admin:%s.list" % request.GET.get("return_url")) match = resolve(self.return_url) view_context = load("%s:%s" % (match.func.__module__, match.func.__name__)) default_columns = view_context.default_columns self.model = load(module_str) self.settings = ViewSettings(self.model, default_columns, view_context) return super(ListSettingsView, self).dispatch(request, *args, **kwargs)
def test_list_view_with_multiple_suppliers(rf, admin_user): shop = factories.get_default_shop() product = factories.create_product(sku="test", shop=shop) shop_product = product.get_shop_instance(shop) shop_product.primary_category = factories.get_default_category() shop_product.save() shop_product.categories.add(shop_product.primary_category) # Also one product with supplier supplier = factories.get_default_supplier() product2 = factories.create_product(sku="test2", shop=shop, supplier=supplier) shop_product2 = product2.get_shop_instance(shop) shop_product2.primary_category = factories.get_default_category() shop_product2.save() shop_product2.categories.add(shop_product.primary_category) with override_settings(E-Commerce_ENABLE_MULTIPLE_SUPPLIERS=True): view = load("E-Commerce.admin.modules.products.views:ProductListView").as_view() request = apply_request_middleware(rf.get("/", { "jq": json.dumps({"perPage": 100, "page": 1}) }), user=admin_user) response = view(request) assert 200 <= response.status_code < 300 data = json.loads(response.content.decode("utf-8")) product_data = [item for item in data["items"] if item["_id"] == shop_product.pk][0] assert product_data["primary_category"] == factories.get_default_category().name assert product_data["categories"] == factories.get_default_category().name assert product_data["categories"] == factories.get_default_category().name assert product_data["suppliers"] == "" product_data2 = [item for item in data["items"] if item["_id"] == shop_product2.pk][0] assert product_data2["suppliers"] == factories.get_default_supplier().name
def test_iframe_mode(rf, admin_user, extra_query_param, extra_query_value, expected_script): get_default_shop() view = load("E-Commerce.admin.modules.categories.views:CategoryEditView").as_view() request = apply_request_middleware(rf.get("/", {"mode": "iframe"}), user=admin_user) response = view(request) if hasattr(response, "render"): response.render() assert 200 <= response.status_code < 300 content = force_text(response.content) post = extract_form_fields(BeautifulSoup(content, "lxml")) post.update({ "base-name__en": "Name" }) post.pop("base-image") # save iframe mode request = apply_request_middleware(rf.post("/", post), user=admin_user) request.GET = request.GET.copy() request.GET["mode"] = "iframe" if extra_query_param: request.GET[extra_query_param] = extra_query_value response = view(request) assert response.status_code == 302 client = Client() client.login(username="******", password="******") response = client.get(response.url) assert response.status_code == 200 assert expected_script in force_text(response.content)
def test_tour_view(rf, admin_user): shop = get_default_shop() assert is_tour_complete(shop, "home", admin_user) is False view = load("E-Commerce.admin.views.tour:TourView").as_view() request = apply_request_middleware(rf.post("/", data={"tourKey": "home"}), user=admin_user) view(request) assert is_tour_complete(shop, "home", admin_user)
def encode_enum(enum_val): enum_cls = enum_val.__class__ spec = "%s:%s" % (enum_cls.__module__, enum_cls.__name__) try: if load(spec) != enum_cls: raise ImproperlyConfigured("That's not the same class!") except ImproperlyConfigured: # Also raised by `load` return enum_val.value # Fall back to the bare value. return [spec, enum_val.value]
def _load_provide_objects(category): provide_specs = _get_provide_specs_from_apps(category) loaded_provides = _loaded_provides[category] if set(provide_specs) != set(loaded_provides.keys()): # Changes occurred, reload provides _uncache(category) explanation = "Loading provides %s" % category loaded_provides = OrderedDict() for spec in provide_specs: loaded_provides[spec] = load(spec, explanation) _loaded_provides[category] = loaded_provides return _loaded_provides.get(category, {})
def get_order_identifier(order): if order.identifier: raise ValueError("Order passed to get_order_identifier() already has an identifier") order_identifier_method = settings.E-Commerce_ORDER_IDENTIFIER_METHOD if order_identifier_method == "id": return force_text(order.id) elif callable(order_identifier_method): return order_identifier_method(order) else: getter = load(order_identifier_method, "Order identifier generator") return getter(order)
def main(): ## predefinition print("本工具可以自定义行列数,根据给定的行列生成A4大小 R x M 的单词卡片") row = input("输入行数:") col = input("输入列数:") source_path = "../data/" save_path = "../src/content/words/" tex_path = "../src/content/" cards_per_page = 6 words = load(source_path) convert(words, save_path) insert(row, col) return
def main(): ## predefinition print("本工具可以自定义行列数,根据给定的行列生成A4大小 R x M 的单词卡片") row = input("输入行数:") col = input("输入列数:") source_path = "../data/" save_path = "../src/content/words/" tex_path = "../src/content/" cards_per_page = 6 words = load(source_path) convert(words, save_path) insert(row,col) return
def _load_module(self): spec = self.default_module_spec module_identifier = self.module_identifier if module_identifier: impls = self.get_module_implementation_map() if module_identifier not in impls: raise ModuleNotFound( "Invalid module identifier %r in %s" % (module_identifier, force_ascii(repr(self))) ) spec = impls[module_identifier] cls = load(spec, context_explanation="Loading module for %s" % force_ascii(repr(self))) options = getattr(self, self.module_options_field, None) or {} return cls(self, options)
def test_list_view(rf, class_spec, admin_user): get_default_shop() view = load(class_spec).as_view() # normal request request = apply_request_middleware(rf.get("/"), user=admin_user) response = view(request) assert response.status_code == 200 # picotable request request = apply_request_middleware(rf.get("/", { "jq": json.dumps({"perPage": 100, "page": 1}) }), user=admin_user) response = view(request) assert 200 <= response.status_code < 300
def load_mass_actions(self): actions = [] for action in self._get_mass_actions(): obj = load(action)() action_data = {} extra_data = obj.get_action_info(self.request) if extra_data and isinstance(extra_data, dict): action_data.update(extra_data) action_data.update({ "key": obj.identifier, "value": obj.label }) actions.append(action_data) return actions
def load(cls, identifier, theme=None): """ Get a plugin class based on the identifier from the `xtheme_plugin` provides registry. :param identifier: Plugin class identifier :type identifier: str :return: A plugin class, or None :rtype: class[Plugin]|None """ loaded_plugin = get_identifier_to_object_map("xtheme_plugin").get(identifier) if not loaded_plugin and theme is not None: for plugin_spec in theme.plugins: plugin = load(plugin_spec) if plugin.identifier == identifier: return plugin return loaded_plugin
def load_setup_wizard_pane(shop, request, pane_id): """ Search, load and return a valid Wizard Pane by its identifier. :type request: HttpRequest :param pane_id: the pane identifier :type pane_id: str :return: the pane instance or None :rtype: E-Commerce.admin.views.wizard.WizardPane|None """ if not shop: raise ValueError("Shop instance is mandatory") for pane_spec in getattr(settings, "E-Commerce_SETUP_WIZARD_PANE_SPEC", []): pane_class = load(pane_spec) pane_inst = pane_class(request=request, object=shop) if pane_inst.identifier == pane_id and pane_inst.valid(): return pane_inst
def load_setup_wizard_panes(shop, request=None, visible_only=True): """ Load the setup Wizard panes. The result will be a list of valid pane instances. :type request: HttpRequest|None :param visible_only: whether to return only visible panes :type visible_only: bool """ if not shop: raise ValueError("Shop instance is mandatory") panes = [] for pane_spec in getattr(settings, "E-Commerce_SETUP_WIZARD_PANE_SPEC", []): pane_class = load(pane_spec) pane_inst = pane_class(request=request, object=shop) if pane_inst.valid() and (not visible_only or pane_inst.visible()): panes.append(pane_inst) return panes
def view(request, *args, **kwargs): handler_attr = HANDLER_ATTR_FMT % error_status # look for compatible error handlers for handler_spec in settings.E-Commerce_ERROR_PAGE_HANDLERS_SPEC: handler = load(handler_spec)() # return a response for the error status if handler.can_handle_error(request, error_status): return handler.handle_error(request, error_status) # tries to use the default handler (set in django's root urlconf) # otherwise just a blank response fallback_handler = _URLCONF_ERROR_HANDLERS.get(handler_attr) if fallback_handler and callable(fallback_handler): return fallback_handler(request) else: return HttpResponse(status=error_status)
def test_menu_view(rf, admin_user): get_default_shop() # obvious prerequisite view = load("E-Commerce.admin.views.menu:MenuToggleView").as_view() request = apply_request_middleware(rf.post("/"), user=admin_user) assert "menu_open" not in request.session response = view(request) if hasattr(response, "render"): response.render() assert response.status_code == 200 assert not request.session["menu_open"] # Menu closed response = view(request) if hasattr(response, "render"): response.render() assert response.status_code == 200 assert request.session["menu_open"] # Menu open
def get_reference_number(order): from E-Commerce import configuration from E-Commerce.admin.modules.settings.consts import ORDER_REFERENCE_NUMBER_METHOD_FIELD if order.reference_number: raise ValueError("Order passed to get_reference_number() already has a reference number") reference_number_method = configuration.get( order.shop, ORDER_REFERENCE_NUMBER_METHOD_FIELD, settings.E-Commerce_REFERENCE_NUMBER_METHOD) if reference_number_method == "unique": return get_unique_reference_number_for_order(order) elif reference_number_method == "running": return get_running_reference_number(order) elif reference_number_method == "shop_running": return get_shop_running_reference_number(order) elif callable(reference_number_method): return reference_number_method(order) else: getter = load(reference_number_method, "Reference number generator") return getter(order)
def svm(): X, Y_ = load() #for i in range(0,1): #print 'emotion number ',i #row_count = X.shape[0]; #tr_count = int(row_count *0.9); #nntrX,nnteX,nntrY,nnteY =cross_validation.train_test_split(X,Y, test_size = 0.1, random_state=0) #print nntrX.shape #print nntrY.shape from sklearn import svm for col in range(0, 4): Y = Y_[:, col] for kernel in ('linear', 'rbf'): print kernel, col clf = svm.SVC(kernel=kernel, gamma=1.0, coef0=1.0, degree=5) #clf.fit(nntrX, nntrY) scores = cross_validation.cross_val_score(clf, X, Y, cv=10) print("Accuracy: %0.2f (+/- %0.2f)" % (scores.mean(), scores.std() * 2))
def test_list_view(rf, admin_user): shop = factories.get_default_shop() supplier = get_simple_supplier() product = factories.create_product(sku="test", shop=shop, supplier=supplier) shop_product = product.get_shop_instance(shop) shop_product.primary_category = factories.get_default_category() shop_product.save() shop_product.categories.add(shop_product.primary_category) view = load("E-Commerce.simple_supplier.admin_module.views:StocksListView").as_view() request = apply_request_middleware(rf.get("/", { "jq": json.dumps({"perPage": 100, "page": 1}) }), user=admin_user) response = view(request) assert 200 <= response.status_code < 300 data = json.loads(response.content.decode("utf-8")) for item in data["items"]: assert item["_url"] == ""
def start(): list_commands = [] drone = 0 max_drone = sim['drones'] for order_id,order in enumerate(orders): print('order %i' % order_id) for item_type_id, quantity in order["items"].iteritems(): print('item %i' % item_type_id) while(True): print('quantity is: %i' % quantity) warehouse_id = find_item(item_type_id) if warehouse_id is None: break items_take, command = load(drone, warehouse_id, item_type_id, quantity) list_commands.append(command) list_commands.append(delivery(drone, order_id, item_type_id, items_take)) quantity -= items_take if items_take == 0: break drone = (drone + 1) % max_drone return list_commands
def test_mass_actions_product_ids_mixup(rf, admin_user): shop = get_default_shop() supplier = get_default_supplier() product1 = create_product("sku1") product2 = create_product("sku2") with pytest.raises(ObjectDoesNotExist): product1.get_shop_instance(shop) product2.get_shop_instance(shop) # Let's create shop products in different order so product and shop product # ids does not match. default_price = shop.create_price(10) ShopProduct.objects.create( product=product2, shop=shop, default_price=default_price, visibility=ShopProductVisibility.ALWAYS_VISIBLE, name="SKU 1 product") ShopProduct.objects.create( product=product1, shop=shop, default_price=default_price, visibility=ShopProductVisibility.ALWAYS_VISIBLE, name="SKU 1 product") shop_product1 = product1.get_shop_instance(shop) shop_product2 = product2.get_shop_instance(shop) assert shop_product1.pk != product1.pk assert shop_product2.pk != product2.pk view = load("E-Commerce.admin.modules.products.views:ProductListView").as_view() request = apply_request_middleware(rf.get("/", { "jq": json.dumps({"perPage": 100, "page": 1}) }), user=admin_user) response = view(request) assert 200 <= response.status_code < 300 data = json.loads(response.content.decode("utf-8")) shop_product1_id = [item["_id"] for item in data["items"] if item["product_sku"] == "sku1"][0] assert shop_product1_id == shop_product1.pk InvisibleMassAction().process(request, [shop_product1_id]) shop_product1.refresh_from_db() assert shop_product1.visibility == ShopProductVisibility.NOT_VISIBLE
def start(): list_commands = [] drone = 0 max_drone = sim['drones'] for order_id, order in enumerate(orders): print('order %i' % order_id) for item_type_id, quantity in order["items"].iteritems(): print('item %i' % item_type_id) while (True): print('quantity is: %i' % quantity) warehouse_id = find_item(item_type_id) if warehouse_id is None: break items_take, command = load(drone, warehouse_id, item_type_id, quantity) list_commands.append(command) list_commands.append( delivery(drone, order_id, item_type_id, items_take)) quantity -= items_take if items_take == 0: break drone = (drone + 1) % max_drone return list_commands
def _build_settings_columns(self): columns = [] all_models = [(None, self.model)] defaults = [col.id for col in self.default_columns] known_names = [] for identifier, m in self.view_context.related_objects: all_models.append((identifier, load(m))) for identifier, model in all_models: if hasattr(model, "_parler_meta"): self._add_translated_columns(columns, defaults, identifier, known_names, model) self._add_local_columns(all_models, columns, defaults, identifier, known_names, model) self._add_m2m_columns(all_models, columns, defaults, identifier, known_names, model) self._add_provided_columns(columns, identifier, known_names, model) table_columns = set([col.id for col in columns]) for default_column in self.default_columns: if default_column.id not in table_columns and default_column.id != "select": columns.append(default_column) return columns
def test_detail_view(rf, admin_user, model_and_class): get_default_shop() # obvious prerequisite model_func, class_spec = model_and_class model = model_func() view = load(class_spec).as_view() request = apply_request_middleware(rf.get("/"), user=admin_user) if model_func == get_default_product: pk = model.shop_products.first().pk else: pk = model.pk response = view(request, pk=pk) if hasattr(response, "render"): response.render() assert 200 <= response.status_code < 300 # request with iframe mode request = apply_request_middleware(rf.get("/", {"mode": "iframe"}), user=admin_user) response = view(request, pk=pk) if hasattr(response, "render"): response.render() assert 200 <= response.status_code < 300
def get_theme_plugin_choices(self, empty_label=None): """ Get a sorted list of 2-tuples (identifier and name) of available theme specific Xtheme plugins. Handy for `<select>` boxes. :param empty_label: Label for the "empty" choice. If falsy, no empty choice is prepended :type empty_label: str|None :return: List of 2-tuples :rtype: Iterable[tuple[str, str]] """ choices = [] if empty_label: choices.append(("", empty_label)) for plugin_spec in self.plugins: plugin = load(plugin_spec) choices.append(( plugin.identifier, getattr(plugin, "name", None) or plugin.identifier )) choices.sort(key=lambda v: v[1]) return choices
def test_list_view(rf, admin_user): shop = factories.get_default_shop() parent_category = factories.CategoryFactory(status=CategoryStatus.VISIBLE) parent_category.shops.add(shop) child_category = factories.CategoryFactory(status=CategoryStatus.VISIBLE) child_category.parent = parent_category child_category.save() child_category.shops.add(shop) view = load("E-Commerce.admin.modules.categories.views:CategoryListView").as_view() request = apply_request_middleware(rf.get("/", { "jq": json.dumps({"perPage": 100, "page": 1}) }), user=admin_user) response = view(request) assert 200 <= response.status_code < 300 data = json.loads(response.content.decode("utf-8")) parent_data = _get_item_data(data, parent_category) assert _get_abstract_header(parent_data) == parent_category.name child_data = _get_item_data(data, child_category) assert _get_abstract_header(child_data) == child_category.name
def test_list_view(rf, admin_user): shop = factories.get_default_shop() product = factories.create_product(sku="test", shop=shop) shop_product = product.get_shop_instance(shop) shop_product.primary_category = factories.get_default_category() shop_product.save() shop_product.categories.add(shop_product.primary_category) view = load("E-Commerce.admin.modules.products.views:ProductListView").as_view() request = apply_request_middleware(rf.get("/", { "jq": json.dumps({"perPage": 100, "page": 1}) }), user=admin_user) response = view(request) assert 200 <= response.status_code < 300 data = json.loads(response.content.decode("utf-8")) product_data = [item for item in data["items"] if item["_id"] == shop_product.pk][0] assert product_data["primary_category"] == factories.get_default_category().name assert product_data["categories"] == factories.get_default_category().name assert product_data["categories"] == factories.get_default_category().name # Suppliers not available by default since multiple suppliers is not enabled assert "suppliers" not in product_data
# runs all 6 algorithms tune = 'tune' in argv # attempt multiple runs with different tuning parameters final = 'final' in argv # use best algorithm, tuning parameters, and features write = 'write' in argv # write plots if (short + tune + final) > 1: print 'COULD NOT RUN' print 'short, tune, and final are incompatible arguments' elif (short + tune + final) == 0: final = True else: if read: if shard: df_clean = pd.read_csv('../data/clean_shard.csv') else: ints_in_argv = [int(arg) for arg in argv if arg.isdigit()] if ints_in_argv: rows = ints_in_argv[0] df_clean = pd.read_csv('../data/clean.csv', nrows=rows) else: df_clean = pd.read_csv('../data/clean.csv') else: df_clean = clean(load()) model(df_clean, shard, short, tune, final, write)
def load_json( filename ): ''' ''' with open( filename ) as rd: return load( rd )
def test_unquote(): sexp = load("(a b c ~d)") assert repr(sexp) == "((a b c (unquote d)))"
from sklearn import decomposition import matplotlib.pyplot as plt from load import * train = load('train.csv') pca = decomposition.PCA() pca.fit(train[['hour', 'age_seconds', 'weather']]) print pca.components_ plt.plot(pca.explained_variance_) plt.show()
def test_load_empty(): sexp = load("(())") assert repr(sexp) == "((nil))"
def test_load_mixed(): sexp = load("(a b c (1 2 3) \"foo\")") assert repr(sexp) == "((a b c (1 2 3) \"foo\"))"
def test_deref_list(): sexp = load("(a b c @(1 2 3))") assert repr(sexp) == "((a b c (deref (1 2 3))))"
from game import * from load import * info = load() resources = load_everthing() while True: info = run(info, resources)
p = f(con1(board.reshape(-1,1), flat = True)) # print p if all(board == u[0]): p[0] = 0 if all(board == d[0]): p[1] = 0 if all(board == l[0]): p[2] = 0 if all(board == r[0]): p[3] = 0 # p /= p.sum() # return random.choice(arange(4), p = p) return p.argmax() if __name__ == '__main__': tr_x = load('rec_board.npy') tr_y = load('rec_move.npy') tr_x = con1(tr_x.T) print tr_x.shape print tr_y.shape data = ClassificationDataSet(tr_x.shape[1], 1, nb_classes = 4) for ind, ele in enumerate(tr_x): data.addSample(ele, tr_y[ind]) data._convertToOneOfMany() print data.outdim fnn = buildNetwork(data.indim, 10, 10, data.outdim, hiddenclass=SigmoidLayer, outclass=SoftmaxLayer ) trainer = BackpropTrainer( fnn, dataset=data)#, momentum=0.1, verbose=True, weightdecay=0.01)
def test_deref(): sexp = load("(a b c @d)") assert repr(sexp) == "((a b c (deref d)))"
def test_quote(): sexp = load("(a b c '(1 2 3))") assert repr(sexp) == "((a b c (quote (1 2 3))))"
from descriptor import * parser = argparse.ArgumentParser(description='Processes images and detects pedestrians.') parser.add_argument('command', choices=['train_model', 'prepare_initial', 'prepare_hard_examples']) parser.add_argument('--descriptor', choices=['hog', 'css', 'hogcss'], required=True) parser.add_argument('--model') parser.add_argument('--prefix') parser.add_argument('--hard_examples', nargs='*') args = parser.parse_args() if args.descriptor == "hog": descriptor = HOG() elif args.descriptor == "css": descriptor = CSS() elif args.descriptor == "hogcss": descriptor = HOGCSS() model = Model(descriptor) if args.command == 'prepare_initial': model.prepare_initial() elif args.command == 'prepare_hard_examples': model.load(args.model) model.prepare_hard_examples(args.prefix) elif args.command == 'train_model': print "Loading training and test set..." images_train, labels_train = load(WINDOW_TRAIN_POS, WINDOW_TRAIN_NEG, args.hard_examples) images_test, labels_test = load(WINDOW_TEST_POS, WINDOW_TEST_NEG, args.hard_examples) print "Loaded {0} train and {1} test images".format(len(images_train), len(images_test)) model.train(images_train, labels_train, images_test, labels_test) model.save(args.model)
lambda x: ' '.join(x.split())) end_time(start) return df_clean if __name__ == '__main__': if 'read' in argv: if 'shard' in argv: df = pd.read_csv('../data/similars_shard.csv') else: df = pd.read_csv('../data/similars.csv') else: df = load() df_clean = clean(df) if 'write' in argv: if 'shard' in argv: ints_in_argv = [int(arg) for arg in argv if arg.isdigit()] rows = ints_in_argv[0] if ints_in_argv else 100 df_clean.head(rows).to_csv('../data/clean_shard.csv', index=False, encoding='utf-8') else: df_clean.to_csv('../data/clean.csv', index=False, encoding='utf-8')
def test_unbalanced_lparen(): with pytest.raises(ParserError): sexp = load("(a b c")
def test_unquote_splice(): sexp = load("(a b c ~@d)") assert repr(sexp) == "((a b c (unquote-splice d)))"
def job(): extract() transform() load()
def main(): move_old = load("move") auto_old = load("auto") on_old = load("on") superdecorate("CONVOLUTIONAL MAZE RUNNER ROBOT") imp(None, on_old) imp(auto_old, None) while(1): # Check if there is any change in mode or status on, auto = load("on"), load("auto") if(on != on_old): imp(None, on) if(auto != auto_old): imp(auto, None) while (load("on")=="1" and load("auto")=="1"): # Load Data decorate("Loading Data") coord = load("coord").split(' ') x0, y0 = int(coord[0]), int(coord[1]) x1, y1 = int(coord[2]), int(coord[3]) print("Starting Point: (" + str(x0) + "," + str(y0) + ")") print("Ending Point: (" + str(x1) + "," + str(y1) + ")") # Conv Neural Network decorate("Running Convolutional Neural Network") maze = conv(0) print("Walls detected:") print(maze) # A* Pathfinding Algorithm decorate("Running A* Pathfinding Algorithm") start = (x0, y0) end = (x1, y1) path = astar(maze, start, end) print("Shortest path found: " + str(path)) # Encoder decorate("Encoding Data") orders = encoder(path) print("Orders encoded: " + str(orders)) # Send orders via Bluetooth decorate("Sending orders to Robot") blue_auto(orders) print("Orders sent") # Change mode to OFF write("on",0) while (load("on")=="1" and load("auto")=="0"): # Load manual control move = load("move") if (move != move_old): imp(move, None) # Send orther via bluetoooth blue_manual(move) t.sleep(0.5) move_old = move t.sleep(0.5) on_old, auto_old = on, auto
def test_unquote_splice_list(): sexp = load("(a b c ~@(1 2 3))") assert repr(sexp) == "((a b c (unquote-splice (1 2 3))))"