[Numpy-discussion] [ANN] mlabrap-1.0final: a high level python to matlab

2007-04-11 Thread Alexander Schmolck
I'm pleased to finally announce mlabwrap-1.0:

Project website
---
http://mlabwrap.sourceforge.net/


Description
---

Mlabwrap-1.0 is a high-level python to matlab(tm) bridge that makes calling
matlab functions from python almost as convenient as using a normal python
library. It is available under a very liberal license (BSD/MIT) and should
work on all major platforms and (non-ancient) python and matlab versions and
either numpy or Numeric (Numeric support will be dropped in the future).


Examples


Creating a simple line plot:

 from mlabwrap import mlab; mlab.plot([1,2,3],'-o')

Creating a surface plot:

 from mlabwrap import mlab; from numpy import *
 xx = arange(-2*pi, 2*pi, 0.2)
 mlab.surf(subtract.outer(sin(xx),cos(xx)))

Creating a neural network and training it on the xor problem (requires netlab)

 net = mlab.mlp(2,3,1,'logistic')
 net = mlab.mlptrain(net, [[1,1], [0,0], [1,0], [0,1]], [0,0,1,1], 1000)

What the future holds
-

Please note that mlabwrap-1.0 will be the last non-bugfix release with Numeric
support. Future versions of mlabwrap will require numpy be a part of scipy's
scikits infrastructure (so the package name will be ``scikits.mlabwrap``) and
use setuptools rather than distutils so that it should be possible to
automatically download and install via EasyInstall.

The next major version of mlabwrap should also bring more powerful proxying
and marshalling facilities, but the default conversion behavior might be
changed to reflect the fact that matlab is becoming increasingly less
``double`` (-matrix) centric; although wrappers for old-style behavior will be
provided if backwards-incompatible interface changes are introduced, for
upwards compatibility it is recommended to explicitly pass in float64 arrays
rather than e.g. lists of ints if the desired input type that matlab should
see is a double array (i.e. use ``mlab.sin(array([1., 2., 3.])`` rather than
``mlab.sin([1,2,3])`` for production code in order to be on the safe side)).
Please have a look at http://www.scipy.org/Mlabwrap if you're interested in
the ongoing development of mlabwrap and planned features.


Feedback and support


The preferred formum for users to request help and offer feedback and keep
informed about new releases is mlabwrap-user:

 https://lists.sourceforge.net/lists/listinfo/mlabwrap-user

the list is low-volume and subscription is recommended.

Discussion of mlabwrap development takes place on the scipy-dev (please
mention mlabwrap in the subject line):

 http://projects.scipy.org/mailman/listinfo/scipy-dev 

cheers,

Alexander Schmolck, mlabwrap author and maintainer
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] detecting shared data

2007-04-11 Thread Matthew Koichi Grimes
Is there any way to detect whether one array is a view into another 
array? I'd like something like:

  arr = N.arange(5)
  subarr = arr[1:3]
  sharesdata(arr, subarr)
True

-- Matt
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] detecting shared data

2007-04-11 Thread Pierre GM
On Wednesday 11 April 2007 18:12:16 Matthew Koichi Grimes wrote:
 Is there any way to detect whether one array is a view into another

 array? I'd like something like:
   arr = N.arange(5)
   subarr = arr[1:3]
   sharesdata(arr, subarr)

Mmh, would arr.flags['OWNDATA'] would do the trick ?
p.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] detecting shared data

2007-04-11 Thread Stefan van der Walt
On Wed, Apr 11, 2007 at 06:12:16PM -0400, Matthew Koichi Grimes wrote:
 Is there any way to detect whether one array is a view into another 
 array? I'd like something like:
 
   arr = N.arange(5)
   subarr = arr[1:3]
   sharesdata(arr, subarr)
 True

Your best bet is probably

N.may_share_memory(arr,subarr)

Cheers
Stéfan
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] detecting shared data

2007-04-11 Thread Matthew Koichi Grimes
It's better than nothing. I basically want some sanity-check assert code 
that can assert that some arrays are in fact sub-arrays of another 
array. Your OWNDATA suggestion meets me halfway by allowing me to check 
that these sub-arrays are at least sub-arrays of *someone*.

Thanks,
-- Matt

Pierre GM wrote:
 On Wednesday 11 April 2007 18:12:16 Matthew Koichi Grimes wrote:
   
 Is there any way to detect whether one array is a view into another

 array? I'd like something like:
   arr = N.arange(5)
   subarr = arr[1:3]
   sharesdata(arr, subarr)
 

 Mmh, would arr.flags['OWNDATA'] would do the trick ?
 p.
   

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] detecting shared data

2007-04-11 Thread Bill Baxter
On 4/12/07, Matthew Koichi Grimes [EMAIL PROTECTED] wrote:
 It's better than nothing. I basically want some sanity-check assert code
 that can assert that some arrays are in fact sub-arrays of another
 array. Your OWNDATA suggestion meets me halfway by allowing me to check
 that these sub-arrays are at least sub-arrays of *someone*.

 Thanks,
 -- Matt

 Pierre GM wrote:
  On Wednesday 11 April 2007 18:12:16 Matthew Koichi Grimes wrote:
 
  Is there any way to detect whether one array is a view into another
 
  array? I'd like something like:
arr = N.arange(5)
subarr = arr[1:3]
sharesdata(arr, subarr)
 
 
  Mmh, would arr.flags['OWNDATA'] would do the trick ?
  p.

I wrote this a while back that may do what you want:


def same_array(a, b):
Tries to figure out if a and b are sharing (some of) the same
memory or not.
This is sometimes useful for determining if a copy was made as a
result of some
operation, or for determining if modifying a might also modify b.
A True result means that a and b both borrow memory from the same
array object,
but it does not necessarily mean the memory regions used overlap.
For example:
 x = rand(4,4)
 a,b = x[:2], x[2:]
 same_array(a,b)
True
A False result means the arrays definitely do not overlap in memory.
same_array(a, b) - Bool

ab = a
while ab.base is not None:
ab = ab.base
bb = b
while bb.base is not None:
bb = bb.base
return ab is bb

But maybe that's pretty much what may_share_memory does?
--bb
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] detecting shared data

2007-04-11 Thread Anne Archibald

On 11/04/07, Bill Baxter [EMAIL PROTECTED] wrote:


Must be pretty recent.  I'm using 1.0.2.dev3520 (enthought egg) and
the function's not there.


It is.

I've never been quite happy with it, though; I realize it's not very
feasible to write one that efficiently checks all possible overlaps,
but the current one claims (e.g.) a.real and a.imag may share memory,
which irks me. I put in a quick fix. Also, may_share_memory did not
have any tests (for shame!), so I put some of those in too. I wasn't
sure how to express expected failure, and they're not the most
thorough, but they should help.

Anne M. Archibald


share-patch
Description: Binary data
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion