Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## [Jython-users] jython and multidimentional arrays

 [Jython-users] jython and multidimentional arrays From: Rune Braathen - 2002-05-21 22:41:17 ```Gabriella Turek writes: > What is the equivalent of > int LENGTH = 32; > float[][] x_vals = new float[1][LENGTH]; > float[][] y_vals = new float[1][LENGTH]; > > in jython? I am trying to replicate in jython some code that displays an > x,y plot using VISAD. The plotting routines require a float[][] as input. > I am new at jython, and I can't figure this out. > Thanx in advance for your help. If you want to do things in a more neat manner (which probably is why you are using Jython in the first place), you can actually pass a nested list as arguments to java methods taking a 2-dimensional array as parameter, like so: Java method: public class SomeClass { public static void foo( float _arg[][]) { ... } } Jython code: from SomeClass import foo foo( [[2,3,4],[5,6,7]] ) Just make sure your lists contain values that in some manner can be coerced into a float, and you should be ok. -- runeb ```

 [Jython-users] jython and multidimentional arrays From: Gabriella Turek - 2002-05-21 21:45:02 ```What is the equivalent of int LENGTH = 32; float[][] x_vals = new float[1][LENGTH]; float[][] y_vals = new float[1][LENGTH]; in jython? I am trying to replicate in jython some code that displays an x,y plot using VISAD. The plotting routines require a float[][] as input. I am new at jython, and I can't figure this out. Thanx in advance for your help. Gaby -- ************************************************************************* Gabriella Turek | gaby@... | http://www.chimere.org Sr. Applications Developer - IPAC/SSC/NHSC ************************************************************************* ** Listening to music is listening to all noise, realising that its ** ** appropriation and control is a reflection of power - Jacques Attali ** ************************************************************************* ```
 Re: [Jython-users] jython and multidimentional arrays From: Jeff Emanuel - 2002-05-21 22:22:30 ```import java a = java.lang.reflect.Array.newInstance(java.lang.Float.TYPE,[n1,n2]) Gabriella Turek wrote: > What is the equivalent of > int LENGTH = 32; > float[][] x_vals = new float[1][LENGTH]; > float[][] y_vals = new float[1][LENGTH]; > > in jython? I am trying to replicate in jython some code that displays an > x,y plot using VISAD. The plotting routines require a float[][] as input. > I am new at jython, and I can't figure this out. > Thanx in advance for your help. > Gaby > > ```
 [Jython-users] jython and multidimentional arrays From: Rune Braathen - 2002-05-21 22:41:17 ```Gabriella Turek writes: > What is the equivalent of > int LENGTH = 32; > float[][] x_vals = new float[1][LENGTH]; > float[][] y_vals = new float[1][LENGTH]; > > in jython? I am trying to replicate in jython some code that displays an > x,y plot using VISAD. The plotting routines require a float[][] as input. > I am new at jython, and I can't figure this out. > Thanx in advance for your help. If you want to do things in a more neat manner (which probably is why you are using Jython in the first place), you can actually pass a nested list as arguments to java methods taking a 2-dimensional array as parameter, like so: Java method: public class SomeClass { public static void foo( float _arg[][]) { ... } } Jython code: from SomeClass import foo foo( [[2,3,4],[5,6,7]] ) Just make sure your lists contain values that in some manner can be coerced into a float, and you should be ok. -- runeb ```