Title: Consider additional adapt Ops between FunctionalTypes · Issue #47 · scijava/scijava · GitHub
Open Graph Title: Consider additional adapt Ops between FunctionalTypes · Issue #47 · scijava/scijava
X Title: Consider additional adapt Ops between FunctionalTypes · Issue #47 · scijava/scijava
Description: Currently scijava-ops has support for the following adaptations: Computers to Functions Functions to Computers Inplaces to Functions @ctrueden and I have discussed (several times) why the other three conversions have not been implemented...
Open Graph Description: Currently scijava-ops has support for the following adaptations: Computers to Functions Functions to Computers Inplaces to Functions @ctrueden and I have discussed (several times) why the other thr...
X Description: Currently scijava-ops has support for the following adaptations: Computers to Functions Functions to Computers Inplaces to Functions @ctrueden and I have discussed (several times) why the other thr...
Opengraph URL: https://github.com/scijava/scijava/issues/47
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Consider additional adapt Ops between FunctionalTypes","articleBody":"Currently scijava-ops has support for the following `adapt`ations:\r\n* `Computer`s to `Function`s\r\n* `Function`s to `Computer`s\r\n* `Inplace`s to `Function`s\r\n\r\n@ctrueden and I have discussed (*several* times) why the other three conversions have not been implemented. I think it a good idea to put the discussion here for posterity (and because I found myself again asking why we do not have these):\r\n\r\n* `Computer` to `Inplace`: Suppose we have a `double[]` and want to mutate this array with `math.sqrt`. Such a converter might look like\r\n```java\r\n@Plugin(type = Op.class, name = \"adapt\")\r\npublic class CompToInplaceAdaptor implements Function\u003cComputers.Arity1\u003cIO, IO\u003e, Inplaces.Arity1\u003cIO\u003e\u003e {\r\n\r\n @OpDependency(name = \"copy\")\r\n private Function\u003cIO, IO\u003e copyOp;\r\n\r\n public Inplaces.Arity1\u003cIO\u003e apply (final Computers.Arity1\u003cIO, IO\u003e computer) {\r\n return (io) -\u003e {\r\n IO copy = copyOp.apply(io);\r\n computer.compute(copy, io);\r\n };\r\n }\r\n};\r\n```\r\n\r\n* `Inplace` to `Function`: I cannot really think of a use case for this, but the general idea is that the user expects an output to be generated for them, and that their input will not be modified:\r\n```java\r\n@Plugin(type = Op.class, name = \"adapt\")\r\npublic class InplaceToFunctionAdaptor implements Function\u003cInplaces.Arity1\u003cIO\u003e, Function\u003cIO, IO\u003e\u003e {\r\n\r\n @OpDependency(name = \"copy\")\r\n private Function\u003cIO, IO\u003e copyOp;\r\n\r\n public Function\u003cIO, IO\u003e apply (final Inplaces.Arity1\u003cIO\u003e inplace) {\r\n return (in ) -\u003e {\r\n IO copy = copyOp.apply(io);\r\n inplace.mutate(copy);\r\n return copy;\r\n };\r\n }\r\n};\r\n```\r\n\r\n* `Inplace` to `Computer`: I cannot really think of a use case for this, but the general idea is that the user expects the output of the Op to be placed in their preallocated output, and that their input will not be modified:\r\n```java\r\n@Plugin(type = Op.class, name = \"adapt\")\r\npublic class InplaceToComputerAdaptor implements Function\u003cInplaces.Arity1\u003cIO\u003e, Computers.Arity1\u003cIO, IO\u003e\u003e {\r\n\r\n @OpDependency(name = \"copy\")\r\n private Computers.Arity1\u003cIO, IO\u003e copyOp;\r\n\r\n public Computers.Arity1\u003cIO, IO\u003e apply (final Inplaces.Arity1\u003cIO\u003e inplace) {\r\n return (in, out) -\u003e {\r\n copyOp.compute(in, out);\r\n inplace.mutate(out);\r\n };\r\n }\r\n};\r\n```","author":{"url":"https://github.com/gselzer","@type":"Person","name":"gselzer"},"datePublished":"2020-07-01T13:58:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/47/scijava/issues/47"}
| 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:259982df-0407-3586-fa20-6a02a64daab5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ABBE:2C3E22:198B18A:21093CA:696B2F68 |
| html-safe-nonce | c07ca96c8414e64c35d03a022886acc57d52545c0b24163dcdaeab424acc5855 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQkJFOjJDM0UyMjoxOThCMThBOjIxMDkzQ0E6Njk2QjJGNjgiLCJ2aXNpdG9yX2lkIjoiNDcwNzMzNDgxMTc2Njc0MTUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1db1007d9e6575aa282a0d7a8cab7f0995cb4c7261e4ff0905ad1dbfc5e2a38b |
| hovercard-subject-tag | issue:649004948 |
| 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/scijava/scijava/47/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5d50f29217367f2a77f2496fdbe60890aedcad6989f2d670fff00e60f2fe8554/scijava/scijava/issues/47 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5d50f29217367f2a77f2496fdbe60890aedcad6989f2d670fff00e60f2fe8554/scijava/scijava/issues/47 |
| og:image:alt | Currently scijava-ops has support for the following adaptations: Computers to Functions Functions to Computers Inplaces to Functions @ctrueden and I have discussed (several times) why the other thr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gselzer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/scijava/scijava git https://github.com/scijava/scijava.git |
| octolytics-dimension-user_id | 1262770 |
| octolytics-dimension-user_login | scijava |
| octolytics-dimension-repository_id | 85618439 |
| octolytics-dimension-repository_nwo | scijava/scijava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 85618439 |
| octolytics-dimension-repository_network_root_nwo | scijava/scijava |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width