I implemented my own csv reader using
cassava library. The reader from
missingh library was taking too long (~ 17 seconds) for a file with 43200 lines. I compared the result with
python-pandas csv reader. Below is rough comparison.
|cassava (ignore #)
|cassava (no support for ignoring #)
|> 10 sec
As obvious, pandas does really well at reading csv file. I was hoping that my csv reader would do better but it didn’t. But it still beats the
parsec based reader hands down.
The code is here https://github.com/dilawar/HBatteries/blob/master/src/HBatteries/CSV.hs
Here is a test case
>>> import numpy as np
>>> a = np.array( [ 0.0, 1, 2, 0.2, 0.0, 0.0, 2, 3] )
I want to turn all non-zero elements of this array to 1. I can do it using
np.where and numpy indexing.
>>> a[ np.where( a != 0 ) ] = 1
array([ 0., 1., 1., 1., 0., 0., 1., 1.])
np.where returns the indices where the condition is true. e.g. if you want to change all 0 to -1.
>>> a[ np.where[ a == 0] ] = -1.0
That’s it. Checkout
np.clip as well.
For our neural simulator, MOOSE, we use GNU Scientific Library (GSL) for random number generation, for solving system of non-linear equations, and for solving ODE system.
Recently I checked the performance of GSL ode solver V/s Boost ode solver; both using Runge-Kutta 4. The boost-odeint outperformed GSL by approximately by a factor of 4. The numerical results were same. Both implementation were compiled with -O3 switch.
Below are the numerical results. In second subplot, a molecule is changing is concentration ( calcium ) and on the top, another molecule is produced (CaMKII). This network has more than 30 reactions and approximately 20 molecules.
GSL took approximately 39 seconds to simulate the system for 1 year. While Boost-odeint took only 8.6 seconds!