JuliaPy / JuliaPy/PythonCall.jl

Julia objects are falsely marked as subtypes of most Python abstract base classes.

オープン
#390 コメント 8 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Julia
スター
1.1k
フォーク
86
平均マージ
1日 22時間
マージ済み PR(30日)
3

説明

**Affects:** JuliaCall

**Describe the bug**

An example of this that I ran into is that everything is reported as itterable, even when it cannot be iterated.

This looks pretty bad on the surface:
```pycon
>>> import collections
>>> isinstance([1,2,3], collections.abc.Iterable)
True
>>> isinstance(1, collections.abc.Iterable)
False
>>> isinstance(sum, collections.abc.Iterable)
False
>>> f = jl.seval("f(x) = x+1")
>>> isinstance(f, collections.abc.Iterable)
True
>>> s = jl.seval(":a")
>>> isinstance(s, collections.abc.Iterable)
True
>>> f
Julia: f (generic function with 1 method)
>>> s
Julia: :a
```

And indeed it causes bugs when passing non-iterable Julia objects to Python functions which check for iterability and then, if iterable, iterate. For example, this function in PyTorch:

https://github.com/pytorch/pytorch/blob/185e76238d9f634c9c8d6fc6be75aa4fc71e04d3/torch/autograd/gradcheck.py#L78-L87

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。