Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Loosely assert for functions that produce ints but internally might use floats

Open
#154 8 comments 0 reactions 1 assignee View on GitHub

@honno is already working on this.

Since Nov 1, 2022.

Assessment

This issue has not been assessed yet.

Description

It looks like the test_trunc reference implementation is math.trunc for at least a subset of the checks. I noticed that for some large values there is a mismatch with both the pykokkos (ultimately C++) version of trunc and math.trunc, which causes the conformance test to fail. I see the same thing in NumPy as well--do you have a suggestion on how I should proceed here? Is this effectively related to arbitrary precision Python integers, etc.?

I'll just use NumPy rather than pykokkos below, to keep things familiar:

>>> import math
>>> import numpy as np
>>> math.trunc(9007199254740993)
9007199254740993
>>> np.trunc(9007199254740993)
9007199254740992.0

And then in the conformance testing: pytest array_api_tests/test_operators_and_elementwise_functions.py::test_trunc

AssertionError: out[0]=9007199254740992, but should be trunc(x[0])=9007199254740993 [trunc()]

Would you say that my reference implementation in pykokkos and the exposed NumPy trunc are both wrong here, and the test suite is correct or?

Dominant language
Python
Stars
74
Forks
54
Avg merge
4h 35m
Merged PRs (30d)
4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from data-apis/array-api-tests

All issues in data-apis/array-api-tests

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.