Folks,

 

I defined a C++/CLI IEnumerator<KeyValuePair<int, double> > class (a sparse matrix class).

 

When I use it in a comprehension(see below) IP seems to "automatically" return only the value part of the KeyValuePair.

 

 

IronPython 1.0.2302 (Beta) on .NET 2.0.50727.40

Copyright (c) Microsoft Corporation. All rights reserved.

>>> import ShoNS

>>> sss = ShoNS.Array.SparseArray(1000, 1000, 1000)

>>> sss[100, 10] = 1

>>> sss[2, 10] = 2

 

## Test the IEnumerator directly ##

>>> eee = sss.ColumnElements(10)

>>> eee.MoveNext()

True

>>> eee.Current

[100, 1]

## Type is right!! ##

>>> type(eee.Current)

<type 'KeyValuePair`2'>

 

## Strange that this does not work ###

>>> [s for s in sss.ColumnElements(10)]

[1.0, 2.0]

 

## Even worse, this is a bug!!!  ##

>>> for s in sss.ColumnElements(10): print s.Key, "->", s.Value

...

Traceback (most recent call last):

  File , line 0, in input##203

AttributeError: 'float' object has no attribute 'Key'

>>> 

 

 

 

 

Thanks,

Paul Viola

Senior Researcher

Microsoft Research

 

_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to