[Numpy-discussion] ANN: BayesPy 0.2

2014-08-21 Thread Jaakko Luttinen
Dear all,

I am pleased to announce the release of BayesPy version 0.2.

BayesPy provides tools for Bayesian inference in Python. In particular, 
it implements variational message passing framework, which enables 
modular and efficient way to construct models and perform approximate 
posterior inference.

Download: https://pypi.python.org/pypi/bayespy/

Documentation: http://www.bayespy.org

Repository: https://github.com/bayespy/bayespy

Comments, feedback and contributions are welcome.

Best regards,
Jaakko
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy/Fortran puzzle (?)

2014-08-21 Thread Xavier Barthelemy
Hi Andrea
You should add a dimension argument in your Fortran code, also you should
write a f2py header in the same Fortran code.
Remember, numpy memory is C order wise.
You can specify in numpy the ordering of the matrices you pass when you
create them.
F2py automatically deals with matrices , but tends to mix dimensions when
there are too many matrices.
Manual declaration of dimensions should do the trick
Xavier
On 21/08/2014 2:07 am, Andrea Gavana andrea.gav...@gmail.com wrote:

 Hi All,

 I have the following (very ugly) line of code:

 all_results = np.asarray([transm_hist[date_idx, :, idx_main_set[date_idx]
 ]*main_flow[date_idx, 0:n_fluids] for date_idx in xrange(n_dates)])

 where transm_hist.shape = (n_dates, n_fluids, n_nodes), main_flow.shape =
 (n_dates, n_fluids) and idx_main_set is an array containing integer indices
 with idx_main_set.shape = (n_dates, ) . The resulting variable
 all_results.shape = (n_dates, n_fluids)

 Since that line of code is relatively slow if done repeatedly, I thought
 I'd be smart to rewrite it in Fortran and then use f2py to wrap the
 subroutine. So I wrote this:

 subroutine matmul(transm_hist, idx_main_set, main_flow, all_results, 
   n_dates, n_fluids, n_nodes)

   implicit none

   integer ( kind = 4 ), intent(in) :: n_dates, n_fluids, n_nodes

   real( kind = 4 ), intent(in) :: transm_hist(n_dates, n_fluids,
 n_nodes)
   real( kind = 4 ), intent(in) :: main_flow(n_dates, n_fluids)
   integer ( kind = 4 ), intent(in) :: idx_main_set(n_dates)
   real( kind = 4 ), intent(out):: all_results(n_dates, n_fluids)

   integer (kind = 4) i, node

   do i = 1, n_dates
   node = int(idx_main_set(i))
   all_results(i, :) = transm_hist(i, 1:n_fluids, node)*main_flow(i,
 1:n_fluids)
   enddo

 end


 Unfortunately, it appears that I am not getting out quite the same
 results... I know it's a bit of a stretch with so little information, but
 does anyone have a suggestion on where the culprit might be? Maybe the
 elementwise multiplication is done differently in Numpy and Fortran, or I
 am misunderstanding what the np.asarray is doing with the list
 comprehension above?

 I appreciate any suggestion, which can also be related to improvement in
 the code. Thank you in advance.

 Andrea.

 Imagination Is The Only Weapon In The War Against Reality.
 http://www.infinity77.net


 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Best way to broadcast a function from C

2014-08-21 Thread Nathaniel Smith
On Thu, Aug 21, 2014 at 2:34 AM, James Crist crist...@umn.edu wrote:
 All,

 I have a C function func that takes in scalar arguments, and an array of
 fixed dimension that is modified in place to provide the output. The
 prototype is something like:

 `void func(double a, double b, double c, double *arr);`

 I've wrapped this in Cython and called it from python with no problem. What
 I'd like to do now though is get it set up to broadcast over the input
 arguments and return a 3 dimensional array of the results. By this I mean

 a = array([1, 2, 3])
 b = array([2.0, 3.0, 4.0])
 c = array([3, 4, 5])

 func(a, b, c) - a 3d array containing the results of func for (a, b, c) =
 (1, 2.0, 3), (2, 3.0, 4), (3, 4.0, 5)

 I'm not sure if this would qualify as a ufunc, as the result of one function
 call isn't a scalar but an array, but the effect I'm looking for is similar.
 Ideally it would handle datatype conversions (in the above `a` and `c`
 aren't double, but `func` takes in double). It would also be awesome to
 allow an argument to be a scalar and not an array, and have it be broadcast
 as if it were.

 I'm just wondering what the best way for me to hook my code up to the
 internals of numpy and get this kind of behavior in an efficient way. I've
 read the writing your own ufunc part of the docs, but am unsure if what
 I'm looking for qualifies. Note that I can change the inner workings of
 `func` if this is required to achieve this behavior.

I don't think it's currently possible to write a ufunc that maps
scalars to fixed-length arrays.

There's probably some not-too-terrible way to do this using the C
nditer interface, but IIRC the docs aren't for that aren't very
helpful.

The simplest approach is just to do a bit of work at the Python level
using the standard numpy API to do error-checking and set up your
arrays in the way you want, and then pass them to the C
implementation. This is not the best way to get a Right solution that
will handle all the funky corner cases that ufuncs handle, but it's by
far the fastest way to get something that's good enough for whatever
you need Right Now.

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Just FYI: numpy-vbench was moved to another box, benchmarks are re-estimating

2014-08-21 Thread Yaroslav Halchenko
I have no stats on either anyone is looking at
http://yarikoptic.github.io/numpy-vbench besides me at times, so I
might be just crying into the wild:

I have moved running of numpy-vbench on a bit newer/more powerful box,
and that is why benchmark results are being reestimated (thus you might
still find some spikes and more noise than before for a bit
longer). It is a dual Quad-Core AMD Opteron(tm) Processor 2384
with 32GB of RAM, so if someone is keen on pushing the benchmarks limits
-- be my guest ;)

-- 
Yaroslav O. Halchenko, Ph.D.
http://neuro.debian.net http://www.pymvpa.org http://www.fail2ban.org
Research Scientist,Psychological and Brain Sciences Dept.
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834   Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion