Posts

python - find 2d elements in a 3d array which are similar to 2d elements in another 3d array -

i have 2 3d arrays , want identify 2d elements in 1 array, have 1 or more similar counterparts in other array. this works in python 3: import numpy np import random np.random.seed(123) = np.round(np.random.rand(25000,2,2),2) b = np.round(np.random.rand(25000,2,2),2) a_index = np.zeros(a.shape[0]) in range(a.shape[0]): b in range(b.shape[0]): if np.allclose(a[a,:,:].reshape(-1, a.shape[1]), b[b,:,:].reshape(-1, b.shape[1]), rtol=1e-04, atol=1e-06): a_index[a] = 1 break np.nonzero(a_index)[0] but of course approach awfully slow. please tell me, there more efficient way (and is). thx. you trying all-nearest-neighbor type query. has special o(n log n) algorithms, i'm not aware of python implementation. can use regular nearest-neighbor o(n log n) bit slower. example scipy.spatial.kdtree or ckdtree . import numpy np import random np.random.seed(123) = np.round(np.random.rand(25000,2,2),2) b = np.round...

java - How get the some numbers from the string -

i have string "9x1x121: 1001, 1yxy2121: 2001, role: zzzzz" , need numbers input string. string input = "9x1x121: 1001, 1yxy2121: 2001, role: zzzzz"; string[] part = input.split("(?<=\\d)(?=\\d)"); system.out.println(part[0]); system.out.println(part[1]); i need output below numbers only 1001 2001 you split on ',' split splitted string on ': ' , check if part[1] number or not (to avoid cases role). string input = "9x1x121: 1001, 1yxy2121: 2001, role: zzzzz"; string[] allparts = input.split(", "); (string part : allparts) { string[] parts = part.split(": "); /* parts[1] need if it's number */ }

php - Regular expression: Get TeX commands -

i have string like: $str = "\textaolig 3 \texthtbardotlessjvar \textrthooklong b \textbenttailyogh ; \textinvomega q \textscaolig . \textbktailgamma p \textinvsca r \textscdelta d \textctinvglotstop ! \textinvscripta s \textscf 2 \textctjvar \textlfishhookrlig t \textsck"; and wanna tex commands (\textaolig etc.) regular expression. tried: \\([[a-z]\s]+) but no luck. can me out? kind regards, first of all, have enclose string single quotes because when using double quotes if use backslash try escape character, isn't case. secondly, have use \\\\ match backslash. i don't know tex commands, i've tried match [\w\s\.;]+ correct if needed: $str = '\textaolig 3 \texthtbardotlessjvar \textrthooklong b \textbenttailyogh ; \textinvomega q \textscaolig . \textbktailgamma p \textinvsca r \textscdelta d \textctinvglotstop ! \textinvscripta s \textscf 2 \textctjvar \textlfishhookrlig t \textsck'; preg_...

if statement - Check if 2 string are differents java -

i have problem if condition, have code : if(!session.getattribute("login").equals(d3.getlogin_demandeur())){ //do }else{ //do else } so code if session.getattribute("login") equals d3.getlogin_demandeur() should go else statement, doesn't work, have printed out these 2 values , same , still go else statement, idea ? edit : here how print system.out.println(session.getattribute("login")+"="+(d3.getlogin_demandeur())); and have : smilleto=smilleto you can use trim() function remove unwanted spaces , use equalsignorecase() if don't have case sensitivity criteria. string login = (string)session.getattribute("login").trim(); string logindemandeur = d3.getlogin_demandeur().trim(); // assuming getlogin_demandeur has return type string. if(!login.equalsignorecase(logindemandeur)){ //do }else{ //do else }

ruby on rails - Why puma staging environment does not start? -

when try start web-server in staging environment not run. in production environment same configuration - ok. where can error? my config puma is: deploy_to = env['current_path'] workers integer(env['puma_workers'] || 3) threads integer(env['min_threads'] || 16), integer(env['max_threads'] || 16) daemonize true preload_app! backlog = integer(env['puma_backlog'] || 20) directory "#{deploy_to}/current" pidfile "#{deploy_to}/shared/tmp/pids/puma.pid" state_path "#{deploy_to}/shared/tmp/sockets/puma.state" stdout_redirect "#{deploy_to}/shared/log/puma.stdout.log", "#{deploy_to}/shared/log/puma.stderr.log" bind "unix://#{deploy_to}/shared/tmp/sockets/kiosk.sock" activate_control_app "unix://#{deploy_to}/shared/tmp/sockets/pumactl.sock" on_worker_boot # worker specific setup activesupport.on_load(:active_record) config = acti...

html - Bootstrap Scrolling Nav: fix sections height and active menu highlight -

when click <a> link in navigation anchor point looks wrong, because can't see section headline. <h2> in case. is possible highlight <a> link? border or smething this... this html code: <!-- fixed navbar --> <nav id="navbar" class="navbar navbar-default"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div id="navbar" class="navbar-collapse collapse...

bayesian - How to test the convergence in bugs model? -

Image
i want explain convergence in bugs model command plot(). example of output in follow figure i don't sure can read output well, :) unfortunately, not if can confirm convergence figure showing ( edit : there @ least information, see below). left hand side of figure caterpillar plot, shows 95% intervals of distribution each parameter. assessing convergence more nuanced process, there multiple ways decide if model has converged. want determine model has appropriately explored parameter space each parameter (through trace plots, traceplot function in coda library), between , within chain variance (the gelman-rubin diagnostic, gelman.diag in coda library), , auto-correlation in chains ( autocorr.plot in coda ). there variety of other measures others have suggested assess if model has converged, , looking through rest of coda package illustrate this. i highly suggest go through winbugs tutorial in user manual (link pdf), has section addresses checking model co...