Posts

Integrating over an interpolate function (interp1d) in python -

i trying double integration on interpolated function, in r = r(x,y) . from scipy import interpolate import scipy sp r = [0, 1, 2] z = [0, 1, 2] def cartesian(x, y, f): r = sp.sqrt(x**2 + y**2) return f(r) interp = interpolate.interp1d(r, z) print(cart(1,1,interp)) = sp.integrate.dblquad(cart, 0, 1, lambda x: 0, lambda x: 1, args=(interp)) print(a) executing cartesian function once produces correct answer. integral gives the following error: typeerror: integrate() argument after * must iterable, not interp1d i don't understand why function isn't iterable , not know how convert iterable form. many help. args supposed sequence of arguments, so: sp.integrate.dblquad(cart, 0, 1, lambda x: 0, lambda x: 1, args=(interp,)) the comma after interp critical: in python, (x) x , (x,) tuple (i.e. sequence).

python - Add successive rows in Pandas if they match on some columns -

i have dataframe following one: id url seconds 1 email 9 1 email 3 1 app 5 1 app 9 1 faceboook 50 1 faceboook 7 1 faceboook 39 1 faceboook 10 1 email 39 1 email 5 1 email 57 1 faceboook 7 1 faceboook 32 1 faceboook 3 2 app 11 2 app 10 2 email 56 2 faceboook 9 2 faceboook 46 2 faceboook 16 2 email 21 i want sum 'seconds' column successive views of same url same id. that's result i'm looking for: id url seconds 1 email 12 1 app 14 1 faceboook 106 1 email 101 1 faceboook 42 2 app 21 2 email 56 2 faceboook 71 2 email 21 df.groupby(['id', 'url']).sum() not work in case sum cases of same url same id, not successive ones. any ideas? you can use groupby series created compare ne column url , shifted, last use cumsum boolean mas...

javascript - When to bind this keyword to an event handler in react? -

so, let's have class named search simple input field submit button. here's code that. class search extends component { constructor(props){ super(props); this.state = {term: ''}; this.handlechange = this.handlechange.bind(this); } handlechange(e) { console.log(this); console.log(e.target.value); this.setstate({term: e.target.value}); } render() { return ( <form classname='input-group'> <input classname='form-control' placeholder='city' onchange={this.handlechange} value={this.state.value}/> <span classname='input-group-btn'> <button type='submit' classname='btn btn-primary'>submit</button> </span> </form> ) } } ...

c++ - Why does my application crash on exit after invoked QNetowrkAccessManager::get? -

i using qt 5.7 32bit in visual studio 2015. want http qnetworkaccessmanager. but, application crashed when closing application. because, when calling qnetworkmanager::get function , closing window, access violation exception occurs in qnetwork.dll , application abort . (if comment out line calling qnetworkmanager::get function, abnormal termination doesn't occur.) specifically, call stack follows. happened in qnetwork.dll , others. ntdll.dll!7770904e() unknown [frames below may incorrect and/or missing, no symbols loaded ntdll.dll] [external code] libeay32.dll!020b122e() unknown libeay32.dll!02120e0c() unknown libeay32.dll!02117592() unknown libeay32.dll!021176cb() unknown libeay32.dll!0211764c() unknown libeay32.dll!021177e0() unknown libeay32.dll!021174e0() unknown libeay32.dll!02113d7e() unknown qt5networkd.dll!q_x509_free(x509_st * a) line 354 c++ qt5networkd.dll!qsslcertificateprivate::~qsslcertificateprivate() line 92 c++ [external code] qt5networkd.dll!qexplicitlys...

python - How to store Gzipped content in Aerospike (cache)? -

i'm using aerospike python client here. don't find problem while storing plain string in cache because when retrieve key, same string saved when conn.get(key) import aerospike conn_aerospike_config = {'hosts': [('127.0.0.1', 3000)]} conn = aerospike.client(conn_aerospike_config).connect() key = ('namspace_name', 'set_name', 'key_name') value = "some big string" conn.put(key, {'value': value}) if want save gzipped content in place of value, don't find error i'm unable exact content. from gzip import gzipfile io import bytesio def compress_string(s): zbuf = bytesio() gzipfile(mode='wb', compresslevel=6, fileobj=zbuf, mtime=0) zfile: zfile.write(s) return zbuf.getvalue() put_value = compress_string(value) conn.put(key, {'value': put_value}) _, _, get_value = conn.get(key) i checked printing values of put_value, get_value. don't match, , need gzipped content, beca...

Determine latest file from SFTP server using java jsch -

is there way determine name of latest file on unix server using java jsch? i want copy latest file server local machine. have working code that. i'm not able identify latest file. folder contains many files in below format:- report dd/mm/yyyy hh:ss i tried code mentioned in this post isn't picking latest file. code never seems stop executing. any appreciated. according post referred this post there code line says filter xml file have changed check file format list = main.chansftp.ls("*.xml"); also there sleep method called on executing thread 1 minute thread.sleep(60000); so expect code run atleast minute this might help

How to connect slack app to webhook? -

how can above keep getting following error when try , interact accompanying button. darn – didn't work. slack apps can add interactive elements messages interactive buttons of features work if use slack app. 1 reason need place configure url of script slack send request when clicking on button. work webhooks, if webhook part of slack app. not work simple custom webhook. to make slack app slack team need follow 2 steps. create new slack app (e.g. on page ) install slack app in slack team oath. (see here ) note not need publish slack app slack app directory. optional.