Skip to content

Inconsistent arguments in some helper functions #100

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

Closed
asmeurer opened this issue Feb 18, 2022 · 1 comment · Fixed by #120
Closed

Inconsistent arguments in some helper functions #100

asmeurer opened this issue Feb 18, 2022 · 1 comment · Fixed by #120
Assignees

Comments

@asmeurer
Copy link
Member

For example, in assert_dtype, the in_dtype is before out_dtype

def assert_dtype(
func_name: str,
in_dtype: Union[DataType, Sequence[DataType]],
out_dtype: DataType,
expected: Optional[DataType] = None,
*,
repr_name: str = "out.dtype",
):
in assert_keepdimable_shape the in_shape is after out_shape
def assert_keepdimable_shape(
func_name: str,
out_shape: Shape,
in_shape: Shape,
axes: Tuple[int, ...],
keepdims: bool,
/,
**kw,
):

By the way, it would be useful to have small docstrings for the various helper functions.

@honno
Copy link
Member

honno commented Feb 18, 2022

Ah this is a bit awkward, because say ph.assert_dtype() will always use in_dtype both for its error messages e.g. ... [func(uint8, int16)], and sometimes use it for inferring expected. In say ph.assert_keepdimable_shape(), in_shape is indeed always used as the "expected" to assert against.

Still yeah it'd be a good idea to to review the args order a bit, and definitely write some docs. I hadn't spent too much time on documenting utils because I end up removing half the ones I write anyway, but now would be a good time to regroup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants