Skip to content

incorrect results with uint scalars #2508

Closed

Description

@stress-tess

I discovered this while working #2505, we aren't correctly handing uint scalars.

Our tests are catching this because I didn't choose the value of the uint scalar very well, so it's being treated as an integer

scalars = {"int64": 5, "uint64": np.uint64(5), "float64": 3.14159, "bool": True}

if we update this to have "uint64": np.uint64(2**63 + 1), we start seeing these incorrect results.

Before updating the test:

# ops not implemented by numpy or arkouda: 114
# ops implemented by numpy but not arkouda: 135
# ops implemented by arkouda but not numpy: 4
# ops implemented by both: 611
  Matching results:         611 / 611
  Arkouda execution errors: 0 / 611

  Dtype mismatches:         0 / 611

  Value mismatches:         0 / 611

After updating the test:

# ops not implemented by numpy or arkouda: 122
# ops implemented by numpy but not arkouda: 147
# ops implemented by arkouda but not numpy: 6
# ops implemented by both: 589
  Matching results:         586 / 589
  Arkouda execution errors: 0 / 589

  Dtype mismatches:         2 / 589
int64(array) + uint64(scalar): float64(np) vs. int64(ak)
int64(array) - uint64(scalar): float64(np) vs. int64(ak)
  Value mismatches:         1 / 589
uint64(scalar) % float64(array): np: [           nan 2.84217094e-14 2.84217094e-14 2.84217094e-14
 2.84217094e-14 6.22222222e-01 2.84217094e-14 7.30158730e-01
 2.84217094e-14 0.00000000e+00]
ak: [nan  0.  0.  0.  0.  0.  0.  0.  0.  0.]

So we some combinations involving uint scalars that have appeared to be working, but are actually incorrect.

I found this by running ak.arange(10) + np.uint(2**63 + 1). We should return a float array to match numpy but we aren't. The updated tests shows this int64(array) + uint64(scalar): float64(np) vs. int64(ak)

We also have some operations that we thought supported uint scalars, but don't. We can see that by the number of ops implemented by numpy but not arkouda increasing

Fiinally we see there's a value mismatch with uint scalar % float array

Activity

  1. added
    bug
    on Jun 15, 2023
  2. self-assigned this
    on Jun 15, 2023
  3. stress-tess commented on Jun 21, 2023

    @stress-tess
    MemberAuthor

    updating the uint arrays to have better examples as well we see more mismatches

    global pdarrays
    pdarrays = {
        "int64": ak.arange(0, SIZE, 1),
        "uint64": ak.array(np.arange(2**64 - SIZE, 2**64, 1, dtype=np.uint64)),
        "float64": ak.linspace(0, 2, SIZE),
        "bool": (ak.arange(0, SIZE, 1) % 2) == 0,
    }
    global ndarrays
    ndarrays = {
        "int64": np.arange(0, SIZE, 1),
        "uint64": np.arange(2**64 - SIZE, 2**64, 1, dtype=np.uint64),
        "float64": np.linspace(0, 2, SIZE),
        "bool": (np.arange(0, SIZE, 1) % 2) == 0,
    }
    # ops implemented by both: 589
      Matching results:         584 / 589
      Arkouda execution errors: 0 / 589
    
      Dtype mismatches:         2 / 589
    int64(array) - uint64(scalar): float64(np) vs. int64(ak)
    int64(array) + uint64(scalar): float64(np) vs. int64(ak)
      Value mismatches:         3 / 589
    uint64(array) % float64(array): np: [           nan 5.68434189e-14 5.68434189e-14 5.68434189e-14
     5.68434189e-14 1.33333333e-01 5.68434189e-14 1.46031746e+00
     5.68434189e-14 0.00000000e+00]
    ak: [nan  0.  0.  0.  0.  0.  0.  0.  0.  0.]
    uint64(array) % float64(scalar): np: [1.19112358 1.19112358 1.19112358 1.19112358 1.19112358 1.19112358
     1.19112358 1.19112358 1.19112358 1.19112358]
    ak: [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
    uint64(scalar) % float64(array): np: [           nan 2.84217094e-14 2.84217094e-14 2.84217094e-14
     2.84217094e-14 6.22222222e-01 2.84217094e-14 7.30158730e-01
     2.84217094e-14 0.00000000e+00]
    ak: [nan  0.  0.  0.  0.  0.  0.  0.  0.  0.]
    
  4. added 3 commits that reference this issue on Jun 21, 2023
    afb15a6
    39405b8
    f7096fc
  5. added a commit that references this issue on Jun 29, 2023
    49763d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions