google / edward2

A simple probabilistic programming language.
Apache License 2.0
679 stars 75 forks source link

Allow raise_error to be bool type and make return type more precise. #588

Closed copybara-service[bot] closed 6 months ago

copybara-service[bot] commented 6 months ago

Allow raise_error to be bool type and make return type more precise.

Prior to this CL, pytype raises an error on this:

from edward2 import maps
def my_custom_function() -> list[int]:
  return maps.robust_map(lambda x: x + 1, range(10))

Or this:

from edward2 import maps
def my_custom_function(raise_error: bool) -> Sequence[int]:
  return maps.robust_map(lambda x: x + 1, range(10), raise_error=raise_error)