Posts

get elements in "AND" in logic string with Python -

i want parse logic strings , combinations of elements in "and" logic. instance, string '( , ( b or c ) )' should [[a,b],[a,c]] , string '( , b , ( c or d , f ) or f , g )' should [[a,b,c],[a,b,d,f],[f,g]]. i'm trying use pyparsing. following post here parsing complex logical expression in pyparsing in binary tree fashion manage nested list letters grouped according preferences ("and" has preference on "or", , parenthesis overrides this): import pyparsing pp complex_expr = pp.forward() vars = pp.word(pp.alphas, pp.alphanums + "_") | pp.regex(r"[+-]?\d+(:?\.\d*)?(:?[ee][+-]?\d+)?").setname('proteins') clause = pp.group(vars ^ (pp.suppress("(") + complex_expr + pp.suppress(")") )) expr = pp.operatorprecedence(clause,[ ("and", 2, pp.opassoc.left, ), ("or", 2, pp.opassoc.left, ),]) #print expr complex_expr ...

why `ifroom` does not work - android studio -

hi there try set ifroom in menu item. can see in code try possible senario (please see each showasaction item <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".mainactivity"> <item android:id="@+id/action_forward" android:title="forward" android:icon="@drawable/ic_action_arrow_forward" android:showasaction="ifroom" ></item> <item android:id="@+id/action_zoom_in" android:title="zoom in" android:icon="@drawable/ic_action_zoom_in" android:showasaction="ifroom|withtext" ></item> <item android:id="@+id/action_home" android:title="home" android:icon="@d...

emulation - Visual Studio Android Emulator Display Keyboard -

Image
how can display keyboard on vs android emulator? in avd can setup emulator configurator, there no way in vs. i found solution in android setting → language input → keyboard click on current keyboard , switch "hardware show input method"

Has Sitecore 8 built-in support for MVC areas? -

is sitecore 8 has built-in support mvc areas? or still need install sitecore plugins? thanks quoting kevin brechbühl (from the sitecore mvc puzzle ): sitecore has no support areas out of box, there multiple solutions available integrate them in solutions: resolve area in mvc.renderrendering-pipeline use custom controllerrunner , custom renderer resolve area configurations we saw sitecore working on solution integrate areas core. rumor has integrate similar pattern brainjocks mvc.renderrendering pipeline.

python - Genetic Algorithm roulette selection - returning 2 parent chromosomes -

i want implement roulette wheel selection in ga algorithm. tried following guide https://stackoverflow.com/a/5315710/536474 sends new population instead of 2 best parents. suppose found fitness score initial population , need select 2 parent chromosomes population according fitness. , further goes crossover , mutation processes. in following case, how can find 2 best parents crossover based on roulette wheel selection? population = [[text1],[text2],[text3],.....[textnum]] fitnesses = [0.8057515980834005, 1.2151126619653638, 0.6429369518995411, ... 0.805412427797966] num = 50 it doesn't send new population, num parents. if want 2 parents call roulette_select way: roulette_select(population, fitnesses, 2) often ga crossover operator expects 2 parents there variations many parents (e.g. genetic algorithms multi-parent recombination - a.e. eiben, p-e. raué, zs. ruttkay ). there self-crossover operators. so having num input parameters makes sense.

What are the constraints of Swift's array syntax? -

i'm working through exercises in the swift programming language , , 1 thing noted odd array syntax. per this answer , array<t.generator.element>() works, yet var common = [t.generator.element]() not. @ same time, var common: [t.generator.element] = [] correct. what rules around array syntax/initialization? why doesn't second line work?

python - Django Rest Framework: Implementing Many-to-Many relationship in Serializer -

i'm using django rest framework create custom api movies model defined follows: models.py from django.db import models class genres(models.model): genre = models.charfield(max_length = 128, unique = true) class movies(models.model): popularity = models.floatfield() director = models.charfield(max_length = 128) genres = models.manytomanyfield(genres, related_name = 'movies') imdb_score = models.floatfield() movie_name = models.charfield(max_length = 500) now, in application, each genre can have multiple movie instances , vice versa. result, there many-to-many relationship between genres model , movies model. want allow admin chose multiple genres particular movie while posting new movies instances @ api endpoint. serializers.py from shoppy.models import movies, genres rest_framework import serializers class genresserializer(serializers.modelserializer): class meta: model = genres class moviesserializer(serializers...