{"action":"created","comment":{"url":"https://api.github.com/repos/metric-learn/metric-learn/pulls/comments/234901038","pull_request_review_id":176640102,"id":234901038,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNDkwMTAzOA==","diff_hunk":"@@ -12,39 +14,264 @@ def vector_norm(X):\n     return np.linalg.norm(X, axis=1)\r\n \r\n \r\n-def check_tuples(tuples):\r\n-  \"\"\"Check that the input is a valid 3D array representing a dataset of tuples.\r\n-\r\n-  Equivalent of `check_array` in scikit-learn.\r\n+def check_input(input, y=None, preprocessor=None,\r\n+                type_of_inputs='classic', t=None, accept_sparse=False,\r\n+                dtype=\"numeric\", order=None,\r\n+                copy=False, force_all_finite=True,\r\n+                multi_output=False, ensure_min_samples=1,\r\n+                ensure_min_features=1, y_numeric=False,\r\n+                warn_on_dtype=False, estimator=None):\r\n+  \"\"\"Checks that the input format is valid, and converts it if specified\r\n+  (this is the equivalent of scikit-learn's `check_array` or `check_X_y`).\r\n+  All arguments following t are scikit-learn's `check_X_y`\r\n+  arguments that will be enforced on the data and labels array. If\r\n+  indicators are given as an input data array, the returned data array\r\n+  will be the formed points/tuples, using the given preprocessor.\r\n \r\n   Parameters\r\n   ----------\r\n-  tuples : object\r\n-    The tuples to check.\r\n+  input : array-like\r\n+    The input data array to check.\r\n+\r\n+  y : array-like\r\n+    The input labels array to check.\r\n+\r\n+  preprocessor : callable (default=None)\r","path":"metric_learn/_util.py","position":41,"original_position":41,"commit_id":"b29a555bbaca244fba9e1a6526afa5f5ddae06a8","original_commit_id":"b29a555bbaca244fba9e1a6526afa5f5ddae06a8","user":{"login":"wdevazelhes","id":31916524,"node_id":"MDQ6VXNlcjMxOTE2NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/31916524?v=4","gravatar_id":"","url":"https://api.github.com/users/wdevazelhes","html_url":"https://github.com/wdevazelhes","followers_url":"https://api.github.com/users/wdevazelhes/followers","following_url":"https://api.github.com/users/wdevazelhes/following{/other_user}","gists_url":"https://api.github.com/users/wdevazelhes/gists{/gist_id}","starred_url":"https://api.github.com/users/wdevazelhes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdevazelhes/subscriptions","organizations_url":"https://api.github.com/users/wdevazelhes/orgs","repos_url":"https://api.github.com/users/wdevazelhes/repos","events_url":"https://api.github.com/users/wdevazelhes/events{/privacy}","received_events_url":"https://api.github.com/users/wdevazelhes/received_events","type":"User","site_admin":false},"body":"Right thanks, I'll note it down also for changing it in other parts of the code in some next PR.","created_at":"2018-11-20T08:07:28Z","updated_at":"2018-11-20T08:07:29Z","html_url":"https://github.com/metric-learn/metric-learn/pull/117#discussion_r234901038","pull_request_url":"https://api.github.com/repos/metric-learn/metric-learn/pulls/117","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/metric-learn/metric-learn/pulls/comments/234901038"},"html":{"href":"https://github.com/metric-learn/metric-learn/pull/117#discussion_r234901038"},"pull_request":{"href":"https://api.github.com/repos/metric-learn/metric-learn/pulls/117"}},"in_reply_to_id":233979098},"pull_request":{"url":"https://api.github.com/repos/metric-learn/metric-learn/pulls/117","id":209880973,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5ODgwOTcz","html_url":"https://github.com/metric-learn/metric-learn/pull/117","diff_url":"https://github.com/metric-learn/metric-learn/pull/117.diff","patch_url":"https://github.com/metric-learn/metric-learn/pull/117.patch","issue_url":"https://api.github.com/repos/metric-learn/metric-learn/issues/117","number":117,"state":"open","locked":false,"title":"[MRG] Add preprocessor option","user":{"login":"wdevazelhes","id":31916524,"node_id":"MDQ6VXNlcjMxOTE2NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/31916524?v=4","gravatar_id":"","url":"https://api.github.com/users/wdevazelhes","html_url":"https://github.com/wdevazelhes","followers_url":"https://api.github.com/users/wdevazelhes/followers","following_url":"https://api.github.com/users/wdevazelhes/following{/other_user}","gists_url":"https://api.github.com/users/wdevazelhes/gists{/gist_id}","starred_url":"https://api.github.com/users/wdevazelhes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdevazelhes/subscriptions","organizations_url":"https://api.github.com/users/wdevazelhes/orgs","repos_url":"https://api.github.com/users/wdevazelhes/repos","events_url":"https://api.github.com/users/wdevazelhes/events{/privacy}","received_events_url":"https://api.github.com/users/wdevazelhes/received_events","type":"User","site_admin":false},"body":"This PR adds an argument `preprocessor` to weakly supervised algorithms initialization: an option that allows them to accept two types of input: either 3D arrays of tuples of points as before, or 2D arrays of indices/identifiers of points. In the latter case, the preprocessor given as input to the Metric Learner will allow to retreive points from identifiers. The preprocessor is basically a callable that is called on a list of identifiers (or just on one identifier ? we'll have to decide), and that returns the points associated to this identifiers. \r\nIf instead of a callable the user provides an array X, it will automatically create the \"indexing\" preprocessor (i.e. a preprocessor such that preprocessor(id) returns X[id]). We could also imagine other shortcuts like this (for instance the user could provide a string of a root folder containing images and then it would create a preprocessor such that preprocessor(\"img2.png\") would return the vector associated to the image located at \"rootfolder/img2.png\") \r\n\r\nNote: This PR branched from MahalanobisMixin PR, so as soon as MahalanobisMixin is merged the diff should become more readable.\r\n\r\n#### TODO: \r\n\r\n- [x] Add comments and more info to this PR\r\n- [x] Add tests: in progress: add tests to check that the output format of `check_input` is as specified\r\n-<strike> [ ] Add documentation </strike> -> probably in another PR\r\n- [x] Make it simpler with unified `check_input` function\r\n- [x] Refactor the `check_input` function and its tests to be cleaner\r\n- [x] Write docstrings","created_at":"2018-08-21T16:13:35Z","updated_at":"2018-11-20T08:07:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d06af5ca795730144d6d8b162a77f451fd33be5","assignee":null,"assignees":[],"requested_reviewers":[{"login":"nvauquie","id":19710083,"node_id":"MDQ6VXNlcjE5NzEwMDgz","avatar_url":"https://avatars1.githubusercontent.com/u/19710083?v=4","gravatar_id":"","url":"https://api.github.com/users/nvauquie","html_url":"https://github.com/nvauquie","followers_url":"https://api.github.com/users/nvauquie/followers","following_url":"https://api.github.com/users/nvauquie/following{/other_user}","gists_url":"https://api.github.com/users/nvauquie/gists{/gist_id}","starred_url":"https://api.github.com/users/nvauquie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvauquie/subscriptions","organizations_url":"https://api.github.com/users/nvauquie/orgs","repos_url":"https://api.github.com/users/nvauquie/repos","events_url":"https://api.github.com/users/nvauquie/events{/privacy}","received_events_url":"https://api.github.com/users/nvauquie/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/metric-learn/metric-learn/pulls/117/commits","review_comments_url":"https://api.github.com/repos/metric-learn/metric-learn/pulls/117/comments","review_comment_url":"https://api.github.com/repos/metric-learn/metric-learn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/metric-learn/metric-learn/issues/117/comments","statuses_url":"https://api.github.com/repos/metric-learn/metric-learn/statuses/b29a555bbaca244fba9e1a6526afa5f5ddae06a8","head":{"label":"wdevazelhes:feat/preprocessor","ref":"feat/preprocessor","sha":"b29a555bbaca244fba9e1a6526afa5f5ddae06a8","user":{"login":"wdevazelhes","id":31916524,"node_id":"MDQ6VXNlcjMxOTE2NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/31916524?v=4","gravatar_id":"","url":"https://api.github.com/users/wdevazelhes","html_url":"https://github.com/wdevazelhes","followers_url":"https://api.github.com/users/wdevazelhes/followers","following_url":"https://api.github.com/users/wdevazelhes/following{/other_user}","gists_url":"https://api.github.com/users/wdevazelhes/gists{/gist_id}","starred_url":"https://api.github.com/users/wdevazelhes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdevazelhes/subscriptions","organizations_url":"https://api.github.com/users/wdevazelhes/orgs","repos_url":"https://api.github.com/users/wdevazelhes/repos","events_url":"https://api.github.com/users/wdevazelhes/events{/privacy}","received_events_url":"https://api.github.com/users/wdevazelhes/received_events","type":"User","site_admin":false},"repo":{"id":121612336,"node_id":"MDEwOlJlcG9zaXRvcnkxMjE2MTIzMzY=","name":"metric-learn","full_name":"wdevazelhes/metric-learn","private":false,"owner":{"login":"wdevazelhes","id":31916524,"node_id":"MDQ6VXNlcjMxOTE2NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/31916524?v=4","gravatar_id":"","url":"https://api.github.com/users/wdevazelhes","html_url":"https://github.com/wdevazelhes","followers_url":"https://api.github.com/users/wdevazelhes/followers","following_url":"https://api.github.com/users/wdevazelhes/following{/other_user}","gists_url":"https://api.github.com/users/wdevazelhes/gists{/gist_id}","starred_url":"https://api.github.com/users/wdevazelhes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdevazelhes/subscriptions","organizations_url":"https://api.github.com/users/wdevazelhes/orgs","repos_url":"https://api.github.com/users/wdevazelhes/repos","events_url":"https://api.github.com/users/wdevazelhes/events{/privacy}","received_events_url":"https://api.github.com/users/wdevazelhes/received_events","type":"User","site_admin":false},"html_url":"https://github.com/wdevazelhes/metric-learn","description":"Metric learning algorithms in Python","fork":true,"url":"https://api.github.com/repos/wdevazelhes/metric-learn","forks_url":"https://api.github.com/repos/wdevazelhes/metric-learn/forks","keys_url":"https://api.github.com/repos/wdevazelhes/metric-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wdevazelhes/metric-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wdevazelhes/metric-learn/teams","hooks_url":"https://api.github.com/repos/wdevazelhes/metric-learn/hooks","issue_events_url":"https://api.github.com/repos/wdevazelhes/metric-learn/issues/events{/number}","events_url":"https://api.github.com/repos/wdevazelhes/metric-learn/events","assignees_url":"https://api.github.com/repos/wdevazelhes/metric-learn/assignees{/user}","branches_url":"https://api.github.com/repos/wdevazelhes/metric-learn/branches{/branch}","tags_url":"https://api.github.com/repos/wdevazelhes/metric-learn/tags","blobs_url":"https://api.github.com/repos/wdevazelhes/metric-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wdevazelhes/metric-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wdevazelhes/metric-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/wdevazelhes/metric-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wdevazelhes/metric-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/wdevazelhes/metric-learn/languages","stargazers_url":"https://api.github.com/repos/wdevazelhes/metric-learn/stargazers","contributors_url":"https://api.github.com/repos/wdevazelhes/metric-learn/contributors","subscribers_url":"https://api.github.com/repos/wdevazelhes/metric-learn/subscribers","subscription_url":"https://api.github.com/repos/wdevazelhes/metric-learn/subscription","commits_url":"https://api.github.com/repos/wdevazelhes/metric-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/wdevazelhes/metric-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/wdevazelhes/metric-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/wdevazelhes/metric-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/wdevazelhes/metric-learn/contents/{+path}","compare_url":"https://api.github.com/repos/wdevazelhes/metric-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wdevazelhes/metric-learn/merges","archive_url":"https://api.github.com/repos/wdevazelhes/metric-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wdevazelhes/metric-learn/downloads","issues_url":"https://api.github.com/repos/wdevazelhes/metric-learn/issues{/number}","pulls_url":"https://api.github.com/repos/wdevazelhes/metric-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/wdevazelhes/metric-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/wdevazelhes/metric-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wdevazelhes/metric-learn/labels{/name}","releases_url":"https://api.github.com/repos/wdevazelhes/metric-learn/releases{/id}","deployments_url":"https://api.github.com/repos/wdevazelhes/metric-learn/deployments","created_at":"2018-02-15T09:43:10Z","updated_at":"2018-08-31T15:25:44Z","pushed_at":"2018-11-15T11:05:49Z","git_url":"git://github.com/wdevazelhes/metric-learn.git","ssh_url":"git@github.com:wdevazelhes/metric-learn.git","clone_url":"https://github.com/wdevazelhes/metric-learn.git","svn_url":"https://github.com/wdevazelhes/metric-learn","homepage":null,"size":1631,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"metric-learn:new_api_design","ref":"new_api_design","sha":"e4685b16fad4c97f0f3c59f9e5ce4af08d3e3f02","user":{"login":"metric-learn","id":35635935,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1NjM1OTM1","avatar_url":"https://avatars1.githubusercontent.com/u/35635935?v=4","gravatar_id":"","url":"https://api.github.com/users/metric-learn","html_url":"https://github.com/metric-learn","followers_url":"https://api.github.com/users/metric-learn/followers","following_url":"https://api.github.com/users/metric-learn/following{/other_user}","gists_url":"https://api.github.com/users/metric-learn/gists{/gist_id}","starred_url":"https://api.github.com/users/metric-learn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metric-learn/subscriptions","organizations_url":"https://api.github.com/users/metric-learn/orgs","repos_url":"https://api.github.com/users/metric-learn/repos","events_url":"https://api.github.com/users/metric-learn/events{/privacy}","received_events_url":"https://api.github.com/users/metric-learn/received_events","type":"Organization","site_admin":false},"repo":{"id":14063354,"node_id":"MDEwOlJlcG9zaXRvcnkxNDA2MzM1NA==","name":"metric-learn","full_name":"metric-learn/metric-learn","private":false,"owner":{"login":"metric-learn","id":35635935,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1NjM1OTM1","avatar_url":"https://avatars1.githubusercontent.com/u/35635935?v=4","gravatar_id":"","url":"https://api.github.com/users/metric-learn","html_url":"https://github.com/metric-learn","followers_url":"https://api.github.com/users/metric-learn/followers","following_url":"https://api.github.com/users/metric-learn/following{/other_user}","gists_url":"https://api.github.com/users/metric-learn/gists{/gist_id}","starred_url":"https://api.github.com/users/metric-learn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metric-learn/subscriptions","organizations_url":"https://api.github.com/users/metric-learn/orgs","repos_url":"https://api.github.com/users/metric-learn/repos","events_url":"https://api.github.com/users/metric-learn/events{/privacy}","received_events_url":"https://api.github.com/users/metric-learn/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/metric-learn/metric-learn","description":"Metric learning algorithms in Python","fork":false,"url":"https://api.github.com/repos/metric-learn/metric-learn","forks_url":"https://api.github.com/repos/metric-learn/metric-learn/forks","keys_url":"https://api.github.com/repos/metric-learn/metric-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metric-learn/metric-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metric-learn/metric-learn/teams","hooks_url":"https://api.github.com/repos/metric-learn/metric-learn/hooks","issue_events_url":"https://api.github.com/repos/metric-learn/metric-learn/issues/events{/number}","events_url":"https://api.github.com/repos/metric-learn/metric-learn/events","assignees_url":"https://api.github.com/repos/metric-learn/metric-learn/assignees{/user}","branches_url":"https://api.github.com/repos/metric-learn/metric-learn/branches{/branch}","tags_url":"https://api.github.com/repos/metric-learn/metric-learn/tags","blobs_url":"https://api.github.com/repos/metric-learn/metric-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metric-learn/metric-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metric-learn/metric-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/metric-learn/metric-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metric-learn/metric-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/metric-learn/metric-learn/languages","stargazers_url":"https://api.github.com/repos/metric-learn/metric-learn/stargazers","contributors_url":"https://api.github.com/repos/metric-learn/metric-learn/contributors","subscribers_url":"https://api.github.com/repos/metric-learn/metric-learn/subscribers","subscription_url":"https://api.github.com/repos/metric-learn/metric-learn/subscription","commits_url":"https://api.github.com/repos/metric-learn/metric-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/metric-learn/metric-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/metric-learn/metric-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/metric-learn/metric-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/metric-learn/metric-learn/contents/{+path}","compare_url":"https://api.github.com/repos/metric-learn/metric-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metric-learn/metric-learn/merges","archive_url":"https://api.github.com/repos/metric-learn/metric-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metric-learn/metric-learn/downloads","issues_url":"https://api.github.com/repos/metric-learn/metric-learn/issues{/number}","pulls_url":"https://api.github.com/repos/metric-learn/metric-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/metric-learn/metric-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/metric-learn/metric-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metric-learn/metric-learn/labels{/name}","releases_url":"https://api.github.com/repos/metric-learn/metric-learn/releases{/id}","deployments_url":"https://api.github.com/repos/metric-learn/metric-learn/deployments","created_at":"2013-11-02T08:29:47Z","updated_at":"2018-11-19T06:37:10Z","pushed_at":"2018-11-15T11:05:50Z","git_url":"git://github.com/metric-learn/metric-learn.git","ssh_url":"git@github.com:metric-learn/metric-learn.git","clone_url":"https://github.com/metric-learn/metric-learn.git","svn_url":"https://github.com/metric-learn/metric-learn","homepage":null,"size":2607,"stargazers_count":550,"watchers_count":550,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":137,"mirror_url":null,"archived":false,"open_issues_count":25,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":137,"open_issues":25,"watchers":550,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/metric-learn/metric-learn/pulls/117"},"html":{"href":"https://github.com/metric-learn/metric-learn/pull/117"},"issue":{"href":"https://api.github.com/repos/metric-learn/metric-learn/issues/117"},"comments":{"href":"https://api.github.com/repos/metric-learn/metric-learn/issues/117/comments"},"review_comments":{"href":"https://api.github.com/repos/metric-learn/metric-learn/pulls/117/comments"},"review_comment":{"href":"https://api.github.com/repos/metric-learn/metric-learn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/metric-learn/metric-learn/pulls/117/commits"},"statuses":{"href":"https://api.github.com/repos/metric-learn/metric-learn/statuses/b29a555bbaca244fba9e1a6526afa5f5ddae06a8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"wdevazelhes"}}