sbi-dev / sbi

Simulation-based inference toolkit
https://sbi-dev.github.io/sbi/
Apache License 2.0
546 stars 133 forks source link

Pyright failing on main in pyro flows #1162

Closed janfb closed 3 weeks ago

janfb commented 1 month ago

image

Problem 1: https://github.com/sbi-dev/sbi/blob/7900af0e1f70b394e5bb85cfe706c176325be650/sbi/samplers/vi/vi_pyro_flows.py#L193-L203

Problem 2: https://github.com/sbi-dev/sbi/blob/7900af0e1f70b394e5bb85cfe706c176325be650/sbi/utils/pyroutils.py#L30-L32

@manuelgloeckler any idea why this appears now?

manuelgloeckler commented 3 weeks ago

I am not able to reproduce these errors locally (but some others) in Python 3.11.7. Will check python 3.8.

Edit, here are my local pyright outputs:

0 errors, 0 warnings, 0 informations

- Python 3.10.13 / 3.11.7

/root/sbi/sbi/analysis/plot.py /root/sbi/sbi/analysis/plot.py:184:16 - error: Argument of type "tuple[Tensor, Tensor, Tensor, Tensor]" cannot be assigned to parameter "extent" of type "tuple[float, float, float, float] | None" in function "imshow" Type "tuple[Tensor, Tensor, Tensor, Tensor]" cannot be assigned to type "tuple[float, float, float, float] | None" "tuple[Tensor, Tensor, Tensor, Tensor]" is incompatible with "tuple[float, float, float, float]" Tuple entry 1 is incorrect type "Tensor" is incompatible with "float" "tuple[Tensor, Tensor, Tensor, Tensor]" is incompatible with "None" (reportArgumentType) /root/sbi/sbi/analysis/plot.py:394:21 - error: Argument of type "tuple[Unknown | Tensor, Unknown | Tensor]" cannot be assigned to parameter "left" of type "float | tuple[float, float] | None" in function "set_xlim" Type "tuple[Unknown | Tensor, Unknown | Tensor]" cannot be assigned to type "float | tuple[float, float] | None" "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "float" "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "tuple[float, float]" Tuple entry 1 is incorrect type Type "Unknown | Tensor" cannot be assigned to type "float" "Tensor" is incompatible with "float" "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "None" (reportArgumentType) /root/sbi/sbi/analysis/plot.py:397:21 - error: Argument of type "tuple[Unknown | Tensor, Unknown | Tensor]" cannot be assigned to parameter "bottom" of type "float | tuple[float, float] | None" in function "set_ylim" Type "tuple[Unknown | Tensor, Unknown | Tensor]" cannot be assigned to type "float | tuple[float, float] | None" "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "float" "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "tuple[float, float]" Tuple entry 1 is incorrect type Type "Unknown | Tensor" cannot be assigned to type "float" "Tensor" is incompatible with "float" "tuple[Unknown | Tensor, Unknown | Tensor]" is incompatible with "None" (reportArgumentType) /root/sbi/sbi/analysis/plot.py:1975:19 - error: No overloads for "delete" match the provided arguments (reportCallIssue) /root/sbi/sbi/analysis/plot.py:1975:29 - error: Argument of type "BarContainer | Polygon | list[BarContainer | Polygon]" cannot be assigned to parameter "arr" of type "ArrayLike" in function "delete" (reportArgumentType) 5 errors, 0 warnings, 0 informations



So, it seems to be some GitHub workflow environment-specific problem ...
manuelgloeckler commented 3 weeks ago

Okay, I fixed it in #1165. In the end it was: