Posts

python - Database connection setup broken after updating to Peewee 2.6 from 2.4 -

i want upgrade pewee v2.4.7 v2.6.3 in order use get_or_create method. however, after updating connection setup broken. i used following superclass enable foreign key contraints sqlite (2.6.3): class sqlitefkdatabase(sqlitedatabase): def initialize_connection(self): self.execute_sql('pragma foreign_keys=on;') return self ... using following connection setup code: db = sqlitefkdatabase(none) init_db(path_to_db) def init_db(path_to_db): ...

android - Prevent view overlapping in RelativeLayout -

Image
i'm trying accomplish simple layout task, i'm stuck view overlapping in relativelayout . screenshot: the title textview should centered (both vertically , horizontally). problem when title bit longer , covers button . the desired behaviour title textview aligns left button, or trims (e.g. singleline ). here xml: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <relativelayout android:layout_width="match_parent" android:layout_height="50dp" android:background="#ffffff"> <linearlayout android:id="@+id/backbutton" android:layout_width="100dp" android:layout_height="match_parent" android:background="#cccccc"> ...

java - Consider all possible class values for outputing the predictions on test split -

i new weka , running naive bayes classifier multiclass classification problem. class "game" can have multiple values soccer, rugby, cricket, baseball etc. has more 20 values. when run naivebayes class "game", select option of "output predictions" in order see actual class , missclassified class. one of output : inst# actual predicted error probability distribution 1 1:soccer 5:baseball + 0.1 0 0 0 *0.9 here misclassified class baseball probability of 0.9 , other class has probability of 0.1 soccer correct class. there way can consider class values has probability , if 1 of class values match actual class, should classify correctly. want top class values in row has probability values considered actual class value , if of class(even having lowest probability value) match actual class, correct class. so possible output : inst# actual predicted error ...

f# - Return multiple columns / a dataframe in Deedle based on row-wise mapping -

i want @ each row in frame , construct multiple columns new frame based on values in row. the final result should frame has columns of original frame plus new columns. i have solution wonder if there better one. think best way explain desired behavior example. i'm using deedle's titanic data set : #r @"f:\aolney\research_projects\braintrust\code\qualtricstor\packages\deedle.1.2.3\lib\net40\deedle.dll";; #r @"f:\aolney\research_projects\braintrust\code\qualtricstor\packages\fsharp.charting.0.90.12\lib\net40\fsharp.charting.dll";; #r @"f:\aolney\research_projects\braintrust\code\qualtricstor\packages\fsharp.data.2.2.2\lib\net40\fsharp.data.dll";; open system open fsharp.data open deedle open fsharp.charting;; #load @"f:\aolney\research_projects\braintrust\code\qualtricstor\packages\fsharp.charting.0.90.12\fsharp.charting.fsx";; #load @"f:\aolney\research_projects\braintrust\code\qualtricstor\packages\deedle.1.2.3\deedle.fsx...

c# - service bus receive not returning immediately -

i'm using azure service bus topic/subscriptions , running unexplained performance receiving messages. according msdn: if 0 passed in serverwaittime, there no wait time. instead server bus fetch whatever messages available, or return null result. in code, stripped down bare essentials, pass in 0, receive takes 60 seconds complete. when completes, passed null object. why take 60 seconds when should return immediately? var client = servicebusclient.getorcreatesubscriptionclient(topicname, subscriptionname, false); var msg = client.receive(timespan.fromseconds(0));

c# - LINQ to Entities, Where Any In -

how write 'where in' in linq entity? here model : class chair { public int id { get; set; } public int tableid { get; set; } public table table { get; set; } } class table { public int id { get; set; } public icollection<chair> chairs { get; set; } public icollection<category> categories { get; set; } public table() { chairs = new list<chair>(); categories = new list<category>(); } } class category { public int id { get; set; } public icollection<table> tables { get; set; } } i got simple list of category : list<category> mycategories = new list<category>(c,d,e); i want chairs belongs table got 1 of category mycategories list. thats im trying : var result = ctx.chairs.where(x => x.table.categories.any(y => mycategories.any(z => z.id == y.id))).tolist(); i think ok error : "unable create constant value of type 'consoleapplication1.categ...

Parsing JSON in swift 2.0 -

i'm trying parse json data server api. json : [ {"interest": { "title":"sport", "sub":[ "painting", "photography", "museum"] } }, {"interest": { "title": "music", "sub": [ "rock", "classic", "techno"] } }] the code file test parse : do{ let path = nsbundle.mainbundle().pathforresource("maininterest", oftype: "json") let jsondata = nsdata(contentsoffile: path!) let jsonresult:nsarray! = try nsjsonserialization.jsonobjectwithdata(jsondata! , options: nsjsonreadingoptions.mutablecontainers) as! nsarray } catch let error nserror { print(error) } i can access whole file : print(jsonresult) but can't access more 1 level, here first level : if let = jsonresult { print(a[0...