Posts

swift - iOS tableview how can I check if it is scrolling up or down -

i learning how work tableviews , wondering how can figure out if tableview scrolling or down ? been trying various things such hasn't worked granted below scrollview , have tableview . suggestions great new @ ... func scrollviewwillbegindragging(_ scrollview: uiscrollview) { if scrollview.pangesturerecognizer.translation(in: scrollview).y < 0 { print("down") } else { print("up") } } this have in tableview code func tableview(_ tableview:uitableview, numberofrowsinsection section:int) -> int { return locations.count } func tableview(tableview: uitableview, willdisplaycell cell: uitableviewcell, forrowatindexpath indexpath: nsindexpath) { if indexpath.row == self.posts.count - 4 { reloadtable(latmin: self.latmin,latmax: self.latmax,lonmin: self.lonmin,lonmax: self.lonmax,my_id: myid) print("load more") } } func tableview(_ tableview: uitable...

Swaping elements in 3d numpy array -

this question has answer here: numpy reverse multidimensional array 2 answers given 3d numpy array how swap first , last element of each 'pixel' for example: a = [[[15 3 61] [56 27 22] [48 32 29] [38 21 50] [28 54 37]] [[47 27 35] [52 34 12] [18 56 48] [ 8 34 1] [37 27 38]]] i want array be: a = [[[61 3 15] [22 27 56] [29 32 48] [50 21 38] [37 54 28]] and on is there way without using loops? you can reverse array along third axis a[..., ::-1] : a = np.array([[[15, 3, 61], [56, 27, 22], [48, 32, 29], [38, 21, 50], [28, 54, 37]], [[47, 27, 35], [52, 34, 12], [18, 56, 48], [ 8, 34, 1], [37, 27, 38]]]) a[..., ::-1] #array([[[61, 3, 15], # [22, 27, 56], # [29, 32, 48], # [50, 21, 38], # [37, 54, 28]], # [[35, 27,...

python - how do I use my machine learning model as an api? -

suppose created machine learning prediction model on data set, trained it, got results , want use make prediction on new data take user. every 1 says deploy aws, microsoft azure etc, want use research purpose, how can create simple api of machine learning model? i think question bit broad want share experience on building first api in python. i installed flask , framework on top of flask called flask-restful . flask_restful super easy use , official guide helped me out lot. my suggestion build api first figure out platform want use deployment.

Redux - I don't understand "Task-Based Updates" example -

in link: task-based updates don't understand below code: import posts "./postsreducer"; // missing code?? import comments "./commentsreducer"; // missing code?? and why should that? const combinedreducer = combinereducers({ posts, comments }); const rootreducer = reducereducers( combinedreducer, featurereducers ); only featurereducers okie? not need combindedreducer? anh postsreducer code, commentsreducer code? thanks helps! unfortunately example little confusing (one of few places in solid redux docs). if go here , check out 'third approach', you'll see concept explained little better. essentially, postreducer , commentreducer there handle actions modify posts or comments --that is, things not require changes multiple tables (e.g posts , comments ). featurereducer task-based reducer handles actions require updates multiple tables. a simplified example: const postreducer = (state = {}, action) =...

python - What's the difference between getAffineTransform(), getPerspectiveTransform() and findHomography() -

i'm investigating ways of transforming image , overlaying within contour of image. as best can tell there 3 ways opencv in python: getaffinetransform() getperspectivetransform() findhomography() i found 3 different methods via blog , posts , produce same results, i.e. taking source image , warping/overlaying on contour of different shape on destination image. this demonstrates getaffinetransform() https://stackoverflow.com/a/38323528/1887261 this demonstrates getperspectivetransform() http://uberhip.com/python/image-processing/opencv/2014/10/26/warping-brien/ this demonstrates findhomography() http://www.learnopencv.com/homography-examples-using-opencv-python-c/#download i'm wondering best method use , why use 1 on other?

javascript - Protractor persistent variables -

i'm trying set similar environment / global variables in postman. postman stores these variables in json , when modify them within test, changed new values permanently. example: postman.setenvironmentvariable("variable1", parseint(postman.getenvironmentvariable) +1); this function increment environment variable 1 @ start of request. in real postman tests use custom function calculate valid ean13 barcode based on used barcode must unique. is there can achieved in protractor? use 'params' object storing data. can set in config file. config params: { login: { user: 'jane', password: '1234' } } accessed browser object browser.params.login . can change value of object can retrieved in test.

project reactor - ParallelFlux vs flatMap() for a Blocking I/O task -

i have project reactor chain includes blocking task (a network call, need wait response). i'd run multiple blocking tasks concurrently. it seems either parallelflux or flatmap() used, bare-bone examples: flux.just(1) .repeat(10) .parallel(3) .runon(schedulers.elastic()) .doonnext(i -> blockingtask()) .sequential() .subscribe() or flux.just(1) .repeat(10) .flatmap(i -> mono.fromcallable(() -> {blockingtask(); return i;}).subscribeon(schedulers.elastic()), 3) .subscribe(); what merits of 2 techniques? 1 preferred on other? there alternatives? parallel tailored parallelization of tasks performance purposes, , dispatching of work between "rails" or "groups", each of own execution context scheduler pass runon . in short, put cpu cores work if cpu intensive work. you're doing i/o bound work... so in case, flatmap better candidate. use of flatmap parallelization more orchestration. thes...