{"action":"created","comment":{"url":"https://api.github.com/repos/openfisca/openfisca-france/pulls/comments/42239036","id":42239036,"diff_hunk":"@@ -39,13 +39,40 @@ class af_nbenf(SimpleFormulaColumn):\n     label = u\"Nombre d'enfants dans la famille au sens des allocations familiales\"\n \n     def function(self, simulation, period):\n-        period_mois = period.start.offset('first-of', 'month').period('month')\n+        period_mois = period.this_month\n \n         af_enfant_a_charge_holder = simulation.compute('af_enfant_a_charge', period_mois)\n         af_nbenf = self.sum_by_entity(af_enfant_a_charge_holder)\n \n         return period, af_nbenf\n \n+@reference_formula\n+class af_coeff_garde_alternee(DatedFormulaColumn):\n+    column = FloatCol(default = 1)\n+    entity_class = Familles\n+    label = u\"Coefficient à appliquer aux af pour tenir compte de la garde alternée\"\n+\n+    @dated_function(start = date(2007, 5, 1))\n+    def function_2007(self, simulation, period):\n+        period = period.this_month\n+        nb_enf = simulation.calculate('af_nbenf', period)\n+        alt = simulation.compute('alt', period)\n+        af_enfant_a_charge = simulation.compute('af_enfant_a_charge', period)\n+\n+        # Le nombre d'individus pour qui sont à la fois en garde alternee et enfant à charge\n+        nb_enf_garde_alternee = self.sum_by_entity(alt.array * af_enfant_a_charge.array)\n+\n+        # On doit distinguer le cas nb_enf = 0. On a donc besoin d'une fonction spécifique qu'on vectorialise.\n+        def coefficient_garde_alternee(nb_enf_garde_alternee, nb_enf):\n+            if nb_enf == 0:\n+                return 1\n+            else:\n+                return 1 - (nb_enf_garde_alternee / nb_enf) * 0.5\n+\n+        coefficient_garde_alternee_vec = vectorize(coefficient_garde_alternee)","path":"openfisca_france/model/prestations/prestations_familiales/af.py","position":null,"original_position":53,"commit_id":"5bbc068554f74c73db1d3156e56e056ff1900353","original_commit_id":"9828c3f89a5d68a9ba571ff07c1cb7321387c491","user":{"login":"fpagnoux","id":11834997,"avatar_url":"https://avatars.githubusercontent.com/u/11834997?v=3","gravatar_id":"","url":"https://api.github.com/users/fpagnoux","html_url":"https://github.com/fpagnoux","followers_url":"https://api.github.com/users/fpagnoux/followers","following_url":"https://api.github.com/users/fpagnoux/following{/other_user}","gists_url":"https://api.github.com/users/fpagnoux/gists{/gist_id}","starred_url":"https://api.github.com/users/fpagnoux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fpagnoux/subscriptions","organizations_url":"https://api.github.com/users/fpagnoux/orgs","repos_url":"https://api.github.com/users/fpagnoux/repos","events_url":"https://api.github.com/users/fpagnoux/events{/privacy}","received_events_url":"https://api.github.com/users/fpagnoux/received_events","type":"User","site_admin":false},"body":"Corrigé pour le cas des af.","created_at":"2015-10-16T12:59:39Z","updated_at":"2015-10-16T12:59:39Z","html_url":"https://github.com/openfisca/openfisca-france/pull/341#discussion_r42239036","pull_request_url":"https://api.github.com/repos/openfisca/openfisca-france/pulls/341","_links":{"self":{"href":"https://api.github.com/repos/openfisca/openfisca-france/pulls/comments/42239036"},"html":{"href":"https://github.com/openfisca/openfisca-france/pull/341#discussion_r42239036"},"pull_request":{"href":"https://api.github.com/repos/openfisca/openfisca-france/pulls/341"}}},"pull_request":{"url":"https://api.github.com/repos/openfisca/openfisca-france/pulls/341","id":47809243,"html_url":"https://github.com/openfisca/openfisca-france/pull/341","diff_url":"https://github.com/openfisca/openfisca-france/pull/341.diff","patch_url":"https://github.com/openfisca/openfisca-france/pull/341.patch","issue_url":"https://api.github.com/repos/openfisca/openfisca-france/issues/341","number":341,"state":"open","locked":false,"title":"Prendre en compte la garde alternée dans les AF","user":{"login":"fpagnoux","id":11834997,"avatar_url":"https://avatars.githubusercontent.com/u/11834997?v=3","gravatar_id":"","url":"https://api.github.com/users/fpagnoux","html_url":"https://github.com/fpagnoux","followers_url":"https://api.github.com/users/fpagnoux/followers","following_url":"https://api.github.com/users/fpagnoux/following{/other_user}","gists_url":"https://api.github.com/users/fpagnoux/gists{/gist_id}","starred_url":"https://api.github.com/users/fpagnoux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fpagnoux/subscriptions","organizations_url":"https://api.github.com/users/fpagnoux/orgs","repos_url":"https://api.github.com/users/fpagnoux/repos","events_url":"https://api.github.com/users/fpagnoux/events{/privacy}","received_events_url":"https://api.github.com/users/fpagnoux/received_events","type":"User","site_admin":false},"body":"Connected to sgmap/openfisca-france#27","created_at":"2015-10-15T16:22:25Z","updated_at":"2015-10-16T12:59:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d868b1e517165946796df268418a0d16d8d18d97","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openfisca/openfisca-france/pulls/341/commits","review_comments_url":"https://api.github.com/repos/openfisca/openfisca-france/pulls/341/comments","review_comment_url":"https://api.github.com/repos/openfisca/openfisca-france/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openfisca/openfisca-france/issues/341/comments","statuses_url":"https://api.github.com/repos/openfisca/openfisca-france/statuses/5bbc068554f74c73db1d3156e56e056ff1900353","head":{"label":"openfisca:af-garde-alternee","ref":"af-garde-alternee","sha":"5bbc068554f74c73db1d3156e56e056ff1900353","user":{"login":"openfisca","id":1794404,"avatar_url":"https://avatars.githubusercontent.com/u/1794404?v=3","gravatar_id":"","url":"https://api.github.com/users/openfisca","html_url":"https://github.com/openfisca","followers_url":"https://api.github.com/users/openfisca/followers","following_url":"https://api.github.com/users/openfisca/following{/other_user}","gists_url":"https://api.github.com/users/openfisca/gists{/gist_id}","starred_url":"https://api.github.com/users/openfisca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openfisca/subscriptions","organizations_url":"https://api.github.com/users/openfisca/orgs","repos_url":"https://api.github.com/users/openfisca/repos","events_url":"https://api.github.com/users/openfisca/events{/privacy}","received_events_url":"https://api.github.com/users/openfisca/received_events","type":"Organization","site_admin":false},"repo":{"id":15510233,"name":"openfisca-france","full_name":"openfisca/openfisca-france","owner":{"login":"openfisca","id":1794404,"avatar_url":"https://avatars.githubusercontent.com/u/1794404?v=3","gravatar_id":"","url":"https://api.github.com/users/openfisca","html_url":"https://github.com/openfisca","followers_url":"https://api.github.com/users/openfisca/followers","following_url":"https://api.github.com/users/openfisca/following{/other_user}","gists_url":"https://api.github.com/users/openfisca/gists{/gist_id}","starred_url":"https://api.github.com/users/openfisca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openfisca/subscriptions","organizations_url":"https://api.github.com/users/openfisca/orgs","repos_url":"https://api.github.com/users/openfisca/repos","events_url":"https://api.github.com/users/openfisca/events{/privacy}","received_events_url":"https://api.github.com/users/openfisca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openfisca/openfisca-france","description":"French tax and benefit system for OpenFisca","fork":false,"url":"https://api.github.com/repos/openfisca/openfisca-france","forks_url":"https://api.github.com/repos/openfisca/openfisca-france/forks","keys_url":"https://api.github.com/repos/openfisca/openfisca-france/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openfisca/openfisca-france/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openfisca/openfisca-france/teams","hooks_url":"https://api.github.com/repos/openfisca/openfisca-france/hooks","issue_events_url":"https://api.github.com/repos/openfisca/openfisca-france/issues/events{/number}","events_url":"https://api.github.com/repos/openfisca/openfisca-france/events","assignees_url":"https://api.github.com/repos/openfisca/openfisca-france/assignees{/user}","branches_url":"https://api.github.com/repos/openfisca/openfisca-france/branches{/branch}","tags_url":"https://api.github.com/repos/openfisca/openfisca-france/tags","blobs_url":"https://api.github.com/repos/openfisca/openfisca-france/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openfisca/openfisca-france/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openfisca/openfisca-france/git/refs{/sha}","trees_url":"https://api.github.com/repos/openfisca/openfisca-france/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openfisca/openfisca-france/statuses/{sha}","languages_url":"https://api.github.com/repos/openfisca/openfisca-france/languages","stargazers_url":"https://api.github.com/repos/openfisca/openfisca-france/stargazers","contributors_url":"https://api.github.com/repos/openfisca/openfisca-france/contributors","subscribers_url":"https://api.github.com/repos/openfisca/openfisca-france/subscribers","subscription_url":"https://api.github.com/repos/openfisca/openfisca-france/subscription","commits_url":"https://api.github.com/repos/openfisca/openfisca-france/commits{/sha}","git_commits_url":"https://api.github.com/repos/openfisca/openfisca-france/git/commits{/sha}","comments_url":"https://api.github.com/repos/openfisca/openfisca-france/comments{/number}","issue_comment_url":"https://api.github.com/repos/openfisca/openfisca-france/issues/comments{/number}","contents_url":"https://api.github.com/repos/openfisca/openfisca-france/contents/{+path}","compare_url":"https://api.github.com/repos/openfisca/openfisca-france/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openfisca/openfisca-france/merges","archive_url":"https://api.github.com/repos/openfisca/openfisca-france/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openfisca/openfisca-france/downloads","issues_url":"https://api.github.com/repos/openfisca/openfisca-france/issues{/number}","pulls_url":"https://api.github.com/repos/openfisca/openfisca-france/pulls{/number}","milestones_url":"https://api.github.com/repos/openfisca/openfisca-france/milestones{/number}","notifications_url":"https://api.github.com/repos/openfisca/openfisca-france/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openfisca/openfisca-france/labels{/name}","releases_url":"https://api.github.com/repos/openfisca/openfisca-france/releases{/id}","created_at":"2013-12-29T15:15:09Z","updated_at":"2015-10-09T13:25:20Z","pushed_at":"2015-10-16T12:59:08Z","git_url":"git://github.com/openfisca/openfisca-france.git","ssh_url":"git@github.com:openfisca/openfisca-france.git","clone_url":"https://github.com/openfisca/openfisca-france.git","svn_url":"https://github.com/openfisca/openfisca-france","homepage":"http://www.openfisca.fr/","size":19490,"stargazers_count":36,"watchers_count":36,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":61,"forks":41,"open_issues":61,"watchers":36,"default_branch":"master"}},"base":{"label":"openfisca:next","ref":"next","sha":"9afa0c924cc6174c9414c8a25adea4c98b4eaffe","user":{"login":"openfisca","id":1794404,"avatar_url":"https://avatars.githubusercontent.com/u/1794404?v=3","gravatar_id":"","url":"https://api.github.com/users/openfisca","html_url":"https://github.com/openfisca","followers_url":"https://api.github.com/users/openfisca/followers","following_url":"https://api.github.com/users/openfisca/following{/other_user}","gists_url":"https://api.github.com/users/openfisca/gists{/gist_id}","starred_url":"https://api.github.com/users/openfisca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openfisca/subscriptions","organizations_url":"https://api.github.com/users/openfisca/orgs","repos_url":"https://api.github.com/users/openfisca/repos","events_url":"https://api.github.com/users/openfisca/events{/privacy}","received_events_url":"https://api.github.com/users/openfisca/received_events","type":"Organization","site_admin":false},"repo":{"id":15510233,"name":"openfisca-france","full_name":"openfisca/openfisca-france","owner":{"login":"openfisca","id":1794404,"avatar_url":"https://avatars.githubusercontent.com/u/1794404?v=3","gravatar_id":"","url":"https://api.github.com/users/openfisca","html_url":"https://github.com/openfisca","followers_url":"https://api.github.com/users/openfisca/followers","following_url":"https://api.github.com/users/openfisca/following{/other_user}","gists_url":"https://api.github.com/users/openfisca/gists{/gist_id}","starred_url":"https://api.github.com/users/openfisca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openfisca/subscriptions","organizations_url":"https://api.github.com/users/openfisca/orgs","repos_url":"https://api.github.com/users/openfisca/repos","events_url":"https://api.github.com/users/openfisca/events{/privacy}","received_events_url":"https://api.github.com/users/openfisca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openfisca/openfisca-france","description":"French tax and benefit system for OpenFisca","fork":false,"url":"https://api.github.com/repos/openfisca/openfisca-france","forks_url":"https://api.github.com/repos/openfisca/openfisca-france/forks","keys_url":"https://api.github.com/repos/openfisca/openfisca-france/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openfisca/openfisca-france/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openfisca/openfisca-france/teams","hooks_url":"https://api.github.com/repos/openfisca/openfisca-france/hooks","issue_events_url":"https://api.github.com/repos/openfisca/openfisca-france/issues/events{/number}","events_url":"https://api.github.com/repos/openfisca/openfisca-france/events","assignees_url":"https://api.github.com/repos/openfisca/openfisca-france/assignees{/user}","branches_url":"https://api.github.com/repos/openfisca/openfisca-france/branches{/branch}","tags_url":"https://api.github.com/repos/openfisca/openfisca-france/tags","blobs_url":"https://api.github.com/repos/openfisca/openfisca-france/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openfisca/openfisca-france/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openfisca/openfisca-france/git/refs{/sha}","trees_url":"https://api.github.com/repos/openfisca/openfisca-france/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openfisca/openfisca-france/statuses/{sha}","languages_url":"https://api.github.com/repos/openfisca/openfisca-france/languages","stargazers_url":"https://api.github.com/repos/openfisca/openfisca-france/stargazers","contributors_url":"https://api.github.com/repos/openfisca/openfisca-france/contributors","subscribers_url":"https://api.github.com/repos/openfisca/openfisca-france/subscribers","subscription_url":"https://api.github.com/repos/openfisca/openfisca-france/subscription","commits_url":"https://api.github.com/repos/openfisca/openfisca-france/commits{/sha}","git_commits_url":"https://api.github.com/repos/openfisca/openfisca-france/git/commits{/sha}","comments_url":"https://api.github.com/repos/openfisca/openfisca-france/comments{/number}","issue_comment_url":"https://api.github.com/repos/openfisca/openfisca-france/issues/comments{/number}","contents_url":"https://api.github.com/repos/openfisca/openfisca-france/contents/{+path}","compare_url":"https://api.github.com/repos/openfisca/openfisca-france/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openfisca/openfisca-france/merges","archive_url":"https://api.github.com/repos/openfisca/openfisca-france/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openfisca/openfisca-france/downloads","issues_url":"https://api.github.com/repos/openfisca/openfisca-france/issues{/number}","pulls_url":"https://api.github.com/repos/openfisca/openfisca-france/pulls{/number}","milestones_url":"https://api.github.com/repos/openfisca/openfisca-france/milestones{/number}","notifications_url":"https://api.github.com/repos/openfisca/openfisca-france/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openfisca/openfisca-france/labels{/name}","releases_url":"https://api.github.com/repos/openfisca/openfisca-france/releases{/id}","created_at":"2013-12-29T15:15:09Z","updated_at":"2015-10-09T13:25:20Z","pushed_at":"2015-10-16T12:59:08Z","git_url":"git://github.com/openfisca/openfisca-france.git","ssh_url":"git@github.com:openfisca/openfisca-france.git","clone_url":"https://github.com/openfisca/openfisca-france.git","svn_url":"https://github.com/openfisca/openfisca-france","homepage":"http://www.openfisca.fr/","size":19490,"stargazers_count":36,"watchers_count":36,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":61,"forks":41,"open_issues":61,"watchers":36,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openfisca/openfisca-france/pulls/341"},"html":{"href":"https://github.com/openfisca/openfisca-france/pull/341"},"issue":{"href":"https://api.github.com/repos/openfisca/openfisca-france/issues/341"},"comments":{"href":"https://api.github.com/repos/openfisca/openfisca-france/issues/341/comments"},"review_comments":{"href":"https://api.github.com/repos/openfisca/openfisca-france/pulls/341/comments"},"review_comment":{"href":"https://api.github.com/repos/openfisca/openfisca-france/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openfisca/openfisca-france/pulls/341/commits"},"statuses":{"href":"https://api.github.com/repos/openfisca/openfisca-france/statuses/5bbc068554f74c73db1d3156e56e056ff1900353"}}}}