{"record":{"id":"8d9b0fd44b90cb0c","repo":"keras-team/keras","slug":"x-and-weights-must-both-be-bcoos","errorCode":null,"errorMessage":"`x` and `weights` must both be BCOOs","messagePattern":"`x` and `weights` must both be BCOOs","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/jax/numpy.py","lineNumber":93,"sourceCode":"def hypot(x1, x2):\n    x1 = convert_to_tensor(x1)\n    x2 = convert_to_tensor(x2)\n    return jnp.hypot(x1, x2)\n\n\ndef kaiser(x, beta):\n    x = convert_to_tensor(x)\n    return cast(jnp.kaiser(x, beta), config.floatx())\n\n\ndef bincount(x, weights=None, minlength=0, sparse=False):\n    # Note: bincount is never traceable / jittable because the output shape\n    # depends on the values in x.\n    if sparse or isinstance(x, jax_sparse.BCOO):\n        if isinstance(x, jax_sparse.BCOO):\n            if weights is not None:\n                if not isinstance(weights, jax_sparse.BCOO):\n                    raise ValueError(\"`x` and `weights` must both be BCOOs\")\n                if x.indices is not weights.indices:\n                    # This test works in eager mode only\n                    if not jnp.all(jnp.equal(x.indices, weights.indices)):\n                        raise ValueError(\n                            \"`x` and `weights` BCOOs must have the same indices\"\n                        )\n                weights = weights.data\n            x = x.data\n        reduction_axis = 1 if len(x.shape) > 1 else 0\n        maxlength = jnp.maximum(jnp.max(x) + 1, minlength)\n        one_hot_encoding = nn.one_hot(x, maxlength, sparse=True)\n        if weights is not None:\n            expanded_weights = jnp.expand_dims(weights, reduction_axis + 1)\n            one_hot_encoding = one_hot_encoding * expanded_weights\n\n        outputs = jax_sparse.bcoo_reduce_sum(\n            one_hot_encoding,\n            axes=(reduction_axis,),","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/jax/numpy.py#L75-L111","documentation":"Error \"`x` and `weights` must both be BCOOs\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/jax/numpy.py:93 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}