Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map() fails on Array[str] #1666

Closed
Mt-SQ opened this issue Mar 8, 2023 · 3 comments
Closed

map() fails on Array[str] #1666

Mt-SQ opened this issue Mar 8, 2023 · 3 comments

Comments

@Mt-SQ
Copy link

Mt-SQ commented Mar 8, 2023

Description

List[str] works but Array[str] fails.

IronPython 3.4.0 (3.4.0.1000)
[.NETFramework,Version=v4.6.2 on .NET Framework 4.8.9139.0 (64-bit)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from System.Collections.Generic import List
>>> list(map(str, List[int]([1, 3, 5, 7, 9])))
['1', '3', '5', '7', '9']
>>> list(map(int, List[str](['1', '3', '5', '7', '9'])))
[1, 3, 5, 7, 9]
>>> from System import Array
>>> list(map(str, Array[int]([1, 3, 5, 7, 9])))
['1', '3', '5', '7', '9']
>>> list(map(int, Array[str](['1', '3', '5', '7', '9'])))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: int() takes at most 3 arguments (6 given)

IronPython 2.7 works as expected.

IronPython 2.7.12 (2.7.12.1000)
[.NETFramework,Version=v4.5 on .NET Framework 4.8.9139.0 (64-bit)]
Type "help", "copyright", "credits" or "license" for more information.
>>> from System import Array
>>> list(map(str, Array[int]([1, 3, 5, 7, 9])))
['1', '3', '5', '7', '9']
>>> list(map(int, Array[str](['1', '3', '5', '7', '9'])))
[1, 3, 5, 7, 9]
@slozier
Copy link
Contributor

slozier commented Mar 10, 2023

Thanks for the report! Looks like it's binding the Array[str] argument directly to the params object[]. There are probably other places that have the same issue (e.g. zip).

@Mt-SQ
Copy link
Author

Mt-SQ commented Mar 10, 2023

Thank you for your confirmation.
I will add the verification results.

IronPython 3.4.0 (3.4.0.1000)
[.NETFramework,Version=v4.6.2 on .NET Framework 4.8.9139.0 (64-bit)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from System import Array, Char
>>> list(zip(range(5), Array[str](['1', '3', '5', '7', '9'])))
[(0, '1'), (1, '3'), (2, '5'), (3, '7'), (4, '9')]
>>> list(filter(lambda s: int(s) <= 5, Array[str](['1', '3', '5', '7', '9'])))
['1', '3', '5']
>>> list(map(int.Parse, Array[Char](['1', '3', '5', '7', '9'])))
[1, 3, 5, 7, 9]
>>> list(map(int.Parse, Array[str](['1', '3', '5', '7', '9'])))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Parse() takes at most 3 arguments (5 given)

@slozier
Copy link
Contributor

slozier commented Jun 23, 2023

Going to close this since it looks like the same issue as #892. As for reproducing with zip:

data = ['1','2','3','4']
assert list(zip(System.Array[System.String](data))) == list(zip(data))

@slozier slozier closed this as completed Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants