[IronPython] Error with non-jagged array?

Keith J. Farmer kfarmer at thuban.org
Sat Apr 9 12:09:58 CEST 2005


Caveat:  I ran this using Mono, so I'm not sure if it's really a problem
with Mono, or a bug in IronPython.  It looks like there are some
problems with arrays, but someone with a Win32 version should check
this.

The following uses Mapack, downloadable from Lutz Roeder's site.

Intended usage from C# would be:

	Matrix A = new Matrix(3, 3);
	A[0,0] = 2.0; A[0,1] = 1.0; A[0,2] = 2.0;
	A[1,0] = 1.0; A[1,1] = 4.0; A[1,2] = 0.0;
	A[2,0] = 2.0; A[2,1] = 0.0; A[2,2] = 8.0;

----------
Keith J. Farmer
kfarmer at thuban.org
http://www.thuban.org

C:\Program Files\IronPython-0.7.1\bin>mono IronPythonConsole.exe
IronPython 0.7.1 on .NET 2.0.40607.16
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import sys
>>> sys.LoadAssemblyFromFile("C:\\Documents and
Settings\\kfarmer\\Desktop\\Mapack\\Build\\Mapack.dll")
>>> from Mapack import *
>>> m = Matrix.Random(3, 3)
>>> m
0.225364771776537 0.31672962862846 0.88264873478685
0.648747126408269 0.137992081762288 0.868301292354381
0.880461812895006 0.061446850682351 0.249342372757076

>>> m.Transpose()
0.225364771776537 0.648747126408269 0.880461812895006
0.31672962862846 0.137992081762288 0.061446850682351
0.88264873478685 0.868301292354381 0.249342372757076

>>> m[0,0]
System.Reflection.TargetParameterCountException: Number of parameter
does not match expected count.
in <0x00111> System.Reflection.Binder:ConvertArgs
(System.Reflection.Binder,object[],System.Reflection.ParameterInfo[],Sys
tem.Globalization.CultureInfo)
in <0x00040> System.Reflection.MonoMethod:Invoke
(object,System.Reflection.BindingFlags,System.Reflection.Binder,object[]
,System.Globalization.CultureInfo)
in <0x00060> System.Reflection.MonoProperty:GetValue
(object,System.Reflection.BindingFlags,System.Reflection.Binder,object[]
,System.Globalization.CultureInfo)
in <0x00017> System.Reflection.PropertyInfo:GetValue (object,object[])
in <0x00070> IronPython.Objects.PythonType:__getitem__ (object,object)
in <0x002ca> IronPython.Objects.Ops:GetIndex (object,object)
in <0x000a4> input_7:Run (IronPython.Objects.Frame)
in <0x0023f> IronPython.Hosting.PythonEngine:DoOneInteractive
(IronPython.Objects.Frame)
in <0x0003f> IronPython.Hosting.PythonEngine:RunInteractive ()

>>> m[0][0]
System.Reflection.TargetParameterCountException: Number of parameter
does not match expected count.
in <0x00111> System.Reflection.Binder:ConvertArgs
(System.Reflection.Binder,object[],System.Reflection.ParameterInfo[],Sys
tem.Globalization.CultureInfo)
in <0x00040> System.Reflection.MonoMethod:Invoke
(object,System.Reflection.BindingFlags,System.Reflection.Binder,object[]
,System.Globalization.CultureInfo)
in <0x00060> System.Reflection.MonoProperty:GetValue
(object,System.Reflection.BindingFlags,System.Reflection.Binder,object[]
,System.Globalization.CultureInfo)
in <0x00017> System.Reflection.PropertyInfo:GetValue (object,object[])
in <0x00070> IronPython.Objects.PythonType:__getitem__ (object,object)
in <0x002ca> IronPython.Objects.Ops:GetIndex (object,object)
in <0x00051> input_8:Run (IronPython.Objects.Frame)
in <0x0023f> IronPython.Hosting.PythonEngine:DoOneInteractive
(IronPython.Objects.Frame)
in <0x0003f> IronPython.Hosting.PythonEngine:RunInteractive ()

>>> m.__dict__
{'Trace': <property# Trace on Matrix>, 'Submatrix': <method# Submatrix
on Mapack.Matrix>, 'GetHashCode': <method# GetHashCode on
System.Object>, 'Diagonal': <method# Diagonal on Mapack.Matrix>,
'Random': <method# Random on Mapack.Matrix>, 'IsSquare': <property#
IsSquare on Matrix>, 'Item': <property# Item on Matrix>, 'Inverse':
<property# Inverse on Matrix>, 'Norm1': <property# Norm1 on Matrix>,
'IsSymmetric': <property# IsSymmetric on Matrix>, 'InfinityNorm':
<property# InfinityNorm on Matrix>, 'Transpose': <method# Transpose on
Mapack.Matrix>, 'ToString': <method# ToString on Mapack.Matrix>, 'Rows':
<property# Rows on Matrix>, '__new__': <method Mapack.Matrix.__new__>,
'GetType': <method# GetType on System.Object>, '__repr__': <built-in
function ReprMethod>, 'FrobeniusNorm': <property# FrobeniusNorm on
Matrix>, 'Solve': <method# Solve on Mapack.Matrix>, 'Columns':
<property# Columns on Matrix>, 'Determinant': <property# Determinant on
Matrix>,'Clone': <method# Clone on Mapack.Matrix>, 'Equals': <method#
Equals on System.Object>}
>>>



More information about the Ironpython-users mailing list