{"action":"created","comment":{"url":"https://api.github.com/repos/odlgroup/odl/pulls/comments/132794258","pull_request_review_id":55919003,"id":132794258,"diff_hunk":"@@ -686,65 +675,430 @@ def __setitem__(self, indices, values):\n             shape is allowed as ``values``.\n         \"\"\"\n         if values in self.space:\n-            # For DiscretizedSetElement of the same type, use ntuple directly\n-            self.ntuple[indices] = values.ntuple\n+            self.tensor[indices] = values.tensor\n         else:\n-            # Other sequence types are piped through a Numpy array. Equivalent\n-            # views are optimized for in Numpy.\n-            if indices == slice(None):\n-                values = np.atleast_1d(values)\n-                if (values.ndim > 1 and\n-                        values.shape != self.space.shape):\n-                    raise ValueError('shape {} of value array {} not equal '\n-                                     'to sampling grid shape {}'\n-                                     ''.format(values.shape, values,\n-                                               self.space.shape))\n-                values = values.ravel(order=self.space.order)\n-\n             super().__setitem__(indices, values)\n \n-    @property\n-    def ufuncs(self):\n-        \"\"\"`DiscreteLpUfuncs`, access to numpy style ufuncs.\n+    def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):\n+        \"\"\"Interface to Numpy's ufunc machinery.\n+\n+        This method is called by Numpy version 1.13 and higher as a single\n+        point for the ufunc dispatch logic. An object implementing\n+        ``__array_ufunc__`` takes over control when a `numpy.ufunc` is\n+        called on it, allowing it to use custom implementations and\n+        output types.\n+\n+        This includes handling of in-place arithmetic like\n+        ``npy_array += custom_obj``. In this case, the custom object's\n+        ``__array_ufunc__`` takes precedence over the baseline\n+        `numpy.ndarray` implementation. It will be called with\n+        ``npy_array`` as ``out`` argument, which ensures that the\n+        returned object is a Numpy array. For this to work properly,\n+        ``__array_ufunc__`` has to accept Numpy arrays as ``out`` arguments.\n+\n+        See the `corresponding NEP`_ and the `interface documentation`_\n+        for further details. See also the `general documentation on\n+        Numpy ufuncs`_.\n+\n+        .. note::\n+            This basic implementation casts inputs and\n+            outputs to Numpy arrays and evaluates ``ufunc`` on those.\n+            For `numpy.ndarray` based data storage, this incurs no\n+            significant overhead compared to direct usage of Numpy arrays.\n+\n+            For other (in particular non-local) implementations, e.g.,\n+            GPU arrays or distributed memory, overhead is significant due\n+            to copies to CPU main memory. In those classes, the\n+            ``__array_ufunc__`` mechanism should be overridden to use\n+            native implementations if possible.\n+\n+        .. note::\n+            When using operations that alter the shape (like ``reduce``),\n+            or the data type (can be any of the methods),\n+            the resulting array is wrapped in a space of the same\n+            type as ``self.space``, however **only** using the minimal\n+            set of parameters ``size`` and ``dtype``. If more properties\n+            are supposed to be propagated, this method must be overridden.","path":"odl/discr/lp_discr.py","position":701,"original_position":701,"commit_id":"6bf4c34292730a7dfb460fcfa26a25823cbaef2d","original_commit_id":"6bf4c34292730a7dfb460fcfa26a25823cbaef2d","user":{"login":"kohr-h","id":5030250,"avatar_url":"https://avatars2.githubusercontent.com/u/5030250?v=4","gravatar_id":"","url":"https://api.github.com/users/kohr-h","html_url":"https://github.com/kohr-h","followers_url":"https://api.github.com/users/kohr-h/followers","following_url":"https://api.github.com/users/kohr-h/following{/other_user}","gists_url":"https://api.github.com/users/kohr-h/gists{/gist_id}","starred_url":"https://api.github.com/users/kohr-h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohr-h/subscriptions","organizations_url":"https://api.github.com/users/kohr-h/orgs","repos_url":"https://api.github.com/users/kohr-h/repos","events_url":"https://api.github.com/users/kohr-h/events{/privacy}","received_events_url":"https://api.github.com/users/kohr-h/received_events","type":"User","site_admin":false},"body":"Needs update","created_at":"2017-08-11T22:21:17Z","updated_at":"2017-08-11T22:21:18Z","html_url":"https://github.com/odlgroup/odl/pull/1088#discussion_r132794258","pull_request_url":"https://api.github.com/repos/odlgroup/odl/pulls/1088","_links":{"self":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/comments/132794258"},"html":{"href":"https://github.com/odlgroup/odl/pull/1088#discussion_r132794258"},"pull_request":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/1088"}}},"pull_request":{"url":"https://api.github.com/repos/odlgroup/odl/pulls/1088","id":135290027,"html_url":"https://github.com/odlgroup/odl/pull/1088","diff_url":"https://github.com/odlgroup/odl/pull/1088.diff","patch_url":"https://github.com/odlgroup/odl/pull/1088.patch","issue_url":"https://api.github.com/repos/odlgroup/odl/issues/1088","number":1088,"state":"open","locked":false,"title":"CPU tensors","user":{"login":"kohr-h","id":5030250,"avatar_url":"https://avatars2.githubusercontent.com/u/5030250?v=4","gravatar_id":"","url":"https://api.github.com/users/kohr-h","html_url":"https://github.com/kohr-h","followers_url":"https://api.github.com/users/kohr-h/followers","following_url":"https://api.github.com/users/kohr-h/following{/other_user}","gists_url":"https://api.github.com/users/kohr-h/gists{/gist_id}","starred_url":"https://api.github.com/users/kohr-h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohr-h/subscriptions","organizations_url":"https://api.github.com/users/kohr-h/orgs","repos_url":"https://api.github.com/users/kohr-h/repos","events_url":"https://api.github.com/users/kohr-h/events{/privacy}","received_events_url":"https://api.github.com/users/kohr-h/received_events","type":"User","site_admin":false},"body":"### TODOs\r\n(copied from #861)\r\n\r\n- [x] Implement basic structures for tensors and tensor spaces\r\n- [x] Replicate functionality of `NtuplesBase`, `FnBase`, `NumpyNtuples` and `NumpyFn` in the corresponding tensor classes\r\n- [x] Remove `Ntuples` and related stuff\r\n- [x] Add former `Ntuples` and the likes as special case to tensor classes\r\n- [x] Change names with \"tensor\" to something more lightweight\r\n- [x] Find place for ~~`MatVecOperator`~~`MatrixOperator`, see #584. Solved in #911 \r\n- [x] Improve pretty-printing of elements\r\n- [x] Fix broken downstream code (`lp_discr`, ...)\r\n- [x] Change code that was restricted to 1D data containers\r\n- [x] Port unit tests\r\n- [x] Write some doctests\r\n- [x] Write more doctests\r\n- [x] Remove `TensorSet` and others (see #860) duck-type space properties\r\n- [x] Check documentation for outdated information, e.g. regarding 1D data layout (Update: can't find anything explicit)\r\n- [x] ~~Use notion \"rank\" instead of \"number of dimensions\" to better distinguish between `space.ndim` and `space.size`~~ Not doing this\r\n- [x] Implement indexing of `TensorSpace`. ~~Done, but kind of wrong, see [here](https://github.com/odlgroup/odl/pull/861#issuecomment-275454215) and [here](https://github.com/odlgroup/odl/pull/861#issuecomment-275540310)~~ Done properly now\r\n- [x] ~~Write extra documentation on tensors~~ Should be part of #908\r\n- [x] Port `show` methods (1D from `Ntuples`, 2D from `DiscreteLp`)\r\n- [ ] Add unit tests for unusual data types and the likes\r\n- [x] Simplify doctests of tensor spaces\r\n- [x] Fix `FunctionSpaceElement` in 1D (again)\r\n- [x] Implement tensor-valued functions, see #908 \r\n- [x] Fix interpolation from array of points, related to #908 \r\n- [x] Cleanup (old stuff, commit history, ...)\r\n- [ ] Fix large-scale tests\r\n- [x] Make test with power function more general\r\n- [ ] Add more tests for product space multi-indexing\r\n- [x] Implement indexing of `FunctionSpace` for input and output dimensions \r\n- [x] Implement indexing of `DiscreteLp` along input dimensions (output not yet applicable since tensor-valued stuff remains TODO)\r\n- [x] Implement `__array_ufunc__` interface on `Tensor` and `NumpyTensor` (the latter only differs in weight propagation)\r\n- [x] Implement `__array_ufunc__` interface on `DiscreteLpElement`\r\n- [ ] Write more extensive tests for `__array_ufunc__` intefaces (bad input etc.)\r\n  - [x] For `NumpyTensor`\r\n  - [ ] For `DiscreteLpElement`","created_at":"2017-08-11T08:42:56Z","updated_at":"2017-08-11T22:21:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"296ac2eb4730b2b38d855b02d89499d3f8ae748c","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/odlgroup/odl/pulls/1088/commits","review_comments_url":"https://api.github.com/repos/odlgroup/odl/pulls/1088/comments","review_comment_url":"https://api.github.com/repos/odlgroup/odl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/odlgroup/odl/issues/1088/comments","statuses_url":"https://api.github.com/repos/odlgroup/odl/statuses/6bf4c34292730a7dfb460fcfa26a25823cbaef2d","head":{"label":"odlgroup:issue-342__tensor","ref":"issue-342__tensor","sha":"6bf4c34292730a7dfb460fcfa26a25823cbaef2d","user":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars1.githubusercontent.com/u/15667171?v=4","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"repo":{"id":45596393,"name":"odl","full_name":"odlgroup/odl","owner":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars1.githubusercontent.com/u/15667171?v=4","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odlgroup/odl","description":"Operator Discretization Library","fork":false,"url":"https://api.github.com/repos/odlgroup/odl","forks_url":"https://api.github.com/repos/odlgroup/odl/forks","keys_url":"https://api.github.com/repos/odlgroup/odl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odlgroup/odl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odlgroup/odl/teams","hooks_url":"https://api.github.com/repos/odlgroup/odl/hooks","issue_events_url":"https://api.github.com/repos/odlgroup/odl/issues/events{/number}","events_url":"https://api.github.com/repos/odlgroup/odl/events","assignees_url":"https://api.github.com/repos/odlgroup/odl/assignees{/user}","branches_url":"https://api.github.com/repos/odlgroup/odl/branches{/branch}","tags_url":"https://api.github.com/repos/odlgroup/odl/tags","blobs_url":"https://api.github.com/repos/odlgroup/odl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odlgroup/odl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odlgroup/odl/git/refs{/sha}","trees_url":"https://api.github.com/repos/odlgroup/odl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odlgroup/odl/statuses/{sha}","languages_url":"https://api.github.com/repos/odlgroup/odl/languages","stargazers_url":"https://api.github.com/repos/odlgroup/odl/stargazers","contributors_url":"https://api.github.com/repos/odlgroup/odl/contributors","subscribers_url":"https://api.github.com/repos/odlgroup/odl/subscribers","subscription_url":"https://api.github.com/repos/odlgroup/odl/subscription","commits_url":"https://api.github.com/repos/odlgroup/odl/commits{/sha}","git_commits_url":"https://api.github.com/repos/odlgroup/odl/git/commits{/sha}","comments_url":"https://api.github.com/repos/odlgroup/odl/comments{/number}","issue_comment_url":"https://api.github.com/repos/odlgroup/odl/issues/comments{/number}","contents_url":"https://api.github.com/repos/odlgroup/odl/contents/{+path}","compare_url":"https://api.github.com/repos/odlgroup/odl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odlgroup/odl/merges","archive_url":"https://api.github.com/repos/odlgroup/odl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odlgroup/odl/downloads","issues_url":"https://api.github.com/repos/odlgroup/odl/issues{/number}","pulls_url":"https://api.github.com/repos/odlgroup/odl/pulls{/number}","milestones_url":"https://api.github.com/repos/odlgroup/odl/milestones{/number}","notifications_url":"https://api.github.com/repos/odlgroup/odl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odlgroup/odl/labels{/name}","releases_url":"https://api.github.com/repos/odlgroup/odl/releases{/id}","deployments_url":"https://api.github.com/repos/odlgroup/odl/deployments","created_at":"2015-11-05T07:57:55Z","updated_at":"2017-08-04T14:04:25Z","pushed_at":"2017-08-11T21:51:40Z","git_url":"git://github.com/odlgroup/odl.git","ssh_url":"git@github.com:odlgroup/odl.git","clone_url":"https://github.com/odlgroup/odl.git","svn_url":"https://github.com/odlgroup/odl","homepage":"","size":27510,"stargazers_count":24,"watchers_count":24,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":20,"mirror_url":null,"open_issues_count":167,"forks":20,"open_issues":167,"watchers":24,"default_branch":"master"}},"base":{"label":"odlgroup:master","ref":"master","sha":"04706abfab7badcd30867afb71f32157c8878e58","user":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars1.githubusercontent.com/u/15667171?v=4","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"repo":{"id":45596393,"name":"odl","full_name":"odlgroup/odl","owner":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars1.githubusercontent.com/u/15667171?v=4","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odlgroup/odl","description":"Operator Discretization Library","fork":false,"url":"https://api.github.com/repos/odlgroup/odl","forks_url":"https://api.github.com/repos/odlgroup/odl/forks","keys_url":"https://api.github.com/repos/odlgroup/odl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odlgroup/odl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odlgroup/odl/teams","hooks_url":"https://api.github.com/repos/odlgroup/odl/hooks","issue_events_url":"https://api.github.com/repos/odlgroup/odl/issues/events{/number}","events_url":"https://api.github.com/repos/odlgroup/odl/events","assignees_url":"https://api.github.com/repos/odlgroup/odl/assignees{/user}","branches_url":"https://api.github.com/repos/odlgroup/odl/branches{/branch}","tags_url":"https://api.github.com/repos/odlgroup/odl/tags","blobs_url":"https://api.github.com/repos/odlgroup/odl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odlgroup/odl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odlgroup/odl/git/refs{/sha}","trees_url":"https://api.github.com/repos/odlgroup/odl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odlgroup/odl/statuses/{sha}","languages_url":"https://api.github.com/repos/odlgroup/odl/languages","stargazers_url":"https://api.github.com/repos/odlgroup/odl/stargazers","contributors_url":"https://api.github.com/repos/odlgroup/odl/contributors","subscribers_url":"https://api.github.com/repos/odlgroup/odl/subscribers","subscription_url":"https://api.github.com/repos/odlgroup/odl/subscription","commits_url":"https://api.github.com/repos/odlgroup/odl/commits{/sha}","git_commits_url":"https://api.github.com/repos/odlgroup/odl/git/commits{/sha}","comments_url":"https://api.github.com/repos/odlgroup/odl/comments{/number}","issue_comment_url":"https://api.github.com/repos/odlgroup/odl/issues/comments{/number}","contents_url":"https://api.github.com/repos/odlgroup/odl/contents/{+path}","compare_url":"https://api.github.com/repos/odlgroup/odl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odlgroup/odl/merges","archive_url":"https://api.github.com/repos/odlgroup/odl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odlgroup/odl/downloads","issues_url":"https://api.github.com/repos/odlgroup/odl/issues{/number}","pulls_url":"https://api.github.com/repos/odlgroup/odl/pulls{/number}","milestones_url":"https://api.github.com/repos/odlgroup/odl/milestones{/number}","notifications_url":"https://api.github.com/repos/odlgroup/odl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odlgroup/odl/labels{/name}","releases_url":"https://api.github.com/repos/odlgroup/odl/releases{/id}","deployments_url":"https://api.github.com/repos/odlgroup/odl/deployments","created_at":"2015-11-05T07:57:55Z","updated_at":"2017-08-04T14:04:25Z","pushed_at":"2017-08-11T21:51:40Z","git_url":"git://github.com/odlgroup/odl.git","ssh_url":"git@github.com:odlgroup/odl.git","clone_url":"https://github.com/odlgroup/odl.git","svn_url":"https://github.com/odlgroup/odl","homepage":"","size":27510,"stargazers_count":24,"watchers_count":24,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":20,"mirror_url":null,"open_issues_count":167,"forks":20,"open_issues":167,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/1088"},"html":{"href":"https://github.com/odlgroup/odl/pull/1088"},"issue":{"href":"https://api.github.com/repos/odlgroup/odl/issues/1088"},"comments":{"href":"https://api.github.com/repos/odlgroup/odl/issues/1088/comments"},"review_comments":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/1088/comments"},"review_comment":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/1088/commits"},"statuses":{"href":"https://api.github.com/repos/odlgroup/odl/statuses/6bf4c34292730a7dfb460fcfa26a25823cbaef2d"}}}}
{"actor":{"display_login":"kohr-h"}}