Title: Document the order to check chained functions · Issue #370 · datacamp/pythonwhat · GitHub
Open Graph Title: Document the order to check chained functions · Issue #370 · datacamp/pythonwhat
X Title: Document the order to check chained functions · Issue #370 · datacamp/pythonwhat
Description: In ch3ex6 of "Machine Learning for Time Series in Python", the student has to complete this line of code. missing_values = prices.isna().sum() The SCT to check this was Ex().multi( check_correct( check_object("missing_values").has_equal_...
Open Graph Description: In ch3ex6 of "Machine Learning for Time Series in Python", the student has to complete this line of code. missing_values = prices.isna().sum() The SCT to check this was Ex().multi( check_correct( c...
X Description: In ch3ex6 of "Machine Learning for Time Series in Python", the student has to complete this line of code. missing_values = prices.isna().sum() The SCT to check this was Ex().multi( check_...
Opengraph URL: https://github.com/datacamp/pythonwhat/issues/370
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Document the order to check chained functions","articleBody":"In [ch3ex6](https://www.datacamp.com/teach/editor/1536/edit/6571140900?branch=master) of \"Machine Learning for Time Series in Python\", the student has to complete this line of code.\r\n\r\n```python\r\nmissing_values = prices.isna().sum()\r\n```\r\n\r\nThe SCT to check this was\r\n\r\n```python\r\nEx().multi(\r\n check_correct(\r\n check_object(\"missing_values\").has_equal_value(), \r\n multi(\r\n check_function(\"prices.isna.sum\", signature=False), \r\n check_function(\"prices.isna\")\r\n )\r\n )\r\n)\r\n```\r\n\r\nThis gives a bad feedback message when the student types a different function to `is.na()`.\r\n\r\nFor example, the submission\r\n\r\n```python\r\nmissing_values = prices.isnaxxx().sum()\r\n```\r\n\r\nResults in the feedback\r\n\r\n```\r\nDid you call `prices.isna.sum()`?\r\n```\r\n\r\nThis is confusing: it ought to say\r\n\r\n```\r\nDid you call `prices.isna().sum()`?\r\n```\r\n\r\nA partial fix is to perform the checks in reverse order. That is **functions should be checked from left to right, not right to left**.\r\n\r\n```python\r\nEx().multi(\r\n check_correct(\r\n check_object(\"missing_values\").has_equal_value(), \r\n multi(\r\n check_function(\"prices.isna\"),\r\n check_function(\"prices.isna.sum\", signature=False)\r\n )\r\n )\r\n)\r\n```\r\n\r\nIn this case, the submission \r\n\r\n```python\r\nmissing_values = prices.isnaxxx().sum()\r\n```\r\n\r\ngives the feedback\r\n\r\n```\r\nDid you call `prices.isna()`?\r\n```\r\n\r\nIt isn't perfect though. The submission\r\n\r\n```python\r\nmissing_values = prices.isna().sumxxx()\r\n```\r\n\r\ngives the feedback\r\n\r\n```\r\nDid you call `prices.isna.sum()`?\r\n```\r\n\r\nSo a custom missing message needs to be provided.\r\n```python\r\nEx().multi(\r\n check_correct(\r\n check_object(\"missing_values\").has_equal_value(), \r\n multi(\r\n check_function(\"prices.isna\"),\r\n check_function(\"prices.isna.sum\", signature=False, missing_msg = \"Did you call `prices.isna().sum()`?\")\r\n )\r\n )\r\n)\r\n```\r\n\r\nSince this is a subtle problem, I think it needs documenting. Ideally, the feedback message also needs fixing so that parentheses are included where the intermediate element is a function.\r\n\r\n","author":{"url":"https://github.com/richierocks","@type":"Person","name":"richierocks"},"datePublished":"2019-01-10T14:22:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/370/pythonwhat/issues/370"}
| 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:8839b413-6f20-d3ee-4d44-f3a34a4c01f0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DC28:2006B6:7A76A40:A55099A:698CDD89 |
| html-safe-nonce | c6f5174b2454c82ac526ad525dc28e081bdc219e35b04818f3e8ddeb81e5a21f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzI4OjIwMDZCNjo3QTc2QTQwOkE1NTA5OUE6Njk4Q0REODkiLCJ2aXNpdG9yX2lkIjoiODk1OTYzODI0ODk2NDgwODA3MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 72dd34dbdcee717e702058a8099aed5348933311770fad7aa8f5df282418853f |
| hovercard-subject-tag | issue:397852727 |
| 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/datacamp/pythonwhat/370/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0078b79988758aa6469653806314ff34e9994d361304c074cd6264f626811ff3/datacamp/pythonwhat/issues/370 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0078b79988758aa6469653806314ff34e9994d361304c074cd6264f626811ff3/datacamp/pythonwhat/issues/370 |
| og:image:alt | In ch3ex6 of "Machine Learning for Time Series in Python", the student has to complete this line of code. missing_values = prices.isna().sum() The SCT to check this was Ex().multi( check_correct( c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | richierocks |
| hostname | github.com |
| expected-hostname | github.com |
| None | 640eeb7b6ff4d8d106235d228c0c286e82592d4d2403227b5b2b4fc5832297a4 |
| turbo-cache-control | no-preview |
| go-import | github.com/datacamp/pythonwhat git https://github.com/datacamp/pythonwhat.git |
| octolytics-dimension-user_id | 6276968 |
| octolytics-dimension-user_login | datacamp |
| octolytics-dimension-repository_id | 51361383 |
| octolytics-dimension-repository_nwo | datacamp/pythonwhat |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 51361383 |
| octolytics-dimension-repository_network_root_nwo | datacamp/pythonwhat |
| 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 | 3d444f0a47beeeac94cddbb51c91ab408befe8d4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width