Wednesday, 15 August 2012

Enforcing compatibility between numpy 1.8 and 1.9 nansum? -



Enforcing compatibility between numpy 1.8 and 1.9 nansum? -

i have code needs behave identically independent of numpy version, underlying np.nansum function has changed behavior such np.nansum([np.nan,np.nan]) 0.0 in 1.9 , nan in 1.8. <=1.8 behavior 1 prefer, more of import thing code robust against numpy version.

the tricky thing is, code applies arbitrary numpy function (generally, np.nan[something] function) ndarray. there way forcefulness new or old numpy nan[something] functions conform old or new behavior shy of monkeypatching them?

a possible solution can think of outarr[np.allnan(inarr, axis=axis)] = np.nan, there no np.allnan function - if best solution, best implementation np.all(np.isnan(arr), axis=axis) (which require supporting np>=1.7, that's ok)?

in numpy 1.8, nansum defined as:

class="lang-py prettyprint-override">a, mask = _replace_nan(a, 0) if mask none: homecoming np.sum(a, axis=axis, dtype=dtype, out=out, keepdims=keepdims) mask = np.all(mask, axis=axis, keepdims=keepdims) tot = np.sum(a, axis=axis, dtype=dtype, out=out, keepdims=keepdims) if np.any(mask): tot = _copyto(tot, np.nan, mask) warnings.warn("in numpy 1.9 sum along empty slices zero.", futurewarning) homecoming tot

in numpy 1.9, is:

class="lang-py prettyprint-override">a, mask = _replace_nan(a, 0) homecoming np.sum(a, axis=axis, dtype=dtype, out=out, keepdims=keepdims)

i don't think there way create new nansum behave old way, given original nansum code isn't long, can include re-create of code (without warning) if care preserving pre-1.8 behavior?

note _copyto can imported numpy.lib.nanfunctions

numpy

web services - javax.net.ssl.SSLException: hostname in certificate didn't match in Android -



web services - javax.net.ssl.SSLException: hostname in certificate didn't match in Android -

i updating web service url of android application, using https protocol. see current https url working migrating new domain creating problem.

i have checked many threads on stackoverflow javax.net.ssl.sslexception: hostname in certificate didn't match android didn't find reply answering bypass security or allow all.

javax.net.ssl.sslexception: hostname in certificate didn't match:

//httpget getmethod = new httpget(string.format(httpurl)); httpget getmethod = new httpget(httpurl); defaulthttpclient client = new defaulthttpclient(); responsehandler<string> responsehandler = new basicresponsehandler(); httpparams params = client.getparams(); params.setparameter(coreconnectionpnames.connection_timeout, 60000); params.setparameter(coreconnectionpnames.so_timeout, 60000); client.setparams(params); responsebody = client.execute(getmethod, responsehandler); responsebody = responsebody.trim();

thanks in advance.

if works in browser not in app might problem missing sni support, see why android wrong ssl certificate? (two domains, 1 server).

android web-services ssl https

javascript - Listening horizontal scroll -



javascript - Listening horizontal scroll -

javascript has ability hear scrolling on fly (scrolltop(); isn't it). there function hear i've scrolled if i'm doing horizontally?

i have div of images, can scrolled horizontally ( see: http://jsfiddle.net/j5q1b8x9/).

.scroll-container { overflow-x: scroll; overflow-y: hidden; white-space: nowrap;

}

and want when scroll right, reddish box move left , vice versa. i've tried scrollleft(); , fires when i've reached end of images, isn't listening coordinates on fly.

bonus, it's possible implement kind of function each of images, using foreach path? i.e. if scroll 1 image viewport left right, reddish box move right left, , when new image pops viewport, jazz begins again, new image.

any ideas should test out create reddish box move mirror when scrolling left right?

if understand question works demo

var container = $(".scroll-container"); var box= $(".test-div"); var scrollx =container.scrollleft(); container.scroll(function(){ var delta =container.scrollleft() - scrollx; // direction < 0 left right scrollx =container.scrollleft(); if (delta<0) box.css({left:0, right:'auto'}); else box.css({left:'auto', right:0});

});

javascript jquery

c# - visual studo item template with wizard and T4 -



c# - visual studo item template with wizard and T4 -

i looking sample on how create item template wizard in visual studio 2012.

i need wizard mvc controller.

when user selects add together item, want show dialog user enters input parameters, including class in solution.

then on pressing ok generate form (including designer , resx) want add together project.

currently have t4 files , programme this, using external tools (texttransform.exe), copying files in folder of solution , manipulating csproj file manually.

// set text transform programme (this alter according windows version) p.startinfo.filename = "c:\\program files (x86)\\common files\\microsoft shared\\texttemplating\\11.0\\texttransform.exe"; // specify t4 template file p.startinfo.arguments = "-out " + "\"" + output + "\"" + " \"" + template + "\""; //manipulating csproj var formnode = new xelement(@"{http://schemas.microsoft.com/developer/msbuild/2003}compile", new xattribute("include", frompath)); formnode.add(new xelement(@"{http://schemas.microsoft.com/developer/msbuild/2003}subtype", "form")); programnode.addbeforeself(formnode);

c# visual-studio templates visual-studio-2012 t4

python - Would any CPython 2.7 code work in Jython 2.7b3? -



python - Would any CPython 2.7 code work in Jython 2.7b3? -

frank wierzbicki in blog post has written "jython 2.7b3 brings language level compatibility 2.7 version of cpython."

does mean cpython 2.7 code work jython?

i have big code written in cpython 2.7. since want integrate java modules, extremely interested in way of migrating jython without rewriting of code. considering libraries, utilize lot of lxml (as described here) not compatible previous versions jython.

no, not all code works in cpython 2.7 work in jython, in same way code tied specific os , won't work on other os-es (e.g. windows-specific python code won't work on linux, , vice versa).

the syntax work, if script requires specific add-on modules such lxml, not work. because lxml c-api extension, , jython doesn't back upwards python c-api.

similarly, if code uses multiprocessing module, won't work on jython, because part of standard library not included.

python migration lxml jython

neo4j - how to match relationships with multiple properties passed as a query parameter? -



neo4j - how to match relationships with multiple properties passed as a query parameter? -

let's have next info model:

(user)-[r:has_permissions]->(n) , properties of 'r' permissions in boolean values, view=true, create=true.

i want find users have permissions entity, passed query parameter.

naively want like:

match (u:user)-[r:has_permissions {permissions}]->(n) homecoming u, know isn't right {permissions} can used create statement..

the passed permissions parameter map, {view: true}

i'm thinking of like:

match (u:user)-[r:has_permissions]->(n) all(p in {permissions} r.{p} = {permissions}.p) homecoming u

obviously won't work permissions property map , not array , need access it's keys , values somehow.

am in right direction ? how can accomplish i'm looking ?

you can pass each of properties of permissions variable independently.

match (u:user)-[r:has_permissions { view: {view}, create: {create} }]->(n) homecoming u

then pass in parameters view , create.

if don't know permissions properties may be, handle in app. in ruby, i'd this:

def permissions_parameter(permissions) permission_keys = [] permission_values = [] permissions.each |k, v| permission_keys.push("r.#{k}: {#{k}}") permission_values.push("'#{k}': '#{v}'") end permission_keys_cypher = permission_keys.join(', ') permission_params_cypher = permission_values.join(', ') [permission_keys_cypher, permission_params_cypher] end permissions = permissions_parameter({ create: true, view: true }) puts "match (u:user)-[r:has_permissions { #{permissions[0]} }]->(n) homecoming u" # match (u:user)-[r:has_permissions { r.create: {create}, r.view: {view} }]->(n) homecoming u puts "params: #{permissions[1]}" # params: 'create': 'true', 'view': 'true'

neo4j cypher

c# - Camera Lerp seems to be incrementing every loop -



c# - Camera Lerp seems to be incrementing every loop -

i have 7 positions iterate between , have difference on x axis of 4.5 position0 = 0, position1 = 4.5 & position = 9, on , forth.

however, appears when go position0 position1, x continues grow 4.5. iterate through array works increases 4.5 every frame. doing wrong?

void start () { _positionarray[0] = position0; _positionarray[1] = position1; _positionarray[2] = position2; _positionarray[3] = position3; _positionarray[4] = position4; _positionarray[5] = position5; _positionarray[6] = position6; endposition = position0; } public void changedestination() { if (_leapmanager.swipeperformed) { swipedirection = _leapmanager.swipedirection; if (swipedirection == "left" && posinarray >= 0 && posinarray < 5) { debug.log("called"); posinarray++; endposition.position = _positionarray[posinarray].position; } else if (swipedirection == "right" && posinarray <= 5 && posinarray > 0) { posinarray--; endposition.position = _positionarray[posinarray].position; } } } // update called 1 time per frame void update () { transform.position = vector3.lerp(transform.position, endposition.position, speed * 3.0f * time.deltatime); }

c# unity3d