Skip to content
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

[CPU/GPU] prod kernel on an empty list of a complex type gives a wrong result #3236

Open
ianna opened this issue Sep 12, 2024 · 0 comments
Open
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged

Comments

@ianna
Copy link
Collaborator

ianna commented Sep 12, 2024

Version of Awkward Array

master branch (2.6.7)

Description and code to reproduce

def test_block_boundary_prod_complex13():
    rng = np.random.default_rng(seed=42)
    array = rng.integers(50, size=1000)
    complex_array = np.vectorize(complex)(
        array[0 : len(array) : 2], array[1 : len(array) : 2]
    )
    content = ak.contents.NumpyArray(complex_array)
    
    assert np.allclose(to_list(ak.prod(content, -1, highlevel=False)), np.prod(ak.Array(content)), equal_nan=True)

    offsets = ak.index.Index64(np.array([0, 5, 996, 1000], dtype=np.int64))
    depth1 = ak.contents.ListOffsetArray(offsets, content)
    print(to_list(ak.prod(depth1, -1, highlevel=False))) 
    print([np.prod(ak.Array(depth1[0])), np.prod(ak.Array(depth1[1])), np.prod(ak.Array(depth1[2]))])

where ak.Array(depth1[2]) has ArrayType(NumpyType('complex128'), 0, None). The ak.prod result of an empty list should be (1+0j), as correctly produced by Numpy:

[(6891360-24365880j), (nan+nanj), 0j]
[(6891360-24365880j), (nan+nanj), (1+0j)]

@ianna ianna added the bug (unverified) The problem described would be a bug, but needs to be triaged label Sep 12, 2024
@ianna ianna changed the title [CPU/GPU] prod kernel on empty complex type lists give wrong result [CPU/GPU] prod kernel on empty complex type lists gives wrong result Sep 12, 2024
@ianna ianna changed the title [CPU/GPU] prod kernel on empty complex type lists gives wrong result [CPU/GPU] prod kernel on an empty list of a complex type lists gives a wrong result Sep 12, 2024
@ianna ianna changed the title [CPU/GPU] prod kernel on an empty list of a complex type lists gives a wrong result [CPU/GPU] prod kernel on an empty list of a complex type gives a wrong result Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant