Title: Custom operations over user defined types that creates new instance of userdefined type · Issue #564 · python-graphblas/python-graphblas · GitHub
Open Graph Title: Custom operations over user defined types that creates new instance of userdefined type · Issue #564 · python-graphblas/python-graphblas
X Title: Custom operations over user defined types that creates new instance of userdefined type · Issue #564 · python-graphblas/python-graphblas
Description: Is it possible to define custom operation that creates instances of user defined type? NP_UDT = np.dtype([("x", np.int64), ("y", np.float64)], align=True) UDT = gb.dtypes.register_new("UDT", NP_UDT) v1 = gb.Vector(Point, size=10) v1[0] =...
Open Graph Description: Is it possible to define custom operation that creates instances of user defined type? NP_UDT = np.dtype([("x", np.int64), ("y", np.float64)], align=True) UDT = gb.dtypes.register_new("UDT", NP_UDT...
X Description: Is it possible to define custom operation that creates instances of user defined type? NP_UDT = np.dtype([("x", np.int64), ("y", np.float64)], align=True) UDT = gb.dtypes.regist...
Opengraph URL: https://github.com/python-graphblas/python-graphblas/issues/564
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Custom operations over user defined types that creates new instance of userdefined type","articleBody":"Is it possible to define custom operation that creates instances of user defined type?\n\n```python\nNP_UDT = np.dtype([(\"x\", np.int64), (\"y\", np.float64)], align=True)\nUDT = gb.dtypes.register_new(\"UDT\", NP_UDT)\n\nv1 = gb.Vector(Point, size=10)\nv1[0] = (1, 4.5) # Tuple works here\n\n# I want to define a function that creates new UDT from int and float passed as parameters\ndef udt_add_op(x, y):\n # When I try to use tuple here (similarly to assignment to v1[0]) it fails with exception below.\n return ??? # What should be here to create new UDT(x,y) ?\n\nBinaryOp.register_new(\"udt_add\", udt_add_op,is_udt=True)\n\ndef v_add(v1, v2):\n gb.Vector.ewise_add(v1, v2, \"udt_add\")\n ...\n```\n\nException on attempt to return tuple from ```udt_add_op```:\n\n```\nTraceback (most recent call last):\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n File \"example.py\", line 24, in v_add\n v3 \u003c\u003c gb.Vector.ewise_add(v1, v2, \"points_add\")\n File \"/miniconda3/lib/python3.10/site-packages/graphblas/core/vector.py\", line 998, in ewise_add\n return self._ewise_add(other, op)\n File \"/miniconda3/lib/python3.10/site-packages/graphblas/core/vector.py\", line 1029, in _ewise_add\n op = get_typed_op(op, self.dtype, other.dtype, kind=\"binary\")\n File \"/miniconda3/lib/python3.10/site-packages/graphblas/core/operator/utils.py\", line 112, in get_typed_op\n return get_typed_op(\n File \"/miniconda3/lib/python3.10/site-packages/graphblas/core/operator/utils.py\", line 43, in get_typed_op\n return op._compile_udt(dtype, dtype2)\n File \"/miniconda3/lib/python3.10/site-packages/graphblas/core/operator/binary.py\", line 609, in _compile_udt\n ret_type = lookup_dtype(numba_func.overloads[sig].signature.return_type)\n File \"/miniconda3/lib/python3.10/site-packages/graphblas/core/dtypes.py\", line 374, in lookup_dtype\n raise ValueError(f\"Unknown dtype: {key} of type {type(key)}\")\nValueError: Unknown dtype: Tuple(Literal[int](1), float64) of type \u003cclass 'numba.core.types.containers.Tuple'\u003e\n```","author":{"url":"https://github.com/gsvgit","@type":"Person","name":"gsvgit"},"datePublished":"2025-09-23T14:34:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/564/python-graphblas/issues/564"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:61af5716-5beb-8eeb-6d3a-37423058bc3e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EB02:3A1BE:1BC3792:26256BE:698DC53D |
| html-safe-nonce | 1639c7d34fc99d0ad26405ef898856cb17b7182de06cbbd28b0b7c8f0fb43ced |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjAyOjNBMUJFOjFCQzM3OTI6MjYyNTZCRTo2OThEQzUzRCIsInZpc2l0b3JfaWQiOiI0NjE0MjY3ODk1NTk2ODIzNjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 67f9c2bc21a3ad47fce247bdf9f08c060fb501ab005849cb4c63e5e9a125d049 |
| hovercard-subject-tag | issue:3445556074 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-graphblas/python-graphblas/564/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9d3226cc57530f7664d064bbbcadb711bd611c04d0403f50772916e7dd052e38/python-graphblas/python-graphblas/issues/564 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9d3226cc57530f7664d064bbbcadb711bd611c04d0403f50772916e7dd052e38/python-graphblas/python-graphblas/issues/564 |
| og:image:alt | Is it possible to define custom operation that creates instances of user defined type? NP_UDT = np.dtype([("x", np.int64), ("y", np.float64)], align=True) UDT = gb.dtypes.register_new("UDT", NP_UDT... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gsvgit |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2457fd9a1b17ca7f38c3c2653895ccb2e0dd04f18f77446a21354e9bc4b7902f |
| turbo-cache-control | no-preview |
| go-import | github.com/python-graphblas/python-graphblas git https://github.com/python-graphblas/python-graphblas.git |
| octolytics-dimension-user_id | 103965858 |
| octolytics-dimension-user_login | python-graphblas |
| octolytics-dimension-repository_id | 221014819 |
| octolytics-dimension-repository_nwo | python-graphblas/python-graphblas |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 221014819 |
| octolytics-dimension-repository_network_root_nwo | python-graphblas/python-graphblas |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 878672b82363fd98fbdc5bd0edb68e572c8a8d9b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width