From dfcf79a10b841d9ea0162403fba33675bca89cf6 Mon Sep 17 00:00:00 2001 From: Joel Nitta Date: Fri, 11 Dec 2020 17:56:50 +0900 Subject: [PATCH 1/5] Update python-novice-inflammation submodule --- python-novice-inflammation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-novice-inflammation b/python-novice-inflammation index 6c4b4a73..806e45b1 160000 --- a/python-novice-inflammation +++ b/python-novice-inflammation @@ -1 +1 @@ -Subproject commit 6c4b4a73b4f1fad1c5d170cf4cf3aaa8dbfc8e67 +Subproject commit 806e45b1cb6e7714f6ece9f2b1a8aed1e55812d8 From 5bab7872eeae3ea1ddf2dbf4151ee6c43c304db8 Mon Sep 17 00:00:00 2001 From: Joel Nitta Date: Fri, 11 Dec 2020 18:01:55 +0900 Subject: [PATCH 2/5] Run po4gitbook/update.sh to create po/python-novice-inflammation.pot --- po/python-novice-inflammation.pot | 11568 ++++++++++++++++++++++++++++ 1 file changed, 11568 insertions(+) create mode 100644 po/python-novice-inflammation.pot diff --git a/po/python-novice-inflammation.pot b/po/python-novice-inflammation.pot new file mode 100644 index 00000000..2df775b2 --- /dev/null +++ b/po/python-novice-inflammation.pot @@ -0,0 +1,11568 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:1 +# Front Matter +msgid "---\n" +"layout: page\n" +"title: \"Contributor Code of Conduct\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:5 +msgid "As contributors and maintainers of this project,\n" +"we pledge to follow the [Carpentry Code of Conduct][coc]." +msgstr "" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:8 +msgid "Instances of abusive, harassing, or otherwise unacceptable behavior\n" +"may be reported by following our [reporting guidelines][coc-reporting]." +msgstr "" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:11 +#: python-novice-inflammation/_episodes/01-intro.md:225 +#: python-novice-inflammation/_episodes/02-numpy.md:802 +#: python-novice-inflammation/_episodes/03-matplotlib.md:264 +#: python-novice-inflammation/_episodes/04-loop.md:416 +#: python-novice-inflammation/_episodes/05-lists.md:564 +#: python-novice-inflammation/_episodes/06-files.md:194 +#: python-novice-inflammation/_episodes/07-cond.md:508 +#: python-novice-inflammation/_episodes/08-func.md:932 +#: python-novice-inflammation/_episodes/09-errors.md:598 +#: python-novice-inflammation/_episodes/10-defensive.md:542 +#: python-novice-inflammation/_episodes/11-debugging.md:290 +#: python-novice-inflammation/_episodes/12-cmdline.md:1028 +#: python-novice-inflammation/_extras/extra_exercises.md:75 +#: python-novice-inflammation/_extras/figures.md:79 +#: python-novice-inflammation/bin/boilerplate/_episodes/01-introduction.md:14 +#: python-novice-inflammation/bin/boilerplate/_extras/discuss.md:6 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:79 +#: python-novice-inflammation/bin/boilerplate/_extras/guide.md:6 +#: python-novice-inflammation/bin/boilerplate/index.md:17 +#: python-novice-inflammation/bin/boilerplate/reference.md:9 +#: python-novice-inflammation/bin/boilerplate/setup.md:7 +#: python-novice-inflammation/index.md:50 +msgid "{% include links.md %}" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:1 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:1 +# header +msgid "# Contributing" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:3 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:3 +msgid "[The Carpentries][c-site] ([Software Carpentry][swc-site], [Data Carpentry][dc-site], and [Library Carpentry][lc-site]) are open source projects,\n" +"and we welcome contributions of all kinds:\n" +"new lessons,\n" +"fixes to existing material,\n" +"bug reports,\n" +"and reviews of proposed changes are all welcome." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:10 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:10 +# header +msgid "## Contributor Agreement" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:12 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:12 +msgid "By contributing,\n" +"you agree that we may redistribute your work under [our license](LICENSE.md).\n" +"In exchange,\n" +"we will address your issues and/or assess your change proposal as promptly as we can,\n" +"and help you become a member of our community.\n" +"Everyone involved in [The Carpentries][c-site]\n" +"agrees to abide by our [code of conduct](CODE_OF_CONDUCT.md)." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:20 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:20 +# header +msgid "## How to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:22 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:22 +msgid "The easiest way to get started is to file an issue\n" +"to tell us about a spelling mistake,\n" +"some awkward wording,\n" +"or a factual error.\n" +"This is a good way to introduce yourself\n" +"and to meet some of our community members." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:29 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:29 +# ordered list +msgid "1. If you do not have a [GitHub][github] account," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:30 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:30 +msgid " you can [send us comments by email][email].\n" +" However,\n" +" we will be able to respond more quickly if you use one of the other methods described below." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:34 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:34 +# ordered list +msgid "2. If you have a [GitHub][github] account," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:35 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:35 +msgid " or are willing to [create one][github-join],\n" +" but do not know how to use Git,\n" +" you can report problems or suggest improvements by [creating an issue][issues].\n" +" This allows us to assign the item to someone\n" +" and to respond to it in a threaded discussion." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:41 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:41 +# ordered list +msgid "3. If you are comfortable with Git," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:42 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:42 +msgid " and would like to add or change material,\n" +" you can submit a pull request (PR).\n" +" Instructions for doing this are [included below](#using-github)." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:46 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:46 +# header +msgid "## Where to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:48 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:48 +# ordered list +msgid "1. If you wish to change this lesson," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:49 +msgid " please work in ,\n" +" which can be viewed at ." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:52 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:52 +# ordered list +msgid "2. If you wish to change the example lesson," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:53 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:53 +msgid " please work in ,\n" +" which documents the format of our lessons\n" +" and can be viewed at ." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:57 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:57 +# ordered list +msgid "3. If you wish to change the template used for workshop websites," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:58 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:58 +msgid " please work in .\n" +" The home page of that repository explains how to set up workshop websites,\n" +" while the extra pages in \n" +" provide more background on our design choices." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:63 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:63 +# ordered list +msgid "4. If you wish to change CSS style files, tools," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:64 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:64 +msgid " or HTML boilerplate for lessons or workshops stored in `_includes` or `_layouts`,\n" +" please work in ." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:67 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:67 +# header +msgid "## What to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:69 +msgid "There are many ways to contribute,\n" +"from writing new exercises and improving existing ones\n" +"to updating or filling in the documentation\n" +"and submitting [bug reports][issues]\n" +"about things that don't work, aren't clear, or are missing.\n" +"If you are looking for ideas, please see the 'Issues' tab for\n" +"a list of issues associated with this repository,\n" +"or you may also look at the issues for [Data Carpentry][dc-issues],\n" +"[Software Carpentry][swc-issues], and [Library Carpentry][lc-issues] projects." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:79 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:79 +msgid "Comments on issues and reviews of pull requests are just as welcome:\n" +"we are smarter together than we are on our own.\n" +"Reviews from novices and newcomers are particularly valuable:\n" +"it's easy for people who have been using these lessons for a while\n" +"to forget how impenetrable some of this material can be,\n" +"so fresh eyes are always welcome." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:86 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:86 +# header +msgid "## What *Not* to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:88 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:88 +msgid "Our lessons already contain more material than we can cover in a typical workshop,\n" +"so we are usually *not* looking for more concepts or tools to add to them.\n" +"As a rule,\n" +"if you want to introduce a new idea,\n" +"you must (a) estimate how long it will take to teach\n" +"and (b) explain what you would take out to make room for it.\n" +"The first encourages contributors to be honest about requirements;\n" +"the second, to think hard about priorities." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:97 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:97 +msgid "We are also not looking for exercises or other material that only run on one platform.\n" +"Our workshops typically contain a mixture of Windows, macOS, and Linux users;\n" +"in order to be usable,\n" +"our lessons must run equally well on all three." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:102 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:102 +# header +msgid "## Using GitHub" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:104 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:104 +msgid "If you choose to contribute via GitHub, you may want to look at\n" +"[How to Contribute to an Open Source Project on GitHub][how-contribute].\n" +"To manage changes, we follow [GitHub flow][github-flow].\n" +"Each lesson has two maintainers who review issues and pull requests or encourage others to do so.\n" +"The maintainers are community volunteers and have final say over what gets merged into the lesson.\n" +"To use the web interface for contributing to a lesson:" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:111 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:111 +# ordered list +msgid "1. Fork the originating repository to your GitHub profile." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:112 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:112 +# ordered list +msgid "2. Within your version of the forked repository, move to the `gh-pages` branch and" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:113 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:113 +msgid "create a new branch for each significant change being made.\n" +"3. Navigate to the file(s) you wish to change within the new branches and make revisions as required.\n" +"4. Commit all changed files within the appropriate branches.\n" +"5. Create individual pull requests from each of your changed branches\n" +"to the `gh-pages` branch within the originating repository.\n" +"6. If you receive feedback, make changes using your issue-specific branches of the forked\n" +"repository and the pull requests will update automatically.\n" +"7. Repeat as needed until all feedback has been addressed." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:122 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:122 +msgid "When starting work, please make sure your clone of the originating `gh-pages` branch is up-to-date\n" +"before creating your own revision-specific branch(es) from there.\n" +"Additionally, please only work from your newly-created branch(es) and *not*\n" +"your clone of the originating `gh-pages` branch.\n" +"Lastly, published copies of all the lessons are available in the `gh-pages` branch of the originating\n" +"repository for reference while revising." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:129 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:129 +# header +msgid "## Other Resources" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:131 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:131 +msgid "General discussion of [Software Carpentry][swc-site] and [Data Carpentry][dc-site]\n" +"happens on the [discussion mailing list][discuss-list],\n" +"which everyone is welcome to join.\n" +"You can also [reach us by email][email]." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:136 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:136 +msgid "[email]: mailto:admin@software-carpentry.org\n" +"[dc-issues]: https://github.com/issues?q=user%3Adatacarpentry\n" +"[dc-lessons]: http://datacarpentry.org/lessons/\n" +"[dc-site]: http://datacarpentry.org/\n" +"[discuss-list]: https://carpentries.topicbox.com/groups/discuss\n" +"[github]: https://github.com\n" +"[github-flow]: https://guides.github.com/introduction/flow/\n" +"[github-join]: https://github.com/join\n" +"[how-contribute]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github\n" +"[issues]: https://guides.github.com/features/issues/\n" +"[swc-issues]: https://github.com/issues?q=user%3Aswcarpentry\n" +"[swc-lessons]: https://software-carpentry.org/lessons/\n" +"[swc-site]: https://software-carpentry.org/\n" +"[c-site]: https://carpentries.org/\n" +"[lc-site]: https://librarycarpentry.org/\n" +"[lc-issues]: https://github.com/issues?q=user%3Alibrarycarpentry" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:1 +# Front Matter +msgid "---\n" +"layout: page\n" +"title: \"Licenses\"\n" +"root: .\n" +"---" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:6 +# header +msgid "## Instructional Material" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:8 +msgid "All Software Carpentry, Data Carpentry, and Library Carpentry instructional material is\n" +"made available under the [Creative Commons Attribution\n" +"license][cc-by-human]. The following is a human-readable summary of\n" +"(and not a substitute for) the [full legal text of the CC BY 4.0\n" +"license][cc-by-legal]." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:14 +msgid "You are free:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:16 +# unordered list +msgid "* to **Share**---copy and redistribute the material in any medium or format" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:17 +# unordered list +msgid "* to **Adapt**---remix, transform, and build upon the material" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:19 +msgid "for any purpose, even commercially." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:21 +msgid "The licensor cannot revoke these freedoms as long as you follow the\n" +"license terms." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:24 +msgid "Under the following terms:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:26 +# unordered list +msgid "* **Attribution**---You must give appropriate credit (mentioning that" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:27 +msgid " your work is derived from work that is Copyright © Software\n" +" Carpentry and, where practical, linking to\n" +" http://software-carpentry.org/), provide a [link to the\n" +" license][cc-by-human], and indicate if changes were made. You may do\n" +" so in any reasonable manner, but not in any way that suggests the\n" +" licensor endorses you or your use." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:34 +msgid "**No additional restrictions**---You may not apply legal terms or\n" +"technological measures that legally restrict others from doing\n" +"anything the license permits. With the understanding that:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:38 +msgid "Notices:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:40 +# unordered list +msgid "* You do not have to comply with the license for elements of the" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:41 +msgid " material in the public domain or where your use is permitted by an\n" +" applicable exception or limitation.\n" +"* No warranties are given. The license may not give you all of the\n" +" permissions necessary for your intended use. For example, other\n" +" rights such as publicity, privacy, or moral rights may limit how you\n" +" use the material." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:48 +# header +msgid "## Software" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:50 +msgid "Except where otherwise noted, the example programs and other software\n" +"provided by Software Carpentry and Data Carpentry are made available under the\n" +"[OSI][osi]-approved\n" +"[MIT license][mit-license]." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:55 +msgid "Permission is hereby granted, free of charge, to any person obtaining\n" +"a copy of this software and associated documentation files (the\n" +"\"Software\"), to deal in the Software without restriction, including\n" +"without limitation the rights to use, copy, modify, merge, publish,\n" +"distribute, sublicense, and/or sell copies of the Software, and to\n" +"permit persons to whom the Software is furnished to do so, subject to\n" +"the following conditions:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:63 +msgid "The above copyright notice and this permission notice shall be\n" +"included in all copies or substantial portions of the Software." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:66 +msgid "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n" +"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n" +"MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n" +"NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n" +"LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n" +"OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n" +"WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:74 +# header +msgid "## Trademark" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:76 +msgid "\"Software Carpentry\" and \"Data Carpentry\" and their respective logos\n" +"are registered trademarks of [Community Initiatives][CI]." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:79 +msgid "[cc-by-human]: https://creativecommons.org/licenses/by/4.0/\n" +"[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode\n" +"[mit-license]: https://opensource.org/licenses/mit-license.html\n" +"[ci]: http://communityin.org/\n" +"[osi]: https://opensource.org" +msgstr "" + +#: python-novice-inflammation/README.md:1 +# header +msgid "# Programming with Python" +msgstr "" + +#: python-novice-inflammation/README.md:3 +msgid "[![GitHub release][shields_release]][swc_py_releases]\n" +"[![Create a Slack Account with us][create_slack_svg]][slack_heroku_invite]\n" +"[![Slack Status][slack_channel_status]][slack_channel_url]" +msgstr "" + +#: python-novice-inflammation/README.md:7 +msgid "An introduction to Python for non-programmers using inflammation data." +msgstr "" + +#: python-novice-inflammation/README.md:9 +# header +msgid "## About the Lesson" +msgstr "" + +#: python-novice-inflammation/README.md:11 +msgid "This lesson teaches novice programmers to write modular code to perform data analysis\n" +"using Python. The emphasis, however, is on teaching language-agnostic principles of\n" +"programming such as automation with loops and encapsulation with functions,\n" +"see [Best Practices for Scientific Computing][best-practices] and\n" +"[Good enough practices in scientific computing][good-practices] to learn more." +msgstr "" + +#: python-novice-inflammation/README.md:17 +msgid "The example used in this lesson analyses a set of 12 files with simulated inflammation\n" +"data collected from a trial for a new treatment for arthritis. Learners are shown\n" +"how it is better to automate analysis using functions instead of repeating analysis\n" +"steps manually." +msgstr "" + +#: python-novice-inflammation/README.md:22 +msgid "The rendered version of the lesson is available at:\n" +"." +msgstr "" + +#: python-novice-inflammation/README.md:25 +msgid "This lesson is also available in [R][R] and [MATLAB][MATLAB]." +msgstr "" + +#: python-novice-inflammation/README.md:27 +# header +msgid "## Episodes" +msgstr "" + +#: python-novice-inflammation/README.md:29 +msgid "| # | Episode | Time | Question(s) |\n" +"|--:|:---------|:----:|:------------|\n" +"| 1 | [Python Fundamentals][episode01] | 30 | What basic data types can I work with in Python?
How can I create a new variable in Python?
Can I change the value associated with a variable after I create it? |\n" +"| 2 | [Analyzing Patient Data][episode02] | 60 | How can I process tabular data files in Python? |\n" +"| 3 | [Visualizing Tabular Data][episode03] | 50 | How can I visualize tabular data in Python?
How can I group several plots together? |\n" +"| 4 | [Repeating Actions with Loops][episode04] | 30 | How can I do the same operations on many different values? |\n" +"| 5 | [Storing Multiple Values in Lists][episode05] | 30 | How can I store many values together? |\n" +"| 6 | [Analyzing Data from Multiple Files][episode06] | 20 | How can I do the same operations on many different files? |\n" +"| 7 | [Making Choices][episode07] | 30 | How can my programs do different things based on data values? |\n" +"| 8 | [Creating Functions][episode08] | 30 | How can I define new functions?
What’s the difference between defining and calling a function?
What happens when I call a function? |\n" +"| 9 | [Errors and Exceptions][episode09] | 30 | How does Python report errors?
How can I handle errors in Python programs? |\n" +"|10 | [Defensive Programming][episode10] | 30 | How can I make my programs more reliable? |\n" +"|11 | [Debugging][episode11] | 30 | How can I debug my program? |\n" +"|12 | [Command-Line Programs][episode12] | 30 | How can I write Python programs that will work like Unix command-line tools? |" +msgstr "" + +#: python-novice-inflammation/README.md:45 +#: python-novice-inflammation/bin/boilerplate/README.md:7 +# header +msgid "## Contributing" +msgstr "" + +#: python-novice-inflammation/README.md:46 +msgid "[![Travis Build Status][travis_svg]][travis_url]" +msgstr "" + +#: python-novice-inflammation/README.md:48 +msgid "We welcome all contributions to improve the lesson!\n" +"Maintainers will do their best to help you if you have any questions, concerns,\n" +"or experience any difficulties along the way." +msgstr "" + +#: python-novice-inflammation/README.md:52 +msgid "We'd like to ask you to familiarize yourself with our [Contribution Guide](CONTRIBUTING.md)\n" +"and have a look at the [more detailed guidelines][lesson-example] on proper formatting,\n" +"ways to render the lesson locally, and even how to write new episodes!" +msgstr "" + +#: python-novice-inflammation/README.md:56 +# header +msgid "## Maintainers" +msgstr "" + +#: python-novice-inflammation/README.md:58 +msgid "Lesson maintainers are [Trevor Bekolay][trevor_bekolay], [Maxim Belkin][maxim_belkin],\n" +"[Anne Fouilloux][anne_fouilloux], [Lauren Ko][lauren_ko], [Valentina Staneva][valentina_staneva], and [creator][swc_history] of Software Carpentry:\n" +"[Greg Wilson][greg_wilson]." +msgstr "" + +#: python-novice-inflammation/README.md:62 +#: python-novice-inflammation/bin/boilerplate/README.md:32 +# header +msgid "## Authors" +msgstr "" + +#: python-novice-inflammation/README.md:63 +msgid "A list of contributors to the lesson can be found in [AUTHORS](AUTHORS)." +msgstr "" + +#: python-novice-inflammation/README.md:65 +# header +msgid "## License" +msgstr "" + +#: python-novice-inflammation/README.md:66 +msgid "Instructional material from this lesson is made available under the\n" +"[Creative Commons Attribution][cc-by-human] ([CC BY 4.0][cc-by-legal]) license. Except where\n" +"otherwise noted, example programs and software included as part of this lesson are made available\n" +"under the [MIT license][mit-license]. For more information, see [LICENSE.md](LICENSE.md)." +msgstr "" + +#: python-novice-inflammation/README.md:71 +#: python-novice-inflammation/bin/boilerplate/README.md:36 +# header +msgid "## Citation" +msgstr "" + +#: python-novice-inflammation/README.md:72 +msgid "To cite this lesson, please consult with [CITATION](CITATION)." +msgstr "" + +#: python-novice-inflammation/README.md:74 +# header +msgid "## About Software Carpentry" +msgstr "" + +#: python-novice-inflammation/README.md:76 +msgid "Software Carpentry is a volunteer project that teaches basic computing skills to researchers since\n" +"1998. More information about Software Carpentry can be found [here][swc-about]." +msgstr "" + +#: python-novice-inflammation/README.md:79 +# header +msgid "## About The Carpentries" +msgstr "" + +#: python-novice-inflammation/README.md:81 +msgid "The Carpentries is a fiscally sponsored project of [Community Initiatives][community-initiatives], a\n" +"registered 501(c)3 non-profit organisation based in California, USA. We are a global community\n" +"teaching foundational computational and data science skills to researchers in academia, industry and\n" +"government. More information can be found [here][cp-about]." +msgstr "" + +#: python-novice-inflammation/README.md:86 +msgid "[lesson-example]: https://carpentries.github.io/lesson-example\n" +"[anne_fouilloux]: https://github.com/annefou\n" +"[lauren_ko]: https://github.com/ldko\n" +"[maxim_belkin]: https://github.com/maxim-belkin\n" +"[mike_trizna]: https://github.com/MikeTrizna\n" +"[trevor_bekolay]: http://software-carpentry.org/team/#bekolay_trevor\n" +"[valentina_staneva]: http://software-carpentry.org/team/#staneva_valentina\n" +"[greg_wilson]: https://github.com/gvwilson\n" +"[swc_history]: https://software-carpentry.org/scf/history/\n" +"[best-practices]: http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.1001745\n" +"[good-practices]: http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1005510\n" +"[R]: https://github.com/swcarpentry/r-novice-inflammation\n" +"[MATLAB]: https://github.com/swcarpentry/matlab-novice-inflammation\n" +"[shields_release]: https://img.shields.io/github/release/swcarpentry/python-novice-inflammation.svg\n" +"[swc_py_releases]: https://github.com/swcarpentry/python-novice-inflammation/releases\n" +"[create_slack_svg]: https://img.shields.io/badge/Create_Slack_Account-The_Carpentries-071159.svg\n" +"[slack_heroku_invite]: https://swc-slack-invite.herokuapp.com\n" +"[slack_channel_status]: https://img.shields.io/badge/Slack_Channel-swc--py--inflammation-E01563.svg\n" +"[slack_channel_url]: https://swcarpentry.slack.com/messages/C9Y0L6MF0\n" +"[travis_svg]: https://travis-ci.org/swcarpentry/python-novice-inflammation.svg?branch=gh-pages\n" +"[travis_url]: https://travis-ci.org/swcarpentry/python-novice-inflammation\n" +"[episode01]: https://swcarpentry.github.io/python-novice-inflammation/01-intro/index.html\n" +"[episode02]: https://swcarpentry.github.io/python-novice-inflammation/02-numpy/index.html\n" +"[episode03]: https://swcarpentry.github.io/python-novice-inflammation/03-matplotlib/index.html\n" +"[episode04]: https://swcarpentry.github.io/python-novice-inflammation/04-loop/index.html\n" +"[episode05]: https://swcarpentry.github.io/python-novice-inflammation/05-lists/index.html\n" +"[episode06]: https://swcarpentry.github.io/python-novice-inflammation/06-files/index.html\n" +"[episode07]: https://swcarpentry.github.io/python-novice-inflammation/07-cond/index.html\n" +"[episode08]: https://swcarpentry.github.io/python-novice-inflammation/08-func/index.html\n" +"[episode09]: https://swcarpentry.github.io/python-novice-inflammation/09-errors/index.html\n" +"[episode10]: https://swcarpentry.github.io/python-novice-inflammation/10-defensive/index.html\n" +"[episode11]: https://swcarpentry.github.io/python-novice-inflammation/11-debugging/index.html\n" +"[episode12]: https://swcarpentry.github.io/python-novice-inflammation/12-cmdline/index.html\n" +"[community-initiatives]: https://communityin.org\n" +"[cp-about]: https://carpentries.org/about\n" +"[swc-about]: https://software-carpentry.org/about/\n" +"[mit-license]: https://opensource.org/licenses/mit-license.html\n" +"[cc-by-human]: https://creativecommons.org/licenses/by/4.0/\n" +"[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:1 +# Front Matter +msgid "---\n" +"title: Python Fundamentals\n" +"teaching: 20\n" +"exercises: 10\n" +"questions:\n" +"- \"What basic data types can I work with in Python?\"\n" +"- \"How can I create a new variable in Python?\"\n" +"- \"Can I change the value associated with a variable after I create it?\"\n" +"objectives:\n" +"- \"Assign values to variables.\"\n" +"keypoints:\n" +"- \"Basic data types in Python include integers, strings, and floating-point numbers.\"\n" +"- \"Use `variable = value` to assign a value to a variable in order to record it in memory.\"\n" +"- \"Variables are created on demand whenever a value is assigned to them.\"\n" +"- \"Use `print(something)` to display the value of `something`.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:18 +# header +msgid "## Variables" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:20 +msgid "Any Python interpreter can be used as a calculator:\n" +"~~~\n" +"3 + 5 * 4\n" +"~~~\n" +"{: .language-python}\n" +"~~~\n" +"23\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:28 +#: python-novice-inflammation/_episodes/01-intro.md:87 +#: python-novice-inflammation/_episodes/01-intro.md:98 +#: python-novice-inflammation/_episodes/01-intro.md:110 +#: python-novice-inflammation/_episodes/01-intro.md:121 +#: python-novice-inflammation/_episodes/01-intro.md:135 +#: python-novice-inflammation/_episodes/02-numpy.md:67 +#: python-novice-inflammation/_episodes/02-numpy.md:135 +#: python-novice-inflammation/_episodes/02-numpy.md:150 +#: python-novice-inflammation/_episodes/02-numpy.md:191 +#: python-novice-inflammation/_episodes/02-numpy.md:214 +#: python-novice-inflammation/_episodes/02-numpy.md:224 +#: python-novice-inflammation/_episodes/02-numpy.md:276 +#: python-novice-inflammation/_episodes/02-numpy.md:296 +#: python-novice-inflammation/_episodes/02-numpy.md:317 +#: python-novice-inflammation/_episodes/02-numpy.md:333 +#: python-novice-inflammation/_episodes/02-numpy.md:382 +#: python-novice-inflammation/_episodes/02-numpy.md:415 +#: python-novice-inflammation/_episodes/02-numpy.md:433 +#: python-novice-inflammation/_episodes/02-numpy.md:463 +#: python-novice-inflammation/_episodes/02-numpy.md:476 +#: python-novice-inflammation/_episodes/02-numpy.md:495 +#: python-novice-inflammation/_episodes/04-loop.md:55 +#: python-novice-inflammation/_episodes/04-loop.md:86 +#: python-novice-inflammation/_episodes/04-loop.md:116 +#: python-novice-inflammation/_episodes/04-loop.md:136 +#: python-novice-inflammation/_episodes/04-loop.md:203 +#: python-novice-inflammation/_episodes/04-loop.md:241 +#: python-novice-inflammation/_episodes/04-loop.md:254 +#: python-novice-inflammation/_episodes/05-lists.md:38 +#: python-novice-inflammation/_episodes/05-lists.md:55 +#: python-novice-inflammation/_episodes/05-lists.md:75 +#: python-novice-inflammation/_episodes/05-lists.md:94 +#: python-novice-inflammation/_episodes/05-lists.md:244 +#: python-novice-inflammation/_episodes/05-lists.md:257 +#: python-novice-inflammation/_episodes/05-lists.md:268 +#: python-novice-inflammation/_episodes/05-lists.md:288 +#: python-novice-inflammation/_episodes/05-lists.md:307 +#: python-novice-inflammation/_episodes/05-lists.md:363 +#: python-novice-inflammation/_episodes/05-lists.md:498 +#: python-novice-inflammation/_episodes/05-lists.md:519 +#: python-novice-inflammation/_episodes/06-files.md:40 +#: python-novice-inflammation/_episodes/06-files.md:86 +#: python-novice-inflammation/_episodes/06-files.md:93 +#: python-novice-inflammation/_episodes/06-files.md:100 +#: python-novice-inflammation/_episodes/07-cond.md:46 +#: python-novice-inflammation/_episodes/07-cond.md:75 +#: python-novice-inflammation/_episodes/07-cond.md:96 +#: python-novice-inflammation/_episodes/07-cond.md:128 +#: python-novice-inflammation/_episodes/07-cond.md:141 +#: python-novice-inflammation/_episodes/07-cond.md:217 +#: python-novice-inflammation/_episodes/07-cond.md:237 +#: python-novice-inflammation/_episodes/08-func.md:93 +#: python-novice-inflammation/_episodes/08-func.md:115 +#: python-novice-inflammation/_episodes/08-func.md:136 +#: python-novice-inflammation/_episodes/08-func.md:248 +#: python-novice-inflammation/_episodes/08-func.md:268 +#: python-novice-inflammation/_episodes/08-func.md:287 +#: python-novice-inflammation/_episodes/08-func.md:304 +#: python-novice-inflammation/_episodes/08-func.md:319 +#: python-novice-inflammation/_episodes/08-func.md:366 +#: python-novice-inflammation/_episodes/08-func.md:401 +#: python-novice-inflammation/_episodes/08-func.md:425 +#: python-novice-inflammation/_episodes/08-func.md:483 +#: python-novice-inflammation/_episodes/08-func.md:506 +#: python-novice-inflammation/_episodes/08-func.md:536 +#: python-novice-inflammation/_episodes/08-func.md:553 +#: python-novice-inflammation/_episodes/08-func.md:576 +#: python-novice-inflammation/_episodes/08-func.md:585 +#: python-novice-inflammation/_episodes/09-errors.md:349 +#: python-novice-inflammation/_episodes/10-defensive.md:205 +#: python-novice-inflammation/_episodes/12-cmdline.md:51 +#: python-novice-inflammation/_episodes/12-cmdline.md:106 +#: python-novice-inflammation/_episodes/12-cmdline.md:131 +#: python-novice-inflammation/_episodes/12-cmdline.md:145 +#: python-novice-inflammation/_episodes/12-cmdline.md:279 +#: python-novice-inflammation/_episodes/12-cmdline.md:338 +#: python-novice-inflammation/_episodes/12-cmdline.md:349 +#: python-novice-inflammation/_episodes/12-cmdline.md:360 +#: python-novice-inflammation/_episodes/12-cmdline.md:423 +#: python-novice-inflammation/_episodes/12-cmdline.md:488 +#: python-novice-inflammation/_episodes/12-cmdline.md:586 +#: python-novice-inflammation/_episodes/12-cmdline.md:660 +#: python-novice-inflammation/_extras/additional_material.md:26 +#: python-novice-inflammation/_extras/additional_material.md:41 +#: python-novice-inflammation/_extras/additional_material.md:51 +#: python-novice-inflammation/_extras/additional_material.md:64 +#: python-novice-inflammation/_extras/additional_material.md:74 +#: python-novice-inflammation/_extras/additional_material.md:84 +#: python-novice-inflammation/_extras/additional_material.md:93 +#: python-novice-inflammation/_extras/additional_material.md:106 +#: python-novice-inflammation/_extras/additional_material.md:116 +#: python-novice-inflammation/_extras/discuss.md:109 +#: python-novice-inflammation/_extras/discuss.md:131 +#: python-novice-inflammation/_extras/discuss.md:145 +#: python-novice-inflammation/_extras/discuss.md:221 +#: python-novice-inflammation/_extras/discuss.md:252 +#: python-novice-inflammation/_extras/discuss.md:265 +# SC/DC Template label +msgid "{: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:30 +msgid "This is great but not very interesting.\n" +"To do anything useful with data, we need to assign its value to a _variable_.\n" +"In Python, we can [assign]({{ page.root }}/reference.html#assign) a value to a\n" +"[variable]({{ page.root }}/reference.html#variable), using the equals sign `=`.\n" +"For example, to assign value `60` to a variable `weight_kg`, we would execute:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:36 +# code block +msgid "~~~\n" +"weight_kg = 60\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:39 +#: python-novice-inflammation/_episodes/01-intro.md:67 +#: python-novice-inflammation/_episodes/01-intro.md:74 +#: python-novice-inflammation/_episodes/01-intro.md:82 +#: python-novice-inflammation/_episodes/01-intro.md:105 +#: python-novice-inflammation/_episodes/01-intro.md:130 +#: python-novice-inflammation/_episodes/02-numpy.md:43 +#: python-novice-inflammation/_episodes/02-numpy.md:56 +#: python-novice-inflammation/_episodes/02-numpy.md:115 +#: python-novice-inflammation/_episodes/02-numpy.md:124 +#: python-novice-inflammation/_episodes/02-numpy.md:145 +#: python-novice-inflammation/_episodes/02-numpy.md:186 +#: python-novice-inflammation/_episodes/02-numpy.md:209 +#: python-novice-inflammation/_episodes/02-numpy.md:219 +#: python-novice-inflammation/_episodes/02-numpy.md:268 +#: python-novice-inflammation/_episodes/02-numpy.md:287 +#: python-novice-inflammation/_episodes/02-numpy.md:328 +#: python-novice-inflammation/_episodes/02-numpy.md:372 +#: python-novice-inflammation/_episodes/02-numpy.md:410 +#: python-novice-inflammation/_episodes/02-numpy.md:428 +#: python-novice-inflammation/_episodes/02-numpy.md:451 +#: python-novice-inflammation/_episodes/02-numpy.md:471 +#: python-novice-inflammation/_episodes/02-numpy.md:485 +#: python-novice-inflammation/_episodes/03-matplotlib.md:28 +#: python-novice-inflammation/_episodes/03-matplotlib.md:40 +#: python-novice-inflammation/_episodes/03-matplotlib.md:53 +#: python-novice-inflammation/_episodes/03-matplotlib.md:61 +#: python-novice-inflammation/_episodes/03-matplotlib.md:109 +#: python-novice-inflammation/_episodes/04-loop.md:33 +#: python-novice-inflammation/_episodes/04-loop.md:47 +#: python-novice-inflammation/_episodes/04-loop.md:79 +#: python-novice-inflammation/_episodes/04-loop.md:108 +#: python-novice-inflammation/_episodes/04-loop.md:126 +#: python-novice-inflammation/_episodes/04-loop.md:146 +#: python-novice-inflammation/_episodes/04-loop.md:198 +#: python-novice-inflammation/_episodes/04-loop.md:233 +#: python-novice-inflammation/_episodes/04-loop.md:249 +#: python-novice-inflammation/_episodes/05-lists.md:33 +#: python-novice-inflammation/_episodes/05-lists.md:48 +#: python-novice-inflammation/_episodes/05-lists.md:67 +#: python-novice-inflammation/_episodes/05-lists.md:88 +#: python-novice-inflammation/_episodes/05-lists.md:102 +#: python-novice-inflammation/_episodes/05-lists.md:239 +#: python-novice-inflammation/_episodes/05-lists.md:251 +#: python-novice-inflammation/_episodes/05-lists.md:263 +#: python-novice-inflammation/_episodes/05-lists.md:282 +#: python-novice-inflammation/_episodes/05-lists.md:301 +#: python-novice-inflammation/_episodes/05-lists.md:355 +#: python-novice-inflammation/_episodes/05-lists.md:492 +#: python-novice-inflammation/_episodes/05-lists.md:512 +#: python-novice-inflammation/_episodes/06-files.md:21 +#: python-novice-inflammation/_episodes/06-files.md:33 +#: python-novice-inflammation/_episodes/06-files.md:81 +#: python-novice-inflammation/_episodes/07-cond.md:40 +#: python-novice-inflammation/_episodes/07-cond.md:69 +#: python-novice-inflammation/_episodes/07-cond.md:91 +#: python-novice-inflammation/_episodes/07-cond.md:123 +#: python-novice-inflammation/_episodes/07-cond.md:136 +#: python-novice-inflammation/_episodes/07-cond.md:160 +#: python-novice-inflammation/_episodes/07-cond.md:177 +#: python-novice-inflammation/_episodes/07-cond.md:187 +#: python-novice-inflammation/_episodes/07-cond.md:195 +#: python-novice-inflammation/_episodes/07-cond.md:212 +#: python-novice-inflammation/_episodes/07-cond.md:232 +#: python-novice-inflammation/_episodes/08-func.md:55 +#: python-novice-inflammation/_episodes/08-func.md:78 +#: python-novice-inflammation/_episodes/08-func.md:110 +#: python-novice-inflammation/_episodes/08-func.md:131 +#: python-novice-inflammation/_episodes/08-func.md:174 +#: python-novice-inflammation/_episodes/08-func.md:191 +#: python-novice-inflammation/_episodes/08-func.md:210 +#: python-novice-inflammation/_episodes/08-func.md:229 +#: python-novice-inflammation/_episodes/08-func.md:242 +#: python-novice-inflammation/_episodes/08-func.md:257 +#: python-novice-inflammation/_episodes/08-func.md:281 +#: python-novice-inflammation/_episodes/08-func.md:299 +#: python-novice-inflammation/_episodes/08-func.md:314 +#: python-novice-inflammation/_episodes/08-func.md:338 +#: python-novice-inflammation/_episodes/08-func.md:350 +#: python-novice-inflammation/_episodes/08-func.md:358 +#: python-novice-inflammation/_episodes/08-func.md:387 +#: python-novice-inflammation/_episodes/08-func.md:414 +#: python-novice-inflammation/_episodes/08-func.md:432 +#: python-novice-inflammation/_episodes/08-func.md:466 +#: python-novice-inflammation/_episodes/08-func.md:477 +#: python-novice-inflammation/_episodes/08-func.md:496 +#: python-novice-inflammation/_episodes/08-func.md:526 +#: python-novice-inflammation/_episodes/08-func.md:547 +#: python-novice-inflammation/_episodes/08-func.md:561 +#: python-novice-inflammation/_episodes/08-func.md:594 +#: python-novice-inflammation/_episodes/08-func.md:633 +#: python-novice-inflammation/_episodes/09-errors.md:57 +#: python-novice-inflammation/_episodes/09-errors.md:156 +#: python-novice-inflammation/_episodes/09-errors.md:181 +#: python-novice-inflammation/_episodes/09-errors.md:235 +#: python-novice-inflammation/_episodes/09-errors.md:261 +#: python-novice-inflammation/_episodes/09-errors.md:282 +#: python-novice-inflammation/_episodes/09-errors.md:309 +#: python-novice-inflammation/_episodes/09-errors.md:342 +#: python-novice-inflammation/_episodes/09-errors.md:381 +#: python-novice-inflammation/_episodes/09-errors.md:416 +#: python-novice-inflammation/_episodes/10-defensive.md:78 +#: python-novice-inflammation/_episodes/10-defensive.md:144 +#: python-novice-inflammation/_episodes/10-defensive.md:151 +#: python-novice-inflammation/_episodes/10-defensive.md:173 +#: python-novice-inflammation/_episodes/10-defensive.md:200 +#: python-novice-inflammation/_episodes/10-defensive.md:213 +#: python-novice-inflammation/_episodes/10-defensive.md:313 +#: python-novice-inflammation/_episodes/10-defensive.md:344 +#: python-novice-inflammation/_episodes/10-defensive.md:360 +#: python-novice-inflammation/_episodes/10-defensive.md:387 +#: python-novice-inflammation/_episodes/10-defensive.md:414 +#: python-novice-inflammation/_episodes/10-defensive.md:433 +#: python-novice-inflammation/_episodes/10-defensive.md:440 +#: python-novice-inflammation/_episodes/12-cmdline.md:89 +#: python-novice-inflammation/_episodes/12-cmdline.md:114 +#: python-novice-inflammation/_episodes/12-cmdline.md:173 +#: python-novice-inflammation/_episodes/12-cmdline.md:208 +#: python-novice-inflammation/_episodes/12-cmdline.md:408 +#: python-novice-inflammation/_episodes/12-cmdline.md:475 +#: python-novice-inflammation/_episodes/12-cmdline.md:542 +#: python-novice-inflammation/_episodes/12-cmdline.md:569 +#: python-novice-inflammation/_episodes/12-cmdline.md:647 +#: python-novice-inflammation/_extras/additional_material.md:18 +#: python-novice-inflammation/_extras/additional_material.md:59 +#: python-novice-inflammation/_extras/additional_material.md:69 +#: python-novice-inflammation/_extras/additional_material.md:79 +#: python-novice-inflammation/_extras/additional_material.md:88 +#: python-novice-inflammation/_extras/additional_material.md:101 +#: python-novice-inflammation/_extras/additional_material.md:111 +#: python-novice-inflammation/_extras/discuss.md:30 +#: python-novice-inflammation/_extras/discuss.md:94 +#: python-novice-inflammation/_extras/discuss.md:126 +#: python-novice-inflammation/_extras/discuss.md:140 +#: python-novice-inflammation/_extras/discuss.md:187 +#: python-novice-inflammation/_extras/discuss.md:202 +#: python-novice-inflammation/_extras/discuss.md:214 +#: python-novice-inflammation/_extras/discuss.md:246 +#: python-novice-inflammation/_extras/discuss.md:260 +#: python-novice-inflammation/_extras/discuss.md:276 +#: python-novice-inflammation/_extras/discuss.md:312 +#: python-novice-inflammation/_extras/discuss.md:325 +#: python-novice-inflammation/_extras/discuss.md:342 +msgid "{: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:41 +msgid "From now on, whenever we use `weight_kg`, Python will substitute the value we assigned to\n" +"it. In layman's terms, **a variable is a name for a value**." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:44 +msgid "In Python, variable names:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:46 +# unordered list +msgid " - can include letters, digits, and underscores" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:47 +# unordered list +msgid " - cannot start with a digit" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:48 +# unordered list +msgid " - are [case sensitive]({{ page.root }}/reference.html#case-sensitive)." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:50 +msgid "This means that, for example:\n" +" - `weight0` is a valid variable name, whereas `0weight` is not\n" +" - `weight` and `Weight` are different variables" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:54 +# header +msgid "## Types of data" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:55 +msgid "Python knows various types of data. Three common ones are:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:57 +# unordered list +msgid "* integer numbers" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:58 +# unordered list +msgid "* floating point numbers, and" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:59 +# unordered list +msgid "* strings." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:61 +msgid "In the example above, variable `weight_kg` has an integer value of `60`.\n" +"To create a variable with a floating point value, we can execute:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:64 +# code block +msgid "~~~\n" +"weight_kg = 60.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:69 +msgid "And to create a string, we add single or double quotes around some text, for example:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:71 +# code block +msgid "~~~\n" +"weight_kg_text = 'weight in kilograms:'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:76 +# header +msgid "## Using Variables in Python" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:77 +msgid "To display the value of a variable to the screen in Python, we can use the `print` function:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:79 +# code block +msgid "~~~\n" +"print(weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:84 +#: python-novice-inflammation/_episodes/01-intro.md:118 +# code block +msgid "~~~\n" +"60.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:89 +msgid "We can display multiple things at once using only one `print` command:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:91 +# code block +msgid "~~~\n" +"print(weight_kg_text, weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:94 +msgid "{: .language-python}\n" +"~~~\n" +"weight in kilograms: 60.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:100 +msgid "Moreover, we can do arithmetic with variables right inside the `print` function:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:102 +# code block +msgid "~~~\n" +"print('weight in pounds:', 2.2 * weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:107 +# code block +msgid "~~~\n" +"weight in pounds: 132.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:112 +msgid "The above command, however, did not change the value of `weight_kg`:\n" +"~~~\n" +"print(weight_kg)\n" +"~~~\n" +"{: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:123 +msgid "To change the value of the `weight_kg` variable, we have to\n" +"**assign** `weight_kg` a new value using the equals `=` sign:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:126 +# code block +msgid "~~~\n" +"weight_kg = 65.0\n" +"print('weight in kilograms is now:', weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:132 +# code block +msgid "~~~\n" +"weight in kilograms is now: 65.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:137 +# blockquote, which can be cascaded +msgid "> ## Variables as Sticky Notes" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:138 +msgid ">\n" +"> A variable is analogous to a sticky note with a name written on it:\n" +"> assigning a value to a variable is like putting that sticky note on a particular value.\n" +">\n" +"> ![Value of 65.0 with weight_kg label stuck on it](../fig/python-sticky-note-variables-01.svg)\n" +">\n" +"> This means that assigning a value to one variable does **not** change\n" +"> values of other variables.\n" +"> For example, let's store the subject's weight in pounds in its own variable:\n" +">\n" +"> ~~~\n" +"> # There are 2.2 pounds per kilogram\n" +"> weight_lb = 2.2 * weight_kg\n" +"> print(weight_kg_text, weight_kg, 'and in pounds:', weight_lb)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> weight in kilograms: 65.0 and in pounds: 143.0\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:158 +#: python-novice-inflammation/_episodes/01-intro.md:173 +#: python-novice-inflammation/_episodes/02-numpy.md:175 +#: python-novice-inflammation/_episodes/02-numpy.md:354 +#: python-novice-inflammation/_episodes/02-numpy.md:516 +#: python-novice-inflammation/_episodes/02-numpy.md:632 +#: python-novice-inflammation/_episodes/02-numpy.md:706 +#: python-novice-inflammation/_episodes/02-numpy.md:725 +#: python-novice-inflammation/_episodes/04-loop.md:184 +#: python-novice-inflammation/_episodes/04-loop.md:336 +#: python-novice-inflammation/_episodes/04-loop.md:401 +#: python-novice-inflammation/_episodes/05-lists.md:144 +#: python-novice-inflammation/_episodes/05-lists.md:160 +#: python-novice-inflammation/_episodes/05-lists.md:198 +#: python-novice-inflammation/_episodes/05-lists.md:208 +#: python-novice-inflammation/_episodes/05-lists.md:218 +#: python-novice-inflammation/_episodes/05-lists.md:383 +#: python-novice-inflammation/_episodes/05-lists.md:424 +#: python-novice-inflammation/_episodes/05-lists.md:441 +#: python-novice-inflammation/_episodes/05-lists.md:460 +#: python-novice-inflammation/_episodes/07-cond.md:378 +#: python-novice-inflammation/_episodes/07-cond.md:427 +#: python-novice-inflammation/_episodes/07-cond.md:436 +#: python-novice-inflammation/_episodes/08-func.md:666 +#: python-novice-inflammation/_episodes/08-func.md:729 +#: python-novice-inflammation/_episodes/10-defensive.md:504 +#: python-novice-inflammation/_episodes/10-defensive.md:514 +#: python-novice-inflammation/_episodes/11-debugging.md:279 +#: python-novice-inflammation/_episodes/12-cmdline.md:679 +#: python-novice-inflammation/_episodes/12-cmdline.md:689 +#: python-novice-inflammation/_episodes/12-cmdline.md:744 +#: python-novice-inflammation/_episodes/12-cmdline.md:1015 +#: python-novice-inflammation/_episodes/12-cmdline.md:1025 +# SC/DC Template label +msgid "> {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:159 +msgid ">\n" +"> ![Value of 65.0 with weight_kg label stuck on it, and value of 143.0 with weight_lb label stuck on it](../fig/python-sticky-note-variables-02.svg)\n" +">\n" +"> Let's now change `weight_kg`:\n" +">\n" +"> ~~~\n" +"> weight_kg = 100.0\n" +"> print('weight in kilograms is now:', weight_kg, 'and weight in pounds is still:', weight_lb)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> weight in kilograms is now: 100.0 and weight in pounds is still: 143.0\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:174 +msgid ">\n" +"> ![Value of 100.0 with label weight_kg stuck on it, and value of 143.0 with label weight_lb stuck on it](../fig/python-sticky-note-variables-03.svg)\n" +">\n" +"> Since `weight_lb` doesn't \"remember\" where its value comes from,\n" +"> it is not updated when we change `weight_kg`." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:179 +#: python-novice-inflammation/_episodes/02-numpy.md:103 +#: python-novice-inflammation/_episodes/02-numpy.md:179 +#: python-novice-inflammation/_episodes/02-numpy.md:256 +#: python-novice-inflammation/_episodes/02-numpy.md:359 +#: python-novice-inflammation/_episodes/02-numpy.md:397 +#: python-novice-inflammation/_episodes/04-loop.md:188 +#: python-novice-inflammation/_episodes/05-lists.md:166 +#: python-novice-inflammation/_episodes/05-lists.md:222 +#: python-novice-inflammation/_episodes/05-lists.md:230 +#: python-novice-inflammation/_episodes/07-cond.md:112 +#: python-novice-inflammation/_episodes/07-cond.md:147 +#: python-novice-inflammation/_episodes/09-errors.md:104 +#: python-novice-inflammation/_episodes/09-errors.md:224 +#: python-novice-inflammation/_episodes/11-debugging.md:202 +#: python-novice-inflammation/_episodes/12-cmdline.md:32 +#: python-novice-inflammation/_episodes/12-cmdline.md:307 +#: python-novice-inflammation/_episodes/12-cmdline.md:321 +#: python-novice-inflammation/_episodes/12-cmdline.md:437 +# SC/DC Template label +msgid "{: .callout}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:182 +# blockquote, which can be cascaded +msgid "> ## Check Your Understanding" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:183 +msgid ">\n" +"> What values do the variables `mass` and `age` have after each of the following statements?\n" +"> Test your answer by executing the lines.\n" +">\n" +"> ~~~\n" +"> mass = 47.5\n" +"> age = 122\n" +"> mass = mass * 2.0\n" +"> age = age - 20\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > `mass` holds a value of 47.5, `age` does not exist\n" +"> > `mass` still holds a value of 47.5, `age` holds a value of 122\n" +"> > `mass` now has a value of 95.0, `age`'s value is still 122\n" +"> > `mass` still has a value of 95.0, `age` now holds 102\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:203 +#: python-novice-inflammation/_episodes/01-intro.md:222 +#: python-novice-inflammation/_episodes/02-numpy.md:529 +#: python-novice-inflammation/_episodes/02-numpy.md:540 +#: python-novice-inflammation/_episodes/02-numpy.md:548 +#: python-novice-inflammation/_episodes/02-numpy.md:573 +#: python-novice-inflammation/_episodes/02-numpy.md:590 +#: python-novice-inflammation/_episodes/02-numpy.md:661 +#: python-novice-inflammation/_episodes/02-numpy.md:682 +#: python-novice-inflammation/_episodes/02-numpy.md:743 +#: python-novice-inflammation/_episodes/02-numpy.md:752 +#: python-novice-inflammation/_episodes/02-numpy.md:799 +#: python-novice-inflammation/_episodes/03-matplotlib.md:137 +#: python-novice-inflammation/_episodes/03-matplotlib.md:158 +#: python-novice-inflammation/_episodes/03-matplotlib.md:169 +#: python-novice-inflammation/_episodes/03-matplotlib.md:210 +#: python-novice-inflammation/_episodes/03-matplotlib.md:224 +#: python-novice-inflammation/_episodes/03-matplotlib.md:261 +#: python-novice-inflammation/_episodes/04-loop.md:292 +#: python-novice-inflammation/_episodes/04-loop.md:319 +#: python-novice-inflammation/_episodes/04-loop.md:349 +#: python-novice-inflammation/_episodes/04-loop.md:368 +#: python-novice-inflammation/_episodes/04-loop.md:413 +#: python-novice-inflammation/_episodes/05-lists.md:333 +#: python-novice-inflammation/_episodes/05-lists.md:400 +#: python-novice-inflammation/_episodes/05-lists.md:479 +#: python-novice-inflammation/_episodes/05-lists.md:559 +#: python-novice-inflammation/_episodes/06-files.md:136 +#: python-novice-inflammation/_episodes/07-cond.md:271 +#: python-novice-inflammation/_episodes/07-cond.md:335 +#: python-novice-inflammation/_episodes/07-cond.md:348 +#: python-novice-inflammation/_episodes/07-cond.md:358 +#: python-novice-inflammation/_episodes/07-cond.md:404 +#: python-novice-inflammation/_episodes/07-cond.md:480 +#: python-novice-inflammation/_episodes/07-cond.md:503 +#: python-novice-inflammation/_episodes/08-func.md:674 +#: python-novice-inflammation/_episodes/08-func.md:709 +#: python-novice-inflammation/_episodes/08-func.md:737 +#: python-novice-inflammation/_episodes/08-func.md:756 +#: python-novice-inflammation/_episodes/08-func.md:781 +#: python-novice-inflammation/_episodes/08-func.md:802 +#: python-novice-inflammation/_episodes/08-func.md:836 +#: python-novice-inflammation/_episodes/08-func.md:885 +#: python-novice-inflammation/_episodes/08-func.md:921 +#: python-novice-inflammation/_episodes/09-errors.md:499 +#: python-novice-inflammation/_episodes/09-errors.md:529 +#: python-novice-inflammation/_episodes/09-errors.md:571 +#: python-novice-inflammation/_episodes/09-errors.md:595 +#: python-novice-inflammation/_episodes/10-defensive.md:488 +#: python-novice-inflammation/_episodes/10-defensive.md:539 +#: python-novice-inflammation/_episodes/11-debugging.md:287 +#: python-novice-inflammation/_episodes/12-cmdline.md:724 +#: python-novice-inflammation/_episodes/12-cmdline.md:764 +#: python-novice-inflammation/_episodes/12-cmdline.md:808 +#: python-novice-inflammation/_episodes/12-cmdline.md:859 +#: python-novice-inflammation/_episodes/12-cmdline.md:905 +#: python-novice-inflammation/_episodes/12-cmdline.md:949 +#: python-novice-inflammation/_episodes/12-cmdline.md:998 +#: python-novice-inflammation/_extras/extra_exercises.md:48 +#: python-novice-inflammation/_extras/extra_exercises.md:72 +#: python-novice-inflammation/setup.md:71 +#: python-novice-inflammation/setup.md:82 +#: python-novice-inflammation/setup.md:91 +#: python-novice-inflammation/setup.md:98 +# SC/DC Template label +msgid "> {: .solution}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:204 +#: python-novice-inflammation/_episodes/01-intro.md:223 +#: python-novice-inflammation/_episodes/02-numpy.md:574 +#: python-novice-inflammation/_episodes/02-numpy.md:591 +#: python-novice-inflammation/_episodes/02-numpy.md:683 +#: python-novice-inflammation/_episodes/02-numpy.md:800 +#: python-novice-inflammation/_episodes/03-matplotlib.md:170 +#: python-novice-inflammation/_episodes/03-matplotlib.md:211 +#: python-novice-inflammation/_episodes/03-matplotlib.md:225 +#: python-novice-inflammation/_episodes/03-matplotlib.md:262 +#: python-novice-inflammation/_episodes/04-loop.md:293 +#: python-novice-inflammation/_episodes/04-loop.md:320 +#: python-novice-inflammation/_episodes/04-loop.md:350 +#: python-novice-inflammation/_episodes/04-loop.md:369 +#: python-novice-inflammation/_episodes/04-loop.md:414 +#: python-novice-inflammation/_episodes/05-lists.md:334 +#: python-novice-inflammation/_episodes/05-lists.md:401 +#: python-novice-inflammation/_episodes/05-lists.md:480 +#: python-novice-inflammation/_episodes/05-lists.md:560 +#: python-novice-inflammation/_episodes/06-files.md:137 +#: python-novice-inflammation/_episodes/06-files.md:192 +#: python-novice-inflammation/_episodes/07-cond.md:272 +#: python-novice-inflammation/_episodes/07-cond.md:296 +#: python-novice-inflammation/_episodes/07-cond.md:315 +#: python-novice-inflammation/_episodes/07-cond.md:359 +#: python-novice-inflammation/_episodes/07-cond.md:405 +#: python-novice-inflammation/_episodes/07-cond.md:481 +#: python-novice-inflammation/_episodes/07-cond.md:504 +#: python-novice-inflammation/_episodes/08-func.md:675 +#: python-novice-inflammation/_episodes/08-func.md:710 +#: python-novice-inflammation/_episodes/08-func.md:738 +#: python-novice-inflammation/_episodes/08-func.md:757 +#: python-novice-inflammation/_episodes/08-func.md:782 +#: python-novice-inflammation/_episodes/08-func.md:803 +#: python-novice-inflammation/_episodes/08-func.md:837 +#: python-novice-inflammation/_episodes/08-func.md:886 +#: python-novice-inflammation/_episodes/08-func.md:922 +#: python-novice-inflammation/_episodes/08-func.md:930 +#: python-novice-inflammation/_episodes/09-errors.md:500 +#: python-novice-inflammation/_episodes/09-errors.md:530 +#: python-novice-inflammation/_episodes/09-errors.md:572 +#: python-novice-inflammation/_episodes/09-errors.md:596 +#: python-novice-inflammation/_episodes/10-defensive.md:489 +#: python-novice-inflammation/_episodes/10-defensive.md:540 +#: python-novice-inflammation/_episodes/11-debugging.md:247 +#: python-novice-inflammation/_episodes/11-debugging.md:288 +#: python-novice-inflammation/_episodes/12-cmdline.md:725 +#: python-novice-inflammation/_episodes/12-cmdline.md:765 +#: python-novice-inflammation/_episodes/12-cmdline.md:809 +#: python-novice-inflammation/_episodes/12-cmdline.md:860 +#: python-novice-inflammation/_episodes/12-cmdline.md:906 +#: python-novice-inflammation/_episodes/12-cmdline.md:950 +#: python-novice-inflammation/_episodes/12-cmdline.md:999 +#: python-novice-inflammation/_episodes/12-cmdline.md:1026 +#: python-novice-inflammation/_extras/discuss.md:176 +#: python-novice-inflammation/_extras/discuss.md:357 +#: python-novice-inflammation/_extras/discuss.md:362 +#: python-novice-inflammation/_extras/discuss.md:369 +#: python-novice-inflammation/_extras/discuss.md:375 +#: python-novice-inflammation/_extras/discuss.md:381 +#: python-novice-inflammation/_extras/extra_exercises.md:49 +#: python-novice-inflammation/_extras/extra_exercises.md:73 +# SC/DC Template label +msgid "{: .challenge}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:206 +# blockquote, which can be cascaded +msgid "> ## Sorting Out References" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:207 +msgid ">\n" +"> What does the following program print out?\n" +">\n" +"> ~~~\n" +"> first, second = 'Grace', 'Hopper'\n" +"> third, fourth = second, first\n" +"> print(third, fourth)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > Hopper Grace\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:1 +# Front Matter +msgid "---\n" +"title: Analyzing Patient Data\n" +"teaching: 40\n" +"exercises: 20\n" +"questions:\n" +"- \"How can I process tabular data files in Python?\"\n" +"objectives:\n" +"- \"Explain what a library is and what libraries are used for.\"\n" +"- \"Import a Python library and use the functions it contains.\"\n" +"- \"Read tabular data from a file into a program.\"\n" +"- \"Select individual values and subsections from data.\"\n" +"- \"Perform operations on arrays of data.\"\n" +"keypoints:\n" +"- \"Import a library into a program using `import libraryname`.\"\n" +"- \"Use the `numpy` library to work with arrays in Python.\"\n" +"- \"The expression `array.shape` gives the shape of an array.\"\n" +"- \"Use `array[x, y]` to select a single element from a 2D array.\"\n" +"- \"Array indices start at 0, not 1.\"\n" +"- \"Use `low:high` to specify a `slice` that includes the indices from `low` to `high-1`.\"\n" +"- \"Use `# some kind of explanation` to add comments to programs.\"\n" +"- \"Use `numpy.mean(array)`, `numpy.max(array)`, and `numpy.min(array)` to calculate simple statistics.\"\n" +"- \"Use `numpy.mean(array, axis=0)` or `numpy.mean(array, axis=1)` to calculate statistics across the specified axis.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:25 +msgid "Words are useful, but what's more useful are the sentences and stories we build with them.\n" +"Similarly, while a lot of powerful, general tools are built into Python,\n" +"specialized tools built up from these basic units live in\n" +"[libraries]({{ page.root }}/reference.html#library)\n" +"that can be called upon when needed." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:31 +# header +msgid "## Loading data into Python" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:33 +msgid "To begin processing inflammation data, we need to load it into Python.\n" +"We can do that using a library called\n" +"[NumPy](http://docs.scipy.org/doc/numpy/ \"NumPy Documentation\"), which stands for Numerical Python.\n" +"In general, you should use this library when you want to do fancy things with lots of numbers,\n" +"especially if you have matrices or arrays. To tell Python that we'd like to start using NumPy,\n" +"we need to [import]({{ page.root }}/reference.html#import) it:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:40 +#: python-novice-inflammation/_episodes/07-cond.md:157 +# code block +msgid "~~~\n" +"import numpy\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:45 +msgid "Importing a library is like getting a piece of lab equipment out of a storage locker and setting it\n" +"up on the bench. Libraries provide additional functionality to the basic Python package, much like\n" +"a new piece of equipment adds functionality to a lab space. Just like in the lab, importing too\n" +"many libraries can sometimes complicate and slow down your programs - so we only import what we\n" +"need for each program." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:51 +msgid "Once we've imported the library, we can ask the library to read our data file for us:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:53 +# code block +msgid "~~~\n" +"numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:58 +#: python-novice-inflammation/_episodes/08-func.md:416 +# code block +msgid "~~~\n" +"array([[ 0., 0., 1., ..., 3., 0., 0.],\n" +" [ 0., 1., 2., ..., 1., 0., 1.],\n" +" [ 0., 1., 1., ..., 2., 1., 1.],\n" +" ...,\n" +" [ 0., 1., 1., ..., 1., 1., 1.],\n" +" [ 0., 0., 0., ..., 0., 2., 0.],\n" +" [ 0., 0., 1., ..., 1., 1., 0.]])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:69 +msgid "The expression `numpy.loadtxt(...)` is a [function call]({{ page.root }}/reference.html#function-call)\n" +"that asks Python to run the [function]({{ page.root }}/reference.html#function) `loadtxt` which\n" +"belongs to the `numpy` library. This [dotted notation]({{ page.root }}/reference.html#dotted-notation)\n" +"is used everywhere in Python: the thing that appears before the dot contains the thing that\n" +"appears after." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:75 +msgid "As an example, John Smith is the John that belongs to the Smith family.\n" +"We could use the dot notation to write his name `smith.john`,\n" +"just as `loadtxt` is a function that belongs to the `numpy` library." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:79 +msgid "`numpy.loadtxt` has two [parameters]({{ page.root }}/reference.html#parameter): the name of the file\n" +"we want to read and the [delimiter]({{ page.root }}/reference.html#delimiter) that separates values on\n" +"a line. These both need to be character strings (or [strings]({{ page.root }}/reference.html#string)\n" +"for short), so we put them in quotes." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:84 +msgid "Since we haven't told it to do anything else with the function's output,\n" +"the [notebook]({{ page.root }}/reference.html#notebook) displays it.\n" +"In this case,\n" +"that output is the data we just loaded.\n" +"By default,\n" +"only a few rows and columns are shown\n" +"(with `...` to omit elements when displaying big arrays).\n" +"Note that, to save space when displaying NumPy arrays, Python does not show us trailing zeros, so `1.0` becomes `1.`." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:93 +# blockquote, which can be cascaded +msgid "> ## Importing libraries with shortcuts" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:94 +msgid ">\n" +"> In this lesson we use the `import numpy` [syntax]({{ page.root }}/reference.html#syntax) to import NumPy.\n" +"> However, shortcuts such as `import numpy as np` are frequently used. Importing NumPy this way means that after the\n" +"> inital import, rather than writing `numpy.loadtxt(...)`, you can now write `np.loadtxt(...)`. Some\n" +"> people prefer this as it is quicker to type and results in shorter lines of code - especially for libraries\n" +"> with long names! You will frequently see Python code online using a NumPy function with `np`, and it's\n" +"> because they've used this shortcut. It makes no difference which approach you choose to take, but you must be\n" +"> consistent as if you use `import numpy as np` then `numpy.loadtxt(...)` will not work, and you must use `np.loadtxt(...)`\n" +"> instead. Because of this, when working with other people it is important you agree on how libraries are imported." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:105 +msgid "Our call to `numpy.loadtxt` read our file\n" +"but didn't save the data in memory.\n" +"To do that,\n" +"we need to assign the array to a variable. In a similar manner to how we assign a single\n" +"value to a variable, we can also assign an array of values to a variable using the same syntax.\n" +"Let's re-run `numpy.loadtxt` and save the returned data:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:112 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:117 +msgid "This statement doesn't produce any output because we've assigned the output to the variable `data`.\n" +"If we want to check that the data have been loaded,\n" +"we can print the variable's value:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:121 +# code block +msgid "~~~\n" +"print(data)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:126 +# code block +msgid "~~~\n" +"[[ 0. 0. 1. ..., 3. 0. 0.]\n" +" [ 0. 1. 2. ..., 1. 0. 1.]\n" +" [ 0. 1. 1. ..., 2. 1. 1.]\n" +" ...,\n" +" [ 0. 1. 1. ..., 1. 1. 1.]\n" +" [ 0. 0. 0. ..., 0. 2. 0.]\n" +" [ 0. 0. 1. ..., 1. 1. 0.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:137 +msgid "Now that the data are in memory,\n" +"we can manipulate them.\n" +"First,\n" +"let's ask what [type]({{ page.root }}/reference.html#type) of thing `data` refers to:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:142 +# code block +msgid "~~~\n" +"print(type(data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:147 +# code block +msgid "~~~\n" +"\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:152 +msgid "The output tells us that `data` currently refers to\n" +"an N-dimensional array, the functionality for which is provided by the NumPy library.\n" +"These data correspond to arthritis patients' inflammation.\n" +"The rows are the individual patients, and the columns\n" +"are their daily inflammation measurements." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:158 +# blockquote, which can be cascaded +msgid "> ## Data Type" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:159 +msgid ">\n" +"> A Numpy array contains one or more elements\n" +"> of the same type. The `type` function will only tell you that\n" +"> a variable is a NumPy array but won't tell you the type of\n" +"> thing inside the array.\n" +"> We can find out the type\n" +"> of the data contained in the NumPy array.\n" +">\n" +"> ~~~\n" +"> print(data.dtype)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> float64\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:176 +msgid ">\n" +"> This tells us that the NumPy array's elements are\n" +"> [floating-point numbers]({{ page.root }}/reference.html#floating-point number)." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:181 +msgid "With the following command, we can see the array's [shape]({{ page.root }}/reference.html#shape):" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:183 +# code block +msgid "~~~\n" +"print(data.shape)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:188 +# code block +msgid "~~~\n" +"(60, 40)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:193 +msgid "The output tells us that the `data` array variable contains 60 rows and 40 columns. When we\n" +"created the variable `data` to store our arthritis data, we did not only create the array; we also\n" +"created information about the array, called [members]({{ page.root }}/reference.html#member) or\n" +"attributes. This extra information describes `data` in the same way an adjective describes a noun.\n" +"`data.shape` is an attribute of `data` which describes the dimensions of `data`. We use the same\n" +"dotted notation for the attributes of variables that we use for the functions in libraries because\n" +"they have the same part-and-whole relationship." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:201 +msgid "If we want to get a single number from the array, we must provide an\n" +"[index]({{ page.root }}/reference.html#index) in square brackets after the variable name, just as we\n" +"do in math when referring to an element of a matrix. Our inflammation data has two dimensions, so\n" +"we will need to use two indices to refer to one specific value:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:206 +# code block +msgid "~~~\n" +"print('first value in data:', data[0, 0])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:211 +# code block +msgid "~~~\n" +"first value in data: 0.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:216 +# code block +msgid "~~~\n" +"print('middle value in data:', data[30, 20])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:221 +# code block +msgid "~~~\n" +"middle value in data: 13.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:226 +msgid "The expression `data[30, 20]` accesses the element at row 30, column 20. While this expression may\n" +"not surprise you,\n" +" `data[0, 0]` might.\n" +"Programming languages like Fortran, MATLAB and R start counting at 1\n" +"because that's what human beings have done for thousands of years.\n" +"Languages in the C family (including C++, Java, Perl, and Python) count from 0\n" +"because it represents an offset from the first value in the array (the second\n" +"value is offset by one index from the first value). This is closer to the way\n" +"that computers represent arrays (if you are interested in the historical\n" +"reasons behind counting indices from zero, you can read\n" +"[Mike Hoye's blog post](http://exple.tive.org/blarg/2013/10/22/citation-needed/)).\n" +"As a result,\n" +"if we have an M×N array in Python,\n" +"its indices go from 0 to M-1 on the first axis\n" +"and 0 to N-1 on the second.\n" +"It takes a bit of getting used to,\n" +"but one way to remember the rule is that\n" +"the index is how many steps we have to take from the start to get the item we want." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:245 +msgid "![Zero Index](../fig/python-zero-index.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:247 +# blockquote, which can be cascaded +msgid "> ## In the Corner" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:248 +msgid ">\n" +"> What may also surprise you is that when Python displays an array,\n" +"> it shows the element with index `[0, 0]` in the upper left corner\n" +"> rather than the lower left.\n" +"> This is consistent with the way mathematicians draw matrices\n" +"> but different from the Cartesian coordinates.\n" +"> The indices are (row, column) instead of (column, row) for the same reason,\n" +"> which can be confusing when plotting data." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:258 +# header +msgid "## Slicing data" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:259 +msgid "An index like `[30, 20]` selects a single element of an array,\n" +"but we can select whole sections as well.\n" +"For example,\n" +"we can select the first ten days (columns) of values\n" +"for the first four patients (rows) like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:265 +# code block +msgid "~~~\n" +"print(data[0:4, 0:10])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:270 +# code block +msgid "~~~\n" +"[[ 0. 0. 1. 3. 1. 2. 4. 7. 8. 3.]\n" +" [ 0. 1. 2. 1. 2. 1. 3. 2. 2. 6.]\n" +" [ 0. 1. 1. 3. 3. 2. 6. 2. 5. 9.]\n" +" [ 0. 0. 2. 0. 4. 2. 2. 1. 6. 7.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:278 +msgid "The [slice]({{ page.root }}/reference.html#slice) `0:4` means, \"Start at index 0 and go up to, but not\n" +"including, index 4\". Again, the up-to-but-not-including takes a bit of getting used to, but the\n" +"rule is that the difference between the upper and lower bounds is the number of values in the slice." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:282 +msgid "We don't have to start slices at 0:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:284 +# code block +msgid "~~~\n" +"print(data[5:10, 0:10])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:289 +# code block +msgid "~~~\n" +"[[ 0. 0. 1. 2. 2. 4. 2. 1. 6. 4.]\n" +" [ 0. 0. 2. 2. 4. 2. 2. 5. 5. 8.]\n" +" [ 0. 0. 1. 2. 3. 1. 2. 3. 5. 3.]\n" +" [ 0. 0. 0. 3. 1. 5. 6. 5. 5. 8.]\n" +" [ 0. 1. 1. 2. 1. 3. 5. 3. 5. 8.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:298 +msgid "We also don't have to include the upper and lower bound on the slice. If we don't include the lower\n" +"bound, Python uses 0 by default; if we don't include the upper, the slice runs to the end of the\n" +"axis, and if we don't include either (i.e., if we use ':' on its own), the slice includes\n" +"everything:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:303 +# code block +msgid "~~~\n" +"small = data[:3, 36:]\n" +"print('small is:')\n" +"print(small)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:308 +msgid "{: .language-python}\n" +"The above example selects rows 0 through 2 and columns 36 through to the end of the array." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:311 +# code block +msgid "~~~\n" +"small is:\n" +"[[ 2. 3. 0. 0.]\n" +" [ 1. 1. 0. 1.]\n" +" [ 2. 2. 1. 1.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:319 +# header +msgid "## Analyzing data" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:321 +msgid "NumPy has several useful functions that take an array as input to perform operations on its values.\n" +"If we want to find the average inflammation for all patients on\n" +"all days, for example, we can ask NumPy to compute `data`'s mean value:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:325 +# code block +msgid "~~~\n" +"print(numpy.mean(data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:330 +# code block +msgid "~~~\n" +"6.14875\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:335 +msgid "`mean` is a [function]({{ page.root }}/reference.html#function) that takes\n" +"an array as an [argument]({{ page.root }}/reference.html#argument)." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:338 +# blockquote, which can be cascaded +msgid "> ## Not All Functions Have Input" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:339 +msgid ">\n" +"> Generally, a function uses inputs to produce outputs.\n" +"> However, some functions produce outputs without\n" +"> needing any input. For example, checking the current time\n" +"> doesn't require any input.\n" +">\n" +"> ~~~\n" +"> import time\n" +"> print(time.ctime())\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Sat Mar 26 13:07:33 2016\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:355 +msgid ">\n" +"> For functions that don't take in any arguments,\n" +"> we still need parentheses (`()`)\n" +"> to tell Python to go and do something for us." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:361 +msgid "Let's use three other NumPy functions to get some descriptive values about the dataset.\n" +"We'll also use multiple assignment,\n" +"a convenient Python feature that will enable us to do this all in one line." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:365 +# code block +msgid "~~~\n" +"maxval, minval, stdval = numpy.max(data), numpy.min(data), numpy.std(data)\n" +"\n" +"print('maximum inflammation:', maxval)\n" +"print('minimum inflammation:', minval)\n" +"print('standard deviation:', stdval)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:374 +msgid "Here we've assigned the return value from `numpy.max(data)` to the variable `maxval`, the value\n" +"from `numpy.min(data)` to `minval`, and so on." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:377 +# code block +msgid "~~~\n" +"maximum inflammation: 20.0\n" +"minimum inflammation: 0.0\n" +"standard deviation: 4.61383319712\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:384 +# blockquote, which can be cascaded +msgid "> ## Mystery Functions in IPython" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:385 +msgid ">\n" +"> How did we know what functions NumPy has and how to use them?\n" +"> If you are working in IPython or in a Jupyter Notebook, there is an easy way to find out.\n" +"> If you type the name of something followed by a dot, then you can use tab completion\n" +"> (e.g. type `numpy.` and then press Tab)\n" +"> to see a list of all functions and attributes that you can use. After selecting one, you\n" +"> can also add a question mark (e.g. `numpy.cumprod?`), and IPython will return an\n" +"> explanation of the method! This is the same as doing `help(numpy.cumprod)`.\n" +"> Similarly, if you are using the \"plain vanilla\" Python interpreter, you can type `numpy.`\n" +"> and press the Tab key twice for a listing of what is available. You can then use the\n" +"> `help()` function to see an explanation of the function you're interested in,\n" +"> for example: `help(numpy.cumprod)`." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:399 +msgid "When analyzing data, though,\n" +"we often want to look at variations in statistical values,\n" +"such as the maximum inflammation per patient\n" +"or the average inflammation per day.\n" +"One way to do this is to create a new temporary array of the data we want,\n" +"then ask it to do the calculation:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:406 +# code block +msgid "~~~\n" +"patient_0 = data[0, :] # 0 on the first axis (rows), everything on the second (columns)\n" +"print('maximum inflammation for patient 0:', numpy.max(patient_0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:412 +# code block +msgid "~~~\n" +"maximum inflammation for patient 0: 18.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:417 +msgid "Everything in a line of code following the '#' symbol is a\n" +"[comment]({{ page.root }}/reference.html#comment) that is ignored by Python.\n" +"Comments allow programmers to leave explanatory notes for other\n" +"programmers or their future selves." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:422 +msgid "We don't actually need to store the row in a variable of its own.\n" +"Instead, we can combine the selection and the function call:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:425 +# code block +msgid "~~~\n" +"print('maximum inflammation for patient 2:', numpy.max(data[2, :]))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:430 +# code block +msgid "~~~\n" +"maximum inflammation for patient 2: 19.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:435 +msgid "What if we need the maximum inflammation for each patient over all days (as in the\n" +"next diagram on the left) or the average for each day (as in the\n" +"diagram on the right)? As the diagram below shows, we want to perform the\n" +"operation across an axis:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:440 +msgid "![Per-patient maximum inflammation is computed row-wise across all columns using numpy.max(data, axis=1).\n" +"Per-day average inflammation is computed column-wise across all rows using numpy.mean(data, axis=0).](../fig/python-operations-across-axes.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:443 +msgid "To support this functionality,\n" +"most array functions allow us to specify the axis we want to work on.\n" +"If we ask for the average across axis 0 (rows in our 2D example),\n" +"we get:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:448 +# code block +msgid "~~~\n" +"print(numpy.mean(data, axis=0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:453 +# code block +msgid "~~~\n" +"[ 0. 0.45 1.11666667 1.75 2.43333333 3.15\n" +" 3.8 3.88333333 5.23333333 5.51666667 5.95 5.9\n" +" 8.35 7.73333333 8.36666667 9.5 9.58333333\n" +" 10.63333333 11.56666667 12.35 13.25 11.96666667\n" +" 11.03333333 10.16666667 10. 8.66666667 9.15 7.25\n" +" 7.33333333 6.58333333 6.06666667 5.95 5.11666667 3.6\n" +" 3.3 3.56666667 2.48333333 1.5 1.13333333\n" +" 0.56666667]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:465 +msgid "As a quick check,\n" +"we can ask this array what its shape is:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:468 +# code block +msgid "~~~\n" +"print(numpy.mean(data, axis=0).shape)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:473 +# code block +msgid "~~~\n" +"(40,)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:478 +msgid "The expression `(40,)` tells us we have an N×1 vector,\n" +"so this is the average inflammation per day for all patients.\n" +"If we average across axis 1 (columns in our 2D example), we get:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:482 +# code block +msgid "~~~\n" +"print(numpy.mean(data, axis=1))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:487 +# code block +msgid "~~~\n" +"[ 5.45 5.425 6.1 5.9 5.55 6.225 5.975 6.65 6.625 6.525\n" +" 6.775 5.8 6.225 5.75 5.225 6.3 6.55 5.7 5.85 6.55\n" +" 5.775 5.825 6.175 6.1 5.8 6.425 6.05 6.025 6.175 6.55\n" +" 6.175 6.35 6.725 6.125 7.075 5.725 5.925 6.15 6.075 5.75\n" +" 5.975 5.725 6.3 5.9 6.75 5.925 7.225 6.15 5.95 6.275 5.7\n" +" 6.1 6.825 5.975 6.725 5.7 6.25 6.4 7.05 5.9 ]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:497 +msgid "which is the average inflammation per patient across all days." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:500 +# blockquote, which can be cascaded +msgid "> ## Slicing Strings" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:501 +msgid ">\n" +"> A section of an array is called a [slice]({{ page.root }}/reference.html#slice).\n" +"> We can take slices of character strings as well:\n" +">\n" +"> ~~~\n" +"> element = 'oxygen'\n" +"> print('first three characters:', element[0:3])\n" +"> print('last three characters:', element[3:6])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> first three characters: oxy\n" +"> last three characters: gen\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:517 +msgid ">\n" +"> What is the value of `element[:4]`?\n" +"> What about `element[4:]`?\n" +"> Or `element[:]`?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > oxyg\n" +"> > en\n" +"> > oxygen\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:530 +msgid ">\n" +"> What is `element[-1]`?\n" +"> What is `element[-2]`?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > n\n" +"> > e\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:541 +msgid ">\n" +"> Given those answers,\n" +"> explain what `element[1:-1]` does.\n" +">\n" +"> > ## Solution\n" +"> > Creates a substring from index 1 up to (not including) the final index,\n" +"> > effectively removing the first and last letters from 'oxygen'" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:549 +msgid ">\n" +"> How can we rewrite the slice for getting the last three characters of `element`,\n" +"> so that it works even if we assign a different string to `element`?\n" +"> Test your solution with the following strings: `carpentry`, `clone`, `hi`.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > element = 'oxygen'\n" +"> > print('last three characters:', element[-3:])\n" +"> > element = 'carpentry'\n" +"> > print('last three characters:', element[-3:])\n" +"> > element = 'clone'\n" +"> > print('last three characters:', element[-3:])\n" +"> > element = 'hi'\n" +"> > print('last three characters:', element[-3:])\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> > ~~~\n" +"> > last three characters: gen\n" +"> > last three characters: try\n" +"> > last three characters: one\n" +"> > last three characters: hi\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:576 +# blockquote, which can be cascaded +msgid "> ## Thin Slices" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:577 +msgid ">\n" +"> The expression `element[3:3]` produces an [empty string]({{ page.root }}/reference.html#empty-string),\n" +"> i.e., a string that contains no characters.\n" +"> If `data` holds our array of patient data,\n" +"> what does `data[3:3, 4:4]` produce?\n" +"> What about `data[3:3, :]`?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > array([], shape=(0, 0), dtype=float64)\n" +"> > array([], shape=(0, 40), dtype=float64)\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:593 +# blockquote, which can be cascaded +msgid "> ## Stacking Arrays" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:594 +msgid ">\n" +"> Arrays can be concatenated and stacked on top of one another,\n" +"> using NumPy's `vstack` and `hstack` functions for vertical and horizontal stacking, respectively.\n" +">\n" +"> ~~~\n" +"> import numpy\n" +">\n" +"> A = numpy.array([[1,2,3], [4,5,6], [7, 8, 9]])\n" +"> print('A = ')\n" +"> print(A)\n" +">\n" +"> B = numpy.hstack([A, A])\n" +"> print('B = ')\n" +"> print(B)\n" +">\n" +"> C = numpy.vstack([A, A])\n" +"> print('C = ')\n" +"> print(C)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> A =\n" +"> [[1 2 3]\n" +"> [4 5 6]\n" +"> [7 8 9]]\n" +"> B =\n" +"> [[1 2 3 1 2 3]\n" +"> [4 5 6 4 5 6]\n" +"> [7 8 9 7 8 9]]\n" +"> C =\n" +"> [[1 2 3]\n" +"> [4 5 6]\n" +"> [7 8 9]\n" +"> [1 2 3]\n" +"> [4 5 6]\n" +"> [7 8 9]]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:633 +msgid ">\n" +"> Write some additional code that slices the first and last columns of `A`,\n" +"> and stacks them into a 3x2 array.\n" +"> Make sure to `print` the results to verify your solution.\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > A 'gotcha' with array indexing is that singleton dimensions\n" +"> > are dropped by default. That means `A[:, 0]` is a one dimensional\n" +"> > array, which won't stack as desired. To preserve singleton dimensions,\n" +"> > the index itself can be a slice or array. For example, `A[:, :1]` returns\n" +"> > a two dimensional array with one singleton dimension (i.e. a column\n" +"> > vector).\n" +"> >\n" +"> > ~~~\n" +"> > D = numpy.hstack((A[:, :1], A[:, -1:]))\n" +"> > print('D = ')\n" +"> > print(D)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > D =\n" +"> > [[1 3]\n" +"> > [4 6]\n" +"> > [7 9]]\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:662 +msgid ">\n" +"> > ## Solution\n" +"> >\n" +"> > An alternative way to achieve the same result is to use Numpy's\n" +"> > delete function to remove the second column of A.\n" +"> >\n" +"> > ~~~\n" +"> > D = numpy.delete(A, 1, 1)\n" +"> > print('D = ')\n" +"> > print(D)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > D =\n" +"> > [[1 3]\n" +"> > [4 6]\n" +"> > [7 9]]\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:685 +# blockquote, which can be cascaded +msgid "> ## Change In Inflammation" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:686 +msgid ">\n" +"> The patient data is _longitudinal_ in the sense that each row represents a\n" +"> series of observations relating to one individual. This means that\n" +"> the change in inflammation over time is a meaningful concept.\n" +"> Let's find out how to calculate changes in the data contained in an array\n" +"> with NumPy.\n" +">\n" +"> The `numpy.diff()` function takes an array and returns the differences\n" +"> between two successive values. Let's use it to examine the changes\n" +"> each day across the first week of patient 3 from our inflammation dataset.\n" +">\n" +"> ~~~\n" +"> patient3_week1 = data[3, :7]\n" +"> print(patient3_week1)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> [0. 0. 2. 0. 4. 2. 2.]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:707 +msgid ">\n" +"> Calling `numpy.diff(patient3_week1)` would do the following calculations\n" +">\n" +"> ~~~\n" +"> [ 0 - 0, 2 - 0, 0 - 2, 4 - 0, 2 - 4, 2 - 2 ]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> and return the 6 difference values in a new array.\n" +">\n" +"> ~~~\n" +"> numpy.diff(patient3_week1)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> array([ 0., 2., -2., 4., -2., 0.])\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:726 +msgid ">\n" +"> Note that the array of differences is shorter by one element (length 6).\n" +">\n" +"> When calling `numpy.diff` with a multi-dimensional array, an `axis` argument may\n" +"> be passed to the function to specify which axis to process. When applying\n" +"> `numpy.diff` to our 2D inflammation array `data`, which axis would we specify?\n" +">\n" +"> > ## Solution\n" +"> > Since the row axis (0) is patients, it does not make sense to get the\n" +"> > difference between two arbitrary patients. The column axis (1) is in\n" +"> > days, so the difference is the change in inflammation -- a meaningful\n" +"> > concept.\n" +"> >\n" +"> > ~~~\n" +"> > numpy.diff(data, axis=1)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:744 +msgid ">\n" +"> If the shape of an individual data file is `(60, 40)` (60 rows and 40\n" +"> columns), what would the shape of the array be after you run the `diff()`\n" +"> function and why?\n" +">\n" +"> > ## Solution\n" +"> > The shape will be `(60, 39)` because there is one fewer difference between\n" +"> > columns than there are columns in the data." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:753 +msgid ">\n" +"> How would you find the largest change in inflammation for each patient? Does\n" +"> it matter if the change in inflammation is an increase or a decrease?\n" +">\n" +"> > ## Solution\n" +"> > By using the `numpy.max()` function after you apply the `numpy.diff()`\n" +"> > function, you will get the largest difference between days.\n" +"> >\n" +"> > ~~~\n" +"> > numpy.max(numpy.diff(data, axis=1), axis=1)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > array([ 7., 12., 11., 10., 11., 13., 10., 8., 10., 10., 7.,\n" +"> > 7., 13., 7., 10., 10., 8., 10., 9., 10., 13., 7.,\n" +"> > 12., 9., 12., 11., 10., 10., 7., 10., 11., 10., 8.,\n" +"> > 11., 12., 10., 9., 10., 13., 10., 7., 7., 10., 13.,\n" +"> > 12., 8., 8., 10., 10., 9., 8., 13., 10., 7., 10.,\n" +"> > 8., 12., 10., 7., 12.])\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > If inflammation values *decrease* along an axis, then the difference from\n" +"> > one element to the next will be negative. If\n" +"> > you are interested in the **magnitude** of the change and not the\n" +"> > direction, the `numpy.absolute()` function will provide that.\n" +"> >\n" +"> > Notice the difference if you get the largest _absolute_ difference\n" +"> > between readings.\n" +"> >\n" +"> > ~~~\n" +"> > numpy.max(numpy.absolute(numpy.diff(data, axis=1)), axis=1)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > array([ 12., 14., 11., 13., 11., 13., 10., 12., 10., 10., 10.,\n" +"> > 12., 13., 10., 11., 10., 12., 13., 9., 10., 13., 9.,\n" +"> > 12., 9., 12., 11., 10., 13., 9., 13., 11., 11., 8.,\n" +"> > 11., 12., 13., 9., 10., 13., 11., 11., 13., 11., 13.,\n" +"> > 13., 10., 9., 10., 10., 9., 9., 13., 10., 9., 10.,\n" +"> > 11., 13., 10., 10., 12.])\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:1 +# Front Matter +msgid "---\n" +"title: Visualizing Tabular Data\n" +"teaching: 30\n" +"exercises: 20\n" +"questions:\n" +"- \"How can I visualize tabular data in Python?\"\n" +"- \"How can I group several plots together?\"\n" +"objectives:\n" +"- \"Plot simple graphs from data.\"\n" +"- \"Group several graphs in a single figure.\"\n" +"keypoints:\n" +"- \"Use the `pyplot` module from the `matplotlib` library for creating simple visualizations.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:15 +# header +msgid "## Visualizing data" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:16 +msgid "The mathematician Richard Hamming once said, \"The purpose of computing is insight, not numbers,\" and\n" +"the best way to develop insight is often to visualize data. Visualization deserves an entire\n" +"lecture of its own, but we can explore a few features of Python's `matplotlib` library here. While\n" +"there is no official plotting library, `matplotlib` is the _de facto_ standard. First, we will\n" +"import the `pyplot` module from `matplotlib` and use two of its functions to create and display a\n" +"[heat map]({{ page.root }}/reference.html#heat-map) of our data:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:23 +# code block +msgid "~~~\n" +"import matplotlib.pyplot\n" +"image = matplotlib.pyplot.imshow(data)\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:30 +msgid "![Heat map representing the `data` variable. Each cell is colored by value along a color gradient from blue to yellow.](../fig/inflammation-01-imshow.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:32 +msgid "Blue pixels in this heat map represent low values, while yellow pixels represent high values. As we\n" +"can see, inflammation rises and falls over a 40-day period. Let's take a look at the average inflammation over time:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:35 +# code block +msgid "~~~\n" +"ave_inflammation = numpy.mean(data, axis=0)\n" +"ave_plot = matplotlib.pyplot.plot(ave_inflammation)\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:42 +msgid "![Average Inflammation Over Time](../fig/inflammation-01-average.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:44 +msgid "Here, we have put the average inflammation per day across all patients in the variable `ave_inflammation`, then\n" +"asked `matplotlib.pyplot` to create and display a line graph of those values. The result is a\n" +"roughly linear rise and fall, which is suspicious: we might instead expect a sharper rise and slower\n" +"fall. Let's have a look at two other statistics:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:49 +# code block +msgid "~~~\n" +"max_plot = matplotlib.pyplot.plot(numpy.max(data, axis=0))\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:55 +msgid "![Maximum Value Along The First Axis](../fig/inflammation-01-maximum.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:57 +# code block +msgid "~~~\n" +"min_plot = matplotlib.pyplot.plot(numpy.min(data, axis=0))\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:63 +msgid "![Minimum Value Along The First Axis](../fig/inflammation-01-minimum.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:65 +msgid "The maximum value rises and falls smoothly, while the minimum seems to be a step function. Neither\n" +"trend seems particularly likely, so either there's a mistake in our calculations or something is\n" +"wrong with our data. This insight would have been difficult to reach by examining the numbers\n" +"themselves without visualization tools." +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:70 +# header +msgid "### Grouping plots" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:71 +msgid "You can group similar plots in a single figure using subplots.\n" +"This script below uses a number of new commands. The function `matplotlib.pyplot.figure()`\n" +"creates a space into which we will place all of our plots. The parameter `figsize`\n" +"tells Python how big to make this space. Each subplot is placed into the figure using\n" +"its `add_subplot` [method]({{ page.root }}/reference.html#method). The `add_subplot` method takes 3\n" +"parameters. The first denotes how many total rows of subplots there are, the second parameter\n" +"refers to the total number of subplot columns, and the final parameter denotes which subplot\n" +"your variable is referencing (left-to-right, top-to-bottom). Each subplot is stored in a\n" +"different variable (`axes1`, `axes2`, `axes3`). Once a subplot is created, the axes can\n" +"be titled using the `set_xlabel()` command (or `set_ylabel()`).\n" +"Here are our three plots side by side:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:83 +# code block +msgid "~~~\n" +"import numpy\n" +"import matplotlib.pyplot\n" +"\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"\n" +"fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"\n" +"axes1 = fig.add_subplot(1, 3, 1)\n" +"axes2 = fig.add_subplot(1, 3, 2)\n" +"axes3 = fig.add_subplot(1, 3, 3)\n" +"\n" +"axes1.set_ylabel('average')\n" +"axes1.plot(numpy.mean(data, axis=0))\n" +"\n" +"axes2.set_ylabel('max')\n" +"axes2.plot(numpy.max(data, axis=0))\n" +"\n" +"axes3.set_ylabel('min')\n" +"axes3.plot(numpy.min(data, axis=0))\n" +"\n" +"fig.tight_layout()\n" +"\n" +"matplotlib.pyplot.savefig('inflammation.png')\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:111 +msgid "![The Previous Plots as Subplots](../fig/inflammation-01-group-plot.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:113 +msgid "The [call]({{ page.root }}/reference.html#function-call) to `loadtxt` reads our data,\n" +"and the rest of the program tells the plotting library\n" +"how large we want the figure to be,\n" +"that we're creating three subplots,\n" +"what to draw for each one,\n" +"and that we want a tight layout.\n" +"(If we leave out that call to `fig.tight_layout()`,\n" +"the graphs will actually be squeezed together more closely.)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:122 +msgid "The call to `savefig` stores the plot as a graphics file. This can be\n" +"a convenient way to store your plots for use in other documents, web\n" +"pages etc. The graphics format is automatically determined by\n" +"Matplotlib from the file name ending we specify; here PNG from\n" +"'inflammation.png'. Matplotlib supports many different graphics\n" +"formats, including SVG, PDF, and JPEG." +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:130 +# blockquote, which can be cascaded +msgid "> ## Plot Scaling" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:131 +msgid ">\n" +"> Why do all of our plots stop just short of the upper end of our graph?\n" +">\n" +"> > ## Solution\n" +"> > Because matplotlib normally sets x and y axes limits to the min and max of our data\n" +"> > (depending on data range)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:138 +msgid ">\n" +"> If we want to change this, we can use the `set_ylim(min, max)` method of each 'axes',\n" +"> for example:\n" +">\n" +"> ~~~\n" +"> axes3.set_ylim(0,6)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Update your plotting code to automatically set a more appropriate scale.\n" +"> (Hint: you can make use of the `max` and `min` methods to help.)\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # One method\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(data, axis=0))\n" +"> > axes3.set_ylim(0,6)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:159 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # A more automated approach\n" +"> > min_data = numpy.min(data, axis=0)\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(min_data)\n" +"> > axes3.set_ylim(numpy.min(min_data), numpy.max(min_data) * 1.1)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:172 +# blockquote, which can be cascaded +msgid "> ## Drawing Straight Lines" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:173 +msgid ">\n" +"> In the center and right subplots above, we expect all lines to look like step functions because\n" +"> non-integer value are not realistic for the minimum and maximum values. However, you can see\n" +"> that the lines are not always vertical or horizontal, and in particular the step function\n" +"> in the subplot on the right looks slanted. Why is this?\n" +">\n" +"> > ## Solution\n" +"> > Because matplotlib interpolates (draws a straight line) between the points.\n" +"> > One way to do avoid this is to use the Matplotlib `drawstyle` option:\n" +"> >\n" +"> > ~~~\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"> >\n" +"> > fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"> >\n" +"> > axes1 = fig.add_subplot(1, 3, 1)\n" +"> > axes2 = fig.add_subplot(1, 3, 2)\n" +"> > axes3 = fig.add_subplot(1, 3, 3)\n" +"> >\n" +"> > axes1.set_ylabel('average')\n" +"> > axes1.plot(numpy.mean(data, axis=0), drawstyle='steps-mid')\n" +"> >\n" +"> > axes2.set_ylabel('max')\n" +"> > axes2.plot(numpy.max(data, axis=0), drawstyle='steps-mid')\n" +"> >\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(data, axis=0), drawstyle='steps-mid')\n" +"> >\n" +"> > fig.tight_layout()\n" +"> >\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> ![Plot with step lines](../fig/inflammation-01-line-styles.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:213 +# blockquote, which can be cascaded +msgid "> ## Make Your Own Plot" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:214 +msgid ">\n" +"> Create a plot showing the standard deviation (`numpy.std`)\n" +"> of the inflammation data for each day across all patients.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > std_plot = matplotlib.pyplot.plot(numpy.std(data, axis=0))\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:227 +# blockquote, which can be cascaded +msgid "> ## Moving Plots Around" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:228 +msgid ">\n" +"> Modify the program to display the three plots on top of one another\n" +"> instead of side by side.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"> >\n" +"> > # change figsize (swap width and height)\n" +"> > fig = matplotlib.pyplot.figure(figsize=(3.0, 10.0))\n" +"> >\n" +"> > # change add_subplot (swap first two parameters)\n" +"> > axes1 = fig.add_subplot(3, 1, 1)\n" +"> > axes2 = fig.add_subplot(3, 1, 2)\n" +"> > axes3 = fig.add_subplot(3, 1, 3)\n" +"> >\n" +"> > axes1.set_ylabel('average')\n" +"> > axes1.plot(numpy.mean(data, axis=0))\n" +"> >\n" +"> > axes2.set_ylabel('max')\n" +"> > axes2.plot(numpy.max(data, axis=0))\n" +"> >\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(data, axis=0))\n" +"> >\n" +"> > fig.tight_layout()\n" +"> >\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:1 +# Front Matter +msgid "---\n" +"title: Repeating Actions with Loops\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I do the same operations on many different values?\"\n" +"objectives:\n" +"- \"Explain what a `for` loop does.\"\n" +"- \"Correctly write `for` loops to repeat simple calculations.\"\n" +"- \"Trace changes to a loop variable as the loop runs.\"\n" +"- \"Trace changes to other variables as they are updated by a `for` loop.\"\n" +"keypoints:\n" +"- \"Use `for variable in sequence` to process the elements of a sequence one at a time.\"\n" +"- \"The body of a `for` loop must be indented.\"\n" +"- \"Use `len(thing)` to determine the length of something that contains other values.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:18 +msgid "In the last episode, we wrote Python code that plots values of interest from our first\n" +"inflammation dataset (`inflammation-01.csv`), which revealed some suspicious features in it." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:21 +msgid "![Analysis of inflammation-01.csv](../fig/03-loop_2_0.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:23 +msgid "We have a dozen data sets right now, though, and more on the way.\n" +"We want to create plots for all of our data sets with a single statement.\n" +"To do that, we'll have to teach the computer how to repeat things." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:27 +msgid "An example task that we might want to repeat is printing each character in a\n" +"word on a line of its own." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:30 +# code block +msgid "~~~\n" +"word = 'lead'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:35 +msgid "In Python, a string is basically an ordered collection of characters, and every\n" +"character has a unique number associated with it -- its index. This means that\n" +"we can access characters in a string using their indices.\n" +"For example, we can get the first character of the word `'lead'`, by using\n" +"`word[0]`. One way to print each character is to use four `print` statements:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:41 +# code block +msgid "~~~\n" +"print(word[0])\n" +"print(word[1])\n" +"print(word[2])\n" +"print(word[3])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:49 +#: python-novice-inflammation/_episodes/04-loop.md:110 +# code block +msgid "~~~\n" +"l\n" +"e\n" +"a\n" +"d\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:57 +msgid "This is a bad approach for three reasons:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:59 +# ordered list +msgid "1. **Not scalable**. Imagine you need to print characters of a string that is hundreds" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:60 +msgid " of letters long. It might be easier to type them in manually." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:62 +# ordered list +msgid "2. **Difficult to maintain**. If we want to decorate each printed character with an" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:63 +msgid " asterisk or any other character, we would have to change four lines of code. While\n" +" this might not be a problem for short strings, it would definitely be a problem for\n" +" longer ones." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:67 +# ordered list +msgid "3. **Fragile**. If we use it with a word that has more characters than what we initially" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:68 +msgid " envisioned, it will only display part of the word's characters. A shorter string, on\n" +" the other hand, will cause an error because it will be trying to display part of the\n" +" string that doesn't exist." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:72 +# code block +msgid "~~~\n" +"word = 'tin'\n" +"print(word[0])\n" +"print(word[1])\n" +"print(word[2])\n" +"print(word[3])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:81 +# code block +msgid "~~~\n" +"t\n" +"i\n" +"n\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:88 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"IndexError Traceback (most recent call last)\n" +" in ()\n" +" 3 print(word[1])\n" +" 4 print(word[2])\n" +"----> 5 print(word[3])\n" +"\n" +"IndexError: string index out of range\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:98 +#: python-novice-inflammation/_episodes/05-lists.md:113 +#: python-novice-inflammation/_episodes/08-func.md:448 +#: python-novice-inflammation/_episodes/09-errors.md:76 +#: python-novice-inflammation/_episodes/09-errors.md:164 +#: python-novice-inflammation/_episodes/09-errors.md:189 +#: python-novice-inflammation/_episodes/09-errors.md:245 +#: python-novice-inflammation/_episodes/09-errors.md:271 +#: python-novice-inflammation/_episodes/09-errors.md:294 +#: python-novice-inflammation/_episodes/09-errors.md:322 +#: python-novice-inflammation/_episodes/09-errors.md:361 +#: python-novice-inflammation/_episodes/09-errors.md:391 +#: python-novice-inflammation/_episodes/09-errors.md:427 +#: python-novice-inflammation/_episodes/10-defensive.md:92 +#: python-novice-inflammation/_episodes/10-defensive.md:168 +#: python-novice-inflammation/_episodes/10-defensive.md:190 +#: python-novice-inflammation/_episodes/10-defensive.md:230 +#: python-novice-inflammation/_episodes/10-defensive.md:325 +#: python-novice-inflammation/_episodes/10-defensive.md:398 +#: python-novice-inflammation/_episodes/10-defensive.md:457 +#: python-novice-inflammation/_extras/discuss.md:104 +#: python-novice-inflammation/_extras/discuss.md:287 +# SC/DC Template label +msgid "{: .error}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:100 +msgid "Here's a better approach:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:102 +# code block +msgid "~~~\n" +"word = 'lead'\n" +"for char in word:\n" +" print(char)\n" +"\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:118 +msgid "This is shorter --- certainly shorter than something that prints every character in a\n" +"hundred-letter string --- and more robust as well:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:121 +# code block +msgid "~~~\n" +"word = 'oxygen'\n" +"for char in word:\n" +" print(char)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:128 +# code block +msgid "~~~\n" +"o\n" +"x\n" +"y\n" +"g\n" +"e\n" +"n\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:138 +msgid "The improved version uses a [for loop]({{ page.root }}/reference.html#for-loop)\n" +"to repeat an operation --- in this case, printing --- once for each thing in a sequence.\n" +"The general form of a loop is:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:142 +# code block +msgid "~~~\n" +"for variable in collection:\n" +" # do things using variable, such as print\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:148 +msgid "Using the oxygen example above, the loop might look like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:150 +msgid "![loop_image](../fig/loops_image.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:152 +msgid "where each character (`char`) in the variable `word` is looped through and printed one character\n" +"after another. The numbers in the diagram denote which loop cycle the character was printed in (1\n" +"being the first loop, and 6 being the final loop)." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:156 +msgid "We can call the [loop variable]({{ page.root }}/reference.html#loop-variable) anything we like, but\n" +"there must be a colon at the end of the line starting the loop, and we must indent anything we\n" +"want to run inside the loop. Unlike many other languages, there is no command to signify the end\n" +"of the loop body (e.g. `end for`); what is indented after the `for` statement belongs to the loop." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:162 +# blockquote, which can be cascaded +msgid "> ## What's in a name?" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:163 +msgid ">\n" +">\n" +"> In the example above, the loop variable was given the name `char` as a mnemonic;\n" +"> it is short for 'character'. We can choose any name we want for variables.\n" +"> We can even call our loop variable `banana`, as long as we use this name consistently:\n" +">\n" +"> ~~~\n" +"> word = 'oxygen'\n" +"> for banana in word:\n" +"> print(banana)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> o\n" +"> x\n" +"> y\n" +"> g\n" +"> e\n" +"> n\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:185 +msgid ">\n" +"> It is a good idea to choose variable names that are meaningful, otherwise it would be more\n" +"> difficult to understand what the loop is doing." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:190 +msgid "Here's another loop that repeatedly updates a variable:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:192 +# code block +msgid "~~~\n" +"length = 0\n" +"for vowel in 'aeiou':\n" +" length = length + 1\n" +"print('There are', length, 'vowels')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:200 +# code block +msgid "~~~\n" +"There are 5 vowels\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:205 +msgid "It's worth tracing the execution of this little program step by step.\n" +"Since there are five characters in `'aeiou'`,\n" +"the statement on line 3 will be executed five times.\n" +"The first time around,\n" +"`length` is zero (the value assigned to it on line 1)\n" +"and `vowel` is `'a'`.\n" +"The statement adds 1 to the old value of `length`,\n" +"producing 1,\n" +"and updates `length` to refer to that new value.\n" +"The next time around,\n" +"`vowel` is `'e'` and `length` is 1,\n" +"so `length` is updated to be 2.\n" +"After three more updates,\n" +"`length` is 5;\n" +"since there is nothing left in `'aeiou'` for Python to process,\n" +"the loop finishes\n" +"and the `print` statement on line 4 tells us our final answer." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:223 +msgid "Note that a loop variable is a variable that's being used to record progress in a loop.\n" +"It still exists after the loop is over,\n" +"and we can re-use variables previously defined as loop variables as well:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:227 +# code block +msgid "~~~\n" +"letter = 'z'\n" +"for letter in 'abc':\n" +" print(letter)\n" +"print('after the loop, letter is', letter)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:235 +# code block +msgid "~~~\n" +"a\n" +"b\n" +"c\n" +"after the loop, letter is c\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:243 +msgid "Note also that finding the length of a string is such a common operation\n" +"that Python actually has a built-in function to do it called `len`:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:246 +# code block +msgid "~~~\n" +"print(len('aeiou'))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:251 +# code block +msgid "~~~\n" +"5\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:256 +msgid "`len` is much faster than any function we could write ourselves,\n" +"and much easier to read than a two-line loop;\n" +"it will also give us the length of many other things that we haven't met yet,\n" +"so we should always use it when we can." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:261 +# blockquote, which can be cascaded +msgid "> ## From 1 to N" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:262 +msgid ">\n" +"> Python has a built-in function called `range` that generates a sequence of numbers. `range` can\n" +"> accept 1, 2, or 3 parameters.\n" +">\n" +"> * If one parameter is given, `range` generates a sequence of that length,\n" +"> starting at zero and incrementing by 1.\n" +"> For example, `range(3)` produces the numbers `0, 1, 2`.\n" +"> * If two parameters are given, `range` starts at\n" +"> the first and ends just before the second, incrementing by one.\n" +"> For example, `range(2, 5)` produces `2, 3, 4`.\n" +"> * If `range` is given 3 parameters,\n" +"> it starts at the first one, ends just before the second one, and increments by the third one.\n" +"> For example, `range(3, 10, 2)` produces `3, 5, 7, 9`.\n" +">\n" +"> Using `range`,\n" +"> write a loop that uses `range` to print the first 3 natural numbers:\n" +">\n" +"> ~~~\n" +"> 1\n" +"> 2\n" +"> 3\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > for number in range(1, 4):\n" +"> > print(number)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:298 +# blockquote, which can be cascaded +msgid "> ## Understanding the loops" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:299 +msgid ">\n" +"> Given the following loop:\n" +"> ~~~\n" +"> word = 'oxygen'\n" +"> for char in word:\n" +"> print(char)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> How many times is the body of the loop executed?\n" +">\n" +"> * 3 times\n" +"> * 4 times\n" +"> * 5 times\n" +"> * 6 times\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > The body of the loop is executed 6 times.\n" +"> >" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:324 +# blockquote, which can be cascaded +msgid "> ## Computing Powers With Loops" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:325 +msgid ">\n" +"> Exponentiation is built into Python:\n" +">\n" +"> ~~~\n" +"> print(5 ** 3)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 125\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:337 +msgid ">\n" +"> Write a loop that calculates the same result as `5 ** 3` using\n" +"> multiplication (and without exponentiation).\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > result = 1\n" +"> > for number in range(0, 3):\n" +"> > result = result * 5\n" +"> > print(result)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:352 +# blockquote, which can be cascaded +msgid "> ## Reverse a String" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:353 +msgid ">\n" +"> Knowing that two strings can be concatenated using the `+` operator,\n" +"> write a loop that takes a string\n" +"> and produces a new string with the characters in reverse order,\n" +"> so `'Newton'` becomes `'notweN'`.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > newstring = ''\n" +"> > oldstring = 'Newton'\n" +"> > for char in oldstring:\n" +"> > newstring = char + newstring\n" +"> > print(newstring)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:371 +# blockquote, which can be cascaded +msgid "> ## Computing the Value of a Polynomial" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:372 +msgid ">\n" +"> The built-in function `enumerate` takes a sequence (e.g. a [list]({{ page.root }}/05-lists/)) and generates a\n" +"> new sequence of the same length. Each element of the new sequence is a pair composed of the index\n" +"> (0, 1, 2,...) and the value from the original sequence:\n" +">\n" +"> ~~~\n" +"> for idx, val in enumerate(a_list):\n" +"> # Do something using idx and val\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> The code above loops through `a_list`, assigning the index to `idx` and the value to `val`.\n" +">\n" +"> Suppose you have encoded a polynomial as a list of coefficients in\n" +"> the following way: the first element is the constant term, the\n" +"> second element is the coefficient of the linear term, the third is the\n" +"> coefficient of the quadratic term, etc.\n" +">\n" +"> ~~~\n" +"> x = 5\n" +"> coefs = [2, 4, 3]\n" +"> y = coefs[0] * x**0 + coefs[1] * x**1 + coefs[2] * x**2\n" +"> print(y)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 97\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:402 +msgid ">\n" +"> Write a loop using `enumerate(coefs)` which computes the value `y` of any\n" +"> polynomial, given `x` and `coefs`.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > y = 0\n" +"> > for idx, coef in enumerate(coefs):\n" +"> > y = y + coef * x**idx\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:1 +# Front Matter +msgid "---\n" +"title: Storing Multiple Values in Lists\n" +"teaching: 30\n" +"exercises: 15\n" +"questions:\n" +"- \"How can I store many values together?\"\n" +"objectives:\n" +"- \"Explain what a list is.\"\n" +"- \"Create and index lists of simple values.\"\n" +"- \"Change the values of individual elements\"\n" +"- \"Append values to an existing list\"\n" +"- \"Reorder and slice list elements\"\n" +"- \"Create and manipulate nested lists\"\n" +"keypoints:\n" +"- \"`[value1, value2, value3, ...]` creates a list.\"\n" +"- \"Lists can contain any Python object, including lists (i.e., list of lists).\"\n" +"- \"Lists are indexed and sliced with square brackets (e.g., list[0] and\n" +"list[2:9]), in the same way as strings and arrays.\"\n" +"- \"Lists are mutable (i.e., their values can be changed in place).\"\n" +"- \"Strings are immutable (i.e., the characters in them cannot be changed).\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:23 +msgid "Similar to a string that can contain many characters, a list is a container that can store many values.\n" +"Unlike NumPy arrays,\n" +"lists are built into the language (so we don't have to load a library\n" +"to use them).\n" +"We create a list by putting values inside square brackets and separating the values with commas:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:29 +# code block +msgid "~~~\n" +"odds = [1, 3, 5, 7]\n" +"print('odds are:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:35 +# code block +msgid "~~~\n" +"odds are: [1, 3, 5, 7]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:40 +msgid "We can access elements of a list using indices -- numbered positions of elements in the list.\n" +"These positions are numbered starting at 0, so the first element has an index of 0." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:43 +# code block +msgid "~~~\n" +"print('first element:', odds[0])\n" +"print('last element:', odds[3])\n" +"print('\"-1\" element:', odds[-1])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:50 +# code block +msgid "~~~\n" +"first element: 1\n" +"last element: 7\n" +"\"-1\" element: 7\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:57 +msgid "Yes, we can use negative numbers as indices in Python. When we do so, the index `-1` gives us the\n" +"last element in the list, `-2` the second to last, and so on.\n" +"Because of this, `odds[3]` and `odds[-1]` point to the same element here." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:61 +msgid "If we loop over a list, the loop variable is assigned to its elements one at a time:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:63 +# code block +msgid "~~~\n" +"for number in odds:\n" +" print(number)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:69 +# code block +msgid "~~~\n" +"1\n" +"3\n" +"5\n" +"7\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:77 +msgid "There is one important difference between lists and strings:\n" +"we can change the values in a list,\n" +"but we cannot change individual characters in a string.\n" +"For example:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:82 +# code block +msgid "~~~\n" +"names = ['Curie', 'Darwing', 'Turing'] # typo in Darwin's name\n" +"print('names is originally:', names)\n" +"names[1] = 'Darwin' # correct the name\n" +"print('final value of names:', names)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:90 +# code block +msgid "~~~\n" +"names is originally: ['Curie', 'Darwing', 'Turing']\n" +"final value of names: ['Curie', 'Darwin', 'Turing']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:96 +msgid "works, but:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:98 +# code block +msgid "~~~\n" +"name = 'Darwin'\n" +"name[0] = 'd'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:104 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"TypeError Traceback (most recent call last)\n" +" in ()\n" +" 1 name = 'Darwin'\n" +"----> 2 name[0] = 'd'\n" +"\n" +"TypeError: 'str' object does not support item assignment\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:115 +msgid "does not." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:117 +# blockquote, which can be cascaded +msgid "> ## Ch-Ch-Ch-Ch-Changes" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:118 +msgid ">\n" +"> Data which can be modified in place is called [mutable]({{ page.root }}/reference.html#mutable),\n" +"> while data which cannot be modified is called [immutable]({{ page.root }}/reference.html#immutable).\n" +"> Strings and numbers are immutable. This does not mean that variables with string or number values\n" +"> are constants, but when we want to change the value of a string or number variable, we can only\n" +"> replace the old value with a completely new value.\n" +">\n" +"> Lists and arrays, on the other hand, are mutable: we can modify them after they have been\n" +"> created. We can change individual elements, append new elements, or reorder the whole list. For\n" +"> some operations, like sorting, we can choose whether to use a function that modifies the data\n" +"> in-place or a function that returns a modified copy and leaves the original unchanged.\n" +">\n" +"> Be careful when modifying data in-place. If two variables refer to the same list, and you modify\n" +"> the list value, it will change for both variables!\n" +">\n" +"> ~~~\n" +"> salsa = ['peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> my_salsa = salsa # <-- my_salsa and salsa point to the *same* list data in memory\n" +"> salsa[0] = 'hot peppers'\n" +"> print('Ingredients in my salsa:', my_salsa)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Ingredients in my salsa: ['hot peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:145 +msgid ">\n" +"> If you want variables with mutable values to be independent, you\n" +"> must make a copy of the value when you assign it.\n" +">\n" +"> ~~~\n" +"> salsa = ['peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> my_salsa = list(salsa) # <-- makes a *copy* of the list\n" +"> salsa[0] = 'hot peppers'\n" +"> print('Ingredients in my salsa:', my_salsa)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Ingredients in my salsa: ['peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:161 +msgid ">\n" +"> Because of pitfalls like this, code which modifies data in place can be more difficult to\n" +"> understand. However, it is often far more efficient to modify a large data structure in place\n" +"> than to create a modified copy for every small change. You should consider both of these aspects\n" +"> when writing your code." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:168 +# blockquote, which can be cascaded +msgid "> ## Nested Lists" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:169 +# blockquote, which can be cascaded +msgid "> Since a list can contain any Python variables, it can even contain other lists." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:170 +msgid ">\n" +"> For example, we could represent the products in the shelves of a small grocery shop:\n" +">\n" +"> ~~~\n" +"> x = [['pepper', 'zucchini', 'onion'],\n" +"> ['cabbage', 'lettuce', 'garlic'],\n" +"> ['apple', 'pear', 'banana']]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Here is a visual example of how indexing a list of lists `x` works:\n" +">\n" +"> [![x is represented as a pepper shaker containing several packets of pepper. [x[0]] is represented\n" +"> as a pepper shaker containing a single packet of pepper. x[0] is represented as a single packet of\n" +"> pepper. x[0][0] is represented as single grain of pepper. Adapted\n" +"> from @hadleywickham.](../fig/indexing_lists_python.png)][hadleywickham-tweet]\n" +">\n" +"> Using the previously declared list `x`, these would be the results of the\n" +"> index operations shown in the image:\n" +">\n" +"> ~~~\n" +"> print([x[0]])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> [['pepper', 'zucchini', 'onion']]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:199 +msgid ">\n" +"> ~~~\n" +"> print(x[0])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> ['pepper', 'zucchini', 'onion']\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:209 +msgid ">\n" +"> ~~~\n" +"> print(x[0][0])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 'pepper'\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:219 +msgid ">\n" +"> Thanks to [Hadley Wickham][hadleywickham-tweet]\n" +"> for the image above." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:224 +# blockquote, which can be cascaded +msgid "> ## Heterogeneous Lists" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:225 +# blockquote, which can be cascaded +msgid "> Lists in Python can contain elements of different types. Example:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:226 +#: python-novice-inflammation/_episodes/05-lists.md:228 +#: python-novice-inflammation/_episodes/07-cond.md:429 +#: python-novice-inflammation/_episodes/07-cond.md:431 +#: python-novice-inflammation/_episodes/07-cond.md:433 +#: python-novice-inflammation/_episodes/07-cond.md:435 +# blockquote, which can be cascaded +msgid "> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:227 +# blockquote, which can be cascaded +msgid "> sample_ages = [10, 12.5, 'Unknown']" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:229 +#: python-novice-inflammation/_episodes/07-cond.md:432 +# blockquote, which can be cascaded +msgid "> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:232 +msgid "There are many ways to change the contents of lists besides assigning new values to\n" +"individual elements:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:235 +# code block +msgid "~~~\n" +"odds.append(11)\n" +"print('odds after adding a value:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:241 +# code block +msgid "~~~\n" +"odds after adding a value: [1, 3, 5, 7, 11]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:246 +# code block +msgid "~~~\n" +"removed_element = odds.pop(0)\n" +"print('odds after removing the first element:', odds)\n" +"print('removed_element:', removed_element)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:253 +# code block +msgid "~~~\n" +"odds after removing the first element: [3, 5, 7, 11]\n" +"removed_element: 1\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:259 +# code block +msgid "~~~\n" +"odds.reverse()\n" +"print('odds after reversing:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:265 +# code block +msgid "~~~\n" +"odds after reversing: [11, 7, 5, 3]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:270 +msgid "While modifying in place, it is useful to remember that Python treats lists in a slightly\n" +"counter-intuitive way." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:273 +msgid "As we saw earlier, when we modified the `salsa` list item in-place, if we make a list, (attempt to) copy it and then modify this list, we can cause all sorts of trouble. This also applies to modifying the list using the above functions:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:275 +# code block +msgid "~~~\n" +"odds = [1, 3, 5, 7]\n" +"primes = odds\n" +"primes.append(2)\n" +"print('primes:', primes)\n" +"print('odds:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:284 +# code block +msgid "~~~\n" +"primes: [1, 3, 5, 7, 2]\n" +"odds: [1, 3, 5, 7, 2]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:290 +msgid "This is because Python stores a list in memory, and then can use multiple names to refer to the\n" +"same list. If all we want to do is copy a (simple) list, we can again use the `list` function, so we do\n" +"not modify a list we did not mean to:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:294 +# code block +msgid "~~~\n" +"odds = [1, 3, 5, 7]\n" +"primes = list(odds)\n" +"primes.append(2)\n" +"print('primes:', primes)\n" +"print('odds:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:303 +# code block +msgid "~~~\n" +"primes: [1, 3, 5, 7, 2]\n" +"odds: [1, 3, 5, 7]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:309 +# blockquote, which can be cascaded +msgid "> ## Turn a String Into a List" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:310 +msgid ">\n" +"> Use a for-loop to convert the string \"hello\" into a list of letters:\n" +">\n" +"> ~~~\n" +"> ['h', 'e', 'l', 'l', 'o']\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Hint: You can create an empty list like this:\n" +">\n" +"> ~~~\n" +"> my_list = []\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > my_list = []\n" +"> > for char in 'hello':\n" +"> > my_list.append(char)\n" +"> > print(my_list)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:336 +msgid "Subsets of lists and strings can be accessed by specifying ranges of values in brackets,\n" +"similar to how we accessed ranges of positions in a NumPy array.\n" +"This is commonly referred to as \"slicing\" the list/string." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:340 +# code block +msgid "~~~\n" +"binomial_name = 'Drosophila melanogaster'\n" +"group = binomial_name[0:10]\n" +"print('group:', group)\n" +"\n" +"species = binomial_name[11:23]\n" +"print('species:', species)\n" +"\n" +"chromosomes = ['X', 'Y', '2', '3', '4']\n" +"autosomes = chromosomes[2:5]\n" +"print('autosomes:', autosomes)\n" +"\n" +"last = chromosomes[-1]\n" +"print('last:', last)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:357 +# code block +msgid "~~~\n" +"group: Drosophila\n" +"species: melanogaster\n" +"autosomes: ['2', '3', '4']\n" +"last: 4\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:365 +# blockquote, which can be cascaded +msgid "> ## Slicing From the End" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:366 +msgid ">\n" +"> Use slicing to access only the last four characters of a string or entries of a list.\n" +">\n" +"> ~~~\n" +"> string_for_slicing = 'Observation date: 02-Feb-2013'\n" +"> list_for_slicing = [['fluorine', 'F'],\n" +"> ['chlorine', 'Cl'],\n" +"> ['bromine', 'Br'],\n" +"> ['iodine', 'I'],\n" +"> ['astatine', 'At']]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> '2013'\n" +"> [['chlorine', 'Cl'], ['bromine', 'Br'], ['iodine', 'I'], ['astatine', 'At']]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:384 +msgid ">\n" +"> Would your solution work regardless of whether you knew beforehand\n" +"> the length of the string or list\n" +"> (e.g. if you wanted to apply the solution to a set of lists of different lengths)?\n" +"> If not, try to change your approach to make it more robust.\n" +">\n" +"> Hint: Remember that indices can be negative as well as positive\n" +">\n" +"> > ## Solution\n" +"> > Use negative indices to count elements from the end of a container (such as list or string):\n" +"> >\n" +"> > ~~~\n" +"> > string_for_slicing[-4:]\n" +"> > list_for_slicing[-4:]\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:403 +# blockquote, which can be cascaded +msgid "> ## Non-Continuous Slices" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:404 +msgid ">\n" +"> So far we've seen how to use slicing to take single blocks\n" +"> of successive entries from a sequence.\n" +"> But what if we want to take a subset of entries\n" +"> that aren't next to each other in the sequence?\n" +">\n" +"> You can achieve this by providing a third argument\n" +"> to the range within the brackets, called the _step size_.\n" +"> The example below shows how you can take every third entry in a list:\n" +">\n" +"> ~~~\n" +"> primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]\n" +"> subset = primes[0:12:3]\n" +"> print('subset', subset)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> subset [2, 7, 17, 29]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:425 +msgid ">\n" +"> Notice that the slice taken begins with the first entry in the range,\n" +"> followed by entries taken at equally-spaced intervals (the steps) thereafter.\n" +"> If you wanted to begin the subset with the third entry,\n" +"> you would need to specify that as the starting point of the sliced range:\n" +">\n" +"> ~~~\n" +"> primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]\n" +"> subset = primes[2:12:3]\n" +"> print('subset', subset)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> subset [5, 13, 23, 37]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:442 +msgid ">\n" +"> Use the step size argument to create a new string\n" +"> that contains only every other character in the string\n" +"> \"In an octopus's garden in the shade\". Start with\n" +"> creating a variable to hold the string:\n" +">\n" +"> ~~~\n" +"> beatles = \"In an octopus's garden in the shade\"\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> What slice of `beatles` will produce the\n" +"> following output (i.e., the first character, third\n" +"> character, and every other character through the end\n" +"> of the string)?\n" +"> ~~~\n" +"> I notpssgre ntesae\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:461 +msgid ">\n" +"> > ## Solution\n" +"> > To obtain every other character you need to provide a slice with the step\n" +"> > size of 2:\n" +"> >\n" +"> > ~~~\n" +"> > beatles[0:35:2]\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > You can also leave out the beginning and end of the slice to take the whole string\n" +"> > and provide only the step argument to go every second\n" +"> > element:\n" +"> >\n" +"> > ~~~\n" +"> > beatles[::2]\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:482 +msgid "If you want to take a slice from the beginning of a sequence, you can omit the first index in the\n" +"range:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:485 +# code block +msgid "~~~\n" +"date = 'Monday 4 January 2016'\n" +"day = date[0:6]\n" +"print('Using 0 to begin range:', day)\n" +"day = date[:6]\n" +"print('Omitting beginning index:', day)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:494 +# code block +msgid "~~~\n" +"Using 0 to begin range: Monday\n" +"Omitting beginning index: Monday\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:500 +msgid "And similarly, you can omit the ending index in the range to take a slice to the very end of the\n" +"sequence:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:503 +# code block +msgid "~~~\n" +"months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']\n" +"sond = months[8:12]\n" +"print('With known last position:', sond)\n" +"sond = months[8:len(months)]\n" +"print('Using len() to get last entry:', sond)\n" +"sond = months[8:]\n" +"print('Omitting ending index:', sond)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:514 +# code block +msgid "~~~\n" +"With known last position: ['sep', 'oct', 'nov', 'dec']\n" +"Using len() to get last entry: ['sep', 'oct', 'nov', 'dec']\n" +"Omitting ending index: ['sep', 'oct', 'nov', 'dec']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:521 +# blockquote, which can be cascaded +msgid "> ## Overloading" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:522 +msgid ">\n" +"> `+` usually means addition, but when used on strings or lists, it means \"concatenate\".\n" +"> Given that, what do you think the multiplication operator `*` does on lists?\n" +"> In particular, what will be the output of the following code?\n" +">\n" +"> ~~~\n" +"> counts = [2, 4, 6, 8, 10]\n" +"> repeats = counts * 2\n" +"> print(repeats)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> 1. `[2, 4, 6, 8, 10, 2, 4, 6, 8, 10]`\n" +"> 2. `[4, 8, 12, 16, 20]`\n" +"> 3. `[[2, 4, 6, 8, 10],[2, 4, 6, 8, 10]]`\n" +"> 4. `[2, 4, 6, 8, 10, 4, 8, 12, 16, 20]`\n" +">\n" +"> The technical term for this is *operator overloading*:\n" +"> a single operator, like `+` or `*`,\n" +"> can do different things depending on what it's applied to.\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > The multiplication operator `*` used on a list replicates elements of the list and concatenates\n" +"> > them together:\n" +"> >\n" +"> > ~~~\n" +"> > [2, 4, 6, 8, 10, 2, 4, 6, 8, 10]\n" +"> > ~~~\n" +"> > {: .output}\n" +"> >\n" +"> > It's equivalent to:\n" +"> >\n" +"> > ~~~\n" +"> > counts + counts\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:562 +msgid "[hadleywickham-tweet]: https://twitter.com/hadleywickham/status/643381054758363136" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:1 +# Front Matter +msgid "---\n" +"title: Analyzing Data from Multiple Files\n" +"teaching: 20\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I do the same operations on many different files?\"\n" +"objectives:\n" +"- \"Use a library function to get a list of filenames that match a wildcard pattern.\"\n" +"- \"Write a `for` loop to process multiple files.\"\n" +"keypoints:\n" +"- \"Use `glob.glob(pattern)` to create a list of files whose names match a pattern.\"\n" +"- \"Use `*` in a pattern to match zero or more characters, and `?` to match any single character.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:15 +msgid "We now have almost everything we need to process all our data files.\n" +"The only thing that's missing is a library with a rather unpleasant name:" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:18 +# code block +msgid "~~~\n" +"import glob\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:23 +msgid "The `glob` library contains a function, also called `glob`,\n" +"that finds files and directories whose names match a pattern.\n" +"We provide those patterns as strings:\n" +"the character `*` matches zero or more characters,\n" +"while `?` matches any one character.\n" +"We can use this to get the names of all the CSV files in the current directory:" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:30 +# code block +msgid "~~~\n" +"print(glob.glob('inflammation*.csv'))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:35 +# code block +msgid "~~~\n" +"['inflammation-05.csv', 'inflammation-11.csv', 'inflammation-12.csv', 'inflammation-08.csv',\n" +"'inflammation-03.csv', 'inflammation-06.csv', 'inflammation-09.csv', 'inflammation-07.csv',\n" +"'inflammation-10.csv', 'inflammation-02.csv', 'inflammation-04.csv', 'inflammation-01.csv']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:42 +msgid "As these examples show,\n" +"`glob.glob`'s result is a list of file and directory paths in arbitrary order.\n" +"This means we can loop over it\n" +"to do something with each filename in turn.\n" +"In our case,\n" +"the \"something\" we want to do is generate a set of plots for each file in our inflammation dataset.\n" +"If we want to start by analyzing just the first three files in alphabetical order, we can use the\n" +"`sorted` built-in function to generate a new sorted list from the `glob.glob` output:" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:51 +# code block +msgid "~~~\n" +"import glob\n" +"import numpy\n" +"import matplotlib.pyplot\n" +"\n" +"filenames = sorted(glob.glob('inflammation*.csv'))\n" +"filenames = filenames[0:3]\n" +"for filename in filenames:\n" +" print(filename)\n" +"\n" +" data = numpy.loadtxt(fname=filename, delimiter=',')\n" +"\n" +" fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"\n" +" axes1 = fig.add_subplot(1, 3, 1)\n" +" axes2 = fig.add_subplot(1, 3, 2)\n" +" axes3 = fig.add_subplot(1, 3, 3)\n" +"\n" +" axes1.set_ylabel('average')\n" +" axes1.plot(numpy.mean(data, axis=0))\n" +"\n" +" axes2.set_ylabel('max')\n" +" axes2.plot(numpy.max(data, axis=0))\n" +"\n" +" axes3.set_ylabel('min')\n" +" axes3.plot(numpy.min(data, axis=0))\n" +"\n" +" fig.tight_layout()\n" +" matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:83 +# code block +msgid "~~~\n" +"inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:88 +msgid "![Analysis of inflammation-01.csv](../fig/03-loop_49_1.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:90 +# code block +msgid "~~~\n" +"inflammation-02.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:95 +msgid "![Analysis of inflammation-02.csv](../fig/03-loop_49_3.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:97 +# code block +msgid "~~~\n" +"inflammation-03.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:102 +msgid "![Analysis of inflammation-03.csv](../fig/03-loop_49_5.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:104 +msgid "Sure enough,\n" +"the maxima of the first two data sets show exactly the same ramp as the first,\n" +"and their minima show the same staircase structure;\n" +"a different situation has been revealed in the third dataset,\n" +"where the maxima are a bit less regular, but the minima are consistently zero." +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:110 +# blockquote, which can be cascaded +msgid "> ## Plotting Differences" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:111 +msgid ">\n" +"> Plot the difference between the average inflammations reported in the first and second datasets\n" +"> (stored in `inflammation-01.csv` and `inflammation-02.csv`, correspondingly),\n" +"> i.e., the difference between the leftmost plots of the first two figures.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import glob\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > filenames = sorted(glob.glob('inflammation*.csv'))\n" +"> >\n" +"> > data0 = numpy.loadtxt(fname=filenames[0], delimiter=',')\n" +"> > data1 = numpy.loadtxt(fname=filenames[1], delimiter=',')\n" +"> >\n" +"> > fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"> >\n" +"> > matplotlib.pyplot.ylabel('Difference in average')\n" +"> > matplotlib.pyplot.plot(numpy.mean(data0, axis=0) - numpy.mean(data1, axis=0))\n" +"> >\n" +"> > fig.tight_layout()\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:139 +# blockquote, which can be cascaded +msgid "> ## Generate Composite Statistics" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:140 +msgid ">\n" +"> Use each of the files once to generate a dataset containing values averaged over all patients:\n" +">\n" +"> ~~~\n" +"> filenames = glob.glob('inflammation*.csv')\n" +"> composite_data = numpy.zeros((60,40))\n" +"> for filename in filenames:\n" +"> # sum each new file's data into composite_data as it's read\n" +"> #\n" +"> # and then divide the composite_data by number of samples\n" +"> composite_data = composite_data / len(filenames)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Then use pyplot to generate average, max, and min for all patients.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import glob\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > filenames = glob.glob('inflammation*.csv')\n" +"> > composite_data = numpy.zeros((60,40))\n" +"> >\n" +"> > for filename in filenames:\n" +"> > data = numpy.loadtxt(fname = filename, delimiter=',')\n" +"> > composite_data = composite_data + data\n" +"> >\n" +"> > composite_data = composite_data / len(filenames)\n" +"> >\n" +"> > fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"> >\n" +"> > axes1 = fig.add_subplot(1, 3, 1)\n" +"> > axes2 = fig.add_subplot(1, 3, 2)\n" +"> > axes3 = fig.add_subplot(1, 3, 3)\n" +"> >\n" +"> > axes1.set_ylabel('average')\n" +"> > axes1.plot(numpy.mean(composite_data, axis=0))\n" +"> >\n" +"> > axes2.set_ylabel('max')\n" +"> > axes2.plot(numpy.max(composite_data, axis=0))\n" +"> >\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(composite_data, axis=0))\n" +"> >\n" +"> > fig.tight_layout()\n" +"> >\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:191 +# SC/DC Template label +msgid ">{: .solution}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:1 +# Front Matter +msgid "---\n" +"title: Making Choices\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can my programs do different things based on data values?\"\n" +"objectives:\n" +"- \"Write conditional statements including `if`, `elif`, and `else` branches.\"\n" +"- \"Correctly evaluate expressions containing `and` and `or`.\"\n" +"keypoints:\n" +"- \"Use `if condition` to start a conditional statement, `elif condition` to\n" +" provide additional tests, and `else` to provide a default.\"\n" +"- \"The bodies of the branches of conditional statements must be indented.\"\n" +"- \"Use `==` to test for equality.\"\n" +"- \"`X and Y` is only true if both `X` and `Y` are true.\"\n" +"- \"`X or Y` is true if either `X` or `Y`, or both, are true.\"\n" +"- \"Zero, the empty string, and the empty list are considered false;\n" +" all other numbers, strings, and lists are considered true.\"\n" +"- \"`True` and `False` represent truth values.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:22 +msgid "In our last lesson, we discovered something suspicious was going on\n" +"in our inflammation data by drawing some plots.\n" +"How can we use Python to automatically recognize the different features we saw,\n" +"and take a different action for each? In this lesson, we'll learn how to write code that\n" +"runs only when certain conditions are true." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:28 +# header +msgid "## Conditionals" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:30 +msgid "We can ask Python to take different actions, depending on a condition, with an `if` statement:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:32 +# code block +msgid "~~~\n" +"num = 37\n" +"if num > 100:\n" +" print('greater')\n" +"else:\n" +" print('not greater')\n" +"print('done')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:42 +# code block +msgid "~~~\n" +"not greater\n" +"done\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:48 +msgid "The second line of this code uses the keyword `if` to tell Python that we want to make a choice.\n" +"If the test that follows the `if` statement is true,\n" +"the body of the `if`\n" +"(i.e., the set of lines indented underneath it) is executed, and \"greater\" is printed.\n" +"If the test is false,\n" +"the body of the `else` is executed instead, and \"not greater\" is printed.\n" +"Only one or the other is ever executed before continuing on with program execution to print \"done\":" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:56 +msgid "![A flowchart diagram of the if-else construct that tests if variable num is greater than 100](../fig/python-flowchart-conditional.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:58 +msgid "Conditional statements don't have to include an `else`.\n" +"If there isn't one,\n" +"Python simply does nothing if the test is false:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:62 +# code block +msgid "~~~\n" +"num = 53\n" +"print('before conditional...')\n" +"if num > 100:\n" +" print(num,' is greater than 100')\n" +"print('...after conditional')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:71 +# code block +msgid "~~~\n" +"before conditional...\n" +"...after conditional\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:77 +msgid "We can also chain several tests together using `elif`,\n" +"which is short for \"else if\".\n" +"The following Python code uses `elif` to print the sign of a number." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:81 +# code block +msgid "~~~\n" +"num = -3\n" +"\n" +"if num > 0:\n" +" print(num, 'is positive')\n" +"elif num == 0:\n" +" print(num, 'is zero')\n" +"else:\n" +" print(num, 'is negative')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:93 +# code block +msgid "~~~\n" +"-3 is negative\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:98 +msgid "Note that to test for equality we use a double equals sign `==`\n" +"rather than a single equals sign `=` which is used to assign values." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:101 +# blockquote, which can be cascaded +msgid "> ## Comparing in Python" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:102 +msgid ">\n" +"> Along with the `>` and `==` operators we have already used for comparing values in our conditionals, \n" +"> there are a few more options to know about:\n" +">\n" +"> - `>`: greater than\n" +"> - `<`: less than\n" +"> - `==`: equal to\n" +"> - `!=`: does not equal\n" +"> - `>=`: greater than or equal to\n" +"> - `<=`: less than or equal to" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:114 +msgid "We can also combine tests using `and` and `or`.\n" +"`and` is only true if both parts are true:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:117 +# code block +msgid "~~~\n" +"if (1 > 0) and (-1 >= 0):\n" +" print('both parts are true')\n" +"else:\n" +" print('at least one part is false')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:125 +# code block +msgid "~~~\n" +"at least one part is false\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:130 +msgid "while `or` is true if at least one part is true:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:132 +# code block +msgid "~~~\n" +"if (1 < 0) or (1 >= 0):\n" +" print('at least one test is true')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:138 +# code block +msgid "~~~\n" +"at least one test is true\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:143 +# blockquote, which can be cascaded +msgid "> ## `True` and `False`" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:144 +# blockquote, which can be cascaded +msgid "> `True` and `False` are special words in Python called `booleans`," +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:145 +# blockquote, which can be cascaded +msgid "> which represent truth values. A statement such as `1 < 0` returns" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:146 +# blockquote, which can be cascaded +msgid "> the value `False`, while `-1 < 0` returns the value `True`." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:149 +# header +msgid "## Checking our Data" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:151 +msgid "Now that we've seen how conditionals work,\n" +"we can use them to check for the suspicious features we saw in our inflammation data.\n" +"We are about to use functions provided by the `numpy` module again.\n" +"Therefore, if you're working in a new Python session, make sure to load the\n" +"module with:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:162 +msgid "From the first couple of plots, we saw that maximum daily inflammation exhibits\n" +"a strange behavior and raises one unit a day.\n" +"Wouldn't it be a good idea to detect such behavior and report it as suspicious?\n" +"Let's do that!\n" +"However, instead of checking every single day of the study, let's merely check\n" +"if maximum inflammation in the beginning (day 0) and in the middle (day 20) of\n" +"the study are equal to the corresponding day numbers." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:170 +# code block +msgid "~~~\n" +"max_inflammation_0 = numpy.max(data, axis=0)[0]\n" +"max_inflammation_20 = numpy.max(data, axis=0)[20]\n" +"\n" +"if max_inflammation_0 == 0 and max_inflammation_20 == 20:\n" +" print('Suspicious looking maxima!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:179 +msgid "We also saw a different problem in the third dataset;\n" +"the minima per day were all zero (looks like a healthy person snuck into our study).\n" +"We can also check for this with an `elif` condition:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:183 +# code block +msgid "~~~\n" +"elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:189 +msgid "And if neither of these conditions are true, we can use `else` to give the all-clear:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:191 +# code block +msgid "~~~\n" +"else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:197 +msgid "Let's test that out:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:199 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"\n" +"max_inflammation_0 = numpy.max(data, axis=0)[0]\n" +"max_inflammation_20 = numpy.max(data, axis=0)[20]\n" +"\n" +"if max_inflammation_0 == 0 and max_inflammation_20 == 20:\n" +" print('Suspicious looking maxima!')\n" +"elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +"else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:214 +# code block +msgid "~~~\n" +"Suspicious looking maxima!\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:219 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-03.csv', delimiter=',')\n" +"\n" +"max_inflammation_0 = numpy.max(data, axis=0)[0]\n" +"max_inflammation_20 = numpy.max(data, axis=0)[20]\n" +"\n" +"if max_inflammation_0 == 0 and max_inflammation_20 == 20:\n" +" print('Suspicious looking maxima!')\n" +"elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +"else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:234 +# code block +msgid "~~~\n" +"Minima add up to zero!\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:239 +msgid "In this way,\n" +"we have asked Python to do something different depending on the condition of our data.\n" +"Here we printed messages in all cases,\n" +"but we could also imagine not using the `else` catch-all\n" +"so that messages are only printed when something is wrong,\n" +"freeing us from having to manually examine every plot for features we've seen before." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:246 +# blockquote, which can be cascaded +msgid "> ## How Many Paths?" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:247 +msgid ">\n" +"> Consider this code:\n" +">\n" +"> ~~~\n" +"> if 4 > 5:\n" +"> print('A')\n" +"> elif 4 == 5:\n" +"> print('B')\n" +"> elif 4 < 5:\n" +"> print('C')\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Which of the following would be printed if you were to run this code?\n" +"> Why did you pick this answer?\n" +">\n" +"> 1. A\n" +"> 2. B\n" +"> 3. C\n" +"> 4. B and C\n" +">\n" +"> > ## Solution\n" +"> > C gets printed because the first two conditions, `4 > 5` and `4 == 5`, are not true,\n" +"> > but `4 < 5` is true." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:274 +# blockquote, which can be cascaded +msgid "> ## What Is Truth?" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:275 +msgid ">\n" +"> `True` and `False` booleans are not the only values in Python that are true and false.\n" +"> In fact, *any* value can be used in an `if` or `elif`.\n" +"> After reading and running the code below,\n" +"> explain what the rule is for which values are considered true and which are considered false.\n" +">\n" +"> ~~~\n" +"> if '':\n" +"> print('empty string is true')\n" +"> if 'word':\n" +"> print('word is true')\n" +"> if []:\n" +"> print('empty list is true')\n" +"> if [1, 2, 3]:\n" +"> print('non-empty list is true')\n" +"> if 0:\n" +"> print('zero is true')\n" +"> if 1:\n" +"> print('one is true')\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:298 +# blockquote, which can be cascaded +msgid "> ## That's Not Not What I Meant" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:299 +msgid ">\n" +"> Sometimes it is useful to check whether some condition is not true.\n" +"> The Boolean operator `not` can do this explicitly.\n" +"> After reading and running the code below,\n" +"> write some `if` statements that use `not` to test the rule\n" +"> that you formulated in the previous challenge.\n" +">\n" +"> ~~~\n" +"> if not '':\n" +"> print('empty string is not true')\n" +"> if not 'word':\n" +"> print('word is not true')\n" +"> if not not True:\n" +"> print('not not True is true')\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:317 +# blockquote, which can be cascaded +msgid "> ## Close Enough" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:318 +msgid ">\n" +"> Write some conditions that print `True` if the variable `a` is within 10% of the variable `b`\n" +"> and `False` otherwise.\n" +"> Compare your implementation with your partner's:\n" +"> do you get the same answer for all possible pairs of numbers?\n" +">\n" +"> > ## Hint\n" +"> > There is a [built-in function `abs`][abs-function] that returns the absolute value of\n" +"> > a number:\n" +"> > ~~~\n" +"> > print(abs(-12))\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> > ~~~\n" +"> > 12\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:336 +msgid ">\n" +"> > ## Solution 1\n" +"> > ~~~\n" +"> > a = 5\n" +"> > b = 5.1\n" +"> >\n" +"> > if abs(a - b) <= 0.1 * abs(b):\n" +"> > print('True')\n" +"> > else:\n" +"> > print('False')\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:349 +msgid ">\n" +"> > ## Solution 2\n" +"> > ~~~\n" +"> > print(abs(a - b) <= 0.1 * abs(b))\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > This works because the Booleans `True` and `False`\n" +"> > have string representations which can be printed." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:361 +# blockquote, which can be cascaded +msgid "> ## In-Place Operators" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:362 +msgid ">\n" +"> Python (and most other languages in the C family) provides\n" +"> [in-place operators]({{ page.root }}/reference.html#in-place-operators)\n" +"> that work like this:\n" +">\n" +"> ~~~\n" +"> x = 1 # original value\n" +"> x += 1 # add one to x, assigning result back to x\n" +"> x *= 3 # multiply x by 3\n" +"> print(x)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 6\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:379 +msgid ">\n" +"> Write some code that sums the positive and negative numbers in a list separately,\n" +"> using in-place operators.\n" +"> Do you think the result is more or less readable\n" +"> than writing the same without in-place operators?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > positive_sum = 0\n" +"> > negative_sum = 0\n" +"> > test_list = [3, 4, 6, 1, -1, -5, 0, 7, -8]\n" +"> > for num in test_list:\n" +"> > if num > 0:\n" +"> > positive_sum += num\n" +"> > elif num == 0:\n" +"> > pass\n" +"> > else:\n" +"> > negative_sum += num\n" +"> > print(positive_sum, negative_sum)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > Here `pass` means \"don't do anything\".\n" +"> In this particular case, it's not actually needed, since if `num == 0` neither\n" +"> > sum needs to change, but it illustrates the use of `elif` and `pass`." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:407 +# blockquote, which can be cascaded +msgid "> ## Sorting a List Into Buckets" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:408 +msgid ">\n" +"> In our `data` folder, large data sets are stored in files whose names start with\n" +"> \"inflammation-\" and small data sets -- in files whose names start with \"small-\". We\n" +"> also have some other files that we do not care about at this point. We'd like to break all\n" +"> these files into three lists called `large_files`, `small_files`, and `other_files`,\n" +"> respectively.\n" +">\n" +"> Add code to the template below to do this. Note that the string method\n" +"> [`startswith`](https://docs.python.org/3/library/stdtypes.html#str.startswith)\n" +"> returns `True` if and only if the string it is called on starts with the string\n" +"> passed as an argument, that is:\n" +">\n" +"> ~~~\n" +"> 'String'.startswith('Str')\n" +"> ~~~\n" +"> {: .language-python}\n" +"> ~~~\n" +"> True\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:428 +# blockquote, which can be cascaded +msgid "> But" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:430 +# blockquote, which can be cascaded +msgid "> 'String'.startswith('str')" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:434 +# blockquote, which can be cascaded +msgid "> False" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:437 +msgid ">Use the following Python code as your starting point:\n" +"> ~~~\n" +"> filenames = ['inflammation-01.csv',\n" +"> 'myscript.py',\n" +"> 'inflammation-02.csv',\n" +"> 'small-01.csv',\n" +"> 'small-02.csv']\n" +"> large_files = []\n" +"> small_files = []\n" +"> other_files = []\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Your solution should:\n" +">\n" +"> 1. loop over the names of the files\n" +"> 2. figure out which group each filename belongs in\n" +"> 3. append the filename to that list\n" +">\n" +"> In the end the three lists should be:\n" +">\n" +"> ~~~\n" +"> large_files = ['inflammation-01.csv', 'inflammation-02.csv']\n" +"> small_files = ['small-01.csv', 'small-02.csv']\n" +"> other_files = ['myscript.py']\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > for filename in filenames:\n" +"> > if filename.startswith('inflammation-'):\n" +"> > large_files.append(filename)\n" +"> > elif filename.startswith('small-'):\n" +"> > small_files.append(filename)\n" +"> > else:\n" +"> > other_files.append(filename)\n" +"> >\n" +"> > print('large_files:', large_files)\n" +"> > print('small_files:', small_files)\n" +"> > print('other_files:', other_files)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:483 +# blockquote, which can be cascaded +msgid "> ## Counting Vowels" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:484 +msgid ">\n" +"> 1. Write a loop that counts the number of vowels in a character string.\n" +"> 2. Test it on a few individual words and full sentences.\n" +"> 3. Once you are done, compare your solution to your neighbor's.\n" +"> Did you make the same decisions about how to handle the letter 'y'\n" +"> (which some people think is a vowel, and some do not)?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > vowels = 'aeiouAEIOU'\n" +"> > sentence = 'Mary had a little lamb.'\n" +"> > count = 0\n" +"> > for char in sentence:\n" +"> > if char in vowels:\n" +"> > count += 1\n" +"> >\n" +"> > print('The number of vowels in this string is ' + str(count))\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:506 +msgid "[abs-function]: https://docs.python.org/3/library/functions.html#abs" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:1 +# Front Matter +msgid "---\n" +"title: Creating Functions\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I define new functions?\"\n" +"- \"What's the difference between defining and calling a function?\"\n" +"- \"What happens when I call a function?\"\n" +"objectives:\n" +"- \"Define a function that takes parameters.\"\n" +"- \"Return a value from a function.\"\n" +"- \"Test and debug a function.\"\n" +"- \"Set default values for function parameters.\"\n" +"- \"Explain why we should divide programs into small, single-purpose functions.\"\n" +"keypoints:\n" +"- \"Define a function using `def function_name(parameter)`.\"\n" +"- \"The body of a function must be indented.\"\n" +"- \"Call a function using `function_name(value)`.\"\n" +"- \"Numbers are stored as integers or floating-point numbers.\"\n" +"- \"Variables defined within a function can only be seen and used within the body of the function.\"\n" +"- \"If a variable is not defined within the function it is used,\n" +" Python looks for a definition before the function call\"\n" +"- \"Use `help(thing)` to view help for something.\"\n" +"- \"Put docstrings in functions to provide help for that function.\"\n" +"- \"Specify default values for parameters when defining a function using `name=value`\n" +" in the parameter list.\"\n" +"- \"Parameters can be passed by matching based on name, by position,\n" +" or by omitting them (in which case the default value is used).\"\n" +"- \"Put code whose parameters change frequently in a function,\n" +" then call it with different parameter values to customize its behavior.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:33 +msgid "At this point,\n" +"we've written code to draw some interesting features in our inflammation data,\n" +"loop over all our data files to quickly draw these plots for each of them,\n" +"and have Python make decisions based on what it sees in our data.\n" +"But, our code is getting pretty long and complicated;\n" +"what if we had thousands of datasets,\n" +"and didn't want to generate a figure for every single one?\n" +"Commenting out the figure-drawing code is a nuisance.\n" +"Also, what if we want to use that code again,\n" +"on a different dataset or at a different point in our program?\n" +"Cutting and pasting it is going to make our code get very long and very repetitive,\n" +"very quickly.\n" +"We'd like a way to package our code so that it is easier to reuse,\n" +"and Python provides for this by letting us define things called 'functions' ---\n" +"a shorthand way of re-executing longer pieces of code.\n" +"Let's start by defining a function `fahr_to_celsius` that converts temperatures\n" +"from Fahrenheit to Celsius:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:51 +# code block +msgid "~~~\n" +"def fahr_to_celsius(temp):\n" +" return ((temp - 32) * (5/9))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:57 +msgid "![Labeled parts of a Python function definition](../fig/python-function.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:60 +msgid "The function definition opens with the keyword `def` followed by the\n" +"name of the function (`fahr_to_celsius`) and a parenthesized list of parameter names (`temp`). The\n" +"[body]({{ page.root }}/reference.html#body) of the function --- the\n" +"statements that are executed when it runs --- is indented below the\n" +"definition line. The body concludes with a `return` keyword followed by the return value." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:66 +msgid "When we call the function,\n" +"the values we pass to it are assigned to those variables\n" +"so that we can use them inside the function.\n" +"Inside the function,\n" +"we use a [return statement]({{ page.root }}/reference.html#return-statement) to send a result\n" +"back to whoever asked for it." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:73 +msgid "Let's try running our function." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:75 +# code block +msgid "~~~\n" +"fahr_to_celsius(32)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:80 +msgid "This command should call our function, using \"32\" as the input and return the function value." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:82 +msgid "In fact, calling our own function is no different from calling any other function:\n" +"~~~\n" +"print('freezing point of water:', fahr_to_celsius(32), 'C')\n" +"print('boiling point of water:', fahr_to_celsius(212), 'C')\n" +"~~~\n" +"{: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:89 +# code block +msgid "~~~\n" +"freezing point of water: 0.0 C\n" +"boiling point of water: 100.0 C\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:95 +msgid "We've successfully called the function that we defined,\n" +"and we have access to the value that we returned." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:99 +# header +msgid "## Composing Functions" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:101 +msgid "Now that we've seen how to turn Fahrenheit into Celsius,\n" +"we can also write the function to turn Celsius into Kelvin:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:104 +# code block +msgid "~~~\n" +"def celsius_to_kelvin(temp_c):\n" +" return temp_c + 273.15\n" +"\n" +"print('freezing point of water in Kelvin:', celsius_to_kelvin(0.))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:112 +# code block +msgid "~~~\n" +"freezing point of water in Kelvin: 273.15\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:117 +msgid "What about converting Fahrenheit to Kelvin?\n" +"We could write out the formula,\n" +"but we don't need to.\n" +"Instead,\n" +"we can [compose]({{ page.root }}/reference.html#compose) the two functions we have already created:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:123 +# code block +msgid "~~~\n" +"def fahr_to_kelvin(temp_f):\n" +" temp_c = fahr_to_celsius(temp_f)\n" +" temp_k = celsius_to_kelvin(temp_c)\n" +" return temp_k\n" +"\n" +"print('boiling point of water in Kelvin:', fahr_to_kelvin(212.0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:133 +# code block +msgid "~~~\n" +"boiling point of water in Kelvin: 373.15\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:138 +msgid "This is our first taste of how larger programs are built:\n" +"we define basic operations,\n" +"then combine them in ever-larger chunks to get the effect we want.\n" +"Real-life functions will usually be larger than the ones shown here --- typically half a dozen\n" +"to a few dozen lines --- but they shouldn't ever be much longer than that,\n" +"or the next person who reads it won't be able to understand what's going on." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:145 +# header +msgid "## Tidying up" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:147 +msgid "Now that we know how to wrap bits of code up in functions,\n" +"we can make our inflammation analysis easier to read and easier to reuse.\n" +"First, let's make a `visualize` function that generates our plots:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:151 +# code block +msgid "~~~\n" +"def visualize(filename):\n" +"\n" +" data = numpy.loadtxt(fname=filename, delimiter=',')\n" +"\n" +" fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"\n" +" axes1 = fig.add_subplot(1, 3, 1)\n" +" axes2 = fig.add_subplot(1, 3, 2)\n" +" axes3 = fig.add_subplot(1, 3, 3)\n" +"\n" +" axes1.set_ylabel('average')\n" +" axes1.plot(numpy.mean(data, axis=0))\n" +"\n" +" axes2.set_ylabel('max')\n" +" axes2.plot(numpy.max(data, axis=0))\n" +"\n" +" axes3.set_ylabel('min')\n" +" axes3.plot(numpy.min(data, axis=0))\n" +"\n" +" fig.tight_layout()\n" +" matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:176 +msgid "and another function called `detect_problems` that checks for those systematics\n" +"we noticed:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:179 +# code block +msgid "~~~\n" +"def detect_problems(filename):\n" +"\n" +" data = numpy.loadtxt(fname=filename, delimiter=',')\n" +"\n" +" if numpy.max(data, axis=0)[0] == 0 and numpy.max(data, axis=0)[20] == 20:\n" +" print('Suspicious looking maxima!')\n" +" elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +" else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:193 +msgid "Wait! Didn't we forget to specify what both of these functions should return? Well, we didn't.\n" +"In Python, functions are not required to include a `return` statement and can be used for\n" +"the sole purpose of grouping together pieces of code that conceptually do one thing. In such cases,\n" +"function names usually describe what they do, _e.g._ `visualize`, `detect_problems`." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:198 +msgid "Notice that rather than jumbling this code together in one giant `for` loop,\n" +"we can now read and reuse both ideas separately.\n" +"We can reproduce the previous analysis with a much simpler `for` loop:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:202 +# code block +msgid "~~~\n" +"filenames = sorted(glob.glob('inflammation*.csv'))\n" +"\n" +"for filename in filenames[:3]:\n" +" print(filename)\n" +" visualize(filename)\n" +" detect_problems(filename)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:212 +msgid "By giving our functions human-readable names,\n" +"we can more easily read and understand what is happening in the `for` loop.\n" +"Even better, if at some later date we want to use either of those pieces of code again,\n" +"we can do so in a single line." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:217 +# header +msgid "## Testing and Documenting" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:219 +msgid "Once we start putting things in functions so that we can re-use them,\n" +"we need to start testing that those functions are working correctly.\n" +"To see how to do this,\n" +"let's write a function to offset a dataset so that it's mean value\n" +"shifts to a user-defined value:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:225 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value):\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:231 +msgid "We could test this on our actual data,\n" +"but since we don't know what the values ought to be,\n" +"it will be hard to tell if the result was correct.\n" +"Instead,\n" +"let's use NumPy to create a matrix of 0's\n" +"and then offset its values to have a mean value of 3:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:238 +# code block +msgid "~~~\n" +"z = numpy.zeros((2,2))\n" +"print(offset_mean(z, 3))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:244 +#: python-novice-inflammation/_episodes/08-func.md:479 +# code block +msgid "~~~\n" +"[[ 3. 3.]\n" +" [ 3. 3.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:250 +msgid "That looks right,\n" +"so let's try `offset_mean` on our real data:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:253 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"print(offset_mean(data, 0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:259 +# code block +msgid "~~~\n" +"[[-6.14875 -6.14875 -5.14875 ... -3.14875 -6.14875 -6.14875]\n" +" [-6.14875 -5.14875 -4.14875 ... -5.14875 -6.14875 -5.14875]\n" +" [-6.14875 -5.14875 -5.14875 ... -4.14875 -5.14875 -5.14875]\n" +" ...\n" +" [-6.14875 -5.14875 -5.14875 ... -5.14875 -5.14875 -5.14875]\n" +" [-6.14875 -6.14875 -6.14875 ... -6.14875 -4.14875 -6.14875]\n" +" [-6.14875 -6.14875 -5.14875 ... -5.14875 -5.14875 -6.14875]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:270 +msgid "It's hard to tell from the default output whether the result is correct,\n" +"but there are a few tests that we can run to reassure us:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:273 +# code block +msgid "~~~\n" +"print('original min, mean, and max are:', numpy.min(data), numpy.mean(data), numpy.max(data))\n" +"offset_data = offset_mean(data, 0)\n" +"print('min, mean, and max of offset data are:',\n" +" numpy.min(offset_data),\n" +" numpy.mean(offset_data),\n" +" numpy.max(offset_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:283 +# code block +msgid "~~~\n" +"original min, mean, and max are: 0.0 6.14875 20.0\n" +"min, mean, and and max of offset data are: -6.14875 2.84217094304e-16 13.85125\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:289 +msgid "That seems almost right:\n" +"the original mean was about 6.1,\n" +"so the lower bound from zero is now about -6.1.\n" +"The mean of the offset data isn't quite zero --- we'll explore why not in the challenges --- but\n" +"it's pretty close.\n" +"We can even go further and check that the standard deviation hasn't changed:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:296 +# code block +msgid "~~~\n" +"print('std dev before and after:', numpy.std(data), numpy.std(offset_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:301 +# code block +msgid "~~~\n" +"std dev before and after: 4.61383319712 4.61383319712\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:306 +msgid "Those values look the same,\n" +"but we probably wouldn't notice if they were different in the sixth decimal place.\n" +"Let's do this instead:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:310 +# code block +msgid "~~~\n" +"print('difference in standard deviations before and after:',\n" +" numpy.std(data) - numpy.std(offset_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:316 +# code block +msgid "~~~\n" +"difference in standard deviations before and after: -3.5527136788e-15\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:321 +msgid "Again,\n" +"the difference is very small.\n" +"It's still possible that our function is wrong,\n" +"but it seems unlikely enough that we should probably get back to doing our analysis.\n" +"We have one more task first, though:\n" +"we should write some [documentation]({{ page.root }}/reference.html#documentation) for our function\n" +"to remind ourselves later what it's for and how to use it." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:329 +msgid "The usual way to put documentation in software is\n" +"to add [comments]({{ page.root }}/reference.html#comment) like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:332 +# code block +msgid "~~~\n" +"# offset_mean(data, target_mean_value):\n" +"# return a new array containing the original data with its mean offset to match the desired value.\n" +"def offset_mean(data, target_mean_value):\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:340 +msgid "There's a better way, though.\n" +"If the first thing in a function is a string that isn't assigned to a variable,\n" +"that string is attached to the function as its documentation:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:344 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value):\n" +" \"\"\"Return a new array containing the original data\n" +" with its mean offset to match the desired value.\"\"\"\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:352 +msgid "This is better because we can now ask Python's built-in help system to show us\n" +"the documentation for the function:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:355 +# code block +msgid "~~~\n" +"help(offset_mean)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:360 +# code block +msgid "~~~\n" +"Help on function offset_mean in module __main__:\n" +"\n" +"offset_mean(data, target_mean_value)\n" +" Return a new array containing the original data with its mean offset to match the desired value.\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:368 +msgid "A string like this is called a [docstring]({{ page.root }}/reference.html#docstring).\n" +"We don't need to use triple quotes when we write one,\n" +"but if we do,\n" +"we can break the string across multiple lines:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:373 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value):\n" +" \"\"\"Return a new array containing the original data\n" +" with its mean offset to match the desired value.\n" +"\n" +" Examples\n" +" --------\n" +" >>> offset_mean([1, 2, 3], 0)\n" +" array([-1., 0., 1.])\n" +" \"\"\"\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"\n" +"help(offset_mean)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:389 +# code block +msgid "~~~\n" +"Help on function offset_mean in module __main__:\n" +"\n" +"offset_mean(data, target_mean_value)\n" +" Return a new array containing the original data\n" +" with its mean offset to match the desired value.\n" +"\n" +" Examples\n" +" --------\n" +" >>> offset_mean([1, 2, 3], 0)\n" +" array([-1., 0., 1.])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:403 +# header +msgid "## Defining Defaults" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:405 +msgid "We have passed parameters to functions in two ways:\n" +"directly, as in `type(data)`,\n" +"and by name, as in `numpy.loadtxt(fname='something.csv', delimiter=',')`.\n" +"In fact,\n" +"we can pass the filename to `loadtxt` without the `fname=`:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:411 +# code block +msgid "~~~\n" +"numpy.loadtxt('inflammation-01.csv', delimiter=',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:427 +msgid "but we still need to say `delimiter=`:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:429 +#: python-novice-inflammation/_episodes/08-func.md:591 +# code block +msgid "~~~\n" +"numpy.loadtxt('inflammation-01.csv', ',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:434 +# code block +msgid "~~~\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"/Users/username/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py\", line 1041, in loa\n" +"dtxt\n" +" dtype = np.dtype(dtype)\n" +" File \"/Users/username/anaconda3/lib/python3.6/site-packages/numpy/core/_internal.py\", line 199, in\n" +"_commastring\n" +" newitem = (dtype, eval(repeats))\n" +" File \"\", line 1\n" +" ,\n" +" ^\n" +"SyntaxError: unexpected EOF while parsing\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:450 +msgid "To understand what's going on,\n" +"and make our own functions easier to use,\n" +"let's re-define our `offset_mean` function like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:454 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value=0.0):\n" +" \"\"\"Return a new array containing the original data\n" +" with its mean offset to match the desired value, (0 by default).\n" +"\n" +" Examples\n" +" --------\n" +" >>> offset_mean([1, 2, 3])\n" +" array([-1., 0., 1.])\n" +" \"\"\"\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:468 +msgid "The key change is that the second parameter is now written `target_mean_value=0.0`\n" +"instead of just `target_mean_value`.\n" +"If we call the function with two arguments,\n" +"it works as it did before:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:473 +# code block +msgid "~~~\n" +"test_data = numpy.zeros((2, 2))\n" +"print(offset_mean(test_data, 3))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:485 +msgid "But we can also now call it with just one parameter,\n" +"in which case `target_mean_value` is automatically assigned\n" +"the [default value]({{ page.root }}/reference.html#default-value) of 0.0:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:489 +# code block +msgid "~~~\n" +"more_data = 5 + numpy.zeros((2, 2))\n" +"print('data before mean offset:')\n" +"print(more_data)\n" +"print('offset data:')\n" +"print(offset_mean(more_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:498 +# code block +msgid "~~~\n" +"data before mean offset:\n" +"[[ 5. 5.]\n" +" [ 5. 5.]]\n" +"offset data:\n" +"[[ 0. 0.]\n" +" [ 0. 0.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:508 +msgid "This is handy:\n" +"if we usually want a function to work one way,\n" +"but occasionally need it to do something else,\n" +"we can allow people to pass a parameter when they need to\n" +"but provide a default to make the normal case easier.\n" +"The example below shows how Python matches values to parameters:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:515 +# code block +msgid "~~~\n" +"def display(a=1, b=2, c=3):\n" +" print('a:', a, 'b:', b, 'c:', c)\n" +"\n" +"print('no parameters:')\n" +"display()\n" +"print('one parameter:')\n" +"display(55)\n" +"print('two parameters:')\n" +"display(55, 66)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:528 +# code block +msgid "~~~\n" +"no parameters:\n" +"a: 1 b: 2 c: 3\n" +"one parameter:\n" +"a: 55 b: 2 c: 3\n" +"two parameters:\n" +"a: 55 b: 66 c: 3\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:538 +msgid "As this example shows,\n" +"parameters are matched up from left to right,\n" +"and any that haven't been given a value explicitly get their default value.\n" +"We can override this behavior by naming the value as we pass it in:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:543 +# code block +msgid "~~~\n" +"print('only setting the value of c')\n" +"display(c=77)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:549 +# code block +msgid "~~~\n" +"only setting the value of c\n" +"a: 1 b: 2 c: 77\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:555 +msgid "With that in hand,\n" +"let's look at the help for `numpy.loadtxt`:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:558 +# code block +msgid "~~~\n" +"help(numpy.loadtxt)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:563 +# code block +msgid "~~~\n" +"Help on function loadtxt in module numpy.lib.npyio:\n" +"\n" +"loadtxt(fname, dtype=, comments='#', delimiter=None, converters=None, skiprows=0, use\n" +"cols=None, unpack=False, ndmin=0, encoding='bytes')\n" +" Load data from a text file.\n" +"\n" +" Each row in the text file must have the same number of values.\n" +"\n" +" Parameters\n" +" ----------\n" +"...\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:578 +msgid "There's a lot of information here,\n" +"but the most important part is the first couple of lines:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:581 +# code block +msgid "~~~\n" +"loadtxt(fname, dtype=, comments='#', delimiter=None, converters=None, skiprows=0, use\n" +"cols=None, unpack=False, ndmin=0, encoding='bytes')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:587 +msgid "This tells us that `loadtxt` has one parameter called `fname` that doesn't have a default value,\n" +"and eight others that do.\n" +"If we call the function like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:596 +msgid "then the filename is assigned to `fname` (which is what we want),\n" +"but the delimiter string `','` is assigned to `dtype` rather than `delimiter`,\n" +"because `dtype` is the second parameter in the list. However `','` isn't a known `dtype` so\n" +"our code produced an error message when we tried to run it.\n" +"When we call `loadtxt` we don't have to provide `fname=` for the filename because it's the\n" +"first item in the list, but if we want the `','` to be assigned to the variable `delimiter`,\n" +"we *do* have to provide `delimiter=` for the second parameter since `delimiter` is not\n" +"the second parameter in the list." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:605 +# header +msgid "## Readable functions" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:607 +msgid "Consider these two functions:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:609 +# code block +msgid "~~~\n" +"def s(p):\n" +" a = 0\n" +" for v in p:\n" +" a += v\n" +" m = a / len(p)\n" +" d = 0\n" +" for v in p:\n" +" d += (v - m) * (v - m)\n" +" return numpy.sqrt(d / (len(p) - 1))\n" +"\n" +"def std_dev(sample):\n" +" sample_sum = 0\n" +" for value in sample:\n" +" sample_sum += value\n" +"\n" +" sample_mean = sample_sum / len(sample)\n" +"\n" +" sum_squared_devs = 0\n" +" for value in sample:\n" +" sum_squared_devs += (value - sample_mean) * (value - sample_mean)\n" +"\n" +" return numpy.sqrt(sum_squared_devs / (len(sample) - 1))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:635 +msgid "The functions `s` and `std_dev` are computationally equivalent (they\n" +"both calculate the sample standard deviation), but to a human reader,\n" +"they look very different. You probably found `std_dev` much easier to\n" +"read and understand than `s`." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:640 +msgid "As this example illustrates, both documentation and a programmer's\n" +"_coding style_ combine to determine how easy it is for others to read\n" +"and understand the programmer's code. Choosing meaningful variable\n" +"names and using blank spaces to break the code into logical \"chunks\"\n" +"are helpful techniques for producing _readable code_. This is useful\n" +"not only for sharing code with others, but also for the original\n" +"programmer. If you need to revisit code that you wrote months ago and\n" +"haven't thought about since then, you will appreciate the value of\n" +"readable code!" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:650 +# blockquote, which can be cascaded +msgid "> ## Combining Strings" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:651 +msgid ">\n" +"> \"Adding\" two strings produces their concatenation:\n" +"> `'a' + 'b'` is `'ab'`.\n" +"> Write a function called `fence` that takes two parameters called `original` and `wrapper`\n" +"> and returns a new string that has the wrapper character at the beginning and end of the original.\n" +"> A call to your function should look like this:\n" +">\n" +"> ~~~\n" +"> print(fence('name', '*'))\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> *name*\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:667 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def fence(original, wrapper):\n" +"> > return wrapper + original + wrapper\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:677 +# blockquote, which can be cascaded +msgid "> ## Return versus print" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:678 +msgid ">\n" +"> Note that `return` and `print` are not interchangeable.\n" +"> `print` is a Python function that *prints* data to the screen.\n" +"> It enables us, *users*, see the data.\n" +"> `return` statement, on the other hand, makes data visible to the program.\n" +"> Let's have a look at the following function:\n" +">\n" +"> ~~~\n" +"> def add(a, b):\n" +"> print(a + b)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> **Question**: What will we see if we execute the following commands?\n" +"> ~~~\n" +"> A = add(7, 3)\n" +"> print(A)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > Python will first execute the function `add` with `a = 7` and `b = 3`,\n" +"> > and, therefore, print `10`. However, because function `add` does not have a\n" +"> > line that starts with `return` (no `return` \"statement\"), it will, by default, return\n" +"> > nothing which, in Python world, is called `None`. Therefore, `A` will be assigned to `None`\n" +"> > and the last line (`print(A)`) will print `None`. As a result, we will see:\n" +"> > ~~~\n" +"> > 10\n" +"> > None\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:712 +# blockquote, which can be cascaded +msgid "> ## Selecting Characters From Strings" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:713 +msgid ">\n" +"> If the variable `s` refers to a string,\n" +"> then `s[0]` is the string's first character\n" +"> and `s[-1]` is its last.\n" +"> Write a function called `outer`\n" +"> that returns a string made up of just the first and last characters of its input.\n" +"> A call to your function should look like this:\n" +">\n" +"> ~~~\n" +"> print(outer('helium'))\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> hm\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:730 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def outer(input_string):\n" +"> > return input_string[0] + input_string[-1]\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:740 +# blockquote, which can be cascaded +msgid "> ## Rescaling an Array" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:741 +msgid ">\n" +"> Write a function `rescale` that takes an array as input\n" +"> and returns a corresponding array of values scaled to lie in the range 0.0 to 1.0.\n" +"> (Hint: If `L` and `H` are the lowest and highest values in the original array,\n" +"> then the replacement for a value `v` should be `(v-L) / (H-L)`.)\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def rescale(input_array):\n" +"> > L = numpy.min(input_array)\n" +"> > H = numpy.max(input_array)\n" +"> > output_array = (input_array - L) / (H - L)\n" +"> > return output_array\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:759 +# blockquote, which can be cascaded +msgid "> ## Testing and Documenting Your Function" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:760 +msgid ">\n" +"> Run the commands `help(numpy.arange)` and `help(numpy.linspace)`\n" +"> to see how to use these functions to generate regularly-spaced values,\n" +"> then use those values to test your `rescale` function.\n" +"> Once you've successfully tested your function,\n" +"> add a docstring that explains what it does.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > \"\"\"Takes an array as input, and returns a corresponding array scaled so\n" +"> > that 0 corresponds to the minimum and 1 to the maximum value of the input array.\n" +"> >\n" +"> > Examples:\n" +"> > >>> rescale(numpy.arange(10.0))\n" +"> > array([ 0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444,\n" +"> > 0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ])\n" +"> > >>> rescale(numpy.linspace(0, 100, 5))\n" +"> > array([ 0. , 0.25, 0.5 , 0.75, 1. ])\n" +"> > \"\"\"\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:784 +# blockquote, which can be cascaded +msgid "> ## Defining Defaults" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:785 +msgid ">\n" +"> Rewrite the `rescale` function so that it scales data to lie between `0.0` and `1.0` by default,\n" +"> but will allow the caller to specify lower and upper bounds if they want.\n" +"> Compare your implementation to your neighbor's:\n" +"> do the two functions always behave the same way?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def rescale(input_array, low_val=0.0, high_val=1.0):\n" +"> > \"\"\"rescales input array values to lie between low_val and high_val\"\"\"\n" +"> > L = numpy.min(input_array)\n" +"> > H = numpy.max(input_array)\n" +"> > intermed_array = (input_array - L) / (H - L)\n" +"> > output_array = intermed_array * (high_val - low_val) + low_val\n" +"> > return output_array\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:805 +# blockquote, which can be cascaded +msgid "> ## Variables Inside and Outside Functions" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:806 +msgid ">\n" +"> What does the following piece of code display when run --- and why?\n" +">\n" +"> ~~~\n" +"> f = 0\n" +"> k = 0\n" +">\n" +"> def f2k(f):\n" +"> k = ((f - 32) * (5.0 / 9.0)) + 273.15\n" +"> return k\n" +">\n" +"> print(f2k(8))\n" +"> print(f2k(41))\n" +"> print(f2k(32))\n" +">\n" +"> print(k)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > ~~~\n" +"> > 259.81666666666666\n" +"> > 278.15\n" +"> > 273.15\n" +"> > 0\n" +"> > ~~~\n" +"> > {: .output}\n" +"> > `k` is 0 because the `k` inside the function `f2k` doesn't know\n" +"> > about the `k` defined outside the function." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:839 +# blockquote, which can be cascaded +msgid "> ## Mixing Default and Non-Default Parameters" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:840 +msgid ">\n" +"> Given the following code:\n" +">\n" +"> ~~~\n" +"> def numbers(one, two=2, three, four=4):\n" +"> n = str(one) + str(two) + str(three) + str(four)\n" +"> return n\n" +">\n" +"> print(numbers(1, three=3))\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> what do you expect will be printed? What is actually printed?\n" +"> What rule do you think Python is following?\n" +">\n" +"> 1. `1234`\n" +"> 2. `one2three4`\n" +"> 3. `1239`\n" +"> 4. `SyntaxError`\n" +">\n" +"> Given that, what does the following piece of code display when run?\n" +">\n" +"> ~~~\n" +"> def func(a, b=3, c=6):\n" +"> print('a: ', a, 'b: ', b, 'c:', c)\n" +">\n" +"> func(-1, 2)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> 1. `a: b: 3 c: 6`\n" +"> 2. `a: -1 b: 3 c: 6`\n" +"> 3. `a: -1 b: 2 c: 6`\n" +"> 4. `a: b: -1 c: 2`\n" +">\n" +"> > ## Solution\n" +"> > Attempting to define the `numbers` function results in `4. SyntaxError`.\n" +"> > The defined parameters `two` and `four` are given default values. Because\n" +"> > `one` and `three` are not given default values, they are required to be\n" +"> > included as arguments when the function is called and must be placed\n" +"> > before any parameters that have default values in the function definition.\n" +"> >\n" +"> > The given call to `func` displays `a: -1 b: 2 c: 6`. -1 is assigned to\n" +"> > the first parameter `a`, 2 is assigned to the next parameter `b`, and `c` is\n" +"> > not passed a value, so it uses its default value 6." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:888 +# blockquote, which can be cascaded +msgid "> ## The Old Switcheroo" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:889 +msgid ">\n" +"> Consider this code:\n" +">\n" +"> ~~~\n" +"> a = 3\n" +"> b = 7\n" +">\n" +"> def swap(a, b):\n" +"> temp = a\n" +"> a = b\n" +"> b = temp\n" +">\n" +"> swap(a, b)\n" +">\n" +"> print(a, b)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Which of the following would be printed if you were to run this code?\n" +"> Why did you pick this answer?\n" +">\n" +"> 1. `7 3`\n" +"> 2. `3 7`\n" +"> 3. `3 3`\n" +"> 4. `7 7`\n" +">\n" +"> > ## Solution\n" +"> > `3 7` is the correct answer. Initially, `a` has a value of 3 and `b` has a value of 7.\n" +"> > When the `swap` function is called, it creates local variables (also called\n" +"> > `a` and `b` in this case) and trades their values. The function does not\n" +"> > return any values and does not alter `a` or `b` outside of its local copy.\n" +"> > Therefore the original values of `a` and `b` remain unchanged." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:924 +# blockquote, which can be cascaded +msgid "> ## Readable Code" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:925 +msgid ">\n" +"> Revise a function you wrote for one of the previous exercises to try to make\n" +"> the code more readable. Then, collaborate with one of your neighbors\n" +"> to critique each other's functions and discuss how your function implementations\n" +"> could be further improved to make them more readable." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:1 +# Front Matter +msgid "---\n" +"title: Errors and Exceptions\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How does Python report errors?\"\n" +"- \"How can I handle errors in Python programs?\"\n" +"objectives:\n" +"- \"To be able to read a traceback, and determine where the error took place and what type it is.\"\n" +"- \"To be able to describe the types of situations in which syntax errors,\n" +" indentation errors, name errors, index errors, and missing file errors occur.\"\n" +"keypoints:\n" +"- \"Tracebacks can look intimidating, but they give us a lot of useful information about\n" +" what went wrong in our program, including where the error occurred and\n" +" what type of error it was.\"\n" +"- \"An error having to do with the 'grammar' or syntax of the program is called a `SyntaxError`.\n" +" If the issue has to do with how the code is indented,\n" +" then it will be called an `IndentationError`.\"\n" +"- \"A `NameError` will occur when trying to use a variable that does not exist. Possible causes are\n" +" that a variable definition is missing, a variable reference differs from its definition\n" +" in spelling or capitalization, or the code contains a string that is missing quotes around it.\"\n" +"- \"Containers like lists and strings will generate errors if you try to access items\n" +" in them that do not exist. This type of error is called an `IndexError`.\"\n" +"- \"Trying to read a file that does not exist will give you an `FileNotFoundError`.\n" +" Trying to read a file that is open for writing, or writing to a file that is open for reading,\n" +" will give you an `IOError`.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:29 +msgid "Every programmer encounters errors,\n" +"both those who are just beginning,\n" +"and those who have been programming for years.\n" +"Encountering errors and exceptions can be very frustrating at times,\n" +"and can make coding feel like a hopeless endeavour.\n" +"However,\n" +"understanding what the different types of errors are\n" +"and when you are likely to encounter them can help a lot.\n" +"Once you know *why* you get certain types of errors,\n" +"they become much easier to fix." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:40 +msgid "Errors in Python have a very specific form,\n" +"called a [traceback]({{ page.root }}/reference.html#traceback).\n" +"Let's examine one:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:44 +# code block +msgid "~~~\n" +"# This code has an intentional error. You can type it directly or\n" +"# use it for reference to understand the error message below.\n" +"def favorite_ice_cream():\n" +" ice_creams = [\n" +" 'chocolate',\n" +" 'vanilla',\n" +" 'strawberry'\n" +" ]\n" +" print(ice_creams[3])\n" +"\n" +"favorite_ice_cream()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:59 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"IndexError Traceback (most recent call last)\n" +" in ()\n" +" 9 print(ice_creams[3])\n" +" 10\n" +"----> 11 favorite_ice_cream()\n" +"\n" +" in favorite_ice_cream()\n" +" 7 'strawberry'\n" +" 8 ]\n" +"----> 9 print(ice_creams[3])\n" +" 10\n" +" 11 favorite_ice_cream()\n" +"\n" +"IndexError: list index out of range\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:78 +msgid "This particular traceback has two levels.\n" +"You can determine the number of levels by looking for the number of arrows on the left hand side.\n" +"In this case:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:82 +# ordered list +msgid "1. The first shows code from the cell above," +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:83 +msgid " with an arrow pointing to Line 11 (which is `favorite_ice_cream()`)." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:85 +# ordered list +msgid "2. The second shows some code in the function `favorite_ice_cream`," +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:86 +msgid " with an arrow pointing to Line 9 (which is `print(ice_creams[3])`)." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:88 +msgid "The last level is the actual place where the error occurred.\n" +"The other level(s) show what function the program executed to get to the next level down.\n" +"So, in this case, the program first performed a\n" +"[function call]({{ page.root }}/reference.html#function-call) to the function `favorite_ice_cream`.\n" +"Inside this function,\n" +"the program encountered an error on Line 6, when it tried to run the code `print(ice_creams[3])`." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:95 +# blockquote, which can be cascaded +msgid "> ## Long Tracebacks" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:96 +msgid ">\n" +"> Sometimes, you might see a traceback that is very long\n" +"> -- sometimes they might even be 20 levels deep!\n" +"> This can make it seem like something horrible happened,\n" +"> but the length of the error message does not reflect severity, rather,\n" +"> it indicates that your program called many functions before it encountered the error.\n" +"> Most of the time, the actual place where the error occurred is at the bottom-most level,\n" +"> so you can skip down the traceback to the bottom." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:106 +msgid "So what error did the program actually encounter?\n" +"In the last line of the traceback,\n" +"Python helpfully tells us the category or type of error (in this case, it is an `IndexError`)\n" +"and a more detailed error message (in this case, it says \"list index out of range\")." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:111 +msgid "If you encounter an error and don't know what it means,\n" +"it is still important to read the traceback closely.\n" +"That way,\n" +"if you fix the error,\n" +"but encounter a new one,\n" +"you can tell that the error changed.\n" +"Additionally,\n" +"sometimes knowing *where* the error occurred is enough to fix it,\n" +"even if you don't entirely understand the message." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:121 +msgid "If you do encounter an error you don't recognize,\n" +"try looking at the\n" +"[official documentation on errors](http://docs.python.org/3/library/exceptions.html).\n" +"However,\n" +"note that you may not always be able to find the error there,\n" +"as it is possible to create custom errors.\n" +"In that case,\n" +"hopefully the custom error message is informative enough to help you figure out what went wrong." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:130 +# header +msgid "## Syntax Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:132 +msgid "When you forget a colon at the end of a line,\n" +"accidentally add one space too many when indenting under an `if` statement,\n" +"or forget a parenthesis,\n" +"you will encounter a [syntax error]({{ page.root }}/reference.html#syntax-error).\n" +"This means that Python couldn't figure out how to read your program.\n" +"This is similar to forgetting punctuation in English:\n" +"for example,\n" +"this text is difficult to read there is no punctuation there is also no capitalization\n" +"why is this hard because you have to figure out where each sentence ends\n" +"you also have to figure out where each sentence begins\n" +"to some extent it might be ambiguous if there should be a sentence break or not" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:144 +msgid "People can typically figure out what is meant by text with no punctuation,\n" +"but people are much smarter than computers.\n" +"If Python doesn't know how to read the program,\n" +"it will give up and inform you with an error.\n" +"For example:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:150 +# code block +msgid "~~~\n" +"def some_function()\n" +" msg = 'hello, world!'\n" +" print(msg)\n" +" return msg\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:158 +# code block +msgid "~~~\n" +" File \"\", line 1\n" +" def some_function()\n" +" ^\n" +"SyntaxError: invalid syntax\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:166 +msgid "Here, Python tells us that there is a `SyntaxError` on line 1,\n" +"and even puts a little arrow in the place where there is an issue.\n" +"In this case the problem is that the function definition is missing a colon at the end." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:170 +msgid "Actually, the function above has *two* issues with syntax.\n" +"If we fix the problem with the colon,\n" +"we see that there is *also* an `IndentationError`,\n" +"which means that the lines in the function definition do not all have the same indentation:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:175 +# code block +msgid "~~~\n" +"def some_function():\n" +" msg = 'hello, world!'\n" +" print(msg)\n" +" return msg\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:183 +# code block +msgid "~~~\n" +" File \"\", line 4\n" +" return msg\n" +" ^\n" +"IndentationError: unexpected indent\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:191 +msgid "Both `SyntaxError` and `IndentationError` indicate a problem with the syntax of your program,\n" +"but an `IndentationError` is more specific:\n" +"it *always* means that there is a problem with how your code is indented." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:195 +# blockquote, which can be cascaded +msgid "> ## Tabs and Spaces" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:196 +msgid ">\n" +"> Some indentation errors are harder to spot than others.\n" +"> In particular, mixing spaces and tabs can be difficult to spot\n" +"> because they are both [whitespace]({{ page.root }}/reference.html#whitespace).\n" +"> In the example below, the first two lines in the body of the function\n" +"> `some_function` are indented with tabs, while the third line — with spaces.\n" +"> If you're working in a Jupyter notebook, be sure to copy and paste this example\n" +"> rather than trying to type it in manually because Jupyter automatically replaces\n" +"> tabs with spaces.\n" +">\n" +"> ~~~\n" +"> def some_function():\n" +"> msg = 'hello, world!'\n" +"> print(msg)\n" +"> return msg\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Visually it is impossible to spot the error.\n" +"> Fortunately, Python does not allow you to mix tabs and spaces.\n" +">\n" +"> ~~~\n" +"> File \"\", line 4\n" +"> return msg\n" +"> ^\n" +"> TabError: inconsistent use of tabs and spaces in indentation\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:223 +#: python-novice-inflammation/_episodes/09-errors.md:491 +# SC/DC Template label +msgid "> {: .error}" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:226 +# header +msgid "## Variable Name Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:228 +msgid "Another very common type of error is called a `NameError`,\n" +"and occurs when you try to use a variable that does not exist.\n" +"For example:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:232 +# code block +msgid "~~~\n" +"print(a)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:237 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 print(a)\n" +"\n" +"NameError: name 'a' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:247 +msgid "Variable name errors come with some of the most informative error messages,\n" +"which are usually of the form \"name 'the_variable_name' is not defined\"." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:250 +msgid "Why does this error message occur?\n" +"That's a harder question to answer,\n" +"because it depends on what your code is supposed to do.\n" +"However,\n" +"there are a few very common reasons why you might have an undefined variable.\n" +"The first is that you meant to use a\n" +"[string]({{ page.root }}/reference.html#string), but forgot to put quotes around it:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:258 +# code block +msgid "~~~\n" +"print(hello)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:263 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 print(hello)\n" +"\n" +"NameError: name 'hello' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:273 +msgid "The second reason is that you might be trying to use a variable that does not yet exist.\n" +"In the following example,\n" +"`count` should have been defined (e.g., with `count = 0`) before the for loop:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:277 +# code block +msgid "~~~\n" +"for number in range(10):\n" +" count = count + number\n" +"print('The count is:', count)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:284 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +" 1 for number in range(10):\n" +"----> 2 count = count + number\n" +" 3 print('The count is:', count)\n" +"\n" +"NameError: name 'count' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:296 +msgid "Finally, the third possibility is that you made a typo when you were writing your code.\n" +"Let's say we fixed the error above by adding the line `Count = 0` before the for loop.\n" +"Frustratingly, this actually does not fix the error.\n" +"Remember that variables are [case-sensitive]({{ page.root }}/reference.html#case-sensitive),\n" +"so the variable `count` is different from `Count`. We still get the same error,\n" +"because we still have not defined `count`:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:303 +# code block +msgid "~~~\n" +"Count = 0\n" +"for number in range(10):\n" +" count = count + number\n" +"print('The count is:', count)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:311 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +" 1 Count = 0\n" +" 2 for number in range(10):\n" +"----> 3 count = count + number\n" +" 4 print('The count is:', count)\n" +"\n" +"NameError: name 'count' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:324 +# header +msgid "## Index Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:326 +msgid "Next up are errors having to do with containers (like lists and strings) and the items within them.\n" +"If you try to access an item in a list or a string that does not exist,\n" +"then you will get an error.\n" +"This makes sense:\n" +"if you asked someone what day they would like to get coffee,\n" +"and they answered \"caturday\",\n" +"you might be a bit annoyed.\n" +"Python gets similarly annoyed if you try to ask it for an item that doesn't exist:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:335 +# code block +msgid "~~~\n" +"letters = ['a', 'b', 'c']\n" +"print('Letter #1 is', letters[0])\n" +"print('Letter #2 is', letters[1])\n" +"print('Letter #3 is', letters[2])\n" +"print('Letter #4 is', letters[3])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:344 +# code block +msgid "~~~\n" +"Letter #1 is a\n" +"Letter #2 is b\n" +"Letter #3 is c\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:351 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"IndexError Traceback (most recent call last)\n" +" in ()\n" +" 3 print('Letter #2 is', letters[1])\n" +" 4 print('Letter #3 is', letters[2])\n" +"----> 5 print('Letter #4 is', letters[3])\n" +"\n" +"IndexError: list index out of range\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:363 +msgid "Here,\n" +"Python is telling us that there is an `IndexError` in our code,\n" +"meaning we tried to access a list index that did not exist." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:367 +# header +msgid "## File Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:369 +msgid "The last type of error we'll cover today\n" +"are those associated with reading and writing files: `FileNotFoundError`.\n" +"If you try to read a file that does not exist,\n" +"you will receive a `FileNotFoundError` telling you so.\n" +"If you attempt to write to a file that was opened read-only, Python 3\n" +"returns an `UnsupportedOperationError`.\n" +"More generally, problems with input and output manifest as\n" +"`IOError`s or `OSError`s, depending on the version of Python you use." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:378 +# code block +msgid "~~~\n" +"file_handle = open('myfile.txt', 'r')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:383 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"FileNotFoundError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 file_handle = open('myfile.txt', 'r')\n" +"\n" +"FileNotFoundError: [Errno 2] No such file or directory: 'myfile.txt'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:393 +msgid "One reason for receiving this error is that you specified an incorrect path to the file.\n" +"For example,\n" +"if I am currently in a folder called `myproject`,\n" +"and I have a file in `myproject/writing/myfile.txt`,\n" +"but I try to open `myfile.txt`,\n" +"this will fail.\n" +"The correct path would be `writing/myfile.txt`.\n" +"It is also possible that the file name or its path contains a typo." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:402 +msgid "A related issue can occur if you use the \"read\" flag instead of the \"write\" flag.\n" +"Python will not give you an error if you try to open a file for writing\n" +"when the file does not exist.\n" +"However,\n" +"if you meant to open a file for reading,\n" +"but accidentally opened it for writing,\n" +"and then try to read from it,\n" +"you will get an `UnsupportedOperation` error\n" +"telling you that the file was not opened for reading:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:412 +# code block +msgid "~~~\n" +"file_handle = open('myfile.txt', 'w')\n" +"file_handle.read()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:418 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"UnsupportedOperation Traceback (most recent call last)\n" +" in ()\n" +" 1 file_handle = open('myfile.txt', 'w')\n" +"----> 2 file_handle.read()\n" +"\n" +"UnsupportedOperation: not readable\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:429 +msgid "These are the most common errors with files,\n" +"though many others exist.\n" +"If you get an error that you've never seen before,\n" +"searching the Internet for that error type\n" +"often reveals common reasons why you might get that error." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:435 +# blockquote, which can be cascaded +msgid "> ## Reading Error Messages" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:436 +msgid ">\n" +"> Read the Python code and the resulting traceback below, and answer the following questions:\n" +">\n" +"> 1. How many levels does the traceback have?\n" +"> 2. What is the function name where the error occurred?\n" +"> 3. On which line number in this function did the error occur?\n" +"> 4. What is the type of error?\n" +"> 5. What is the error message?\n" +">\n" +"> ~~~\n" +"> # This code has an intentional error. Do not type it directly;\n" +"> # use it for reference to understand the error message below.\n" +"> def print_message(day):\n" +"> messages = {\n" +"> 'monday': 'Hello, world!',\n" +"> 'tuesday': 'Today is Tuesday!',\n" +"> 'wednesday': 'It is the middle of the week.',\n" +"> 'thursday': 'Today is Donnerstag in German!',\n" +"> 'friday': 'Last day of the week!',\n" +"> 'saturday': 'Hooray for the weekend!',\n" +"> 'sunday': 'Aw, the weekend is almost over.'\n" +"> }\n" +"> print(messages[day])\n" +">\n" +"> def print_friday_message():\n" +"> print_message('Friday')\n" +">\n" +"> print_friday_message()\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> ---------------------------------------------------------------------------\n" +"> KeyError Traceback (most recent call last)\n" +"> in ()\n" +"> 14 print_message('Friday')\n" +"> 15\n" +"> ---> 16 print_friday_message()\n" +">\n" +"> in print_friday_message()\n" +"> 12\n" +"> 13 def print_friday_message():\n" +"> ---> 14 print_message('Friday')\n" +"> 15\n" +"> 16 print_friday_message()\n" +">\n" +"> in print_message(day)\n" +"> 9 'sunday': 'Aw, the weekend is almost over.'\n" +"> 10 }\n" +"> ---> 11 print(messages[day])\n" +"> 12\n" +"> 13 def print_friday_message():\n" +">\n" +"> KeyError: 'Friday'\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:492 +msgid ">\n" +"> > ## Solution\n" +"> > 1. 3 levels\n" +"> > 2. `print_message`\n" +"> > 3. 11\n" +"> > 4. `KeyError`\n" +"> > 5. There isn't really a message; you're supposed to infer that `Friday` is not a key in `messages`." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:502 +# blockquote, which can be cascaded +msgid "> ## Identifying Syntax Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:503 +msgid ">\n" +"> 1. Read the code below, and (without running it) try to identify what the errors are.\n" +"> 2. Run the code, and read the error message. Is it a `SyntaxError` or an `IndentationError`?\n" +"> 3. Fix the error.\n" +"> 4. Repeat steps 2 and 3, until you have fixed all the errors.\n" +">\n" +"> ~~~\n" +"> def another_function\n" +"> print('Syntax errors are annoying.')\n" +"> print('But at least Python tells us about them!')\n" +"> print('So they are usually not too hard to fix.')\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > `SyntaxError` for missing `():` at end of first line,\n" +"> `IndentationError` for mismatch between second and third lines.\n" +"> > A fixed version is:\n" +"> >\n" +"> > ~~~\n" +"> > def another_function():\n" +"> > print('Syntax errors are annoying.')\n" +"> > print('But at least Python tells us about them!')\n" +"> > print('So they are usually not too hard to fix.')\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:532 +# blockquote, which can be cascaded +msgid "> ## Identifying Variable Name Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:533 +msgid ">\n" +"> 1. Read the code below, and (without running it) try to identify what the errors are.\n" +"> 2. Run the code, and read the error message.\n" +"> What type of `NameError` do you think this is?\n" +"> In other words, is it a string with no quotes,\n" +"> a misspelled variable,\n" +"> or a variable that should have been defined but was not?\n" +"> 3. Fix the error.\n" +"> 4. Repeat steps 2 and 3, until you have fixed all the errors.\n" +">\n" +"> ~~~\n" +"> for number in range(10):\n" +"> # use a if the number is a multiple of 3, otherwise use b\n" +"> if (Number % 3) == 0:\n" +"> message = message + a\n" +"> else:\n" +"> message = message + 'b'\n" +"> print(message)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > 3 `NameError`s for `number` being misspelled, for `message` not defined,\n" +"> > and for `a` not being in quotes.\n" +"> >\n" +"> > Fixed version:\n" +"> >\n" +"> > ~~~\n" +"> > message = ''\n" +"> > for number in range(10):\n" +"> > # use a if the number is a multiple of 3, otherwise use b\n" +"> > if (number % 3) == 0:\n" +"> > message = message + 'a'\n" +"> > else:\n" +"> > message = message + 'b'\n" +"> > print(message)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:574 +# blockquote, which can be cascaded +msgid "> ## Identifying Index Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:575 +msgid ">\n" +"> 1. Read the code below, and (without running it) try to identify what the errors are.\n" +"> 2. Run the code, and read the error message. What type of error is it?\n" +"> 3. Fix the error.\n" +">\n" +"> ~~~\n" +"> seasons = ['Spring', 'Summer', 'Fall', 'Winter']\n" +"> print('My favorite season is ', seasons[4])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > `IndexError`; the last entry is `seasons[3]`, so `seasons[4]` doesn't make sense.\n" +"> > A fixed version is:\n" +"> >\n" +"> > ~~~\n" +"> > seasons = ['Spring', 'Summer', 'Fall', 'Winter']\n" +"> > print('My favorite season is ', seasons[-1])\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:1 +# Front Matter +msgid "---\n" +"title: Defensive Programming\n" +"teaching: 30\n" +"exercises: 10\n" +"questions:\n" +"- \"How can I make my programs more reliable?\"\n" +"objectives:\n" +"- \"Explain what an assertion is.\"\n" +"- \"Add assertions that check the program's state is correct.\"\n" +"- \"Correctly add precondition and postcondition assertions to functions.\"\n" +"- \"Explain what test-driven development is, and use it when creating new functions.\"\n" +"- \"Explain why variables should be initialized using actual data values\n" +" rather than arbitrary constants.\"\n" +"keypoints:\n" +"- \"Program defensively, i.e., assume that errors are going to arise,\n" +" and write code to detect them when they do.\"\n" +"- \"Put assertions in programs to check their state as they run,\n" +" and to help readers understand how those programs are supposed to work.\"\n" +"- \"Use preconditions to check that the inputs to a function are safe to use.\"\n" +"- \"Use postconditions to check that the output from a function is safe to use.\"\n" +"- \"Write tests before writing code in order to help determine exactly\n" +" what that code is supposed to do.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:25 +msgid "Our previous lessons have introduced the basic tools of programming:\n" +"variables and lists,\n" +"file I/O,\n" +"loops,\n" +"conditionals,\n" +"and functions.\n" +"What they *haven't* done is show us how to tell\n" +"whether a program is getting the right answer,\n" +"and how to tell if it's *still* getting the right answer\n" +"as we make changes to it." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:36 +msgid "To achieve that,\n" +"we need to:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:39 +# unordered list +msgid "* Write programs that check their own operation." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:40 +# unordered list +msgid "* Write and run tests for widely-used functions." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:41 +# unordered list +msgid "* Make sure we know what \"correct\" actually means." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:43 +msgid "The good news is,\n" +"doing these things will speed up our programming,\n" +"not slow it down.\n" +"As in real carpentry --- the kind done with lumber --- the time saved\n" +"by measuring carefully before cutting a piece of wood\n" +"is much greater than the time that measuring takes." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:50 +# header +msgid "## Assertions" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:52 +msgid "The first step toward getting the right answers from our programs\n" +"is to assume that mistakes *will* happen\n" +"and to guard against them.\n" +"This is called [defensive programming]({{ page.root }}/reference.html#defensive-programming),\n" +"and the most common way to do it is to add\n" +"[assertions]({{ page.root }}/reference.html#assertion) to our code\n" +"so that it checks itself as it runs.\n" +"An assertion is simply a statement that something must be true at a certain point in a program.\n" +"When Python sees one,\n" +"it evaluates the assertion's condition.\n" +"If it's true,\n" +"Python does nothing,\n" +"but if it's false,\n" +"Python halts the program immediately\n" +"and prints the error message if one is provided.\n" +"For example,\n" +"this piece of code halts as soon as the loop encounters a value that isn't positive:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:70 +# code block +msgid "~~~\n" +"numbers = [1.5, 2.3, 0.7, -0.001, 4.4]\n" +"total = 0.0\n" +"for num in numbers:\n" +" assert num > 0.0, 'Data should only contain positive values'\n" +" total += num\n" +"print('total is:', total)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:80 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +" 2 total = 0.0\n" +" 3 for num in numbers:\n" +"----> 4 assert num > 0.0, 'Data should only contain positive values'\n" +" 5 total += num\n" +" 6 print('total is:', total)\n" +"\n" +"AssertionError: Data should only contain positive values\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:94 +msgid "Programs like the Firefox browser are full of assertions:\n" +"10-20% of the code they contain\n" +"are there to check that the other 80–90% are working correctly.\n" +"Broadly speaking,\n" +"assertions fall into three categories:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:100 +# unordered list +msgid "* A [precondition]({{ page.root }}/reference.html#precondition)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:101 +msgid " is something that must be true at the start of a function in order for it to work correctly." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:103 +# unordered list +msgid "* A [postcondition]({{ page.root }}/reference.html#postcondition)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:104 +msgid " is something that the function guarantees is true when it finishes." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:106 +# unordered list +msgid "* An [invariant]({{ page.root }}/reference.html#invariant)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:107 +msgid " is something that is always true at a particular point inside a piece of code." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:109 +msgid "For example,\n" +"suppose we are representing rectangles using a [tuple]({{ page.root }}/reference.html#tuple)\n" +"of four coordinates `(x0, y0, x1, y1)`,\n" +"representing the lower left and upper right corners of the rectangle.\n" +"In order to do some calculations,\n" +"we need to normalize the rectangle so that the lower left corner is at the origin\n" +"and the longest side is 1.0 units long.\n" +"This function does that,\n" +"but checks that its input is correctly formatted and that its result makes sense:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:119 +# code block +msgid "~~~\n" +"def normalize_rectangle(rect):\n" +" \"\"\"Normalizes a rectangle so that it is at the origin and 1.0 units long on its longest axis.\n" +" Input should be of the format (x0, y0, x1, y1).\n" +" (x0, y0) and (x1, y1) define the lower left and upper right corners\n" +" of the rectangle, respectively.\"\"\"\n" +" assert len(rect) == 4, 'Rectangles must contain 4 coordinates'\n" +" x0, y0, x1, y1 = rect\n" +" assert x0 < x1, 'Invalid X coordinates'\n" +" assert y0 < y1, 'Invalid Y coordinates'\n" +"\n" +" dx = x1 - x0\n" +" dy = y1 - y0\n" +" if dx > dy:\n" +" scaled = float(dx) / dy\n" +" upper_x, upper_y = 1.0, scaled\n" +" else:\n" +" scaled = float(dx) / dy\n" +" upper_x, upper_y = scaled, 1.0\n" +"\n" +" assert 0 < upper_x <= 1.0, 'Calculated upper X coordinate invalid'\n" +" assert 0 < upper_y <= 1.0, 'Calculated upper Y coordinate invalid'\n" +"\n" +" return (0, 0, upper_x, upper_y)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:146 +msgid "The preconditions on lines 6, 8, and 9 catch invalid inputs:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:148 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (0.0, 1.0, 2.0) )) # missing the fourth coordinate\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:153 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in \n" +"----> 1 print(normalize_rectangle( (0.0, 1.0, 2.0) )) # missing the fourth coordinate\n" +"\n" +" in normalize_rectangle(rect)\n" +" 4 (x0, y0) and (x1, y1) define the lower left and upper right corners\n" +" 5 of the rectangle, respectively.\"\"\"\n" +"----> 6 assert len(rect) == 4, 'Rectangles must contain 4 coordinates'\n" +" 7 x0, y0, x1, y1 = rect\n" +" 8 assert x0 < x1, 'Invalid X coordinates'\n" +"\n" +"AssertionError: Rectangles must contain 4 coordinates\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:170 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (4.0, 2.0, 1.0, 5.0) )) # X axis inverted\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:175 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in \n" +"----> 1 print(normalize_rectangle( (4.0, 2.0, 1.0, 5.0) )) # X axis inverted\n" +"\n" +" in normalize_rectangle(rect)\n" +" 6 assert len(rect) == 4, 'Rectangles must contain 4 coordinates'\n" +" 7 x0, y0, x1, y1 = rect\n" +"----> 8 assert x0 < x1, 'Invalid X coordinates'\n" +" 9 assert y0 < y1, 'Invalid Y coordinates'\n" +" 10\n" +"\n" +"AssertionError: Invalid X coordinates\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:192 +msgid "The post-conditions on lines 20 and 21 help us catch bugs by telling us when our\n" +"calculations might have been incorrect.\n" +"For example,\n" +"if we normalize a rectangle that is taller than it is wide everything seems OK:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:197 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (0.0, 0.0, 1.0, 5.0) ))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:202 +# code block +msgid "~~~\n" +"(0, 0, 0.2, 1.0)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:207 +msgid "but if we normalize one that's wider than it is tall,\n" +"the assertion is triggered:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:210 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (0.0, 0.0, 5.0, 1.0) ))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:215 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in \n" +"----> 1 print(normalize_rectangle( (0.0, 0.0, 5.0, 1.0) ))\n" +"\n" +" in normalize_rectangle(rect)\n" +" 19\n" +" 20 assert 0 < upper_x <= 1.0, 'Calculated upper X coordinate invalid'\n" +"---> 21 assert 0 < upper_y <= 1.0, 'Calculated upper Y coordinate invalid'\n" +" 22\n" +" 23 return (0, 0, upper_x, upper_y)\n" +"\n" +"AssertionError: Calculated upper Y coordinate invalid\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:232 +msgid "Re-reading our function,\n" +"we realize that line 14 should divide `dy` by `dx` rather than `dx` by `dy`.\n" +"In a Jupyter notebook, you can display line numbers by typing Ctrl+M\n" +"followed by L.\n" +"If we had left out the assertion at the end of the function,\n" +"we would have created and returned something that had the right shape as a valid answer,\n" +"but wasn't.\n" +"Detecting and debugging that would almost certainly have taken more time in the long run\n" +"than writing the assertion." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:242 +msgid "But assertions aren't just about catching errors:\n" +"they also help people understand programs.\n" +"Each assertion gives the person reading the program\n" +"a chance to check (consciously or otherwise)\n" +"that their understanding matches what the code is doing." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:248 +msgid "Most good programmers follow two rules when adding assertions to their code.\n" +"The first is, *fail early, fail often*.\n" +"The greater the distance between when and where an error occurs and when it's noticed,\n" +"the harder the error will be to debug,\n" +"so good code catches mistakes as early as possible." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:254 +msgid "The second rule is, *turn bugs into assertions or tests*.\n" +"Whenever you fix a bug, write an assertion that catches the mistake\n" +"should you make it again.\n" +"If you made a mistake in a piece of code,\n" +"the odds are good that you have made other mistakes nearby,\n" +"or will make the same mistake (or a related one)\n" +"the next time you change it.\n" +"Writing assertions to check that you haven't [regressed]({{ page.root }}/reference.html#regression)\n" +"(i.e., haven't re-introduced an old problem)\n" +"can save a lot of time in the long run,\n" +"and helps to warn people who are reading the code\n" +"(including your future self)\n" +"that this bit is tricky." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:268 +# header +msgid "## Test-Driven Development" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:270 +msgid "An assertion checks that something is true at a particular point in the program.\n" +"The next step is to check the overall behavior of a piece of code,\n" +"i.e.,\n" +"to make sure that it produces the right output when it's given a particular input.\n" +"For example,\n" +"suppose we need to find where two or more time series overlap.\n" +"The range of each time series is represented as a pair of numbers,\n" +"which are the time the interval started and ended.\n" +"The output is the largest range that they all include:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:280 +msgid "![Overlapping Ranges](../fig/python-overlapping-ranges.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:282 +msgid "Most novice programmers would solve this problem like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:284 +# ordered list +msgid "1. Write a function `range_overlap`." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:285 +# ordered list +msgid "2. Call it interactively on two or three different inputs." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:286 +# ordered list +msgid "3. If it produces the wrong answer, fix the function and re-run that test." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:288 +msgid "This clearly works --- after all, thousands of scientists are doing it right now --- but\n" +"there's a better way:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:291 +# ordered list +msgid "1. Write a short function for each test." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:292 +# ordered list +msgid "2. Write a `range_overlap` function that should pass those tests." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:293 +# ordered list +msgid "3. If `range_overlap` produces any wrong answers, fix it and re-run the test functions." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:295 +msgid "Writing the tests *before* writing the function they exercise\n" +"is called [test-driven development]({{ page.root }}/reference.html#test-driven-development) (TDD).\n" +"Its advocates believe it produces better code faster because:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:299 +# ordered list +msgid "1. If people write tests after writing the thing to be tested," +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:300 +msgid " they are subject to confirmation bias,\n" +" i.e.,\n" +" they subconsciously write tests to show that their code is correct,\n" +" rather than to find errors.\n" +"2. Writing tests helps programmers figure out what the function is actually supposed to do." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:306 +msgid "Here are three test functions for `range_overlap`:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:308 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +"assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +"assert range_overlap([ (0.0, 1.0), (0.0, 2.0), (-1.0, 1.0) ]) == (0.0, 1.0)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:315 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +" 2 assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +" 3 assert range_overlap([ (0.0, 1.0), (0.0, 2.0), (-1.0, 1.0) ]) == (0.0, 1.0)\n" +"\n" +"AssertionError:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:327 +msgid "The error is actually reassuring:\n" +"we haven't written `range_overlap` yet,\n" +"so if the tests passed,\n" +"it would be a sign that someone else had\n" +"and that we were accidentally using their function." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:333 +msgid "And as a bonus of writing these tests,\n" +"we've implicitly defined what our input and output look like:\n" +"we expect a list of pairs as input,\n" +"and produce a single pair as output." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:338 +msgid "Something important is missing, though.\n" +"We don't have any tests for the case where the ranges don't overlap at all:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:341 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == ???\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:346 +msgid "What should `range_overlap` do in this case:\n" +"fail with an error message,\n" +"produce a special value like `(0.0, 0.0)` to signal that there's no overlap,\n" +"or something else?\n" +"Any actual implementation of the function will do one of these things;\n" +"writing the tests first helps us figure out which is best\n" +"*before* we're emotionally invested in whatever we happened to write\n" +"before we realized there was an issue." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:355 +msgid "And what about this case?" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:357 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == ???\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:362 +msgid "Do two segments that touch at their endpoints overlap or not?\n" +"Mathematicians usually say \"yes\",\n" +"but engineers usually say \"no\".\n" +"The best answer is \"whatever is most useful in the rest of our program\",\n" +"but again,\n" +"any actual implementation of `range_overlap` is going to do *something*,\n" +"and whatever it is ought to be consistent with what it does when there's no overlap at all." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:370 +msgid "Since we're planning to use the range this function returns\n" +"as the X axis in a time series chart,\n" +"we decide that:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:374 +# ordered list +msgid "1. every overlap has to have non-zero width, and" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:375 +# ordered list +msgid "2. we will return the special value `None` when there's no overlap." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:377 +msgid "`None` is built into Python,\n" +"and means \"nothing here\".\n" +"(Other languages often call the equivalent value `null` or `nil`).\n" +"With that decision made,\n" +"we can finish writing our last two tests:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:383 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +"assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:389 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +" 2 assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +"\n" +"AssertionError:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:400 +msgid "Again,\n" +"we get an error because we haven't written our function,\n" +"but we're now ready to do so:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:404 +# code block +msgid "~~~\n" +"def range_overlap(ranges):\n" +" \"\"\"Return common overlap among a set of [left, right] ranges.\"\"\"\n" +" max_left = 0.0\n" +" min_right = 1.0\n" +" for (left, right) in ranges:\n" +" max_left = max(max_left, left)\n" +" min_right = min(min_right, right)\n" +" return (max_left, min_right)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:416 +msgid "Take a moment to think about why we calculate the left endpoint of the overlap as\n" +"the maximum of the input left endpoints, and the overlap right endpoint as the minimum\n" +"of the input right endpoints.\n" +"We'd now like to re-run our tests,\n" +"but they're scattered across three different cells.\n" +"To make running them easier,\n" +"let's put them all in a function:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:424 +# code block +msgid "~~~\n" +"def test_range_overlap():\n" +" assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +" assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +" assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +" assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +" assert range_overlap([ (0.0, 1.0), (0.0, 2.0), (-1.0, 1.0) ]) == (0.0, 1.0)\n" +" assert range_overlap([]) == None\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:435 +msgid "We can now test `range_overlap` with a single function call:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:437 +# code block +msgid "~~~\n" +"test_range_overlap()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:442 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 test_range_overlap()\n" +"\n" +" in test_range_overlap()\n" +" 1 def test_range_overlap():\n" +"----> 2 assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +" 3 assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +" 4 assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +" 5 assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +"\n" +"AssertionError:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:459 +msgid "The first test that was supposed to produce `None` fails,\n" +"so we know something is wrong with our function.\n" +"We *don't* know whether the other tests passed or failed\n" +"because Python halted the program as soon as it spotted the first error.\n" +"Still,\n" +"some information is better than none,\n" +"and if we trace the behavior of the function with that input,\n" +"we realize that we're initializing `max_left` and `min_right` to 0.0 and 1.0 respectively,\n" +"regardless of the input values.\n" +"This violates another important rule of programming:\n" +"*always initialize from data*." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:471 +# blockquote, which can be cascaded +msgid "> ## Pre- and Post-Conditions" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:472 +msgid ">\n" +"> Suppose you are writing a function called `average` that calculates\n" +"> the average of the numbers in a list.\n" +"> What pre-conditions and post-conditions would you write for it?\n" +"> Compare your answer to your neighbor's:\n" +"> can you think of a function that will pass your tests but not his/hers or vice versa?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # a possible pre-condition:\n" +"> > assert len(input_list) > 0, 'List length must be non-zero'\n" +"> > # a possible post-condition:\n" +"> > assert numpy.min(input_list) <= average <= numpy.max(input_list),\n" +"> > 'Average should be between min and max of input values (inclusive)'\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:491 +# blockquote, which can be cascaded +msgid "> ## Testing Assertions" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:492 +msgid ">\n" +"> Given a sequence of a number of cars, the function `get_total_cars` returns\n" +"> the total number of cars.\n" +">\n" +"> ~~~\n" +"> get_total_cars([1, 2, 3, 4])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 10\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:505 +msgid ">\n" +"> ~~~\n" +"> get_total_cars(['a', 'b', 'c'])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> ValueError: invalid literal for int() with base 10: 'a'\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:515 +msgid ">\n" +"> Explain in words what the assertions in this function check,\n" +"> and for each one,\n" +"> give an example of input that will make that assertion fail.\n" +">\n" +"> ~~~\n" +"> def get_total(values):\n" +"> assert len(values) > 0\n" +"> for element in values:\n" +"> assert int(element)\n" +"> values = [int(element) for element in values]\n" +"> total = sum(values)\n" +"> assert total > 0\n" +"> return total\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > * The first assertion checks that the input sequence `values` is not empty.\n" +"> > An empty sequence such as `[]` will make it fail.\n" +"> > * The second assertion checks that each value in the list can be turned into an integer.\n" +"> > Input such as `[1, 2,'c', 3]` will make it fail.\n" +"> > * The third assertion checks that the total of the list is greater than 0.\n" +"> > Input such as `[-10, 2, 3]` will make it fail." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:1 +# Front Matter +msgid "---\n" +"title: Debugging\n" +"teaching: 30\n" +"exercises: 20\n" +"questions:\n" +"- \"How can I debug my program?\"\n" +"objectives:\n" +"- \"Debug code containing an error systematically.\"\n" +"- \"Identify ways of making code less error-prone and more easily tested.\"\n" +"keypoints:\n" +"- \"Know what code is supposed to do *before* trying to debug it.\"\n" +"- \"Make it fail every time.\"\n" +"- \"Make it fail fast.\"\n" +"- \"Change one thing at a time, and for a reason.\"\n" +"- \"Keep track of what you've done.\"\n" +"- \"Be humble.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:19 +msgid "Once testing has uncovered problems,\n" +"the next step is to fix them.\n" +"Many novices do this by making more-or-less random changes to their code\n" +"until it seems to produce the right answer,\n" +"but that's very inefficient\n" +"(and the result is usually only correct for the one case they're testing).\n" +"The more experienced a programmer is,\n" +"the more systematically they debug,\n" +"and most follow some variation on the rules explained below." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:29 +# header +msgid "## Know What It's Supposed to Do" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:31 +msgid "The first step in debugging something is to\n" +"*know what it's supposed to do*.\n" +"\"My program doesn't work\" isn't good enough:\n" +"in order to diagnose and fix problems,\n" +"we need to be able to tell correct output from incorrect.\n" +"If we can write a test case for the failing case --- i.e.,\n" +"if we can assert that with *these* inputs,\n" +"the function should produce *that* result ---\n" +"then we're ready to start debugging.\n" +"If we can't,\n" +"then we need to figure out how we're going to know when we've fixed things." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:43 +msgid "But writing test cases for scientific software is frequently harder than\n" +"writing test cases for commercial applications,\n" +"because if we knew what the output of the scientific code was supposed to be,\n" +"we wouldn't be running the software:\n" +"we'd be writing up our results and moving on to the next program.\n" +"In practice,\n" +"scientists tend to do the following:" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:51 +# ordered list +msgid "1. *Test with simplified data.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:52 +msgid " Before doing statistics on a real data set,\n" +" we should try calculating statistics for a single record,\n" +" for two identical records,\n" +" for two records whose values are one step apart,\n" +" or for some other case where we can calculate the right answer by hand." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:58 +# ordered list +msgid "2. *Test a simplified case.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:59 +msgid " If our program is supposed to simulate\n" +" magnetic eddies in rapidly-rotating blobs of supercooled helium,\n" +" our first test should be a blob of helium that isn't rotating,\n" +" and isn't being subjected to any external electromagnetic fields.\n" +" Similarly,\n" +" if we're looking at the effects of climate change on speciation,\n" +" our first test should hold temperature, precipitation, and other factors constant." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:67 +# ordered list +msgid "3. *Compare to an oracle.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:68 +msgid " A [test oracle]({{ page.root }}/reference.html#test-oracle) is something whose results are trusted,\n" +" such as experimental data, an older program, or a human expert.\n" +" We use test oracles to determine if our new program produces the correct results.\n" +" If we have a test oracle,\n" +" we should store its output for particular cases\n" +" so that we can compare it with our new results as often as we like\n" +" without re-running that program." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:76 +# ordered list +msgid "4. *Check conservation laws.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:77 +msgid " Mass, energy, and other quantities are conserved in physical systems,\n" +" so they should be in programs as well.\n" +" Similarly,\n" +" if we are analyzing patient data,\n" +" the number of records should either stay the same or decrease\n" +" as we move from one analysis to the next\n" +" (since we might throw away outliers or records with missing values).\n" +" If \"new\" patients start appearing out of nowhere as we move through our pipeline,\n" +" it's probably a sign that something is wrong." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:87 +# ordered list +msgid "5. *Visualize.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:88 +msgid " Data analysts frequently use simple visualizations to check both\n" +" the science they're doing\n" +" and the correctness of their code\n" +" (just as we did in the [opening lesson]({{ page.root }}/01-numpy/) of this tutorial).\n" +" This should only be used for debugging as a last resort,\n" +" though,\n" +" since it's very hard to compare two visualizations automatically." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:96 +# header +msgid "## Make It Fail Every Time" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:98 +msgid "We can only debug something when it fails,\n" +"so the second step is always to find a test case that\n" +"*makes it fail every time*.\n" +"The \"every time\" part is important because\n" +"few things are more frustrating than debugging an intermittent problem:\n" +"if we have to call a function a dozen times to get a single failure,\n" +"the odds are good that we'll scroll past the failure when it actually occurs." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:106 +msgid "As part of this,\n" +"it's always important to check that our code is \"plugged in\",\n" +"i.e.,\n" +"that we're actually exercising the problem that we think we are.\n" +"Every programmer has spent hours chasing a bug,\n" +"only to realize that they were actually calling their code on the wrong data set\n" +"or with the wrong configuration parameters,\n" +"or are using the wrong version of the software entirely.\n" +"Mistakes like these are particularly likely to happen when we're tired,\n" +"frustrated,\n" +"and up against a deadline,\n" +"which is one of the reasons late-night (or overnight) coding sessions\n" +"are almost never worthwhile." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:120 +# header +msgid "## Make It Fail Fast" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:122 +msgid "If it takes 20 minutes for the bug to surface,\n" +"we can only do three experiments an hour.\n" +"This means that we'll get less data in more time and that\n" +"we're more likely to be distracted by other things as we wait for our program to fail,\n" +"which means the time we *are* spending on the problem is less focused.\n" +"It's therefore critical to *make it fail fast*." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:129 +msgid "As well as making the program fail fast in time,\n" +"we want to make it fail fast in space,\n" +"i.e.,\n" +"we want to localize the failure to the smallest possible region of code:" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:134 +# ordered list +msgid "1. The smaller the gap between cause and effect," +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:135 +msgid " the easier the connection is to find.\n" +" Many programmers therefore use a divide and conquer strategy to find bugs,\n" +" i.e.,\n" +" if the output of a function is wrong,\n" +" they check whether things are OK in the middle,\n" +" then concentrate on either the first or second half,\n" +" and so on." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:143 +# ordered list +msgid "2. N things can interact in N! different ways," +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:144 +msgid " so every line of code that *isn't* run as part of a test\n" +" means more than one thing we don't need to worry about." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:147 +# header +msgid "## Change One Thing at a Time, For a Reason" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:149 +msgid "Replacing random chunks of code is unlikely to do much good.\n" +"(After all,\n" +"if you got it wrong the first time,\n" +"you'll probably get it wrong the second and third as well.)\n" +"Good programmers therefore\n" +"*change one thing at a time, for a reason*.\n" +"They are either trying to gather more information\n" +"(\"is the bug still there if we change the order of the loops?\")\n" +"or test a fix\n" +"(\"can we make the bug go away by sorting our data before processing it?\")." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:160 +msgid "Every time we make a change,\n" +"however small,\n" +"we should re-run our tests immediately,\n" +"because the more things we change at once,\n" +"the harder it is to know what's responsible for what\n" +"(those N! interactions again).\n" +"And we should re-run *all* of our tests:\n" +"more than half of fixes made to code introduce (or re-introduce) bugs,\n" +"so re-running all of our tests tells us whether we have regressed." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:170 +# header +msgid "## Keep Track of What You've Done" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:172 +msgid "Good scientists keep track of what they've done\n" +"so that they can reproduce their work,\n" +"and so that they don't waste time repeating the same experiments\n" +"or running ones whose results won't be interesting.\n" +"Similarly,\n" +"debugging works best when we\n" +"*keep track of what we've done*\n" +"and how well it worked.\n" +"If we find ourselves asking,\n" +"\"Did left followed by right with an odd number of lines cause the crash?\n" +"Or was it right followed by left?\n" +"Or was I using an even number of lines?\"\n" +"then it's time to step away from the computer,\n" +"take a deep breath,\n" +"and start working more systematically." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:188 +msgid "Records are particularly useful when the time comes to ask for help.\n" +"People are more likely to listen to us\n" +"when we can explain clearly what we did,\n" +"and we're better able to give them the information they need to be useful." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:193 +# blockquote, which can be cascaded +msgid "> ## Version Control Revisited" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:194 +msgid ">\n" +"> Version control is often used to reset software to a known state during debugging,\n" +"> and to explore recent changes to code that might be responsible for bugs.\n" +"> In particular,\n" +"> most version control systems (e.g. git, Mercurial) have:\n" +"> 1. a `blame` command that shows who last changed each line of a file;\n" +"> 2. a `bisect` command that helps with finding the commit that introduced an\n" +"> issue." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:204 +# header +msgid "## Be Humble" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:206 +msgid "And speaking of help:\n" +"if we can't find a bug in 10 minutes,\n" +"we should *be humble* and ask for help.\n" +"Explaining the problem to someone else is often useful,\n" +"since hearing what we're thinking helps us spot inconsistencies and hidden assumptions.\n" +"If you don't have someone nearby to share your problem description with, get a\n" +"[rubber duck](https://en.wikipedia.org/wiki/Rubber_duck_debugging)!" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:214 +msgid "Asking for help also helps alleviate confirmation bias.\n" +"If we have just spent an hour writing a complicated program,\n" +"we want it to work,\n" +"so we're likely to keep telling ourselves why it should,\n" +"rather than searching for the reason it doesn't.\n" +"People who aren't emotionally invested in the code can be more objective,\n" +"which is why they're often able to spot the simple mistakes we have overlooked." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:222 +msgid "Part of being humble is learning from our mistakes.\n" +"Programmers tend to get the same things wrong over and over:\n" +"either they don't understand the language and libraries they're working with,\n" +"or their model of how things work is wrong.\n" +"In either case,\n" +"taking note of why the error occurred\n" +"and checking for it next time\n" +"quickly turns into not making the mistake at all." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:231 +msgid "And that is what makes us most productive in the long run.\n" +"As the saying goes,\n" +"*A week of hard work can sometimes save you an hour of thought*.\n" +"If we train ourselves to avoid making some kinds of mistakes,\n" +"to break our code into modular, testable chunks,\n" +"and to turn every assumption (or mistake) into an assertion,\n" +"it will actually take us *less* time to produce working programs,\n" +"not more." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:240 +# blockquote, which can be cascaded +msgid "> ## Debug With a Neighbor" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:241 +msgid ">\n" +"> Take a function that you have written today, and introduce a tricky bug.\n" +"> Your function should still run, but will give the wrong output.\n" +"> Switch seats with your neighbor and attempt to debug\n" +"> the bug that they introduced into their function.\n" +"> Which of the principles discussed above did you find helpful?" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:249 +# blockquote, which can be cascaded +msgid "> ## Not Supposed to be the Same" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:250 +msgid ">\n" +"> You are assisting a researcher with Python code that computes the\n" +"> Body Mass Index (BMI) of patients. The researcher is concerned because\n" +"> all patients seemingly have unusual and identical BMIs, despite having different\n" +"> physiques. BMI is calculated as **weight in kilograms**\n" +"> divided by the square of **height in metres**.\n" +">\n" +"> Use the debugging principles in this exercise and locate problems\n" +"> with the code. What suggestions would you give the researcher for\n" +"> ensuring any later changes they make work correctly?\n" +">\n" +"> ~~~\n" +"> patients = [[70, 1.8], [80, 1.9], [150, 1.7]]\n" +">\n" +"> def calculate_bmi(weight, height):\n" +"> return weight / (height ** 2)\n" +">\n" +"> for patient in patients:\n" +"> weight, height = patients[0]\n" +"> bmi = calculate_bmi(height, weight)\n" +"> print(\"Patient's BMI is: %f\" % bmi)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Patient's BMI is: 0.000367\n" +"> Patient's BMI is: 0.000367\n" +"> Patient's BMI is: 0.000367\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:280 +msgid ">\n" +"> > ## Solution\n" +"> > * The loop is not being utilised correctly. `height` and `weight` are always\n" +"> > set as the first patient's data during each iteration of the loop.\n" +"> >\n" +"> > * The height/weight variables are reversed in the function call to\n" +"> > `calculate_bmi(...)`, the correct BMIs are 21.604938, 22.160665 and 51.903114." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1 +# Front Matter +msgid "---\n" +"title: Command-Line Programs\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I write Python programs that will work like Unix command-line tools?\"\n" +"objectives:\n" +"- \"Use the values of command-line arguments in a program.\"\n" +"- \"Handle flags and files separately in a command-line program.\"\n" +"- \"Read data from standard input in a program so that it can be used in a pipeline.\"\n" +"keypoints:\n" +"- \"The `sys` library connects a Python program to the system it is running on.\"\n" +"- \"The list `sys.argv` contains the command-line arguments that a program was run with.\"\n" +"- \"Avoid silent failures.\"\n" +"- \"The pseudo-file `sys.stdin` connects to a program's standard input.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:18 +msgid "The Jupyter Notebook and other interactive tools are great for prototyping code and exploring data,\n" +"but sooner or later we will want to use our program in a pipeline\n" +"or run it in a shell script to process thousands of data files.\n" +"In order to do that,\n" +"we need to make our programs work like other Unix command-line tools.\n" +"For example,\n" +"we may want a program that reads a dataset\n" +"and prints the average inflammation per patient." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:27 +# blockquote, which can be cascaded +msgid "> ## Switching to Shell Commands" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:28 +msgid ">\n" +"> In this lesson we are switching from typing commands in a Python interpreter to typing\n" +"> commands in a shell terminal window (such as bash). When you see a `$` in front of a\n" +"> command that tells you to run that command in the shell rather than the Python interpreter." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:34 +msgid "This program does exactly what we want - it prints the average inflammation per patient\n" +"for a given file." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:37 +# code block +msgid "~~~\n" +"$ python ../code/readings_04.py --mean inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:40 +#: python-novice-inflammation/_episodes/12-cmdline.md:58 +#: python-novice-inflammation/_episodes/12-cmdline.md:65 +#: python-novice-inflammation/_episodes/12-cmdline.md:100 +#: python-novice-inflammation/_episodes/12-cmdline.md:126 +#: python-novice-inflammation/_episodes/12-cmdline.md:140 +#: python-novice-inflammation/_episodes/12-cmdline.md:159 +#: python-novice-inflammation/_episodes/12-cmdline.md:183 +#: python-novice-inflammation/_episodes/12-cmdline.md:192 +#: python-novice-inflammation/_episodes/12-cmdline.md:215 +#: python-novice-inflammation/_episodes/12-cmdline.md:333 +#: python-novice-inflammation/_episodes/12-cmdline.md:343 +#: python-novice-inflammation/_episodes/12-cmdline.md:354 +#: python-novice-inflammation/_episodes/12-cmdline.md:392 +#: python-novice-inflammation/_episodes/12-cmdline.md:415 +#: python-novice-inflammation/_episodes/12-cmdline.md:448 +#: python-novice-inflammation/_episodes/12-cmdline.md:482 +#: python-novice-inflammation/_episodes/12-cmdline.md:511 +#: python-novice-inflammation/_episodes/12-cmdline.md:558 +#: python-novice-inflammation/_episodes/12-cmdline.md:581 +#: python-novice-inflammation/_episodes/12-cmdline.md:593 +#: python-novice-inflammation/_episodes/12-cmdline.md:613 +#: python-novice-inflammation/_episodes/12-cmdline.md:654 +msgid "{: .language-bash}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:42 +# code block +msgid "~~~\n" +"5.45\n" +"5.425\n" +"6.1\n" +"...\n" +"6.4\n" +"7.05\n" +"5.9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:53 +msgid "We might also want to look at the minimum of the first four lines" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:55 +# code block +msgid "~~~\n" +"$ head -4 inflammation-01.csv | python ../code/readings_06.py --min\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:60 +msgid "or the maximum inflammations in several files one after another:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:62 +# code block +msgid "~~~\n" +"$ python ../code/readings_04.py --max inflammation-*.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:67 +msgid "Our scripts should do the following:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:69 +# ordered list +msgid "1. If no filename is given on the command line, read data from" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:70 +msgid "[standard input]({{ page.root }}/reference.html#standard-input).\n" +"2. If one or more filenames are given, read data from them and report statistics for each file\n" +"separately.\n" +"3. Use the `--min`, `--mean`, or `--max` flag to determine what statistic to print." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:75 +msgid "To make this work,\n" +"we need to know how to handle command-line arguments in a program,\n" +"and understand how to handle standard input.\n" +"We'll tackle these questions in turn below." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:80 +# header +msgid "## Command-Line Arguments" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:82 +msgid "Using the text editor of your choice,\n" +"save the following in a text file called `sys_version.py`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:85 +# code block +msgid "~~~\n" +"import sys\n" +"print('version is', sys.version)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:91 +msgid "The first line imports a library called `sys`,\n" +"which is short for \"system\".\n" +"It defines values such as `sys.version`,\n" +"which describes which version of Python we are running.\n" +"We can run this script from the command line like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:97 +# code block +msgid "~~~\n" +"$ python sys_version.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:102 +# code block +msgid "~~~\n" +"version is 3.4.3+ (default, Jul 28 2015, 13:17:50)\n" +"[GCC 4.9.3]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:108 +msgid "Create another file called `argv_list.py` and save the following text to it." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:110 +# code block +msgid "~~~\n" +"import sys\n" +"print('sys.argv is', sys.argv)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:116 +msgid "The strange name `argv` stands for \"argument values\".\n" +"Whenever Python runs a program,\n" +"it takes all of the values given on the command line\n" +"and puts them in the list `sys.argv`\n" +"so that the program can determine what they were.\n" +"If we run this program with no arguments:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:123 +# code block +msgid "~~~\n" +"$ python argv_list.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:128 +# code block +msgid "~~~\n" +"sys.argv is ['argv_list.py']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:133 +msgid "the only thing in the list is the full path to our script,\n" +"which is always `sys.argv[0]`.\n" +"If we run it with a few arguments, however:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:137 +# code block +msgid "~~~\n" +"$ python argv_list.py first second third\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:142 +# code block +msgid "~~~\n" +"sys.argv is ['argv_list.py', 'first', 'second', 'third']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:147 +msgid "then Python adds each of those arguments to that magic list." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:149 +msgid "With this in hand, let's build a version of `readings.py` that always prints\n" +"the per-patient mean of a single data file.\n" +"The first step is to write a function that outlines our implementation,\n" +"and a placeholder for the function that does the actual work.\n" +"By convention this function is usually called `main`,\n" +"though we can call it whatever we want:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:156 +# code block +msgid "~~~\n" +"$ cat ../code/readings_01.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:161 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" filename = sys.argv[1]\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +" for row_mean in numpy.mean(data, axis=1):\n" +" print(row_mean)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:175 +msgid "This function gets the name of the script from `sys.argv[0]`,\n" +"because that's where it's always put,\n" +"and the name of the file to process from `sys.argv[1]`.\n" +"Here's a simple test:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:180 +# code block +msgid "~~~\n" +"$ python ../code/readings_01.py inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:185 +msgid "There is no output because we have defined a function,\n" +"but haven't actually called it.\n" +"Let's add a call to `main`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:189 +# code block +msgid "~~~\n" +"$ cat ../code/readings_02.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:194 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" filename = sys.argv[1]\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +" for row_mean in numpy.mean(data, axis=1):\n" +" print(row_mean)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:210 +msgid "and run that:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:212 +# code block +msgid "~~~\n" +"$ python ../code/readings_02.py inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:217 +# code block +msgid "~~~\n" +"5.45\n" +"5.425\n" +"6.1\n" +"5.9\n" +"5.55\n" +"6.225\n" +"5.975\n" +"6.65\n" +"6.625\n" +"6.525\n" +"6.775\n" +"5.8\n" +"6.225\n" +"5.75\n" +"5.225\n" +"6.3\n" +"6.55\n" +"5.7\n" +"5.85\n" +"6.55\n" +"5.775\n" +"5.825\n" +"6.175\n" +"6.1\n" +"5.8\n" +"6.425\n" +"6.05\n" +"6.025\n" +"6.175\n" +"6.55\n" +"6.175\n" +"6.35\n" +"6.725\n" +"6.125\n" +"7.075\n" +"5.725\n" +"5.925\n" +"6.15\n" +"6.075\n" +"5.75\n" +"5.975\n" +"5.725\n" +"6.3\n" +"5.9\n" +"6.75\n" +"5.925\n" +"7.225\n" +"6.15\n" +"5.95\n" +"6.275\n" +"5.7\n" +"6.1\n" +"6.825\n" +"5.975\n" +"6.725\n" +"5.7\n" +"6.25\n" +"6.4\n" +"7.05\n" +"5.9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:281 +# blockquote, which can be cascaded +msgid "> ## Running Versus Importing" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:282 +msgid ">\n" +"> Running a Python script in bash is very similar to\n" +"> importing that file in Python.\n" +"> The biggest difference is that we don't expect anything\n" +"> to happen when we import a file,\n" +"> whereas when running a script, we expect to see some\n" +"> output printed to the console.\n" +">\n" +"> In order for a Python script to work as expected\n" +"> when imported or when run as a script,\n" +"> we typically put the part of the script\n" +"> that produces output in the following if statement:\n" +">\n" +"> ~~~\n" +"> if __name__ == '__main__':\n" +"> main() # Or whatever function produces output\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> When you import a Python file, `__name__` is the name\n" +"> of that file (e.g., when importing `readings.py`,\n" +"> `__name__` is `'readings'`). However, when running a\n" +"> script in bash, `__name__` is always set to `'__main__'`\n" +"> in that script so that you can determine if the file\n" +"> is being imported or run as a script." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:309 +#: python-novice-inflammation/_episodes/12-cmdline.md:425 +# blockquote, which can be cascaded +msgid "> ## The Right Way to Do It" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:310 +msgid ">\n" +"> If our programs can take complex parameters or multiple filenames,\n" +"> we shouldn't handle `sys.argv` directly.\n" +"> Instead,\n" +"> we should use Python's `argparse` library,\n" +"> which handles common cases in a systematic way,\n" +"> and also makes it easy for us to provide sensible error messages for our users.\n" +"> We will not cover this module in this lesson\n" +"> but you can go to Tshepang Lekhonkhobe's\n" +"> [Argparse tutorial](http://docs.python.org/3/howto/argparse.html)\n" +"> that is part of Python's Official Documentation." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:323 +# header +msgid "## Handling Multiple Files" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:325 +msgid "The next step is to teach our program how to handle multiple files.\n" +"Since 60 lines of output per file is a lot to page through,\n" +"we'll start by using three smaller files,\n" +"each of which has three days of data for two patients:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:330 +# code block +msgid "~~~\n" +"$ ls small-*.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:335 +# code block +msgid "~~~\n" +"small-01.csv small-02.csv small-03.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:340 +# code block +msgid "~~~\n" +"$ cat small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:345 +# code block +msgid "~~~\n" +"0,0,1\n" +"0,1,2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:351 +# code block +msgid "~~~\n" +"$ python ../code/readings_02.py small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:356 +#: python-novice-inflammation/_episodes/12-cmdline.md:656 +# code block +msgid "~~~\n" +"0.333333333333\n" +"1.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:362 +msgid "Using small data files as input also allows us to check our results more easily:\n" +"here,\n" +"for example,\n" +"we can see that our program is calculating the mean correctly for each line,\n" +"whereas we were really taking it on faith before.\n" +"This is yet another rule of programming:\n" +"*test the simple things first*." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:370 +msgid "We want our program to process each file separately,\n" +"so we need a loop that executes once for each filename.\n" +"If we specify the files on the command line,\n" +"the filenames will be in `sys.argv`,\n" +"but we need to be careful:\n" +"`sys.argv[0]` will always be the name of our script,\n" +"rather than the name of a file.\n" +"We also need to handle an unknown number of filenames,\n" +"since our program could be run for any number of files." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:380 +msgid "The solution to both problems is to loop over the contents of `sys.argv[1:]`.\n" +"The '1' tells Python to start the slice at location 1,\n" +"so the program's name isn't included;\n" +"since we've left off the upper bound,\n" +"the slice runs to the end of the list,\n" +"and includes all the filenames.\n" +"Here's our changed program\n" +"`readings_03.py`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:389 +# code block +msgid "~~~\n" +"$ cat ../code/readings_03.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:394 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" for filename in sys.argv[1:]:\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +" for row_mean in numpy.mean(data, axis=1):\n" +" print(row_mean)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:410 +msgid "and here it is in action:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:412 +# code block +msgid "~~~\n" +"$ python ../code/readings_03.py small-01.csv small-02.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:417 +# code block +msgid "~~~\n" +"0.333333333333\n" +"1.0\n" +"13.6666666667\n" +"11.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:426 +msgid ">\n" +"> At this point,\n" +"> we have created three versions of our script called `readings_01.py`,\n" +"> `readings_02.py`, and `readings_03.py`.\n" +"> We wouldn't do this in real life:\n" +"> instead,\n" +"> we would have one file called `readings.py` that we committed to version control\n" +"> every time we got an enhancement working.\n" +"> For teaching,\n" +"> though,\n" +"> we need all the successive versions side by side." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:439 +# header +msgid "## Handling Command-Line Flags" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:441 +msgid "The next step is to teach our program to pay attention to the `--min`, `--mean`, and `--max` flags.\n" +"These always appear before the names of the files,\n" +"so we could do this:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:445 +# code block +msgid "~~~\n" +"$ cat ../code/readings_04.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:450 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" action = sys.argv[1]\n" +" filenames = sys.argv[2:]\n" +"\n" +" for filename in filenames:\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +"\n" +" if action == '--min':\n" +" values = numpy.min(data, axis=1)\n" +" elif action == '--mean':\n" +" values = numpy.mean(data, axis=1)\n" +" elif action == '--max':\n" +" values = numpy.max(data, axis=1)\n" +"\n" +" for val in values:\n" +" print(val)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:477 +msgid "This works:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:479 +# code block +msgid "~~~\n" +"$ python ../code/readings_04.py --max small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:484 +# code block +msgid "~~~\n" +"1.0\n" +"2.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:490 +msgid "but there are several things wrong with it:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:492 +# ordered list +msgid "1. `main` is too large to read comfortably." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:494 +# ordered list +msgid "2. If we do not specify at least two additional arguments on the" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:495 +msgid " command-line, one for the **flag** and one for the **filename**, but only\n" +" one, the program will not throw an exception but will run. It assumes that the file\n" +" list is empty, as `sys.argv[1]` will be considered the `action`, even if it\n" +" is a filename. [Silent failures]({{ page.root }}/reference.html#silence-failure) like this\n" +" are always hard to debug." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:501 +# ordered list +msgid "3. The program should check if the submitted `action` is one of the three recognized flags." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:503 +msgid "This version pulls the processing of each file out of the loop into a function of its own.\n" +"It also checks that `action` is one of the allowed flags\n" +"before doing any processing,\n" +"so that the program fails fast:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:508 +# code block +msgid "~~~\n" +"$ cat ../code/readings_05.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:513 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" action = sys.argv[1]\n" +" filenames = sys.argv[2:]\n" +" assert action in ['--min', '--mean', '--max'], \\\n" +" 'Action is not one of --min, --mean, or --max: ' + action\n" +" for filename in filenames:\n" +" process(filename, action)\n" +"\n" +"def process(filename, action):\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +"\n" +" if action == '--min':\n" +" values = numpy.min(data, axis=1)\n" +" elif action == '--mean':\n" +" values = numpy.mean(data, axis=1)\n" +" elif action == '--max':\n" +" values = numpy.max(data, axis=1)\n" +"\n" +" for val in values:\n" +" print(val)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:544 +msgid "This is four lines longer than its predecessor,\n" +"but broken into more digestible chunks of 8 and 12 lines." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:547 +# header +msgid "## Handling Standard Input" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:549 +msgid "The next thing our program has to do is read data from standard input if no filenames are given\n" +"so that we can put it in a pipeline,\n" +"redirect input to it,\n" +"and so on.\n" +"Let's experiment in another script called `count_stdin.py`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:555 +# code block +msgid "~~~\n" +"$ cat ../code/count_stdin.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:560 +# code block +msgid "~~~\n" +"import sys\n" +"\n" +"count = 0\n" +"for line in sys.stdin:\n" +" count += 1\n" +"\n" +"print(count, 'lines in standard input')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:571 +msgid "This little program reads lines from a special \"file\" called `sys.stdin`,\n" +"which is automatically connected to the program's standard input.\n" +"We don't have to open it --- Python and the operating system\n" +"take care of that when the program starts up ---\n" +"but we can do almost anything with it that we could do to a regular file.\n" +"Let's try running it as if it were a regular command-line program:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:578 +# code block +msgid "~~~\n" +"$ python ../code/count_stdin.py < small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:583 +# code block +msgid "~~~\n" +"2 lines in standard input\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:588 +msgid "A common mistake is to try to run something that reads from standard input like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:590 +# code block +msgid "~~~\n" +"$ python ../code/count_stdin.py small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:595 +msgid "i.e., to forget the `<` character that redirects the file to standard input.\n" +"In this case,\n" +"there's nothing in standard input,\n" +"so the program waits at the start of the loop for someone to type something on the keyboard.\n" +"Since there's no way for us to do this,\n" +"our program is stuck,\n" +"and we have to halt it using the `Interrupt` option from the `Kernel` menu in the Notebook." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:603 +msgid "We now need to rewrite the program so that it loads data from `sys.stdin`\n" +"if no filenames are provided.\n" +"Luckily,\n" +"`numpy.loadtxt` can handle either a filename or an open file as its first parameter,\n" +"so we don't actually need to change `process`.\n" +"Only `main` changes:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:610 +# code block +msgid "~~~\n" +"$ cat ../code/readings_06.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:615 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" action = sys.argv[1]\n" +" filenames = sys.argv[2:]\n" +" assert action in ['--min', '--mean', '--max'], \\\n" +" 'Action is not one of --min, --mean, or --max: ' + action\n" +" if len(filenames) == 0:\n" +" process(sys.stdin, action)\n" +" else:\n" +" for filename in filenames:\n" +" process(filename, action)\n" +"\n" +"def process(filename, action):\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +"\n" +" if action == '--min':\n" +" values = numpy.min(data, axis=1)\n" +" elif action == '--mean':\n" +" values = numpy.mean(data, axis=1)\n" +" elif action == '--max':\n" +" values = numpy.max(data, axis=1)\n" +"\n" +" for val in values:\n" +" print(val)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:649 +msgid "Let's try it out:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:651 +# code block +msgid "~~~\n" +"$ python ../code/readings_06.py --mean < small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:662 +msgid "That's better.\n" +"In fact,\n" +"that's done:\n" +"the program now does everything we set out to do." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:667 +# blockquote, which can be cascaded +msgid "> ## Arithmetic on the Command Line" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:668 +msgid ">\n" +"> Write a command-line program that does addition and subtraction:\n" +">\n" +"> ~~~\n" +"> $ python arith.py add 1 2\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> 3\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:680 +msgid ">\n" +"> ~~~\n" +"> $ python arith.py subtract 3 4\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> -1\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:690 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> >\n" +"> > def main():\n" +"> > assert len(sys.argv) == 4, 'Need exactly 3 arguments'\n" +"> >\n" +"> > operator = sys.argv[1]\n" +"> > assert operator in ['add', 'subtract', 'multiply', 'divide'], \\\n" +"> > 'Operator is not one of add, subtract, multiply, or divide: bailing out'\n" +"> > try:\n" +"> > operand1, operand2 = float(sys.argv[2]), float(sys.argv[3])\n" +"> > except ValueError:\n" +"> > print('cannot convert input to a number: bailing out')\n" +"> > return\n" +"> >\n" +"> > do_arithmetic(operand1, operator, operand2)\n" +"> >\n" +"> > def do_arithmetic(operand1, operator, operand2):\n" +"> >\n" +"> > if operator == 'add':\n" +"> > value = operand1 + operand2\n" +"> > elif operator == 'subtract':\n" +"> > value = operand1 - operand2\n" +"> > elif operator == 'multiply':\n" +"> > value = operand1 * operand2\n" +"> > elif operator == 'divide':\n" +"> > value = operand1 / operand2\n" +"> > print(value)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:727 +# blockquote, which can be cascaded +msgid "> ## Finding Particular Files" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:728 +msgid ">\n" +"> Using the `glob` module introduced [earlier]({{ page.root }}/04-files/),\n" +"> write a simple version of `ls` that shows files in the current directory\n" +"> with a particular suffix.\n" +"> A call to this script should look like this:\n" +">\n" +"> ~~~\n" +"> $ python my_ls.py py\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> left.py\n" +"> right.py\n" +"> zero.py\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:745 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> > import glob\n" +"> >\n" +"> > def main():\n" +"> > \"\"\"prints names of all files with sys.argv as suffix\"\"\"\n" +"> > assert len(sys.argv) >= 2, 'Argument list cannot be empty'\n" +"> > suffix = sys.argv[1] # NB: behaviour is not as you'd expect if sys.argv[1] is *\n" +"> > glob_input = '*.' + suffix # construct the input\n" +"> > glob_output = sorted(glob.glob(glob_input)) # call the glob function\n" +"> > for item in glob_output: # print the output\n" +"> > print(item)\n" +"> > return\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:767 +# blockquote, which can be cascaded +msgid "> ## Changing Flags" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:768 +msgid ">\n" +"> Rewrite `readings.py` so that it uses `-n`, `-m`, and `-x`\n" +"> instead of `--min`, `--mean`, and `--max` respectively.\n" +"> Is the code easier to read?\n" +"> Is the program easier to understand?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # this is code/readings_07.py\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > action = sys.argv[1]\n" +"> > filenames = sys.argv[2:]\n" +"> > assert action in ['-n', '-m', '-x'], \\\n" +"> > 'Action is not one of -n, -m, or -x: ' + action\n" +"> > if len(filenames) == 0:\n" +"> > process(sys.stdin, action)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > process(filename, action)\n" +"> >\n" +"> > def process(filename, action):\n" +"> > data = numpy.loadtxt(filename, delimiter=',')\n" +"> >\n" +"> > if action == '-n':\n" +"> > values = numpy.min(data, axis=1)\n" +"> > elif action == '-m':\n" +"> > values = numpy.mean(data, axis=1)\n" +"> > elif action == '-x':\n" +"> > values = numpy.max(data, axis=1)\n" +"> >\n" +"> > for val in values:\n" +"> > print(val)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:811 +# blockquote, which can be cascaded +msgid "> ## Adding a Help Message" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:812 +msgid ">\n" +"> Separately,\n" +"> modify `readings.py` so that if no parameters are given\n" +"> (i.e., no action is specified and no filenames are given),\n" +"> it prints a message explaining how it should be used.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # this is code/readings_08.py\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > if len(sys.argv) == 1: # no arguments, so print help message\n" +"> > print(\"\"\"Usage: python readings_08.py action filenames\n" +"> > action must be one of --min --mean --max\n" +"> > if filenames is blank, input is taken from stdin;\n" +"> > otherwise, each filename in the list of arguments is processed in turn\"\"\")\n" +"> > return\n" +"> >\n" +"> > action = sys.argv[1]\n" +"> > filenames = sys.argv[2:]\n" +"> > assert action in ['--min', '--mean', '--max'], \\\n" +"> > 'Action is not one of --min, --mean, or --max: ' + action\n" +"> > if len(filenames) == 0:\n" +"> > process(sys.stdin, action)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > process(filename, action)\n" +"> >\n" +"> > def process(filename, action):\n" +"> > data = numpy.loadtxt(filename, delimiter=',')\n" +"> >\n" +"> > if action == '--min':\n" +"> > values = numpy.min(data, axis=1)\n" +"> > elif action == '--mean':\n" +"> > values = numpy.mean(data, axis=1)\n" +"> > elif action == '--max':\n" +"> > values = numpy.max(data, axis=1)\n" +"> >\n" +"> > for val in values:\n" +"> > print(val)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:862 +# blockquote, which can be cascaded +msgid "> ## Adding a Default Action" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:863 +msgid ">\n" +"> Separately,\n" +"> modify `readings.py` so that if no action is given\n" +"> it displays the means of the data.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # this is code/readings_09.py\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > action = sys.argv[1]\n" +"> > if action not in ['--min', '--mean', '--max']: # if no action given\n" +"> > action = '--mean' # set a default action, that being mean\n" +"> > filenames = sys.argv[1:] # start the filenames one place earlier in the argv list\n" +"> > else:\n" +"> > filenames = sys.argv[2:]\n" +"> >\n" +"> > if len(filenames) == 0:\n" +"> > process(sys.stdin, action)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > process(filename, action)\n" +"> >\n" +"> > def process(filename, action):\n" +"> > data = numpy.loadtxt(filename, delimiter=',')\n" +"> >\n" +"> > if action == '--min':\n" +"> > values = numpy.min(data, axis=1)\n" +"> > elif action == '--mean':\n" +"> > values = numpy.mean(data, axis=1)\n" +"> > elif action == '--max':\n" +"> > values = numpy.max(data, axis=1)\n" +"> >\n" +"> > for val in values:\n" +"> > print(val)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:908 +# blockquote, which can be cascaded +msgid "> ## A File-Checker" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:909 +msgid ">\n" +"> Write a program called `check.py` that takes the names of one or more\n" +"> inflammation data files as arguments\n" +"> and checks that all the files have the same number of rows and columns.\n" +"> What is the best way to test your program?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > filenames = sys.argv[1:]\n" +"> > if len(filenames) <=1: #nothing to check\n" +"> > print('Only 1 file specified on input')\n" +"> > else:\n" +"> > nrow0, ncol0 = row_col_count(filenames[0])\n" +"> > print('First file %s: %d rows and %d columns' % (filenames[0], nrow0, ncol0))\n" +"> > for filename in filenames[1:]:\n" +"> > nrow, ncol = row_col_count(filename)\n" +"> > if nrow != nrow0 or ncol != ncol0:\n" +"> > print('File %s does not check: %d rows and %d columns' % (filename, nrow, ncol))\n" +"> > else:\n" +"> > print('File %s checks' % filename)\n" +"> > return\n" +"> >\n" +"> > def row_col_count(filename):\n" +"> > try:\n" +"> > nrow, ncol = numpy.loadtxt(filename, delimiter=',').shape\n" +"> > except ValueError:\n" +"> > # 'ValueError' error is raised when numpy encounters lines that\n" +"> > # have different number of data elements in them than the rest of the lines,\n" +"> > # or when lines have non-numeric elements\n" +"> > nrow, ncol = (0, 0)\n" +"> > return nrow, ncol\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:952 +# blockquote, which can be cascaded +msgid "> ## Counting Lines" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:953 +msgid ">\n" +"> Write a program called `line_count.py` that works like the Unix `wc` command:\n" +">\n" +"> * If no filenames are given, it reports the number of lines in standard input.\n" +"> * If one or more filenames are given, it reports the number of lines in each,\n" +"> followed by the total number of lines.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> >\n" +"> > def main():\n" +"> > \"\"\"print each input filename and the number of lines in it,\n" +"> > and print the sum of the number of lines\"\"\"\n" +"> > filenames = sys.argv[1:]\n" +"> > sum_nlines = 0 #initialize counting variable\n" +"> >\n" +"> > if len(filenames) == 0: # no filenames, just stdin\n" +"> > sum_nlines = count_file_like(sys.stdin)\n" +"> > print('stdin: %d' % sum_nlines)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > nlines = count_file(filename)\n" +"> > print('%s %d' % (filename, nlines))\n" +"> > sum_nlines += nlines\n" +"> > print('total: %d' % sum_nlines)\n" +"> >\n" +"> > def count_file(filename):\n" +"> > \"\"\"count the number of lines in a file\"\"\"\n" +"> > f = open(filename,'r')\n" +"> > nlines = len(f.readlines())\n" +"> > f.close()\n" +"> > return(nlines)\n" +"> >\n" +"> > def count_file_like(file_like):\n" +"> > \"\"\"count the number of lines in a file-like object (eg stdin)\"\"\"\n" +"> > n = 0\n" +"> > for line in file_like:\n" +"> > n = n+1\n" +"> > return n\n" +"> >\n" +"> > main()\n" +"> >\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1001 +# blockquote, which can be cascaded +msgid "> ## Generate an Error Message" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1002 +msgid ">\n" +"> Write a program called `check_arguments.py` that prints usage\n" +"> then exits the program if no arguments are provided.\n" +"> (Hint: You can use `sys.exit()` to exit the program.)\n" +">\n" +"> ~~~\n" +"> $ python check_arguments.py\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> usage: python check_argument.py filename.txt\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1016 +msgid ">\n" +"> ~~~\n" +"> $ python check_arguments.py filename.txt\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> Thanks for specifying arguments!\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_extras/about.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/about.md:1 +# Front Matter +msgid "---\n" +"title: About\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/about.md:4 +msgid "{% include carpentries.html %}" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:1 +# Front Matter +msgid "---\n" +"title: \"Additional material\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:4 +msgid "A collection of facts about Python that do not fit into the main lesson\n" +"either due to the scope or time constraints of the main lesson." +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:8 +# header +msgid "## Jupyter Notebook/IPython: Who's Who in Memory" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:10 +msgid "You can use the `%whos` command at any time to see what\n" +"variables you have created and what modules you have loaded into the computer's memory.\n" +"As this is an IPython command, it will only work if you are in an IPython terminal or the\n" +"Jupyter Notebook." +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:15 +# code block +msgid "~~~\n" +"%whos\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:20 +# code block +msgid "~~~\n" +"Variable Type Data/Info\n" +"--------------------------------\n" +"weight_kg float 100.0\n" +"weight_lb float 143.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:29 +msgid "
\n" +"## Integer Division" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:32 +msgid "We are using Python 3, where division always returns a floating point number:" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:34 +# code block +msgid "~~~\n" +"5/9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:37 +msgid "{: .language-python}\n" +"~~~\n" +"0.5555555555555556\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:43 +msgid "Unfortunately, this wasn't the case in Python 2:\n" +"~~~\n" +"5/9\n" +"~~~\n" +"{: .language-python}\n" +"~~~\n" +"0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:53 +msgid "If you are using Python 2 and want to keep the fractional part of division\n" +"you need to convert one or the other number to floating point:" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:56 +# code block +msgid "~~~\n" +"float(5)/9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:61 +#: python-novice-inflammation/_extras/additional_material.md:71 +#: python-novice-inflammation/_extras/additional_material.md:81 +#: python-novice-inflammation/_extras/additional_material.md:90 +# code block +msgid "~~~\n" +"0.555555555556\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:66 +# code block +msgid "~~~\n" +"5/float(9)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:76 +# code block +msgid "~~~\n" +"5.0/9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:85 +# code block +msgid "~~~\n" +"5/9.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:95 +msgid "And if you want an integer result from division in Python 3,\n" +"use a double-slash:" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:98 +# code block +msgid "~~~\n" +"4//2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:103 +# code block +msgid "~~~\n" +"2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:108 +# code block +msgid "~~~\n" +"3//2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:113 +# code block +msgid "~~~\n" +"1\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/discuss.md:1 +# Front Matter +msgid "---\n" +"title: Discussion\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:4 +# header +msgid "## Rules of Debugging" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:6 +# ordered list +msgid "1. Fail early, fail often." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:7 +# ordered list +msgid "2. Always initialize from data." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:8 +# ordered list +msgid "3. Know what it's supposed to do." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:9 +# ordered list +msgid "4. Make it fail every time." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:10 +# ordered list +msgid "5. Make it fail fast." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:11 +# ordered list +msgid "6. Change one thing at a time, for a reason." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:12 +# ordered list +msgid "7. Keep track of what we've done." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:13 +# ordered list +msgid "8. Be humble." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:14 +# ordered list +msgid "9. Test the simple things first." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:16 +msgid "And remember,\n" +"a week of hard work can sometimes save you an hour of thought." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:19 +# header +msgid "## The Call Stack" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:21 +msgid "Let's take a closer look at what happens when we call `fahr_to_celsius(32.0)`.\n" +"To make things clearer,\n" +"we'll start by putting the initial value 32.0 in a variable\n" +"and store the final result in one as well:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:26 +# code block +msgid "~~~\n" +"original = 32.0\n" +"final = fahr_to_celsius(original)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:32 +msgid "The diagram below shows what memory looks like after the first line has been executed:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:34 +msgid "![Call Stack (Initial State)](../fig/python-call-stack-01.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:36 +msgid "When we call `fahr_to_celsius`,\n" +"Python *doesn't* create the variable `temp` right away.\n" +"Instead,\n" +"it creates something called a [stack frame]({{ page.root }}/reference.html#stack-frame)\n" +"to keep track of the variables defined by `fahr_to_kelvin`.\n" +"Initially,\n" +"this stack frame only holds the value of `temp`:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:44 +msgid "![Call Stack Immediately After First Function Call](../fig/python-call-stack-02.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:46 +msgid "When we call `fahr_to_kelvin` inside `fahr_to_celsius`,\n" +"Python creates another stack frame to hold `fahr_to_kelvin`'s variables:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:49 +msgid "![Call Stack During First Nested Function Call](../fig/python-call-stack-03.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:51 +msgid "It does this because there are now two variables in play called `temp`:\n" +"the parameter to `fahr_to_celsius`,\n" +"and the parameter to `fahr_to_kelvin`.\n" +"Having two variables with the same name in the same part of the program would be ambiguous,\n" +"so Python (and every other modern programming language) creates\n" +"a new stack frame for each function call\n" +"to keep that function's variables separate from those defined by other functions." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:59 +msgid "When the call to `fahr_to_kelvin` returns a value,\n" +"Python throws away `fahr_to_kelvin`'s stack frame\n" +"and creates a new variable in the stack frame for `fahr_to_celsius`\n" +"to hold the temperature in Kelvin:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:64 +msgid "![Call Stack After Return From First Nested Function Call](../fig/python-call-stack-04.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:66 +msgid "It then calls `kelvin_to_celsius`,\n" +"which means it creates a stack frame to hold that function's variables:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:69 +msgid "![Call Stack During Call to Second Nested Function](../fig/python-call-stack-05.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:71 +msgid "Once again,\n" +"Python throws away that stack frame when `kelvin_to_celsius` is done\n" +"and creates the variable `result` in the stack frame for `fahr_to_celsius`:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:75 +msgid "![Call Stack After Second Nested Function Returns](../fig/python-call-stack-06.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:77 +msgid "Finally,\n" +"when `fahr_to_celsius` is done,\n" +"Python throws away *its* stack frame\n" +"and puts its result in a new variable called `final`\n" +"that lives in the stack frame we started with:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:83 +msgid "![Call Stack After All Functions Have Finished](../fig/python-call-stack-07.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:85 +msgid "This final stack frame is always there;\n" +"it holds the variables we defined outside the functions in our code.\n" +"What it *doesn't* hold is the variables that were in the various stack frames.\n" +"If we try to get the value of `temp` after our functions have finished running,\n" +"Python tells us that there's no such thing:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:91 +# code block +msgid "~~~\n" +"print('final value of temp after all function calls:', temp)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:96 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 print('final value of temp after all function calls:', temp)\n" +"\n" +"NameError: name 'temp' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:106 +# code block +msgid "~~~\n" +"final value of temp after all function calls:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:111 +msgid "Why go to all this trouble?\n" +"Well,\n" +"here's a function called `span` that calculates the difference between\n" +"the minimum and maximum values in an array:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:116 +# code block +msgid "~~~\n" +"import numpy\n" +"\n" +"def span(a):\n" +" diff = numpy.max(a) - numpy.min(a)\n" +" return diff\n" +"\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"print('span of data:', span(data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:128 +#: python-novice-inflammation/_extras/discuss.md:142 +# code block +msgid "~~~\n" +"span of data: 20.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:133 +msgid "Notice that `span` assigns a value to a variable called `diff`.\n" +"We might very well use a variable with the same name to hold data:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:136 +# code block +msgid "~~~\n" +"diff = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"print('span of data:', span(diff))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:147 +msgid "We don't expect `diff` to have the value 20.0 after this function call,\n" +"so the name `diff` cannot refer to the same thing inside `span`\n" +"as it does in the main body of our program.\n" +"And yes,\n" +"we could probably choose a different name than `diff` in our main program in this case,\n" +"but we don't want to have to read every line of NumPy to see what variable names its functions use\n" +"before calling any of those functions,\n" +"just in case they change the values of our variables." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:156 +msgid "The big idea here is [encapsulation]({{ page.root }}/reference.html#encapsulation),\n" +"and it's the key to writing correct, comprehensible programs.\n" +"A function's job is to turn several operations into one\n" +"so that we can think about a single function call\n" +"instead of a dozen or a hundred statements\n" +"each time we want to do something.\n" +"That only works if functions don't interfere with each other;\n" +"if they do,\n" +"we have to pay attention to the details once again,\n" +"which quickly overloads our short-term memory." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:167 +# blockquote, which can be cascaded +msgid "> ## Following the Call Stack" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:168 +msgid ">\n" +"> We previously wrote functions called `fence` and `outer`.\n" +"> Draw a diagram showing how the call stack changes when we run the following:\n" +">\n" +"> ~~~\n" +"> print(outer(fence('carbon', '+')))\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:178 +# header +msgid "## Image Grids" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:180 +msgid "Let's start by creating some simple heat maps of our own\n" +"using a library called `ipythonblocks`.\n" +"The first step is to create our own \"image\":" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:184 +# code block +msgid "~~~\n" +"from ipythonblocks import ImageGrid\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:189 +msgid "Unlike the `import` statements we have seen earlier,\n" +"this one doesn't load the entire `ipythonblocks` library.\n" +"Instead,\n" +"it just loads `ImageGrid` from that library,\n" +"since that's the only thing we need (for now)." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:195 +msgid "Once we have `ImageGrid` loaded,\n" +"we can use it to create a very simple grid of colored cells:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:198 +# code block +msgid "~~~\n" +"grid = ImageGrid(5, 3)\n" +"grid.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:204 +msgid "![](../fig/grid-01.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:206 +msgid "Just like a NumPy array,\n" +"an `ImageGrid` has some properties that hold information about it:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:209 +# code block +msgid "~~~\n" +"print('grid width:', grid.width)\n" +"print('grid height:', grid.height)\n" +"print('grid lines on:', grid.lines_on)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:216 +# code block +msgid "~~~\n" +"grid width: 5\n" +"grid height: 3\n" +"grid lines on: True\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:223 +msgid "The obvious thing to do with a grid like this is color in its cells,\n" +"but in order to do that,\n" +"we need to know how computers represent color.\n" +"The most common schemes are [RGB]({{ page.root }}/reference.html#rgb),\n" +"which is short for \"red, green, blue\".\n" +"RGB is an [additive color model]({{ page.root }}/reference.html#additive-color-model):\n" +"every shade is some combination of red, green, and blue intensities.\n" +"We can think of these three values as being the axes in a cube:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:232 +msgid "![RGB Color Cube](../fig/color-cube.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:234 +msgid "An RGB color is an example of a multi-part value:\n" +"like a Cartesian coordinate,\n" +"it is one thing with several parts.\n" +"We can represent such a value in Python using a [tuple]({{ page.root }}/reference.html#tuple),\n" +"which we write using parentheses instead of the square brackets used for a list:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:240 +# code block +msgid "~~~\n" +"position = (12.3, 45.6)\n" +"print('position is:', position)\n" +"color = (10, 20, 30)\n" +"print('color is:', color)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:248 +# code block +msgid "~~~\n" +"position is: (12.3, 45.6)\n" +"color is: (10, 20, 30)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:254 +msgid "We can select elements from tuples using indexing,\n" +"just as we do with lists and arrays:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:257 +# code block +msgid "~~~\n" +"print('first element of color is:', color[0])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:262 +# code block +msgid "~~~\n" +"first element of color is: 10\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:267 +msgid "Unlike lists and arrays,\n" +"though,\n" +"tuples cannot be changed after they are created --- in technical terms,\n" +"they are [immutable]({{ page.root }}/reference.html#immutable):" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:272 +# code block +msgid "~~~\n" +"color[0] = 40\n" +"print('first element of color after change:', color[0])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:278 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"TypeError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 color[0] = 40\n" +"2 print('first element of color after change:', color[0])\n" +"\n" +"TypeError: 'tuple' object does not support item assignment\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:289 +msgid "If a tuple represents an RGB color,\n" +"its red, green, and blue components can take on values between 0 and 255.\n" +"The upper bound may seem odd,\n" +"but it's the largest number that can be represented in an 8-bit byte\n" +"(i.e., 28-1).\n" +"This makes it easy for computers to manipulate colors,\n" +"while providing fine enough gradations to fool most human eyes,\n" +"most of the time." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:298 +msgid "Let's see what a few RGB colors actually look like:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:300 +# code block +msgid "~~~\n" +"row = ImageGrid(8, 1)\n" +"row[0, 0] = (0, 0, 0) # no color => black\n" +"row[1, 0] = (255, 255, 255) # all colors => white\n" +"row[2, 0] = (255, 0, 0) # all red\n" +"row[3, 0] = (0, 255, 0) # all green\n" +"row[4, 0] = (0, 0, 255) # all blue\n" +"row[5, 0] = (255, 255, 0) # red and green\n" +"row[6, 0] = (255, 0, 255) # red and blue\n" +"row[7, 0] = (0, 255, 255) # green and blue\n" +"row.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:314 +msgid "![](../fig/grid-02.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:316 +msgid "Simple color values like `(0,255,0)` are easy enough to decipher with a bit of practice,\n" +"but what color is `(214,90,127)`?\n" +"To help us,\n" +"`ipythonblocks` provides a function called `show_color`:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:321 +# code block +msgid "~~~\n" +"from ipythonblocks import show_color\n" +"show_color(214, 90, 127)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:327 +msgid "![](../fig/ipythonblocks_show_color_example.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:329 +msgid "It also provides a table of standard colors:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:331 +# code block +msgid "~~~\n" +"from ipythonblocks import colors\n" +"c = ImageGrid(3, 2)\n" +"c[0, 0] = colors['Fuchsia']\n" +"c[0, 1] = colors['Salmon']\n" +"c[1, 0] = colors['Orchid']\n" +"c[1, 1] = colors['Lavender']\n" +"c[2, 0] = colors['LimeGreen']\n" +"c[2, 1] = colors['HotPink']\n" +"c.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:344 +msgid "![](../fig/grid-03.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:346 +# blockquote, which can be cascaded +msgid "> ## Making a Colorbar" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:347 +msgid ">\n" +"> Fill in the `____` in the code below to create a bar that changes color from dark blue to black.\n" +">\n" +"> ~~~\n" +"> bar = ImageGrid(10, 1)\n" +"> for x in range(10):\n" +"> bar[x, 0] = (0, 0, ____)\n" +"> bar.show()\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:359 +# blockquote, which can be cascaded +msgid "> ## Why RGB?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:360 +msgid ">\n" +"> Why do computers use red, green, and blue as their primary colors?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:364 +# blockquote, which can be cascaded +msgid "> ## Nested Loops" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:365 +msgid ">\n" +"> Will changing the nesting of the loops in the code above --- i.e.,\n" +"> wrapping the Y-axis loop around the X-axis loop --- change the final image?\n" +"> Why or why not?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:371 +# blockquote, which can be cascaded +msgid "> ## Where to Change Data" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:372 +msgid ">\n" +"> Why did we transpose our data outside our heat map function?\n" +"> Why not have the function perform the transpose?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:377 +# blockquote, which can be cascaded +msgid "> ## Return Versus Display" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:378 +msgid ">\n" +"> Why does the heat map function return the grid rather than displaying it immediately?\n" +"> Do you think this is a good or bad design choice?" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:1 +# Front Matter +msgid "---\n" +"title: \"Additional Exercises\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:4 +msgid "A collection of exercises that have been either removed from\n" +"or not (yet) added to the main lesson." +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:8 +# blockquote, which can be cascaded +msgid "> ## Swapping the contents of variables (5 min)" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:9 +msgid ">\n" +"> Explain what the overall effect of this code is:\n" +">\n" +"> ~~~\n" +"> left = 'L'\n" +"> right = 'R'\n" +">\n" +"> temp = left\n" +"> left = right\n" +"> right = temp\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Compare it to:\n" +">\n" +"> ~~~\n" +"> left, right = [right, left]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Do they always do the same thing?\n" +"> Which do you find easier to read?\n" +">\n" +"> > ## Solution\n" +"> > Both examples exchange the values of `left` and `right`:\n" +"> >\n" +"> > ~~~\n" +"> > print(left, right)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > R L\n" +"> > ~~~\n" +"> > {: .output}\n" +"> >\n" +"> > In the first case we used a temporary variable `temp` to keep the value of `left` before we\n" +"> > overwrite it with the value of `right`. In the second case, `right` and `left` are packed into a\n" +"> > list and then unpacked into `left` and `right`." +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:51 +# blockquote, which can be cascaded +msgid "> ## Fixing and Testing" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:52 +# blockquote, which can be cascaded +msgid "> From: \"Defensive Programming\"" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:53 +msgid ">\n" +"> Fix `range_overlap`. Re-run `test_range_overlap` after each change you make.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def range_overlap(ranges):\n" +"> > '''Return common overlap among a set of [left, right] ranges.'''\n" +"> > if not ranges:\n" +"> > # ranges is None or an empty list\n" +"> > return None\n" +"> > max_left, min_right = ranges[0]\n" +"> > for (left, right) in ranges[1:]:\n" +"> > max_left = max(max_left, left)\n" +"> > min_right = min(min_right, right)\n" +"> > if max_left >= min_right: # no overlap\n" +"> > return None\n" +"> > return (max_left, min_right)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:1 +# Front Matter +msgid "---\n" +"title: Figures\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:5 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:5 +msgid "{% include base_path.html %}\n" +"{% include manual_episode_order.html %}" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:8 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:8 +# inline html +msgid "" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:68 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:68 +msgid "{% comment %} Create anchor for each one of the episodes. {% endcomment %}" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:70 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:70 +msgid "{% for lesson_episode in lesson_episodes %}\n" +" {% if site.episode_order %}\n" +" {% assign episode = site.episodes | where: \"slug\", lesson_episode | first %}\n" +" {% else %}\n" +" {% assign episode = lesson_episode %}\n" +" {% endif %}\n" +"
\n" +"{% endfor %}" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/guide.md:1 +# Front Matter +msgid "---\n" +"title: \"Instructor Notes\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:5 +# header +msgid "## About the lesson" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:7 +msgid "Our real goal isn't to teach workshop attendees Python as a programming language,\n" +"but to teach them the basic concepts that all programming depends on.\n" +"We use Python in our lessons because:" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:11 +# ordered list +msgid "1. It is free and open-source software." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:12 +# ordered list +msgid "2. It is well-documented and runs on all platforms." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:13 +# ordered list +msgid "3. It has a large and constantly growing user-base which includes scientists." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:14 +# ordered list +msgid "4. It is easier for novices to pick up than most other languages." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:16 +# header +msgid "## Legend" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:18 +msgid "We are using a dataset with records on inflammation from patients following an\n" +"arthritis treatment." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:21 +msgid "We make reference in the lesson that this data is somehow strange. It is strange\n" +"because it is fabricated! The script used to generate the inflammation data\n" +"is included as [`code/gen_inflammation.py`](../code/gen_inflammation.py)." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:25 +# header +msgid "## Overall" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:27 +msgid "This lesson is written as an introduction to Python,\n" +"but its real purpose is to introduce the single most important idea in programming:\n" +"how to solve problems by building functions,\n" +"each of which can fit in a programmer's working memory.\n" +"In order to teach that,\n" +"we must teach people a little about\n" +"the mechanics of manipulating data with lists and file I/O\n" +"so that their functions can do things they actually care about.\n" +"Our teaching order tries to show practical uses of every idea as soon as it is introduced;\n" +"instructors should resist the temptation to explain\n" +"the \"other 90%\" of the language\n" +"as well." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:40 +msgid "The final example asks them to build a command-line tool\n" +"that works with the Unix pipe-and-filter model.\n" +"We do this because it is a useful skill\n" +"and because it helps learners see that the software they use isn't magical.\n" +"Tools like `grep` might be more sophisticated than\n" +"the programs our learners can write at this point in their careers,\n" +"but it's crucial they realize this is a difference of scale rather than kind." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:48 +msgid "Explain that we use Python because:" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:50 +# unordered list +msgid "* It's free." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:51 +# unordered list +msgid "* It has a lot of scientific libraries, and more are constantly being added." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:52 +# unordered list +msgid "* It has a large scientific user community." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:53 +# unordered list +msgid "* It's easier for novices to learn than most of the mature alternatives." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:54 +msgid " (Software Carpentry originally used Perl;\n" +" when we switched,\n" +" we found that we could cover as much material in two days in Python\n" +" as we'd covered in three days in Perl,\n" +" and that retention was higher.)" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:60 +msgid "We do *not* include instructions on running the Jupyter Notebook in the tutorial\n" +"because we want to focus on the language rather than the tools.\n" +"Instructors should, however, walk learners through some basic operations:" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:64 +# unordered list +msgid "* Launch from the command line with `jupyter notebook`." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:65 +# unordered list +msgid "* Create a new notebook." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:66 +# unordered list +msgid "* Enter code or data in a cell and execute it." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:67 +# unordered list +msgid "* Explain the difference between `In[#]` and `Out[#]`." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:69 +msgid "Watching the instructor grow programs step by step\n" +"is as helpful to learners as anything to do with Python.\n" +"Resist the urge to update a single cell repeatedly\n" +"(which is what you'd probably do in real life).\n" +"Instead,\n" +"clone the previous cell and write the update in the new copy\n" +"so that learners have a complete record of how the program grew.\n" +"Once you've done this,\n" +"you can say,\n" +"\"Now why don't we just break things into small functions right from the start?\"" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:80 +msgid "The discussion of command-line scripts\n" +"assumes that students understand standard I/O and building filters,\n" +"which are covered in the lesson on the shell." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:84 +# header +msgid "## Frequently Argued Issues (FAI)" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:86 +# unordered list +msgid "* `import ... as ...` syntax." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:88 +msgid " This syntax is commonly used in the scientific Python community;\n" +" it is explicitly recommended in documentation to `import numpy as np`\n" +" and `import matplotlib.pyplot as plt`. Despite that, we have decided\n" +" not to introduce aliasing imports in this novice lesson due to the\n" +" additional cognitive load it puts on students, despite the typing that\n" +" it saves. A good summary of arguments for and against can be found in\n" +" [PR #61](https://github.com/swcarpentry/python-novice-inflammation/pull/61)." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:96 +msgid " It is up to you as an individual instructor whether you want to introduce\n" +" these aliases when you teach this lesson, but we encourage you to please\n" +" read those arguments thoroughly before deciding one way or the other." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:100 +# unordered list +msgid "* NumPy methods." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:102 +msgid " We used to use NumPy array methods in the first [NumPy topic]({{ page.root }}/01-numpy/).\n" +" We switched these methods to the equivalent functions because a majority\n" +" of instructors supported the change; see\n" +" [PR #244](https://github.com/swcarpentry/python-novice-inflammation/pull/244)\n" +" for detailed arguments for and against the change." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:108 +# unordered list +msgid "* Underscores vs. hyphens in filenames" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:110 +msgid " We used to use hyphens in filenames in order to signify that these Python\n" +" files should only be run as scripts and never imported. However, after some\n" +" [discussion](https://github.com/swcarpentry/python-novice-inflammation/pull/254),\n" +" including an informal Twitter poll, we switched over to underscores because\n" +" many files that start off as Python scripts end up being imported eventually.\n" +" For that reason, we also added `if __name__ == '__main__'` guards around\n" +" `main()` calls, which is how real-world Python scripts ensure that imports\n" +" do not result in side-effects." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:119 +msgid "After discussing the challenges is a good time to introduce the `b *= 2` syntax." +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:1 +#: python-novice-inflammation/aio.md:5 +msgid "{% comment %}\n" +"As a maintainer, you don't need to edit this file.\n" +"If you notice that something doesn't work, please\n" +"open an issue: https://github.com/carpentries/styles/issues/new\n" +"{% endcomment %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:7 +msgid "{% include manual_episode_order.html %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:9 +msgid "{% for lesson_episode in lesson_episodes %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:11 +msgid "{% if site.episode_order %}\n" +" {% assign e = site.episodes | where: \"slug\", lesson_episode | first %}\n" +"{% else %}\n" +" {% assign e = lesson_episode %}\n" +"{% endif %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:17 +msgid "

{{ e.title }}

" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:19 +msgid "{% include episode_overview.html teaching_time=e.teaching exercise_time=e.exercises episode_questions=e.questions episode_objectives=e.objectives %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:21 +msgid "{{ e.content }}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:23 +msgid "{% include episode_keypoints.html episode_keypoints=e.keypoints %}\n" +"
\n" +"{% endfor %}" +msgstr "" + +#: python-novice-inflammation/_includes/links.md:1 +msgid "{% include base_path.html %}\n" +"[cc-by-human]: https://creativecommons.org/licenses/by/4.0/\n" +"[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode\n" +"[ci]: http://communityin.org/\n" +"[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html\n" +"[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html\n" +"[concept-maps]: https://carpentries.github.io/instructor-training/05-memory/\n" +"[contrib-covenant]: https://contributor-covenant.org/\n" +"[contributing]: {{ repo_url }}/blob/{{ source_branch }}/CONTRIBUTING.md\n" +"[cran-checkpoint]: https://cran.r-project.org/package=checkpoint\n" +"[cran-knitr]: https://cran.r-project.org/package=knitr\n" +"[cran-stringr]: https://cran.r-project.org/package=stringr\n" +"[dc-lessons]: http://www.datacarpentry.org/lessons/\n" +"[email]: mailto:team@carpentries.org\n" +"[github-importer]: https://import.github.com/\n" +"[importer]: https://github.com/new/import\n" +"[jekyll-collection]: https://jekyllrb.com/docs/collections/\n" +"[jekyll-install]: https://jekyllrb.com/docs/installation/\n" +"[jekyll-windows]: http://jekyll-windows.juthilo.com/\n" +"[jekyll]: https://jekyllrb.com/\n" +"[jupyter]: https://jupyter.org/\n" +"[kramdown]: https://kramdown.gettalong.org/\n" +"[lc-lessons]: https://librarycarpentry.org/lessons/\n" +"[lesson-aio]: {{ relative_root_path }}{% link aio.md %}\n" +"[lesson-coc]: {{ relative_root_path }}{% link CODE_OF_CONDUCT.md %}\n" +"[lesson-example]: https://carpentries.github.io/lesson-example/\n" +"[lesson-license]: {{ relative_root_path }}{% link LICENSE.md %}\n" +"[lesson-mainpage]: {{ relative_root_path }}{% link index.md %}\n" +"[lesson-reference]: {{ relative_root_path }}{% link reference.md %}\n" +"[lesson-setup]: {{ relative_root_path }}{% link setup.md %}\n" +"[mit-license]: https://opensource.org/licenses/mit-license.html\n" +"[morea]: https://morea-framework.github.io/\n" +"[numfocus]: https://numfocus.org/\n" +"[osi]: https://opensource.org\n" +"[pandoc]: https://pandoc.org/\n" +"[paper-now]: https://github.com/PeerJ/paper-now\n" +"[python-gapminder]: https://swcarpentry.github.io/python-novice-gapminder/\n" +"[pyyaml]: https://pypi.org/project/PyYAML/\n" +"[r-markdown]: https://rmarkdown.rstudio.com/\n" +"[rstudio]: https://www.rstudio.com/\n" +"[ruby-install-guide]: https://www.ruby-lang.org/en/downloads/\n" +"[ruby-installer]: https://rubyinstaller.org/\n" +"[rubygems]: https://rubygems.org/pages/download/\n" +"[styles]: https://github.com/carpentries/styles/\n" +"[swc-lessons]: https://software-carpentry.org/lessons/\n" +"[swc-releases]: https://github.com/swcarpentry/swc-releases\n" +"[training]: https://carpentries.github.io/instructor-training/\n" +"[workshop-repo]: {{ site.workshop_repo }}\n" +"[yaml]: http://yaml.org/" +msgstr "" + +#: python-novice-inflammation/aio.md:1 +# Front Matter +msgid "---\n" +"permalink: /aio/index.html\n" +"---" +msgstr "" + +#: python-novice-inflammation/aio.md:11 +msgid "{% include base_path.html %}" +msgstr "" + +#: python-novice-inflammation/aio.md:13 +msgid "{% include aio-script.md %}" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:49 +msgid " please work in ,\n" +" which can be viewed at ." +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:69 +msgid "There are many ways to contribute,\n" +"from writing new exercises and improving existing ones\n" +"to updating or filling in the documentation\n" +"and submitting [bug reports][issues]\n" +"about things that don't work, aren't clear, or are missing.\n" +"If you are looking for ideas, please see the 'Issues' tab for\n" +"a list of issues associated with this repository,\n" +"or you may also look at the issues for [Data Carpentry][dc-issues], \n" +"[Software Carpentry][swc-issues], and [Library Carpentry][lc-issues] projects." +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:1 +# header +msgid "# FIXME Lesson title" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:3 +msgid "[![Create a Slack Account with us](https://img.shields.io/badge/Create_Slack_Account-The_Carpentries-071159.svg)](https://swc-slack-invite.herokuapp.com/)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:5 +msgid "This repository generates the corresponding lesson website from [The Carpentries](https://carpentries.org/) repertoire of lessons. " +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:9 +msgid "We welcome all contributions to improve the lesson! Maintainers will do their best to help you if you have any\n" +"questions, concerns, or experience any difficulties along the way." +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:12 +msgid "We'd like to ask you to familiarize yourself with our [Contribution Guide](CONTRIBUTING.md) and have a look at\n" +"the [more detailed guidelines][lesson-example] on proper formatting, ways to render the lesson locally, and even\n" +"how to write new episodes." +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:16 +msgid "Please see the current list of [issues][FIXME] for ideas for contributing to this\n" +"repository. For making your contribution, we use the GitHub flow, which is\n" +"nicely explained in the chapter [Contributing to a Project](http://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project) in Pro Git\n" +"by Scott Chacon.\n" +"Look for the tag ![good_first_issue](https://img.shields.io/badge/-good%20first%20issue-gold.svg). This indicates that the maintainers will welcome a pull request fixing this issue. " +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:23 +# header +msgid "## Maintainer(s)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:25 +msgid "Current maintainers of this lesson are " +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:27 +#: python-novice-inflammation/bin/boilerplate/README.md:28 +#: python-novice-inflammation/bin/boilerplate/README.md:29 +# unordered list +msgid "* FIXME" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:34 +msgid "A list of contributors to the lesson can be found in [AUTHORS](AUTHORS)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:38 +msgid "To cite this lesson, please consult with [CITATION](CITATION)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:40 +msgid "[lesson-example]: https://carpentries.github.io/lesson-example" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/_episodes/01-introduction.md:1 +# Front Matter +msgid "---\n" +"title: \"Introduction\"\n" +"teaching: 0\n" +"exercises: 0\n" +"questions:\n" +"- \"Key question (FIXME)\"\n" +"objectives:\n" +"- \"First learning objective. (FIXME)\"\n" +"keypoints:\n" +"- \"First key point. Brief Answer to questions. (FIXME)\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/_episodes/01-introduction.md:12 +#: python-novice-inflammation/bin/boilerplate/_extras/discuss.md:4 +#: python-novice-inflammation/bin/boilerplate/_extras/guide.md:4 +#: python-novice-inflammation/bin/boilerplate/reference.md:7 +#: python-novice-inflammation/bin/boilerplate/setup.md:4 +msgid "FIXME" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/_extras/about.md:4 +msgid "{% include carpentries.html %}\n" +"{% include links.md %}" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:1 +# Front Matter +msgid "---\n" +"layout: lesson\n" +"root: . # Is the only page that doesn't follow the pattern /:path/index.html\n" +"permalink: index.html # Is the only page that doesn't follow the pattern /:path/index.html\n" +"---" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:6 +msgid "FIXME: home page introduction" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:8 +msgid "" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:10 +msgid "{% comment %} This is a comment in Liquid {% endcomment %}" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:12 +#: python-novice-inflammation/index.md:37 +# blockquote, which can be cascaded +msgid "> ## Prerequisites" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:13 +msgid ">\n" +"> FIXME" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:15 +#: python-novice-inflammation/index.md:44 +# SC/DC Template label +msgid "{: .prereq}" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/reference.md:1 +#: python-novice-inflammation/reference.md:1 +# Front Matter +msgid "---\n" +"layout: reference\n" +"---" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/reference.md:5 +#: python-novice-inflammation/reference.md:5 +# header +msgid "## Glossary" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/setup.md:1 +#: python-novice-inflammation/setup.md:1 +# Front Matter +msgid "---\n" +"title: Setup\n" +"---" +msgstr "" + +#: python-novice-inflammation/fig/README.md:1 +# header +msgid "## Why SVG?" +msgstr "" + +#: python-novice-inflammation/fig/README.md:3 +msgid "The SVG format (for \"Scalable Vector Graphics\") has a number of advantages over standard \"raster\"\n" +"graphics formats such as JPG, PNG, etc. Most importantly, as the name suggests, SVG images scale\n" +"up or down without loss of visual clarity: they look equally good on a phone, a laptop computer,\n" +"or a 70-inch screen, and don't blur when scaled up." +msgstr "" + +#: python-novice-inflammation/fig/README.md:8 +msgid "Additionally, SVG is a text-based format (based on XML, if you care). As text files, SVG images\n" +"are thus human-readable (a trained eye makes sense of them) and maintainable: easy to manually\n" +"edit, and efficiently tracked by version control systems (VCSs) such as Git. By contrast, images\n" +"in raster formats, being binary files, are versioned as whole objects -- the slightest change\n" +"results in updating the entire file." +msgstr "" + +#: python-novice-inflammation/fig/README.md:14 +# header +msgid "## Working with SVG figures" +msgstr "" + +#: python-novice-inflammation/fig/README.md:16 +msgid "A number of tools can create or modify SVG images -- pick one you like!" +msgstr "" + +#: python-novice-inflammation/fig/README.md:18 +msgid "Many tools, however, delete comments they don't deem useful, and insert extra information useful\n" +"to them, but unneeded for us, and unsuited to our highly collaborative lesson development process." +msgstr "" + +#: python-novice-inflammation/fig/README.md:21 +msgid "Below are some tips on keeping the information we need and removing the information we don't need\n" +"in SVG files before submitting them to our repository." +msgstr "" + +#: python-novice-inflammation/fig/README.md:24 +# header +msgid "### Comments" +msgstr "" + +#: python-novice-inflammation/fig/README.md:26 +msgid "Before modifying an existing figure, inspect it with a text editor, making note of all comments,\n" +"which in SVG files are enclosed between ``. Be sure to add them back in (with\n" +"appropriate changes) after editing the figure, if the tool you use removed them." +msgstr "" + +#: python-novice-inflammation/fig/README.md:30 +# header +msgid "### General tips" +msgstr "" + +#: python-novice-inflammation/fig/README.md:32 +msgid "When using any SVG editor, please make sure to:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:34 +# unordered list +msgid "- save the figure as \"plain\" SVG rather than editor-specific SVG." +msgstr "" + +#: python-novice-inflammation/fig/README.md:35 +# unordered list +msgid "- not group elements (``) unless necessary or beneficial" +msgstr "" + +#: python-novice-inflammation/fig/README.md:36 +# unordered list +msgid "- not embed other SVG images using ``" +msgstr "" + +#: python-novice-inflammation/fig/README.md:38 +msgid "After editing the figure, clean it up using the command-line tool\n" +"[svgcleaner](https://github.com/RazrFalcon/svgcleaner), by running the following in a terminal\n" +"(replace `SVG_figure` by the name of the SVG figure):" +msgstr "" + +#: python-novice-inflammation/fig/README.md:42 +# code block +msgid "```\n" +"svgcleaner \\\n" +" --indent 2 \\\n" +" --ungroup-defs no \\\n" +" --multipass \\\n" +" --coordinates-precision 1 \\\n" +" --properties-precision 1 \\\n" +" --paths-coordinates-precision 1 \\\n" +" SVG_figure.svg SVG_figure_svgcleaner.svg\n" +"```" +msgstr "" + +#: python-novice-inflammation/fig/README.md:53 +msgid "Alternatively, you can also use [svgo](https://github.com/svg/svgo) or\n" +"[scour](https://www.codedread.com/scour/)." +msgstr "" + +#: python-novice-inflammation/fig/README.md:56 +msgid "**The following steps are optional.**" +msgstr "" + +#: python-novice-inflammation/fig/README.md:58 +msgid "Open the file produced by `svgcleaner` (`SVG_figure_svgcleaner.svg` in the example above)\n" +"and follow these steps:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:61 +# unordered list +msgid "- Wrap lines to be under 100 characters (or less) if possible. For example, change this:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:63 +# code block +msgid " ```xml\n" +" 65.0\n" +" ```" +msgstr "" + +#: python-novice-inflammation/fig/README.md:66 +msgid " to this:\n" +" ```xml\n" +" 65.0\n" +" ```" +msgstr "" + +#: python-novice-inflammation/fig/README.md:75 +# unordered list +msgid "- Comment on the nature of each element, using ``, where applicable and when" +msgstr "" + +#: python-novice-inflammation/fig/README.md:76 +msgid " feasible. For example:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:78 +# code block +msgid " ```xml\n" +" \n" +" " +msgstr "" + +#: python-novice-inflammation/fig/README.md:97 +# header +msgid "## Not an SVG expert" +msgstr "" + +#: python-novice-inflammation/fig/README.md:99 +msgid "Don't let the above guidelines discourage you. If needed, submit your contribution \"as is\" and\n" +"mention which steps you skipped. Maintainers will happily help -- make sure they can commit to the\n" +"branch you use to submit your contribution." +msgstr "" + +#: python-novice-inflammation/index.md:1 +# Front Matter +msgid "---\n" +"layout: lesson\n" +"root: .\n" +"permalink: index.html\n" +"---" +msgstr "" + +#: python-novice-inflammation/index.md:7 +msgid "The best way to learn how to program is to do something useful,\n" +"so this introduction to Python is built around a common scientific task:\n" +"**data analysis**." +msgstr "" + +#: python-novice-inflammation/index.md:11 +# header +msgid "### Arthritis Inflammation" +msgstr "" + +#: python-novice-inflammation/index.md:12 +msgid "We are studying **inflammation in patients** who have been given a new treatment for arthritis, and\n" +"need to analyze the first dozen data sets of their daily inflammation. The data sets are stored in\n" +"[comma-separated values]({{ page.root }}/reference.html#comma-separated-values) (CSV) format:" +msgstr "" + +#: python-novice-inflammation/index.md:16 +# unordered list +msgid "- each row holds information for a single patient," +msgstr "" + +#: python-novice-inflammation/index.md:17 +# unordered list +msgid "- columns represent successive days." +msgstr "" + +#: python-novice-inflammation/index.md:19 +msgid "The first three rows of our first file look like this:\n" +"~~~\n" +"0,0,1,3,1,2,4,7,8,3,3,3,10,5,7,4,7,7,12,18,6,13,11,11,7,7,4,6,8,8,4,4,5,7,3,4,2,3,0,0\n" +"0,1,2,1,2,1,3,2,2,6,10,11,5,9,4,4,7,16,8,6,18,4,12,5,12,7,11,5,11,3,3,5,4,4,5,5,1,1,0,1\n" +"0,1,1,3,3,2,6,2,5,9,5,7,4,5,4,15,5,11,9,10,19,14,12,17,7,12,11,7,4,2,10,5,4,2,2,3,2,2,1,1\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/index.md:25 +#: python-novice-inflammation/setup.md:118 +#: python-novice-inflammation/setup.md:128 +#: python-novice-inflammation/setup.md:134 +# SC/DC Template label +msgid "{: .source}" +msgstr "" + +#: python-novice-inflammation/index.md:26 +msgid "Each number represents the number of inflammation bouts that a particular patient experienced on a\n" +"given day. For example, value \"6\" at row 3 column 7 of the data set above means that the third\n" +"patient was experiencing inflammation six times on the seventh day of the clinical study." +msgstr "" + +#: python-novice-inflammation/index.md:30 +msgid "So, we want to:" +msgstr "" + +#: python-novice-inflammation/index.md:32 +# ordered list +msgid "1. Calculate the average inflammation per day across all patients." +msgstr "" + +#: python-novice-inflammation/index.md:33 +# ordered list +msgid "2. Plot the result to discuss and share with colleagues." +msgstr "" + +#: python-novice-inflammation/index.md:35 +msgid "To do all that, we'll have to learn a little bit about programming." +msgstr "" + +#: python-novice-inflammation/index.md:38 +msgid ">\n" +"> You need to understand the concepts of **files** and **directories** and how to start a Python\n" +"> interpreter before tackling this lesson. This lesson sometimes references Jupyter\n" +"> Notebook although you can use any Python interpreter mentioned in the [Setup][lesson-setup].\n" +">\n" +"> The commands in this lesson pertain to **Python 3**." +msgstr "" + +#: python-novice-inflammation/index.md:46 +# header +msgid "### Getting Started" +msgstr "" + +#: python-novice-inflammation/index.md:47 +msgid "To get started, follow the directions on the \"[Setup][lesson-setup]\" page to download data\n" +"and install a Python interpreter." +msgstr "" + +#: python-novice-inflammation/reference.md:7 +msgid "{:auto_ids}\n" +"additive color model\n" +": A way to represent colors as the sum of contributions from primary colors\n" +" such as [red, green, and blue](#rgb)." +msgstr "" + +#: python-novice-inflammation/reference.md:12 +msgid "argument\n" +": A value given to a function or program when it runs.\n" +" The term is often used interchangeably (and inconsistently) with [parameter](#parameter)." +msgstr "" + +#: python-novice-inflammation/reference.md:16 +msgid "assertion\n" +": An expression which is supposed to be true at a particular point in a program.\n" +" Programmers typically put assertions in their code to check for errors;\n" +" if the assertion fails (i.e., if the expression evaluates as false),\n" +" the program halts and produces an error message.\n" +" See also: [invariant](#invariant), [precondition](#precondition),\n" +" [postcondition](#postcondition)." +msgstr "" + +#: python-novice-inflammation/reference.md:24 +msgid "assign\n" +": To give a value a name by associating a variable with it." +msgstr "" + +#: python-novice-inflammation/reference.md:27 +msgid "body\n" +": (of a function): the statements that are executed when a function runs." +msgstr "" + +#: python-novice-inflammation/reference.md:30 +msgid "call stack\n" +": A data structure inside a running program that keeps track of active function calls." +msgstr "" + +#: python-novice-inflammation/reference.md:33 +msgid "case-insensitive\n" +": Treating text as if upper and lower case characters of the same letter were the same.\n" +" See also: [case-sensitive](#case-sensitive)." +msgstr "" + +#: python-novice-inflammation/reference.md:37 +msgid "case-sensitive\n" +": Treating text as if upper and lower case characters of the same letter are different.\n" +" See also: [case-insensitive](#case-insensitive)." +msgstr "" + +#: python-novice-inflammation/reference.md:41 +msgid "comment\n" +": A remark in a program that is intended to help human readers understand what is going on,\n" +" but is ignored by the computer.\n" +" Comments in Python, R, and the Unix shell start with a `#` character and\n" +" run to the end of the line;\n" +" comments in SQL start with `--`,\n" +" and other languages have other conventions." +msgstr "" + +#: python-novice-inflammation/reference.md:49 +msgid "compose\n" +": To apply one function to the result of another, such as `f(g(x))`." +msgstr "" + +#: python-novice-inflammation/reference.md:52 +msgid "conditional statement\n" +": A statement in a program that might or might not be executed\n" +" depending on whether a test is true or false." +msgstr "" + +#: python-novice-inflammation/reference.md:56 +msgid "comma-separated values\n" +": (CSV) A common textual representation for tables\n" +" in which the values in each row are separated by commas." +msgstr "" + +#: python-novice-inflammation/reference.md:60 +msgid "default value\n" +": A value to use for a [parameter](#parameter) if nothing is specified explicitly." +msgstr "" + +#: python-novice-inflammation/reference.md:63 +msgid "defensive programming\n" +": The practice of writing programs that check their own operation\n" +" to catch errors as early as possible." +msgstr "" + +#: python-novice-inflammation/reference.md:67 +msgid "delimiter\n" +": A character or characters used to separate individual values,\n" +" such as the commas between columns in a [CSV](#comma-separated-values) file." +msgstr "" + +#: python-novice-inflammation/reference.md:71 +msgid "docstring\n" +": Short for \"documentation string\",\n" +" this refers to textual documentation embedded in Python programs.\n" +" Unlike comments, docstrings are preserved in the running program\n" +" and can be examined in interactive sessions." +msgstr "" + +#: python-novice-inflammation/reference.md:77 +msgid "documentation\n" +": Human-language text written to explain what software does,\n" +" how it works, or how to use it." +msgstr "" + +#: python-novice-inflammation/reference.md:81 +msgid "dotted notation\n" +": A two-part notation used in many programming languages\n" +" in which `thing.component` refers to the `component` belonging to `thing`." +msgstr "" + +#: python-novice-inflammation/reference.md:85 +msgid "empty string\n" +": A character string containing no characters,\n" +" often thought of as the \"zero\" of text." +msgstr "" + +#: python-novice-inflammation/reference.md:89 +msgid "encapsulation\n" +": The practice of hiding something's implementation details\n" +" so that the rest of a program can worry about *what* it does\n" +" rather than *how* it does it." +msgstr "" + +#: python-novice-inflammation/reference.md:94 +msgid "floating-point number\n" +": A number containing a fractional part and an exponent.\n" +" See also: [integer](#integer)." +msgstr "" + +#: python-novice-inflammation/reference.md:98 +msgid "for loop\n" +": A loop that is executed once for each value in some kind of set, list, or range.\n" +" See also: [while loop](#while-loop)." +msgstr "" + +#: python-novice-inflammation/reference.md:102 +msgid "function\n" +": A named group of instructions that is executed when the function's name is used in\n" +" the code. Occurrence of a function name in the code is a [function call](#function-call).\n" +" Functions may process input [arguments](#argument) and return the result back. Functions\n" +" may also be used for logically grouping together pieces of code. In such cases, they don't\n" +" need to return any meaningful value and can be written without the\n" +" [`return` statement](#return-statement) completely.\n" +" Such functions return a special value `None`, which is a way of saying \"nothing\" in Python." +msgstr "" + +#: python-novice-inflammation/reference.md:111 +msgid "function call\n" +": A use of a function in another piece of software." +msgstr "" + +#: python-novice-inflammation/reference.md:114 +msgid "heat map\n" +": A graphical representation of two-dimensional data in which colors,\n" +" ranging on a scale of hue or intensity, represent the data values." +msgstr "" + +#: python-novice-inflammation/reference.md:118 +msgid "immutable\n" +": Unchangeable.\n" +" The value of immutable data cannot be altered after it has been created.\n" +" See also: [mutable](#mutable)." +msgstr "" + +#: python-novice-inflammation/reference.md:123 +msgid "import\n" +": To load a [library](#library) into a program." +msgstr "" + +#: python-novice-inflammation/reference.md:126 +msgid "in-place operators\n" +": An operator such as `+=` that provides a shorthand notation for\n" +" the common case in which the variable being assigned to\n" +" is also an operand on the right hand side of the assignment.\n" +" For example, the statement `x += 3` means the same thing as `x = x + 3`." +msgstr "" + +#: python-novice-inflammation/reference.md:132 +msgid "index\n" +": A subscript that specifies the location of a single value in a collection,\n" +" such as a single pixel in an image." +msgstr "" + +#: python-novice-inflammation/reference.md:136 +msgid "inner loop\n" +": A loop that is inside another loop. See also: [outer loop](#outer-loop)." +msgstr "" + +#: python-novice-inflammation/reference.md:139 +msgid "integer\n" +": A whole number, such as -12343. See also: [floating-point number](#floating-point-number)." +msgstr "" + +#: python-novice-inflammation/reference.md:142 +msgid "invariant\n" +": An expression whose value doesn't change during the execution of a program,\n" +" typically used in an [assertion](#assertion).\n" +" See also: [precondition](#precondition), [postcondition](#postcondition)." +msgstr "" + +#: python-novice-inflammation/reference.md:147 +msgid "library\n" +": A family of code units (functions, classes, variables) that implement a set of\n" +" related tasks." +msgstr "" + +#: python-novice-inflammation/reference.md:151 +msgid "loop variable\n" +": The variable that keeps track of the progress of the loop." +msgstr "" + +#: python-novice-inflammation/reference.md:154 +msgid "member\n" +": A variable contained within an [object](#object)." +msgstr "" + +#: python-novice-inflammation/reference.md:157 +msgid "method\n" +": A function which is tied to a particular [object](#object).\n" +" Each of an object's methods typically implements one of the things it can do,\n" +" or one of the questions it can answer." +msgstr "" + +#: python-novice-inflammation/reference.md:162 +msgid "mutable\n" +": Changeable. The value of mutable data can be altered after it has been\n" +" created. See [immutable](#immutable).\"" +msgstr "" + +#: python-novice-inflammation/reference.md:166 +msgid "notebook\n" +": Interactive computational environment accessed via your web browser, in which you can write\n" +" and execute Python code and combine it with explanatory text, mathematics and visualizations.\n" +" Examples are IPython or Jupyter notebooks." +msgstr "" + +#: python-novice-inflammation/reference.md:171 +msgid "object\n" +": A collection of conceptually related variables ([members](#member)) and\n" +" functions using those variables ([methods](#method))." +msgstr "" + +#: python-novice-inflammation/reference.md:175 +msgid "outer loop\n" +": A loop that contains another loop.\n" +" See also: [inner loop](#inner-loop)." +msgstr "" + +#: python-novice-inflammation/reference.md:179 +msgid "parameter\n" +": A variable named in the function's declaration that is used to\n" +" hold a value passed into the call.\n" +" The term is often used interchangeably (and inconsistently) with [argument](#argument)." +msgstr "" + +#: python-novice-inflammation/reference.md:184 +msgid "pipe\n" +": A connection from the output of one program to the input of another.\n" +" When two or more programs are connected in this way, they are called a \"pipeline\"." +msgstr "" + +#: python-novice-inflammation/reference.md:188 +msgid "postcondition\n" +": A condition that a function (or other block of code) guarantees is true\n" +" once it has finished running.\n" +" Postconditions are often represented using [assertions](#assertion)." +msgstr "" + +#: python-novice-inflammation/reference.md:193 +msgid "precondition\n" +": A condition that must be true in order for a function (or other block of code)\n" +" to run correctly." +msgstr "" + +#: python-novice-inflammation/reference.md:197 +msgid "regression\n" +": To re-introduce a bug that was once fixed." +msgstr "" + +#: python-novice-inflammation/reference.md:200 +msgid "return statement\n" +": A statement that causes a function to stop executing and return a value\n" +" to its caller immediately." +msgstr "" + +#: python-novice-inflammation/reference.md:204 +msgid "RGB\n" +": An [additive model](#additive-color-model)\n" +" that represents colors as combinations of red, green, and blue.\n" +" Each color's value is typically in the range 0..255\n" +" (i.e., a one-byte integer)." +msgstr "" + +#: python-novice-inflammation/reference.md:210 +msgid "sequence\n" +": A collection of information that is presented in a specific order.\n" +" For example, in Python, a [string](#string) is a sequence of characters,\n" +" while a list is a sequence of any variable." +msgstr "" + +#: python-novice-inflammation/reference.md:215 +msgid "shape\n" +": An array's dimensions, represented as a vector.\n" +" For example, a 5×3 array's shape is `(5,3)`." +msgstr "" + +#: python-novice-inflammation/reference.md:219 +msgid "silent failure\n" +": Failing without producing any warning messages.\n" +" Silent failures are hard to detect and debug." +msgstr "" + +#: python-novice-inflammation/reference.md:223 +msgid "slice\n" +": A regular subsequence of a larger sequence,\n" +" such as the first five elements or every second element." +msgstr "" + +#: python-novice-inflammation/reference.md:227 +msgid "stack frame\n" +": A data structure that provides storage for a function's local variables.\n" +" Each time a function is called, a new stack frame is created\n" +" and put on the top of the [call stack](#call-stack). When the function returns,\n" +" the stack frame is discarded." +msgstr "" + +#: python-novice-inflammation/reference.md:233 +msgid "standard input\n" +": A process's default input stream.\n" +" In interactive command-line applications,\n" +" it is typically connected to the keyboard; in a [pipe](#pipe),\n" +" it receives data from the [standard output](#standard-output) of the preceding process." +msgstr "" + +#: python-novice-inflammation/reference.md:239 +msgid "standard output\n" +": A process's default output stream.\n" +" In interactive command-line applications,\n" +" data sent to standard output is displayed on the screen;\n" +" in a [pipe](#pipe),\n" +" it is passed to the [standard input](#standard-input) of the next process." +msgstr "" + +#: python-novice-inflammation/reference.md:246 +msgid "string\n" +": Short for \"character string\",\n" +" a [sequence](#sequence) of zero or more characters." +msgstr "" + +#: python-novice-inflammation/reference.md:250 +msgid "syntax\n" +": The rules that define how code must be written for a computer to understand." +msgstr "" + +#: python-novice-inflammation/reference.md:253 +msgid "syntax error\n" +": A programming error that occurs when statements are in an order or contain characters\n" +" not expected by the programming language." +msgstr "" + +#: python-novice-inflammation/reference.md:257 +msgid "test oracle\n" +": A program, device, data set, or human being\n" +" against which the results of a test can be compared." +msgstr "" + +#: python-novice-inflammation/reference.md:261 +msgid "test-driven development\n" +": The practice of writing unit tests *before* writing the code they test." +msgstr "" + +#: python-novice-inflammation/reference.md:264 +msgid "traceback\n" +": The sequence of function calls that led to an error." +msgstr "" + +#: python-novice-inflammation/reference.md:267 +msgid "tuple\n" +": An [immutable](#immutable) [sequence](#sequence) of values." +msgstr "" + +#: python-novice-inflammation/reference.md:270 +msgid "type\n" +": The classification of something in a program (for example, the contents of a variable)\n" +" as a kind of number (e.g. [floating-point](#float), [integer](#integer)),\n" +" [string](#string), or something else." +msgstr "" + +#: python-novice-inflammation/reference.md:275 +msgid "type of error\n" +": Indicates the nature of an error in a program. For example, in Python,\n" +" an `IOError` to problems with file input/output.\n" +" See also: [syntax error](#syntax-error)." +msgstr "" + +#: python-novice-inflammation/reference.md:280 +msgid "variable\n" +": A value that has a name associated with it." +msgstr "" + +#: python-novice-inflammation/reference.md:283 +msgid "while loop\n" +": A loop that keeps executing as long as some condition is true.\n" +" See also: [for loop](#for-loop)." +msgstr "" + +#: python-novice-inflammation/setup.md:5 +# header +msgid "## Overview" +msgstr "" + +#: python-novice-inflammation/setup.md:7 +msgid "This lesson is designed to be run on a personal computer.\n" +"All of the software and data used in this lesson are freely available online,\n" +"and instructions on how to obtain them are provided below." +msgstr "" + +#: python-novice-inflammation/setup.md:11 +# header +msgid "## Install Python" +msgstr "" + +#: python-novice-inflammation/setup.md:13 +msgid "In this lesson, we will be using Python 3 with some of its most popular scientific libraries.\n" +"Although one can install a plain-vanilla Python and all required libraries by hand,\n" +"we recommend installing [Anaconda][anaconda-website],\n" +"a Python distribution that comes with everything we need for the lesson.\n" +"Detailed installation instructions for various operating systems can be found\n" +"on The Carpentries [template website for workshops][anaconda-instructions]\n" +"and in [Anaconda documentation][anaconda-install]." +msgstr "" + +#: python-novice-inflammation/setup.md:21 +# header +msgid "## Obtain lesson materials" +msgstr "" + +#: python-novice-inflammation/setup.md:23 +# ordered list +msgid "1. Download [python-novice-inflammation-data.zip][zipfile1]" +msgstr "" + +#: python-novice-inflammation/setup.md:24 +msgid " and [python-novice-inflammation-code.zip][zipfile2].\n" +"2. Create a folder called `swc-python` on your Desktop.\n" +"3. Move downloaded files to `swc-python`.\n" +"4. Unzip the files." +msgstr "" + +#: python-novice-inflammation/setup.md:29 +msgid "You should see two folders called `data` and `code` in the `swc-python` directory on your\n" +"Desktop." +msgstr "" + +#: python-novice-inflammation/setup.md:32 +# header +msgid "## Launch Python interface" +msgstr "" + +#: python-novice-inflammation/setup.md:34 +msgid "To start working with Python, we need to launch a program that will interpret and execute our Python\n" +"commands. Below we list several options. If you don't have a preference, proceed with the top\n" +"option in the list that is available on your machine. Otherwise, you may use any interface you like." +msgstr "" + +#: python-novice-inflammation/setup.md:38 +# header +msgid "## Option A: Jupyter Notebook" +msgstr "" + +#: python-novice-inflammation/setup.md:40 +msgid "A Jupyter Notebook provides a browser-based interface for working with Python.\n" +"If you installed Anaconda, you can launch a notebook in two ways:" +msgstr "" + +#: python-novice-inflammation/setup.md:43 +# blockquote, which can be cascaded +msgid "> ## Anaconda Navigator" +msgstr "" + +#: python-novice-inflammation/setup.md:44 +msgid ">\n" +"> 1. Launch Anaconda Navigator.\n" +"> It might ask you if you'd like to send anonymized usage information to Anaconda developers:\n" +"> ![Anaconda Navigator first launch]({{ page.root }}{% link fig/anaconda-navigator-first-launch.png %})\n" +"> Make your choice and click \"Ok, and don't show again\" button.\n" +"> 2. Find the \"Notebook\" tab and click on the \"Launch\" button:\n" +"> ![Anaconda Navigator Notebook launch]({{ page.root }}{% link fig/anaconda-navigator-notebook-launch.png %})\n" +"> Anaconda will open a new browser window or tab with a Notebook Dashboard showing you the\n" +"> contents of your Home (or User) folder.\n" +"> 3. Navigate to the `data` directory by clicking on the directory names leading to it:\n" +"> `Desktop`, `swc-python`, then `data`:\n" +"> ![Anaconda Navigator Notebook directory]({{ page.root }}{% link fig/jupyter-notebook-data-directory.png %})\n" +"> 4. Launch the notebook by clicking on the \"New\" button and then selecting \"Python 3\":\n" +"> ![Anaconda Navigator Notebook directory]({{ page.root }}{% link fig/jupyter-notebook-launch-notebook.png %})" +msgstr "" + +#: python-novice-inflammation/setup.md:58 +#: python-novice-inflammation/setup.md:103 +# SC/DC Template label +msgid "{: .solution}" +msgstr "" + +#: python-novice-inflammation/setup.md:60 +# blockquote, which can be cascaded +msgid "> ## Command line (Terminal)" +msgstr "" + +#: python-novice-inflammation/setup.md:61 +msgid ">\n" +"> 1\\. Navigate to the `data` directory:\n" +">\n" +"> > ## Unix shell\n" +"> > If you're using a Unix shell application, such as Terminal app in macOS, Console or Terminal\n" +"> > in Linux, or [Git Bash][gitbash] on Windows, execute the following command:\n" +"> > ~~~\n" +"> > cd ~/Desktop/swc-python/data\n" +"> > ~~~\n" +"> > {: .language-bash}" +msgstr "" + +#: python-novice-inflammation/setup.md:72 +msgid ">\n" +"> > ## Command Prompt (Windows)\n" +"> > On Windows, you can use its native Command Prompt program. The easiest way to start it up is\n" +"> > pressing Windows Logo Key+R, entering `cmd`, and hitting\n" +"> > Return. In the Command Prompt, use the following command to navigate to\n" +"> > the `data` folder:\n" +"> > ~~~\n" +"> > cd /D %userprofile%\\Desktop\\swc-python\\data\n" +"> > ~~~\n" +"> > {: .source}" +msgstr "" + +#: python-novice-inflammation/setup.md:83 +msgid ">\n" +"> 2\\. Start Jupyter server\n" +">\n" +"> > ## Unix shell\n" +"> > ~~~\n" +"> > jupyter notebook\n" +"> > ~~~\n" +"> > {: .language-bash}" +msgstr "" + +#: python-novice-inflammation/setup.md:92 +msgid ">\n" +"> > ## Command Prompt (Windows)\n" +"> > ~~~\n" +"> > python -m notebook\n" +"> > ~~~\n" +"> > {: .source}" +msgstr "" + +#: python-novice-inflammation/setup.md:99 +msgid ">\n" +"> 3\\. Launch the notebook by clicking on the \"New\" button on the right and selecting \"Python 3\"\n" +"> from the drop-down menu:\n" +"> ![Anaconda Navigator Notebook directory]({{ page.root }}{% link fig/jupyter-notebook-launch-notebook2.png %})" +msgstr "" + +#: python-novice-inflammation/setup.md:105 +#: python-novice-inflammation/setup.md:120 +msgid "  " +msgstr "" + +#: python-novice-inflammation/setup.md:107 +# header +msgid "## Option B: IPython interpreter" +msgstr "" + +#: python-novice-inflammation/setup.md:109 +msgid "IPython is an alternative solution situated somewhere in between the plain-vanilla Python\n" +"interpreter and Jupyter Notebook. It provides an interactive command-line based interpreter with\n" +"various convenience features and commands. You should have IPython on your system if you installed\n" +"[Anaconda][anaconda-instructions]." +msgstr "" + +#: python-novice-inflammation/setup.md:114 +msgid "To start using IPython, execute:\n" +"~~~\n" +"ipython\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/setup.md:122 +# header +msgid "## Option C: plain-vanilla Python interpreter" +msgstr "" + +#: python-novice-inflammation/setup.md:124 +msgid "To launch a plain-vanilla Python interpreter, execute:\n" +"~~~\n" +"python\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/setup.md:130 +msgid "If you are using [Git Bash on Windows][gitbash], you have to call Python _via_ `winpty`:\n" +"~~~\n" +"winpty python\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/setup.md:136 +msgid "[anaconda-install]: https://docs.anaconda.com/anaconda/install\n" +"[anaconda-instructions]: https://carpentries.github.io/workshop-template/#python\n" +"[anaconda-website]: https://www.anaconda.com/\n" +"[gitbash]: https://gitforwindows.org\n" +"[zipfile1]: {{ page.root }}/data/python-novice-inflammation-data.zip\n" +"[zipfile2]: {{ page.root }}/code/python-novice-inflammation-code.zip" +msgstr "" + From 196a8536a1d7ce58fdcea64f605428448acaf1af Mon Sep 17 00:00:00 2001 From: Joel Nitta Date: Fri, 11 Dec 2020 18:08:36 +0900 Subject: [PATCH 3/5] Bring in splitpot.py from master branch --- helpers/splitpot.py | 172 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 helpers/splitpot.py diff --git a/helpers/splitpot.py b/helpers/splitpot.py new file mode 100644 index 00000000..2d7b123a --- /dev/null +++ b/helpers/splitpot.py @@ -0,0 +1,172 @@ +from argparse import ArgumentParser +import configparser +import datetime +import glob +from pathlib import Path + +# from txclib.commands import _set_source_file + +# Input the lesson file that we want to split: splitplot.py lessonX.pot + +# Create directory with the file name: lessonX.pot => lessonX/ + +# Save header in memory; read till first empty line + +# Read first line, pattern: -> extract filename function +# #: lessonX/filename.md:YY +# if '#:' in line[:2] +# read till `:` => line[:2] +# Add to the filename with a number, for later join them properly together. -> save as 01_[folder-name_]file.pot +# Keep searching for whitespaces, look next line, same filename? add to it. + +def extract_filename(line): + ''' + provides the filename of a file from the po sections, like: + + "#: /path/to/file/with/courious.name:55" + + parameters + ---------- + line: a string containing a line with a filename. + + returns + ------- + filename: the name of the file. + ''' + if '#:' not in line[:2]: + raise TypeError("The current line is not one that contains a filename.") + line_bits = line.split(':') + filename = line_bits[1].strip().split('/')[-1] + return filename + + + +class Pofiles: + def __init__(self, filename): + self.filename = self._check_filename(filename) + self.lesson = self.filename.split('/')[-1].split('.')[0] + + def _check_filename(self, filename): + # filename is a pot/po file? + if '.po' not in filename[-4:]: + raise TypeError(f"The file {filename} doesn't has the right extension (.pot/.po)") + try: + with open(filename, 'r') as file_handler: + self.pot_content = file_handler.readlines() + # TODO Check file follows the pot format standard + except: + raise TypeError("There's been some error reading the file") + return filename + + def split(self, directory='transifex'): + # Check the given directory exists, if not create it: + split_directory = Path(directory) + if not split_directory.is_dir(): + split_directory.mkdir(parents=True) + # Create a directory for this lessons + lesson_directory = split_directory / self.lesson / 'pot' + lesson_directory.mkdir(parents=True) + first_blank = self.pot_content.index('\n') + self.header = self.pot_content[:first_blank + 1] + all_files = {} # To contain filename: [content] + rest_file = self.pot_content[first_blank + 1:] + file_sect = None + + for line in rest_file: + if not file_sect: + file_sect = extract_filename(line) + if file_sect not in all_files.keys(): + all_files[file_sect] = self.header + [line] + else: + all_files[file_sect].append(line) + if line == '\n': + file_sect = None + + # Write dictionary into files + for order_file, (file_sect, content_sect) in enumerate(all_files.items()): + with open(lesson_directory / f"{order_file:02d}__{file_sect}.pot", 'w') as section: + section.writelines(content_sect) + + # Generate transifex config file + tx_dir = lesson_directory.parent / '.tx' + tx_dir.mkdir() + config = configparser.ConfigParser() + config['main'] = {"host": "https://www.transifex.com"} + with open(tx_dir / 'config', 'w') as txconf: + config.write(txconf) + # TODO generate them directly + # for pot in pots: + # _set_source_file(tx_dir, self.lesson, 'en', pot) + + + + def join(self, source_dir, language): + # TODO check that filenames are there to be joint + # get all the files on source_dir/*.language.po + list_translations = glob.glob(f"{source_dir}/{language}/*.po") + list_translations.sort() + # read them all and join them with a single header # NOTE should we join the header info too? (eg., authors) + all_content = [] + translators = [] + last_touch = ('name', '"PO-Revision-Date: 2000-01-01 00:00:00+0000\\n"\n') + for file_translated in list_translations: + with open(file_translated, 'r') as section: + lines = section.readlines() + header = lines[:lines.index('\n') + 1] # we can use the last header as a template. + porev_line = list(filter(lambda x: 'Revision-Date' in x, header))[0] + potrans_line = list(filter(lambda x: 'Last' in x, header))[0] + touch = self._extract_date_po(porev_line) + if touch > self._extract_date_po(last_touch[1]): + last_touch = (potrans_line, porev_line) + lines = lines[lines.index('\n') + 1:] + ['\n'] + all_content.extend(lines) + translators_pos = header.index('# Translators:\n') + translators.extend(header[translators_pos + 1: header.index('# \n', translators_pos + 1)]) + + # find line with last revision date and replace it. + # NOTE Transifex is not updating that field! + header[header.index(porev_line)] = last_touch[1] + header[header.index(porev_line) + 1] = last_touch[0] + + # get unique and sorted names of translators + translators = sorted(set(translators)) + # FIXME add dots after each year for each translators + start = header.index("# Translators:\n") + end = header.index("# \n", start + 1) + header[start + 1: end] = translators + + all_content = header + all_content + + # path from the original filename + path_filename = Path(self.filename).parent + # Write file next to original with the language key. + with open(path_filename / f"{self.lesson}.{language}.po", 'w') as full_translation: + full_translation.writelines(all_content) + + def _extract_date_po(self, line): + title, date, time = line.split() + time = time.split('\\n"')[0] # removes the inside and outside linebreak + seconds_exist = time.count(":") == 2 + if not seconds_exist: + time, zone = time.split('+') + time = time + ":00" + time = "+".join([time, zone]) + + return datetime.datetime.strptime(f"{date} {time}", "%Y-%m-%d %H:%M:%S%z") + +if __name__ == "__main__": + command = ArgumentParser(description="Breaks a pot files into smaller chunks for better management for the translators.") + command.add_argument('filename', help="pot file to be split.") + command.add_argument('--join', '-j', dest='source', help="source directory from where to join split files") + command.add_argument('--lang', '-l', dest='language', help="which language you want to combine") + arguments = command.parse_args() + + pof = Pofiles(arguments.filename) + + if arguments.source and not arguments.language: + command.error("--join requires --lang") + + if arguments.source and arguments.language: + pof.join(arguments.source, arguments.language) + else: + pof.split() From 7a3fbb30533134f72b55bde76c5de659e63d893e Mon Sep 17 00:00:00 2001 From: Joel Nitta Date: Fri, 11 Dec 2020 18:16:13 +0900 Subject: [PATCH 4/5] Run splitpot.py to split up python-novice-inflammation.pot file --- .../python-novice-inflammation/.tx/config | 3 + .../pot/00__CODE_OF_CONDUCT.md.pot | 61 + .../pot/01__CONTRIBUTING.md.pot | 318 ++++ .../pot/02__LICENSE.md.pot | 159 ++ .../pot/03__README.md.pot | 472 ++++++ .../pot/04__01-intro.md.pot | 779 ++++++++++ .../pot/05__02-numpy.md.pot | 1037 +++++++++++++ .../pot/06__03-matplotlib.md.pot | 344 +++++ .../pot/07__04-loop.md.pot | 565 +++++++ .../pot/08__05-lists.md.pot | 736 ++++++++++ .../pot/09__06-files.md.pot | 254 ++++ .../pot/10__07-cond.md.pot | 657 +++++++++ .../pot/11__08-func.md.pot | 1155 +++++++++++++++ .../pot/12__09-errors.md.pot | 762 ++++++++++ .../pot/13__10-defensive.md.pot | 747 ++++++++++ .../pot/14__11-debugging.md.pot | 415 ++++++ .../pot/15__12-cmdline.md.pot | 1306 +++++++++++++++++ .../pot/16__about.md.pot | 34 + .../pot/17__additional_material.md.pot | 168 +++ .../pot/18__discuss.md.pot | 592 ++++++++ .../pot/19__extra_exercises.md.pot | 108 ++ .../pot/20__figures.md.pot | 112 ++ .../pot/21__guide.md.pot | 238 +++ .../pot/22__aio-script.md.pot | 60 + .../pot/23__links.md.pot | 69 + .../pot/24__aio.md.pot | 32 + .../pot/25__01-introduction.md.pot | 40 + .../pot/26__index.md.pot | 151 ++ .../pot/27__reference.md.pot | 441 ++++++ .../pot/28__setup.md.pot | 232 +++ 30 files changed, 12047 insertions(+) create mode 100644 transifex/python-novice-inflammation/.tx/config create mode 100644 transifex/python-novice-inflammation/pot/00__CODE_OF_CONDUCT.md.pot create mode 100644 transifex/python-novice-inflammation/pot/01__CONTRIBUTING.md.pot create mode 100644 transifex/python-novice-inflammation/pot/02__LICENSE.md.pot create mode 100644 transifex/python-novice-inflammation/pot/03__README.md.pot create mode 100644 transifex/python-novice-inflammation/pot/04__01-intro.md.pot create mode 100644 transifex/python-novice-inflammation/pot/05__02-numpy.md.pot create mode 100644 transifex/python-novice-inflammation/pot/06__03-matplotlib.md.pot create mode 100644 transifex/python-novice-inflammation/pot/07__04-loop.md.pot create mode 100644 transifex/python-novice-inflammation/pot/08__05-lists.md.pot create mode 100644 transifex/python-novice-inflammation/pot/09__06-files.md.pot create mode 100644 transifex/python-novice-inflammation/pot/10__07-cond.md.pot create mode 100644 transifex/python-novice-inflammation/pot/11__08-func.md.pot create mode 100644 transifex/python-novice-inflammation/pot/12__09-errors.md.pot create mode 100644 transifex/python-novice-inflammation/pot/13__10-defensive.md.pot create mode 100644 transifex/python-novice-inflammation/pot/14__11-debugging.md.pot create mode 100644 transifex/python-novice-inflammation/pot/15__12-cmdline.md.pot create mode 100644 transifex/python-novice-inflammation/pot/16__about.md.pot create mode 100644 transifex/python-novice-inflammation/pot/17__additional_material.md.pot create mode 100644 transifex/python-novice-inflammation/pot/18__discuss.md.pot create mode 100644 transifex/python-novice-inflammation/pot/19__extra_exercises.md.pot create mode 100644 transifex/python-novice-inflammation/pot/20__figures.md.pot create mode 100644 transifex/python-novice-inflammation/pot/21__guide.md.pot create mode 100644 transifex/python-novice-inflammation/pot/22__aio-script.md.pot create mode 100644 transifex/python-novice-inflammation/pot/23__links.md.pot create mode 100644 transifex/python-novice-inflammation/pot/24__aio.md.pot create mode 100644 transifex/python-novice-inflammation/pot/25__01-introduction.md.pot create mode 100644 transifex/python-novice-inflammation/pot/26__index.md.pot create mode 100644 transifex/python-novice-inflammation/pot/27__reference.md.pot create mode 100644 transifex/python-novice-inflammation/pot/28__setup.md.pot diff --git a/transifex/python-novice-inflammation/.tx/config b/transifex/python-novice-inflammation/.tx/config new file mode 100644 index 00000000..f1603f25 --- /dev/null +++ b/transifex/python-novice-inflammation/.tx/config @@ -0,0 +1,3 @@ +[main] +host = https://www.transifex.com + diff --git a/transifex/python-novice-inflammation/pot/00__CODE_OF_CONDUCT.md.pot b/transifex/python-novice-inflammation/pot/00__CODE_OF_CONDUCT.md.pot new file mode 100644 index 00000000..e296ddc0 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/00__CODE_OF_CONDUCT.md.pot @@ -0,0 +1,61 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:1 +# Front Matter +msgid "---\n" +"layout: page\n" +"title: \"Contributor Code of Conduct\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:5 +msgid "As contributors and maintainers of this project,\n" +"we pledge to follow the [Carpentry Code of Conduct][coc]." +msgstr "" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:8 +msgid "Instances of abusive, harassing, or otherwise unacceptable behavior\n" +"may be reported by following our [reporting guidelines][coc-reporting]." +msgstr "" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:11 +#: python-novice-inflammation/_episodes/01-intro.md:225 +#: python-novice-inflammation/_episodes/02-numpy.md:802 +#: python-novice-inflammation/_episodes/03-matplotlib.md:264 +#: python-novice-inflammation/_episodes/04-loop.md:416 +#: python-novice-inflammation/_episodes/05-lists.md:564 +#: python-novice-inflammation/_episodes/06-files.md:194 +#: python-novice-inflammation/_episodes/07-cond.md:508 +#: python-novice-inflammation/_episodes/08-func.md:932 +#: python-novice-inflammation/_episodes/09-errors.md:598 +#: python-novice-inflammation/_episodes/10-defensive.md:542 +#: python-novice-inflammation/_episodes/11-debugging.md:290 +#: python-novice-inflammation/_episodes/12-cmdline.md:1028 +#: python-novice-inflammation/_extras/extra_exercises.md:75 +#: python-novice-inflammation/_extras/figures.md:79 +#: python-novice-inflammation/bin/boilerplate/_episodes/01-introduction.md:14 +#: python-novice-inflammation/bin/boilerplate/_extras/discuss.md:6 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:79 +#: python-novice-inflammation/bin/boilerplate/_extras/guide.md:6 +#: python-novice-inflammation/bin/boilerplate/index.md:17 +#: python-novice-inflammation/bin/boilerplate/reference.md:9 +#: python-novice-inflammation/bin/boilerplate/setup.md:7 +#: python-novice-inflammation/index.md:50 +msgid "{% include links.md %}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/01__CONTRIBUTING.md.pot b/transifex/python-novice-inflammation/pot/01__CONTRIBUTING.md.pot new file mode 100644 index 00000000..0e67f7ba --- /dev/null +++ b/transifex/python-novice-inflammation/pot/01__CONTRIBUTING.md.pot @@ -0,0 +1,318 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/CONTRIBUTING.md:1 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:1 +# header +msgid "# Contributing" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:3 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:3 +msgid "[The Carpentries][c-site] ([Software Carpentry][swc-site], [Data Carpentry][dc-site], and [Library Carpentry][lc-site]) are open source projects,\n" +"and we welcome contributions of all kinds:\n" +"new lessons,\n" +"fixes to existing material,\n" +"bug reports,\n" +"and reviews of proposed changes are all welcome." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:10 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:10 +# header +msgid "## Contributor Agreement" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:12 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:12 +msgid "By contributing,\n" +"you agree that we may redistribute your work under [our license](LICENSE.md).\n" +"In exchange,\n" +"we will address your issues and/or assess your change proposal as promptly as we can,\n" +"and help you become a member of our community.\n" +"Everyone involved in [The Carpentries][c-site]\n" +"agrees to abide by our [code of conduct](CODE_OF_CONDUCT.md)." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:20 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:20 +# header +msgid "## How to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:22 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:22 +msgid "The easiest way to get started is to file an issue\n" +"to tell us about a spelling mistake,\n" +"some awkward wording,\n" +"or a factual error.\n" +"This is a good way to introduce yourself\n" +"and to meet some of our community members." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:29 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:29 +# ordered list +msgid "1. If you do not have a [GitHub][github] account," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:30 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:30 +msgid " you can [send us comments by email][email].\n" +" However,\n" +" we will be able to respond more quickly if you use one of the other methods described below." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:34 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:34 +# ordered list +msgid "2. If you have a [GitHub][github] account," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:35 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:35 +msgid " or are willing to [create one][github-join],\n" +" but do not know how to use Git,\n" +" you can report problems or suggest improvements by [creating an issue][issues].\n" +" This allows us to assign the item to someone\n" +" and to respond to it in a threaded discussion." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:41 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:41 +# ordered list +msgid "3. If you are comfortable with Git," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:42 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:42 +msgid " and would like to add or change material,\n" +" you can submit a pull request (PR).\n" +" Instructions for doing this are [included below](#using-github)." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:46 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:46 +# header +msgid "## Where to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:48 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:48 +# ordered list +msgid "1. If you wish to change this lesson," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:49 +msgid " please work in ,\n" +" which can be viewed at ." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:52 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:52 +# ordered list +msgid "2. If you wish to change the example lesson," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:53 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:53 +msgid " please work in ,\n" +" which documents the format of our lessons\n" +" and can be viewed at ." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:57 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:57 +# ordered list +msgid "3. If you wish to change the template used for workshop websites," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:58 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:58 +msgid " please work in .\n" +" The home page of that repository explains how to set up workshop websites,\n" +" while the extra pages in \n" +" provide more background on our design choices." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:63 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:63 +# ordered list +msgid "4. If you wish to change CSS style files, tools," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:64 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:64 +msgid " or HTML boilerplate for lessons or workshops stored in `_includes` or `_layouts`,\n" +" please work in ." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:67 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:67 +# header +msgid "## What to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:69 +msgid "There are many ways to contribute,\n" +"from writing new exercises and improving existing ones\n" +"to updating or filling in the documentation\n" +"and submitting [bug reports][issues]\n" +"about things that don't work, aren't clear, or are missing.\n" +"If you are looking for ideas, please see the 'Issues' tab for\n" +"a list of issues associated with this repository,\n" +"or you may also look at the issues for [Data Carpentry][dc-issues],\n" +"[Software Carpentry][swc-issues], and [Library Carpentry][lc-issues] projects." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:79 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:79 +msgid "Comments on issues and reviews of pull requests are just as welcome:\n" +"we are smarter together than we are on our own.\n" +"Reviews from novices and newcomers are particularly valuable:\n" +"it's easy for people who have been using these lessons for a while\n" +"to forget how impenetrable some of this material can be,\n" +"so fresh eyes are always welcome." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:86 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:86 +# header +msgid "## What *Not* to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:88 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:88 +msgid "Our lessons already contain more material than we can cover in a typical workshop,\n" +"so we are usually *not* looking for more concepts or tools to add to them.\n" +"As a rule,\n" +"if you want to introduce a new idea,\n" +"you must (a) estimate how long it will take to teach\n" +"and (b) explain what you would take out to make room for it.\n" +"The first encourages contributors to be honest about requirements;\n" +"the second, to think hard about priorities." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:97 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:97 +msgid "We are also not looking for exercises or other material that only run on one platform.\n" +"Our workshops typically contain a mixture of Windows, macOS, and Linux users;\n" +"in order to be usable,\n" +"our lessons must run equally well on all three." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:102 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:102 +# header +msgid "## Using GitHub" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:104 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:104 +msgid "If you choose to contribute via GitHub, you may want to look at\n" +"[How to Contribute to an Open Source Project on GitHub][how-contribute].\n" +"To manage changes, we follow [GitHub flow][github-flow].\n" +"Each lesson has two maintainers who review issues and pull requests or encourage others to do so.\n" +"The maintainers are community volunteers and have final say over what gets merged into the lesson.\n" +"To use the web interface for contributing to a lesson:" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:111 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:111 +# ordered list +msgid "1. Fork the originating repository to your GitHub profile." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:112 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:112 +# ordered list +msgid "2. Within your version of the forked repository, move to the `gh-pages` branch and" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:113 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:113 +msgid "create a new branch for each significant change being made.\n" +"3. Navigate to the file(s) you wish to change within the new branches and make revisions as required.\n" +"4. Commit all changed files within the appropriate branches.\n" +"5. Create individual pull requests from each of your changed branches\n" +"to the `gh-pages` branch within the originating repository.\n" +"6. If you receive feedback, make changes using your issue-specific branches of the forked\n" +"repository and the pull requests will update automatically.\n" +"7. Repeat as needed until all feedback has been addressed." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:122 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:122 +msgid "When starting work, please make sure your clone of the originating `gh-pages` branch is up-to-date\n" +"before creating your own revision-specific branch(es) from there.\n" +"Additionally, please only work from your newly-created branch(es) and *not*\n" +"your clone of the originating `gh-pages` branch.\n" +"Lastly, published copies of all the lessons are available in the `gh-pages` branch of the originating\n" +"repository for reference while revising." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:129 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:129 +# header +msgid "## Other Resources" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:131 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:131 +msgid "General discussion of [Software Carpentry][swc-site] and [Data Carpentry][dc-site]\n" +"happens on the [discussion mailing list][discuss-list],\n" +"which everyone is welcome to join.\n" +"You can also [reach us by email][email]." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:136 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:136 +msgid "[email]: mailto:admin@software-carpentry.org\n" +"[dc-issues]: https://github.com/issues?q=user%3Adatacarpentry\n" +"[dc-lessons]: http://datacarpentry.org/lessons/\n" +"[dc-site]: http://datacarpentry.org/\n" +"[discuss-list]: https://carpentries.topicbox.com/groups/discuss\n" +"[github]: https://github.com\n" +"[github-flow]: https://guides.github.com/introduction/flow/\n" +"[github-join]: https://github.com/join\n" +"[how-contribute]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github\n" +"[issues]: https://guides.github.com/features/issues/\n" +"[swc-issues]: https://github.com/issues?q=user%3Aswcarpentry\n" +"[swc-lessons]: https://software-carpentry.org/lessons/\n" +"[swc-site]: https://software-carpentry.org/\n" +"[c-site]: https://carpentries.org/\n" +"[lc-site]: https://librarycarpentry.org/\n" +"[lc-issues]: https://github.com/issues?q=user%3Alibrarycarpentry" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:49 +msgid " please work in ,\n" +" which can be viewed at ." +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:69 +msgid "There are many ways to contribute,\n" +"from writing new exercises and improving existing ones\n" +"to updating or filling in the documentation\n" +"and submitting [bug reports][issues]\n" +"about things that don't work, aren't clear, or are missing.\n" +"If you are looking for ideas, please see the 'Issues' tab for\n" +"a list of issues associated with this repository,\n" +"or you may also look at the issues for [Data Carpentry][dc-issues], \n" +"[Software Carpentry][swc-issues], and [Library Carpentry][lc-issues] projects." +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/02__LICENSE.md.pot b/transifex/python-novice-inflammation/pot/02__LICENSE.md.pot new file mode 100644 index 00000000..172f12a8 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/02__LICENSE.md.pot @@ -0,0 +1,159 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/LICENSE.md:1 +# Front Matter +msgid "---\n" +"layout: page\n" +"title: \"Licenses\"\n" +"root: .\n" +"---" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:6 +# header +msgid "## Instructional Material" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:8 +msgid "All Software Carpentry, Data Carpentry, and Library Carpentry instructional material is\n" +"made available under the [Creative Commons Attribution\n" +"license][cc-by-human]. The following is a human-readable summary of\n" +"(and not a substitute for) the [full legal text of the CC BY 4.0\n" +"license][cc-by-legal]." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:14 +msgid "You are free:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:16 +# unordered list +msgid "* to **Share**---copy and redistribute the material in any medium or format" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:17 +# unordered list +msgid "* to **Adapt**---remix, transform, and build upon the material" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:19 +msgid "for any purpose, even commercially." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:21 +msgid "The licensor cannot revoke these freedoms as long as you follow the\n" +"license terms." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:24 +msgid "Under the following terms:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:26 +# unordered list +msgid "* **Attribution**---You must give appropriate credit (mentioning that" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:27 +msgid " your work is derived from work that is Copyright © Software\n" +" Carpentry and, where practical, linking to\n" +" http://software-carpentry.org/), provide a [link to the\n" +" license][cc-by-human], and indicate if changes were made. You may do\n" +" so in any reasonable manner, but not in any way that suggests the\n" +" licensor endorses you or your use." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:34 +msgid "**No additional restrictions**---You may not apply legal terms or\n" +"technological measures that legally restrict others from doing\n" +"anything the license permits. With the understanding that:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:38 +msgid "Notices:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:40 +# unordered list +msgid "* You do not have to comply with the license for elements of the" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:41 +msgid " material in the public domain or where your use is permitted by an\n" +" applicable exception or limitation.\n" +"* No warranties are given. The license may not give you all of the\n" +" permissions necessary for your intended use. For example, other\n" +" rights such as publicity, privacy, or moral rights may limit how you\n" +" use the material." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:48 +# header +msgid "## Software" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:50 +msgid "Except where otherwise noted, the example programs and other software\n" +"provided by Software Carpentry and Data Carpentry are made available under the\n" +"[OSI][osi]-approved\n" +"[MIT license][mit-license]." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:55 +msgid "Permission is hereby granted, free of charge, to any person obtaining\n" +"a copy of this software and associated documentation files (the\n" +"\"Software\"), to deal in the Software without restriction, including\n" +"without limitation the rights to use, copy, modify, merge, publish,\n" +"distribute, sublicense, and/or sell copies of the Software, and to\n" +"permit persons to whom the Software is furnished to do so, subject to\n" +"the following conditions:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:63 +msgid "The above copyright notice and this permission notice shall be\n" +"included in all copies or substantial portions of the Software." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:66 +msgid "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n" +"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n" +"MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n" +"NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n" +"LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n" +"OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n" +"WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:74 +# header +msgid "## Trademark" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:76 +msgid "\"Software Carpentry\" and \"Data Carpentry\" and their respective logos\n" +"are registered trademarks of [Community Initiatives][CI]." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:79 +msgid "[cc-by-human]: https://creativecommons.org/licenses/by/4.0/\n" +"[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode\n" +"[mit-license]: https://opensource.org/licenses/mit-license.html\n" +"[ci]: http://communityin.org/\n" +"[osi]: https://opensource.org" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/03__README.md.pot b/transifex/python-novice-inflammation/pot/03__README.md.pot new file mode 100644 index 00000000..47a5d090 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/03__README.md.pot @@ -0,0 +1,472 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/README.md:1 +# header +msgid "# Programming with Python" +msgstr "" + +#: python-novice-inflammation/README.md:3 +msgid "[![GitHub release][shields_release]][swc_py_releases]\n" +"[![Create a Slack Account with us][create_slack_svg]][slack_heroku_invite]\n" +"[![Slack Status][slack_channel_status]][slack_channel_url]" +msgstr "" + +#: python-novice-inflammation/README.md:7 +msgid "An introduction to Python for non-programmers using inflammation data." +msgstr "" + +#: python-novice-inflammation/README.md:9 +# header +msgid "## About the Lesson" +msgstr "" + +#: python-novice-inflammation/README.md:11 +msgid "This lesson teaches novice programmers to write modular code to perform data analysis\n" +"using Python. The emphasis, however, is on teaching language-agnostic principles of\n" +"programming such as automation with loops and encapsulation with functions,\n" +"see [Best Practices for Scientific Computing][best-practices] and\n" +"[Good enough practices in scientific computing][good-practices] to learn more." +msgstr "" + +#: python-novice-inflammation/README.md:17 +msgid "The example used in this lesson analyses a set of 12 files with simulated inflammation\n" +"data collected from a trial for a new treatment for arthritis. Learners are shown\n" +"how it is better to automate analysis using functions instead of repeating analysis\n" +"steps manually." +msgstr "" + +#: python-novice-inflammation/README.md:22 +msgid "The rendered version of the lesson is available at:\n" +"." +msgstr "" + +#: python-novice-inflammation/README.md:25 +msgid "This lesson is also available in [R][R] and [MATLAB][MATLAB]." +msgstr "" + +#: python-novice-inflammation/README.md:27 +# header +msgid "## Episodes" +msgstr "" + +#: python-novice-inflammation/README.md:29 +msgid "| # | Episode | Time | Question(s) |\n" +"|--:|:---------|:----:|:------------|\n" +"| 1 | [Python Fundamentals][episode01] | 30 | What basic data types can I work with in Python?
How can I create a new variable in Python?
Can I change the value associated with a variable after I create it? |\n" +"| 2 | [Analyzing Patient Data][episode02] | 60 | How can I process tabular data files in Python? |\n" +"| 3 | [Visualizing Tabular Data][episode03] | 50 | How can I visualize tabular data in Python?
How can I group several plots together? |\n" +"| 4 | [Repeating Actions with Loops][episode04] | 30 | How can I do the same operations on many different values? |\n" +"| 5 | [Storing Multiple Values in Lists][episode05] | 30 | How can I store many values together? |\n" +"| 6 | [Analyzing Data from Multiple Files][episode06] | 20 | How can I do the same operations on many different files? |\n" +"| 7 | [Making Choices][episode07] | 30 | How can my programs do different things based on data values? |\n" +"| 8 | [Creating Functions][episode08] | 30 | How can I define new functions?
What’s the difference between defining and calling a function?
What happens when I call a function? |\n" +"| 9 | [Errors and Exceptions][episode09] | 30 | How does Python report errors?
How can I handle errors in Python programs? |\n" +"|10 | [Defensive Programming][episode10] | 30 | How can I make my programs more reliable? |\n" +"|11 | [Debugging][episode11] | 30 | How can I debug my program? |\n" +"|12 | [Command-Line Programs][episode12] | 30 | How can I write Python programs that will work like Unix command-line tools? |" +msgstr "" + +#: python-novice-inflammation/README.md:45 +#: python-novice-inflammation/bin/boilerplate/README.md:7 +# header +msgid "## Contributing" +msgstr "" + +#: python-novice-inflammation/README.md:46 +msgid "[![Travis Build Status][travis_svg]][travis_url]" +msgstr "" + +#: python-novice-inflammation/README.md:48 +msgid "We welcome all contributions to improve the lesson!\n" +"Maintainers will do their best to help you if you have any questions, concerns,\n" +"or experience any difficulties along the way." +msgstr "" + +#: python-novice-inflammation/README.md:52 +msgid "We'd like to ask you to familiarize yourself with our [Contribution Guide](CONTRIBUTING.md)\n" +"and have a look at the [more detailed guidelines][lesson-example] on proper formatting,\n" +"ways to render the lesson locally, and even how to write new episodes!" +msgstr "" + +#: python-novice-inflammation/README.md:56 +# header +msgid "## Maintainers" +msgstr "" + +#: python-novice-inflammation/README.md:58 +msgid "Lesson maintainers are [Trevor Bekolay][trevor_bekolay], [Maxim Belkin][maxim_belkin],\n" +"[Anne Fouilloux][anne_fouilloux], [Lauren Ko][lauren_ko], [Valentina Staneva][valentina_staneva], and [creator][swc_history] of Software Carpentry:\n" +"[Greg Wilson][greg_wilson]." +msgstr "" + +#: python-novice-inflammation/README.md:62 +#: python-novice-inflammation/bin/boilerplate/README.md:32 +# header +msgid "## Authors" +msgstr "" + +#: python-novice-inflammation/README.md:63 +msgid "A list of contributors to the lesson can be found in [AUTHORS](AUTHORS)." +msgstr "" + +#: python-novice-inflammation/README.md:65 +# header +msgid "## License" +msgstr "" + +#: python-novice-inflammation/README.md:66 +msgid "Instructional material from this lesson is made available under the\n" +"[Creative Commons Attribution][cc-by-human] ([CC BY 4.0][cc-by-legal]) license. Except where\n" +"otherwise noted, example programs and software included as part of this lesson are made available\n" +"under the [MIT license][mit-license]. For more information, see [LICENSE.md](LICENSE.md)." +msgstr "" + +#: python-novice-inflammation/README.md:71 +#: python-novice-inflammation/bin/boilerplate/README.md:36 +# header +msgid "## Citation" +msgstr "" + +#: python-novice-inflammation/README.md:72 +msgid "To cite this lesson, please consult with [CITATION](CITATION)." +msgstr "" + +#: python-novice-inflammation/README.md:74 +# header +msgid "## About Software Carpentry" +msgstr "" + +#: python-novice-inflammation/README.md:76 +msgid "Software Carpentry is a volunteer project that teaches basic computing skills to researchers since\n" +"1998. More information about Software Carpentry can be found [here][swc-about]." +msgstr "" + +#: python-novice-inflammation/README.md:79 +# header +msgid "## About The Carpentries" +msgstr "" + +#: python-novice-inflammation/README.md:81 +msgid "The Carpentries is a fiscally sponsored project of [Community Initiatives][community-initiatives], a\n" +"registered 501(c)3 non-profit organisation based in California, USA. We are a global community\n" +"teaching foundational computational and data science skills to researchers in academia, industry and\n" +"government. More information can be found [here][cp-about]." +msgstr "" + +#: python-novice-inflammation/README.md:86 +msgid "[lesson-example]: https://carpentries.github.io/lesson-example\n" +"[anne_fouilloux]: https://github.com/annefou\n" +"[lauren_ko]: https://github.com/ldko\n" +"[maxim_belkin]: https://github.com/maxim-belkin\n" +"[mike_trizna]: https://github.com/MikeTrizna\n" +"[trevor_bekolay]: http://software-carpentry.org/team/#bekolay_trevor\n" +"[valentina_staneva]: http://software-carpentry.org/team/#staneva_valentina\n" +"[greg_wilson]: https://github.com/gvwilson\n" +"[swc_history]: https://software-carpentry.org/scf/history/\n" +"[best-practices]: http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.1001745\n" +"[good-practices]: http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1005510\n" +"[R]: https://github.com/swcarpentry/r-novice-inflammation\n" +"[MATLAB]: https://github.com/swcarpentry/matlab-novice-inflammation\n" +"[shields_release]: https://img.shields.io/github/release/swcarpentry/python-novice-inflammation.svg\n" +"[swc_py_releases]: https://github.com/swcarpentry/python-novice-inflammation/releases\n" +"[create_slack_svg]: https://img.shields.io/badge/Create_Slack_Account-The_Carpentries-071159.svg\n" +"[slack_heroku_invite]: https://swc-slack-invite.herokuapp.com\n" +"[slack_channel_status]: https://img.shields.io/badge/Slack_Channel-swc--py--inflammation-E01563.svg\n" +"[slack_channel_url]: https://swcarpentry.slack.com/messages/C9Y0L6MF0\n" +"[travis_svg]: https://travis-ci.org/swcarpentry/python-novice-inflammation.svg?branch=gh-pages\n" +"[travis_url]: https://travis-ci.org/swcarpentry/python-novice-inflammation\n" +"[episode01]: https://swcarpentry.github.io/python-novice-inflammation/01-intro/index.html\n" +"[episode02]: https://swcarpentry.github.io/python-novice-inflammation/02-numpy/index.html\n" +"[episode03]: https://swcarpentry.github.io/python-novice-inflammation/03-matplotlib/index.html\n" +"[episode04]: https://swcarpentry.github.io/python-novice-inflammation/04-loop/index.html\n" +"[episode05]: https://swcarpentry.github.io/python-novice-inflammation/05-lists/index.html\n" +"[episode06]: https://swcarpentry.github.io/python-novice-inflammation/06-files/index.html\n" +"[episode07]: https://swcarpentry.github.io/python-novice-inflammation/07-cond/index.html\n" +"[episode08]: https://swcarpentry.github.io/python-novice-inflammation/08-func/index.html\n" +"[episode09]: https://swcarpentry.github.io/python-novice-inflammation/09-errors/index.html\n" +"[episode10]: https://swcarpentry.github.io/python-novice-inflammation/10-defensive/index.html\n" +"[episode11]: https://swcarpentry.github.io/python-novice-inflammation/11-debugging/index.html\n" +"[episode12]: https://swcarpentry.github.io/python-novice-inflammation/12-cmdline/index.html\n" +"[community-initiatives]: https://communityin.org\n" +"[cp-about]: https://carpentries.org/about\n" +"[swc-about]: https://software-carpentry.org/about/\n" +"[mit-license]: https://opensource.org/licenses/mit-license.html\n" +"[cc-by-human]: https://creativecommons.org/licenses/by/4.0/\n" +"[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:1 +# header +msgid "# FIXME Lesson title" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:3 +msgid "[![Create a Slack Account with us](https://img.shields.io/badge/Create_Slack_Account-The_Carpentries-071159.svg)](https://swc-slack-invite.herokuapp.com/)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:5 +msgid "This repository generates the corresponding lesson website from [The Carpentries](https://carpentries.org/) repertoire of lessons. " +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:9 +msgid "We welcome all contributions to improve the lesson! Maintainers will do their best to help you if you have any\n" +"questions, concerns, or experience any difficulties along the way." +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:12 +msgid "We'd like to ask you to familiarize yourself with our [Contribution Guide](CONTRIBUTING.md) and have a look at\n" +"the [more detailed guidelines][lesson-example] on proper formatting, ways to render the lesson locally, and even\n" +"how to write new episodes." +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:16 +msgid "Please see the current list of [issues][FIXME] for ideas for contributing to this\n" +"repository. For making your contribution, we use the GitHub flow, which is\n" +"nicely explained in the chapter [Contributing to a Project](http://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project) in Pro Git\n" +"by Scott Chacon.\n" +"Look for the tag ![good_first_issue](https://img.shields.io/badge/-good%20first%20issue-gold.svg). This indicates that the maintainers will welcome a pull request fixing this issue. " +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:23 +# header +msgid "## Maintainer(s)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:25 +msgid "Current maintainers of this lesson are " +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:27 +#: python-novice-inflammation/bin/boilerplate/README.md:28 +#: python-novice-inflammation/bin/boilerplate/README.md:29 +# unordered list +msgid "* FIXME" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:34 +msgid "A list of contributors to the lesson can be found in [AUTHORS](AUTHORS)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:38 +msgid "To cite this lesson, please consult with [CITATION](CITATION)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:40 +msgid "[lesson-example]: https://carpentries.github.io/lesson-example" +msgstr "" + +#: python-novice-inflammation/fig/README.md:1 +# header +msgid "## Why SVG?" +msgstr "" + +#: python-novice-inflammation/fig/README.md:3 +msgid "The SVG format (for \"Scalable Vector Graphics\") has a number of advantages over standard \"raster\"\n" +"graphics formats such as JPG, PNG, etc. Most importantly, as the name suggests, SVG images scale\n" +"up or down without loss of visual clarity: they look equally good on a phone, a laptop computer,\n" +"or a 70-inch screen, and don't blur when scaled up." +msgstr "" + +#: python-novice-inflammation/fig/README.md:8 +msgid "Additionally, SVG is a text-based format (based on XML, if you care). As text files, SVG images\n" +"are thus human-readable (a trained eye makes sense of them) and maintainable: easy to manually\n" +"edit, and efficiently tracked by version control systems (VCSs) such as Git. By contrast, images\n" +"in raster formats, being binary files, are versioned as whole objects -- the slightest change\n" +"results in updating the entire file." +msgstr "" + +#: python-novice-inflammation/fig/README.md:14 +# header +msgid "## Working with SVG figures" +msgstr "" + +#: python-novice-inflammation/fig/README.md:16 +msgid "A number of tools can create or modify SVG images -- pick one you like!" +msgstr "" + +#: python-novice-inflammation/fig/README.md:18 +msgid "Many tools, however, delete comments they don't deem useful, and insert extra information useful\n" +"to them, but unneeded for us, and unsuited to our highly collaborative lesson development process." +msgstr "" + +#: python-novice-inflammation/fig/README.md:21 +msgid "Below are some tips on keeping the information we need and removing the information we don't need\n" +"in SVG files before submitting them to our repository." +msgstr "" + +#: python-novice-inflammation/fig/README.md:24 +# header +msgid "### Comments" +msgstr "" + +#: python-novice-inflammation/fig/README.md:26 +msgid "Before modifying an existing figure, inspect it with a text editor, making note of all comments,\n" +"which in SVG files are enclosed between ``. Be sure to add them back in (with\n" +"appropriate changes) after editing the figure, if the tool you use removed them." +msgstr "" + +#: python-novice-inflammation/fig/README.md:30 +# header +msgid "### General tips" +msgstr "" + +#: python-novice-inflammation/fig/README.md:32 +msgid "When using any SVG editor, please make sure to:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:34 +# unordered list +msgid "- save the figure as \"plain\" SVG rather than editor-specific SVG." +msgstr "" + +#: python-novice-inflammation/fig/README.md:35 +# unordered list +msgid "- not group elements (``) unless necessary or beneficial" +msgstr "" + +#: python-novice-inflammation/fig/README.md:36 +# unordered list +msgid "- not embed other SVG images using ``" +msgstr "" + +#: python-novice-inflammation/fig/README.md:38 +msgid "After editing the figure, clean it up using the command-line tool\n" +"[svgcleaner](https://github.com/RazrFalcon/svgcleaner), by running the following in a terminal\n" +"(replace `SVG_figure` by the name of the SVG figure):" +msgstr "" + +#: python-novice-inflammation/fig/README.md:42 +# code block +msgid "```\n" +"svgcleaner \\\n" +" --indent 2 \\\n" +" --ungroup-defs no \\\n" +" --multipass \\\n" +" --coordinates-precision 1 \\\n" +" --properties-precision 1 \\\n" +" --paths-coordinates-precision 1 \\\n" +" SVG_figure.svg SVG_figure_svgcleaner.svg\n" +"```" +msgstr "" + +#: python-novice-inflammation/fig/README.md:53 +msgid "Alternatively, you can also use [svgo](https://github.com/svg/svgo) or\n" +"[scour](https://www.codedread.com/scour/)." +msgstr "" + +#: python-novice-inflammation/fig/README.md:56 +msgid "**The following steps are optional.**" +msgstr "" + +#: python-novice-inflammation/fig/README.md:58 +msgid "Open the file produced by `svgcleaner` (`SVG_figure_svgcleaner.svg` in the example above)\n" +"and follow these steps:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:61 +# unordered list +msgid "- Wrap lines to be under 100 characters (or less) if possible. For example, change this:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:63 +# code block +msgid " ```xml\n" +" 65.0\n" +" ```" +msgstr "" + +#: python-novice-inflammation/fig/README.md:66 +msgid " to this:\n" +" ```xml\n" +" 65.0\n" +" ```" +msgstr "" + +#: python-novice-inflammation/fig/README.md:75 +# unordered list +msgid "- Comment on the nature of each element, using ``, where applicable and when" +msgstr "" + +#: python-novice-inflammation/fig/README.md:76 +msgid " feasible. For example:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:78 +# code block +msgid " ```xml\n" +" \n" +" " +msgstr "" + +#: python-novice-inflammation/fig/README.md:97 +# header +msgid "## Not an SVG expert" +msgstr "" + +#: python-novice-inflammation/fig/README.md:99 +msgid "Don't let the above guidelines discourage you. If needed, submit your contribution \"as is\" and\n" +"mention which steps you skipped. Maintainers will happily help -- make sure they can commit to the\n" +"branch you use to submit your contribution." +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/04__01-intro.md.pot b/transifex/python-novice-inflammation/pot/04__01-intro.md.pot new file mode 100644 index 00000000..9c5ab0cb --- /dev/null +++ b/transifex/python-novice-inflammation/pot/04__01-intro.md.pot @@ -0,0 +1,779 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/01-intro.md:1 +# Front Matter +msgid "---\n" +"title: Python Fundamentals\n" +"teaching: 20\n" +"exercises: 10\n" +"questions:\n" +"- \"What basic data types can I work with in Python?\"\n" +"- \"How can I create a new variable in Python?\"\n" +"- \"Can I change the value associated with a variable after I create it?\"\n" +"objectives:\n" +"- \"Assign values to variables.\"\n" +"keypoints:\n" +"- \"Basic data types in Python include integers, strings, and floating-point numbers.\"\n" +"- \"Use `variable = value` to assign a value to a variable in order to record it in memory.\"\n" +"- \"Variables are created on demand whenever a value is assigned to them.\"\n" +"- \"Use `print(something)` to display the value of `something`.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:18 +# header +msgid "## Variables" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:20 +msgid "Any Python interpreter can be used as a calculator:\n" +"~~~\n" +"3 + 5 * 4\n" +"~~~\n" +"{: .language-python}\n" +"~~~\n" +"23\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:28 +#: python-novice-inflammation/_episodes/01-intro.md:87 +#: python-novice-inflammation/_episodes/01-intro.md:98 +#: python-novice-inflammation/_episodes/01-intro.md:110 +#: python-novice-inflammation/_episodes/01-intro.md:121 +#: python-novice-inflammation/_episodes/01-intro.md:135 +#: python-novice-inflammation/_episodes/02-numpy.md:67 +#: python-novice-inflammation/_episodes/02-numpy.md:135 +#: python-novice-inflammation/_episodes/02-numpy.md:150 +#: python-novice-inflammation/_episodes/02-numpy.md:191 +#: python-novice-inflammation/_episodes/02-numpy.md:214 +#: python-novice-inflammation/_episodes/02-numpy.md:224 +#: python-novice-inflammation/_episodes/02-numpy.md:276 +#: python-novice-inflammation/_episodes/02-numpy.md:296 +#: python-novice-inflammation/_episodes/02-numpy.md:317 +#: python-novice-inflammation/_episodes/02-numpy.md:333 +#: python-novice-inflammation/_episodes/02-numpy.md:382 +#: python-novice-inflammation/_episodes/02-numpy.md:415 +#: python-novice-inflammation/_episodes/02-numpy.md:433 +#: python-novice-inflammation/_episodes/02-numpy.md:463 +#: python-novice-inflammation/_episodes/02-numpy.md:476 +#: python-novice-inflammation/_episodes/02-numpy.md:495 +#: python-novice-inflammation/_episodes/04-loop.md:55 +#: python-novice-inflammation/_episodes/04-loop.md:86 +#: python-novice-inflammation/_episodes/04-loop.md:116 +#: python-novice-inflammation/_episodes/04-loop.md:136 +#: python-novice-inflammation/_episodes/04-loop.md:203 +#: python-novice-inflammation/_episodes/04-loop.md:241 +#: python-novice-inflammation/_episodes/04-loop.md:254 +#: python-novice-inflammation/_episodes/05-lists.md:38 +#: python-novice-inflammation/_episodes/05-lists.md:55 +#: python-novice-inflammation/_episodes/05-lists.md:75 +#: python-novice-inflammation/_episodes/05-lists.md:94 +#: python-novice-inflammation/_episodes/05-lists.md:244 +#: python-novice-inflammation/_episodes/05-lists.md:257 +#: python-novice-inflammation/_episodes/05-lists.md:268 +#: python-novice-inflammation/_episodes/05-lists.md:288 +#: python-novice-inflammation/_episodes/05-lists.md:307 +#: python-novice-inflammation/_episodes/05-lists.md:363 +#: python-novice-inflammation/_episodes/05-lists.md:498 +#: python-novice-inflammation/_episodes/05-lists.md:519 +#: python-novice-inflammation/_episodes/06-files.md:40 +#: python-novice-inflammation/_episodes/06-files.md:86 +#: python-novice-inflammation/_episodes/06-files.md:93 +#: python-novice-inflammation/_episodes/06-files.md:100 +#: python-novice-inflammation/_episodes/07-cond.md:46 +#: python-novice-inflammation/_episodes/07-cond.md:75 +#: python-novice-inflammation/_episodes/07-cond.md:96 +#: python-novice-inflammation/_episodes/07-cond.md:128 +#: python-novice-inflammation/_episodes/07-cond.md:141 +#: python-novice-inflammation/_episodes/07-cond.md:217 +#: python-novice-inflammation/_episodes/07-cond.md:237 +#: python-novice-inflammation/_episodes/08-func.md:93 +#: python-novice-inflammation/_episodes/08-func.md:115 +#: python-novice-inflammation/_episodes/08-func.md:136 +#: python-novice-inflammation/_episodes/08-func.md:248 +#: python-novice-inflammation/_episodes/08-func.md:268 +#: python-novice-inflammation/_episodes/08-func.md:287 +#: python-novice-inflammation/_episodes/08-func.md:304 +#: python-novice-inflammation/_episodes/08-func.md:319 +#: python-novice-inflammation/_episodes/08-func.md:366 +#: python-novice-inflammation/_episodes/08-func.md:401 +#: python-novice-inflammation/_episodes/08-func.md:425 +#: python-novice-inflammation/_episodes/08-func.md:483 +#: python-novice-inflammation/_episodes/08-func.md:506 +#: python-novice-inflammation/_episodes/08-func.md:536 +#: python-novice-inflammation/_episodes/08-func.md:553 +#: python-novice-inflammation/_episodes/08-func.md:576 +#: python-novice-inflammation/_episodes/08-func.md:585 +#: python-novice-inflammation/_episodes/09-errors.md:349 +#: python-novice-inflammation/_episodes/10-defensive.md:205 +#: python-novice-inflammation/_episodes/12-cmdline.md:51 +#: python-novice-inflammation/_episodes/12-cmdline.md:106 +#: python-novice-inflammation/_episodes/12-cmdline.md:131 +#: python-novice-inflammation/_episodes/12-cmdline.md:145 +#: python-novice-inflammation/_episodes/12-cmdline.md:279 +#: python-novice-inflammation/_episodes/12-cmdline.md:338 +#: python-novice-inflammation/_episodes/12-cmdline.md:349 +#: python-novice-inflammation/_episodes/12-cmdline.md:360 +#: python-novice-inflammation/_episodes/12-cmdline.md:423 +#: python-novice-inflammation/_episodes/12-cmdline.md:488 +#: python-novice-inflammation/_episodes/12-cmdline.md:586 +#: python-novice-inflammation/_episodes/12-cmdline.md:660 +#: python-novice-inflammation/_extras/additional_material.md:26 +#: python-novice-inflammation/_extras/additional_material.md:41 +#: python-novice-inflammation/_extras/additional_material.md:51 +#: python-novice-inflammation/_extras/additional_material.md:64 +#: python-novice-inflammation/_extras/additional_material.md:74 +#: python-novice-inflammation/_extras/additional_material.md:84 +#: python-novice-inflammation/_extras/additional_material.md:93 +#: python-novice-inflammation/_extras/additional_material.md:106 +#: python-novice-inflammation/_extras/additional_material.md:116 +#: python-novice-inflammation/_extras/discuss.md:109 +#: python-novice-inflammation/_extras/discuss.md:131 +#: python-novice-inflammation/_extras/discuss.md:145 +#: python-novice-inflammation/_extras/discuss.md:221 +#: python-novice-inflammation/_extras/discuss.md:252 +#: python-novice-inflammation/_extras/discuss.md:265 +# SC/DC Template label +msgid "{: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:30 +msgid "This is great but not very interesting.\n" +"To do anything useful with data, we need to assign its value to a _variable_.\n" +"In Python, we can [assign]({{ page.root }}/reference.html#assign) a value to a\n" +"[variable]({{ page.root }}/reference.html#variable), using the equals sign `=`.\n" +"For example, to assign value `60` to a variable `weight_kg`, we would execute:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:36 +# code block +msgid "~~~\n" +"weight_kg = 60\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:39 +#: python-novice-inflammation/_episodes/01-intro.md:67 +#: python-novice-inflammation/_episodes/01-intro.md:74 +#: python-novice-inflammation/_episodes/01-intro.md:82 +#: python-novice-inflammation/_episodes/01-intro.md:105 +#: python-novice-inflammation/_episodes/01-intro.md:130 +#: python-novice-inflammation/_episodes/02-numpy.md:43 +#: python-novice-inflammation/_episodes/02-numpy.md:56 +#: python-novice-inflammation/_episodes/02-numpy.md:115 +#: python-novice-inflammation/_episodes/02-numpy.md:124 +#: python-novice-inflammation/_episodes/02-numpy.md:145 +#: python-novice-inflammation/_episodes/02-numpy.md:186 +#: python-novice-inflammation/_episodes/02-numpy.md:209 +#: python-novice-inflammation/_episodes/02-numpy.md:219 +#: python-novice-inflammation/_episodes/02-numpy.md:268 +#: python-novice-inflammation/_episodes/02-numpy.md:287 +#: python-novice-inflammation/_episodes/02-numpy.md:328 +#: python-novice-inflammation/_episodes/02-numpy.md:372 +#: python-novice-inflammation/_episodes/02-numpy.md:410 +#: python-novice-inflammation/_episodes/02-numpy.md:428 +#: python-novice-inflammation/_episodes/02-numpy.md:451 +#: python-novice-inflammation/_episodes/02-numpy.md:471 +#: python-novice-inflammation/_episodes/02-numpy.md:485 +#: python-novice-inflammation/_episodes/03-matplotlib.md:28 +#: python-novice-inflammation/_episodes/03-matplotlib.md:40 +#: python-novice-inflammation/_episodes/03-matplotlib.md:53 +#: python-novice-inflammation/_episodes/03-matplotlib.md:61 +#: python-novice-inflammation/_episodes/03-matplotlib.md:109 +#: python-novice-inflammation/_episodes/04-loop.md:33 +#: python-novice-inflammation/_episodes/04-loop.md:47 +#: python-novice-inflammation/_episodes/04-loop.md:79 +#: python-novice-inflammation/_episodes/04-loop.md:108 +#: python-novice-inflammation/_episodes/04-loop.md:126 +#: python-novice-inflammation/_episodes/04-loop.md:146 +#: python-novice-inflammation/_episodes/04-loop.md:198 +#: python-novice-inflammation/_episodes/04-loop.md:233 +#: python-novice-inflammation/_episodes/04-loop.md:249 +#: python-novice-inflammation/_episodes/05-lists.md:33 +#: python-novice-inflammation/_episodes/05-lists.md:48 +#: python-novice-inflammation/_episodes/05-lists.md:67 +#: python-novice-inflammation/_episodes/05-lists.md:88 +#: python-novice-inflammation/_episodes/05-lists.md:102 +#: python-novice-inflammation/_episodes/05-lists.md:239 +#: python-novice-inflammation/_episodes/05-lists.md:251 +#: python-novice-inflammation/_episodes/05-lists.md:263 +#: python-novice-inflammation/_episodes/05-lists.md:282 +#: python-novice-inflammation/_episodes/05-lists.md:301 +#: python-novice-inflammation/_episodes/05-lists.md:355 +#: python-novice-inflammation/_episodes/05-lists.md:492 +#: python-novice-inflammation/_episodes/05-lists.md:512 +#: python-novice-inflammation/_episodes/06-files.md:21 +#: python-novice-inflammation/_episodes/06-files.md:33 +#: python-novice-inflammation/_episodes/06-files.md:81 +#: python-novice-inflammation/_episodes/07-cond.md:40 +#: python-novice-inflammation/_episodes/07-cond.md:69 +#: python-novice-inflammation/_episodes/07-cond.md:91 +#: python-novice-inflammation/_episodes/07-cond.md:123 +#: python-novice-inflammation/_episodes/07-cond.md:136 +#: python-novice-inflammation/_episodes/07-cond.md:160 +#: python-novice-inflammation/_episodes/07-cond.md:177 +#: python-novice-inflammation/_episodes/07-cond.md:187 +#: python-novice-inflammation/_episodes/07-cond.md:195 +#: python-novice-inflammation/_episodes/07-cond.md:212 +#: python-novice-inflammation/_episodes/07-cond.md:232 +#: python-novice-inflammation/_episodes/08-func.md:55 +#: python-novice-inflammation/_episodes/08-func.md:78 +#: python-novice-inflammation/_episodes/08-func.md:110 +#: python-novice-inflammation/_episodes/08-func.md:131 +#: python-novice-inflammation/_episodes/08-func.md:174 +#: python-novice-inflammation/_episodes/08-func.md:191 +#: python-novice-inflammation/_episodes/08-func.md:210 +#: python-novice-inflammation/_episodes/08-func.md:229 +#: python-novice-inflammation/_episodes/08-func.md:242 +#: python-novice-inflammation/_episodes/08-func.md:257 +#: python-novice-inflammation/_episodes/08-func.md:281 +#: python-novice-inflammation/_episodes/08-func.md:299 +#: python-novice-inflammation/_episodes/08-func.md:314 +#: python-novice-inflammation/_episodes/08-func.md:338 +#: python-novice-inflammation/_episodes/08-func.md:350 +#: python-novice-inflammation/_episodes/08-func.md:358 +#: python-novice-inflammation/_episodes/08-func.md:387 +#: python-novice-inflammation/_episodes/08-func.md:414 +#: python-novice-inflammation/_episodes/08-func.md:432 +#: python-novice-inflammation/_episodes/08-func.md:466 +#: python-novice-inflammation/_episodes/08-func.md:477 +#: python-novice-inflammation/_episodes/08-func.md:496 +#: python-novice-inflammation/_episodes/08-func.md:526 +#: python-novice-inflammation/_episodes/08-func.md:547 +#: python-novice-inflammation/_episodes/08-func.md:561 +#: python-novice-inflammation/_episodes/08-func.md:594 +#: python-novice-inflammation/_episodes/08-func.md:633 +#: python-novice-inflammation/_episodes/09-errors.md:57 +#: python-novice-inflammation/_episodes/09-errors.md:156 +#: python-novice-inflammation/_episodes/09-errors.md:181 +#: python-novice-inflammation/_episodes/09-errors.md:235 +#: python-novice-inflammation/_episodes/09-errors.md:261 +#: python-novice-inflammation/_episodes/09-errors.md:282 +#: python-novice-inflammation/_episodes/09-errors.md:309 +#: python-novice-inflammation/_episodes/09-errors.md:342 +#: python-novice-inflammation/_episodes/09-errors.md:381 +#: python-novice-inflammation/_episodes/09-errors.md:416 +#: python-novice-inflammation/_episodes/10-defensive.md:78 +#: python-novice-inflammation/_episodes/10-defensive.md:144 +#: python-novice-inflammation/_episodes/10-defensive.md:151 +#: python-novice-inflammation/_episodes/10-defensive.md:173 +#: python-novice-inflammation/_episodes/10-defensive.md:200 +#: python-novice-inflammation/_episodes/10-defensive.md:213 +#: python-novice-inflammation/_episodes/10-defensive.md:313 +#: python-novice-inflammation/_episodes/10-defensive.md:344 +#: python-novice-inflammation/_episodes/10-defensive.md:360 +#: python-novice-inflammation/_episodes/10-defensive.md:387 +#: python-novice-inflammation/_episodes/10-defensive.md:414 +#: python-novice-inflammation/_episodes/10-defensive.md:433 +#: python-novice-inflammation/_episodes/10-defensive.md:440 +#: python-novice-inflammation/_episodes/12-cmdline.md:89 +#: python-novice-inflammation/_episodes/12-cmdline.md:114 +#: python-novice-inflammation/_episodes/12-cmdline.md:173 +#: python-novice-inflammation/_episodes/12-cmdline.md:208 +#: python-novice-inflammation/_episodes/12-cmdline.md:408 +#: python-novice-inflammation/_episodes/12-cmdline.md:475 +#: python-novice-inflammation/_episodes/12-cmdline.md:542 +#: python-novice-inflammation/_episodes/12-cmdline.md:569 +#: python-novice-inflammation/_episodes/12-cmdline.md:647 +#: python-novice-inflammation/_extras/additional_material.md:18 +#: python-novice-inflammation/_extras/additional_material.md:59 +#: python-novice-inflammation/_extras/additional_material.md:69 +#: python-novice-inflammation/_extras/additional_material.md:79 +#: python-novice-inflammation/_extras/additional_material.md:88 +#: python-novice-inflammation/_extras/additional_material.md:101 +#: python-novice-inflammation/_extras/additional_material.md:111 +#: python-novice-inflammation/_extras/discuss.md:30 +#: python-novice-inflammation/_extras/discuss.md:94 +#: python-novice-inflammation/_extras/discuss.md:126 +#: python-novice-inflammation/_extras/discuss.md:140 +#: python-novice-inflammation/_extras/discuss.md:187 +#: python-novice-inflammation/_extras/discuss.md:202 +#: python-novice-inflammation/_extras/discuss.md:214 +#: python-novice-inflammation/_extras/discuss.md:246 +#: python-novice-inflammation/_extras/discuss.md:260 +#: python-novice-inflammation/_extras/discuss.md:276 +#: python-novice-inflammation/_extras/discuss.md:312 +#: python-novice-inflammation/_extras/discuss.md:325 +#: python-novice-inflammation/_extras/discuss.md:342 +msgid "{: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:41 +msgid "From now on, whenever we use `weight_kg`, Python will substitute the value we assigned to\n" +"it. In layman's terms, **a variable is a name for a value**." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:44 +msgid "In Python, variable names:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:46 +# unordered list +msgid " - can include letters, digits, and underscores" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:47 +# unordered list +msgid " - cannot start with a digit" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:48 +# unordered list +msgid " - are [case sensitive]({{ page.root }}/reference.html#case-sensitive)." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:50 +msgid "This means that, for example:\n" +" - `weight0` is a valid variable name, whereas `0weight` is not\n" +" - `weight` and `Weight` are different variables" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:54 +# header +msgid "## Types of data" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:55 +msgid "Python knows various types of data. Three common ones are:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:57 +# unordered list +msgid "* integer numbers" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:58 +# unordered list +msgid "* floating point numbers, and" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:59 +# unordered list +msgid "* strings." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:61 +msgid "In the example above, variable `weight_kg` has an integer value of `60`.\n" +"To create a variable with a floating point value, we can execute:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:64 +# code block +msgid "~~~\n" +"weight_kg = 60.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:69 +msgid "And to create a string, we add single or double quotes around some text, for example:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:71 +# code block +msgid "~~~\n" +"weight_kg_text = 'weight in kilograms:'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:76 +# header +msgid "## Using Variables in Python" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:77 +msgid "To display the value of a variable to the screen in Python, we can use the `print` function:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:79 +# code block +msgid "~~~\n" +"print(weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:84 +#: python-novice-inflammation/_episodes/01-intro.md:118 +# code block +msgid "~~~\n" +"60.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:89 +msgid "We can display multiple things at once using only one `print` command:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:91 +# code block +msgid "~~~\n" +"print(weight_kg_text, weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:94 +msgid "{: .language-python}\n" +"~~~\n" +"weight in kilograms: 60.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:100 +msgid "Moreover, we can do arithmetic with variables right inside the `print` function:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:102 +# code block +msgid "~~~\n" +"print('weight in pounds:', 2.2 * weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:107 +# code block +msgid "~~~\n" +"weight in pounds: 132.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:112 +msgid "The above command, however, did not change the value of `weight_kg`:\n" +"~~~\n" +"print(weight_kg)\n" +"~~~\n" +"{: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:123 +msgid "To change the value of the `weight_kg` variable, we have to\n" +"**assign** `weight_kg` a new value using the equals `=` sign:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:126 +# code block +msgid "~~~\n" +"weight_kg = 65.0\n" +"print('weight in kilograms is now:', weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:132 +# code block +msgid "~~~\n" +"weight in kilograms is now: 65.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:137 +# blockquote, which can be cascaded +msgid "> ## Variables as Sticky Notes" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:138 +msgid ">\n" +"> A variable is analogous to a sticky note with a name written on it:\n" +"> assigning a value to a variable is like putting that sticky note on a particular value.\n" +">\n" +"> ![Value of 65.0 with weight_kg label stuck on it](../fig/python-sticky-note-variables-01.svg)\n" +">\n" +"> This means that assigning a value to one variable does **not** change\n" +"> values of other variables.\n" +"> For example, let's store the subject's weight in pounds in its own variable:\n" +">\n" +"> ~~~\n" +"> # There are 2.2 pounds per kilogram\n" +"> weight_lb = 2.2 * weight_kg\n" +"> print(weight_kg_text, weight_kg, 'and in pounds:', weight_lb)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> weight in kilograms: 65.0 and in pounds: 143.0\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:158 +#: python-novice-inflammation/_episodes/01-intro.md:173 +#: python-novice-inflammation/_episodes/02-numpy.md:175 +#: python-novice-inflammation/_episodes/02-numpy.md:354 +#: python-novice-inflammation/_episodes/02-numpy.md:516 +#: python-novice-inflammation/_episodes/02-numpy.md:632 +#: python-novice-inflammation/_episodes/02-numpy.md:706 +#: python-novice-inflammation/_episodes/02-numpy.md:725 +#: python-novice-inflammation/_episodes/04-loop.md:184 +#: python-novice-inflammation/_episodes/04-loop.md:336 +#: python-novice-inflammation/_episodes/04-loop.md:401 +#: python-novice-inflammation/_episodes/05-lists.md:144 +#: python-novice-inflammation/_episodes/05-lists.md:160 +#: python-novice-inflammation/_episodes/05-lists.md:198 +#: python-novice-inflammation/_episodes/05-lists.md:208 +#: python-novice-inflammation/_episodes/05-lists.md:218 +#: python-novice-inflammation/_episodes/05-lists.md:383 +#: python-novice-inflammation/_episodes/05-lists.md:424 +#: python-novice-inflammation/_episodes/05-lists.md:441 +#: python-novice-inflammation/_episodes/05-lists.md:460 +#: python-novice-inflammation/_episodes/07-cond.md:378 +#: python-novice-inflammation/_episodes/07-cond.md:427 +#: python-novice-inflammation/_episodes/07-cond.md:436 +#: python-novice-inflammation/_episodes/08-func.md:666 +#: python-novice-inflammation/_episodes/08-func.md:729 +#: python-novice-inflammation/_episodes/10-defensive.md:504 +#: python-novice-inflammation/_episodes/10-defensive.md:514 +#: python-novice-inflammation/_episodes/11-debugging.md:279 +#: python-novice-inflammation/_episodes/12-cmdline.md:679 +#: python-novice-inflammation/_episodes/12-cmdline.md:689 +#: python-novice-inflammation/_episodes/12-cmdline.md:744 +#: python-novice-inflammation/_episodes/12-cmdline.md:1015 +#: python-novice-inflammation/_episodes/12-cmdline.md:1025 +# SC/DC Template label +msgid "> {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:159 +msgid ">\n" +"> ![Value of 65.0 with weight_kg label stuck on it, and value of 143.0 with weight_lb label stuck on it](../fig/python-sticky-note-variables-02.svg)\n" +">\n" +"> Let's now change `weight_kg`:\n" +">\n" +"> ~~~\n" +"> weight_kg = 100.0\n" +"> print('weight in kilograms is now:', weight_kg, 'and weight in pounds is still:', weight_lb)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> weight in kilograms is now: 100.0 and weight in pounds is still: 143.0\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:174 +msgid ">\n" +"> ![Value of 100.0 with label weight_kg stuck on it, and value of 143.0 with label weight_lb stuck on it](../fig/python-sticky-note-variables-03.svg)\n" +">\n" +"> Since `weight_lb` doesn't \"remember\" where its value comes from,\n" +"> it is not updated when we change `weight_kg`." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:179 +#: python-novice-inflammation/_episodes/02-numpy.md:103 +#: python-novice-inflammation/_episodes/02-numpy.md:179 +#: python-novice-inflammation/_episodes/02-numpy.md:256 +#: python-novice-inflammation/_episodes/02-numpy.md:359 +#: python-novice-inflammation/_episodes/02-numpy.md:397 +#: python-novice-inflammation/_episodes/04-loop.md:188 +#: python-novice-inflammation/_episodes/05-lists.md:166 +#: python-novice-inflammation/_episodes/05-lists.md:222 +#: python-novice-inflammation/_episodes/05-lists.md:230 +#: python-novice-inflammation/_episodes/07-cond.md:112 +#: python-novice-inflammation/_episodes/07-cond.md:147 +#: python-novice-inflammation/_episodes/09-errors.md:104 +#: python-novice-inflammation/_episodes/09-errors.md:224 +#: python-novice-inflammation/_episodes/11-debugging.md:202 +#: python-novice-inflammation/_episodes/12-cmdline.md:32 +#: python-novice-inflammation/_episodes/12-cmdline.md:307 +#: python-novice-inflammation/_episodes/12-cmdline.md:321 +#: python-novice-inflammation/_episodes/12-cmdline.md:437 +# SC/DC Template label +msgid "{: .callout}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:182 +# blockquote, which can be cascaded +msgid "> ## Check Your Understanding" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:183 +msgid ">\n" +"> What values do the variables `mass` and `age` have after each of the following statements?\n" +"> Test your answer by executing the lines.\n" +">\n" +"> ~~~\n" +"> mass = 47.5\n" +"> age = 122\n" +"> mass = mass * 2.0\n" +"> age = age - 20\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > `mass` holds a value of 47.5, `age` does not exist\n" +"> > `mass` still holds a value of 47.5, `age` holds a value of 122\n" +"> > `mass` now has a value of 95.0, `age`'s value is still 122\n" +"> > `mass` still has a value of 95.0, `age` now holds 102\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:203 +#: python-novice-inflammation/_episodes/01-intro.md:222 +#: python-novice-inflammation/_episodes/02-numpy.md:529 +#: python-novice-inflammation/_episodes/02-numpy.md:540 +#: python-novice-inflammation/_episodes/02-numpy.md:548 +#: python-novice-inflammation/_episodes/02-numpy.md:573 +#: python-novice-inflammation/_episodes/02-numpy.md:590 +#: python-novice-inflammation/_episodes/02-numpy.md:661 +#: python-novice-inflammation/_episodes/02-numpy.md:682 +#: python-novice-inflammation/_episodes/02-numpy.md:743 +#: python-novice-inflammation/_episodes/02-numpy.md:752 +#: python-novice-inflammation/_episodes/02-numpy.md:799 +#: python-novice-inflammation/_episodes/03-matplotlib.md:137 +#: python-novice-inflammation/_episodes/03-matplotlib.md:158 +#: python-novice-inflammation/_episodes/03-matplotlib.md:169 +#: python-novice-inflammation/_episodes/03-matplotlib.md:210 +#: python-novice-inflammation/_episodes/03-matplotlib.md:224 +#: python-novice-inflammation/_episodes/03-matplotlib.md:261 +#: python-novice-inflammation/_episodes/04-loop.md:292 +#: python-novice-inflammation/_episodes/04-loop.md:319 +#: python-novice-inflammation/_episodes/04-loop.md:349 +#: python-novice-inflammation/_episodes/04-loop.md:368 +#: python-novice-inflammation/_episodes/04-loop.md:413 +#: python-novice-inflammation/_episodes/05-lists.md:333 +#: python-novice-inflammation/_episodes/05-lists.md:400 +#: python-novice-inflammation/_episodes/05-lists.md:479 +#: python-novice-inflammation/_episodes/05-lists.md:559 +#: python-novice-inflammation/_episodes/06-files.md:136 +#: python-novice-inflammation/_episodes/07-cond.md:271 +#: python-novice-inflammation/_episodes/07-cond.md:335 +#: python-novice-inflammation/_episodes/07-cond.md:348 +#: python-novice-inflammation/_episodes/07-cond.md:358 +#: python-novice-inflammation/_episodes/07-cond.md:404 +#: python-novice-inflammation/_episodes/07-cond.md:480 +#: python-novice-inflammation/_episodes/07-cond.md:503 +#: python-novice-inflammation/_episodes/08-func.md:674 +#: python-novice-inflammation/_episodes/08-func.md:709 +#: python-novice-inflammation/_episodes/08-func.md:737 +#: python-novice-inflammation/_episodes/08-func.md:756 +#: python-novice-inflammation/_episodes/08-func.md:781 +#: python-novice-inflammation/_episodes/08-func.md:802 +#: python-novice-inflammation/_episodes/08-func.md:836 +#: python-novice-inflammation/_episodes/08-func.md:885 +#: python-novice-inflammation/_episodes/08-func.md:921 +#: python-novice-inflammation/_episodes/09-errors.md:499 +#: python-novice-inflammation/_episodes/09-errors.md:529 +#: python-novice-inflammation/_episodes/09-errors.md:571 +#: python-novice-inflammation/_episodes/09-errors.md:595 +#: python-novice-inflammation/_episodes/10-defensive.md:488 +#: python-novice-inflammation/_episodes/10-defensive.md:539 +#: python-novice-inflammation/_episodes/11-debugging.md:287 +#: python-novice-inflammation/_episodes/12-cmdline.md:724 +#: python-novice-inflammation/_episodes/12-cmdline.md:764 +#: python-novice-inflammation/_episodes/12-cmdline.md:808 +#: python-novice-inflammation/_episodes/12-cmdline.md:859 +#: python-novice-inflammation/_episodes/12-cmdline.md:905 +#: python-novice-inflammation/_episodes/12-cmdline.md:949 +#: python-novice-inflammation/_episodes/12-cmdline.md:998 +#: python-novice-inflammation/_extras/extra_exercises.md:48 +#: python-novice-inflammation/_extras/extra_exercises.md:72 +#: python-novice-inflammation/setup.md:71 +#: python-novice-inflammation/setup.md:82 +#: python-novice-inflammation/setup.md:91 +#: python-novice-inflammation/setup.md:98 +# SC/DC Template label +msgid "> {: .solution}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:204 +#: python-novice-inflammation/_episodes/01-intro.md:223 +#: python-novice-inflammation/_episodes/02-numpy.md:574 +#: python-novice-inflammation/_episodes/02-numpy.md:591 +#: python-novice-inflammation/_episodes/02-numpy.md:683 +#: python-novice-inflammation/_episodes/02-numpy.md:800 +#: python-novice-inflammation/_episodes/03-matplotlib.md:170 +#: python-novice-inflammation/_episodes/03-matplotlib.md:211 +#: python-novice-inflammation/_episodes/03-matplotlib.md:225 +#: python-novice-inflammation/_episodes/03-matplotlib.md:262 +#: python-novice-inflammation/_episodes/04-loop.md:293 +#: python-novice-inflammation/_episodes/04-loop.md:320 +#: python-novice-inflammation/_episodes/04-loop.md:350 +#: python-novice-inflammation/_episodes/04-loop.md:369 +#: python-novice-inflammation/_episodes/04-loop.md:414 +#: python-novice-inflammation/_episodes/05-lists.md:334 +#: python-novice-inflammation/_episodes/05-lists.md:401 +#: python-novice-inflammation/_episodes/05-lists.md:480 +#: python-novice-inflammation/_episodes/05-lists.md:560 +#: python-novice-inflammation/_episodes/06-files.md:137 +#: python-novice-inflammation/_episodes/06-files.md:192 +#: python-novice-inflammation/_episodes/07-cond.md:272 +#: python-novice-inflammation/_episodes/07-cond.md:296 +#: python-novice-inflammation/_episodes/07-cond.md:315 +#: python-novice-inflammation/_episodes/07-cond.md:359 +#: python-novice-inflammation/_episodes/07-cond.md:405 +#: python-novice-inflammation/_episodes/07-cond.md:481 +#: python-novice-inflammation/_episodes/07-cond.md:504 +#: python-novice-inflammation/_episodes/08-func.md:675 +#: python-novice-inflammation/_episodes/08-func.md:710 +#: python-novice-inflammation/_episodes/08-func.md:738 +#: python-novice-inflammation/_episodes/08-func.md:757 +#: python-novice-inflammation/_episodes/08-func.md:782 +#: python-novice-inflammation/_episodes/08-func.md:803 +#: python-novice-inflammation/_episodes/08-func.md:837 +#: python-novice-inflammation/_episodes/08-func.md:886 +#: python-novice-inflammation/_episodes/08-func.md:922 +#: python-novice-inflammation/_episodes/08-func.md:930 +#: python-novice-inflammation/_episodes/09-errors.md:500 +#: python-novice-inflammation/_episodes/09-errors.md:530 +#: python-novice-inflammation/_episodes/09-errors.md:572 +#: python-novice-inflammation/_episodes/09-errors.md:596 +#: python-novice-inflammation/_episodes/10-defensive.md:489 +#: python-novice-inflammation/_episodes/10-defensive.md:540 +#: python-novice-inflammation/_episodes/11-debugging.md:247 +#: python-novice-inflammation/_episodes/11-debugging.md:288 +#: python-novice-inflammation/_episodes/12-cmdline.md:725 +#: python-novice-inflammation/_episodes/12-cmdline.md:765 +#: python-novice-inflammation/_episodes/12-cmdline.md:809 +#: python-novice-inflammation/_episodes/12-cmdline.md:860 +#: python-novice-inflammation/_episodes/12-cmdline.md:906 +#: python-novice-inflammation/_episodes/12-cmdline.md:950 +#: python-novice-inflammation/_episodes/12-cmdline.md:999 +#: python-novice-inflammation/_episodes/12-cmdline.md:1026 +#: python-novice-inflammation/_extras/discuss.md:176 +#: python-novice-inflammation/_extras/discuss.md:357 +#: python-novice-inflammation/_extras/discuss.md:362 +#: python-novice-inflammation/_extras/discuss.md:369 +#: python-novice-inflammation/_extras/discuss.md:375 +#: python-novice-inflammation/_extras/discuss.md:381 +#: python-novice-inflammation/_extras/extra_exercises.md:49 +#: python-novice-inflammation/_extras/extra_exercises.md:73 +# SC/DC Template label +msgid "{: .challenge}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:206 +# blockquote, which can be cascaded +msgid "> ## Sorting Out References" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:207 +msgid ">\n" +"> What does the following program print out?\n" +">\n" +"> ~~~\n" +"> first, second = 'Grace', 'Hopper'\n" +"> third, fourth = second, first\n" +"> print(third, fourth)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > Hopper Grace\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/05__02-numpy.md.pot b/transifex/python-novice-inflammation/pot/05__02-numpy.md.pot new file mode 100644 index 00000000..36db12e6 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/05__02-numpy.md.pot @@ -0,0 +1,1037 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/02-numpy.md:1 +# Front Matter +msgid "---\n" +"title: Analyzing Patient Data\n" +"teaching: 40\n" +"exercises: 20\n" +"questions:\n" +"- \"How can I process tabular data files in Python?\"\n" +"objectives:\n" +"- \"Explain what a library is and what libraries are used for.\"\n" +"- \"Import a Python library and use the functions it contains.\"\n" +"- \"Read tabular data from a file into a program.\"\n" +"- \"Select individual values and subsections from data.\"\n" +"- \"Perform operations on arrays of data.\"\n" +"keypoints:\n" +"- \"Import a library into a program using `import libraryname`.\"\n" +"- \"Use the `numpy` library to work with arrays in Python.\"\n" +"- \"The expression `array.shape` gives the shape of an array.\"\n" +"- \"Use `array[x, y]` to select a single element from a 2D array.\"\n" +"- \"Array indices start at 0, not 1.\"\n" +"- \"Use `low:high` to specify a `slice` that includes the indices from `low` to `high-1`.\"\n" +"- \"Use `# some kind of explanation` to add comments to programs.\"\n" +"- \"Use `numpy.mean(array)`, `numpy.max(array)`, and `numpy.min(array)` to calculate simple statistics.\"\n" +"- \"Use `numpy.mean(array, axis=0)` or `numpy.mean(array, axis=1)` to calculate statistics across the specified axis.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:25 +msgid "Words are useful, but what's more useful are the sentences and stories we build with them.\n" +"Similarly, while a lot of powerful, general tools are built into Python,\n" +"specialized tools built up from these basic units live in\n" +"[libraries]({{ page.root }}/reference.html#library)\n" +"that can be called upon when needed." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:31 +# header +msgid "## Loading data into Python" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:33 +msgid "To begin processing inflammation data, we need to load it into Python.\n" +"We can do that using a library called\n" +"[NumPy](http://docs.scipy.org/doc/numpy/ \"NumPy Documentation\"), which stands for Numerical Python.\n" +"In general, you should use this library when you want to do fancy things with lots of numbers,\n" +"especially if you have matrices or arrays. To tell Python that we'd like to start using NumPy,\n" +"we need to [import]({{ page.root }}/reference.html#import) it:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:40 +#: python-novice-inflammation/_episodes/07-cond.md:157 +# code block +msgid "~~~\n" +"import numpy\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:45 +msgid "Importing a library is like getting a piece of lab equipment out of a storage locker and setting it\n" +"up on the bench. Libraries provide additional functionality to the basic Python package, much like\n" +"a new piece of equipment adds functionality to a lab space. Just like in the lab, importing too\n" +"many libraries can sometimes complicate and slow down your programs - so we only import what we\n" +"need for each program." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:51 +msgid "Once we've imported the library, we can ask the library to read our data file for us:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:53 +# code block +msgid "~~~\n" +"numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:58 +#: python-novice-inflammation/_episodes/08-func.md:416 +# code block +msgid "~~~\n" +"array([[ 0., 0., 1., ..., 3., 0., 0.],\n" +" [ 0., 1., 2., ..., 1., 0., 1.],\n" +" [ 0., 1., 1., ..., 2., 1., 1.],\n" +" ...,\n" +" [ 0., 1., 1., ..., 1., 1., 1.],\n" +" [ 0., 0., 0., ..., 0., 2., 0.],\n" +" [ 0., 0., 1., ..., 1., 1., 0.]])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:69 +msgid "The expression `numpy.loadtxt(...)` is a [function call]({{ page.root }}/reference.html#function-call)\n" +"that asks Python to run the [function]({{ page.root }}/reference.html#function) `loadtxt` which\n" +"belongs to the `numpy` library. This [dotted notation]({{ page.root }}/reference.html#dotted-notation)\n" +"is used everywhere in Python: the thing that appears before the dot contains the thing that\n" +"appears after." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:75 +msgid "As an example, John Smith is the John that belongs to the Smith family.\n" +"We could use the dot notation to write his name `smith.john`,\n" +"just as `loadtxt` is a function that belongs to the `numpy` library." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:79 +msgid "`numpy.loadtxt` has two [parameters]({{ page.root }}/reference.html#parameter): the name of the file\n" +"we want to read and the [delimiter]({{ page.root }}/reference.html#delimiter) that separates values on\n" +"a line. These both need to be character strings (or [strings]({{ page.root }}/reference.html#string)\n" +"for short), so we put them in quotes." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:84 +msgid "Since we haven't told it to do anything else with the function's output,\n" +"the [notebook]({{ page.root }}/reference.html#notebook) displays it.\n" +"In this case,\n" +"that output is the data we just loaded.\n" +"By default,\n" +"only a few rows and columns are shown\n" +"(with `...` to omit elements when displaying big arrays).\n" +"Note that, to save space when displaying NumPy arrays, Python does not show us trailing zeros, so `1.0` becomes `1.`." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:93 +# blockquote, which can be cascaded +msgid "> ## Importing libraries with shortcuts" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:94 +msgid ">\n" +"> In this lesson we use the `import numpy` [syntax]({{ page.root }}/reference.html#syntax) to import NumPy.\n" +"> However, shortcuts such as `import numpy as np` are frequently used. Importing NumPy this way means that after the\n" +"> inital import, rather than writing `numpy.loadtxt(...)`, you can now write `np.loadtxt(...)`. Some\n" +"> people prefer this as it is quicker to type and results in shorter lines of code - especially for libraries\n" +"> with long names! You will frequently see Python code online using a NumPy function with `np`, and it's\n" +"> because they've used this shortcut. It makes no difference which approach you choose to take, but you must be\n" +"> consistent as if you use `import numpy as np` then `numpy.loadtxt(...)` will not work, and you must use `np.loadtxt(...)`\n" +"> instead. Because of this, when working with other people it is important you agree on how libraries are imported." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:105 +msgid "Our call to `numpy.loadtxt` read our file\n" +"but didn't save the data in memory.\n" +"To do that,\n" +"we need to assign the array to a variable. In a similar manner to how we assign a single\n" +"value to a variable, we can also assign an array of values to a variable using the same syntax.\n" +"Let's re-run `numpy.loadtxt` and save the returned data:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:112 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:117 +msgid "This statement doesn't produce any output because we've assigned the output to the variable `data`.\n" +"If we want to check that the data have been loaded,\n" +"we can print the variable's value:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:121 +# code block +msgid "~~~\n" +"print(data)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:126 +# code block +msgid "~~~\n" +"[[ 0. 0. 1. ..., 3. 0. 0.]\n" +" [ 0. 1. 2. ..., 1. 0. 1.]\n" +" [ 0. 1. 1. ..., 2. 1. 1.]\n" +" ...,\n" +" [ 0. 1. 1. ..., 1. 1. 1.]\n" +" [ 0. 0. 0. ..., 0. 2. 0.]\n" +" [ 0. 0. 1. ..., 1. 1. 0.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:137 +msgid "Now that the data are in memory,\n" +"we can manipulate them.\n" +"First,\n" +"let's ask what [type]({{ page.root }}/reference.html#type) of thing `data` refers to:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:142 +# code block +msgid "~~~\n" +"print(type(data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:147 +# code block +msgid "~~~\n" +"\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:152 +msgid "The output tells us that `data` currently refers to\n" +"an N-dimensional array, the functionality for which is provided by the NumPy library.\n" +"These data correspond to arthritis patients' inflammation.\n" +"The rows are the individual patients, and the columns\n" +"are their daily inflammation measurements." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:158 +# blockquote, which can be cascaded +msgid "> ## Data Type" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:159 +msgid ">\n" +"> A Numpy array contains one or more elements\n" +"> of the same type. The `type` function will only tell you that\n" +"> a variable is a NumPy array but won't tell you the type of\n" +"> thing inside the array.\n" +"> We can find out the type\n" +"> of the data contained in the NumPy array.\n" +">\n" +"> ~~~\n" +"> print(data.dtype)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> float64\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:176 +msgid ">\n" +"> This tells us that the NumPy array's elements are\n" +"> [floating-point numbers]({{ page.root }}/reference.html#floating-point number)." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:181 +msgid "With the following command, we can see the array's [shape]({{ page.root }}/reference.html#shape):" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:183 +# code block +msgid "~~~\n" +"print(data.shape)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:188 +# code block +msgid "~~~\n" +"(60, 40)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:193 +msgid "The output tells us that the `data` array variable contains 60 rows and 40 columns. When we\n" +"created the variable `data` to store our arthritis data, we did not only create the array; we also\n" +"created information about the array, called [members]({{ page.root }}/reference.html#member) or\n" +"attributes. This extra information describes `data` in the same way an adjective describes a noun.\n" +"`data.shape` is an attribute of `data` which describes the dimensions of `data`. We use the same\n" +"dotted notation for the attributes of variables that we use for the functions in libraries because\n" +"they have the same part-and-whole relationship." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:201 +msgid "If we want to get a single number from the array, we must provide an\n" +"[index]({{ page.root }}/reference.html#index) in square brackets after the variable name, just as we\n" +"do in math when referring to an element of a matrix. Our inflammation data has two dimensions, so\n" +"we will need to use two indices to refer to one specific value:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:206 +# code block +msgid "~~~\n" +"print('first value in data:', data[0, 0])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:211 +# code block +msgid "~~~\n" +"first value in data: 0.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:216 +# code block +msgid "~~~\n" +"print('middle value in data:', data[30, 20])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:221 +# code block +msgid "~~~\n" +"middle value in data: 13.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:226 +msgid "The expression `data[30, 20]` accesses the element at row 30, column 20. While this expression may\n" +"not surprise you,\n" +" `data[0, 0]` might.\n" +"Programming languages like Fortran, MATLAB and R start counting at 1\n" +"because that's what human beings have done for thousands of years.\n" +"Languages in the C family (including C++, Java, Perl, and Python) count from 0\n" +"because it represents an offset from the first value in the array (the second\n" +"value is offset by one index from the first value). This is closer to the way\n" +"that computers represent arrays (if you are interested in the historical\n" +"reasons behind counting indices from zero, you can read\n" +"[Mike Hoye's blog post](http://exple.tive.org/blarg/2013/10/22/citation-needed/)).\n" +"As a result,\n" +"if we have an M×N array in Python,\n" +"its indices go from 0 to M-1 on the first axis\n" +"and 0 to N-1 on the second.\n" +"It takes a bit of getting used to,\n" +"but one way to remember the rule is that\n" +"the index is how many steps we have to take from the start to get the item we want." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:245 +msgid "![Zero Index](../fig/python-zero-index.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:247 +# blockquote, which can be cascaded +msgid "> ## In the Corner" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:248 +msgid ">\n" +"> What may also surprise you is that when Python displays an array,\n" +"> it shows the element with index `[0, 0]` in the upper left corner\n" +"> rather than the lower left.\n" +"> This is consistent with the way mathematicians draw matrices\n" +"> but different from the Cartesian coordinates.\n" +"> The indices are (row, column) instead of (column, row) for the same reason,\n" +"> which can be confusing when plotting data." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:258 +# header +msgid "## Slicing data" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:259 +msgid "An index like `[30, 20]` selects a single element of an array,\n" +"but we can select whole sections as well.\n" +"For example,\n" +"we can select the first ten days (columns) of values\n" +"for the first four patients (rows) like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:265 +# code block +msgid "~~~\n" +"print(data[0:4, 0:10])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:270 +# code block +msgid "~~~\n" +"[[ 0. 0. 1. 3. 1. 2. 4. 7. 8. 3.]\n" +" [ 0. 1. 2. 1. 2. 1. 3. 2. 2. 6.]\n" +" [ 0. 1. 1. 3. 3. 2. 6. 2. 5. 9.]\n" +" [ 0. 0. 2. 0. 4. 2. 2. 1. 6. 7.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:278 +msgid "The [slice]({{ page.root }}/reference.html#slice) `0:4` means, \"Start at index 0 and go up to, but not\n" +"including, index 4\". Again, the up-to-but-not-including takes a bit of getting used to, but the\n" +"rule is that the difference between the upper and lower bounds is the number of values in the slice." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:282 +msgid "We don't have to start slices at 0:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:284 +# code block +msgid "~~~\n" +"print(data[5:10, 0:10])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:289 +# code block +msgid "~~~\n" +"[[ 0. 0. 1. 2. 2. 4. 2. 1. 6. 4.]\n" +" [ 0. 0. 2. 2. 4. 2. 2. 5. 5. 8.]\n" +" [ 0. 0. 1. 2. 3. 1. 2. 3. 5. 3.]\n" +" [ 0. 0. 0. 3. 1. 5. 6. 5. 5. 8.]\n" +" [ 0. 1. 1. 2. 1. 3. 5. 3. 5. 8.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:298 +msgid "We also don't have to include the upper and lower bound on the slice. If we don't include the lower\n" +"bound, Python uses 0 by default; if we don't include the upper, the slice runs to the end of the\n" +"axis, and if we don't include either (i.e., if we use ':' on its own), the slice includes\n" +"everything:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:303 +# code block +msgid "~~~\n" +"small = data[:3, 36:]\n" +"print('small is:')\n" +"print(small)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:308 +msgid "{: .language-python}\n" +"The above example selects rows 0 through 2 and columns 36 through to the end of the array." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:311 +# code block +msgid "~~~\n" +"small is:\n" +"[[ 2. 3. 0. 0.]\n" +" [ 1. 1. 0. 1.]\n" +" [ 2. 2. 1. 1.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:319 +# header +msgid "## Analyzing data" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:321 +msgid "NumPy has several useful functions that take an array as input to perform operations on its values.\n" +"If we want to find the average inflammation for all patients on\n" +"all days, for example, we can ask NumPy to compute `data`'s mean value:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:325 +# code block +msgid "~~~\n" +"print(numpy.mean(data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:330 +# code block +msgid "~~~\n" +"6.14875\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:335 +msgid "`mean` is a [function]({{ page.root }}/reference.html#function) that takes\n" +"an array as an [argument]({{ page.root }}/reference.html#argument)." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:338 +# blockquote, which can be cascaded +msgid "> ## Not All Functions Have Input" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:339 +msgid ">\n" +"> Generally, a function uses inputs to produce outputs.\n" +"> However, some functions produce outputs without\n" +"> needing any input. For example, checking the current time\n" +"> doesn't require any input.\n" +">\n" +"> ~~~\n" +"> import time\n" +"> print(time.ctime())\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Sat Mar 26 13:07:33 2016\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:355 +msgid ">\n" +"> For functions that don't take in any arguments,\n" +"> we still need parentheses (`()`)\n" +"> to tell Python to go and do something for us." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:361 +msgid "Let's use three other NumPy functions to get some descriptive values about the dataset.\n" +"We'll also use multiple assignment,\n" +"a convenient Python feature that will enable us to do this all in one line." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:365 +# code block +msgid "~~~\n" +"maxval, minval, stdval = numpy.max(data), numpy.min(data), numpy.std(data)\n" +"\n" +"print('maximum inflammation:', maxval)\n" +"print('minimum inflammation:', minval)\n" +"print('standard deviation:', stdval)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:374 +msgid "Here we've assigned the return value from `numpy.max(data)` to the variable `maxval`, the value\n" +"from `numpy.min(data)` to `minval`, and so on." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:377 +# code block +msgid "~~~\n" +"maximum inflammation: 20.0\n" +"minimum inflammation: 0.0\n" +"standard deviation: 4.61383319712\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:384 +# blockquote, which can be cascaded +msgid "> ## Mystery Functions in IPython" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:385 +msgid ">\n" +"> How did we know what functions NumPy has and how to use them?\n" +"> If you are working in IPython or in a Jupyter Notebook, there is an easy way to find out.\n" +"> If you type the name of something followed by a dot, then you can use tab completion\n" +"> (e.g. type `numpy.` and then press Tab)\n" +"> to see a list of all functions and attributes that you can use. After selecting one, you\n" +"> can also add a question mark (e.g. `numpy.cumprod?`), and IPython will return an\n" +"> explanation of the method! This is the same as doing `help(numpy.cumprod)`.\n" +"> Similarly, if you are using the \"plain vanilla\" Python interpreter, you can type `numpy.`\n" +"> and press the Tab key twice for a listing of what is available. You can then use the\n" +"> `help()` function to see an explanation of the function you're interested in,\n" +"> for example: `help(numpy.cumprod)`." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:399 +msgid "When analyzing data, though,\n" +"we often want to look at variations in statistical values,\n" +"such as the maximum inflammation per patient\n" +"or the average inflammation per day.\n" +"One way to do this is to create a new temporary array of the data we want,\n" +"then ask it to do the calculation:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:406 +# code block +msgid "~~~\n" +"patient_0 = data[0, :] # 0 on the first axis (rows), everything on the second (columns)\n" +"print('maximum inflammation for patient 0:', numpy.max(patient_0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:412 +# code block +msgid "~~~\n" +"maximum inflammation for patient 0: 18.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:417 +msgid "Everything in a line of code following the '#' symbol is a\n" +"[comment]({{ page.root }}/reference.html#comment) that is ignored by Python.\n" +"Comments allow programmers to leave explanatory notes for other\n" +"programmers or their future selves." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:422 +msgid "We don't actually need to store the row in a variable of its own.\n" +"Instead, we can combine the selection and the function call:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:425 +# code block +msgid "~~~\n" +"print('maximum inflammation for patient 2:', numpy.max(data[2, :]))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:430 +# code block +msgid "~~~\n" +"maximum inflammation for patient 2: 19.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:435 +msgid "What if we need the maximum inflammation for each patient over all days (as in the\n" +"next diagram on the left) or the average for each day (as in the\n" +"diagram on the right)? As the diagram below shows, we want to perform the\n" +"operation across an axis:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:440 +msgid "![Per-patient maximum inflammation is computed row-wise across all columns using numpy.max(data, axis=1).\n" +"Per-day average inflammation is computed column-wise across all rows using numpy.mean(data, axis=0).](../fig/python-operations-across-axes.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:443 +msgid "To support this functionality,\n" +"most array functions allow us to specify the axis we want to work on.\n" +"If we ask for the average across axis 0 (rows in our 2D example),\n" +"we get:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:448 +# code block +msgid "~~~\n" +"print(numpy.mean(data, axis=0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:453 +# code block +msgid "~~~\n" +"[ 0. 0.45 1.11666667 1.75 2.43333333 3.15\n" +" 3.8 3.88333333 5.23333333 5.51666667 5.95 5.9\n" +" 8.35 7.73333333 8.36666667 9.5 9.58333333\n" +" 10.63333333 11.56666667 12.35 13.25 11.96666667\n" +" 11.03333333 10.16666667 10. 8.66666667 9.15 7.25\n" +" 7.33333333 6.58333333 6.06666667 5.95 5.11666667 3.6\n" +" 3.3 3.56666667 2.48333333 1.5 1.13333333\n" +" 0.56666667]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:465 +msgid "As a quick check,\n" +"we can ask this array what its shape is:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:468 +# code block +msgid "~~~\n" +"print(numpy.mean(data, axis=0).shape)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:473 +# code block +msgid "~~~\n" +"(40,)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:478 +msgid "The expression `(40,)` tells us we have an N×1 vector,\n" +"so this is the average inflammation per day for all patients.\n" +"If we average across axis 1 (columns in our 2D example), we get:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:482 +# code block +msgid "~~~\n" +"print(numpy.mean(data, axis=1))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:487 +# code block +msgid "~~~\n" +"[ 5.45 5.425 6.1 5.9 5.55 6.225 5.975 6.65 6.625 6.525\n" +" 6.775 5.8 6.225 5.75 5.225 6.3 6.55 5.7 5.85 6.55\n" +" 5.775 5.825 6.175 6.1 5.8 6.425 6.05 6.025 6.175 6.55\n" +" 6.175 6.35 6.725 6.125 7.075 5.725 5.925 6.15 6.075 5.75\n" +" 5.975 5.725 6.3 5.9 6.75 5.925 7.225 6.15 5.95 6.275 5.7\n" +" 6.1 6.825 5.975 6.725 5.7 6.25 6.4 7.05 5.9 ]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:497 +msgid "which is the average inflammation per patient across all days." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:500 +# blockquote, which can be cascaded +msgid "> ## Slicing Strings" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:501 +msgid ">\n" +"> A section of an array is called a [slice]({{ page.root }}/reference.html#slice).\n" +"> We can take slices of character strings as well:\n" +">\n" +"> ~~~\n" +"> element = 'oxygen'\n" +"> print('first three characters:', element[0:3])\n" +"> print('last three characters:', element[3:6])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> first three characters: oxy\n" +"> last three characters: gen\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:517 +msgid ">\n" +"> What is the value of `element[:4]`?\n" +"> What about `element[4:]`?\n" +"> Or `element[:]`?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > oxyg\n" +"> > en\n" +"> > oxygen\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:530 +msgid ">\n" +"> What is `element[-1]`?\n" +"> What is `element[-2]`?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > n\n" +"> > e\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:541 +msgid ">\n" +"> Given those answers,\n" +"> explain what `element[1:-1]` does.\n" +">\n" +"> > ## Solution\n" +"> > Creates a substring from index 1 up to (not including) the final index,\n" +"> > effectively removing the first and last letters from 'oxygen'" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:549 +msgid ">\n" +"> How can we rewrite the slice for getting the last three characters of `element`,\n" +"> so that it works even if we assign a different string to `element`?\n" +"> Test your solution with the following strings: `carpentry`, `clone`, `hi`.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > element = 'oxygen'\n" +"> > print('last three characters:', element[-3:])\n" +"> > element = 'carpentry'\n" +"> > print('last three characters:', element[-3:])\n" +"> > element = 'clone'\n" +"> > print('last three characters:', element[-3:])\n" +"> > element = 'hi'\n" +"> > print('last three characters:', element[-3:])\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> > ~~~\n" +"> > last three characters: gen\n" +"> > last three characters: try\n" +"> > last three characters: one\n" +"> > last three characters: hi\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:576 +# blockquote, which can be cascaded +msgid "> ## Thin Slices" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:577 +msgid ">\n" +"> The expression `element[3:3]` produces an [empty string]({{ page.root }}/reference.html#empty-string),\n" +"> i.e., a string that contains no characters.\n" +"> If `data` holds our array of patient data,\n" +"> what does `data[3:3, 4:4]` produce?\n" +"> What about `data[3:3, :]`?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > array([], shape=(0, 0), dtype=float64)\n" +"> > array([], shape=(0, 40), dtype=float64)\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:593 +# blockquote, which can be cascaded +msgid "> ## Stacking Arrays" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:594 +msgid ">\n" +"> Arrays can be concatenated and stacked on top of one another,\n" +"> using NumPy's `vstack` and `hstack` functions for vertical and horizontal stacking, respectively.\n" +">\n" +"> ~~~\n" +"> import numpy\n" +">\n" +"> A = numpy.array([[1,2,3], [4,5,6], [7, 8, 9]])\n" +"> print('A = ')\n" +"> print(A)\n" +">\n" +"> B = numpy.hstack([A, A])\n" +"> print('B = ')\n" +"> print(B)\n" +">\n" +"> C = numpy.vstack([A, A])\n" +"> print('C = ')\n" +"> print(C)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> A =\n" +"> [[1 2 3]\n" +"> [4 5 6]\n" +"> [7 8 9]]\n" +"> B =\n" +"> [[1 2 3 1 2 3]\n" +"> [4 5 6 4 5 6]\n" +"> [7 8 9 7 8 9]]\n" +"> C =\n" +"> [[1 2 3]\n" +"> [4 5 6]\n" +"> [7 8 9]\n" +"> [1 2 3]\n" +"> [4 5 6]\n" +"> [7 8 9]]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:633 +msgid ">\n" +"> Write some additional code that slices the first and last columns of `A`,\n" +"> and stacks them into a 3x2 array.\n" +"> Make sure to `print` the results to verify your solution.\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > A 'gotcha' with array indexing is that singleton dimensions\n" +"> > are dropped by default. That means `A[:, 0]` is a one dimensional\n" +"> > array, which won't stack as desired. To preserve singleton dimensions,\n" +"> > the index itself can be a slice or array. For example, `A[:, :1]` returns\n" +"> > a two dimensional array with one singleton dimension (i.e. a column\n" +"> > vector).\n" +"> >\n" +"> > ~~~\n" +"> > D = numpy.hstack((A[:, :1], A[:, -1:]))\n" +"> > print('D = ')\n" +"> > print(D)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > D =\n" +"> > [[1 3]\n" +"> > [4 6]\n" +"> > [7 9]]\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:662 +msgid ">\n" +"> > ## Solution\n" +"> >\n" +"> > An alternative way to achieve the same result is to use Numpy's\n" +"> > delete function to remove the second column of A.\n" +"> >\n" +"> > ~~~\n" +"> > D = numpy.delete(A, 1, 1)\n" +"> > print('D = ')\n" +"> > print(D)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > D =\n" +"> > [[1 3]\n" +"> > [4 6]\n" +"> > [7 9]]\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:685 +# blockquote, which can be cascaded +msgid "> ## Change In Inflammation" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:686 +msgid ">\n" +"> The patient data is _longitudinal_ in the sense that each row represents a\n" +"> series of observations relating to one individual. This means that\n" +"> the change in inflammation over time is a meaningful concept.\n" +"> Let's find out how to calculate changes in the data contained in an array\n" +"> with NumPy.\n" +">\n" +"> The `numpy.diff()` function takes an array and returns the differences\n" +"> between two successive values. Let's use it to examine the changes\n" +"> each day across the first week of patient 3 from our inflammation dataset.\n" +">\n" +"> ~~~\n" +"> patient3_week1 = data[3, :7]\n" +"> print(patient3_week1)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> [0. 0. 2. 0. 4. 2. 2.]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:707 +msgid ">\n" +"> Calling `numpy.diff(patient3_week1)` would do the following calculations\n" +">\n" +"> ~~~\n" +"> [ 0 - 0, 2 - 0, 0 - 2, 4 - 0, 2 - 4, 2 - 2 ]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> and return the 6 difference values in a new array.\n" +">\n" +"> ~~~\n" +"> numpy.diff(patient3_week1)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> array([ 0., 2., -2., 4., -2., 0.])\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:726 +msgid ">\n" +"> Note that the array of differences is shorter by one element (length 6).\n" +">\n" +"> When calling `numpy.diff` with a multi-dimensional array, an `axis` argument may\n" +"> be passed to the function to specify which axis to process. When applying\n" +"> `numpy.diff` to our 2D inflammation array `data`, which axis would we specify?\n" +">\n" +"> > ## Solution\n" +"> > Since the row axis (0) is patients, it does not make sense to get the\n" +"> > difference between two arbitrary patients. The column axis (1) is in\n" +"> > days, so the difference is the change in inflammation -- a meaningful\n" +"> > concept.\n" +"> >\n" +"> > ~~~\n" +"> > numpy.diff(data, axis=1)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:744 +msgid ">\n" +"> If the shape of an individual data file is `(60, 40)` (60 rows and 40\n" +"> columns), what would the shape of the array be after you run the `diff()`\n" +"> function and why?\n" +">\n" +"> > ## Solution\n" +"> > The shape will be `(60, 39)` because there is one fewer difference between\n" +"> > columns than there are columns in the data." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:753 +msgid ">\n" +"> How would you find the largest change in inflammation for each patient? Does\n" +"> it matter if the change in inflammation is an increase or a decrease?\n" +">\n" +"> > ## Solution\n" +"> > By using the `numpy.max()` function after you apply the `numpy.diff()`\n" +"> > function, you will get the largest difference between days.\n" +"> >\n" +"> > ~~~\n" +"> > numpy.max(numpy.diff(data, axis=1), axis=1)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > array([ 7., 12., 11., 10., 11., 13., 10., 8., 10., 10., 7.,\n" +"> > 7., 13., 7., 10., 10., 8., 10., 9., 10., 13., 7.,\n" +"> > 12., 9., 12., 11., 10., 10., 7., 10., 11., 10., 8.,\n" +"> > 11., 12., 10., 9., 10., 13., 10., 7., 7., 10., 13.,\n" +"> > 12., 8., 8., 10., 10., 9., 8., 13., 10., 7., 10.,\n" +"> > 8., 12., 10., 7., 12.])\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > If inflammation values *decrease* along an axis, then the difference from\n" +"> > one element to the next will be negative. If\n" +"> > you are interested in the **magnitude** of the change and not the\n" +"> > direction, the `numpy.absolute()` function will provide that.\n" +"> >\n" +"> > Notice the difference if you get the largest _absolute_ difference\n" +"> > between readings.\n" +"> >\n" +"> > ~~~\n" +"> > numpy.max(numpy.absolute(numpy.diff(data, axis=1)), axis=1)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > array([ 12., 14., 11., 13., 11., 13., 10., 12., 10., 10., 10.,\n" +"> > 12., 13., 10., 11., 10., 12., 13., 9., 10., 13., 9.,\n" +"> > 12., 9., 12., 11., 10., 13., 9., 13., 11., 11., 8.,\n" +"> > 11., 12., 13., 9., 10., 13., 11., 11., 13., 11., 13.,\n" +"> > 13., 10., 9., 10., 10., 9., 9., 13., 10., 9., 10.,\n" +"> > 11., 13., 10., 10., 12.])\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/06__03-matplotlib.md.pot b/transifex/python-novice-inflammation/pot/06__03-matplotlib.md.pot new file mode 100644 index 00000000..da688c6e --- /dev/null +++ b/transifex/python-novice-inflammation/pot/06__03-matplotlib.md.pot @@ -0,0 +1,344 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:1 +# Front Matter +msgid "---\n" +"title: Visualizing Tabular Data\n" +"teaching: 30\n" +"exercises: 20\n" +"questions:\n" +"- \"How can I visualize tabular data in Python?\"\n" +"- \"How can I group several plots together?\"\n" +"objectives:\n" +"- \"Plot simple graphs from data.\"\n" +"- \"Group several graphs in a single figure.\"\n" +"keypoints:\n" +"- \"Use the `pyplot` module from the `matplotlib` library for creating simple visualizations.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:15 +# header +msgid "## Visualizing data" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:16 +msgid "The mathematician Richard Hamming once said, \"The purpose of computing is insight, not numbers,\" and\n" +"the best way to develop insight is often to visualize data. Visualization deserves an entire\n" +"lecture of its own, but we can explore a few features of Python's `matplotlib` library here. While\n" +"there is no official plotting library, `matplotlib` is the _de facto_ standard. First, we will\n" +"import the `pyplot` module from `matplotlib` and use two of its functions to create and display a\n" +"[heat map]({{ page.root }}/reference.html#heat-map) of our data:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:23 +# code block +msgid "~~~\n" +"import matplotlib.pyplot\n" +"image = matplotlib.pyplot.imshow(data)\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:30 +msgid "![Heat map representing the `data` variable. Each cell is colored by value along a color gradient from blue to yellow.](../fig/inflammation-01-imshow.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:32 +msgid "Blue pixels in this heat map represent low values, while yellow pixels represent high values. As we\n" +"can see, inflammation rises and falls over a 40-day period. Let's take a look at the average inflammation over time:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:35 +# code block +msgid "~~~\n" +"ave_inflammation = numpy.mean(data, axis=0)\n" +"ave_plot = matplotlib.pyplot.plot(ave_inflammation)\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:42 +msgid "![Average Inflammation Over Time](../fig/inflammation-01-average.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:44 +msgid "Here, we have put the average inflammation per day across all patients in the variable `ave_inflammation`, then\n" +"asked `matplotlib.pyplot` to create and display a line graph of those values. The result is a\n" +"roughly linear rise and fall, which is suspicious: we might instead expect a sharper rise and slower\n" +"fall. Let's have a look at two other statistics:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:49 +# code block +msgid "~~~\n" +"max_plot = matplotlib.pyplot.plot(numpy.max(data, axis=0))\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:55 +msgid "![Maximum Value Along The First Axis](../fig/inflammation-01-maximum.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:57 +# code block +msgid "~~~\n" +"min_plot = matplotlib.pyplot.plot(numpy.min(data, axis=0))\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:63 +msgid "![Minimum Value Along The First Axis](../fig/inflammation-01-minimum.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:65 +msgid "The maximum value rises and falls smoothly, while the minimum seems to be a step function. Neither\n" +"trend seems particularly likely, so either there's a mistake in our calculations or something is\n" +"wrong with our data. This insight would have been difficult to reach by examining the numbers\n" +"themselves without visualization tools." +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:70 +# header +msgid "### Grouping plots" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:71 +msgid "You can group similar plots in a single figure using subplots.\n" +"This script below uses a number of new commands. The function `matplotlib.pyplot.figure()`\n" +"creates a space into which we will place all of our plots. The parameter `figsize`\n" +"tells Python how big to make this space. Each subplot is placed into the figure using\n" +"its `add_subplot` [method]({{ page.root }}/reference.html#method). The `add_subplot` method takes 3\n" +"parameters. The first denotes how many total rows of subplots there are, the second parameter\n" +"refers to the total number of subplot columns, and the final parameter denotes which subplot\n" +"your variable is referencing (left-to-right, top-to-bottom). Each subplot is stored in a\n" +"different variable (`axes1`, `axes2`, `axes3`). Once a subplot is created, the axes can\n" +"be titled using the `set_xlabel()` command (or `set_ylabel()`).\n" +"Here are our three plots side by side:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:83 +# code block +msgid "~~~\n" +"import numpy\n" +"import matplotlib.pyplot\n" +"\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"\n" +"fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"\n" +"axes1 = fig.add_subplot(1, 3, 1)\n" +"axes2 = fig.add_subplot(1, 3, 2)\n" +"axes3 = fig.add_subplot(1, 3, 3)\n" +"\n" +"axes1.set_ylabel('average')\n" +"axes1.plot(numpy.mean(data, axis=0))\n" +"\n" +"axes2.set_ylabel('max')\n" +"axes2.plot(numpy.max(data, axis=0))\n" +"\n" +"axes3.set_ylabel('min')\n" +"axes3.plot(numpy.min(data, axis=0))\n" +"\n" +"fig.tight_layout()\n" +"\n" +"matplotlib.pyplot.savefig('inflammation.png')\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:111 +msgid "![The Previous Plots as Subplots](../fig/inflammation-01-group-plot.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:113 +msgid "The [call]({{ page.root }}/reference.html#function-call) to `loadtxt` reads our data,\n" +"and the rest of the program tells the plotting library\n" +"how large we want the figure to be,\n" +"that we're creating three subplots,\n" +"what to draw for each one,\n" +"and that we want a tight layout.\n" +"(If we leave out that call to `fig.tight_layout()`,\n" +"the graphs will actually be squeezed together more closely.)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:122 +msgid "The call to `savefig` stores the plot as a graphics file. This can be\n" +"a convenient way to store your plots for use in other documents, web\n" +"pages etc. The graphics format is automatically determined by\n" +"Matplotlib from the file name ending we specify; here PNG from\n" +"'inflammation.png'. Matplotlib supports many different graphics\n" +"formats, including SVG, PDF, and JPEG." +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:130 +# blockquote, which can be cascaded +msgid "> ## Plot Scaling" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:131 +msgid ">\n" +"> Why do all of our plots stop just short of the upper end of our graph?\n" +">\n" +"> > ## Solution\n" +"> > Because matplotlib normally sets x and y axes limits to the min and max of our data\n" +"> > (depending on data range)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:138 +msgid ">\n" +"> If we want to change this, we can use the `set_ylim(min, max)` method of each 'axes',\n" +"> for example:\n" +">\n" +"> ~~~\n" +"> axes3.set_ylim(0,6)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Update your plotting code to automatically set a more appropriate scale.\n" +"> (Hint: you can make use of the `max` and `min` methods to help.)\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # One method\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(data, axis=0))\n" +"> > axes3.set_ylim(0,6)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:159 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # A more automated approach\n" +"> > min_data = numpy.min(data, axis=0)\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(min_data)\n" +"> > axes3.set_ylim(numpy.min(min_data), numpy.max(min_data) * 1.1)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:172 +# blockquote, which can be cascaded +msgid "> ## Drawing Straight Lines" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:173 +msgid ">\n" +"> In the center and right subplots above, we expect all lines to look like step functions because\n" +"> non-integer value are not realistic for the minimum and maximum values. However, you can see\n" +"> that the lines are not always vertical or horizontal, and in particular the step function\n" +"> in the subplot on the right looks slanted. Why is this?\n" +">\n" +"> > ## Solution\n" +"> > Because matplotlib interpolates (draws a straight line) between the points.\n" +"> > One way to do avoid this is to use the Matplotlib `drawstyle` option:\n" +"> >\n" +"> > ~~~\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"> >\n" +"> > fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"> >\n" +"> > axes1 = fig.add_subplot(1, 3, 1)\n" +"> > axes2 = fig.add_subplot(1, 3, 2)\n" +"> > axes3 = fig.add_subplot(1, 3, 3)\n" +"> >\n" +"> > axes1.set_ylabel('average')\n" +"> > axes1.plot(numpy.mean(data, axis=0), drawstyle='steps-mid')\n" +"> >\n" +"> > axes2.set_ylabel('max')\n" +"> > axes2.plot(numpy.max(data, axis=0), drawstyle='steps-mid')\n" +"> >\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(data, axis=0), drawstyle='steps-mid')\n" +"> >\n" +"> > fig.tight_layout()\n" +"> >\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> ![Plot with step lines](../fig/inflammation-01-line-styles.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:213 +# blockquote, which can be cascaded +msgid "> ## Make Your Own Plot" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:214 +msgid ">\n" +"> Create a plot showing the standard deviation (`numpy.std`)\n" +"> of the inflammation data for each day across all patients.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > std_plot = matplotlib.pyplot.plot(numpy.std(data, axis=0))\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:227 +# blockquote, which can be cascaded +msgid "> ## Moving Plots Around" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:228 +msgid ">\n" +"> Modify the program to display the three plots on top of one another\n" +"> instead of side by side.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"> >\n" +"> > # change figsize (swap width and height)\n" +"> > fig = matplotlib.pyplot.figure(figsize=(3.0, 10.0))\n" +"> >\n" +"> > # change add_subplot (swap first two parameters)\n" +"> > axes1 = fig.add_subplot(3, 1, 1)\n" +"> > axes2 = fig.add_subplot(3, 1, 2)\n" +"> > axes3 = fig.add_subplot(3, 1, 3)\n" +"> >\n" +"> > axes1.set_ylabel('average')\n" +"> > axes1.plot(numpy.mean(data, axis=0))\n" +"> >\n" +"> > axes2.set_ylabel('max')\n" +"> > axes2.plot(numpy.max(data, axis=0))\n" +"> >\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(data, axis=0))\n" +"> >\n" +"> > fig.tight_layout()\n" +"> >\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/07__04-loop.md.pot b/transifex/python-novice-inflammation/pot/07__04-loop.md.pot new file mode 100644 index 00000000..0fde18a6 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/07__04-loop.md.pot @@ -0,0 +1,565 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/04-loop.md:1 +# Front Matter +msgid "---\n" +"title: Repeating Actions with Loops\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I do the same operations on many different values?\"\n" +"objectives:\n" +"- \"Explain what a `for` loop does.\"\n" +"- \"Correctly write `for` loops to repeat simple calculations.\"\n" +"- \"Trace changes to a loop variable as the loop runs.\"\n" +"- \"Trace changes to other variables as they are updated by a `for` loop.\"\n" +"keypoints:\n" +"- \"Use `for variable in sequence` to process the elements of a sequence one at a time.\"\n" +"- \"The body of a `for` loop must be indented.\"\n" +"- \"Use `len(thing)` to determine the length of something that contains other values.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:18 +msgid "In the last episode, we wrote Python code that plots values of interest from our first\n" +"inflammation dataset (`inflammation-01.csv`), which revealed some suspicious features in it." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:21 +msgid "![Analysis of inflammation-01.csv](../fig/03-loop_2_0.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:23 +msgid "We have a dozen data sets right now, though, and more on the way.\n" +"We want to create plots for all of our data sets with a single statement.\n" +"To do that, we'll have to teach the computer how to repeat things." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:27 +msgid "An example task that we might want to repeat is printing each character in a\n" +"word on a line of its own." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:30 +# code block +msgid "~~~\n" +"word = 'lead'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:35 +msgid "In Python, a string is basically an ordered collection of characters, and every\n" +"character has a unique number associated with it -- its index. This means that\n" +"we can access characters in a string using their indices.\n" +"For example, we can get the first character of the word `'lead'`, by using\n" +"`word[0]`. One way to print each character is to use four `print` statements:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:41 +# code block +msgid "~~~\n" +"print(word[0])\n" +"print(word[1])\n" +"print(word[2])\n" +"print(word[3])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:49 +#: python-novice-inflammation/_episodes/04-loop.md:110 +# code block +msgid "~~~\n" +"l\n" +"e\n" +"a\n" +"d\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:57 +msgid "This is a bad approach for three reasons:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:59 +# ordered list +msgid "1. **Not scalable**. Imagine you need to print characters of a string that is hundreds" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:60 +msgid " of letters long. It might be easier to type them in manually." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:62 +# ordered list +msgid "2. **Difficult to maintain**. If we want to decorate each printed character with an" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:63 +msgid " asterisk or any other character, we would have to change four lines of code. While\n" +" this might not be a problem for short strings, it would definitely be a problem for\n" +" longer ones." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:67 +# ordered list +msgid "3. **Fragile**. If we use it with a word that has more characters than what we initially" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:68 +msgid " envisioned, it will only display part of the word's characters. A shorter string, on\n" +" the other hand, will cause an error because it will be trying to display part of the\n" +" string that doesn't exist." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:72 +# code block +msgid "~~~\n" +"word = 'tin'\n" +"print(word[0])\n" +"print(word[1])\n" +"print(word[2])\n" +"print(word[3])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:81 +# code block +msgid "~~~\n" +"t\n" +"i\n" +"n\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:88 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"IndexError Traceback (most recent call last)\n" +" in ()\n" +" 3 print(word[1])\n" +" 4 print(word[2])\n" +"----> 5 print(word[3])\n" +"\n" +"IndexError: string index out of range\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:98 +#: python-novice-inflammation/_episodes/05-lists.md:113 +#: python-novice-inflammation/_episodes/08-func.md:448 +#: python-novice-inflammation/_episodes/09-errors.md:76 +#: python-novice-inflammation/_episodes/09-errors.md:164 +#: python-novice-inflammation/_episodes/09-errors.md:189 +#: python-novice-inflammation/_episodes/09-errors.md:245 +#: python-novice-inflammation/_episodes/09-errors.md:271 +#: python-novice-inflammation/_episodes/09-errors.md:294 +#: python-novice-inflammation/_episodes/09-errors.md:322 +#: python-novice-inflammation/_episodes/09-errors.md:361 +#: python-novice-inflammation/_episodes/09-errors.md:391 +#: python-novice-inflammation/_episodes/09-errors.md:427 +#: python-novice-inflammation/_episodes/10-defensive.md:92 +#: python-novice-inflammation/_episodes/10-defensive.md:168 +#: python-novice-inflammation/_episodes/10-defensive.md:190 +#: python-novice-inflammation/_episodes/10-defensive.md:230 +#: python-novice-inflammation/_episodes/10-defensive.md:325 +#: python-novice-inflammation/_episodes/10-defensive.md:398 +#: python-novice-inflammation/_episodes/10-defensive.md:457 +#: python-novice-inflammation/_extras/discuss.md:104 +#: python-novice-inflammation/_extras/discuss.md:287 +# SC/DC Template label +msgid "{: .error}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:100 +msgid "Here's a better approach:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:102 +# code block +msgid "~~~\n" +"word = 'lead'\n" +"for char in word:\n" +" print(char)\n" +"\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:118 +msgid "This is shorter --- certainly shorter than something that prints every character in a\n" +"hundred-letter string --- and more robust as well:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:121 +# code block +msgid "~~~\n" +"word = 'oxygen'\n" +"for char in word:\n" +" print(char)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:128 +# code block +msgid "~~~\n" +"o\n" +"x\n" +"y\n" +"g\n" +"e\n" +"n\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:138 +msgid "The improved version uses a [for loop]({{ page.root }}/reference.html#for-loop)\n" +"to repeat an operation --- in this case, printing --- once for each thing in a sequence.\n" +"The general form of a loop is:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:142 +# code block +msgid "~~~\n" +"for variable in collection:\n" +" # do things using variable, such as print\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:148 +msgid "Using the oxygen example above, the loop might look like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:150 +msgid "![loop_image](../fig/loops_image.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:152 +msgid "where each character (`char`) in the variable `word` is looped through and printed one character\n" +"after another. The numbers in the diagram denote which loop cycle the character was printed in (1\n" +"being the first loop, and 6 being the final loop)." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:156 +msgid "We can call the [loop variable]({{ page.root }}/reference.html#loop-variable) anything we like, but\n" +"there must be a colon at the end of the line starting the loop, and we must indent anything we\n" +"want to run inside the loop. Unlike many other languages, there is no command to signify the end\n" +"of the loop body (e.g. `end for`); what is indented after the `for` statement belongs to the loop." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:162 +# blockquote, which can be cascaded +msgid "> ## What's in a name?" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:163 +msgid ">\n" +">\n" +"> In the example above, the loop variable was given the name `char` as a mnemonic;\n" +"> it is short for 'character'. We can choose any name we want for variables.\n" +"> We can even call our loop variable `banana`, as long as we use this name consistently:\n" +">\n" +"> ~~~\n" +"> word = 'oxygen'\n" +"> for banana in word:\n" +"> print(banana)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> o\n" +"> x\n" +"> y\n" +"> g\n" +"> e\n" +"> n\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:185 +msgid ">\n" +"> It is a good idea to choose variable names that are meaningful, otherwise it would be more\n" +"> difficult to understand what the loop is doing." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:190 +msgid "Here's another loop that repeatedly updates a variable:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:192 +# code block +msgid "~~~\n" +"length = 0\n" +"for vowel in 'aeiou':\n" +" length = length + 1\n" +"print('There are', length, 'vowels')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:200 +# code block +msgid "~~~\n" +"There are 5 vowels\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:205 +msgid "It's worth tracing the execution of this little program step by step.\n" +"Since there are five characters in `'aeiou'`,\n" +"the statement on line 3 will be executed five times.\n" +"The first time around,\n" +"`length` is zero (the value assigned to it on line 1)\n" +"and `vowel` is `'a'`.\n" +"The statement adds 1 to the old value of `length`,\n" +"producing 1,\n" +"and updates `length` to refer to that new value.\n" +"The next time around,\n" +"`vowel` is `'e'` and `length` is 1,\n" +"so `length` is updated to be 2.\n" +"After three more updates,\n" +"`length` is 5;\n" +"since there is nothing left in `'aeiou'` for Python to process,\n" +"the loop finishes\n" +"and the `print` statement on line 4 tells us our final answer." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:223 +msgid "Note that a loop variable is a variable that's being used to record progress in a loop.\n" +"It still exists after the loop is over,\n" +"and we can re-use variables previously defined as loop variables as well:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:227 +# code block +msgid "~~~\n" +"letter = 'z'\n" +"for letter in 'abc':\n" +" print(letter)\n" +"print('after the loop, letter is', letter)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:235 +# code block +msgid "~~~\n" +"a\n" +"b\n" +"c\n" +"after the loop, letter is c\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:243 +msgid "Note also that finding the length of a string is such a common operation\n" +"that Python actually has a built-in function to do it called `len`:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:246 +# code block +msgid "~~~\n" +"print(len('aeiou'))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:251 +# code block +msgid "~~~\n" +"5\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:256 +msgid "`len` is much faster than any function we could write ourselves,\n" +"and much easier to read than a two-line loop;\n" +"it will also give us the length of many other things that we haven't met yet,\n" +"so we should always use it when we can." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:261 +# blockquote, which can be cascaded +msgid "> ## From 1 to N" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:262 +msgid ">\n" +"> Python has a built-in function called `range` that generates a sequence of numbers. `range` can\n" +"> accept 1, 2, or 3 parameters.\n" +">\n" +"> * If one parameter is given, `range` generates a sequence of that length,\n" +"> starting at zero and incrementing by 1.\n" +"> For example, `range(3)` produces the numbers `0, 1, 2`.\n" +"> * If two parameters are given, `range` starts at\n" +"> the first and ends just before the second, incrementing by one.\n" +"> For example, `range(2, 5)` produces `2, 3, 4`.\n" +"> * If `range` is given 3 parameters,\n" +"> it starts at the first one, ends just before the second one, and increments by the third one.\n" +"> For example, `range(3, 10, 2)` produces `3, 5, 7, 9`.\n" +">\n" +"> Using `range`,\n" +"> write a loop that uses `range` to print the first 3 natural numbers:\n" +">\n" +"> ~~~\n" +"> 1\n" +"> 2\n" +"> 3\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > for number in range(1, 4):\n" +"> > print(number)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:298 +# blockquote, which can be cascaded +msgid "> ## Understanding the loops" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:299 +msgid ">\n" +"> Given the following loop:\n" +"> ~~~\n" +"> word = 'oxygen'\n" +"> for char in word:\n" +"> print(char)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> How many times is the body of the loop executed?\n" +">\n" +"> * 3 times\n" +"> * 4 times\n" +"> * 5 times\n" +"> * 6 times\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > The body of the loop is executed 6 times.\n" +"> >" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:324 +# blockquote, which can be cascaded +msgid "> ## Computing Powers With Loops" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:325 +msgid ">\n" +"> Exponentiation is built into Python:\n" +">\n" +"> ~~~\n" +"> print(5 ** 3)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 125\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:337 +msgid ">\n" +"> Write a loop that calculates the same result as `5 ** 3` using\n" +"> multiplication (and without exponentiation).\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > result = 1\n" +"> > for number in range(0, 3):\n" +"> > result = result * 5\n" +"> > print(result)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:352 +# blockquote, which can be cascaded +msgid "> ## Reverse a String" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:353 +msgid ">\n" +"> Knowing that two strings can be concatenated using the `+` operator,\n" +"> write a loop that takes a string\n" +"> and produces a new string with the characters in reverse order,\n" +"> so `'Newton'` becomes `'notweN'`.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > newstring = ''\n" +"> > oldstring = 'Newton'\n" +"> > for char in oldstring:\n" +"> > newstring = char + newstring\n" +"> > print(newstring)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:371 +# blockquote, which can be cascaded +msgid "> ## Computing the Value of a Polynomial" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:372 +msgid ">\n" +"> The built-in function `enumerate` takes a sequence (e.g. a [list]({{ page.root }}/05-lists/)) and generates a\n" +"> new sequence of the same length. Each element of the new sequence is a pair composed of the index\n" +"> (0, 1, 2,...) and the value from the original sequence:\n" +">\n" +"> ~~~\n" +"> for idx, val in enumerate(a_list):\n" +"> # Do something using idx and val\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> The code above loops through `a_list`, assigning the index to `idx` and the value to `val`.\n" +">\n" +"> Suppose you have encoded a polynomial as a list of coefficients in\n" +"> the following way: the first element is the constant term, the\n" +"> second element is the coefficient of the linear term, the third is the\n" +"> coefficient of the quadratic term, etc.\n" +">\n" +"> ~~~\n" +"> x = 5\n" +"> coefs = [2, 4, 3]\n" +"> y = coefs[0] * x**0 + coefs[1] * x**1 + coefs[2] * x**2\n" +"> print(y)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 97\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:402 +msgid ">\n" +"> Write a loop using `enumerate(coefs)` which computes the value `y` of any\n" +"> polynomial, given `x` and `coefs`.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > y = 0\n" +"> > for idx, coef in enumerate(coefs):\n" +"> > y = y + coef * x**idx\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/08__05-lists.md.pot b/transifex/python-novice-inflammation/pot/08__05-lists.md.pot new file mode 100644 index 00000000..b9a40733 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/08__05-lists.md.pot @@ -0,0 +1,736 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/05-lists.md:1 +# Front Matter +msgid "---\n" +"title: Storing Multiple Values in Lists\n" +"teaching: 30\n" +"exercises: 15\n" +"questions:\n" +"- \"How can I store many values together?\"\n" +"objectives:\n" +"- \"Explain what a list is.\"\n" +"- \"Create and index lists of simple values.\"\n" +"- \"Change the values of individual elements\"\n" +"- \"Append values to an existing list\"\n" +"- \"Reorder and slice list elements\"\n" +"- \"Create and manipulate nested lists\"\n" +"keypoints:\n" +"- \"`[value1, value2, value3, ...]` creates a list.\"\n" +"- \"Lists can contain any Python object, including lists (i.e., list of lists).\"\n" +"- \"Lists are indexed and sliced with square brackets (e.g., list[0] and\n" +"list[2:9]), in the same way as strings and arrays.\"\n" +"- \"Lists are mutable (i.e., their values can be changed in place).\"\n" +"- \"Strings are immutable (i.e., the characters in them cannot be changed).\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:23 +msgid "Similar to a string that can contain many characters, a list is a container that can store many values.\n" +"Unlike NumPy arrays,\n" +"lists are built into the language (so we don't have to load a library\n" +"to use them).\n" +"We create a list by putting values inside square brackets and separating the values with commas:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:29 +# code block +msgid "~~~\n" +"odds = [1, 3, 5, 7]\n" +"print('odds are:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:35 +# code block +msgid "~~~\n" +"odds are: [1, 3, 5, 7]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:40 +msgid "We can access elements of a list using indices -- numbered positions of elements in the list.\n" +"These positions are numbered starting at 0, so the first element has an index of 0." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:43 +# code block +msgid "~~~\n" +"print('first element:', odds[0])\n" +"print('last element:', odds[3])\n" +"print('\"-1\" element:', odds[-1])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:50 +# code block +msgid "~~~\n" +"first element: 1\n" +"last element: 7\n" +"\"-1\" element: 7\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:57 +msgid "Yes, we can use negative numbers as indices in Python. When we do so, the index `-1` gives us the\n" +"last element in the list, `-2` the second to last, and so on.\n" +"Because of this, `odds[3]` and `odds[-1]` point to the same element here." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:61 +msgid "If we loop over a list, the loop variable is assigned to its elements one at a time:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:63 +# code block +msgid "~~~\n" +"for number in odds:\n" +" print(number)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:69 +# code block +msgid "~~~\n" +"1\n" +"3\n" +"5\n" +"7\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:77 +msgid "There is one important difference between lists and strings:\n" +"we can change the values in a list,\n" +"but we cannot change individual characters in a string.\n" +"For example:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:82 +# code block +msgid "~~~\n" +"names = ['Curie', 'Darwing', 'Turing'] # typo in Darwin's name\n" +"print('names is originally:', names)\n" +"names[1] = 'Darwin' # correct the name\n" +"print('final value of names:', names)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:90 +# code block +msgid "~~~\n" +"names is originally: ['Curie', 'Darwing', 'Turing']\n" +"final value of names: ['Curie', 'Darwin', 'Turing']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:96 +msgid "works, but:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:98 +# code block +msgid "~~~\n" +"name = 'Darwin'\n" +"name[0] = 'd'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:104 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"TypeError Traceback (most recent call last)\n" +" in ()\n" +" 1 name = 'Darwin'\n" +"----> 2 name[0] = 'd'\n" +"\n" +"TypeError: 'str' object does not support item assignment\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:115 +msgid "does not." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:117 +# blockquote, which can be cascaded +msgid "> ## Ch-Ch-Ch-Ch-Changes" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:118 +msgid ">\n" +"> Data which can be modified in place is called [mutable]({{ page.root }}/reference.html#mutable),\n" +"> while data which cannot be modified is called [immutable]({{ page.root }}/reference.html#immutable).\n" +"> Strings and numbers are immutable. This does not mean that variables with string or number values\n" +"> are constants, but when we want to change the value of a string or number variable, we can only\n" +"> replace the old value with a completely new value.\n" +">\n" +"> Lists and arrays, on the other hand, are mutable: we can modify them after they have been\n" +"> created. We can change individual elements, append new elements, or reorder the whole list. For\n" +"> some operations, like sorting, we can choose whether to use a function that modifies the data\n" +"> in-place or a function that returns a modified copy and leaves the original unchanged.\n" +">\n" +"> Be careful when modifying data in-place. If two variables refer to the same list, and you modify\n" +"> the list value, it will change for both variables!\n" +">\n" +"> ~~~\n" +"> salsa = ['peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> my_salsa = salsa # <-- my_salsa and salsa point to the *same* list data in memory\n" +"> salsa[0] = 'hot peppers'\n" +"> print('Ingredients in my salsa:', my_salsa)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Ingredients in my salsa: ['hot peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:145 +msgid ">\n" +"> If you want variables with mutable values to be independent, you\n" +"> must make a copy of the value when you assign it.\n" +">\n" +"> ~~~\n" +"> salsa = ['peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> my_salsa = list(salsa) # <-- makes a *copy* of the list\n" +"> salsa[0] = 'hot peppers'\n" +"> print('Ingredients in my salsa:', my_salsa)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Ingredients in my salsa: ['peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:161 +msgid ">\n" +"> Because of pitfalls like this, code which modifies data in place can be more difficult to\n" +"> understand. However, it is often far more efficient to modify a large data structure in place\n" +"> than to create a modified copy for every small change. You should consider both of these aspects\n" +"> when writing your code." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:168 +# blockquote, which can be cascaded +msgid "> ## Nested Lists" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:169 +# blockquote, which can be cascaded +msgid "> Since a list can contain any Python variables, it can even contain other lists." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:170 +msgid ">\n" +"> For example, we could represent the products in the shelves of a small grocery shop:\n" +">\n" +"> ~~~\n" +"> x = [['pepper', 'zucchini', 'onion'],\n" +"> ['cabbage', 'lettuce', 'garlic'],\n" +"> ['apple', 'pear', 'banana']]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Here is a visual example of how indexing a list of lists `x` works:\n" +">\n" +"> [![x is represented as a pepper shaker containing several packets of pepper. [x[0]] is represented\n" +"> as a pepper shaker containing a single packet of pepper. x[0] is represented as a single packet of\n" +"> pepper. x[0][0] is represented as single grain of pepper. Adapted\n" +"> from @hadleywickham.](../fig/indexing_lists_python.png)][hadleywickham-tweet]\n" +">\n" +"> Using the previously declared list `x`, these would be the results of the\n" +"> index operations shown in the image:\n" +">\n" +"> ~~~\n" +"> print([x[0]])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> [['pepper', 'zucchini', 'onion']]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:199 +msgid ">\n" +"> ~~~\n" +"> print(x[0])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> ['pepper', 'zucchini', 'onion']\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:209 +msgid ">\n" +"> ~~~\n" +"> print(x[0][0])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 'pepper'\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:219 +msgid ">\n" +"> Thanks to [Hadley Wickham][hadleywickham-tweet]\n" +"> for the image above." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:224 +# blockquote, which can be cascaded +msgid "> ## Heterogeneous Lists" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:225 +# blockquote, which can be cascaded +msgid "> Lists in Python can contain elements of different types. Example:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:226 +#: python-novice-inflammation/_episodes/05-lists.md:228 +#: python-novice-inflammation/_episodes/07-cond.md:429 +#: python-novice-inflammation/_episodes/07-cond.md:431 +#: python-novice-inflammation/_episodes/07-cond.md:433 +#: python-novice-inflammation/_episodes/07-cond.md:435 +# blockquote, which can be cascaded +msgid "> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:227 +# blockquote, which can be cascaded +msgid "> sample_ages = [10, 12.5, 'Unknown']" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:229 +#: python-novice-inflammation/_episodes/07-cond.md:432 +# blockquote, which can be cascaded +msgid "> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:232 +msgid "There are many ways to change the contents of lists besides assigning new values to\n" +"individual elements:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:235 +# code block +msgid "~~~\n" +"odds.append(11)\n" +"print('odds after adding a value:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:241 +# code block +msgid "~~~\n" +"odds after adding a value: [1, 3, 5, 7, 11]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:246 +# code block +msgid "~~~\n" +"removed_element = odds.pop(0)\n" +"print('odds after removing the first element:', odds)\n" +"print('removed_element:', removed_element)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:253 +# code block +msgid "~~~\n" +"odds after removing the first element: [3, 5, 7, 11]\n" +"removed_element: 1\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:259 +# code block +msgid "~~~\n" +"odds.reverse()\n" +"print('odds after reversing:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:265 +# code block +msgid "~~~\n" +"odds after reversing: [11, 7, 5, 3]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:270 +msgid "While modifying in place, it is useful to remember that Python treats lists in a slightly\n" +"counter-intuitive way." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:273 +msgid "As we saw earlier, when we modified the `salsa` list item in-place, if we make a list, (attempt to) copy it and then modify this list, we can cause all sorts of trouble. This also applies to modifying the list using the above functions:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:275 +# code block +msgid "~~~\n" +"odds = [1, 3, 5, 7]\n" +"primes = odds\n" +"primes.append(2)\n" +"print('primes:', primes)\n" +"print('odds:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:284 +# code block +msgid "~~~\n" +"primes: [1, 3, 5, 7, 2]\n" +"odds: [1, 3, 5, 7, 2]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:290 +msgid "This is because Python stores a list in memory, and then can use multiple names to refer to the\n" +"same list. If all we want to do is copy a (simple) list, we can again use the `list` function, so we do\n" +"not modify a list we did not mean to:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:294 +# code block +msgid "~~~\n" +"odds = [1, 3, 5, 7]\n" +"primes = list(odds)\n" +"primes.append(2)\n" +"print('primes:', primes)\n" +"print('odds:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:303 +# code block +msgid "~~~\n" +"primes: [1, 3, 5, 7, 2]\n" +"odds: [1, 3, 5, 7]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:309 +# blockquote, which can be cascaded +msgid "> ## Turn a String Into a List" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:310 +msgid ">\n" +"> Use a for-loop to convert the string \"hello\" into a list of letters:\n" +">\n" +"> ~~~\n" +"> ['h', 'e', 'l', 'l', 'o']\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Hint: You can create an empty list like this:\n" +">\n" +"> ~~~\n" +"> my_list = []\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > my_list = []\n" +"> > for char in 'hello':\n" +"> > my_list.append(char)\n" +"> > print(my_list)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:336 +msgid "Subsets of lists and strings can be accessed by specifying ranges of values in brackets,\n" +"similar to how we accessed ranges of positions in a NumPy array.\n" +"This is commonly referred to as \"slicing\" the list/string." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:340 +# code block +msgid "~~~\n" +"binomial_name = 'Drosophila melanogaster'\n" +"group = binomial_name[0:10]\n" +"print('group:', group)\n" +"\n" +"species = binomial_name[11:23]\n" +"print('species:', species)\n" +"\n" +"chromosomes = ['X', 'Y', '2', '3', '4']\n" +"autosomes = chromosomes[2:5]\n" +"print('autosomes:', autosomes)\n" +"\n" +"last = chromosomes[-1]\n" +"print('last:', last)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:357 +# code block +msgid "~~~\n" +"group: Drosophila\n" +"species: melanogaster\n" +"autosomes: ['2', '3', '4']\n" +"last: 4\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:365 +# blockquote, which can be cascaded +msgid "> ## Slicing From the End" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:366 +msgid ">\n" +"> Use slicing to access only the last four characters of a string or entries of a list.\n" +">\n" +"> ~~~\n" +"> string_for_slicing = 'Observation date: 02-Feb-2013'\n" +"> list_for_slicing = [['fluorine', 'F'],\n" +"> ['chlorine', 'Cl'],\n" +"> ['bromine', 'Br'],\n" +"> ['iodine', 'I'],\n" +"> ['astatine', 'At']]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> '2013'\n" +"> [['chlorine', 'Cl'], ['bromine', 'Br'], ['iodine', 'I'], ['astatine', 'At']]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:384 +msgid ">\n" +"> Would your solution work regardless of whether you knew beforehand\n" +"> the length of the string or list\n" +"> (e.g. if you wanted to apply the solution to a set of lists of different lengths)?\n" +"> If not, try to change your approach to make it more robust.\n" +">\n" +"> Hint: Remember that indices can be negative as well as positive\n" +">\n" +"> > ## Solution\n" +"> > Use negative indices to count elements from the end of a container (such as list or string):\n" +"> >\n" +"> > ~~~\n" +"> > string_for_slicing[-4:]\n" +"> > list_for_slicing[-4:]\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:403 +# blockquote, which can be cascaded +msgid "> ## Non-Continuous Slices" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:404 +msgid ">\n" +"> So far we've seen how to use slicing to take single blocks\n" +"> of successive entries from a sequence.\n" +"> But what if we want to take a subset of entries\n" +"> that aren't next to each other in the sequence?\n" +">\n" +"> You can achieve this by providing a third argument\n" +"> to the range within the brackets, called the _step size_.\n" +"> The example below shows how you can take every third entry in a list:\n" +">\n" +"> ~~~\n" +"> primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]\n" +"> subset = primes[0:12:3]\n" +"> print('subset', subset)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> subset [2, 7, 17, 29]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:425 +msgid ">\n" +"> Notice that the slice taken begins with the first entry in the range,\n" +"> followed by entries taken at equally-spaced intervals (the steps) thereafter.\n" +"> If you wanted to begin the subset with the third entry,\n" +"> you would need to specify that as the starting point of the sliced range:\n" +">\n" +"> ~~~\n" +"> primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]\n" +"> subset = primes[2:12:3]\n" +"> print('subset', subset)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> subset [5, 13, 23, 37]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:442 +msgid ">\n" +"> Use the step size argument to create a new string\n" +"> that contains only every other character in the string\n" +"> \"In an octopus's garden in the shade\". Start with\n" +"> creating a variable to hold the string:\n" +">\n" +"> ~~~\n" +"> beatles = \"In an octopus's garden in the shade\"\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> What slice of `beatles` will produce the\n" +"> following output (i.e., the first character, third\n" +"> character, and every other character through the end\n" +"> of the string)?\n" +"> ~~~\n" +"> I notpssgre ntesae\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:461 +msgid ">\n" +"> > ## Solution\n" +"> > To obtain every other character you need to provide a slice with the step\n" +"> > size of 2:\n" +"> >\n" +"> > ~~~\n" +"> > beatles[0:35:2]\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > You can also leave out the beginning and end of the slice to take the whole string\n" +"> > and provide only the step argument to go every second\n" +"> > element:\n" +"> >\n" +"> > ~~~\n" +"> > beatles[::2]\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:482 +msgid "If you want to take a slice from the beginning of a sequence, you can omit the first index in the\n" +"range:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:485 +# code block +msgid "~~~\n" +"date = 'Monday 4 January 2016'\n" +"day = date[0:6]\n" +"print('Using 0 to begin range:', day)\n" +"day = date[:6]\n" +"print('Omitting beginning index:', day)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:494 +# code block +msgid "~~~\n" +"Using 0 to begin range: Monday\n" +"Omitting beginning index: Monday\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:500 +msgid "And similarly, you can omit the ending index in the range to take a slice to the very end of the\n" +"sequence:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:503 +# code block +msgid "~~~\n" +"months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']\n" +"sond = months[8:12]\n" +"print('With known last position:', sond)\n" +"sond = months[8:len(months)]\n" +"print('Using len() to get last entry:', sond)\n" +"sond = months[8:]\n" +"print('Omitting ending index:', sond)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:514 +# code block +msgid "~~~\n" +"With known last position: ['sep', 'oct', 'nov', 'dec']\n" +"Using len() to get last entry: ['sep', 'oct', 'nov', 'dec']\n" +"Omitting ending index: ['sep', 'oct', 'nov', 'dec']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:521 +# blockquote, which can be cascaded +msgid "> ## Overloading" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:522 +msgid ">\n" +"> `+` usually means addition, but when used on strings or lists, it means \"concatenate\".\n" +"> Given that, what do you think the multiplication operator `*` does on lists?\n" +"> In particular, what will be the output of the following code?\n" +">\n" +"> ~~~\n" +"> counts = [2, 4, 6, 8, 10]\n" +"> repeats = counts * 2\n" +"> print(repeats)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> 1. `[2, 4, 6, 8, 10, 2, 4, 6, 8, 10]`\n" +"> 2. `[4, 8, 12, 16, 20]`\n" +"> 3. `[[2, 4, 6, 8, 10],[2, 4, 6, 8, 10]]`\n" +"> 4. `[2, 4, 6, 8, 10, 4, 8, 12, 16, 20]`\n" +">\n" +"> The technical term for this is *operator overloading*:\n" +"> a single operator, like `+` or `*`,\n" +"> can do different things depending on what it's applied to.\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > The multiplication operator `*` used on a list replicates elements of the list and concatenates\n" +"> > them together:\n" +"> >\n" +"> > ~~~\n" +"> > [2, 4, 6, 8, 10, 2, 4, 6, 8, 10]\n" +"> > ~~~\n" +"> > {: .output}\n" +"> >\n" +"> > It's equivalent to:\n" +"> >\n" +"> > ~~~\n" +"> > counts + counts\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:562 +msgid "[hadleywickham-tweet]: https://twitter.com/hadleywickham/status/643381054758363136" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/09__06-files.md.pot b/transifex/python-novice-inflammation/pot/09__06-files.md.pot new file mode 100644 index 00000000..29c0286a --- /dev/null +++ b/transifex/python-novice-inflammation/pot/09__06-files.md.pot @@ -0,0 +1,254 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/06-files.md:1 +# Front Matter +msgid "---\n" +"title: Analyzing Data from Multiple Files\n" +"teaching: 20\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I do the same operations on many different files?\"\n" +"objectives:\n" +"- \"Use a library function to get a list of filenames that match a wildcard pattern.\"\n" +"- \"Write a `for` loop to process multiple files.\"\n" +"keypoints:\n" +"- \"Use `glob.glob(pattern)` to create a list of files whose names match a pattern.\"\n" +"- \"Use `*` in a pattern to match zero or more characters, and `?` to match any single character.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:15 +msgid "We now have almost everything we need to process all our data files.\n" +"The only thing that's missing is a library with a rather unpleasant name:" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:18 +# code block +msgid "~~~\n" +"import glob\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:23 +msgid "The `glob` library contains a function, also called `glob`,\n" +"that finds files and directories whose names match a pattern.\n" +"We provide those patterns as strings:\n" +"the character `*` matches zero or more characters,\n" +"while `?` matches any one character.\n" +"We can use this to get the names of all the CSV files in the current directory:" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:30 +# code block +msgid "~~~\n" +"print(glob.glob('inflammation*.csv'))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:35 +# code block +msgid "~~~\n" +"['inflammation-05.csv', 'inflammation-11.csv', 'inflammation-12.csv', 'inflammation-08.csv',\n" +"'inflammation-03.csv', 'inflammation-06.csv', 'inflammation-09.csv', 'inflammation-07.csv',\n" +"'inflammation-10.csv', 'inflammation-02.csv', 'inflammation-04.csv', 'inflammation-01.csv']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:42 +msgid "As these examples show,\n" +"`glob.glob`'s result is a list of file and directory paths in arbitrary order.\n" +"This means we can loop over it\n" +"to do something with each filename in turn.\n" +"In our case,\n" +"the \"something\" we want to do is generate a set of plots for each file in our inflammation dataset.\n" +"If we want to start by analyzing just the first three files in alphabetical order, we can use the\n" +"`sorted` built-in function to generate a new sorted list from the `glob.glob` output:" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:51 +# code block +msgid "~~~\n" +"import glob\n" +"import numpy\n" +"import matplotlib.pyplot\n" +"\n" +"filenames = sorted(glob.glob('inflammation*.csv'))\n" +"filenames = filenames[0:3]\n" +"for filename in filenames:\n" +" print(filename)\n" +"\n" +" data = numpy.loadtxt(fname=filename, delimiter=',')\n" +"\n" +" fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"\n" +" axes1 = fig.add_subplot(1, 3, 1)\n" +" axes2 = fig.add_subplot(1, 3, 2)\n" +" axes3 = fig.add_subplot(1, 3, 3)\n" +"\n" +" axes1.set_ylabel('average')\n" +" axes1.plot(numpy.mean(data, axis=0))\n" +"\n" +" axes2.set_ylabel('max')\n" +" axes2.plot(numpy.max(data, axis=0))\n" +"\n" +" axes3.set_ylabel('min')\n" +" axes3.plot(numpy.min(data, axis=0))\n" +"\n" +" fig.tight_layout()\n" +" matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:83 +# code block +msgid "~~~\n" +"inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:88 +msgid "![Analysis of inflammation-01.csv](../fig/03-loop_49_1.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:90 +# code block +msgid "~~~\n" +"inflammation-02.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:95 +msgid "![Analysis of inflammation-02.csv](../fig/03-loop_49_3.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:97 +# code block +msgid "~~~\n" +"inflammation-03.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:102 +msgid "![Analysis of inflammation-03.csv](../fig/03-loop_49_5.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:104 +msgid "Sure enough,\n" +"the maxima of the first two data sets show exactly the same ramp as the first,\n" +"and their minima show the same staircase structure;\n" +"a different situation has been revealed in the third dataset,\n" +"where the maxima are a bit less regular, but the minima are consistently zero." +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:110 +# blockquote, which can be cascaded +msgid "> ## Plotting Differences" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:111 +msgid ">\n" +"> Plot the difference between the average inflammations reported in the first and second datasets\n" +"> (stored in `inflammation-01.csv` and `inflammation-02.csv`, correspondingly),\n" +"> i.e., the difference between the leftmost plots of the first two figures.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import glob\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > filenames = sorted(glob.glob('inflammation*.csv'))\n" +"> >\n" +"> > data0 = numpy.loadtxt(fname=filenames[0], delimiter=',')\n" +"> > data1 = numpy.loadtxt(fname=filenames[1], delimiter=',')\n" +"> >\n" +"> > fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"> >\n" +"> > matplotlib.pyplot.ylabel('Difference in average')\n" +"> > matplotlib.pyplot.plot(numpy.mean(data0, axis=0) - numpy.mean(data1, axis=0))\n" +"> >\n" +"> > fig.tight_layout()\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:139 +# blockquote, which can be cascaded +msgid "> ## Generate Composite Statistics" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:140 +msgid ">\n" +"> Use each of the files once to generate a dataset containing values averaged over all patients:\n" +">\n" +"> ~~~\n" +"> filenames = glob.glob('inflammation*.csv')\n" +"> composite_data = numpy.zeros((60,40))\n" +"> for filename in filenames:\n" +"> # sum each new file's data into composite_data as it's read\n" +"> #\n" +"> # and then divide the composite_data by number of samples\n" +"> composite_data = composite_data / len(filenames)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Then use pyplot to generate average, max, and min for all patients.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import glob\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > filenames = glob.glob('inflammation*.csv')\n" +"> > composite_data = numpy.zeros((60,40))\n" +"> >\n" +"> > for filename in filenames:\n" +"> > data = numpy.loadtxt(fname = filename, delimiter=',')\n" +"> > composite_data = composite_data + data\n" +"> >\n" +"> > composite_data = composite_data / len(filenames)\n" +"> >\n" +"> > fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"> >\n" +"> > axes1 = fig.add_subplot(1, 3, 1)\n" +"> > axes2 = fig.add_subplot(1, 3, 2)\n" +"> > axes3 = fig.add_subplot(1, 3, 3)\n" +"> >\n" +"> > axes1.set_ylabel('average')\n" +"> > axes1.plot(numpy.mean(composite_data, axis=0))\n" +"> >\n" +"> > axes2.set_ylabel('max')\n" +"> > axes2.plot(numpy.max(composite_data, axis=0))\n" +"> >\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(composite_data, axis=0))\n" +"> >\n" +"> > fig.tight_layout()\n" +"> >\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:191 +# SC/DC Template label +msgid ">{: .solution}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/10__07-cond.md.pot b/transifex/python-novice-inflammation/pot/10__07-cond.md.pot new file mode 100644 index 00000000..377d39f4 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/10__07-cond.md.pot @@ -0,0 +1,657 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/07-cond.md:1 +# Front Matter +msgid "---\n" +"title: Making Choices\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can my programs do different things based on data values?\"\n" +"objectives:\n" +"- \"Write conditional statements including `if`, `elif`, and `else` branches.\"\n" +"- \"Correctly evaluate expressions containing `and` and `or`.\"\n" +"keypoints:\n" +"- \"Use `if condition` to start a conditional statement, `elif condition` to\n" +" provide additional tests, and `else` to provide a default.\"\n" +"- \"The bodies of the branches of conditional statements must be indented.\"\n" +"- \"Use `==` to test for equality.\"\n" +"- \"`X and Y` is only true if both `X` and `Y` are true.\"\n" +"- \"`X or Y` is true if either `X` or `Y`, or both, are true.\"\n" +"- \"Zero, the empty string, and the empty list are considered false;\n" +" all other numbers, strings, and lists are considered true.\"\n" +"- \"`True` and `False` represent truth values.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:22 +msgid "In our last lesson, we discovered something suspicious was going on\n" +"in our inflammation data by drawing some plots.\n" +"How can we use Python to automatically recognize the different features we saw,\n" +"and take a different action for each? In this lesson, we'll learn how to write code that\n" +"runs only when certain conditions are true." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:28 +# header +msgid "## Conditionals" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:30 +msgid "We can ask Python to take different actions, depending on a condition, with an `if` statement:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:32 +# code block +msgid "~~~\n" +"num = 37\n" +"if num > 100:\n" +" print('greater')\n" +"else:\n" +" print('not greater')\n" +"print('done')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:42 +# code block +msgid "~~~\n" +"not greater\n" +"done\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:48 +msgid "The second line of this code uses the keyword `if` to tell Python that we want to make a choice.\n" +"If the test that follows the `if` statement is true,\n" +"the body of the `if`\n" +"(i.e., the set of lines indented underneath it) is executed, and \"greater\" is printed.\n" +"If the test is false,\n" +"the body of the `else` is executed instead, and \"not greater\" is printed.\n" +"Only one or the other is ever executed before continuing on with program execution to print \"done\":" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:56 +msgid "![A flowchart diagram of the if-else construct that tests if variable num is greater than 100](../fig/python-flowchart-conditional.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:58 +msgid "Conditional statements don't have to include an `else`.\n" +"If there isn't one,\n" +"Python simply does nothing if the test is false:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:62 +# code block +msgid "~~~\n" +"num = 53\n" +"print('before conditional...')\n" +"if num > 100:\n" +" print(num,' is greater than 100')\n" +"print('...after conditional')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:71 +# code block +msgid "~~~\n" +"before conditional...\n" +"...after conditional\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:77 +msgid "We can also chain several tests together using `elif`,\n" +"which is short for \"else if\".\n" +"The following Python code uses `elif` to print the sign of a number." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:81 +# code block +msgid "~~~\n" +"num = -3\n" +"\n" +"if num > 0:\n" +" print(num, 'is positive')\n" +"elif num == 0:\n" +" print(num, 'is zero')\n" +"else:\n" +" print(num, 'is negative')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:93 +# code block +msgid "~~~\n" +"-3 is negative\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:98 +msgid "Note that to test for equality we use a double equals sign `==`\n" +"rather than a single equals sign `=` which is used to assign values." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:101 +# blockquote, which can be cascaded +msgid "> ## Comparing in Python" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:102 +msgid ">\n" +"> Along with the `>` and `==` operators we have already used for comparing values in our conditionals, \n" +"> there are a few more options to know about:\n" +">\n" +"> - `>`: greater than\n" +"> - `<`: less than\n" +"> - `==`: equal to\n" +"> - `!=`: does not equal\n" +"> - `>=`: greater than or equal to\n" +"> - `<=`: less than or equal to" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:114 +msgid "We can also combine tests using `and` and `or`.\n" +"`and` is only true if both parts are true:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:117 +# code block +msgid "~~~\n" +"if (1 > 0) and (-1 >= 0):\n" +" print('both parts are true')\n" +"else:\n" +" print('at least one part is false')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:125 +# code block +msgid "~~~\n" +"at least one part is false\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:130 +msgid "while `or` is true if at least one part is true:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:132 +# code block +msgid "~~~\n" +"if (1 < 0) or (1 >= 0):\n" +" print('at least one test is true')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:138 +# code block +msgid "~~~\n" +"at least one test is true\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:143 +# blockquote, which can be cascaded +msgid "> ## `True` and `False`" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:144 +# blockquote, which can be cascaded +msgid "> `True` and `False` are special words in Python called `booleans`," +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:145 +# blockquote, which can be cascaded +msgid "> which represent truth values. A statement such as `1 < 0` returns" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:146 +# blockquote, which can be cascaded +msgid "> the value `False`, while `-1 < 0` returns the value `True`." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:149 +# header +msgid "## Checking our Data" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:151 +msgid "Now that we've seen how conditionals work,\n" +"we can use them to check for the suspicious features we saw in our inflammation data.\n" +"We are about to use functions provided by the `numpy` module again.\n" +"Therefore, if you're working in a new Python session, make sure to load the\n" +"module with:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:162 +msgid "From the first couple of plots, we saw that maximum daily inflammation exhibits\n" +"a strange behavior and raises one unit a day.\n" +"Wouldn't it be a good idea to detect such behavior and report it as suspicious?\n" +"Let's do that!\n" +"However, instead of checking every single day of the study, let's merely check\n" +"if maximum inflammation in the beginning (day 0) and in the middle (day 20) of\n" +"the study are equal to the corresponding day numbers." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:170 +# code block +msgid "~~~\n" +"max_inflammation_0 = numpy.max(data, axis=0)[0]\n" +"max_inflammation_20 = numpy.max(data, axis=0)[20]\n" +"\n" +"if max_inflammation_0 == 0 and max_inflammation_20 == 20:\n" +" print('Suspicious looking maxima!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:179 +msgid "We also saw a different problem in the third dataset;\n" +"the minima per day were all zero (looks like a healthy person snuck into our study).\n" +"We can also check for this with an `elif` condition:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:183 +# code block +msgid "~~~\n" +"elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:189 +msgid "And if neither of these conditions are true, we can use `else` to give the all-clear:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:191 +# code block +msgid "~~~\n" +"else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:197 +msgid "Let's test that out:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:199 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"\n" +"max_inflammation_0 = numpy.max(data, axis=0)[0]\n" +"max_inflammation_20 = numpy.max(data, axis=0)[20]\n" +"\n" +"if max_inflammation_0 == 0 and max_inflammation_20 == 20:\n" +" print('Suspicious looking maxima!')\n" +"elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +"else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:214 +# code block +msgid "~~~\n" +"Suspicious looking maxima!\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:219 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-03.csv', delimiter=',')\n" +"\n" +"max_inflammation_0 = numpy.max(data, axis=0)[0]\n" +"max_inflammation_20 = numpy.max(data, axis=0)[20]\n" +"\n" +"if max_inflammation_0 == 0 and max_inflammation_20 == 20:\n" +" print('Suspicious looking maxima!')\n" +"elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +"else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:234 +# code block +msgid "~~~\n" +"Minima add up to zero!\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:239 +msgid "In this way,\n" +"we have asked Python to do something different depending on the condition of our data.\n" +"Here we printed messages in all cases,\n" +"but we could also imagine not using the `else` catch-all\n" +"so that messages are only printed when something is wrong,\n" +"freeing us from having to manually examine every plot for features we've seen before." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:246 +# blockquote, which can be cascaded +msgid "> ## How Many Paths?" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:247 +msgid ">\n" +"> Consider this code:\n" +">\n" +"> ~~~\n" +"> if 4 > 5:\n" +"> print('A')\n" +"> elif 4 == 5:\n" +"> print('B')\n" +"> elif 4 < 5:\n" +"> print('C')\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Which of the following would be printed if you were to run this code?\n" +"> Why did you pick this answer?\n" +">\n" +"> 1. A\n" +"> 2. B\n" +"> 3. C\n" +"> 4. B and C\n" +">\n" +"> > ## Solution\n" +"> > C gets printed because the first two conditions, `4 > 5` and `4 == 5`, are not true,\n" +"> > but `4 < 5` is true." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:274 +# blockquote, which can be cascaded +msgid "> ## What Is Truth?" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:275 +msgid ">\n" +"> `True` and `False` booleans are not the only values in Python that are true and false.\n" +"> In fact, *any* value can be used in an `if` or `elif`.\n" +"> After reading and running the code below,\n" +"> explain what the rule is for which values are considered true and which are considered false.\n" +">\n" +"> ~~~\n" +"> if '':\n" +"> print('empty string is true')\n" +"> if 'word':\n" +"> print('word is true')\n" +"> if []:\n" +"> print('empty list is true')\n" +"> if [1, 2, 3]:\n" +"> print('non-empty list is true')\n" +"> if 0:\n" +"> print('zero is true')\n" +"> if 1:\n" +"> print('one is true')\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:298 +# blockquote, which can be cascaded +msgid "> ## That's Not Not What I Meant" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:299 +msgid ">\n" +"> Sometimes it is useful to check whether some condition is not true.\n" +"> The Boolean operator `not` can do this explicitly.\n" +"> After reading and running the code below,\n" +"> write some `if` statements that use `not` to test the rule\n" +"> that you formulated in the previous challenge.\n" +">\n" +"> ~~~\n" +"> if not '':\n" +"> print('empty string is not true')\n" +"> if not 'word':\n" +"> print('word is not true')\n" +"> if not not True:\n" +"> print('not not True is true')\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:317 +# blockquote, which can be cascaded +msgid "> ## Close Enough" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:318 +msgid ">\n" +"> Write some conditions that print `True` if the variable `a` is within 10% of the variable `b`\n" +"> and `False` otherwise.\n" +"> Compare your implementation with your partner's:\n" +"> do you get the same answer for all possible pairs of numbers?\n" +">\n" +"> > ## Hint\n" +"> > There is a [built-in function `abs`][abs-function] that returns the absolute value of\n" +"> > a number:\n" +"> > ~~~\n" +"> > print(abs(-12))\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> > ~~~\n" +"> > 12\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:336 +msgid ">\n" +"> > ## Solution 1\n" +"> > ~~~\n" +"> > a = 5\n" +"> > b = 5.1\n" +"> >\n" +"> > if abs(a - b) <= 0.1 * abs(b):\n" +"> > print('True')\n" +"> > else:\n" +"> > print('False')\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:349 +msgid ">\n" +"> > ## Solution 2\n" +"> > ~~~\n" +"> > print(abs(a - b) <= 0.1 * abs(b))\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > This works because the Booleans `True` and `False`\n" +"> > have string representations which can be printed." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:361 +# blockquote, which can be cascaded +msgid "> ## In-Place Operators" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:362 +msgid ">\n" +"> Python (and most other languages in the C family) provides\n" +"> [in-place operators]({{ page.root }}/reference.html#in-place-operators)\n" +"> that work like this:\n" +">\n" +"> ~~~\n" +"> x = 1 # original value\n" +"> x += 1 # add one to x, assigning result back to x\n" +"> x *= 3 # multiply x by 3\n" +"> print(x)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 6\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:379 +msgid ">\n" +"> Write some code that sums the positive and negative numbers in a list separately,\n" +"> using in-place operators.\n" +"> Do you think the result is more or less readable\n" +"> than writing the same without in-place operators?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > positive_sum = 0\n" +"> > negative_sum = 0\n" +"> > test_list = [3, 4, 6, 1, -1, -5, 0, 7, -8]\n" +"> > for num in test_list:\n" +"> > if num > 0:\n" +"> > positive_sum += num\n" +"> > elif num == 0:\n" +"> > pass\n" +"> > else:\n" +"> > negative_sum += num\n" +"> > print(positive_sum, negative_sum)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > Here `pass` means \"don't do anything\".\n" +"> In this particular case, it's not actually needed, since if `num == 0` neither\n" +"> > sum needs to change, but it illustrates the use of `elif` and `pass`." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:407 +# blockquote, which can be cascaded +msgid "> ## Sorting a List Into Buckets" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:408 +msgid ">\n" +"> In our `data` folder, large data sets are stored in files whose names start with\n" +"> \"inflammation-\" and small data sets -- in files whose names start with \"small-\". We\n" +"> also have some other files that we do not care about at this point. We'd like to break all\n" +"> these files into three lists called `large_files`, `small_files`, and `other_files`,\n" +"> respectively.\n" +">\n" +"> Add code to the template below to do this. Note that the string method\n" +"> [`startswith`](https://docs.python.org/3/library/stdtypes.html#str.startswith)\n" +"> returns `True` if and only if the string it is called on starts with the string\n" +"> passed as an argument, that is:\n" +">\n" +"> ~~~\n" +"> 'String'.startswith('Str')\n" +"> ~~~\n" +"> {: .language-python}\n" +"> ~~~\n" +"> True\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:428 +# blockquote, which can be cascaded +msgid "> But" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:430 +# blockquote, which can be cascaded +msgid "> 'String'.startswith('str')" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:434 +# blockquote, which can be cascaded +msgid "> False" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:437 +msgid ">Use the following Python code as your starting point:\n" +"> ~~~\n" +"> filenames = ['inflammation-01.csv',\n" +"> 'myscript.py',\n" +"> 'inflammation-02.csv',\n" +"> 'small-01.csv',\n" +"> 'small-02.csv']\n" +"> large_files = []\n" +"> small_files = []\n" +"> other_files = []\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Your solution should:\n" +">\n" +"> 1. loop over the names of the files\n" +"> 2. figure out which group each filename belongs in\n" +"> 3. append the filename to that list\n" +">\n" +"> In the end the three lists should be:\n" +">\n" +"> ~~~\n" +"> large_files = ['inflammation-01.csv', 'inflammation-02.csv']\n" +"> small_files = ['small-01.csv', 'small-02.csv']\n" +"> other_files = ['myscript.py']\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > for filename in filenames:\n" +"> > if filename.startswith('inflammation-'):\n" +"> > large_files.append(filename)\n" +"> > elif filename.startswith('small-'):\n" +"> > small_files.append(filename)\n" +"> > else:\n" +"> > other_files.append(filename)\n" +"> >\n" +"> > print('large_files:', large_files)\n" +"> > print('small_files:', small_files)\n" +"> > print('other_files:', other_files)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:483 +# blockquote, which can be cascaded +msgid "> ## Counting Vowels" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:484 +msgid ">\n" +"> 1. Write a loop that counts the number of vowels in a character string.\n" +"> 2. Test it on a few individual words and full sentences.\n" +"> 3. Once you are done, compare your solution to your neighbor's.\n" +"> Did you make the same decisions about how to handle the letter 'y'\n" +"> (which some people think is a vowel, and some do not)?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > vowels = 'aeiouAEIOU'\n" +"> > sentence = 'Mary had a little lamb.'\n" +"> > count = 0\n" +"> > for char in sentence:\n" +"> > if char in vowels:\n" +"> > count += 1\n" +"> >\n" +"> > print('The number of vowels in this string is ' + str(count))\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:506 +msgid "[abs-function]: https://docs.python.org/3/library/functions.html#abs" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/11__08-func.md.pot b/transifex/python-novice-inflammation/pot/11__08-func.md.pot new file mode 100644 index 00000000..80b90e0e --- /dev/null +++ b/transifex/python-novice-inflammation/pot/11__08-func.md.pot @@ -0,0 +1,1155 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/08-func.md:1 +# Front Matter +msgid "---\n" +"title: Creating Functions\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I define new functions?\"\n" +"- \"What's the difference between defining and calling a function?\"\n" +"- \"What happens when I call a function?\"\n" +"objectives:\n" +"- \"Define a function that takes parameters.\"\n" +"- \"Return a value from a function.\"\n" +"- \"Test and debug a function.\"\n" +"- \"Set default values for function parameters.\"\n" +"- \"Explain why we should divide programs into small, single-purpose functions.\"\n" +"keypoints:\n" +"- \"Define a function using `def function_name(parameter)`.\"\n" +"- \"The body of a function must be indented.\"\n" +"- \"Call a function using `function_name(value)`.\"\n" +"- \"Numbers are stored as integers or floating-point numbers.\"\n" +"- \"Variables defined within a function can only be seen and used within the body of the function.\"\n" +"- \"If a variable is not defined within the function it is used,\n" +" Python looks for a definition before the function call\"\n" +"- \"Use `help(thing)` to view help for something.\"\n" +"- \"Put docstrings in functions to provide help for that function.\"\n" +"- \"Specify default values for parameters when defining a function using `name=value`\n" +" in the parameter list.\"\n" +"- \"Parameters can be passed by matching based on name, by position,\n" +" or by omitting them (in which case the default value is used).\"\n" +"- \"Put code whose parameters change frequently in a function,\n" +" then call it with different parameter values to customize its behavior.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:33 +msgid "At this point,\n" +"we've written code to draw some interesting features in our inflammation data,\n" +"loop over all our data files to quickly draw these plots for each of them,\n" +"and have Python make decisions based on what it sees in our data.\n" +"But, our code is getting pretty long and complicated;\n" +"what if we had thousands of datasets,\n" +"and didn't want to generate a figure for every single one?\n" +"Commenting out the figure-drawing code is a nuisance.\n" +"Also, what if we want to use that code again,\n" +"on a different dataset or at a different point in our program?\n" +"Cutting and pasting it is going to make our code get very long and very repetitive,\n" +"very quickly.\n" +"We'd like a way to package our code so that it is easier to reuse,\n" +"and Python provides for this by letting us define things called 'functions' ---\n" +"a shorthand way of re-executing longer pieces of code.\n" +"Let's start by defining a function `fahr_to_celsius` that converts temperatures\n" +"from Fahrenheit to Celsius:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:51 +# code block +msgid "~~~\n" +"def fahr_to_celsius(temp):\n" +" return ((temp - 32) * (5/9))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:57 +msgid "![Labeled parts of a Python function definition](../fig/python-function.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:60 +msgid "The function definition opens with the keyword `def` followed by the\n" +"name of the function (`fahr_to_celsius`) and a parenthesized list of parameter names (`temp`). The\n" +"[body]({{ page.root }}/reference.html#body) of the function --- the\n" +"statements that are executed when it runs --- is indented below the\n" +"definition line. The body concludes with a `return` keyword followed by the return value." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:66 +msgid "When we call the function,\n" +"the values we pass to it are assigned to those variables\n" +"so that we can use them inside the function.\n" +"Inside the function,\n" +"we use a [return statement]({{ page.root }}/reference.html#return-statement) to send a result\n" +"back to whoever asked for it." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:73 +msgid "Let's try running our function." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:75 +# code block +msgid "~~~\n" +"fahr_to_celsius(32)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:80 +msgid "This command should call our function, using \"32\" as the input and return the function value." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:82 +msgid "In fact, calling our own function is no different from calling any other function:\n" +"~~~\n" +"print('freezing point of water:', fahr_to_celsius(32), 'C')\n" +"print('boiling point of water:', fahr_to_celsius(212), 'C')\n" +"~~~\n" +"{: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:89 +# code block +msgid "~~~\n" +"freezing point of water: 0.0 C\n" +"boiling point of water: 100.0 C\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:95 +msgid "We've successfully called the function that we defined,\n" +"and we have access to the value that we returned." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:99 +# header +msgid "## Composing Functions" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:101 +msgid "Now that we've seen how to turn Fahrenheit into Celsius,\n" +"we can also write the function to turn Celsius into Kelvin:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:104 +# code block +msgid "~~~\n" +"def celsius_to_kelvin(temp_c):\n" +" return temp_c + 273.15\n" +"\n" +"print('freezing point of water in Kelvin:', celsius_to_kelvin(0.))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:112 +# code block +msgid "~~~\n" +"freezing point of water in Kelvin: 273.15\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:117 +msgid "What about converting Fahrenheit to Kelvin?\n" +"We could write out the formula,\n" +"but we don't need to.\n" +"Instead,\n" +"we can [compose]({{ page.root }}/reference.html#compose) the two functions we have already created:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:123 +# code block +msgid "~~~\n" +"def fahr_to_kelvin(temp_f):\n" +" temp_c = fahr_to_celsius(temp_f)\n" +" temp_k = celsius_to_kelvin(temp_c)\n" +" return temp_k\n" +"\n" +"print('boiling point of water in Kelvin:', fahr_to_kelvin(212.0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:133 +# code block +msgid "~~~\n" +"boiling point of water in Kelvin: 373.15\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:138 +msgid "This is our first taste of how larger programs are built:\n" +"we define basic operations,\n" +"then combine them in ever-larger chunks to get the effect we want.\n" +"Real-life functions will usually be larger than the ones shown here --- typically half a dozen\n" +"to a few dozen lines --- but they shouldn't ever be much longer than that,\n" +"or the next person who reads it won't be able to understand what's going on." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:145 +# header +msgid "## Tidying up" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:147 +msgid "Now that we know how to wrap bits of code up in functions,\n" +"we can make our inflammation analysis easier to read and easier to reuse.\n" +"First, let's make a `visualize` function that generates our plots:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:151 +# code block +msgid "~~~\n" +"def visualize(filename):\n" +"\n" +" data = numpy.loadtxt(fname=filename, delimiter=',')\n" +"\n" +" fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"\n" +" axes1 = fig.add_subplot(1, 3, 1)\n" +" axes2 = fig.add_subplot(1, 3, 2)\n" +" axes3 = fig.add_subplot(1, 3, 3)\n" +"\n" +" axes1.set_ylabel('average')\n" +" axes1.plot(numpy.mean(data, axis=0))\n" +"\n" +" axes2.set_ylabel('max')\n" +" axes2.plot(numpy.max(data, axis=0))\n" +"\n" +" axes3.set_ylabel('min')\n" +" axes3.plot(numpy.min(data, axis=0))\n" +"\n" +" fig.tight_layout()\n" +" matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:176 +msgid "and another function called `detect_problems` that checks for those systematics\n" +"we noticed:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:179 +# code block +msgid "~~~\n" +"def detect_problems(filename):\n" +"\n" +" data = numpy.loadtxt(fname=filename, delimiter=',')\n" +"\n" +" if numpy.max(data, axis=0)[0] == 0 and numpy.max(data, axis=0)[20] == 20:\n" +" print('Suspicious looking maxima!')\n" +" elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +" else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:193 +msgid "Wait! Didn't we forget to specify what both of these functions should return? Well, we didn't.\n" +"In Python, functions are not required to include a `return` statement and can be used for\n" +"the sole purpose of grouping together pieces of code that conceptually do one thing. In such cases,\n" +"function names usually describe what they do, _e.g._ `visualize`, `detect_problems`." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:198 +msgid "Notice that rather than jumbling this code together in one giant `for` loop,\n" +"we can now read and reuse both ideas separately.\n" +"We can reproduce the previous analysis with a much simpler `for` loop:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:202 +# code block +msgid "~~~\n" +"filenames = sorted(glob.glob('inflammation*.csv'))\n" +"\n" +"for filename in filenames[:3]:\n" +" print(filename)\n" +" visualize(filename)\n" +" detect_problems(filename)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:212 +msgid "By giving our functions human-readable names,\n" +"we can more easily read and understand what is happening in the `for` loop.\n" +"Even better, if at some later date we want to use either of those pieces of code again,\n" +"we can do so in a single line." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:217 +# header +msgid "## Testing and Documenting" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:219 +msgid "Once we start putting things in functions so that we can re-use them,\n" +"we need to start testing that those functions are working correctly.\n" +"To see how to do this,\n" +"let's write a function to offset a dataset so that it's mean value\n" +"shifts to a user-defined value:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:225 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value):\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:231 +msgid "We could test this on our actual data,\n" +"but since we don't know what the values ought to be,\n" +"it will be hard to tell if the result was correct.\n" +"Instead,\n" +"let's use NumPy to create a matrix of 0's\n" +"and then offset its values to have a mean value of 3:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:238 +# code block +msgid "~~~\n" +"z = numpy.zeros((2,2))\n" +"print(offset_mean(z, 3))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:244 +#: python-novice-inflammation/_episodes/08-func.md:479 +# code block +msgid "~~~\n" +"[[ 3. 3.]\n" +" [ 3. 3.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:250 +msgid "That looks right,\n" +"so let's try `offset_mean` on our real data:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:253 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"print(offset_mean(data, 0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:259 +# code block +msgid "~~~\n" +"[[-6.14875 -6.14875 -5.14875 ... -3.14875 -6.14875 -6.14875]\n" +" [-6.14875 -5.14875 -4.14875 ... -5.14875 -6.14875 -5.14875]\n" +" [-6.14875 -5.14875 -5.14875 ... -4.14875 -5.14875 -5.14875]\n" +" ...\n" +" [-6.14875 -5.14875 -5.14875 ... -5.14875 -5.14875 -5.14875]\n" +" [-6.14875 -6.14875 -6.14875 ... -6.14875 -4.14875 -6.14875]\n" +" [-6.14875 -6.14875 -5.14875 ... -5.14875 -5.14875 -6.14875]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:270 +msgid "It's hard to tell from the default output whether the result is correct,\n" +"but there are a few tests that we can run to reassure us:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:273 +# code block +msgid "~~~\n" +"print('original min, mean, and max are:', numpy.min(data), numpy.mean(data), numpy.max(data))\n" +"offset_data = offset_mean(data, 0)\n" +"print('min, mean, and max of offset data are:',\n" +" numpy.min(offset_data),\n" +" numpy.mean(offset_data),\n" +" numpy.max(offset_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:283 +# code block +msgid "~~~\n" +"original min, mean, and max are: 0.0 6.14875 20.0\n" +"min, mean, and and max of offset data are: -6.14875 2.84217094304e-16 13.85125\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:289 +msgid "That seems almost right:\n" +"the original mean was about 6.1,\n" +"so the lower bound from zero is now about -6.1.\n" +"The mean of the offset data isn't quite zero --- we'll explore why not in the challenges --- but\n" +"it's pretty close.\n" +"We can even go further and check that the standard deviation hasn't changed:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:296 +# code block +msgid "~~~\n" +"print('std dev before and after:', numpy.std(data), numpy.std(offset_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:301 +# code block +msgid "~~~\n" +"std dev before and after: 4.61383319712 4.61383319712\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:306 +msgid "Those values look the same,\n" +"but we probably wouldn't notice if they were different in the sixth decimal place.\n" +"Let's do this instead:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:310 +# code block +msgid "~~~\n" +"print('difference in standard deviations before and after:',\n" +" numpy.std(data) - numpy.std(offset_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:316 +# code block +msgid "~~~\n" +"difference in standard deviations before and after: -3.5527136788e-15\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:321 +msgid "Again,\n" +"the difference is very small.\n" +"It's still possible that our function is wrong,\n" +"but it seems unlikely enough that we should probably get back to doing our analysis.\n" +"We have one more task first, though:\n" +"we should write some [documentation]({{ page.root }}/reference.html#documentation) for our function\n" +"to remind ourselves later what it's for and how to use it." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:329 +msgid "The usual way to put documentation in software is\n" +"to add [comments]({{ page.root }}/reference.html#comment) like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:332 +# code block +msgid "~~~\n" +"# offset_mean(data, target_mean_value):\n" +"# return a new array containing the original data with its mean offset to match the desired value.\n" +"def offset_mean(data, target_mean_value):\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:340 +msgid "There's a better way, though.\n" +"If the first thing in a function is a string that isn't assigned to a variable,\n" +"that string is attached to the function as its documentation:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:344 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value):\n" +" \"\"\"Return a new array containing the original data\n" +" with its mean offset to match the desired value.\"\"\"\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:352 +msgid "This is better because we can now ask Python's built-in help system to show us\n" +"the documentation for the function:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:355 +# code block +msgid "~~~\n" +"help(offset_mean)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:360 +# code block +msgid "~~~\n" +"Help on function offset_mean in module __main__:\n" +"\n" +"offset_mean(data, target_mean_value)\n" +" Return a new array containing the original data with its mean offset to match the desired value.\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:368 +msgid "A string like this is called a [docstring]({{ page.root }}/reference.html#docstring).\n" +"We don't need to use triple quotes when we write one,\n" +"but if we do,\n" +"we can break the string across multiple lines:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:373 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value):\n" +" \"\"\"Return a new array containing the original data\n" +" with its mean offset to match the desired value.\n" +"\n" +" Examples\n" +" --------\n" +" >>> offset_mean([1, 2, 3], 0)\n" +" array([-1., 0., 1.])\n" +" \"\"\"\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"\n" +"help(offset_mean)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:389 +# code block +msgid "~~~\n" +"Help on function offset_mean in module __main__:\n" +"\n" +"offset_mean(data, target_mean_value)\n" +" Return a new array containing the original data\n" +" with its mean offset to match the desired value.\n" +"\n" +" Examples\n" +" --------\n" +" >>> offset_mean([1, 2, 3], 0)\n" +" array([-1., 0., 1.])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:403 +# header +msgid "## Defining Defaults" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:405 +msgid "We have passed parameters to functions in two ways:\n" +"directly, as in `type(data)`,\n" +"and by name, as in `numpy.loadtxt(fname='something.csv', delimiter=',')`.\n" +"In fact,\n" +"we can pass the filename to `loadtxt` without the `fname=`:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:411 +# code block +msgid "~~~\n" +"numpy.loadtxt('inflammation-01.csv', delimiter=',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:427 +msgid "but we still need to say `delimiter=`:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:429 +#: python-novice-inflammation/_episodes/08-func.md:591 +# code block +msgid "~~~\n" +"numpy.loadtxt('inflammation-01.csv', ',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:434 +# code block +msgid "~~~\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"/Users/username/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py\", line 1041, in loa\n" +"dtxt\n" +" dtype = np.dtype(dtype)\n" +" File \"/Users/username/anaconda3/lib/python3.6/site-packages/numpy/core/_internal.py\", line 199, in\n" +"_commastring\n" +" newitem = (dtype, eval(repeats))\n" +" File \"\", line 1\n" +" ,\n" +" ^\n" +"SyntaxError: unexpected EOF while parsing\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:450 +msgid "To understand what's going on,\n" +"and make our own functions easier to use,\n" +"let's re-define our `offset_mean` function like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:454 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value=0.0):\n" +" \"\"\"Return a new array containing the original data\n" +" with its mean offset to match the desired value, (0 by default).\n" +"\n" +" Examples\n" +" --------\n" +" >>> offset_mean([1, 2, 3])\n" +" array([-1., 0., 1.])\n" +" \"\"\"\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:468 +msgid "The key change is that the second parameter is now written `target_mean_value=0.0`\n" +"instead of just `target_mean_value`.\n" +"If we call the function with two arguments,\n" +"it works as it did before:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:473 +# code block +msgid "~~~\n" +"test_data = numpy.zeros((2, 2))\n" +"print(offset_mean(test_data, 3))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:485 +msgid "But we can also now call it with just one parameter,\n" +"in which case `target_mean_value` is automatically assigned\n" +"the [default value]({{ page.root }}/reference.html#default-value) of 0.0:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:489 +# code block +msgid "~~~\n" +"more_data = 5 + numpy.zeros((2, 2))\n" +"print('data before mean offset:')\n" +"print(more_data)\n" +"print('offset data:')\n" +"print(offset_mean(more_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:498 +# code block +msgid "~~~\n" +"data before mean offset:\n" +"[[ 5. 5.]\n" +" [ 5. 5.]]\n" +"offset data:\n" +"[[ 0. 0.]\n" +" [ 0. 0.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:508 +msgid "This is handy:\n" +"if we usually want a function to work one way,\n" +"but occasionally need it to do something else,\n" +"we can allow people to pass a parameter when they need to\n" +"but provide a default to make the normal case easier.\n" +"The example below shows how Python matches values to parameters:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:515 +# code block +msgid "~~~\n" +"def display(a=1, b=2, c=3):\n" +" print('a:', a, 'b:', b, 'c:', c)\n" +"\n" +"print('no parameters:')\n" +"display()\n" +"print('one parameter:')\n" +"display(55)\n" +"print('two parameters:')\n" +"display(55, 66)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:528 +# code block +msgid "~~~\n" +"no parameters:\n" +"a: 1 b: 2 c: 3\n" +"one parameter:\n" +"a: 55 b: 2 c: 3\n" +"two parameters:\n" +"a: 55 b: 66 c: 3\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:538 +msgid "As this example shows,\n" +"parameters are matched up from left to right,\n" +"and any that haven't been given a value explicitly get their default value.\n" +"We can override this behavior by naming the value as we pass it in:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:543 +# code block +msgid "~~~\n" +"print('only setting the value of c')\n" +"display(c=77)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:549 +# code block +msgid "~~~\n" +"only setting the value of c\n" +"a: 1 b: 2 c: 77\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:555 +msgid "With that in hand,\n" +"let's look at the help for `numpy.loadtxt`:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:558 +# code block +msgid "~~~\n" +"help(numpy.loadtxt)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:563 +# code block +msgid "~~~\n" +"Help on function loadtxt in module numpy.lib.npyio:\n" +"\n" +"loadtxt(fname, dtype=, comments='#', delimiter=None, converters=None, skiprows=0, use\n" +"cols=None, unpack=False, ndmin=0, encoding='bytes')\n" +" Load data from a text file.\n" +"\n" +" Each row in the text file must have the same number of values.\n" +"\n" +" Parameters\n" +" ----------\n" +"...\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:578 +msgid "There's a lot of information here,\n" +"but the most important part is the first couple of lines:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:581 +# code block +msgid "~~~\n" +"loadtxt(fname, dtype=, comments='#', delimiter=None, converters=None, skiprows=0, use\n" +"cols=None, unpack=False, ndmin=0, encoding='bytes')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:587 +msgid "This tells us that `loadtxt` has one parameter called `fname` that doesn't have a default value,\n" +"and eight others that do.\n" +"If we call the function like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:596 +msgid "then the filename is assigned to `fname` (which is what we want),\n" +"but the delimiter string `','` is assigned to `dtype` rather than `delimiter`,\n" +"because `dtype` is the second parameter in the list. However `','` isn't a known `dtype` so\n" +"our code produced an error message when we tried to run it.\n" +"When we call `loadtxt` we don't have to provide `fname=` for the filename because it's the\n" +"first item in the list, but if we want the `','` to be assigned to the variable `delimiter`,\n" +"we *do* have to provide `delimiter=` for the second parameter since `delimiter` is not\n" +"the second parameter in the list." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:605 +# header +msgid "## Readable functions" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:607 +msgid "Consider these two functions:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:609 +# code block +msgid "~~~\n" +"def s(p):\n" +" a = 0\n" +" for v in p:\n" +" a += v\n" +" m = a / len(p)\n" +" d = 0\n" +" for v in p:\n" +" d += (v - m) * (v - m)\n" +" return numpy.sqrt(d / (len(p) - 1))\n" +"\n" +"def std_dev(sample):\n" +" sample_sum = 0\n" +" for value in sample:\n" +" sample_sum += value\n" +"\n" +" sample_mean = sample_sum / len(sample)\n" +"\n" +" sum_squared_devs = 0\n" +" for value in sample:\n" +" sum_squared_devs += (value - sample_mean) * (value - sample_mean)\n" +"\n" +" return numpy.sqrt(sum_squared_devs / (len(sample) - 1))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:635 +msgid "The functions `s` and `std_dev` are computationally equivalent (they\n" +"both calculate the sample standard deviation), but to a human reader,\n" +"they look very different. You probably found `std_dev` much easier to\n" +"read and understand than `s`." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:640 +msgid "As this example illustrates, both documentation and a programmer's\n" +"_coding style_ combine to determine how easy it is for others to read\n" +"and understand the programmer's code. Choosing meaningful variable\n" +"names and using blank spaces to break the code into logical \"chunks\"\n" +"are helpful techniques for producing _readable code_. This is useful\n" +"not only for sharing code with others, but also for the original\n" +"programmer. If you need to revisit code that you wrote months ago and\n" +"haven't thought about since then, you will appreciate the value of\n" +"readable code!" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:650 +# blockquote, which can be cascaded +msgid "> ## Combining Strings" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:651 +msgid ">\n" +"> \"Adding\" two strings produces their concatenation:\n" +"> `'a' + 'b'` is `'ab'`.\n" +"> Write a function called `fence` that takes two parameters called `original` and `wrapper`\n" +"> and returns a new string that has the wrapper character at the beginning and end of the original.\n" +"> A call to your function should look like this:\n" +">\n" +"> ~~~\n" +"> print(fence('name', '*'))\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> *name*\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:667 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def fence(original, wrapper):\n" +"> > return wrapper + original + wrapper\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:677 +# blockquote, which can be cascaded +msgid "> ## Return versus print" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:678 +msgid ">\n" +"> Note that `return` and `print` are not interchangeable.\n" +"> `print` is a Python function that *prints* data to the screen.\n" +"> It enables us, *users*, see the data.\n" +"> `return` statement, on the other hand, makes data visible to the program.\n" +"> Let's have a look at the following function:\n" +">\n" +"> ~~~\n" +"> def add(a, b):\n" +"> print(a + b)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> **Question**: What will we see if we execute the following commands?\n" +"> ~~~\n" +"> A = add(7, 3)\n" +"> print(A)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > Python will first execute the function `add` with `a = 7` and `b = 3`,\n" +"> > and, therefore, print `10`. However, because function `add` does not have a\n" +"> > line that starts with `return` (no `return` \"statement\"), it will, by default, return\n" +"> > nothing which, in Python world, is called `None`. Therefore, `A` will be assigned to `None`\n" +"> > and the last line (`print(A)`) will print `None`. As a result, we will see:\n" +"> > ~~~\n" +"> > 10\n" +"> > None\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:712 +# blockquote, which can be cascaded +msgid "> ## Selecting Characters From Strings" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:713 +msgid ">\n" +"> If the variable `s` refers to a string,\n" +"> then `s[0]` is the string's first character\n" +"> and `s[-1]` is its last.\n" +"> Write a function called `outer`\n" +"> that returns a string made up of just the first and last characters of its input.\n" +"> A call to your function should look like this:\n" +">\n" +"> ~~~\n" +"> print(outer('helium'))\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> hm\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:730 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def outer(input_string):\n" +"> > return input_string[0] + input_string[-1]\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:740 +# blockquote, which can be cascaded +msgid "> ## Rescaling an Array" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:741 +msgid ">\n" +"> Write a function `rescale` that takes an array as input\n" +"> and returns a corresponding array of values scaled to lie in the range 0.0 to 1.0.\n" +"> (Hint: If `L` and `H` are the lowest and highest values in the original array,\n" +"> then the replacement for a value `v` should be `(v-L) / (H-L)`.)\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def rescale(input_array):\n" +"> > L = numpy.min(input_array)\n" +"> > H = numpy.max(input_array)\n" +"> > output_array = (input_array - L) / (H - L)\n" +"> > return output_array\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:759 +# blockquote, which can be cascaded +msgid "> ## Testing and Documenting Your Function" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:760 +msgid ">\n" +"> Run the commands `help(numpy.arange)` and `help(numpy.linspace)`\n" +"> to see how to use these functions to generate regularly-spaced values,\n" +"> then use those values to test your `rescale` function.\n" +"> Once you've successfully tested your function,\n" +"> add a docstring that explains what it does.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > \"\"\"Takes an array as input, and returns a corresponding array scaled so\n" +"> > that 0 corresponds to the minimum and 1 to the maximum value of the input array.\n" +"> >\n" +"> > Examples:\n" +"> > >>> rescale(numpy.arange(10.0))\n" +"> > array([ 0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444,\n" +"> > 0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ])\n" +"> > >>> rescale(numpy.linspace(0, 100, 5))\n" +"> > array([ 0. , 0.25, 0.5 , 0.75, 1. ])\n" +"> > \"\"\"\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:784 +# blockquote, which can be cascaded +msgid "> ## Defining Defaults" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:785 +msgid ">\n" +"> Rewrite the `rescale` function so that it scales data to lie between `0.0` and `1.0` by default,\n" +"> but will allow the caller to specify lower and upper bounds if they want.\n" +"> Compare your implementation to your neighbor's:\n" +"> do the two functions always behave the same way?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def rescale(input_array, low_val=0.0, high_val=1.0):\n" +"> > \"\"\"rescales input array values to lie between low_val and high_val\"\"\"\n" +"> > L = numpy.min(input_array)\n" +"> > H = numpy.max(input_array)\n" +"> > intermed_array = (input_array - L) / (H - L)\n" +"> > output_array = intermed_array * (high_val - low_val) + low_val\n" +"> > return output_array\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:805 +# blockquote, which can be cascaded +msgid "> ## Variables Inside and Outside Functions" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:806 +msgid ">\n" +"> What does the following piece of code display when run --- and why?\n" +">\n" +"> ~~~\n" +"> f = 0\n" +"> k = 0\n" +">\n" +"> def f2k(f):\n" +"> k = ((f - 32) * (5.0 / 9.0)) + 273.15\n" +"> return k\n" +">\n" +"> print(f2k(8))\n" +"> print(f2k(41))\n" +"> print(f2k(32))\n" +">\n" +"> print(k)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > ~~~\n" +"> > 259.81666666666666\n" +"> > 278.15\n" +"> > 273.15\n" +"> > 0\n" +"> > ~~~\n" +"> > {: .output}\n" +"> > `k` is 0 because the `k` inside the function `f2k` doesn't know\n" +"> > about the `k` defined outside the function." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:839 +# blockquote, which can be cascaded +msgid "> ## Mixing Default and Non-Default Parameters" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:840 +msgid ">\n" +"> Given the following code:\n" +">\n" +"> ~~~\n" +"> def numbers(one, two=2, three, four=4):\n" +"> n = str(one) + str(two) + str(three) + str(four)\n" +"> return n\n" +">\n" +"> print(numbers(1, three=3))\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> what do you expect will be printed? What is actually printed?\n" +"> What rule do you think Python is following?\n" +">\n" +"> 1. `1234`\n" +"> 2. `one2three4`\n" +"> 3. `1239`\n" +"> 4. `SyntaxError`\n" +">\n" +"> Given that, what does the following piece of code display when run?\n" +">\n" +"> ~~~\n" +"> def func(a, b=3, c=6):\n" +"> print('a: ', a, 'b: ', b, 'c:', c)\n" +">\n" +"> func(-1, 2)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> 1. `a: b: 3 c: 6`\n" +"> 2. `a: -1 b: 3 c: 6`\n" +"> 3. `a: -1 b: 2 c: 6`\n" +"> 4. `a: b: -1 c: 2`\n" +">\n" +"> > ## Solution\n" +"> > Attempting to define the `numbers` function results in `4. SyntaxError`.\n" +"> > The defined parameters `two` and `four` are given default values. Because\n" +"> > `one` and `three` are not given default values, they are required to be\n" +"> > included as arguments when the function is called and must be placed\n" +"> > before any parameters that have default values in the function definition.\n" +"> >\n" +"> > The given call to `func` displays `a: -1 b: 2 c: 6`. -1 is assigned to\n" +"> > the first parameter `a`, 2 is assigned to the next parameter `b`, and `c` is\n" +"> > not passed a value, so it uses its default value 6." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:888 +# blockquote, which can be cascaded +msgid "> ## The Old Switcheroo" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:889 +msgid ">\n" +"> Consider this code:\n" +">\n" +"> ~~~\n" +"> a = 3\n" +"> b = 7\n" +">\n" +"> def swap(a, b):\n" +"> temp = a\n" +"> a = b\n" +"> b = temp\n" +">\n" +"> swap(a, b)\n" +">\n" +"> print(a, b)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Which of the following would be printed if you were to run this code?\n" +"> Why did you pick this answer?\n" +">\n" +"> 1. `7 3`\n" +"> 2. `3 7`\n" +"> 3. `3 3`\n" +"> 4. `7 7`\n" +">\n" +"> > ## Solution\n" +"> > `3 7` is the correct answer. Initially, `a` has a value of 3 and `b` has a value of 7.\n" +"> > When the `swap` function is called, it creates local variables (also called\n" +"> > `a` and `b` in this case) and trades their values. The function does not\n" +"> > return any values and does not alter `a` or `b` outside of its local copy.\n" +"> > Therefore the original values of `a` and `b` remain unchanged." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:924 +# blockquote, which can be cascaded +msgid "> ## Readable Code" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:925 +msgid ">\n" +"> Revise a function you wrote for one of the previous exercises to try to make\n" +"> the code more readable. Then, collaborate with one of your neighbors\n" +"> to critique each other's functions and discuss how your function implementations\n" +"> could be further improved to make them more readable." +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/12__09-errors.md.pot b/transifex/python-novice-inflammation/pot/12__09-errors.md.pot new file mode 100644 index 00000000..f00f3ace --- /dev/null +++ b/transifex/python-novice-inflammation/pot/12__09-errors.md.pot @@ -0,0 +1,762 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/09-errors.md:1 +# Front Matter +msgid "---\n" +"title: Errors and Exceptions\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How does Python report errors?\"\n" +"- \"How can I handle errors in Python programs?\"\n" +"objectives:\n" +"- \"To be able to read a traceback, and determine where the error took place and what type it is.\"\n" +"- \"To be able to describe the types of situations in which syntax errors,\n" +" indentation errors, name errors, index errors, and missing file errors occur.\"\n" +"keypoints:\n" +"- \"Tracebacks can look intimidating, but they give us a lot of useful information about\n" +" what went wrong in our program, including where the error occurred and\n" +" what type of error it was.\"\n" +"- \"An error having to do with the 'grammar' or syntax of the program is called a `SyntaxError`.\n" +" If the issue has to do with how the code is indented,\n" +" then it will be called an `IndentationError`.\"\n" +"- \"A `NameError` will occur when trying to use a variable that does not exist. Possible causes are\n" +" that a variable definition is missing, a variable reference differs from its definition\n" +" in spelling or capitalization, or the code contains a string that is missing quotes around it.\"\n" +"- \"Containers like lists and strings will generate errors if you try to access items\n" +" in them that do not exist. This type of error is called an `IndexError`.\"\n" +"- \"Trying to read a file that does not exist will give you an `FileNotFoundError`.\n" +" Trying to read a file that is open for writing, or writing to a file that is open for reading,\n" +" will give you an `IOError`.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:29 +msgid "Every programmer encounters errors,\n" +"both those who are just beginning,\n" +"and those who have been programming for years.\n" +"Encountering errors and exceptions can be very frustrating at times,\n" +"and can make coding feel like a hopeless endeavour.\n" +"However,\n" +"understanding what the different types of errors are\n" +"and when you are likely to encounter them can help a lot.\n" +"Once you know *why* you get certain types of errors,\n" +"they become much easier to fix." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:40 +msgid "Errors in Python have a very specific form,\n" +"called a [traceback]({{ page.root }}/reference.html#traceback).\n" +"Let's examine one:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:44 +# code block +msgid "~~~\n" +"# This code has an intentional error. You can type it directly or\n" +"# use it for reference to understand the error message below.\n" +"def favorite_ice_cream():\n" +" ice_creams = [\n" +" 'chocolate',\n" +" 'vanilla',\n" +" 'strawberry'\n" +" ]\n" +" print(ice_creams[3])\n" +"\n" +"favorite_ice_cream()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:59 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"IndexError Traceback (most recent call last)\n" +" in ()\n" +" 9 print(ice_creams[3])\n" +" 10\n" +"----> 11 favorite_ice_cream()\n" +"\n" +" in favorite_ice_cream()\n" +" 7 'strawberry'\n" +" 8 ]\n" +"----> 9 print(ice_creams[3])\n" +" 10\n" +" 11 favorite_ice_cream()\n" +"\n" +"IndexError: list index out of range\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:78 +msgid "This particular traceback has two levels.\n" +"You can determine the number of levels by looking for the number of arrows on the left hand side.\n" +"In this case:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:82 +# ordered list +msgid "1. The first shows code from the cell above," +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:83 +msgid " with an arrow pointing to Line 11 (which is `favorite_ice_cream()`)." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:85 +# ordered list +msgid "2. The second shows some code in the function `favorite_ice_cream`," +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:86 +msgid " with an arrow pointing to Line 9 (which is `print(ice_creams[3])`)." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:88 +msgid "The last level is the actual place where the error occurred.\n" +"The other level(s) show what function the program executed to get to the next level down.\n" +"So, in this case, the program first performed a\n" +"[function call]({{ page.root }}/reference.html#function-call) to the function `favorite_ice_cream`.\n" +"Inside this function,\n" +"the program encountered an error on Line 6, when it tried to run the code `print(ice_creams[3])`." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:95 +# blockquote, which can be cascaded +msgid "> ## Long Tracebacks" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:96 +msgid ">\n" +"> Sometimes, you might see a traceback that is very long\n" +"> -- sometimes they might even be 20 levels deep!\n" +"> This can make it seem like something horrible happened,\n" +"> but the length of the error message does not reflect severity, rather,\n" +"> it indicates that your program called many functions before it encountered the error.\n" +"> Most of the time, the actual place where the error occurred is at the bottom-most level,\n" +"> so you can skip down the traceback to the bottom." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:106 +msgid "So what error did the program actually encounter?\n" +"In the last line of the traceback,\n" +"Python helpfully tells us the category or type of error (in this case, it is an `IndexError`)\n" +"and a more detailed error message (in this case, it says \"list index out of range\")." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:111 +msgid "If you encounter an error and don't know what it means,\n" +"it is still important to read the traceback closely.\n" +"That way,\n" +"if you fix the error,\n" +"but encounter a new one,\n" +"you can tell that the error changed.\n" +"Additionally,\n" +"sometimes knowing *where* the error occurred is enough to fix it,\n" +"even if you don't entirely understand the message." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:121 +msgid "If you do encounter an error you don't recognize,\n" +"try looking at the\n" +"[official documentation on errors](http://docs.python.org/3/library/exceptions.html).\n" +"However,\n" +"note that you may not always be able to find the error there,\n" +"as it is possible to create custom errors.\n" +"In that case,\n" +"hopefully the custom error message is informative enough to help you figure out what went wrong." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:130 +# header +msgid "## Syntax Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:132 +msgid "When you forget a colon at the end of a line,\n" +"accidentally add one space too many when indenting under an `if` statement,\n" +"or forget a parenthesis,\n" +"you will encounter a [syntax error]({{ page.root }}/reference.html#syntax-error).\n" +"This means that Python couldn't figure out how to read your program.\n" +"This is similar to forgetting punctuation in English:\n" +"for example,\n" +"this text is difficult to read there is no punctuation there is also no capitalization\n" +"why is this hard because you have to figure out where each sentence ends\n" +"you also have to figure out where each sentence begins\n" +"to some extent it might be ambiguous if there should be a sentence break or not" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:144 +msgid "People can typically figure out what is meant by text with no punctuation,\n" +"but people are much smarter than computers.\n" +"If Python doesn't know how to read the program,\n" +"it will give up and inform you with an error.\n" +"For example:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:150 +# code block +msgid "~~~\n" +"def some_function()\n" +" msg = 'hello, world!'\n" +" print(msg)\n" +" return msg\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:158 +# code block +msgid "~~~\n" +" File \"\", line 1\n" +" def some_function()\n" +" ^\n" +"SyntaxError: invalid syntax\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:166 +msgid "Here, Python tells us that there is a `SyntaxError` on line 1,\n" +"and even puts a little arrow in the place where there is an issue.\n" +"In this case the problem is that the function definition is missing a colon at the end." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:170 +msgid "Actually, the function above has *two* issues with syntax.\n" +"If we fix the problem with the colon,\n" +"we see that there is *also* an `IndentationError`,\n" +"which means that the lines in the function definition do not all have the same indentation:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:175 +# code block +msgid "~~~\n" +"def some_function():\n" +" msg = 'hello, world!'\n" +" print(msg)\n" +" return msg\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:183 +# code block +msgid "~~~\n" +" File \"\", line 4\n" +" return msg\n" +" ^\n" +"IndentationError: unexpected indent\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:191 +msgid "Both `SyntaxError` and `IndentationError` indicate a problem with the syntax of your program,\n" +"but an `IndentationError` is more specific:\n" +"it *always* means that there is a problem with how your code is indented." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:195 +# blockquote, which can be cascaded +msgid "> ## Tabs and Spaces" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:196 +msgid ">\n" +"> Some indentation errors are harder to spot than others.\n" +"> In particular, mixing spaces and tabs can be difficult to spot\n" +"> because they are both [whitespace]({{ page.root }}/reference.html#whitespace).\n" +"> In the example below, the first two lines in the body of the function\n" +"> `some_function` are indented with tabs, while the third line — with spaces.\n" +"> If you're working in a Jupyter notebook, be sure to copy and paste this example\n" +"> rather than trying to type it in manually because Jupyter automatically replaces\n" +"> tabs with spaces.\n" +">\n" +"> ~~~\n" +"> def some_function():\n" +"> msg = 'hello, world!'\n" +"> print(msg)\n" +"> return msg\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Visually it is impossible to spot the error.\n" +"> Fortunately, Python does not allow you to mix tabs and spaces.\n" +">\n" +"> ~~~\n" +"> File \"\", line 4\n" +"> return msg\n" +"> ^\n" +"> TabError: inconsistent use of tabs and spaces in indentation\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:223 +#: python-novice-inflammation/_episodes/09-errors.md:491 +# SC/DC Template label +msgid "> {: .error}" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:226 +# header +msgid "## Variable Name Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:228 +msgid "Another very common type of error is called a `NameError`,\n" +"and occurs when you try to use a variable that does not exist.\n" +"For example:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:232 +# code block +msgid "~~~\n" +"print(a)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:237 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 print(a)\n" +"\n" +"NameError: name 'a' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:247 +msgid "Variable name errors come with some of the most informative error messages,\n" +"which are usually of the form \"name 'the_variable_name' is not defined\"." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:250 +msgid "Why does this error message occur?\n" +"That's a harder question to answer,\n" +"because it depends on what your code is supposed to do.\n" +"However,\n" +"there are a few very common reasons why you might have an undefined variable.\n" +"The first is that you meant to use a\n" +"[string]({{ page.root }}/reference.html#string), but forgot to put quotes around it:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:258 +# code block +msgid "~~~\n" +"print(hello)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:263 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 print(hello)\n" +"\n" +"NameError: name 'hello' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:273 +msgid "The second reason is that you might be trying to use a variable that does not yet exist.\n" +"In the following example,\n" +"`count` should have been defined (e.g., with `count = 0`) before the for loop:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:277 +# code block +msgid "~~~\n" +"for number in range(10):\n" +" count = count + number\n" +"print('The count is:', count)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:284 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +" 1 for number in range(10):\n" +"----> 2 count = count + number\n" +" 3 print('The count is:', count)\n" +"\n" +"NameError: name 'count' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:296 +msgid "Finally, the third possibility is that you made a typo when you were writing your code.\n" +"Let's say we fixed the error above by adding the line `Count = 0` before the for loop.\n" +"Frustratingly, this actually does not fix the error.\n" +"Remember that variables are [case-sensitive]({{ page.root }}/reference.html#case-sensitive),\n" +"so the variable `count` is different from `Count`. We still get the same error,\n" +"because we still have not defined `count`:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:303 +# code block +msgid "~~~\n" +"Count = 0\n" +"for number in range(10):\n" +" count = count + number\n" +"print('The count is:', count)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:311 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +" 1 Count = 0\n" +" 2 for number in range(10):\n" +"----> 3 count = count + number\n" +" 4 print('The count is:', count)\n" +"\n" +"NameError: name 'count' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:324 +# header +msgid "## Index Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:326 +msgid "Next up are errors having to do with containers (like lists and strings) and the items within them.\n" +"If you try to access an item in a list or a string that does not exist,\n" +"then you will get an error.\n" +"This makes sense:\n" +"if you asked someone what day they would like to get coffee,\n" +"and they answered \"caturday\",\n" +"you might be a bit annoyed.\n" +"Python gets similarly annoyed if you try to ask it for an item that doesn't exist:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:335 +# code block +msgid "~~~\n" +"letters = ['a', 'b', 'c']\n" +"print('Letter #1 is', letters[0])\n" +"print('Letter #2 is', letters[1])\n" +"print('Letter #3 is', letters[2])\n" +"print('Letter #4 is', letters[3])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:344 +# code block +msgid "~~~\n" +"Letter #1 is a\n" +"Letter #2 is b\n" +"Letter #3 is c\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:351 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"IndexError Traceback (most recent call last)\n" +" in ()\n" +" 3 print('Letter #2 is', letters[1])\n" +" 4 print('Letter #3 is', letters[2])\n" +"----> 5 print('Letter #4 is', letters[3])\n" +"\n" +"IndexError: list index out of range\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:363 +msgid "Here,\n" +"Python is telling us that there is an `IndexError` in our code,\n" +"meaning we tried to access a list index that did not exist." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:367 +# header +msgid "## File Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:369 +msgid "The last type of error we'll cover today\n" +"are those associated with reading and writing files: `FileNotFoundError`.\n" +"If you try to read a file that does not exist,\n" +"you will receive a `FileNotFoundError` telling you so.\n" +"If you attempt to write to a file that was opened read-only, Python 3\n" +"returns an `UnsupportedOperationError`.\n" +"More generally, problems with input and output manifest as\n" +"`IOError`s or `OSError`s, depending on the version of Python you use." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:378 +# code block +msgid "~~~\n" +"file_handle = open('myfile.txt', 'r')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:383 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"FileNotFoundError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 file_handle = open('myfile.txt', 'r')\n" +"\n" +"FileNotFoundError: [Errno 2] No such file or directory: 'myfile.txt'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:393 +msgid "One reason for receiving this error is that you specified an incorrect path to the file.\n" +"For example,\n" +"if I am currently in a folder called `myproject`,\n" +"and I have a file in `myproject/writing/myfile.txt`,\n" +"but I try to open `myfile.txt`,\n" +"this will fail.\n" +"The correct path would be `writing/myfile.txt`.\n" +"It is also possible that the file name or its path contains a typo." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:402 +msgid "A related issue can occur if you use the \"read\" flag instead of the \"write\" flag.\n" +"Python will not give you an error if you try to open a file for writing\n" +"when the file does not exist.\n" +"However,\n" +"if you meant to open a file for reading,\n" +"but accidentally opened it for writing,\n" +"and then try to read from it,\n" +"you will get an `UnsupportedOperation` error\n" +"telling you that the file was not opened for reading:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:412 +# code block +msgid "~~~\n" +"file_handle = open('myfile.txt', 'w')\n" +"file_handle.read()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:418 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"UnsupportedOperation Traceback (most recent call last)\n" +" in ()\n" +" 1 file_handle = open('myfile.txt', 'w')\n" +"----> 2 file_handle.read()\n" +"\n" +"UnsupportedOperation: not readable\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:429 +msgid "These are the most common errors with files,\n" +"though many others exist.\n" +"If you get an error that you've never seen before,\n" +"searching the Internet for that error type\n" +"often reveals common reasons why you might get that error." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:435 +# blockquote, which can be cascaded +msgid "> ## Reading Error Messages" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:436 +msgid ">\n" +"> Read the Python code and the resulting traceback below, and answer the following questions:\n" +">\n" +"> 1. How many levels does the traceback have?\n" +"> 2. What is the function name where the error occurred?\n" +"> 3. On which line number in this function did the error occur?\n" +"> 4. What is the type of error?\n" +"> 5. What is the error message?\n" +">\n" +"> ~~~\n" +"> # This code has an intentional error. Do not type it directly;\n" +"> # use it for reference to understand the error message below.\n" +"> def print_message(day):\n" +"> messages = {\n" +"> 'monday': 'Hello, world!',\n" +"> 'tuesday': 'Today is Tuesday!',\n" +"> 'wednesday': 'It is the middle of the week.',\n" +"> 'thursday': 'Today is Donnerstag in German!',\n" +"> 'friday': 'Last day of the week!',\n" +"> 'saturday': 'Hooray for the weekend!',\n" +"> 'sunday': 'Aw, the weekend is almost over.'\n" +"> }\n" +"> print(messages[day])\n" +">\n" +"> def print_friday_message():\n" +"> print_message('Friday')\n" +">\n" +"> print_friday_message()\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> ---------------------------------------------------------------------------\n" +"> KeyError Traceback (most recent call last)\n" +"> in ()\n" +"> 14 print_message('Friday')\n" +"> 15\n" +"> ---> 16 print_friday_message()\n" +">\n" +"> in print_friday_message()\n" +"> 12\n" +"> 13 def print_friday_message():\n" +"> ---> 14 print_message('Friday')\n" +"> 15\n" +"> 16 print_friday_message()\n" +">\n" +"> in print_message(day)\n" +"> 9 'sunday': 'Aw, the weekend is almost over.'\n" +"> 10 }\n" +"> ---> 11 print(messages[day])\n" +"> 12\n" +"> 13 def print_friday_message():\n" +">\n" +"> KeyError: 'Friday'\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:492 +msgid ">\n" +"> > ## Solution\n" +"> > 1. 3 levels\n" +"> > 2. `print_message`\n" +"> > 3. 11\n" +"> > 4. `KeyError`\n" +"> > 5. There isn't really a message; you're supposed to infer that `Friday` is not a key in `messages`." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:502 +# blockquote, which can be cascaded +msgid "> ## Identifying Syntax Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:503 +msgid ">\n" +"> 1. Read the code below, and (without running it) try to identify what the errors are.\n" +"> 2. Run the code, and read the error message. Is it a `SyntaxError` or an `IndentationError`?\n" +"> 3. Fix the error.\n" +"> 4. Repeat steps 2 and 3, until you have fixed all the errors.\n" +">\n" +"> ~~~\n" +"> def another_function\n" +"> print('Syntax errors are annoying.')\n" +"> print('But at least Python tells us about them!')\n" +"> print('So they are usually not too hard to fix.')\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > `SyntaxError` for missing `():` at end of first line,\n" +"> `IndentationError` for mismatch between second and third lines.\n" +"> > A fixed version is:\n" +"> >\n" +"> > ~~~\n" +"> > def another_function():\n" +"> > print('Syntax errors are annoying.')\n" +"> > print('But at least Python tells us about them!')\n" +"> > print('So they are usually not too hard to fix.')\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:532 +# blockquote, which can be cascaded +msgid "> ## Identifying Variable Name Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:533 +msgid ">\n" +"> 1. Read the code below, and (without running it) try to identify what the errors are.\n" +"> 2. Run the code, and read the error message.\n" +"> What type of `NameError` do you think this is?\n" +"> In other words, is it a string with no quotes,\n" +"> a misspelled variable,\n" +"> or a variable that should have been defined but was not?\n" +"> 3. Fix the error.\n" +"> 4. Repeat steps 2 and 3, until you have fixed all the errors.\n" +">\n" +"> ~~~\n" +"> for number in range(10):\n" +"> # use a if the number is a multiple of 3, otherwise use b\n" +"> if (Number % 3) == 0:\n" +"> message = message + a\n" +"> else:\n" +"> message = message + 'b'\n" +"> print(message)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > 3 `NameError`s for `number` being misspelled, for `message` not defined,\n" +"> > and for `a` not being in quotes.\n" +"> >\n" +"> > Fixed version:\n" +"> >\n" +"> > ~~~\n" +"> > message = ''\n" +"> > for number in range(10):\n" +"> > # use a if the number is a multiple of 3, otherwise use b\n" +"> > if (number % 3) == 0:\n" +"> > message = message + 'a'\n" +"> > else:\n" +"> > message = message + 'b'\n" +"> > print(message)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:574 +# blockquote, which can be cascaded +msgid "> ## Identifying Index Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:575 +msgid ">\n" +"> 1. Read the code below, and (without running it) try to identify what the errors are.\n" +"> 2. Run the code, and read the error message. What type of error is it?\n" +"> 3. Fix the error.\n" +">\n" +"> ~~~\n" +"> seasons = ['Spring', 'Summer', 'Fall', 'Winter']\n" +"> print('My favorite season is ', seasons[4])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > `IndexError`; the last entry is `seasons[3]`, so `seasons[4]` doesn't make sense.\n" +"> > A fixed version is:\n" +"> >\n" +"> > ~~~\n" +"> > seasons = ['Spring', 'Summer', 'Fall', 'Winter']\n" +"> > print('My favorite season is ', seasons[-1])\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/13__10-defensive.md.pot b/transifex/python-novice-inflammation/pot/13__10-defensive.md.pot new file mode 100644 index 00000000..d0f567e3 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/13__10-defensive.md.pot @@ -0,0 +1,747 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/10-defensive.md:1 +# Front Matter +msgid "---\n" +"title: Defensive Programming\n" +"teaching: 30\n" +"exercises: 10\n" +"questions:\n" +"- \"How can I make my programs more reliable?\"\n" +"objectives:\n" +"- \"Explain what an assertion is.\"\n" +"- \"Add assertions that check the program's state is correct.\"\n" +"- \"Correctly add precondition and postcondition assertions to functions.\"\n" +"- \"Explain what test-driven development is, and use it when creating new functions.\"\n" +"- \"Explain why variables should be initialized using actual data values\n" +" rather than arbitrary constants.\"\n" +"keypoints:\n" +"- \"Program defensively, i.e., assume that errors are going to arise,\n" +" and write code to detect them when they do.\"\n" +"- \"Put assertions in programs to check their state as they run,\n" +" and to help readers understand how those programs are supposed to work.\"\n" +"- \"Use preconditions to check that the inputs to a function are safe to use.\"\n" +"- \"Use postconditions to check that the output from a function is safe to use.\"\n" +"- \"Write tests before writing code in order to help determine exactly\n" +" what that code is supposed to do.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:25 +msgid "Our previous lessons have introduced the basic tools of programming:\n" +"variables and lists,\n" +"file I/O,\n" +"loops,\n" +"conditionals,\n" +"and functions.\n" +"What they *haven't* done is show us how to tell\n" +"whether a program is getting the right answer,\n" +"and how to tell if it's *still* getting the right answer\n" +"as we make changes to it." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:36 +msgid "To achieve that,\n" +"we need to:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:39 +# unordered list +msgid "* Write programs that check their own operation." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:40 +# unordered list +msgid "* Write and run tests for widely-used functions." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:41 +# unordered list +msgid "* Make sure we know what \"correct\" actually means." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:43 +msgid "The good news is,\n" +"doing these things will speed up our programming,\n" +"not slow it down.\n" +"As in real carpentry --- the kind done with lumber --- the time saved\n" +"by measuring carefully before cutting a piece of wood\n" +"is much greater than the time that measuring takes." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:50 +# header +msgid "## Assertions" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:52 +msgid "The first step toward getting the right answers from our programs\n" +"is to assume that mistakes *will* happen\n" +"and to guard against them.\n" +"This is called [defensive programming]({{ page.root }}/reference.html#defensive-programming),\n" +"and the most common way to do it is to add\n" +"[assertions]({{ page.root }}/reference.html#assertion) to our code\n" +"so that it checks itself as it runs.\n" +"An assertion is simply a statement that something must be true at a certain point in a program.\n" +"When Python sees one,\n" +"it evaluates the assertion's condition.\n" +"If it's true,\n" +"Python does nothing,\n" +"but if it's false,\n" +"Python halts the program immediately\n" +"and prints the error message if one is provided.\n" +"For example,\n" +"this piece of code halts as soon as the loop encounters a value that isn't positive:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:70 +# code block +msgid "~~~\n" +"numbers = [1.5, 2.3, 0.7, -0.001, 4.4]\n" +"total = 0.0\n" +"for num in numbers:\n" +" assert num > 0.0, 'Data should only contain positive values'\n" +" total += num\n" +"print('total is:', total)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:80 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +" 2 total = 0.0\n" +" 3 for num in numbers:\n" +"----> 4 assert num > 0.0, 'Data should only contain positive values'\n" +" 5 total += num\n" +" 6 print('total is:', total)\n" +"\n" +"AssertionError: Data should only contain positive values\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:94 +msgid "Programs like the Firefox browser are full of assertions:\n" +"10-20% of the code they contain\n" +"are there to check that the other 80–90% are working correctly.\n" +"Broadly speaking,\n" +"assertions fall into three categories:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:100 +# unordered list +msgid "* A [precondition]({{ page.root }}/reference.html#precondition)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:101 +msgid " is something that must be true at the start of a function in order for it to work correctly." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:103 +# unordered list +msgid "* A [postcondition]({{ page.root }}/reference.html#postcondition)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:104 +msgid " is something that the function guarantees is true when it finishes." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:106 +# unordered list +msgid "* An [invariant]({{ page.root }}/reference.html#invariant)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:107 +msgid " is something that is always true at a particular point inside a piece of code." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:109 +msgid "For example,\n" +"suppose we are representing rectangles using a [tuple]({{ page.root }}/reference.html#tuple)\n" +"of four coordinates `(x0, y0, x1, y1)`,\n" +"representing the lower left and upper right corners of the rectangle.\n" +"In order to do some calculations,\n" +"we need to normalize the rectangle so that the lower left corner is at the origin\n" +"and the longest side is 1.0 units long.\n" +"This function does that,\n" +"but checks that its input is correctly formatted and that its result makes sense:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:119 +# code block +msgid "~~~\n" +"def normalize_rectangle(rect):\n" +" \"\"\"Normalizes a rectangle so that it is at the origin and 1.0 units long on its longest axis.\n" +" Input should be of the format (x0, y0, x1, y1).\n" +" (x0, y0) and (x1, y1) define the lower left and upper right corners\n" +" of the rectangle, respectively.\"\"\"\n" +" assert len(rect) == 4, 'Rectangles must contain 4 coordinates'\n" +" x0, y0, x1, y1 = rect\n" +" assert x0 < x1, 'Invalid X coordinates'\n" +" assert y0 < y1, 'Invalid Y coordinates'\n" +"\n" +" dx = x1 - x0\n" +" dy = y1 - y0\n" +" if dx > dy:\n" +" scaled = float(dx) / dy\n" +" upper_x, upper_y = 1.0, scaled\n" +" else:\n" +" scaled = float(dx) / dy\n" +" upper_x, upper_y = scaled, 1.0\n" +"\n" +" assert 0 < upper_x <= 1.0, 'Calculated upper X coordinate invalid'\n" +" assert 0 < upper_y <= 1.0, 'Calculated upper Y coordinate invalid'\n" +"\n" +" return (0, 0, upper_x, upper_y)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:146 +msgid "The preconditions on lines 6, 8, and 9 catch invalid inputs:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:148 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (0.0, 1.0, 2.0) )) # missing the fourth coordinate\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:153 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in \n" +"----> 1 print(normalize_rectangle( (0.0, 1.0, 2.0) )) # missing the fourth coordinate\n" +"\n" +" in normalize_rectangle(rect)\n" +" 4 (x0, y0) and (x1, y1) define the lower left and upper right corners\n" +" 5 of the rectangle, respectively.\"\"\"\n" +"----> 6 assert len(rect) == 4, 'Rectangles must contain 4 coordinates'\n" +" 7 x0, y0, x1, y1 = rect\n" +" 8 assert x0 < x1, 'Invalid X coordinates'\n" +"\n" +"AssertionError: Rectangles must contain 4 coordinates\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:170 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (4.0, 2.0, 1.0, 5.0) )) # X axis inverted\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:175 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in \n" +"----> 1 print(normalize_rectangle( (4.0, 2.0, 1.0, 5.0) )) # X axis inverted\n" +"\n" +" in normalize_rectangle(rect)\n" +" 6 assert len(rect) == 4, 'Rectangles must contain 4 coordinates'\n" +" 7 x0, y0, x1, y1 = rect\n" +"----> 8 assert x0 < x1, 'Invalid X coordinates'\n" +" 9 assert y0 < y1, 'Invalid Y coordinates'\n" +" 10\n" +"\n" +"AssertionError: Invalid X coordinates\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:192 +msgid "The post-conditions on lines 20 and 21 help us catch bugs by telling us when our\n" +"calculations might have been incorrect.\n" +"For example,\n" +"if we normalize a rectangle that is taller than it is wide everything seems OK:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:197 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (0.0, 0.0, 1.0, 5.0) ))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:202 +# code block +msgid "~~~\n" +"(0, 0, 0.2, 1.0)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:207 +msgid "but if we normalize one that's wider than it is tall,\n" +"the assertion is triggered:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:210 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (0.0, 0.0, 5.0, 1.0) ))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:215 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in \n" +"----> 1 print(normalize_rectangle( (0.0, 0.0, 5.0, 1.0) ))\n" +"\n" +" in normalize_rectangle(rect)\n" +" 19\n" +" 20 assert 0 < upper_x <= 1.0, 'Calculated upper X coordinate invalid'\n" +"---> 21 assert 0 < upper_y <= 1.0, 'Calculated upper Y coordinate invalid'\n" +" 22\n" +" 23 return (0, 0, upper_x, upper_y)\n" +"\n" +"AssertionError: Calculated upper Y coordinate invalid\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:232 +msgid "Re-reading our function,\n" +"we realize that line 14 should divide `dy` by `dx` rather than `dx` by `dy`.\n" +"In a Jupyter notebook, you can display line numbers by typing Ctrl+M\n" +"followed by L.\n" +"If we had left out the assertion at the end of the function,\n" +"we would have created and returned something that had the right shape as a valid answer,\n" +"but wasn't.\n" +"Detecting and debugging that would almost certainly have taken more time in the long run\n" +"than writing the assertion." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:242 +msgid "But assertions aren't just about catching errors:\n" +"they also help people understand programs.\n" +"Each assertion gives the person reading the program\n" +"a chance to check (consciously or otherwise)\n" +"that their understanding matches what the code is doing." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:248 +msgid "Most good programmers follow two rules when adding assertions to their code.\n" +"The first is, *fail early, fail often*.\n" +"The greater the distance between when and where an error occurs and when it's noticed,\n" +"the harder the error will be to debug,\n" +"so good code catches mistakes as early as possible." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:254 +msgid "The second rule is, *turn bugs into assertions or tests*.\n" +"Whenever you fix a bug, write an assertion that catches the mistake\n" +"should you make it again.\n" +"If you made a mistake in a piece of code,\n" +"the odds are good that you have made other mistakes nearby,\n" +"or will make the same mistake (or a related one)\n" +"the next time you change it.\n" +"Writing assertions to check that you haven't [regressed]({{ page.root }}/reference.html#regression)\n" +"(i.e., haven't re-introduced an old problem)\n" +"can save a lot of time in the long run,\n" +"and helps to warn people who are reading the code\n" +"(including your future self)\n" +"that this bit is tricky." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:268 +# header +msgid "## Test-Driven Development" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:270 +msgid "An assertion checks that something is true at a particular point in the program.\n" +"The next step is to check the overall behavior of a piece of code,\n" +"i.e.,\n" +"to make sure that it produces the right output when it's given a particular input.\n" +"For example,\n" +"suppose we need to find where two or more time series overlap.\n" +"The range of each time series is represented as a pair of numbers,\n" +"which are the time the interval started and ended.\n" +"The output is the largest range that they all include:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:280 +msgid "![Overlapping Ranges](../fig/python-overlapping-ranges.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:282 +msgid "Most novice programmers would solve this problem like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:284 +# ordered list +msgid "1. Write a function `range_overlap`." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:285 +# ordered list +msgid "2. Call it interactively on two or three different inputs." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:286 +# ordered list +msgid "3. If it produces the wrong answer, fix the function and re-run that test." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:288 +msgid "This clearly works --- after all, thousands of scientists are doing it right now --- but\n" +"there's a better way:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:291 +# ordered list +msgid "1. Write a short function for each test." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:292 +# ordered list +msgid "2. Write a `range_overlap` function that should pass those tests." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:293 +# ordered list +msgid "3. If `range_overlap` produces any wrong answers, fix it and re-run the test functions." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:295 +msgid "Writing the tests *before* writing the function they exercise\n" +"is called [test-driven development]({{ page.root }}/reference.html#test-driven-development) (TDD).\n" +"Its advocates believe it produces better code faster because:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:299 +# ordered list +msgid "1. If people write tests after writing the thing to be tested," +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:300 +msgid " they are subject to confirmation bias,\n" +" i.e.,\n" +" they subconsciously write tests to show that their code is correct,\n" +" rather than to find errors.\n" +"2. Writing tests helps programmers figure out what the function is actually supposed to do." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:306 +msgid "Here are three test functions for `range_overlap`:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:308 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +"assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +"assert range_overlap([ (0.0, 1.0), (0.0, 2.0), (-1.0, 1.0) ]) == (0.0, 1.0)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:315 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +" 2 assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +" 3 assert range_overlap([ (0.0, 1.0), (0.0, 2.0), (-1.0, 1.0) ]) == (0.0, 1.0)\n" +"\n" +"AssertionError:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:327 +msgid "The error is actually reassuring:\n" +"we haven't written `range_overlap` yet,\n" +"so if the tests passed,\n" +"it would be a sign that someone else had\n" +"and that we were accidentally using their function." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:333 +msgid "And as a bonus of writing these tests,\n" +"we've implicitly defined what our input and output look like:\n" +"we expect a list of pairs as input,\n" +"and produce a single pair as output." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:338 +msgid "Something important is missing, though.\n" +"We don't have any tests for the case where the ranges don't overlap at all:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:341 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == ???\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:346 +msgid "What should `range_overlap` do in this case:\n" +"fail with an error message,\n" +"produce a special value like `(0.0, 0.0)` to signal that there's no overlap,\n" +"or something else?\n" +"Any actual implementation of the function will do one of these things;\n" +"writing the tests first helps us figure out which is best\n" +"*before* we're emotionally invested in whatever we happened to write\n" +"before we realized there was an issue." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:355 +msgid "And what about this case?" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:357 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == ???\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:362 +msgid "Do two segments that touch at their endpoints overlap or not?\n" +"Mathematicians usually say \"yes\",\n" +"but engineers usually say \"no\".\n" +"The best answer is \"whatever is most useful in the rest of our program\",\n" +"but again,\n" +"any actual implementation of `range_overlap` is going to do *something*,\n" +"and whatever it is ought to be consistent with what it does when there's no overlap at all." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:370 +msgid "Since we're planning to use the range this function returns\n" +"as the X axis in a time series chart,\n" +"we decide that:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:374 +# ordered list +msgid "1. every overlap has to have non-zero width, and" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:375 +# ordered list +msgid "2. we will return the special value `None` when there's no overlap." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:377 +msgid "`None` is built into Python,\n" +"and means \"nothing here\".\n" +"(Other languages often call the equivalent value `null` or `nil`).\n" +"With that decision made,\n" +"we can finish writing our last two tests:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:383 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +"assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:389 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +" 2 assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +"\n" +"AssertionError:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:400 +msgid "Again,\n" +"we get an error because we haven't written our function,\n" +"but we're now ready to do so:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:404 +# code block +msgid "~~~\n" +"def range_overlap(ranges):\n" +" \"\"\"Return common overlap among a set of [left, right] ranges.\"\"\"\n" +" max_left = 0.0\n" +" min_right = 1.0\n" +" for (left, right) in ranges:\n" +" max_left = max(max_left, left)\n" +" min_right = min(min_right, right)\n" +" return (max_left, min_right)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:416 +msgid "Take a moment to think about why we calculate the left endpoint of the overlap as\n" +"the maximum of the input left endpoints, and the overlap right endpoint as the minimum\n" +"of the input right endpoints.\n" +"We'd now like to re-run our tests,\n" +"but they're scattered across three different cells.\n" +"To make running them easier,\n" +"let's put them all in a function:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:424 +# code block +msgid "~~~\n" +"def test_range_overlap():\n" +" assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +" assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +" assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +" assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +" assert range_overlap([ (0.0, 1.0), (0.0, 2.0), (-1.0, 1.0) ]) == (0.0, 1.0)\n" +" assert range_overlap([]) == None\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:435 +msgid "We can now test `range_overlap` with a single function call:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:437 +# code block +msgid "~~~\n" +"test_range_overlap()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:442 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 test_range_overlap()\n" +"\n" +" in test_range_overlap()\n" +" 1 def test_range_overlap():\n" +"----> 2 assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +" 3 assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +" 4 assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +" 5 assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +"\n" +"AssertionError:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:459 +msgid "The first test that was supposed to produce `None` fails,\n" +"so we know something is wrong with our function.\n" +"We *don't* know whether the other tests passed or failed\n" +"because Python halted the program as soon as it spotted the first error.\n" +"Still,\n" +"some information is better than none,\n" +"and if we trace the behavior of the function with that input,\n" +"we realize that we're initializing `max_left` and `min_right` to 0.0 and 1.0 respectively,\n" +"regardless of the input values.\n" +"This violates another important rule of programming:\n" +"*always initialize from data*." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:471 +# blockquote, which can be cascaded +msgid "> ## Pre- and Post-Conditions" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:472 +msgid ">\n" +"> Suppose you are writing a function called `average` that calculates\n" +"> the average of the numbers in a list.\n" +"> What pre-conditions and post-conditions would you write for it?\n" +"> Compare your answer to your neighbor's:\n" +"> can you think of a function that will pass your tests but not his/hers or vice versa?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # a possible pre-condition:\n" +"> > assert len(input_list) > 0, 'List length must be non-zero'\n" +"> > # a possible post-condition:\n" +"> > assert numpy.min(input_list) <= average <= numpy.max(input_list),\n" +"> > 'Average should be between min and max of input values (inclusive)'\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:491 +# blockquote, which can be cascaded +msgid "> ## Testing Assertions" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:492 +msgid ">\n" +"> Given a sequence of a number of cars, the function `get_total_cars` returns\n" +"> the total number of cars.\n" +">\n" +"> ~~~\n" +"> get_total_cars([1, 2, 3, 4])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 10\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:505 +msgid ">\n" +"> ~~~\n" +"> get_total_cars(['a', 'b', 'c'])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> ValueError: invalid literal for int() with base 10: 'a'\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:515 +msgid ">\n" +"> Explain in words what the assertions in this function check,\n" +"> and for each one,\n" +"> give an example of input that will make that assertion fail.\n" +">\n" +"> ~~~\n" +"> def get_total(values):\n" +"> assert len(values) > 0\n" +"> for element in values:\n" +"> assert int(element)\n" +"> values = [int(element) for element in values]\n" +"> total = sum(values)\n" +"> assert total > 0\n" +"> return total\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > * The first assertion checks that the input sequence `values` is not empty.\n" +"> > An empty sequence such as `[]` will make it fail.\n" +"> > * The second assertion checks that each value in the list can be turned into an integer.\n" +"> > Input such as `[1, 2,'c', 3]` will make it fail.\n" +"> > * The third assertion checks that the total of the list is greater than 0.\n" +"> > Input such as `[-10, 2, 3]` will make it fail." +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/14__11-debugging.md.pot b/transifex/python-novice-inflammation/pot/14__11-debugging.md.pot new file mode 100644 index 00000000..ac807ca0 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/14__11-debugging.md.pot @@ -0,0 +1,415 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/11-debugging.md:1 +# Front Matter +msgid "---\n" +"title: Debugging\n" +"teaching: 30\n" +"exercises: 20\n" +"questions:\n" +"- \"How can I debug my program?\"\n" +"objectives:\n" +"- \"Debug code containing an error systematically.\"\n" +"- \"Identify ways of making code less error-prone and more easily tested.\"\n" +"keypoints:\n" +"- \"Know what code is supposed to do *before* trying to debug it.\"\n" +"- \"Make it fail every time.\"\n" +"- \"Make it fail fast.\"\n" +"- \"Change one thing at a time, and for a reason.\"\n" +"- \"Keep track of what you've done.\"\n" +"- \"Be humble.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:19 +msgid "Once testing has uncovered problems,\n" +"the next step is to fix them.\n" +"Many novices do this by making more-or-less random changes to their code\n" +"until it seems to produce the right answer,\n" +"but that's very inefficient\n" +"(and the result is usually only correct for the one case they're testing).\n" +"The more experienced a programmer is,\n" +"the more systematically they debug,\n" +"and most follow some variation on the rules explained below." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:29 +# header +msgid "## Know What It's Supposed to Do" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:31 +msgid "The first step in debugging something is to\n" +"*know what it's supposed to do*.\n" +"\"My program doesn't work\" isn't good enough:\n" +"in order to diagnose and fix problems,\n" +"we need to be able to tell correct output from incorrect.\n" +"If we can write a test case for the failing case --- i.e.,\n" +"if we can assert that with *these* inputs,\n" +"the function should produce *that* result ---\n" +"then we're ready to start debugging.\n" +"If we can't,\n" +"then we need to figure out how we're going to know when we've fixed things." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:43 +msgid "But writing test cases for scientific software is frequently harder than\n" +"writing test cases for commercial applications,\n" +"because if we knew what the output of the scientific code was supposed to be,\n" +"we wouldn't be running the software:\n" +"we'd be writing up our results and moving on to the next program.\n" +"In practice,\n" +"scientists tend to do the following:" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:51 +# ordered list +msgid "1. *Test with simplified data.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:52 +msgid " Before doing statistics on a real data set,\n" +" we should try calculating statistics for a single record,\n" +" for two identical records,\n" +" for two records whose values are one step apart,\n" +" or for some other case where we can calculate the right answer by hand." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:58 +# ordered list +msgid "2. *Test a simplified case.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:59 +msgid " If our program is supposed to simulate\n" +" magnetic eddies in rapidly-rotating blobs of supercooled helium,\n" +" our first test should be a blob of helium that isn't rotating,\n" +" and isn't being subjected to any external electromagnetic fields.\n" +" Similarly,\n" +" if we're looking at the effects of climate change on speciation,\n" +" our first test should hold temperature, precipitation, and other factors constant." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:67 +# ordered list +msgid "3. *Compare to an oracle.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:68 +msgid " A [test oracle]({{ page.root }}/reference.html#test-oracle) is something whose results are trusted,\n" +" such as experimental data, an older program, or a human expert.\n" +" We use test oracles to determine if our new program produces the correct results.\n" +" If we have a test oracle,\n" +" we should store its output for particular cases\n" +" so that we can compare it with our new results as often as we like\n" +" without re-running that program." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:76 +# ordered list +msgid "4. *Check conservation laws.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:77 +msgid " Mass, energy, and other quantities are conserved in physical systems,\n" +" so they should be in programs as well.\n" +" Similarly,\n" +" if we are analyzing patient data,\n" +" the number of records should either stay the same or decrease\n" +" as we move from one analysis to the next\n" +" (since we might throw away outliers or records with missing values).\n" +" If \"new\" patients start appearing out of nowhere as we move through our pipeline,\n" +" it's probably a sign that something is wrong." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:87 +# ordered list +msgid "5. *Visualize.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:88 +msgid " Data analysts frequently use simple visualizations to check both\n" +" the science they're doing\n" +" and the correctness of their code\n" +" (just as we did in the [opening lesson]({{ page.root }}/01-numpy/) of this tutorial).\n" +" This should only be used for debugging as a last resort,\n" +" though,\n" +" since it's very hard to compare two visualizations automatically." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:96 +# header +msgid "## Make It Fail Every Time" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:98 +msgid "We can only debug something when it fails,\n" +"so the second step is always to find a test case that\n" +"*makes it fail every time*.\n" +"The \"every time\" part is important because\n" +"few things are more frustrating than debugging an intermittent problem:\n" +"if we have to call a function a dozen times to get a single failure,\n" +"the odds are good that we'll scroll past the failure when it actually occurs." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:106 +msgid "As part of this,\n" +"it's always important to check that our code is \"plugged in\",\n" +"i.e.,\n" +"that we're actually exercising the problem that we think we are.\n" +"Every programmer has spent hours chasing a bug,\n" +"only to realize that they were actually calling their code on the wrong data set\n" +"or with the wrong configuration parameters,\n" +"or are using the wrong version of the software entirely.\n" +"Mistakes like these are particularly likely to happen when we're tired,\n" +"frustrated,\n" +"and up against a deadline,\n" +"which is one of the reasons late-night (or overnight) coding sessions\n" +"are almost never worthwhile." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:120 +# header +msgid "## Make It Fail Fast" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:122 +msgid "If it takes 20 minutes for the bug to surface,\n" +"we can only do three experiments an hour.\n" +"This means that we'll get less data in more time and that\n" +"we're more likely to be distracted by other things as we wait for our program to fail,\n" +"which means the time we *are* spending on the problem is less focused.\n" +"It's therefore critical to *make it fail fast*." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:129 +msgid "As well as making the program fail fast in time,\n" +"we want to make it fail fast in space,\n" +"i.e.,\n" +"we want to localize the failure to the smallest possible region of code:" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:134 +# ordered list +msgid "1. The smaller the gap between cause and effect," +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:135 +msgid " the easier the connection is to find.\n" +" Many programmers therefore use a divide and conquer strategy to find bugs,\n" +" i.e.,\n" +" if the output of a function is wrong,\n" +" they check whether things are OK in the middle,\n" +" then concentrate on either the first or second half,\n" +" and so on." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:143 +# ordered list +msgid "2. N things can interact in N! different ways," +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:144 +msgid " so every line of code that *isn't* run as part of a test\n" +" means more than one thing we don't need to worry about." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:147 +# header +msgid "## Change One Thing at a Time, For a Reason" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:149 +msgid "Replacing random chunks of code is unlikely to do much good.\n" +"(After all,\n" +"if you got it wrong the first time,\n" +"you'll probably get it wrong the second and third as well.)\n" +"Good programmers therefore\n" +"*change one thing at a time, for a reason*.\n" +"They are either trying to gather more information\n" +"(\"is the bug still there if we change the order of the loops?\")\n" +"or test a fix\n" +"(\"can we make the bug go away by sorting our data before processing it?\")." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:160 +msgid "Every time we make a change,\n" +"however small,\n" +"we should re-run our tests immediately,\n" +"because the more things we change at once,\n" +"the harder it is to know what's responsible for what\n" +"(those N! interactions again).\n" +"And we should re-run *all* of our tests:\n" +"more than half of fixes made to code introduce (or re-introduce) bugs,\n" +"so re-running all of our tests tells us whether we have regressed." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:170 +# header +msgid "## Keep Track of What You've Done" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:172 +msgid "Good scientists keep track of what they've done\n" +"so that they can reproduce their work,\n" +"and so that they don't waste time repeating the same experiments\n" +"or running ones whose results won't be interesting.\n" +"Similarly,\n" +"debugging works best when we\n" +"*keep track of what we've done*\n" +"and how well it worked.\n" +"If we find ourselves asking,\n" +"\"Did left followed by right with an odd number of lines cause the crash?\n" +"Or was it right followed by left?\n" +"Or was I using an even number of lines?\"\n" +"then it's time to step away from the computer,\n" +"take a deep breath,\n" +"and start working more systematically." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:188 +msgid "Records are particularly useful when the time comes to ask for help.\n" +"People are more likely to listen to us\n" +"when we can explain clearly what we did,\n" +"and we're better able to give them the information they need to be useful." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:193 +# blockquote, which can be cascaded +msgid "> ## Version Control Revisited" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:194 +msgid ">\n" +"> Version control is often used to reset software to a known state during debugging,\n" +"> and to explore recent changes to code that might be responsible for bugs.\n" +"> In particular,\n" +"> most version control systems (e.g. git, Mercurial) have:\n" +"> 1. a `blame` command that shows who last changed each line of a file;\n" +"> 2. a `bisect` command that helps with finding the commit that introduced an\n" +"> issue." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:204 +# header +msgid "## Be Humble" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:206 +msgid "And speaking of help:\n" +"if we can't find a bug in 10 minutes,\n" +"we should *be humble* and ask for help.\n" +"Explaining the problem to someone else is often useful,\n" +"since hearing what we're thinking helps us spot inconsistencies and hidden assumptions.\n" +"If you don't have someone nearby to share your problem description with, get a\n" +"[rubber duck](https://en.wikipedia.org/wiki/Rubber_duck_debugging)!" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:214 +msgid "Asking for help also helps alleviate confirmation bias.\n" +"If we have just spent an hour writing a complicated program,\n" +"we want it to work,\n" +"so we're likely to keep telling ourselves why it should,\n" +"rather than searching for the reason it doesn't.\n" +"People who aren't emotionally invested in the code can be more objective,\n" +"which is why they're often able to spot the simple mistakes we have overlooked." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:222 +msgid "Part of being humble is learning from our mistakes.\n" +"Programmers tend to get the same things wrong over and over:\n" +"either they don't understand the language and libraries they're working with,\n" +"or their model of how things work is wrong.\n" +"In either case,\n" +"taking note of why the error occurred\n" +"and checking for it next time\n" +"quickly turns into not making the mistake at all." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:231 +msgid "And that is what makes us most productive in the long run.\n" +"As the saying goes,\n" +"*A week of hard work can sometimes save you an hour of thought*.\n" +"If we train ourselves to avoid making some kinds of mistakes,\n" +"to break our code into modular, testable chunks,\n" +"and to turn every assumption (or mistake) into an assertion,\n" +"it will actually take us *less* time to produce working programs,\n" +"not more." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:240 +# blockquote, which can be cascaded +msgid "> ## Debug With a Neighbor" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:241 +msgid ">\n" +"> Take a function that you have written today, and introduce a tricky bug.\n" +"> Your function should still run, but will give the wrong output.\n" +"> Switch seats with your neighbor and attempt to debug\n" +"> the bug that they introduced into their function.\n" +"> Which of the principles discussed above did you find helpful?" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:249 +# blockquote, which can be cascaded +msgid "> ## Not Supposed to be the Same" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:250 +msgid ">\n" +"> You are assisting a researcher with Python code that computes the\n" +"> Body Mass Index (BMI) of patients. The researcher is concerned because\n" +"> all patients seemingly have unusual and identical BMIs, despite having different\n" +"> physiques. BMI is calculated as **weight in kilograms**\n" +"> divided by the square of **height in metres**.\n" +">\n" +"> Use the debugging principles in this exercise and locate problems\n" +"> with the code. What suggestions would you give the researcher for\n" +"> ensuring any later changes they make work correctly?\n" +">\n" +"> ~~~\n" +"> patients = [[70, 1.8], [80, 1.9], [150, 1.7]]\n" +">\n" +"> def calculate_bmi(weight, height):\n" +"> return weight / (height ** 2)\n" +">\n" +"> for patient in patients:\n" +"> weight, height = patients[0]\n" +"> bmi = calculate_bmi(height, weight)\n" +"> print(\"Patient's BMI is: %f\" % bmi)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Patient's BMI is: 0.000367\n" +"> Patient's BMI is: 0.000367\n" +"> Patient's BMI is: 0.000367\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:280 +msgid ">\n" +"> > ## Solution\n" +"> > * The loop is not being utilised correctly. `height` and `weight` are always\n" +"> > set as the first patient's data during each iteration of the loop.\n" +"> >\n" +"> > * The height/weight variables are reversed in the function call to\n" +"> > `calculate_bmi(...)`, the correct BMIs are 21.604938, 22.160665 and 51.903114." +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/15__12-cmdline.md.pot b/transifex/python-novice-inflammation/pot/15__12-cmdline.md.pot new file mode 100644 index 00000000..32e98bf9 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/15__12-cmdline.md.pot @@ -0,0 +1,1306 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1 +# Front Matter +msgid "---\n" +"title: Command-Line Programs\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I write Python programs that will work like Unix command-line tools?\"\n" +"objectives:\n" +"- \"Use the values of command-line arguments in a program.\"\n" +"- \"Handle flags and files separately in a command-line program.\"\n" +"- \"Read data from standard input in a program so that it can be used in a pipeline.\"\n" +"keypoints:\n" +"- \"The `sys` library connects a Python program to the system it is running on.\"\n" +"- \"The list `sys.argv` contains the command-line arguments that a program was run with.\"\n" +"- \"Avoid silent failures.\"\n" +"- \"The pseudo-file `sys.stdin` connects to a program's standard input.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:18 +msgid "The Jupyter Notebook and other interactive tools are great for prototyping code and exploring data,\n" +"but sooner or later we will want to use our program in a pipeline\n" +"or run it in a shell script to process thousands of data files.\n" +"In order to do that,\n" +"we need to make our programs work like other Unix command-line tools.\n" +"For example,\n" +"we may want a program that reads a dataset\n" +"and prints the average inflammation per patient." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:27 +# blockquote, which can be cascaded +msgid "> ## Switching to Shell Commands" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:28 +msgid ">\n" +"> In this lesson we are switching from typing commands in a Python interpreter to typing\n" +"> commands in a shell terminal window (such as bash). When you see a `$` in front of a\n" +"> command that tells you to run that command in the shell rather than the Python interpreter." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:34 +msgid "This program does exactly what we want - it prints the average inflammation per patient\n" +"for a given file." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:37 +# code block +msgid "~~~\n" +"$ python ../code/readings_04.py --mean inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:40 +#: python-novice-inflammation/_episodes/12-cmdline.md:58 +#: python-novice-inflammation/_episodes/12-cmdline.md:65 +#: python-novice-inflammation/_episodes/12-cmdline.md:100 +#: python-novice-inflammation/_episodes/12-cmdline.md:126 +#: python-novice-inflammation/_episodes/12-cmdline.md:140 +#: python-novice-inflammation/_episodes/12-cmdline.md:159 +#: python-novice-inflammation/_episodes/12-cmdline.md:183 +#: python-novice-inflammation/_episodes/12-cmdline.md:192 +#: python-novice-inflammation/_episodes/12-cmdline.md:215 +#: python-novice-inflammation/_episodes/12-cmdline.md:333 +#: python-novice-inflammation/_episodes/12-cmdline.md:343 +#: python-novice-inflammation/_episodes/12-cmdline.md:354 +#: python-novice-inflammation/_episodes/12-cmdline.md:392 +#: python-novice-inflammation/_episodes/12-cmdline.md:415 +#: python-novice-inflammation/_episodes/12-cmdline.md:448 +#: python-novice-inflammation/_episodes/12-cmdline.md:482 +#: python-novice-inflammation/_episodes/12-cmdline.md:511 +#: python-novice-inflammation/_episodes/12-cmdline.md:558 +#: python-novice-inflammation/_episodes/12-cmdline.md:581 +#: python-novice-inflammation/_episodes/12-cmdline.md:593 +#: python-novice-inflammation/_episodes/12-cmdline.md:613 +#: python-novice-inflammation/_episodes/12-cmdline.md:654 +msgid "{: .language-bash}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:42 +# code block +msgid "~~~\n" +"5.45\n" +"5.425\n" +"6.1\n" +"...\n" +"6.4\n" +"7.05\n" +"5.9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:53 +msgid "We might also want to look at the minimum of the first four lines" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:55 +# code block +msgid "~~~\n" +"$ head -4 inflammation-01.csv | python ../code/readings_06.py --min\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:60 +msgid "or the maximum inflammations in several files one after another:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:62 +# code block +msgid "~~~\n" +"$ python ../code/readings_04.py --max inflammation-*.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:67 +msgid "Our scripts should do the following:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:69 +# ordered list +msgid "1. If no filename is given on the command line, read data from" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:70 +msgid "[standard input]({{ page.root }}/reference.html#standard-input).\n" +"2. If one or more filenames are given, read data from them and report statistics for each file\n" +"separately.\n" +"3. Use the `--min`, `--mean`, or `--max` flag to determine what statistic to print." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:75 +msgid "To make this work,\n" +"we need to know how to handle command-line arguments in a program,\n" +"and understand how to handle standard input.\n" +"We'll tackle these questions in turn below." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:80 +# header +msgid "## Command-Line Arguments" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:82 +msgid "Using the text editor of your choice,\n" +"save the following in a text file called `sys_version.py`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:85 +# code block +msgid "~~~\n" +"import sys\n" +"print('version is', sys.version)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:91 +msgid "The first line imports a library called `sys`,\n" +"which is short for \"system\".\n" +"It defines values such as `sys.version`,\n" +"which describes which version of Python we are running.\n" +"We can run this script from the command line like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:97 +# code block +msgid "~~~\n" +"$ python sys_version.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:102 +# code block +msgid "~~~\n" +"version is 3.4.3+ (default, Jul 28 2015, 13:17:50)\n" +"[GCC 4.9.3]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:108 +msgid "Create another file called `argv_list.py` and save the following text to it." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:110 +# code block +msgid "~~~\n" +"import sys\n" +"print('sys.argv is', sys.argv)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:116 +msgid "The strange name `argv` stands for \"argument values\".\n" +"Whenever Python runs a program,\n" +"it takes all of the values given on the command line\n" +"and puts them in the list `sys.argv`\n" +"so that the program can determine what they were.\n" +"If we run this program with no arguments:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:123 +# code block +msgid "~~~\n" +"$ python argv_list.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:128 +# code block +msgid "~~~\n" +"sys.argv is ['argv_list.py']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:133 +msgid "the only thing in the list is the full path to our script,\n" +"which is always `sys.argv[0]`.\n" +"If we run it with a few arguments, however:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:137 +# code block +msgid "~~~\n" +"$ python argv_list.py first second third\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:142 +# code block +msgid "~~~\n" +"sys.argv is ['argv_list.py', 'first', 'second', 'third']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:147 +msgid "then Python adds each of those arguments to that magic list." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:149 +msgid "With this in hand, let's build a version of `readings.py` that always prints\n" +"the per-patient mean of a single data file.\n" +"The first step is to write a function that outlines our implementation,\n" +"and a placeholder for the function that does the actual work.\n" +"By convention this function is usually called `main`,\n" +"though we can call it whatever we want:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:156 +# code block +msgid "~~~\n" +"$ cat ../code/readings_01.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:161 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" filename = sys.argv[1]\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +" for row_mean in numpy.mean(data, axis=1):\n" +" print(row_mean)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:175 +msgid "This function gets the name of the script from `sys.argv[0]`,\n" +"because that's where it's always put,\n" +"and the name of the file to process from `sys.argv[1]`.\n" +"Here's a simple test:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:180 +# code block +msgid "~~~\n" +"$ python ../code/readings_01.py inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:185 +msgid "There is no output because we have defined a function,\n" +"but haven't actually called it.\n" +"Let's add a call to `main`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:189 +# code block +msgid "~~~\n" +"$ cat ../code/readings_02.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:194 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" filename = sys.argv[1]\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +" for row_mean in numpy.mean(data, axis=1):\n" +" print(row_mean)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:210 +msgid "and run that:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:212 +# code block +msgid "~~~\n" +"$ python ../code/readings_02.py inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:217 +# code block +msgid "~~~\n" +"5.45\n" +"5.425\n" +"6.1\n" +"5.9\n" +"5.55\n" +"6.225\n" +"5.975\n" +"6.65\n" +"6.625\n" +"6.525\n" +"6.775\n" +"5.8\n" +"6.225\n" +"5.75\n" +"5.225\n" +"6.3\n" +"6.55\n" +"5.7\n" +"5.85\n" +"6.55\n" +"5.775\n" +"5.825\n" +"6.175\n" +"6.1\n" +"5.8\n" +"6.425\n" +"6.05\n" +"6.025\n" +"6.175\n" +"6.55\n" +"6.175\n" +"6.35\n" +"6.725\n" +"6.125\n" +"7.075\n" +"5.725\n" +"5.925\n" +"6.15\n" +"6.075\n" +"5.75\n" +"5.975\n" +"5.725\n" +"6.3\n" +"5.9\n" +"6.75\n" +"5.925\n" +"7.225\n" +"6.15\n" +"5.95\n" +"6.275\n" +"5.7\n" +"6.1\n" +"6.825\n" +"5.975\n" +"6.725\n" +"5.7\n" +"6.25\n" +"6.4\n" +"7.05\n" +"5.9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:281 +# blockquote, which can be cascaded +msgid "> ## Running Versus Importing" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:282 +msgid ">\n" +"> Running a Python script in bash is very similar to\n" +"> importing that file in Python.\n" +"> The biggest difference is that we don't expect anything\n" +"> to happen when we import a file,\n" +"> whereas when running a script, we expect to see some\n" +"> output printed to the console.\n" +">\n" +"> In order for a Python script to work as expected\n" +"> when imported or when run as a script,\n" +"> we typically put the part of the script\n" +"> that produces output in the following if statement:\n" +">\n" +"> ~~~\n" +"> if __name__ == '__main__':\n" +"> main() # Or whatever function produces output\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> When you import a Python file, `__name__` is the name\n" +"> of that file (e.g., when importing `readings.py`,\n" +"> `__name__` is `'readings'`). However, when running a\n" +"> script in bash, `__name__` is always set to `'__main__'`\n" +"> in that script so that you can determine if the file\n" +"> is being imported or run as a script." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:309 +#: python-novice-inflammation/_episodes/12-cmdline.md:425 +# blockquote, which can be cascaded +msgid "> ## The Right Way to Do It" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:310 +msgid ">\n" +"> If our programs can take complex parameters or multiple filenames,\n" +"> we shouldn't handle `sys.argv` directly.\n" +"> Instead,\n" +"> we should use Python's `argparse` library,\n" +"> which handles common cases in a systematic way,\n" +"> and also makes it easy for us to provide sensible error messages for our users.\n" +"> We will not cover this module in this lesson\n" +"> but you can go to Tshepang Lekhonkhobe's\n" +"> [Argparse tutorial](http://docs.python.org/3/howto/argparse.html)\n" +"> that is part of Python's Official Documentation." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:323 +# header +msgid "## Handling Multiple Files" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:325 +msgid "The next step is to teach our program how to handle multiple files.\n" +"Since 60 lines of output per file is a lot to page through,\n" +"we'll start by using three smaller files,\n" +"each of which has three days of data for two patients:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:330 +# code block +msgid "~~~\n" +"$ ls small-*.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:335 +# code block +msgid "~~~\n" +"small-01.csv small-02.csv small-03.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:340 +# code block +msgid "~~~\n" +"$ cat small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:345 +# code block +msgid "~~~\n" +"0,0,1\n" +"0,1,2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:351 +# code block +msgid "~~~\n" +"$ python ../code/readings_02.py small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:356 +#: python-novice-inflammation/_episodes/12-cmdline.md:656 +# code block +msgid "~~~\n" +"0.333333333333\n" +"1.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:362 +msgid "Using small data files as input also allows us to check our results more easily:\n" +"here,\n" +"for example,\n" +"we can see that our program is calculating the mean correctly for each line,\n" +"whereas we were really taking it on faith before.\n" +"This is yet another rule of programming:\n" +"*test the simple things first*." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:370 +msgid "We want our program to process each file separately,\n" +"so we need a loop that executes once for each filename.\n" +"If we specify the files on the command line,\n" +"the filenames will be in `sys.argv`,\n" +"but we need to be careful:\n" +"`sys.argv[0]` will always be the name of our script,\n" +"rather than the name of a file.\n" +"We also need to handle an unknown number of filenames,\n" +"since our program could be run for any number of files." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:380 +msgid "The solution to both problems is to loop over the contents of `sys.argv[1:]`.\n" +"The '1' tells Python to start the slice at location 1,\n" +"so the program's name isn't included;\n" +"since we've left off the upper bound,\n" +"the slice runs to the end of the list,\n" +"and includes all the filenames.\n" +"Here's our changed program\n" +"`readings_03.py`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:389 +# code block +msgid "~~~\n" +"$ cat ../code/readings_03.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:394 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" for filename in sys.argv[1:]:\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +" for row_mean in numpy.mean(data, axis=1):\n" +" print(row_mean)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:410 +msgid "and here it is in action:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:412 +# code block +msgid "~~~\n" +"$ python ../code/readings_03.py small-01.csv small-02.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:417 +# code block +msgid "~~~\n" +"0.333333333333\n" +"1.0\n" +"13.6666666667\n" +"11.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:426 +msgid ">\n" +"> At this point,\n" +"> we have created three versions of our script called `readings_01.py`,\n" +"> `readings_02.py`, and `readings_03.py`.\n" +"> We wouldn't do this in real life:\n" +"> instead,\n" +"> we would have one file called `readings.py` that we committed to version control\n" +"> every time we got an enhancement working.\n" +"> For teaching,\n" +"> though,\n" +"> we need all the successive versions side by side." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:439 +# header +msgid "## Handling Command-Line Flags" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:441 +msgid "The next step is to teach our program to pay attention to the `--min`, `--mean`, and `--max` flags.\n" +"These always appear before the names of the files,\n" +"so we could do this:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:445 +# code block +msgid "~~~\n" +"$ cat ../code/readings_04.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:450 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" action = sys.argv[1]\n" +" filenames = sys.argv[2:]\n" +"\n" +" for filename in filenames:\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +"\n" +" if action == '--min':\n" +" values = numpy.min(data, axis=1)\n" +" elif action == '--mean':\n" +" values = numpy.mean(data, axis=1)\n" +" elif action == '--max':\n" +" values = numpy.max(data, axis=1)\n" +"\n" +" for val in values:\n" +" print(val)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:477 +msgid "This works:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:479 +# code block +msgid "~~~\n" +"$ python ../code/readings_04.py --max small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:484 +# code block +msgid "~~~\n" +"1.0\n" +"2.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:490 +msgid "but there are several things wrong with it:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:492 +# ordered list +msgid "1. `main` is too large to read comfortably." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:494 +# ordered list +msgid "2. If we do not specify at least two additional arguments on the" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:495 +msgid " command-line, one for the **flag** and one for the **filename**, but only\n" +" one, the program will not throw an exception but will run. It assumes that the file\n" +" list is empty, as `sys.argv[1]` will be considered the `action`, even if it\n" +" is a filename. [Silent failures]({{ page.root }}/reference.html#silence-failure) like this\n" +" are always hard to debug." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:501 +# ordered list +msgid "3. The program should check if the submitted `action` is one of the three recognized flags." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:503 +msgid "This version pulls the processing of each file out of the loop into a function of its own.\n" +"It also checks that `action` is one of the allowed flags\n" +"before doing any processing,\n" +"so that the program fails fast:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:508 +# code block +msgid "~~~\n" +"$ cat ../code/readings_05.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:513 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" action = sys.argv[1]\n" +" filenames = sys.argv[2:]\n" +" assert action in ['--min', '--mean', '--max'], \\\n" +" 'Action is not one of --min, --mean, or --max: ' + action\n" +" for filename in filenames:\n" +" process(filename, action)\n" +"\n" +"def process(filename, action):\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +"\n" +" if action == '--min':\n" +" values = numpy.min(data, axis=1)\n" +" elif action == '--mean':\n" +" values = numpy.mean(data, axis=1)\n" +" elif action == '--max':\n" +" values = numpy.max(data, axis=1)\n" +"\n" +" for val in values:\n" +" print(val)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:544 +msgid "This is four lines longer than its predecessor,\n" +"but broken into more digestible chunks of 8 and 12 lines." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:547 +# header +msgid "## Handling Standard Input" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:549 +msgid "The next thing our program has to do is read data from standard input if no filenames are given\n" +"so that we can put it in a pipeline,\n" +"redirect input to it,\n" +"and so on.\n" +"Let's experiment in another script called `count_stdin.py`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:555 +# code block +msgid "~~~\n" +"$ cat ../code/count_stdin.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:560 +# code block +msgid "~~~\n" +"import sys\n" +"\n" +"count = 0\n" +"for line in sys.stdin:\n" +" count += 1\n" +"\n" +"print(count, 'lines in standard input')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:571 +msgid "This little program reads lines from a special \"file\" called `sys.stdin`,\n" +"which is automatically connected to the program's standard input.\n" +"We don't have to open it --- Python and the operating system\n" +"take care of that when the program starts up ---\n" +"but we can do almost anything with it that we could do to a regular file.\n" +"Let's try running it as if it were a regular command-line program:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:578 +# code block +msgid "~~~\n" +"$ python ../code/count_stdin.py < small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:583 +# code block +msgid "~~~\n" +"2 lines in standard input\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:588 +msgid "A common mistake is to try to run something that reads from standard input like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:590 +# code block +msgid "~~~\n" +"$ python ../code/count_stdin.py small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:595 +msgid "i.e., to forget the `<` character that redirects the file to standard input.\n" +"In this case,\n" +"there's nothing in standard input,\n" +"so the program waits at the start of the loop for someone to type something on the keyboard.\n" +"Since there's no way for us to do this,\n" +"our program is stuck,\n" +"and we have to halt it using the `Interrupt` option from the `Kernel` menu in the Notebook." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:603 +msgid "We now need to rewrite the program so that it loads data from `sys.stdin`\n" +"if no filenames are provided.\n" +"Luckily,\n" +"`numpy.loadtxt` can handle either a filename or an open file as its first parameter,\n" +"so we don't actually need to change `process`.\n" +"Only `main` changes:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:610 +# code block +msgid "~~~\n" +"$ cat ../code/readings_06.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:615 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" action = sys.argv[1]\n" +" filenames = sys.argv[2:]\n" +" assert action in ['--min', '--mean', '--max'], \\\n" +" 'Action is not one of --min, --mean, or --max: ' + action\n" +" if len(filenames) == 0:\n" +" process(sys.stdin, action)\n" +" else:\n" +" for filename in filenames:\n" +" process(filename, action)\n" +"\n" +"def process(filename, action):\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +"\n" +" if action == '--min':\n" +" values = numpy.min(data, axis=1)\n" +" elif action == '--mean':\n" +" values = numpy.mean(data, axis=1)\n" +" elif action == '--max':\n" +" values = numpy.max(data, axis=1)\n" +"\n" +" for val in values:\n" +" print(val)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:649 +msgid "Let's try it out:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:651 +# code block +msgid "~~~\n" +"$ python ../code/readings_06.py --mean < small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:662 +msgid "That's better.\n" +"In fact,\n" +"that's done:\n" +"the program now does everything we set out to do." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:667 +# blockquote, which can be cascaded +msgid "> ## Arithmetic on the Command Line" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:668 +msgid ">\n" +"> Write a command-line program that does addition and subtraction:\n" +">\n" +"> ~~~\n" +"> $ python arith.py add 1 2\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> 3\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:680 +msgid ">\n" +"> ~~~\n" +"> $ python arith.py subtract 3 4\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> -1\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:690 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> >\n" +"> > def main():\n" +"> > assert len(sys.argv) == 4, 'Need exactly 3 arguments'\n" +"> >\n" +"> > operator = sys.argv[1]\n" +"> > assert operator in ['add', 'subtract', 'multiply', 'divide'], \\\n" +"> > 'Operator is not one of add, subtract, multiply, or divide: bailing out'\n" +"> > try:\n" +"> > operand1, operand2 = float(sys.argv[2]), float(sys.argv[3])\n" +"> > except ValueError:\n" +"> > print('cannot convert input to a number: bailing out')\n" +"> > return\n" +"> >\n" +"> > do_arithmetic(operand1, operator, operand2)\n" +"> >\n" +"> > def do_arithmetic(operand1, operator, operand2):\n" +"> >\n" +"> > if operator == 'add':\n" +"> > value = operand1 + operand2\n" +"> > elif operator == 'subtract':\n" +"> > value = operand1 - operand2\n" +"> > elif operator == 'multiply':\n" +"> > value = operand1 * operand2\n" +"> > elif operator == 'divide':\n" +"> > value = operand1 / operand2\n" +"> > print(value)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:727 +# blockquote, which can be cascaded +msgid "> ## Finding Particular Files" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:728 +msgid ">\n" +"> Using the `glob` module introduced [earlier]({{ page.root }}/04-files/),\n" +"> write a simple version of `ls` that shows files in the current directory\n" +"> with a particular suffix.\n" +"> A call to this script should look like this:\n" +">\n" +"> ~~~\n" +"> $ python my_ls.py py\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> left.py\n" +"> right.py\n" +"> zero.py\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:745 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> > import glob\n" +"> >\n" +"> > def main():\n" +"> > \"\"\"prints names of all files with sys.argv as suffix\"\"\"\n" +"> > assert len(sys.argv) >= 2, 'Argument list cannot be empty'\n" +"> > suffix = sys.argv[1] # NB: behaviour is not as you'd expect if sys.argv[1] is *\n" +"> > glob_input = '*.' + suffix # construct the input\n" +"> > glob_output = sorted(glob.glob(glob_input)) # call the glob function\n" +"> > for item in glob_output: # print the output\n" +"> > print(item)\n" +"> > return\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:767 +# blockquote, which can be cascaded +msgid "> ## Changing Flags" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:768 +msgid ">\n" +"> Rewrite `readings.py` so that it uses `-n`, `-m`, and `-x`\n" +"> instead of `--min`, `--mean`, and `--max` respectively.\n" +"> Is the code easier to read?\n" +"> Is the program easier to understand?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # this is code/readings_07.py\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > action = sys.argv[1]\n" +"> > filenames = sys.argv[2:]\n" +"> > assert action in ['-n', '-m', '-x'], \\\n" +"> > 'Action is not one of -n, -m, or -x: ' + action\n" +"> > if len(filenames) == 0:\n" +"> > process(sys.stdin, action)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > process(filename, action)\n" +"> >\n" +"> > def process(filename, action):\n" +"> > data = numpy.loadtxt(filename, delimiter=',')\n" +"> >\n" +"> > if action == '-n':\n" +"> > values = numpy.min(data, axis=1)\n" +"> > elif action == '-m':\n" +"> > values = numpy.mean(data, axis=1)\n" +"> > elif action == '-x':\n" +"> > values = numpy.max(data, axis=1)\n" +"> >\n" +"> > for val in values:\n" +"> > print(val)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:811 +# blockquote, which can be cascaded +msgid "> ## Adding a Help Message" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:812 +msgid ">\n" +"> Separately,\n" +"> modify `readings.py` so that if no parameters are given\n" +"> (i.e., no action is specified and no filenames are given),\n" +"> it prints a message explaining how it should be used.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # this is code/readings_08.py\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > if len(sys.argv) == 1: # no arguments, so print help message\n" +"> > print(\"\"\"Usage: python readings_08.py action filenames\n" +"> > action must be one of --min --mean --max\n" +"> > if filenames is blank, input is taken from stdin;\n" +"> > otherwise, each filename in the list of arguments is processed in turn\"\"\")\n" +"> > return\n" +"> >\n" +"> > action = sys.argv[1]\n" +"> > filenames = sys.argv[2:]\n" +"> > assert action in ['--min', '--mean', '--max'], \\\n" +"> > 'Action is not one of --min, --mean, or --max: ' + action\n" +"> > if len(filenames) == 0:\n" +"> > process(sys.stdin, action)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > process(filename, action)\n" +"> >\n" +"> > def process(filename, action):\n" +"> > data = numpy.loadtxt(filename, delimiter=',')\n" +"> >\n" +"> > if action == '--min':\n" +"> > values = numpy.min(data, axis=1)\n" +"> > elif action == '--mean':\n" +"> > values = numpy.mean(data, axis=1)\n" +"> > elif action == '--max':\n" +"> > values = numpy.max(data, axis=1)\n" +"> >\n" +"> > for val in values:\n" +"> > print(val)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:862 +# blockquote, which can be cascaded +msgid "> ## Adding a Default Action" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:863 +msgid ">\n" +"> Separately,\n" +"> modify `readings.py` so that if no action is given\n" +"> it displays the means of the data.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # this is code/readings_09.py\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > action = sys.argv[1]\n" +"> > if action not in ['--min', '--mean', '--max']: # if no action given\n" +"> > action = '--mean' # set a default action, that being mean\n" +"> > filenames = sys.argv[1:] # start the filenames one place earlier in the argv list\n" +"> > else:\n" +"> > filenames = sys.argv[2:]\n" +"> >\n" +"> > if len(filenames) == 0:\n" +"> > process(sys.stdin, action)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > process(filename, action)\n" +"> >\n" +"> > def process(filename, action):\n" +"> > data = numpy.loadtxt(filename, delimiter=',')\n" +"> >\n" +"> > if action == '--min':\n" +"> > values = numpy.min(data, axis=1)\n" +"> > elif action == '--mean':\n" +"> > values = numpy.mean(data, axis=1)\n" +"> > elif action == '--max':\n" +"> > values = numpy.max(data, axis=1)\n" +"> >\n" +"> > for val in values:\n" +"> > print(val)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:908 +# blockquote, which can be cascaded +msgid "> ## A File-Checker" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:909 +msgid ">\n" +"> Write a program called `check.py` that takes the names of one or more\n" +"> inflammation data files as arguments\n" +"> and checks that all the files have the same number of rows and columns.\n" +"> What is the best way to test your program?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > filenames = sys.argv[1:]\n" +"> > if len(filenames) <=1: #nothing to check\n" +"> > print('Only 1 file specified on input')\n" +"> > else:\n" +"> > nrow0, ncol0 = row_col_count(filenames[0])\n" +"> > print('First file %s: %d rows and %d columns' % (filenames[0], nrow0, ncol0))\n" +"> > for filename in filenames[1:]:\n" +"> > nrow, ncol = row_col_count(filename)\n" +"> > if nrow != nrow0 or ncol != ncol0:\n" +"> > print('File %s does not check: %d rows and %d columns' % (filename, nrow, ncol))\n" +"> > else:\n" +"> > print('File %s checks' % filename)\n" +"> > return\n" +"> >\n" +"> > def row_col_count(filename):\n" +"> > try:\n" +"> > nrow, ncol = numpy.loadtxt(filename, delimiter=',').shape\n" +"> > except ValueError:\n" +"> > # 'ValueError' error is raised when numpy encounters lines that\n" +"> > # have different number of data elements in them than the rest of the lines,\n" +"> > # or when lines have non-numeric elements\n" +"> > nrow, ncol = (0, 0)\n" +"> > return nrow, ncol\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:952 +# blockquote, which can be cascaded +msgid "> ## Counting Lines" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:953 +msgid ">\n" +"> Write a program called `line_count.py` that works like the Unix `wc` command:\n" +">\n" +"> * If no filenames are given, it reports the number of lines in standard input.\n" +"> * If one or more filenames are given, it reports the number of lines in each,\n" +"> followed by the total number of lines.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> >\n" +"> > def main():\n" +"> > \"\"\"print each input filename and the number of lines in it,\n" +"> > and print the sum of the number of lines\"\"\"\n" +"> > filenames = sys.argv[1:]\n" +"> > sum_nlines = 0 #initialize counting variable\n" +"> >\n" +"> > if len(filenames) == 0: # no filenames, just stdin\n" +"> > sum_nlines = count_file_like(sys.stdin)\n" +"> > print('stdin: %d' % sum_nlines)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > nlines = count_file(filename)\n" +"> > print('%s %d' % (filename, nlines))\n" +"> > sum_nlines += nlines\n" +"> > print('total: %d' % sum_nlines)\n" +"> >\n" +"> > def count_file(filename):\n" +"> > \"\"\"count the number of lines in a file\"\"\"\n" +"> > f = open(filename,'r')\n" +"> > nlines = len(f.readlines())\n" +"> > f.close()\n" +"> > return(nlines)\n" +"> >\n" +"> > def count_file_like(file_like):\n" +"> > \"\"\"count the number of lines in a file-like object (eg stdin)\"\"\"\n" +"> > n = 0\n" +"> > for line in file_like:\n" +"> > n = n+1\n" +"> > return n\n" +"> >\n" +"> > main()\n" +"> >\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1001 +# blockquote, which can be cascaded +msgid "> ## Generate an Error Message" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1002 +msgid ">\n" +"> Write a program called `check_arguments.py` that prints usage\n" +"> then exits the program if no arguments are provided.\n" +"> (Hint: You can use `sys.exit()` to exit the program.)\n" +">\n" +"> ~~~\n" +"> $ python check_arguments.py\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> usage: python check_argument.py filename.txt\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1016 +msgid ">\n" +"> ~~~\n" +"> $ python check_arguments.py filename.txt\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> Thanks for specifying arguments!\n" +"> ~~~" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/16__about.md.pot b/transifex/python-novice-inflammation/pot/16__about.md.pot new file mode 100644 index 00000000..3f37dc20 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/16__about.md.pot @@ -0,0 +1,34 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/about.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/about.md:1 +# Front Matter +msgid "---\n" +"title: About\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/about.md:4 +msgid "{% include carpentries.html %}" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/_extras/about.md:4 +msgid "{% include carpentries.html %}\n" +"{% include links.md %}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/17__additional_material.md.pot b/transifex/python-novice-inflammation/pot/17__additional_material.md.pot new file mode 100644 index 00000000..1dbb75df --- /dev/null +++ b/transifex/python-novice-inflammation/pot/17__additional_material.md.pot @@ -0,0 +1,168 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/additional_material.md:1 +# Front Matter +msgid "---\n" +"title: \"Additional material\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:4 +msgid "A collection of facts about Python that do not fit into the main lesson\n" +"either due to the scope or time constraints of the main lesson." +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:8 +# header +msgid "## Jupyter Notebook/IPython: Who's Who in Memory" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:10 +msgid "You can use the `%whos` command at any time to see what\n" +"variables you have created and what modules you have loaded into the computer's memory.\n" +"As this is an IPython command, it will only work if you are in an IPython terminal or the\n" +"Jupyter Notebook." +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:15 +# code block +msgid "~~~\n" +"%whos\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:20 +# code block +msgid "~~~\n" +"Variable Type Data/Info\n" +"--------------------------------\n" +"weight_kg float 100.0\n" +"weight_lb float 143.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:29 +msgid "
\n" +"## Integer Division" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:32 +msgid "We are using Python 3, where division always returns a floating point number:" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:34 +# code block +msgid "~~~\n" +"5/9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:37 +msgid "{: .language-python}\n" +"~~~\n" +"0.5555555555555556\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:43 +msgid "Unfortunately, this wasn't the case in Python 2:\n" +"~~~\n" +"5/9\n" +"~~~\n" +"{: .language-python}\n" +"~~~\n" +"0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:53 +msgid "If you are using Python 2 and want to keep the fractional part of division\n" +"you need to convert one or the other number to floating point:" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:56 +# code block +msgid "~~~\n" +"float(5)/9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:61 +#: python-novice-inflammation/_extras/additional_material.md:71 +#: python-novice-inflammation/_extras/additional_material.md:81 +#: python-novice-inflammation/_extras/additional_material.md:90 +# code block +msgid "~~~\n" +"0.555555555556\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:66 +# code block +msgid "~~~\n" +"5/float(9)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:76 +# code block +msgid "~~~\n" +"5.0/9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:85 +# code block +msgid "~~~\n" +"5/9.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:95 +msgid "And if you want an integer result from division in Python 3,\n" +"use a double-slash:" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:98 +# code block +msgid "~~~\n" +"4//2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:103 +# code block +msgid "~~~\n" +"2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:108 +# code block +msgid "~~~\n" +"3//2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:113 +# code block +msgid "~~~\n" +"1\n" +"~~~" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/18__discuss.md.pot b/transifex/python-novice-inflammation/pot/18__discuss.md.pot new file mode 100644 index 00000000..d85064ae --- /dev/null +++ b/transifex/python-novice-inflammation/pot/18__discuss.md.pot @@ -0,0 +1,592 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/discuss.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/discuss.md:1 +# Front Matter +msgid "---\n" +"title: Discussion\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:4 +# header +msgid "## Rules of Debugging" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:6 +# ordered list +msgid "1. Fail early, fail often." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:7 +# ordered list +msgid "2. Always initialize from data." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:8 +# ordered list +msgid "3. Know what it's supposed to do." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:9 +# ordered list +msgid "4. Make it fail every time." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:10 +# ordered list +msgid "5. Make it fail fast." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:11 +# ordered list +msgid "6. Change one thing at a time, for a reason." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:12 +# ordered list +msgid "7. Keep track of what we've done." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:13 +# ordered list +msgid "8. Be humble." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:14 +# ordered list +msgid "9. Test the simple things first." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:16 +msgid "And remember,\n" +"a week of hard work can sometimes save you an hour of thought." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:19 +# header +msgid "## The Call Stack" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:21 +msgid "Let's take a closer look at what happens when we call `fahr_to_celsius(32.0)`.\n" +"To make things clearer,\n" +"we'll start by putting the initial value 32.0 in a variable\n" +"and store the final result in one as well:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:26 +# code block +msgid "~~~\n" +"original = 32.0\n" +"final = fahr_to_celsius(original)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:32 +msgid "The diagram below shows what memory looks like after the first line has been executed:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:34 +msgid "![Call Stack (Initial State)](../fig/python-call-stack-01.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:36 +msgid "When we call `fahr_to_celsius`,\n" +"Python *doesn't* create the variable `temp` right away.\n" +"Instead,\n" +"it creates something called a [stack frame]({{ page.root }}/reference.html#stack-frame)\n" +"to keep track of the variables defined by `fahr_to_kelvin`.\n" +"Initially,\n" +"this stack frame only holds the value of `temp`:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:44 +msgid "![Call Stack Immediately After First Function Call](../fig/python-call-stack-02.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:46 +msgid "When we call `fahr_to_kelvin` inside `fahr_to_celsius`,\n" +"Python creates another stack frame to hold `fahr_to_kelvin`'s variables:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:49 +msgid "![Call Stack During First Nested Function Call](../fig/python-call-stack-03.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:51 +msgid "It does this because there are now two variables in play called `temp`:\n" +"the parameter to `fahr_to_celsius`,\n" +"and the parameter to `fahr_to_kelvin`.\n" +"Having two variables with the same name in the same part of the program would be ambiguous,\n" +"so Python (and every other modern programming language) creates\n" +"a new stack frame for each function call\n" +"to keep that function's variables separate from those defined by other functions." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:59 +msgid "When the call to `fahr_to_kelvin` returns a value,\n" +"Python throws away `fahr_to_kelvin`'s stack frame\n" +"and creates a new variable in the stack frame for `fahr_to_celsius`\n" +"to hold the temperature in Kelvin:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:64 +msgid "![Call Stack After Return From First Nested Function Call](../fig/python-call-stack-04.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:66 +msgid "It then calls `kelvin_to_celsius`,\n" +"which means it creates a stack frame to hold that function's variables:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:69 +msgid "![Call Stack During Call to Second Nested Function](../fig/python-call-stack-05.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:71 +msgid "Once again,\n" +"Python throws away that stack frame when `kelvin_to_celsius` is done\n" +"and creates the variable `result` in the stack frame for `fahr_to_celsius`:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:75 +msgid "![Call Stack After Second Nested Function Returns](../fig/python-call-stack-06.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:77 +msgid "Finally,\n" +"when `fahr_to_celsius` is done,\n" +"Python throws away *its* stack frame\n" +"and puts its result in a new variable called `final`\n" +"that lives in the stack frame we started with:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:83 +msgid "![Call Stack After All Functions Have Finished](../fig/python-call-stack-07.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:85 +msgid "This final stack frame is always there;\n" +"it holds the variables we defined outside the functions in our code.\n" +"What it *doesn't* hold is the variables that were in the various stack frames.\n" +"If we try to get the value of `temp` after our functions have finished running,\n" +"Python tells us that there's no such thing:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:91 +# code block +msgid "~~~\n" +"print('final value of temp after all function calls:', temp)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:96 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 print('final value of temp after all function calls:', temp)\n" +"\n" +"NameError: name 'temp' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:106 +# code block +msgid "~~~\n" +"final value of temp after all function calls:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:111 +msgid "Why go to all this trouble?\n" +"Well,\n" +"here's a function called `span` that calculates the difference between\n" +"the minimum and maximum values in an array:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:116 +# code block +msgid "~~~\n" +"import numpy\n" +"\n" +"def span(a):\n" +" diff = numpy.max(a) - numpy.min(a)\n" +" return diff\n" +"\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"print('span of data:', span(data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:128 +#: python-novice-inflammation/_extras/discuss.md:142 +# code block +msgid "~~~\n" +"span of data: 20.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:133 +msgid "Notice that `span` assigns a value to a variable called `diff`.\n" +"We might very well use a variable with the same name to hold data:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:136 +# code block +msgid "~~~\n" +"diff = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"print('span of data:', span(diff))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:147 +msgid "We don't expect `diff` to have the value 20.0 after this function call,\n" +"so the name `diff` cannot refer to the same thing inside `span`\n" +"as it does in the main body of our program.\n" +"And yes,\n" +"we could probably choose a different name than `diff` in our main program in this case,\n" +"but we don't want to have to read every line of NumPy to see what variable names its functions use\n" +"before calling any of those functions,\n" +"just in case they change the values of our variables." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:156 +msgid "The big idea here is [encapsulation]({{ page.root }}/reference.html#encapsulation),\n" +"and it's the key to writing correct, comprehensible programs.\n" +"A function's job is to turn several operations into one\n" +"so that we can think about a single function call\n" +"instead of a dozen or a hundred statements\n" +"each time we want to do something.\n" +"That only works if functions don't interfere with each other;\n" +"if they do,\n" +"we have to pay attention to the details once again,\n" +"which quickly overloads our short-term memory." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:167 +# blockquote, which can be cascaded +msgid "> ## Following the Call Stack" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:168 +msgid ">\n" +"> We previously wrote functions called `fence` and `outer`.\n" +"> Draw a diagram showing how the call stack changes when we run the following:\n" +">\n" +"> ~~~\n" +"> print(outer(fence('carbon', '+')))\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:178 +# header +msgid "## Image Grids" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:180 +msgid "Let's start by creating some simple heat maps of our own\n" +"using a library called `ipythonblocks`.\n" +"The first step is to create our own \"image\":" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:184 +# code block +msgid "~~~\n" +"from ipythonblocks import ImageGrid\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:189 +msgid "Unlike the `import` statements we have seen earlier,\n" +"this one doesn't load the entire `ipythonblocks` library.\n" +"Instead,\n" +"it just loads `ImageGrid` from that library,\n" +"since that's the only thing we need (for now)." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:195 +msgid "Once we have `ImageGrid` loaded,\n" +"we can use it to create a very simple grid of colored cells:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:198 +# code block +msgid "~~~\n" +"grid = ImageGrid(5, 3)\n" +"grid.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:204 +msgid "![](../fig/grid-01.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:206 +msgid "Just like a NumPy array,\n" +"an `ImageGrid` has some properties that hold information about it:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:209 +# code block +msgid "~~~\n" +"print('grid width:', grid.width)\n" +"print('grid height:', grid.height)\n" +"print('grid lines on:', grid.lines_on)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:216 +# code block +msgid "~~~\n" +"grid width: 5\n" +"grid height: 3\n" +"grid lines on: True\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:223 +msgid "The obvious thing to do with a grid like this is color in its cells,\n" +"but in order to do that,\n" +"we need to know how computers represent color.\n" +"The most common schemes are [RGB]({{ page.root }}/reference.html#rgb),\n" +"which is short for \"red, green, blue\".\n" +"RGB is an [additive color model]({{ page.root }}/reference.html#additive-color-model):\n" +"every shade is some combination of red, green, and blue intensities.\n" +"We can think of these three values as being the axes in a cube:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:232 +msgid "![RGB Color Cube](../fig/color-cube.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:234 +msgid "An RGB color is an example of a multi-part value:\n" +"like a Cartesian coordinate,\n" +"it is one thing with several parts.\n" +"We can represent such a value in Python using a [tuple]({{ page.root }}/reference.html#tuple),\n" +"which we write using parentheses instead of the square brackets used for a list:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:240 +# code block +msgid "~~~\n" +"position = (12.3, 45.6)\n" +"print('position is:', position)\n" +"color = (10, 20, 30)\n" +"print('color is:', color)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:248 +# code block +msgid "~~~\n" +"position is: (12.3, 45.6)\n" +"color is: (10, 20, 30)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:254 +msgid "We can select elements from tuples using indexing,\n" +"just as we do with lists and arrays:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:257 +# code block +msgid "~~~\n" +"print('first element of color is:', color[0])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:262 +# code block +msgid "~~~\n" +"first element of color is: 10\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:267 +msgid "Unlike lists and arrays,\n" +"though,\n" +"tuples cannot be changed after they are created --- in technical terms,\n" +"they are [immutable]({{ page.root }}/reference.html#immutable):" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:272 +# code block +msgid "~~~\n" +"color[0] = 40\n" +"print('first element of color after change:', color[0])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:278 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"TypeError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 color[0] = 40\n" +"2 print('first element of color after change:', color[0])\n" +"\n" +"TypeError: 'tuple' object does not support item assignment\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:289 +msgid "If a tuple represents an RGB color,\n" +"its red, green, and blue components can take on values between 0 and 255.\n" +"The upper bound may seem odd,\n" +"but it's the largest number that can be represented in an 8-bit byte\n" +"(i.e., 28-1).\n" +"This makes it easy for computers to manipulate colors,\n" +"while providing fine enough gradations to fool most human eyes,\n" +"most of the time." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:298 +msgid "Let's see what a few RGB colors actually look like:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:300 +# code block +msgid "~~~\n" +"row = ImageGrid(8, 1)\n" +"row[0, 0] = (0, 0, 0) # no color => black\n" +"row[1, 0] = (255, 255, 255) # all colors => white\n" +"row[2, 0] = (255, 0, 0) # all red\n" +"row[3, 0] = (0, 255, 0) # all green\n" +"row[4, 0] = (0, 0, 255) # all blue\n" +"row[5, 0] = (255, 255, 0) # red and green\n" +"row[6, 0] = (255, 0, 255) # red and blue\n" +"row[7, 0] = (0, 255, 255) # green and blue\n" +"row.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:314 +msgid "![](../fig/grid-02.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:316 +msgid "Simple color values like `(0,255,0)` are easy enough to decipher with a bit of practice,\n" +"but what color is `(214,90,127)`?\n" +"To help us,\n" +"`ipythonblocks` provides a function called `show_color`:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:321 +# code block +msgid "~~~\n" +"from ipythonblocks import show_color\n" +"show_color(214, 90, 127)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:327 +msgid "![](../fig/ipythonblocks_show_color_example.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:329 +msgid "It also provides a table of standard colors:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:331 +# code block +msgid "~~~\n" +"from ipythonblocks import colors\n" +"c = ImageGrid(3, 2)\n" +"c[0, 0] = colors['Fuchsia']\n" +"c[0, 1] = colors['Salmon']\n" +"c[1, 0] = colors['Orchid']\n" +"c[1, 1] = colors['Lavender']\n" +"c[2, 0] = colors['LimeGreen']\n" +"c[2, 1] = colors['HotPink']\n" +"c.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:344 +msgid "![](../fig/grid-03.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:346 +# blockquote, which can be cascaded +msgid "> ## Making a Colorbar" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:347 +msgid ">\n" +"> Fill in the `____` in the code below to create a bar that changes color from dark blue to black.\n" +">\n" +"> ~~~\n" +"> bar = ImageGrid(10, 1)\n" +"> for x in range(10):\n" +"> bar[x, 0] = (0, 0, ____)\n" +"> bar.show()\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:359 +# blockquote, which can be cascaded +msgid "> ## Why RGB?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:360 +msgid ">\n" +"> Why do computers use red, green, and blue as their primary colors?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:364 +# blockquote, which can be cascaded +msgid "> ## Nested Loops" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:365 +msgid ">\n" +"> Will changing the nesting of the loops in the code above --- i.e.,\n" +"> wrapping the Y-axis loop around the X-axis loop --- change the final image?\n" +"> Why or why not?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:371 +# blockquote, which can be cascaded +msgid "> ## Where to Change Data" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:372 +msgid ">\n" +"> Why did we transpose our data outside our heat map function?\n" +"> Why not have the function perform the transpose?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:377 +# blockquote, which can be cascaded +msgid "> ## Return Versus Display" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:378 +msgid ">\n" +"> Why does the heat map function return the grid rather than displaying it immediately?\n" +"> Do you think this is a good or bad design choice?" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/19__extra_exercises.md.pot b/transifex/python-novice-inflammation/pot/19__extra_exercises.md.pot new file mode 100644 index 00000000..b0e6e29f --- /dev/null +++ b/transifex/python-novice-inflammation/pot/19__extra_exercises.md.pot @@ -0,0 +1,108 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/extra_exercises.md:1 +# Front Matter +msgid "---\n" +"title: \"Additional Exercises\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:4 +msgid "A collection of exercises that have been either removed from\n" +"or not (yet) added to the main lesson." +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:8 +# blockquote, which can be cascaded +msgid "> ## Swapping the contents of variables (5 min)" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:9 +msgid ">\n" +"> Explain what the overall effect of this code is:\n" +">\n" +"> ~~~\n" +"> left = 'L'\n" +"> right = 'R'\n" +">\n" +"> temp = left\n" +"> left = right\n" +"> right = temp\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Compare it to:\n" +">\n" +"> ~~~\n" +"> left, right = [right, left]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Do they always do the same thing?\n" +"> Which do you find easier to read?\n" +">\n" +"> > ## Solution\n" +"> > Both examples exchange the values of `left` and `right`:\n" +"> >\n" +"> > ~~~\n" +"> > print(left, right)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > R L\n" +"> > ~~~\n" +"> > {: .output}\n" +"> >\n" +"> > In the first case we used a temporary variable `temp` to keep the value of `left` before we\n" +"> > overwrite it with the value of `right`. In the second case, `right` and `left` are packed into a\n" +"> > list and then unpacked into `left` and `right`." +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:51 +# blockquote, which can be cascaded +msgid "> ## Fixing and Testing" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:52 +# blockquote, which can be cascaded +msgid "> From: \"Defensive Programming\"" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:53 +msgid ">\n" +"> Fix `range_overlap`. Re-run `test_range_overlap` after each change you make.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def range_overlap(ranges):\n" +"> > '''Return common overlap among a set of [left, right] ranges.'''\n" +"> > if not ranges:\n" +"> > # ranges is None or an empty list\n" +"> > return None\n" +"> > max_left, min_right = ranges[0]\n" +"> > for (left, right) in ranges[1:]:\n" +"> > max_left = max(max_left, left)\n" +"> > min_right = min(min_right, right)\n" +"> > if max_left >= min_right: # no overlap\n" +"> > return None\n" +"> > return (max_left, min_right)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/20__figures.md.pot b/transifex/python-novice-inflammation/pot/20__figures.md.pot new file mode 100644 index 00000000..d113d067 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/20__figures.md.pot @@ -0,0 +1,112 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/figures.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:1 +# Front Matter +msgid "---\n" +"title: Figures\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:5 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:5 +msgid "{% include base_path.html %}\n" +"{% include manual_episode_order.html %}" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:8 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:8 +# inline html +msgid "" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:68 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:68 +msgid "{% comment %} Create anchor for each one of the episodes. {% endcomment %}" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:70 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:70 +msgid "{% for lesson_episode in lesson_episodes %}\n" +" {% if site.episode_order %}\n" +" {% assign episode = site.episodes | where: \"slug\", lesson_episode | first %}\n" +" {% else %}\n" +" {% assign episode = lesson_episode %}\n" +" {% endif %}\n" +"
\n" +"{% endfor %}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/21__guide.md.pot b/transifex/python-novice-inflammation/pot/21__guide.md.pot new file mode 100644 index 00000000..95072305 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/21__guide.md.pot @@ -0,0 +1,238 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/guide.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/guide.md:1 +# Front Matter +msgid "---\n" +"title: \"Instructor Notes\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:5 +# header +msgid "## About the lesson" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:7 +msgid "Our real goal isn't to teach workshop attendees Python as a programming language,\n" +"but to teach them the basic concepts that all programming depends on.\n" +"We use Python in our lessons because:" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:11 +# ordered list +msgid "1. It is free and open-source software." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:12 +# ordered list +msgid "2. It is well-documented and runs on all platforms." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:13 +# ordered list +msgid "3. It has a large and constantly growing user-base which includes scientists." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:14 +# ordered list +msgid "4. It is easier for novices to pick up than most other languages." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:16 +# header +msgid "## Legend" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:18 +msgid "We are using a dataset with records on inflammation from patients following an\n" +"arthritis treatment." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:21 +msgid "We make reference in the lesson that this data is somehow strange. It is strange\n" +"because it is fabricated! The script used to generate the inflammation data\n" +"is included as [`code/gen_inflammation.py`](../code/gen_inflammation.py)." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:25 +# header +msgid "## Overall" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:27 +msgid "This lesson is written as an introduction to Python,\n" +"but its real purpose is to introduce the single most important idea in programming:\n" +"how to solve problems by building functions,\n" +"each of which can fit in a programmer's working memory.\n" +"In order to teach that,\n" +"we must teach people a little about\n" +"the mechanics of manipulating data with lists and file I/O\n" +"so that their functions can do things they actually care about.\n" +"Our teaching order tries to show practical uses of every idea as soon as it is introduced;\n" +"instructors should resist the temptation to explain\n" +"the \"other 90%\" of the language\n" +"as well." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:40 +msgid "The final example asks them to build a command-line tool\n" +"that works with the Unix pipe-and-filter model.\n" +"We do this because it is a useful skill\n" +"and because it helps learners see that the software they use isn't magical.\n" +"Tools like `grep` might be more sophisticated than\n" +"the programs our learners can write at this point in their careers,\n" +"but it's crucial they realize this is a difference of scale rather than kind." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:48 +msgid "Explain that we use Python because:" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:50 +# unordered list +msgid "* It's free." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:51 +# unordered list +msgid "* It has a lot of scientific libraries, and more are constantly being added." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:52 +# unordered list +msgid "* It has a large scientific user community." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:53 +# unordered list +msgid "* It's easier for novices to learn than most of the mature alternatives." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:54 +msgid " (Software Carpentry originally used Perl;\n" +" when we switched,\n" +" we found that we could cover as much material in two days in Python\n" +" as we'd covered in three days in Perl,\n" +" and that retention was higher.)" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:60 +msgid "We do *not* include instructions on running the Jupyter Notebook in the tutorial\n" +"because we want to focus on the language rather than the tools.\n" +"Instructors should, however, walk learners through some basic operations:" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:64 +# unordered list +msgid "* Launch from the command line with `jupyter notebook`." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:65 +# unordered list +msgid "* Create a new notebook." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:66 +# unordered list +msgid "* Enter code or data in a cell and execute it." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:67 +# unordered list +msgid "* Explain the difference between `In[#]` and `Out[#]`." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:69 +msgid "Watching the instructor grow programs step by step\n" +"is as helpful to learners as anything to do with Python.\n" +"Resist the urge to update a single cell repeatedly\n" +"(which is what you'd probably do in real life).\n" +"Instead,\n" +"clone the previous cell and write the update in the new copy\n" +"so that learners have a complete record of how the program grew.\n" +"Once you've done this,\n" +"you can say,\n" +"\"Now why don't we just break things into small functions right from the start?\"" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:80 +msgid "The discussion of command-line scripts\n" +"assumes that students understand standard I/O and building filters,\n" +"which are covered in the lesson on the shell." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:84 +# header +msgid "## Frequently Argued Issues (FAI)" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:86 +# unordered list +msgid "* `import ... as ...` syntax." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:88 +msgid " This syntax is commonly used in the scientific Python community;\n" +" it is explicitly recommended in documentation to `import numpy as np`\n" +" and `import matplotlib.pyplot as plt`. Despite that, we have decided\n" +" not to introduce aliasing imports in this novice lesson due to the\n" +" additional cognitive load it puts on students, despite the typing that\n" +" it saves. A good summary of arguments for and against can be found in\n" +" [PR #61](https://github.com/swcarpentry/python-novice-inflammation/pull/61)." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:96 +msgid " It is up to you as an individual instructor whether you want to introduce\n" +" these aliases when you teach this lesson, but we encourage you to please\n" +" read those arguments thoroughly before deciding one way or the other." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:100 +# unordered list +msgid "* NumPy methods." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:102 +msgid " We used to use NumPy array methods in the first [NumPy topic]({{ page.root }}/01-numpy/).\n" +" We switched these methods to the equivalent functions because a majority\n" +" of instructors supported the change; see\n" +" [PR #244](https://github.com/swcarpentry/python-novice-inflammation/pull/244)\n" +" for detailed arguments for and against the change." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:108 +# unordered list +msgid "* Underscores vs. hyphens in filenames" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:110 +msgid " We used to use hyphens in filenames in order to signify that these Python\n" +" files should only be run as scripts and never imported. However, after some\n" +" [discussion](https://github.com/swcarpentry/python-novice-inflammation/pull/254),\n" +" including an informal Twitter poll, we switched over to underscores because\n" +" many files that start off as Python scripts end up being imported eventually.\n" +" For that reason, we also added `if __name__ == '__main__'` guards around\n" +" `main()` calls, which is how real-world Python scripts ensure that imports\n" +" do not result in side-effects." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:119 +msgid "After discussing the challenges is a good time to introduce the `b *= 2` syntax." +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/22__aio-script.md.pot b/transifex/python-novice-inflammation/pot/22__aio-script.md.pot new file mode 100644 index 00000000..9bcaed56 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/22__aio-script.md.pot @@ -0,0 +1,60 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_includes/aio-script.md:1 +#: python-novice-inflammation/aio.md:5 +msgid "{% comment %}\n" +"As a maintainer, you don't need to edit this file.\n" +"If you notice that something doesn't work, please\n" +"open an issue: https://github.com/carpentries/styles/issues/new\n" +"{% endcomment %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:7 +msgid "{% include manual_episode_order.html %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:9 +msgid "{% for lesson_episode in lesson_episodes %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:11 +msgid "{% if site.episode_order %}\n" +" {% assign e = site.episodes | where: \"slug\", lesson_episode | first %}\n" +"{% else %}\n" +" {% assign e = lesson_episode %}\n" +"{% endif %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:17 +msgid "

{{ e.title }}

" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:19 +msgid "{% include episode_overview.html teaching_time=e.teaching exercise_time=e.exercises episode_questions=e.questions episode_objectives=e.objectives %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:21 +msgid "{{ e.content }}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:23 +msgid "{% include episode_keypoints.html episode_keypoints=e.keypoints %}\n" +"
\n" +"{% endfor %}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/23__links.md.pot b/transifex/python-novice-inflammation/pot/23__links.md.pot new file mode 100644 index 00000000..4baef972 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/23__links.md.pot @@ -0,0 +1,69 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_includes/links.md:1 +msgid "{% include base_path.html %}\n" +"[cc-by-human]: https://creativecommons.org/licenses/by/4.0/\n" +"[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode\n" +"[ci]: http://communityin.org/\n" +"[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html\n" +"[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html\n" +"[concept-maps]: https://carpentries.github.io/instructor-training/05-memory/\n" +"[contrib-covenant]: https://contributor-covenant.org/\n" +"[contributing]: {{ repo_url }}/blob/{{ source_branch }}/CONTRIBUTING.md\n" +"[cran-checkpoint]: https://cran.r-project.org/package=checkpoint\n" +"[cran-knitr]: https://cran.r-project.org/package=knitr\n" +"[cran-stringr]: https://cran.r-project.org/package=stringr\n" +"[dc-lessons]: http://www.datacarpentry.org/lessons/\n" +"[email]: mailto:team@carpentries.org\n" +"[github-importer]: https://import.github.com/\n" +"[importer]: https://github.com/new/import\n" +"[jekyll-collection]: https://jekyllrb.com/docs/collections/\n" +"[jekyll-install]: https://jekyllrb.com/docs/installation/\n" +"[jekyll-windows]: http://jekyll-windows.juthilo.com/\n" +"[jekyll]: https://jekyllrb.com/\n" +"[jupyter]: https://jupyter.org/\n" +"[kramdown]: https://kramdown.gettalong.org/\n" +"[lc-lessons]: https://librarycarpentry.org/lessons/\n" +"[lesson-aio]: {{ relative_root_path }}{% link aio.md %}\n" +"[lesson-coc]: {{ relative_root_path }}{% link CODE_OF_CONDUCT.md %}\n" +"[lesson-example]: https://carpentries.github.io/lesson-example/\n" +"[lesson-license]: {{ relative_root_path }}{% link LICENSE.md %}\n" +"[lesson-mainpage]: {{ relative_root_path }}{% link index.md %}\n" +"[lesson-reference]: {{ relative_root_path }}{% link reference.md %}\n" +"[lesson-setup]: {{ relative_root_path }}{% link setup.md %}\n" +"[mit-license]: https://opensource.org/licenses/mit-license.html\n" +"[morea]: https://morea-framework.github.io/\n" +"[numfocus]: https://numfocus.org/\n" +"[osi]: https://opensource.org\n" +"[pandoc]: https://pandoc.org/\n" +"[paper-now]: https://github.com/PeerJ/paper-now\n" +"[python-gapminder]: https://swcarpentry.github.io/python-novice-gapminder/\n" +"[pyyaml]: https://pypi.org/project/PyYAML/\n" +"[r-markdown]: https://rmarkdown.rstudio.com/\n" +"[rstudio]: https://www.rstudio.com/\n" +"[ruby-install-guide]: https://www.ruby-lang.org/en/downloads/\n" +"[ruby-installer]: https://rubyinstaller.org/\n" +"[rubygems]: https://rubygems.org/pages/download/\n" +"[styles]: https://github.com/carpentries/styles/\n" +"[swc-lessons]: https://software-carpentry.org/lessons/\n" +"[swc-releases]: https://github.com/swcarpentry/swc-releases\n" +"[training]: https://carpentries.github.io/instructor-training/\n" +"[workshop-repo]: {{ site.workshop_repo }}\n" +"[yaml]: http://yaml.org/" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/24__aio.md.pot b/transifex/python-novice-inflammation/pot/24__aio.md.pot new file mode 100644 index 00000000..cffac14d --- /dev/null +++ b/transifex/python-novice-inflammation/pot/24__aio.md.pot @@ -0,0 +1,32 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/aio.md:1 +# Front Matter +msgid "---\n" +"permalink: /aio/index.html\n" +"---" +msgstr "" + +#: python-novice-inflammation/aio.md:11 +msgid "{% include base_path.html %}" +msgstr "" + +#: python-novice-inflammation/aio.md:13 +msgid "{% include aio-script.md %}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/25__01-introduction.md.pot b/transifex/python-novice-inflammation/pot/25__01-introduction.md.pot new file mode 100644 index 00000000..5f94d587 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/25__01-introduction.md.pot @@ -0,0 +1,40 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/bin/boilerplate/_episodes/01-introduction.md:1 +# Front Matter +msgid "---\n" +"title: \"Introduction\"\n" +"teaching: 0\n" +"exercises: 0\n" +"questions:\n" +"- \"Key question (FIXME)\"\n" +"objectives:\n" +"- \"First learning objective. (FIXME)\"\n" +"keypoints:\n" +"- \"First key point. Brief Answer to questions. (FIXME)\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/_episodes/01-introduction.md:12 +#: python-novice-inflammation/bin/boilerplate/_extras/discuss.md:4 +#: python-novice-inflammation/bin/boilerplate/_extras/guide.md:4 +#: python-novice-inflammation/bin/boilerplate/reference.md:7 +#: python-novice-inflammation/bin/boilerplate/setup.md:4 +msgid "FIXME" +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/26__index.md.pot b/transifex/python-novice-inflammation/pot/26__index.md.pot new file mode 100644 index 00000000..5b6c110f --- /dev/null +++ b/transifex/python-novice-inflammation/pot/26__index.md.pot @@ -0,0 +1,151 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/bin/boilerplate/index.md:1 +# Front Matter +msgid "---\n" +"layout: lesson\n" +"root: . # Is the only page that doesn't follow the pattern /:path/index.html\n" +"permalink: index.html # Is the only page that doesn't follow the pattern /:path/index.html\n" +"---" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:6 +msgid "FIXME: home page introduction" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:8 +msgid "" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:10 +msgid "{% comment %} This is a comment in Liquid {% endcomment %}" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:12 +#: python-novice-inflammation/index.md:37 +# blockquote, which can be cascaded +msgid "> ## Prerequisites" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:13 +msgid ">\n" +"> FIXME" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:15 +#: python-novice-inflammation/index.md:44 +# SC/DC Template label +msgid "{: .prereq}" +msgstr "" + +#: python-novice-inflammation/index.md:1 +# Front Matter +msgid "---\n" +"layout: lesson\n" +"root: .\n" +"permalink: index.html\n" +"---" +msgstr "" + +#: python-novice-inflammation/index.md:7 +msgid "The best way to learn how to program is to do something useful,\n" +"so this introduction to Python is built around a common scientific task:\n" +"**data analysis**." +msgstr "" + +#: python-novice-inflammation/index.md:11 +# header +msgid "### Arthritis Inflammation" +msgstr "" + +#: python-novice-inflammation/index.md:12 +msgid "We are studying **inflammation in patients** who have been given a new treatment for arthritis, and\n" +"need to analyze the first dozen data sets of their daily inflammation. The data sets are stored in\n" +"[comma-separated values]({{ page.root }}/reference.html#comma-separated-values) (CSV) format:" +msgstr "" + +#: python-novice-inflammation/index.md:16 +# unordered list +msgid "- each row holds information for a single patient," +msgstr "" + +#: python-novice-inflammation/index.md:17 +# unordered list +msgid "- columns represent successive days." +msgstr "" + +#: python-novice-inflammation/index.md:19 +msgid "The first three rows of our first file look like this:\n" +"~~~\n" +"0,0,1,3,1,2,4,7,8,3,3,3,10,5,7,4,7,7,12,18,6,13,11,11,7,7,4,6,8,8,4,4,5,7,3,4,2,3,0,0\n" +"0,1,2,1,2,1,3,2,2,6,10,11,5,9,4,4,7,16,8,6,18,4,12,5,12,7,11,5,11,3,3,5,4,4,5,5,1,1,0,1\n" +"0,1,1,3,3,2,6,2,5,9,5,7,4,5,4,15,5,11,9,10,19,14,12,17,7,12,11,7,4,2,10,5,4,2,2,3,2,2,1,1\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/index.md:25 +#: python-novice-inflammation/setup.md:118 +#: python-novice-inflammation/setup.md:128 +#: python-novice-inflammation/setup.md:134 +# SC/DC Template label +msgid "{: .source}" +msgstr "" + +#: python-novice-inflammation/index.md:26 +msgid "Each number represents the number of inflammation bouts that a particular patient experienced on a\n" +"given day. For example, value \"6\" at row 3 column 7 of the data set above means that the third\n" +"patient was experiencing inflammation six times on the seventh day of the clinical study." +msgstr "" + +#: python-novice-inflammation/index.md:30 +msgid "So, we want to:" +msgstr "" + +#: python-novice-inflammation/index.md:32 +# ordered list +msgid "1. Calculate the average inflammation per day across all patients." +msgstr "" + +#: python-novice-inflammation/index.md:33 +# ordered list +msgid "2. Plot the result to discuss and share with colleagues." +msgstr "" + +#: python-novice-inflammation/index.md:35 +msgid "To do all that, we'll have to learn a little bit about programming." +msgstr "" + +#: python-novice-inflammation/index.md:38 +msgid ">\n" +"> You need to understand the concepts of **files** and **directories** and how to start a Python\n" +"> interpreter before tackling this lesson. This lesson sometimes references Jupyter\n" +"> Notebook although you can use any Python interpreter mentioned in the [Setup][lesson-setup].\n" +">\n" +"> The commands in this lesson pertain to **Python 3**." +msgstr "" + +#: python-novice-inflammation/index.md:46 +# header +msgid "### Getting Started" +msgstr "" + +#: python-novice-inflammation/index.md:47 +msgid "To get started, follow the directions on the \"[Setup][lesson-setup]\" page to download data\n" +"and install a Python interpreter." +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/27__reference.md.pot b/transifex/python-novice-inflammation/pot/27__reference.md.pot new file mode 100644 index 00000000..3681005d --- /dev/null +++ b/transifex/python-novice-inflammation/pot/27__reference.md.pot @@ -0,0 +1,441 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/bin/boilerplate/reference.md:1 +#: python-novice-inflammation/reference.md:1 +# Front Matter +msgid "---\n" +"layout: reference\n" +"---" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/reference.md:5 +#: python-novice-inflammation/reference.md:5 +# header +msgid "## Glossary" +msgstr "" + +#: python-novice-inflammation/reference.md:7 +msgid "{:auto_ids}\n" +"additive color model\n" +": A way to represent colors as the sum of contributions from primary colors\n" +" such as [red, green, and blue](#rgb)." +msgstr "" + +#: python-novice-inflammation/reference.md:12 +msgid "argument\n" +": A value given to a function or program when it runs.\n" +" The term is often used interchangeably (and inconsistently) with [parameter](#parameter)." +msgstr "" + +#: python-novice-inflammation/reference.md:16 +msgid "assertion\n" +": An expression which is supposed to be true at a particular point in a program.\n" +" Programmers typically put assertions in their code to check for errors;\n" +" if the assertion fails (i.e., if the expression evaluates as false),\n" +" the program halts and produces an error message.\n" +" See also: [invariant](#invariant), [precondition](#precondition),\n" +" [postcondition](#postcondition)." +msgstr "" + +#: python-novice-inflammation/reference.md:24 +msgid "assign\n" +": To give a value a name by associating a variable with it." +msgstr "" + +#: python-novice-inflammation/reference.md:27 +msgid "body\n" +": (of a function): the statements that are executed when a function runs." +msgstr "" + +#: python-novice-inflammation/reference.md:30 +msgid "call stack\n" +": A data structure inside a running program that keeps track of active function calls." +msgstr "" + +#: python-novice-inflammation/reference.md:33 +msgid "case-insensitive\n" +": Treating text as if upper and lower case characters of the same letter were the same.\n" +" See also: [case-sensitive](#case-sensitive)." +msgstr "" + +#: python-novice-inflammation/reference.md:37 +msgid "case-sensitive\n" +": Treating text as if upper and lower case characters of the same letter are different.\n" +" See also: [case-insensitive](#case-insensitive)." +msgstr "" + +#: python-novice-inflammation/reference.md:41 +msgid "comment\n" +": A remark in a program that is intended to help human readers understand what is going on,\n" +" but is ignored by the computer.\n" +" Comments in Python, R, and the Unix shell start with a `#` character and\n" +" run to the end of the line;\n" +" comments in SQL start with `--`,\n" +" and other languages have other conventions." +msgstr "" + +#: python-novice-inflammation/reference.md:49 +msgid "compose\n" +": To apply one function to the result of another, such as `f(g(x))`." +msgstr "" + +#: python-novice-inflammation/reference.md:52 +msgid "conditional statement\n" +": A statement in a program that might or might not be executed\n" +" depending on whether a test is true or false." +msgstr "" + +#: python-novice-inflammation/reference.md:56 +msgid "comma-separated values\n" +": (CSV) A common textual representation for tables\n" +" in which the values in each row are separated by commas." +msgstr "" + +#: python-novice-inflammation/reference.md:60 +msgid "default value\n" +": A value to use for a [parameter](#parameter) if nothing is specified explicitly." +msgstr "" + +#: python-novice-inflammation/reference.md:63 +msgid "defensive programming\n" +": The practice of writing programs that check their own operation\n" +" to catch errors as early as possible." +msgstr "" + +#: python-novice-inflammation/reference.md:67 +msgid "delimiter\n" +": A character or characters used to separate individual values,\n" +" such as the commas between columns in a [CSV](#comma-separated-values) file." +msgstr "" + +#: python-novice-inflammation/reference.md:71 +msgid "docstring\n" +": Short for \"documentation string\",\n" +" this refers to textual documentation embedded in Python programs.\n" +" Unlike comments, docstrings are preserved in the running program\n" +" and can be examined in interactive sessions." +msgstr "" + +#: python-novice-inflammation/reference.md:77 +msgid "documentation\n" +": Human-language text written to explain what software does,\n" +" how it works, or how to use it." +msgstr "" + +#: python-novice-inflammation/reference.md:81 +msgid "dotted notation\n" +": A two-part notation used in many programming languages\n" +" in which `thing.component` refers to the `component` belonging to `thing`." +msgstr "" + +#: python-novice-inflammation/reference.md:85 +msgid "empty string\n" +": A character string containing no characters,\n" +" often thought of as the \"zero\" of text." +msgstr "" + +#: python-novice-inflammation/reference.md:89 +msgid "encapsulation\n" +": The practice of hiding something's implementation details\n" +" so that the rest of a program can worry about *what* it does\n" +" rather than *how* it does it." +msgstr "" + +#: python-novice-inflammation/reference.md:94 +msgid "floating-point number\n" +": A number containing a fractional part and an exponent.\n" +" See also: [integer](#integer)." +msgstr "" + +#: python-novice-inflammation/reference.md:98 +msgid "for loop\n" +": A loop that is executed once for each value in some kind of set, list, or range.\n" +" See also: [while loop](#while-loop)." +msgstr "" + +#: python-novice-inflammation/reference.md:102 +msgid "function\n" +": A named group of instructions that is executed when the function's name is used in\n" +" the code. Occurrence of a function name in the code is a [function call](#function-call).\n" +" Functions may process input [arguments](#argument) and return the result back. Functions\n" +" may also be used for logically grouping together pieces of code. In such cases, they don't\n" +" need to return any meaningful value and can be written without the\n" +" [`return` statement](#return-statement) completely.\n" +" Such functions return a special value `None`, which is a way of saying \"nothing\" in Python." +msgstr "" + +#: python-novice-inflammation/reference.md:111 +msgid "function call\n" +": A use of a function in another piece of software." +msgstr "" + +#: python-novice-inflammation/reference.md:114 +msgid "heat map\n" +": A graphical representation of two-dimensional data in which colors,\n" +" ranging on a scale of hue or intensity, represent the data values." +msgstr "" + +#: python-novice-inflammation/reference.md:118 +msgid "immutable\n" +": Unchangeable.\n" +" The value of immutable data cannot be altered after it has been created.\n" +" See also: [mutable](#mutable)." +msgstr "" + +#: python-novice-inflammation/reference.md:123 +msgid "import\n" +": To load a [library](#library) into a program." +msgstr "" + +#: python-novice-inflammation/reference.md:126 +msgid "in-place operators\n" +": An operator such as `+=` that provides a shorthand notation for\n" +" the common case in which the variable being assigned to\n" +" is also an operand on the right hand side of the assignment.\n" +" For example, the statement `x += 3` means the same thing as `x = x + 3`." +msgstr "" + +#: python-novice-inflammation/reference.md:132 +msgid "index\n" +": A subscript that specifies the location of a single value in a collection,\n" +" such as a single pixel in an image." +msgstr "" + +#: python-novice-inflammation/reference.md:136 +msgid "inner loop\n" +": A loop that is inside another loop. See also: [outer loop](#outer-loop)." +msgstr "" + +#: python-novice-inflammation/reference.md:139 +msgid "integer\n" +": A whole number, such as -12343. See also: [floating-point number](#floating-point-number)." +msgstr "" + +#: python-novice-inflammation/reference.md:142 +msgid "invariant\n" +": An expression whose value doesn't change during the execution of a program,\n" +" typically used in an [assertion](#assertion).\n" +" See also: [precondition](#precondition), [postcondition](#postcondition)." +msgstr "" + +#: python-novice-inflammation/reference.md:147 +msgid "library\n" +": A family of code units (functions, classes, variables) that implement a set of\n" +" related tasks." +msgstr "" + +#: python-novice-inflammation/reference.md:151 +msgid "loop variable\n" +": The variable that keeps track of the progress of the loop." +msgstr "" + +#: python-novice-inflammation/reference.md:154 +msgid "member\n" +": A variable contained within an [object](#object)." +msgstr "" + +#: python-novice-inflammation/reference.md:157 +msgid "method\n" +": A function which is tied to a particular [object](#object).\n" +" Each of an object's methods typically implements one of the things it can do,\n" +" or one of the questions it can answer." +msgstr "" + +#: python-novice-inflammation/reference.md:162 +msgid "mutable\n" +": Changeable. The value of mutable data can be altered after it has been\n" +" created. See [immutable](#immutable).\"" +msgstr "" + +#: python-novice-inflammation/reference.md:166 +msgid "notebook\n" +": Interactive computational environment accessed via your web browser, in which you can write\n" +" and execute Python code and combine it with explanatory text, mathematics and visualizations.\n" +" Examples are IPython or Jupyter notebooks." +msgstr "" + +#: python-novice-inflammation/reference.md:171 +msgid "object\n" +": A collection of conceptually related variables ([members](#member)) and\n" +" functions using those variables ([methods](#method))." +msgstr "" + +#: python-novice-inflammation/reference.md:175 +msgid "outer loop\n" +": A loop that contains another loop.\n" +" See also: [inner loop](#inner-loop)." +msgstr "" + +#: python-novice-inflammation/reference.md:179 +msgid "parameter\n" +": A variable named in the function's declaration that is used to\n" +" hold a value passed into the call.\n" +" The term is often used interchangeably (and inconsistently) with [argument](#argument)." +msgstr "" + +#: python-novice-inflammation/reference.md:184 +msgid "pipe\n" +": A connection from the output of one program to the input of another.\n" +" When two or more programs are connected in this way, they are called a \"pipeline\"." +msgstr "" + +#: python-novice-inflammation/reference.md:188 +msgid "postcondition\n" +": A condition that a function (or other block of code) guarantees is true\n" +" once it has finished running.\n" +" Postconditions are often represented using [assertions](#assertion)." +msgstr "" + +#: python-novice-inflammation/reference.md:193 +msgid "precondition\n" +": A condition that must be true in order for a function (or other block of code)\n" +" to run correctly." +msgstr "" + +#: python-novice-inflammation/reference.md:197 +msgid "regression\n" +": To re-introduce a bug that was once fixed." +msgstr "" + +#: python-novice-inflammation/reference.md:200 +msgid "return statement\n" +": A statement that causes a function to stop executing and return a value\n" +" to its caller immediately." +msgstr "" + +#: python-novice-inflammation/reference.md:204 +msgid "RGB\n" +": An [additive model](#additive-color-model)\n" +" that represents colors as combinations of red, green, and blue.\n" +" Each color's value is typically in the range 0..255\n" +" (i.e., a one-byte integer)." +msgstr "" + +#: python-novice-inflammation/reference.md:210 +msgid "sequence\n" +": A collection of information that is presented in a specific order.\n" +" For example, in Python, a [string](#string) is a sequence of characters,\n" +" while a list is a sequence of any variable." +msgstr "" + +#: python-novice-inflammation/reference.md:215 +msgid "shape\n" +": An array's dimensions, represented as a vector.\n" +" For example, a 5×3 array's shape is `(5,3)`." +msgstr "" + +#: python-novice-inflammation/reference.md:219 +msgid "silent failure\n" +": Failing without producing any warning messages.\n" +" Silent failures are hard to detect and debug." +msgstr "" + +#: python-novice-inflammation/reference.md:223 +msgid "slice\n" +": A regular subsequence of a larger sequence,\n" +" such as the first five elements or every second element." +msgstr "" + +#: python-novice-inflammation/reference.md:227 +msgid "stack frame\n" +": A data structure that provides storage for a function's local variables.\n" +" Each time a function is called, a new stack frame is created\n" +" and put on the top of the [call stack](#call-stack). When the function returns,\n" +" the stack frame is discarded." +msgstr "" + +#: python-novice-inflammation/reference.md:233 +msgid "standard input\n" +": A process's default input stream.\n" +" In interactive command-line applications,\n" +" it is typically connected to the keyboard; in a [pipe](#pipe),\n" +" it receives data from the [standard output](#standard-output) of the preceding process." +msgstr "" + +#: python-novice-inflammation/reference.md:239 +msgid "standard output\n" +": A process's default output stream.\n" +" In interactive command-line applications,\n" +" data sent to standard output is displayed on the screen;\n" +" in a [pipe](#pipe),\n" +" it is passed to the [standard input](#standard-input) of the next process." +msgstr "" + +#: python-novice-inflammation/reference.md:246 +msgid "string\n" +": Short for \"character string\",\n" +" a [sequence](#sequence) of zero or more characters." +msgstr "" + +#: python-novice-inflammation/reference.md:250 +msgid "syntax\n" +": The rules that define how code must be written for a computer to understand." +msgstr "" + +#: python-novice-inflammation/reference.md:253 +msgid "syntax error\n" +": A programming error that occurs when statements are in an order or contain characters\n" +" not expected by the programming language." +msgstr "" + +#: python-novice-inflammation/reference.md:257 +msgid "test oracle\n" +": A program, device, data set, or human being\n" +" against which the results of a test can be compared." +msgstr "" + +#: python-novice-inflammation/reference.md:261 +msgid "test-driven development\n" +": The practice of writing unit tests *before* writing the code they test." +msgstr "" + +#: python-novice-inflammation/reference.md:264 +msgid "traceback\n" +": The sequence of function calls that led to an error." +msgstr "" + +#: python-novice-inflammation/reference.md:267 +msgid "tuple\n" +": An [immutable](#immutable) [sequence](#sequence) of values." +msgstr "" + +#: python-novice-inflammation/reference.md:270 +msgid "type\n" +": The classification of something in a program (for example, the contents of a variable)\n" +" as a kind of number (e.g. [floating-point](#float), [integer](#integer)),\n" +" [string](#string), or something else." +msgstr "" + +#: python-novice-inflammation/reference.md:275 +msgid "type of error\n" +": Indicates the nature of an error in a program. For example, in Python,\n" +" an `IOError` to problems with file input/output.\n" +" See also: [syntax error](#syntax-error)." +msgstr "" + +#: python-novice-inflammation/reference.md:280 +msgid "variable\n" +": A value that has a name associated with it." +msgstr "" + +#: python-novice-inflammation/reference.md:283 +msgid "while loop\n" +": A loop that keeps executing as long as some condition is true.\n" +" See also: [for loop](#for-loop)." +msgstr "" + diff --git a/transifex/python-novice-inflammation/pot/28__setup.md.pot b/transifex/python-novice-inflammation/pot/28__setup.md.pot new file mode 100644 index 00000000..89513100 --- /dev/null +++ b/transifex/python-novice-inflammation/pot/28__setup.md.pot @@ -0,0 +1,232 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/bin/boilerplate/setup.md:1 +#: python-novice-inflammation/setup.md:1 +# Front Matter +msgid "---\n" +"title: Setup\n" +"---" +msgstr "" + +#: python-novice-inflammation/setup.md:5 +# header +msgid "## Overview" +msgstr "" + +#: python-novice-inflammation/setup.md:7 +msgid "This lesson is designed to be run on a personal computer.\n" +"All of the software and data used in this lesson are freely available online,\n" +"and instructions on how to obtain them are provided below." +msgstr "" + +#: python-novice-inflammation/setup.md:11 +# header +msgid "## Install Python" +msgstr "" + +#: python-novice-inflammation/setup.md:13 +msgid "In this lesson, we will be using Python 3 with some of its most popular scientific libraries.\n" +"Although one can install a plain-vanilla Python and all required libraries by hand,\n" +"we recommend installing [Anaconda][anaconda-website],\n" +"a Python distribution that comes with everything we need for the lesson.\n" +"Detailed installation instructions for various operating systems can be found\n" +"on The Carpentries [template website for workshops][anaconda-instructions]\n" +"and in [Anaconda documentation][anaconda-install]." +msgstr "" + +#: python-novice-inflammation/setup.md:21 +# header +msgid "## Obtain lesson materials" +msgstr "" + +#: python-novice-inflammation/setup.md:23 +# ordered list +msgid "1. Download [python-novice-inflammation-data.zip][zipfile1]" +msgstr "" + +#: python-novice-inflammation/setup.md:24 +msgid " and [python-novice-inflammation-code.zip][zipfile2].\n" +"2. Create a folder called `swc-python` on your Desktop.\n" +"3. Move downloaded files to `swc-python`.\n" +"4. Unzip the files." +msgstr "" + +#: python-novice-inflammation/setup.md:29 +msgid "You should see two folders called `data` and `code` in the `swc-python` directory on your\n" +"Desktop." +msgstr "" + +#: python-novice-inflammation/setup.md:32 +# header +msgid "## Launch Python interface" +msgstr "" + +#: python-novice-inflammation/setup.md:34 +msgid "To start working with Python, we need to launch a program that will interpret and execute our Python\n" +"commands. Below we list several options. If you don't have a preference, proceed with the top\n" +"option in the list that is available on your machine. Otherwise, you may use any interface you like." +msgstr "" + +#: python-novice-inflammation/setup.md:38 +# header +msgid "## Option A: Jupyter Notebook" +msgstr "" + +#: python-novice-inflammation/setup.md:40 +msgid "A Jupyter Notebook provides a browser-based interface for working with Python.\n" +"If you installed Anaconda, you can launch a notebook in two ways:" +msgstr "" + +#: python-novice-inflammation/setup.md:43 +# blockquote, which can be cascaded +msgid "> ## Anaconda Navigator" +msgstr "" + +#: python-novice-inflammation/setup.md:44 +msgid ">\n" +"> 1. Launch Anaconda Navigator.\n" +"> It might ask you if you'd like to send anonymized usage information to Anaconda developers:\n" +"> ![Anaconda Navigator first launch]({{ page.root }}{% link fig/anaconda-navigator-first-launch.png %})\n" +"> Make your choice and click \"Ok, and don't show again\" button.\n" +"> 2. Find the \"Notebook\" tab and click on the \"Launch\" button:\n" +"> ![Anaconda Navigator Notebook launch]({{ page.root }}{% link fig/anaconda-navigator-notebook-launch.png %})\n" +"> Anaconda will open a new browser window or tab with a Notebook Dashboard showing you the\n" +"> contents of your Home (or User) folder.\n" +"> 3. Navigate to the `data` directory by clicking on the directory names leading to it:\n" +"> `Desktop`, `swc-python`, then `data`:\n" +"> ![Anaconda Navigator Notebook directory]({{ page.root }}{% link fig/jupyter-notebook-data-directory.png %})\n" +"> 4. Launch the notebook by clicking on the \"New\" button and then selecting \"Python 3\":\n" +"> ![Anaconda Navigator Notebook directory]({{ page.root }}{% link fig/jupyter-notebook-launch-notebook.png %})" +msgstr "" + +#: python-novice-inflammation/setup.md:58 +#: python-novice-inflammation/setup.md:103 +# SC/DC Template label +msgid "{: .solution}" +msgstr "" + +#: python-novice-inflammation/setup.md:60 +# blockquote, which can be cascaded +msgid "> ## Command line (Terminal)" +msgstr "" + +#: python-novice-inflammation/setup.md:61 +msgid ">\n" +"> 1\\. Navigate to the `data` directory:\n" +">\n" +"> > ## Unix shell\n" +"> > If you're using a Unix shell application, such as Terminal app in macOS, Console or Terminal\n" +"> > in Linux, or [Git Bash][gitbash] on Windows, execute the following command:\n" +"> > ~~~\n" +"> > cd ~/Desktop/swc-python/data\n" +"> > ~~~\n" +"> > {: .language-bash}" +msgstr "" + +#: python-novice-inflammation/setup.md:72 +msgid ">\n" +"> > ## Command Prompt (Windows)\n" +"> > On Windows, you can use its native Command Prompt program. The easiest way to start it up is\n" +"> > pressing Windows Logo Key+R, entering `cmd`, and hitting\n" +"> > Return. In the Command Prompt, use the following command to navigate to\n" +"> > the `data` folder:\n" +"> > ~~~\n" +"> > cd /D %userprofile%\\Desktop\\swc-python\\data\n" +"> > ~~~\n" +"> > {: .source}" +msgstr "" + +#: python-novice-inflammation/setup.md:83 +msgid ">\n" +"> 2\\. Start Jupyter server\n" +">\n" +"> > ## Unix shell\n" +"> > ~~~\n" +"> > jupyter notebook\n" +"> > ~~~\n" +"> > {: .language-bash}" +msgstr "" + +#: python-novice-inflammation/setup.md:92 +msgid ">\n" +"> > ## Command Prompt (Windows)\n" +"> > ~~~\n" +"> > python -m notebook\n" +"> > ~~~\n" +"> > {: .source}" +msgstr "" + +#: python-novice-inflammation/setup.md:99 +msgid ">\n" +"> 3\\. Launch the notebook by clicking on the \"New\" button on the right and selecting \"Python 3\"\n" +"> from the drop-down menu:\n" +"> ![Anaconda Navigator Notebook directory]({{ page.root }}{% link fig/jupyter-notebook-launch-notebook2.png %})" +msgstr "" + +#: python-novice-inflammation/setup.md:105 +#: python-novice-inflammation/setup.md:120 +msgid "  " +msgstr "" + +#: python-novice-inflammation/setup.md:107 +# header +msgid "## Option B: IPython interpreter" +msgstr "" + +#: python-novice-inflammation/setup.md:109 +msgid "IPython is an alternative solution situated somewhere in between the plain-vanilla Python\n" +"interpreter and Jupyter Notebook. It provides an interactive command-line based interpreter with\n" +"various convenience features and commands. You should have IPython on your system if you installed\n" +"[Anaconda][anaconda-instructions]." +msgstr "" + +#: python-novice-inflammation/setup.md:114 +msgid "To start using IPython, execute:\n" +"~~~\n" +"ipython\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/setup.md:122 +# header +msgid "## Option C: plain-vanilla Python interpreter" +msgstr "" + +#: python-novice-inflammation/setup.md:124 +msgid "To launch a plain-vanilla Python interpreter, execute:\n" +"~~~\n" +"python\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/setup.md:130 +msgid "If you are using [Git Bash on Windows][gitbash], you have to call Python _via_ `winpty`:\n" +"~~~\n" +"winpty python\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/setup.md:136 +msgid "[anaconda-install]: https://docs.anaconda.com/anaconda/install\n" +"[anaconda-instructions]: https://carpentries.github.io/workshop-template/#python\n" +"[anaconda-website]: https://www.anaconda.com/\n" +"[gitbash]: https://gitforwindows.org\n" +"[zipfile1]: {{ page.root }}/data/python-novice-inflammation-data.zip\n" +"[zipfile2]: {{ page.root }}/code/python-novice-inflammation-code.zip" +msgstr "" + From f1f809a5983e966cec79cf13e89decec5355e75b Mon Sep 17 00:00:00 2001 From: Joel Nitta Date: Fri, 11 Dec 2020 18:21:34 +0900 Subject: [PATCH 5/5] Create PO files for Japanese in transifex/python-novice-inflammation-po --- .../po/00__CODE_OF_CONDUCT.md.ja.po | 61 + .../po/01__CONTRIBUTING.md.ja.po | 318 ++++ .../po/02__LICENSE.md.ja.po | 159 ++ .../po/03__README.md.ja.po | 472 ++++++ .../po/04__01-intro.md.ja.po | 779 ++++++++++ .../po/05__02-numpy.md.ja.po | 1037 +++++++++++++ .../po/06__03-matplotlib.md.ja.po | 344 +++++ .../po/07__04-loop.md.ja.po | 565 +++++++ .../po/08__05-lists.md.ja.po | 736 ++++++++++ .../po/09__06-files.md.ja.po | 254 ++++ .../po/10__07-cond.md.ja.po | 657 +++++++++ .../po/11__08-func.md.ja.po | 1155 +++++++++++++++ .../po/12__09-errors.md.ja.po | 762 ++++++++++ .../po/13__10-defensive.md.ja.po | 747 ++++++++++ .../po/14__11-debugging.md.ja.po | 415 ++++++ .../po/15__12-cmdline.md.ja.po | 1306 +++++++++++++++++ .../po/16__about.md.ja.po | 34 + .../po/17__additional_material.md.ja.po | 168 +++ .../po/18__discuss.md.ja.po | 592 ++++++++ .../po/19__extra_exercises.md.ja.po | 108 ++ .../po/20__figures.md.ja.po | 112 ++ .../po/21__guide.md.ja.po | 238 +++ .../po/22__aio-script.md.ja.po | 60 + .../po/23__links.md.ja.po | 69 + .../po/24__aio.md.ja.po | 32 + .../po/25__01-introduction.md.ja.po | 40 + .../po/26__index.md.ja.po | 151 ++ .../po/27__reference.md.ja.po | 441 ++++++ .../po/28__setup.md.ja.po | 232 +++ 29 files changed, 12044 insertions(+) create mode 100644 transifex/python-novice-inflammation/po/00__CODE_OF_CONDUCT.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/01__CONTRIBUTING.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/02__LICENSE.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/03__README.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/04__01-intro.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/05__02-numpy.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/06__03-matplotlib.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/07__04-loop.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/08__05-lists.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/09__06-files.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/10__07-cond.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/11__08-func.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/12__09-errors.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/13__10-defensive.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/14__11-debugging.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/15__12-cmdline.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/16__about.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/17__additional_material.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/18__discuss.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/19__extra_exercises.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/20__figures.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/21__guide.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/22__aio-script.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/23__links.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/24__aio.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/25__01-introduction.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/26__index.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/27__reference.md.ja.po create mode 100644 transifex/python-novice-inflammation/po/28__setup.md.ja.po diff --git a/transifex/python-novice-inflammation/po/00__CODE_OF_CONDUCT.md.ja.po b/transifex/python-novice-inflammation/po/00__CODE_OF_CONDUCT.md.ja.po new file mode 100644 index 00000000..e296ddc0 --- /dev/null +++ b/transifex/python-novice-inflammation/po/00__CODE_OF_CONDUCT.md.ja.po @@ -0,0 +1,61 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:1 +# Front Matter +msgid "---\n" +"layout: page\n" +"title: \"Contributor Code of Conduct\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:5 +msgid "As contributors and maintainers of this project,\n" +"we pledge to follow the [Carpentry Code of Conduct][coc]." +msgstr "" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:8 +msgid "Instances of abusive, harassing, or otherwise unacceptable behavior\n" +"may be reported by following our [reporting guidelines][coc-reporting]." +msgstr "" + +#: python-novice-inflammation/CODE_OF_CONDUCT.md:11 +#: python-novice-inflammation/_episodes/01-intro.md:225 +#: python-novice-inflammation/_episodes/02-numpy.md:802 +#: python-novice-inflammation/_episodes/03-matplotlib.md:264 +#: python-novice-inflammation/_episodes/04-loop.md:416 +#: python-novice-inflammation/_episodes/05-lists.md:564 +#: python-novice-inflammation/_episodes/06-files.md:194 +#: python-novice-inflammation/_episodes/07-cond.md:508 +#: python-novice-inflammation/_episodes/08-func.md:932 +#: python-novice-inflammation/_episodes/09-errors.md:598 +#: python-novice-inflammation/_episodes/10-defensive.md:542 +#: python-novice-inflammation/_episodes/11-debugging.md:290 +#: python-novice-inflammation/_episodes/12-cmdline.md:1028 +#: python-novice-inflammation/_extras/extra_exercises.md:75 +#: python-novice-inflammation/_extras/figures.md:79 +#: python-novice-inflammation/bin/boilerplate/_episodes/01-introduction.md:14 +#: python-novice-inflammation/bin/boilerplate/_extras/discuss.md:6 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:79 +#: python-novice-inflammation/bin/boilerplate/_extras/guide.md:6 +#: python-novice-inflammation/bin/boilerplate/index.md:17 +#: python-novice-inflammation/bin/boilerplate/reference.md:9 +#: python-novice-inflammation/bin/boilerplate/setup.md:7 +#: python-novice-inflammation/index.md:50 +msgid "{% include links.md %}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/01__CONTRIBUTING.md.ja.po b/transifex/python-novice-inflammation/po/01__CONTRIBUTING.md.ja.po new file mode 100644 index 00000000..0e67f7ba --- /dev/null +++ b/transifex/python-novice-inflammation/po/01__CONTRIBUTING.md.ja.po @@ -0,0 +1,318 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/CONTRIBUTING.md:1 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:1 +# header +msgid "# Contributing" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:3 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:3 +msgid "[The Carpentries][c-site] ([Software Carpentry][swc-site], [Data Carpentry][dc-site], and [Library Carpentry][lc-site]) are open source projects,\n" +"and we welcome contributions of all kinds:\n" +"new lessons,\n" +"fixes to existing material,\n" +"bug reports,\n" +"and reviews of proposed changes are all welcome." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:10 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:10 +# header +msgid "## Contributor Agreement" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:12 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:12 +msgid "By contributing,\n" +"you agree that we may redistribute your work under [our license](LICENSE.md).\n" +"In exchange,\n" +"we will address your issues and/or assess your change proposal as promptly as we can,\n" +"and help you become a member of our community.\n" +"Everyone involved in [The Carpentries][c-site]\n" +"agrees to abide by our [code of conduct](CODE_OF_CONDUCT.md)." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:20 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:20 +# header +msgid "## How to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:22 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:22 +msgid "The easiest way to get started is to file an issue\n" +"to tell us about a spelling mistake,\n" +"some awkward wording,\n" +"or a factual error.\n" +"This is a good way to introduce yourself\n" +"and to meet some of our community members." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:29 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:29 +# ordered list +msgid "1. If you do not have a [GitHub][github] account," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:30 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:30 +msgid " you can [send us comments by email][email].\n" +" However,\n" +" we will be able to respond more quickly if you use one of the other methods described below." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:34 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:34 +# ordered list +msgid "2. If you have a [GitHub][github] account," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:35 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:35 +msgid " or are willing to [create one][github-join],\n" +" but do not know how to use Git,\n" +" you can report problems or suggest improvements by [creating an issue][issues].\n" +" This allows us to assign the item to someone\n" +" and to respond to it in a threaded discussion." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:41 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:41 +# ordered list +msgid "3. If you are comfortable with Git," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:42 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:42 +msgid " and would like to add or change material,\n" +" you can submit a pull request (PR).\n" +" Instructions for doing this are [included below](#using-github)." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:46 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:46 +# header +msgid "## Where to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:48 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:48 +# ordered list +msgid "1. If you wish to change this lesson," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:49 +msgid " please work in ,\n" +" which can be viewed at ." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:52 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:52 +# ordered list +msgid "2. If you wish to change the example lesson," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:53 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:53 +msgid " please work in ,\n" +" which documents the format of our lessons\n" +" and can be viewed at ." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:57 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:57 +# ordered list +msgid "3. If you wish to change the template used for workshop websites," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:58 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:58 +msgid " please work in .\n" +" The home page of that repository explains how to set up workshop websites,\n" +" while the extra pages in \n" +" provide more background on our design choices." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:63 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:63 +# ordered list +msgid "4. If you wish to change CSS style files, tools," +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:64 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:64 +msgid " or HTML boilerplate for lessons or workshops stored in `_includes` or `_layouts`,\n" +" please work in ." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:67 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:67 +# header +msgid "## What to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:69 +msgid "There are many ways to contribute,\n" +"from writing new exercises and improving existing ones\n" +"to updating or filling in the documentation\n" +"and submitting [bug reports][issues]\n" +"about things that don't work, aren't clear, or are missing.\n" +"If you are looking for ideas, please see the 'Issues' tab for\n" +"a list of issues associated with this repository,\n" +"or you may also look at the issues for [Data Carpentry][dc-issues],\n" +"[Software Carpentry][swc-issues], and [Library Carpentry][lc-issues] projects." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:79 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:79 +msgid "Comments on issues and reviews of pull requests are just as welcome:\n" +"we are smarter together than we are on our own.\n" +"Reviews from novices and newcomers are particularly valuable:\n" +"it's easy for people who have been using these lessons for a while\n" +"to forget how impenetrable some of this material can be,\n" +"so fresh eyes are always welcome." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:86 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:86 +# header +msgid "## What *Not* to Contribute" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:88 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:88 +msgid "Our lessons already contain more material than we can cover in a typical workshop,\n" +"so we are usually *not* looking for more concepts or tools to add to them.\n" +"As a rule,\n" +"if you want to introduce a new idea,\n" +"you must (a) estimate how long it will take to teach\n" +"and (b) explain what you would take out to make room for it.\n" +"The first encourages contributors to be honest about requirements;\n" +"the second, to think hard about priorities." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:97 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:97 +msgid "We are also not looking for exercises or other material that only run on one platform.\n" +"Our workshops typically contain a mixture of Windows, macOS, and Linux users;\n" +"in order to be usable,\n" +"our lessons must run equally well on all three." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:102 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:102 +# header +msgid "## Using GitHub" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:104 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:104 +msgid "If you choose to contribute via GitHub, you may want to look at\n" +"[How to Contribute to an Open Source Project on GitHub][how-contribute].\n" +"To manage changes, we follow [GitHub flow][github-flow].\n" +"Each lesson has two maintainers who review issues and pull requests or encourage others to do so.\n" +"The maintainers are community volunteers and have final say over what gets merged into the lesson.\n" +"To use the web interface for contributing to a lesson:" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:111 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:111 +# ordered list +msgid "1. Fork the originating repository to your GitHub profile." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:112 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:112 +# ordered list +msgid "2. Within your version of the forked repository, move to the `gh-pages` branch and" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:113 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:113 +msgid "create a new branch for each significant change being made.\n" +"3. Navigate to the file(s) you wish to change within the new branches and make revisions as required.\n" +"4. Commit all changed files within the appropriate branches.\n" +"5. Create individual pull requests from each of your changed branches\n" +"to the `gh-pages` branch within the originating repository.\n" +"6. If you receive feedback, make changes using your issue-specific branches of the forked\n" +"repository and the pull requests will update automatically.\n" +"7. Repeat as needed until all feedback has been addressed." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:122 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:122 +msgid "When starting work, please make sure your clone of the originating `gh-pages` branch is up-to-date\n" +"before creating your own revision-specific branch(es) from there.\n" +"Additionally, please only work from your newly-created branch(es) and *not*\n" +"your clone of the originating `gh-pages` branch.\n" +"Lastly, published copies of all the lessons are available in the `gh-pages` branch of the originating\n" +"repository for reference while revising." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:129 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:129 +# header +msgid "## Other Resources" +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:131 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:131 +msgid "General discussion of [Software Carpentry][swc-site] and [Data Carpentry][dc-site]\n" +"happens on the [discussion mailing list][discuss-list],\n" +"which everyone is welcome to join.\n" +"You can also [reach us by email][email]." +msgstr "" + +#: python-novice-inflammation/CONTRIBUTING.md:136 +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:136 +msgid "[email]: mailto:admin@software-carpentry.org\n" +"[dc-issues]: https://github.com/issues?q=user%3Adatacarpentry\n" +"[dc-lessons]: http://datacarpentry.org/lessons/\n" +"[dc-site]: http://datacarpentry.org/\n" +"[discuss-list]: https://carpentries.topicbox.com/groups/discuss\n" +"[github]: https://github.com\n" +"[github-flow]: https://guides.github.com/introduction/flow/\n" +"[github-join]: https://github.com/join\n" +"[how-contribute]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github\n" +"[issues]: https://guides.github.com/features/issues/\n" +"[swc-issues]: https://github.com/issues?q=user%3Aswcarpentry\n" +"[swc-lessons]: https://software-carpentry.org/lessons/\n" +"[swc-site]: https://software-carpentry.org/\n" +"[c-site]: https://carpentries.org/\n" +"[lc-site]: https://librarycarpentry.org/\n" +"[lc-issues]: https://github.com/issues?q=user%3Alibrarycarpentry" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:49 +msgid " please work in ,\n" +" which can be viewed at ." +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/CONTRIBUTING.md:69 +msgid "There are many ways to contribute,\n" +"from writing new exercises and improving existing ones\n" +"to updating or filling in the documentation\n" +"and submitting [bug reports][issues]\n" +"about things that don't work, aren't clear, or are missing.\n" +"If you are looking for ideas, please see the 'Issues' tab for\n" +"a list of issues associated with this repository,\n" +"or you may also look at the issues for [Data Carpentry][dc-issues], \n" +"[Software Carpentry][swc-issues], and [Library Carpentry][lc-issues] projects." +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/02__LICENSE.md.ja.po b/transifex/python-novice-inflammation/po/02__LICENSE.md.ja.po new file mode 100644 index 00000000..172f12a8 --- /dev/null +++ b/transifex/python-novice-inflammation/po/02__LICENSE.md.ja.po @@ -0,0 +1,159 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/LICENSE.md:1 +# Front Matter +msgid "---\n" +"layout: page\n" +"title: \"Licenses\"\n" +"root: .\n" +"---" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:6 +# header +msgid "## Instructional Material" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:8 +msgid "All Software Carpentry, Data Carpentry, and Library Carpentry instructional material is\n" +"made available under the [Creative Commons Attribution\n" +"license][cc-by-human]. The following is a human-readable summary of\n" +"(and not a substitute for) the [full legal text of the CC BY 4.0\n" +"license][cc-by-legal]." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:14 +msgid "You are free:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:16 +# unordered list +msgid "* to **Share**---copy and redistribute the material in any medium or format" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:17 +# unordered list +msgid "* to **Adapt**---remix, transform, and build upon the material" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:19 +msgid "for any purpose, even commercially." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:21 +msgid "The licensor cannot revoke these freedoms as long as you follow the\n" +"license terms." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:24 +msgid "Under the following terms:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:26 +# unordered list +msgid "* **Attribution**---You must give appropriate credit (mentioning that" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:27 +msgid " your work is derived from work that is Copyright © Software\n" +" Carpentry and, where practical, linking to\n" +" http://software-carpentry.org/), provide a [link to the\n" +" license][cc-by-human], and indicate if changes were made. You may do\n" +" so in any reasonable manner, but not in any way that suggests the\n" +" licensor endorses you or your use." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:34 +msgid "**No additional restrictions**---You may not apply legal terms or\n" +"technological measures that legally restrict others from doing\n" +"anything the license permits. With the understanding that:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:38 +msgid "Notices:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:40 +# unordered list +msgid "* You do not have to comply with the license for elements of the" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:41 +msgid " material in the public domain or where your use is permitted by an\n" +" applicable exception or limitation.\n" +"* No warranties are given. The license may not give you all of the\n" +" permissions necessary for your intended use. For example, other\n" +" rights such as publicity, privacy, or moral rights may limit how you\n" +" use the material." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:48 +# header +msgid "## Software" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:50 +msgid "Except where otherwise noted, the example programs and other software\n" +"provided by Software Carpentry and Data Carpentry are made available under the\n" +"[OSI][osi]-approved\n" +"[MIT license][mit-license]." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:55 +msgid "Permission is hereby granted, free of charge, to any person obtaining\n" +"a copy of this software and associated documentation files (the\n" +"\"Software\"), to deal in the Software without restriction, including\n" +"without limitation the rights to use, copy, modify, merge, publish,\n" +"distribute, sublicense, and/or sell copies of the Software, and to\n" +"permit persons to whom the Software is furnished to do so, subject to\n" +"the following conditions:" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:63 +msgid "The above copyright notice and this permission notice shall be\n" +"included in all copies or substantial portions of the Software." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:66 +msgid "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n" +"EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n" +"MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n" +"NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n" +"LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n" +"OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n" +"WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:74 +# header +msgid "## Trademark" +msgstr "" + +#: python-novice-inflammation/LICENSE.md:76 +msgid "\"Software Carpentry\" and \"Data Carpentry\" and their respective logos\n" +"are registered trademarks of [Community Initiatives][CI]." +msgstr "" + +#: python-novice-inflammation/LICENSE.md:79 +msgid "[cc-by-human]: https://creativecommons.org/licenses/by/4.0/\n" +"[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode\n" +"[mit-license]: https://opensource.org/licenses/mit-license.html\n" +"[ci]: http://communityin.org/\n" +"[osi]: https://opensource.org" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/03__README.md.ja.po b/transifex/python-novice-inflammation/po/03__README.md.ja.po new file mode 100644 index 00000000..47a5d090 --- /dev/null +++ b/transifex/python-novice-inflammation/po/03__README.md.ja.po @@ -0,0 +1,472 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/README.md:1 +# header +msgid "# Programming with Python" +msgstr "" + +#: python-novice-inflammation/README.md:3 +msgid "[![GitHub release][shields_release]][swc_py_releases]\n" +"[![Create a Slack Account with us][create_slack_svg]][slack_heroku_invite]\n" +"[![Slack Status][slack_channel_status]][slack_channel_url]" +msgstr "" + +#: python-novice-inflammation/README.md:7 +msgid "An introduction to Python for non-programmers using inflammation data." +msgstr "" + +#: python-novice-inflammation/README.md:9 +# header +msgid "## About the Lesson" +msgstr "" + +#: python-novice-inflammation/README.md:11 +msgid "This lesson teaches novice programmers to write modular code to perform data analysis\n" +"using Python. The emphasis, however, is on teaching language-agnostic principles of\n" +"programming such as automation with loops and encapsulation with functions,\n" +"see [Best Practices for Scientific Computing][best-practices] and\n" +"[Good enough practices in scientific computing][good-practices] to learn more." +msgstr "" + +#: python-novice-inflammation/README.md:17 +msgid "The example used in this lesson analyses a set of 12 files with simulated inflammation\n" +"data collected from a trial for a new treatment for arthritis. Learners are shown\n" +"how it is better to automate analysis using functions instead of repeating analysis\n" +"steps manually." +msgstr "" + +#: python-novice-inflammation/README.md:22 +msgid "The rendered version of the lesson is available at:\n" +"." +msgstr "" + +#: python-novice-inflammation/README.md:25 +msgid "This lesson is also available in [R][R] and [MATLAB][MATLAB]." +msgstr "" + +#: python-novice-inflammation/README.md:27 +# header +msgid "## Episodes" +msgstr "" + +#: python-novice-inflammation/README.md:29 +msgid "| # | Episode | Time | Question(s) |\n" +"|--:|:---------|:----:|:------------|\n" +"| 1 | [Python Fundamentals][episode01] | 30 | What basic data types can I work with in Python?
How can I create a new variable in Python?
Can I change the value associated with a variable after I create it? |\n" +"| 2 | [Analyzing Patient Data][episode02] | 60 | How can I process tabular data files in Python? |\n" +"| 3 | [Visualizing Tabular Data][episode03] | 50 | How can I visualize tabular data in Python?
How can I group several plots together? |\n" +"| 4 | [Repeating Actions with Loops][episode04] | 30 | How can I do the same operations on many different values? |\n" +"| 5 | [Storing Multiple Values in Lists][episode05] | 30 | How can I store many values together? |\n" +"| 6 | [Analyzing Data from Multiple Files][episode06] | 20 | How can I do the same operations on many different files? |\n" +"| 7 | [Making Choices][episode07] | 30 | How can my programs do different things based on data values? |\n" +"| 8 | [Creating Functions][episode08] | 30 | How can I define new functions?
What’s the difference between defining and calling a function?
What happens when I call a function? |\n" +"| 9 | [Errors and Exceptions][episode09] | 30 | How does Python report errors?
How can I handle errors in Python programs? |\n" +"|10 | [Defensive Programming][episode10] | 30 | How can I make my programs more reliable? |\n" +"|11 | [Debugging][episode11] | 30 | How can I debug my program? |\n" +"|12 | [Command-Line Programs][episode12] | 30 | How can I write Python programs that will work like Unix command-line tools? |" +msgstr "" + +#: python-novice-inflammation/README.md:45 +#: python-novice-inflammation/bin/boilerplate/README.md:7 +# header +msgid "## Contributing" +msgstr "" + +#: python-novice-inflammation/README.md:46 +msgid "[![Travis Build Status][travis_svg]][travis_url]" +msgstr "" + +#: python-novice-inflammation/README.md:48 +msgid "We welcome all contributions to improve the lesson!\n" +"Maintainers will do their best to help you if you have any questions, concerns,\n" +"or experience any difficulties along the way." +msgstr "" + +#: python-novice-inflammation/README.md:52 +msgid "We'd like to ask you to familiarize yourself with our [Contribution Guide](CONTRIBUTING.md)\n" +"and have a look at the [more detailed guidelines][lesson-example] on proper formatting,\n" +"ways to render the lesson locally, and even how to write new episodes!" +msgstr "" + +#: python-novice-inflammation/README.md:56 +# header +msgid "## Maintainers" +msgstr "" + +#: python-novice-inflammation/README.md:58 +msgid "Lesson maintainers are [Trevor Bekolay][trevor_bekolay], [Maxim Belkin][maxim_belkin],\n" +"[Anne Fouilloux][anne_fouilloux], [Lauren Ko][lauren_ko], [Valentina Staneva][valentina_staneva], and [creator][swc_history] of Software Carpentry:\n" +"[Greg Wilson][greg_wilson]." +msgstr "" + +#: python-novice-inflammation/README.md:62 +#: python-novice-inflammation/bin/boilerplate/README.md:32 +# header +msgid "## Authors" +msgstr "" + +#: python-novice-inflammation/README.md:63 +msgid "A list of contributors to the lesson can be found in [AUTHORS](AUTHORS)." +msgstr "" + +#: python-novice-inflammation/README.md:65 +# header +msgid "## License" +msgstr "" + +#: python-novice-inflammation/README.md:66 +msgid "Instructional material from this lesson is made available under the\n" +"[Creative Commons Attribution][cc-by-human] ([CC BY 4.0][cc-by-legal]) license. Except where\n" +"otherwise noted, example programs and software included as part of this lesson are made available\n" +"under the [MIT license][mit-license]. For more information, see [LICENSE.md](LICENSE.md)." +msgstr "" + +#: python-novice-inflammation/README.md:71 +#: python-novice-inflammation/bin/boilerplate/README.md:36 +# header +msgid "## Citation" +msgstr "" + +#: python-novice-inflammation/README.md:72 +msgid "To cite this lesson, please consult with [CITATION](CITATION)." +msgstr "" + +#: python-novice-inflammation/README.md:74 +# header +msgid "## About Software Carpentry" +msgstr "" + +#: python-novice-inflammation/README.md:76 +msgid "Software Carpentry is a volunteer project that teaches basic computing skills to researchers since\n" +"1998. More information about Software Carpentry can be found [here][swc-about]." +msgstr "" + +#: python-novice-inflammation/README.md:79 +# header +msgid "## About The Carpentries" +msgstr "" + +#: python-novice-inflammation/README.md:81 +msgid "The Carpentries is a fiscally sponsored project of [Community Initiatives][community-initiatives], a\n" +"registered 501(c)3 non-profit organisation based in California, USA. We are a global community\n" +"teaching foundational computational and data science skills to researchers in academia, industry and\n" +"government. More information can be found [here][cp-about]." +msgstr "" + +#: python-novice-inflammation/README.md:86 +msgid "[lesson-example]: https://carpentries.github.io/lesson-example\n" +"[anne_fouilloux]: https://github.com/annefou\n" +"[lauren_ko]: https://github.com/ldko\n" +"[maxim_belkin]: https://github.com/maxim-belkin\n" +"[mike_trizna]: https://github.com/MikeTrizna\n" +"[trevor_bekolay]: http://software-carpentry.org/team/#bekolay_trevor\n" +"[valentina_staneva]: http://software-carpentry.org/team/#staneva_valentina\n" +"[greg_wilson]: https://github.com/gvwilson\n" +"[swc_history]: https://software-carpentry.org/scf/history/\n" +"[best-practices]: http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.1001745\n" +"[good-practices]: http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1005510\n" +"[R]: https://github.com/swcarpentry/r-novice-inflammation\n" +"[MATLAB]: https://github.com/swcarpentry/matlab-novice-inflammation\n" +"[shields_release]: https://img.shields.io/github/release/swcarpentry/python-novice-inflammation.svg\n" +"[swc_py_releases]: https://github.com/swcarpentry/python-novice-inflammation/releases\n" +"[create_slack_svg]: https://img.shields.io/badge/Create_Slack_Account-The_Carpentries-071159.svg\n" +"[slack_heroku_invite]: https://swc-slack-invite.herokuapp.com\n" +"[slack_channel_status]: https://img.shields.io/badge/Slack_Channel-swc--py--inflammation-E01563.svg\n" +"[slack_channel_url]: https://swcarpentry.slack.com/messages/C9Y0L6MF0\n" +"[travis_svg]: https://travis-ci.org/swcarpentry/python-novice-inflammation.svg?branch=gh-pages\n" +"[travis_url]: https://travis-ci.org/swcarpentry/python-novice-inflammation\n" +"[episode01]: https://swcarpentry.github.io/python-novice-inflammation/01-intro/index.html\n" +"[episode02]: https://swcarpentry.github.io/python-novice-inflammation/02-numpy/index.html\n" +"[episode03]: https://swcarpentry.github.io/python-novice-inflammation/03-matplotlib/index.html\n" +"[episode04]: https://swcarpentry.github.io/python-novice-inflammation/04-loop/index.html\n" +"[episode05]: https://swcarpentry.github.io/python-novice-inflammation/05-lists/index.html\n" +"[episode06]: https://swcarpentry.github.io/python-novice-inflammation/06-files/index.html\n" +"[episode07]: https://swcarpentry.github.io/python-novice-inflammation/07-cond/index.html\n" +"[episode08]: https://swcarpentry.github.io/python-novice-inflammation/08-func/index.html\n" +"[episode09]: https://swcarpentry.github.io/python-novice-inflammation/09-errors/index.html\n" +"[episode10]: https://swcarpentry.github.io/python-novice-inflammation/10-defensive/index.html\n" +"[episode11]: https://swcarpentry.github.io/python-novice-inflammation/11-debugging/index.html\n" +"[episode12]: https://swcarpentry.github.io/python-novice-inflammation/12-cmdline/index.html\n" +"[community-initiatives]: https://communityin.org\n" +"[cp-about]: https://carpentries.org/about\n" +"[swc-about]: https://software-carpentry.org/about/\n" +"[mit-license]: https://opensource.org/licenses/mit-license.html\n" +"[cc-by-human]: https://creativecommons.org/licenses/by/4.0/\n" +"[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:1 +# header +msgid "# FIXME Lesson title" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:3 +msgid "[![Create a Slack Account with us](https://img.shields.io/badge/Create_Slack_Account-The_Carpentries-071159.svg)](https://swc-slack-invite.herokuapp.com/)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:5 +msgid "This repository generates the corresponding lesson website from [The Carpentries](https://carpentries.org/) repertoire of lessons. " +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:9 +msgid "We welcome all contributions to improve the lesson! Maintainers will do their best to help you if you have any\n" +"questions, concerns, or experience any difficulties along the way." +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:12 +msgid "We'd like to ask you to familiarize yourself with our [Contribution Guide](CONTRIBUTING.md) and have a look at\n" +"the [more detailed guidelines][lesson-example] on proper formatting, ways to render the lesson locally, and even\n" +"how to write new episodes." +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:16 +msgid "Please see the current list of [issues][FIXME] for ideas for contributing to this\n" +"repository. For making your contribution, we use the GitHub flow, which is\n" +"nicely explained in the chapter [Contributing to a Project](http://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project) in Pro Git\n" +"by Scott Chacon.\n" +"Look for the tag ![good_first_issue](https://img.shields.io/badge/-good%20first%20issue-gold.svg). This indicates that the maintainers will welcome a pull request fixing this issue. " +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:23 +# header +msgid "## Maintainer(s)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:25 +msgid "Current maintainers of this lesson are " +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:27 +#: python-novice-inflammation/bin/boilerplate/README.md:28 +#: python-novice-inflammation/bin/boilerplate/README.md:29 +# unordered list +msgid "* FIXME" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:34 +msgid "A list of contributors to the lesson can be found in [AUTHORS](AUTHORS)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:38 +msgid "To cite this lesson, please consult with [CITATION](CITATION)" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/README.md:40 +msgid "[lesson-example]: https://carpentries.github.io/lesson-example" +msgstr "" + +#: python-novice-inflammation/fig/README.md:1 +# header +msgid "## Why SVG?" +msgstr "" + +#: python-novice-inflammation/fig/README.md:3 +msgid "The SVG format (for \"Scalable Vector Graphics\") has a number of advantages over standard \"raster\"\n" +"graphics formats such as JPG, PNG, etc. Most importantly, as the name suggests, SVG images scale\n" +"up or down without loss of visual clarity: they look equally good on a phone, a laptop computer,\n" +"or a 70-inch screen, and don't blur when scaled up." +msgstr "" + +#: python-novice-inflammation/fig/README.md:8 +msgid "Additionally, SVG is a text-based format (based on XML, if you care). As text files, SVG images\n" +"are thus human-readable (a trained eye makes sense of them) and maintainable: easy to manually\n" +"edit, and efficiently tracked by version control systems (VCSs) such as Git. By contrast, images\n" +"in raster formats, being binary files, are versioned as whole objects -- the slightest change\n" +"results in updating the entire file." +msgstr "" + +#: python-novice-inflammation/fig/README.md:14 +# header +msgid "## Working with SVG figures" +msgstr "" + +#: python-novice-inflammation/fig/README.md:16 +msgid "A number of tools can create or modify SVG images -- pick one you like!" +msgstr "" + +#: python-novice-inflammation/fig/README.md:18 +msgid "Many tools, however, delete comments they don't deem useful, and insert extra information useful\n" +"to them, but unneeded for us, and unsuited to our highly collaborative lesson development process." +msgstr "" + +#: python-novice-inflammation/fig/README.md:21 +msgid "Below are some tips on keeping the information we need and removing the information we don't need\n" +"in SVG files before submitting them to our repository." +msgstr "" + +#: python-novice-inflammation/fig/README.md:24 +# header +msgid "### Comments" +msgstr "" + +#: python-novice-inflammation/fig/README.md:26 +msgid "Before modifying an existing figure, inspect it with a text editor, making note of all comments,\n" +"which in SVG files are enclosed between ``. Be sure to add them back in (with\n" +"appropriate changes) after editing the figure, if the tool you use removed them." +msgstr "" + +#: python-novice-inflammation/fig/README.md:30 +# header +msgid "### General tips" +msgstr "" + +#: python-novice-inflammation/fig/README.md:32 +msgid "When using any SVG editor, please make sure to:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:34 +# unordered list +msgid "- save the figure as \"plain\" SVG rather than editor-specific SVG." +msgstr "" + +#: python-novice-inflammation/fig/README.md:35 +# unordered list +msgid "- not group elements (``) unless necessary or beneficial" +msgstr "" + +#: python-novice-inflammation/fig/README.md:36 +# unordered list +msgid "- not embed other SVG images using ``" +msgstr "" + +#: python-novice-inflammation/fig/README.md:38 +msgid "After editing the figure, clean it up using the command-line tool\n" +"[svgcleaner](https://github.com/RazrFalcon/svgcleaner), by running the following in a terminal\n" +"(replace `SVG_figure` by the name of the SVG figure):" +msgstr "" + +#: python-novice-inflammation/fig/README.md:42 +# code block +msgid "```\n" +"svgcleaner \\\n" +" --indent 2 \\\n" +" --ungroup-defs no \\\n" +" --multipass \\\n" +" --coordinates-precision 1 \\\n" +" --properties-precision 1 \\\n" +" --paths-coordinates-precision 1 \\\n" +" SVG_figure.svg SVG_figure_svgcleaner.svg\n" +"```" +msgstr "" + +#: python-novice-inflammation/fig/README.md:53 +msgid "Alternatively, you can also use [svgo](https://github.com/svg/svgo) or\n" +"[scour](https://www.codedread.com/scour/)." +msgstr "" + +#: python-novice-inflammation/fig/README.md:56 +msgid "**The following steps are optional.**" +msgstr "" + +#: python-novice-inflammation/fig/README.md:58 +msgid "Open the file produced by `svgcleaner` (`SVG_figure_svgcleaner.svg` in the example above)\n" +"and follow these steps:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:61 +# unordered list +msgid "- Wrap lines to be under 100 characters (or less) if possible. For example, change this:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:63 +# code block +msgid " ```xml\n" +" 65.0\n" +" ```" +msgstr "" + +#: python-novice-inflammation/fig/README.md:66 +msgid " to this:\n" +" ```xml\n" +" 65.0\n" +" ```" +msgstr "" + +#: python-novice-inflammation/fig/README.md:75 +# unordered list +msgid "- Comment on the nature of each element, using ``, where applicable and when" +msgstr "" + +#: python-novice-inflammation/fig/README.md:76 +msgid " feasible. For example:" +msgstr "" + +#: python-novice-inflammation/fig/README.md:78 +# code block +msgid " ```xml\n" +" \n" +" " +msgstr "" + +#: python-novice-inflammation/fig/README.md:97 +# header +msgid "## Not an SVG expert" +msgstr "" + +#: python-novice-inflammation/fig/README.md:99 +msgid "Don't let the above guidelines discourage you. If needed, submit your contribution \"as is\" and\n" +"mention which steps you skipped. Maintainers will happily help -- make sure they can commit to the\n" +"branch you use to submit your contribution." +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/04__01-intro.md.ja.po b/transifex/python-novice-inflammation/po/04__01-intro.md.ja.po new file mode 100644 index 00000000..9c5ab0cb --- /dev/null +++ b/transifex/python-novice-inflammation/po/04__01-intro.md.ja.po @@ -0,0 +1,779 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/01-intro.md:1 +# Front Matter +msgid "---\n" +"title: Python Fundamentals\n" +"teaching: 20\n" +"exercises: 10\n" +"questions:\n" +"- \"What basic data types can I work with in Python?\"\n" +"- \"How can I create a new variable in Python?\"\n" +"- \"Can I change the value associated with a variable after I create it?\"\n" +"objectives:\n" +"- \"Assign values to variables.\"\n" +"keypoints:\n" +"- \"Basic data types in Python include integers, strings, and floating-point numbers.\"\n" +"- \"Use `variable = value` to assign a value to a variable in order to record it in memory.\"\n" +"- \"Variables are created on demand whenever a value is assigned to them.\"\n" +"- \"Use `print(something)` to display the value of `something`.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:18 +# header +msgid "## Variables" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:20 +msgid "Any Python interpreter can be used as a calculator:\n" +"~~~\n" +"3 + 5 * 4\n" +"~~~\n" +"{: .language-python}\n" +"~~~\n" +"23\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:28 +#: python-novice-inflammation/_episodes/01-intro.md:87 +#: python-novice-inflammation/_episodes/01-intro.md:98 +#: python-novice-inflammation/_episodes/01-intro.md:110 +#: python-novice-inflammation/_episodes/01-intro.md:121 +#: python-novice-inflammation/_episodes/01-intro.md:135 +#: python-novice-inflammation/_episodes/02-numpy.md:67 +#: python-novice-inflammation/_episodes/02-numpy.md:135 +#: python-novice-inflammation/_episodes/02-numpy.md:150 +#: python-novice-inflammation/_episodes/02-numpy.md:191 +#: python-novice-inflammation/_episodes/02-numpy.md:214 +#: python-novice-inflammation/_episodes/02-numpy.md:224 +#: python-novice-inflammation/_episodes/02-numpy.md:276 +#: python-novice-inflammation/_episodes/02-numpy.md:296 +#: python-novice-inflammation/_episodes/02-numpy.md:317 +#: python-novice-inflammation/_episodes/02-numpy.md:333 +#: python-novice-inflammation/_episodes/02-numpy.md:382 +#: python-novice-inflammation/_episodes/02-numpy.md:415 +#: python-novice-inflammation/_episodes/02-numpy.md:433 +#: python-novice-inflammation/_episodes/02-numpy.md:463 +#: python-novice-inflammation/_episodes/02-numpy.md:476 +#: python-novice-inflammation/_episodes/02-numpy.md:495 +#: python-novice-inflammation/_episodes/04-loop.md:55 +#: python-novice-inflammation/_episodes/04-loop.md:86 +#: python-novice-inflammation/_episodes/04-loop.md:116 +#: python-novice-inflammation/_episodes/04-loop.md:136 +#: python-novice-inflammation/_episodes/04-loop.md:203 +#: python-novice-inflammation/_episodes/04-loop.md:241 +#: python-novice-inflammation/_episodes/04-loop.md:254 +#: python-novice-inflammation/_episodes/05-lists.md:38 +#: python-novice-inflammation/_episodes/05-lists.md:55 +#: python-novice-inflammation/_episodes/05-lists.md:75 +#: python-novice-inflammation/_episodes/05-lists.md:94 +#: python-novice-inflammation/_episodes/05-lists.md:244 +#: python-novice-inflammation/_episodes/05-lists.md:257 +#: python-novice-inflammation/_episodes/05-lists.md:268 +#: python-novice-inflammation/_episodes/05-lists.md:288 +#: python-novice-inflammation/_episodes/05-lists.md:307 +#: python-novice-inflammation/_episodes/05-lists.md:363 +#: python-novice-inflammation/_episodes/05-lists.md:498 +#: python-novice-inflammation/_episodes/05-lists.md:519 +#: python-novice-inflammation/_episodes/06-files.md:40 +#: python-novice-inflammation/_episodes/06-files.md:86 +#: python-novice-inflammation/_episodes/06-files.md:93 +#: python-novice-inflammation/_episodes/06-files.md:100 +#: python-novice-inflammation/_episodes/07-cond.md:46 +#: python-novice-inflammation/_episodes/07-cond.md:75 +#: python-novice-inflammation/_episodes/07-cond.md:96 +#: python-novice-inflammation/_episodes/07-cond.md:128 +#: python-novice-inflammation/_episodes/07-cond.md:141 +#: python-novice-inflammation/_episodes/07-cond.md:217 +#: python-novice-inflammation/_episodes/07-cond.md:237 +#: python-novice-inflammation/_episodes/08-func.md:93 +#: python-novice-inflammation/_episodes/08-func.md:115 +#: python-novice-inflammation/_episodes/08-func.md:136 +#: python-novice-inflammation/_episodes/08-func.md:248 +#: python-novice-inflammation/_episodes/08-func.md:268 +#: python-novice-inflammation/_episodes/08-func.md:287 +#: python-novice-inflammation/_episodes/08-func.md:304 +#: python-novice-inflammation/_episodes/08-func.md:319 +#: python-novice-inflammation/_episodes/08-func.md:366 +#: python-novice-inflammation/_episodes/08-func.md:401 +#: python-novice-inflammation/_episodes/08-func.md:425 +#: python-novice-inflammation/_episodes/08-func.md:483 +#: python-novice-inflammation/_episodes/08-func.md:506 +#: python-novice-inflammation/_episodes/08-func.md:536 +#: python-novice-inflammation/_episodes/08-func.md:553 +#: python-novice-inflammation/_episodes/08-func.md:576 +#: python-novice-inflammation/_episodes/08-func.md:585 +#: python-novice-inflammation/_episodes/09-errors.md:349 +#: python-novice-inflammation/_episodes/10-defensive.md:205 +#: python-novice-inflammation/_episodes/12-cmdline.md:51 +#: python-novice-inflammation/_episodes/12-cmdline.md:106 +#: python-novice-inflammation/_episodes/12-cmdline.md:131 +#: python-novice-inflammation/_episodes/12-cmdline.md:145 +#: python-novice-inflammation/_episodes/12-cmdline.md:279 +#: python-novice-inflammation/_episodes/12-cmdline.md:338 +#: python-novice-inflammation/_episodes/12-cmdline.md:349 +#: python-novice-inflammation/_episodes/12-cmdline.md:360 +#: python-novice-inflammation/_episodes/12-cmdline.md:423 +#: python-novice-inflammation/_episodes/12-cmdline.md:488 +#: python-novice-inflammation/_episodes/12-cmdline.md:586 +#: python-novice-inflammation/_episodes/12-cmdline.md:660 +#: python-novice-inflammation/_extras/additional_material.md:26 +#: python-novice-inflammation/_extras/additional_material.md:41 +#: python-novice-inflammation/_extras/additional_material.md:51 +#: python-novice-inflammation/_extras/additional_material.md:64 +#: python-novice-inflammation/_extras/additional_material.md:74 +#: python-novice-inflammation/_extras/additional_material.md:84 +#: python-novice-inflammation/_extras/additional_material.md:93 +#: python-novice-inflammation/_extras/additional_material.md:106 +#: python-novice-inflammation/_extras/additional_material.md:116 +#: python-novice-inflammation/_extras/discuss.md:109 +#: python-novice-inflammation/_extras/discuss.md:131 +#: python-novice-inflammation/_extras/discuss.md:145 +#: python-novice-inflammation/_extras/discuss.md:221 +#: python-novice-inflammation/_extras/discuss.md:252 +#: python-novice-inflammation/_extras/discuss.md:265 +# SC/DC Template label +msgid "{: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:30 +msgid "This is great but not very interesting.\n" +"To do anything useful with data, we need to assign its value to a _variable_.\n" +"In Python, we can [assign]({{ page.root }}/reference.html#assign) a value to a\n" +"[variable]({{ page.root }}/reference.html#variable), using the equals sign `=`.\n" +"For example, to assign value `60` to a variable `weight_kg`, we would execute:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:36 +# code block +msgid "~~~\n" +"weight_kg = 60\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:39 +#: python-novice-inflammation/_episodes/01-intro.md:67 +#: python-novice-inflammation/_episodes/01-intro.md:74 +#: python-novice-inflammation/_episodes/01-intro.md:82 +#: python-novice-inflammation/_episodes/01-intro.md:105 +#: python-novice-inflammation/_episodes/01-intro.md:130 +#: python-novice-inflammation/_episodes/02-numpy.md:43 +#: python-novice-inflammation/_episodes/02-numpy.md:56 +#: python-novice-inflammation/_episodes/02-numpy.md:115 +#: python-novice-inflammation/_episodes/02-numpy.md:124 +#: python-novice-inflammation/_episodes/02-numpy.md:145 +#: python-novice-inflammation/_episodes/02-numpy.md:186 +#: python-novice-inflammation/_episodes/02-numpy.md:209 +#: python-novice-inflammation/_episodes/02-numpy.md:219 +#: python-novice-inflammation/_episodes/02-numpy.md:268 +#: python-novice-inflammation/_episodes/02-numpy.md:287 +#: python-novice-inflammation/_episodes/02-numpy.md:328 +#: python-novice-inflammation/_episodes/02-numpy.md:372 +#: python-novice-inflammation/_episodes/02-numpy.md:410 +#: python-novice-inflammation/_episodes/02-numpy.md:428 +#: python-novice-inflammation/_episodes/02-numpy.md:451 +#: python-novice-inflammation/_episodes/02-numpy.md:471 +#: python-novice-inflammation/_episodes/02-numpy.md:485 +#: python-novice-inflammation/_episodes/03-matplotlib.md:28 +#: python-novice-inflammation/_episodes/03-matplotlib.md:40 +#: python-novice-inflammation/_episodes/03-matplotlib.md:53 +#: python-novice-inflammation/_episodes/03-matplotlib.md:61 +#: python-novice-inflammation/_episodes/03-matplotlib.md:109 +#: python-novice-inflammation/_episodes/04-loop.md:33 +#: python-novice-inflammation/_episodes/04-loop.md:47 +#: python-novice-inflammation/_episodes/04-loop.md:79 +#: python-novice-inflammation/_episodes/04-loop.md:108 +#: python-novice-inflammation/_episodes/04-loop.md:126 +#: python-novice-inflammation/_episodes/04-loop.md:146 +#: python-novice-inflammation/_episodes/04-loop.md:198 +#: python-novice-inflammation/_episodes/04-loop.md:233 +#: python-novice-inflammation/_episodes/04-loop.md:249 +#: python-novice-inflammation/_episodes/05-lists.md:33 +#: python-novice-inflammation/_episodes/05-lists.md:48 +#: python-novice-inflammation/_episodes/05-lists.md:67 +#: python-novice-inflammation/_episodes/05-lists.md:88 +#: python-novice-inflammation/_episodes/05-lists.md:102 +#: python-novice-inflammation/_episodes/05-lists.md:239 +#: python-novice-inflammation/_episodes/05-lists.md:251 +#: python-novice-inflammation/_episodes/05-lists.md:263 +#: python-novice-inflammation/_episodes/05-lists.md:282 +#: python-novice-inflammation/_episodes/05-lists.md:301 +#: python-novice-inflammation/_episodes/05-lists.md:355 +#: python-novice-inflammation/_episodes/05-lists.md:492 +#: python-novice-inflammation/_episodes/05-lists.md:512 +#: python-novice-inflammation/_episodes/06-files.md:21 +#: python-novice-inflammation/_episodes/06-files.md:33 +#: python-novice-inflammation/_episodes/06-files.md:81 +#: python-novice-inflammation/_episodes/07-cond.md:40 +#: python-novice-inflammation/_episodes/07-cond.md:69 +#: python-novice-inflammation/_episodes/07-cond.md:91 +#: python-novice-inflammation/_episodes/07-cond.md:123 +#: python-novice-inflammation/_episodes/07-cond.md:136 +#: python-novice-inflammation/_episodes/07-cond.md:160 +#: python-novice-inflammation/_episodes/07-cond.md:177 +#: python-novice-inflammation/_episodes/07-cond.md:187 +#: python-novice-inflammation/_episodes/07-cond.md:195 +#: python-novice-inflammation/_episodes/07-cond.md:212 +#: python-novice-inflammation/_episodes/07-cond.md:232 +#: python-novice-inflammation/_episodes/08-func.md:55 +#: python-novice-inflammation/_episodes/08-func.md:78 +#: python-novice-inflammation/_episodes/08-func.md:110 +#: python-novice-inflammation/_episodes/08-func.md:131 +#: python-novice-inflammation/_episodes/08-func.md:174 +#: python-novice-inflammation/_episodes/08-func.md:191 +#: python-novice-inflammation/_episodes/08-func.md:210 +#: python-novice-inflammation/_episodes/08-func.md:229 +#: python-novice-inflammation/_episodes/08-func.md:242 +#: python-novice-inflammation/_episodes/08-func.md:257 +#: python-novice-inflammation/_episodes/08-func.md:281 +#: python-novice-inflammation/_episodes/08-func.md:299 +#: python-novice-inflammation/_episodes/08-func.md:314 +#: python-novice-inflammation/_episodes/08-func.md:338 +#: python-novice-inflammation/_episodes/08-func.md:350 +#: python-novice-inflammation/_episodes/08-func.md:358 +#: python-novice-inflammation/_episodes/08-func.md:387 +#: python-novice-inflammation/_episodes/08-func.md:414 +#: python-novice-inflammation/_episodes/08-func.md:432 +#: python-novice-inflammation/_episodes/08-func.md:466 +#: python-novice-inflammation/_episodes/08-func.md:477 +#: python-novice-inflammation/_episodes/08-func.md:496 +#: python-novice-inflammation/_episodes/08-func.md:526 +#: python-novice-inflammation/_episodes/08-func.md:547 +#: python-novice-inflammation/_episodes/08-func.md:561 +#: python-novice-inflammation/_episodes/08-func.md:594 +#: python-novice-inflammation/_episodes/08-func.md:633 +#: python-novice-inflammation/_episodes/09-errors.md:57 +#: python-novice-inflammation/_episodes/09-errors.md:156 +#: python-novice-inflammation/_episodes/09-errors.md:181 +#: python-novice-inflammation/_episodes/09-errors.md:235 +#: python-novice-inflammation/_episodes/09-errors.md:261 +#: python-novice-inflammation/_episodes/09-errors.md:282 +#: python-novice-inflammation/_episodes/09-errors.md:309 +#: python-novice-inflammation/_episodes/09-errors.md:342 +#: python-novice-inflammation/_episodes/09-errors.md:381 +#: python-novice-inflammation/_episodes/09-errors.md:416 +#: python-novice-inflammation/_episodes/10-defensive.md:78 +#: python-novice-inflammation/_episodes/10-defensive.md:144 +#: python-novice-inflammation/_episodes/10-defensive.md:151 +#: python-novice-inflammation/_episodes/10-defensive.md:173 +#: python-novice-inflammation/_episodes/10-defensive.md:200 +#: python-novice-inflammation/_episodes/10-defensive.md:213 +#: python-novice-inflammation/_episodes/10-defensive.md:313 +#: python-novice-inflammation/_episodes/10-defensive.md:344 +#: python-novice-inflammation/_episodes/10-defensive.md:360 +#: python-novice-inflammation/_episodes/10-defensive.md:387 +#: python-novice-inflammation/_episodes/10-defensive.md:414 +#: python-novice-inflammation/_episodes/10-defensive.md:433 +#: python-novice-inflammation/_episodes/10-defensive.md:440 +#: python-novice-inflammation/_episodes/12-cmdline.md:89 +#: python-novice-inflammation/_episodes/12-cmdline.md:114 +#: python-novice-inflammation/_episodes/12-cmdline.md:173 +#: python-novice-inflammation/_episodes/12-cmdline.md:208 +#: python-novice-inflammation/_episodes/12-cmdline.md:408 +#: python-novice-inflammation/_episodes/12-cmdline.md:475 +#: python-novice-inflammation/_episodes/12-cmdline.md:542 +#: python-novice-inflammation/_episodes/12-cmdline.md:569 +#: python-novice-inflammation/_episodes/12-cmdline.md:647 +#: python-novice-inflammation/_extras/additional_material.md:18 +#: python-novice-inflammation/_extras/additional_material.md:59 +#: python-novice-inflammation/_extras/additional_material.md:69 +#: python-novice-inflammation/_extras/additional_material.md:79 +#: python-novice-inflammation/_extras/additional_material.md:88 +#: python-novice-inflammation/_extras/additional_material.md:101 +#: python-novice-inflammation/_extras/additional_material.md:111 +#: python-novice-inflammation/_extras/discuss.md:30 +#: python-novice-inflammation/_extras/discuss.md:94 +#: python-novice-inflammation/_extras/discuss.md:126 +#: python-novice-inflammation/_extras/discuss.md:140 +#: python-novice-inflammation/_extras/discuss.md:187 +#: python-novice-inflammation/_extras/discuss.md:202 +#: python-novice-inflammation/_extras/discuss.md:214 +#: python-novice-inflammation/_extras/discuss.md:246 +#: python-novice-inflammation/_extras/discuss.md:260 +#: python-novice-inflammation/_extras/discuss.md:276 +#: python-novice-inflammation/_extras/discuss.md:312 +#: python-novice-inflammation/_extras/discuss.md:325 +#: python-novice-inflammation/_extras/discuss.md:342 +msgid "{: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:41 +msgid "From now on, whenever we use `weight_kg`, Python will substitute the value we assigned to\n" +"it. In layman's terms, **a variable is a name for a value**." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:44 +msgid "In Python, variable names:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:46 +# unordered list +msgid " - can include letters, digits, and underscores" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:47 +# unordered list +msgid " - cannot start with a digit" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:48 +# unordered list +msgid " - are [case sensitive]({{ page.root }}/reference.html#case-sensitive)." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:50 +msgid "This means that, for example:\n" +" - `weight0` is a valid variable name, whereas `0weight` is not\n" +" - `weight` and `Weight` are different variables" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:54 +# header +msgid "## Types of data" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:55 +msgid "Python knows various types of data. Three common ones are:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:57 +# unordered list +msgid "* integer numbers" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:58 +# unordered list +msgid "* floating point numbers, and" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:59 +# unordered list +msgid "* strings." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:61 +msgid "In the example above, variable `weight_kg` has an integer value of `60`.\n" +"To create a variable with a floating point value, we can execute:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:64 +# code block +msgid "~~~\n" +"weight_kg = 60.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:69 +msgid "And to create a string, we add single or double quotes around some text, for example:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:71 +# code block +msgid "~~~\n" +"weight_kg_text = 'weight in kilograms:'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:76 +# header +msgid "## Using Variables in Python" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:77 +msgid "To display the value of a variable to the screen in Python, we can use the `print` function:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:79 +# code block +msgid "~~~\n" +"print(weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:84 +#: python-novice-inflammation/_episodes/01-intro.md:118 +# code block +msgid "~~~\n" +"60.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:89 +msgid "We can display multiple things at once using only one `print` command:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:91 +# code block +msgid "~~~\n" +"print(weight_kg_text, weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:94 +msgid "{: .language-python}\n" +"~~~\n" +"weight in kilograms: 60.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:100 +msgid "Moreover, we can do arithmetic with variables right inside the `print` function:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:102 +# code block +msgid "~~~\n" +"print('weight in pounds:', 2.2 * weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:107 +# code block +msgid "~~~\n" +"weight in pounds: 132.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:112 +msgid "The above command, however, did not change the value of `weight_kg`:\n" +"~~~\n" +"print(weight_kg)\n" +"~~~\n" +"{: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:123 +msgid "To change the value of the `weight_kg` variable, we have to\n" +"**assign** `weight_kg` a new value using the equals `=` sign:" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:126 +# code block +msgid "~~~\n" +"weight_kg = 65.0\n" +"print('weight in kilograms is now:', weight_kg)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:132 +# code block +msgid "~~~\n" +"weight in kilograms is now: 65.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:137 +# blockquote, which can be cascaded +msgid "> ## Variables as Sticky Notes" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:138 +msgid ">\n" +"> A variable is analogous to a sticky note with a name written on it:\n" +"> assigning a value to a variable is like putting that sticky note on a particular value.\n" +">\n" +"> ![Value of 65.0 with weight_kg label stuck on it](../fig/python-sticky-note-variables-01.svg)\n" +">\n" +"> This means that assigning a value to one variable does **not** change\n" +"> values of other variables.\n" +"> For example, let's store the subject's weight in pounds in its own variable:\n" +">\n" +"> ~~~\n" +"> # There are 2.2 pounds per kilogram\n" +"> weight_lb = 2.2 * weight_kg\n" +"> print(weight_kg_text, weight_kg, 'and in pounds:', weight_lb)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> weight in kilograms: 65.0 and in pounds: 143.0\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:158 +#: python-novice-inflammation/_episodes/01-intro.md:173 +#: python-novice-inflammation/_episodes/02-numpy.md:175 +#: python-novice-inflammation/_episodes/02-numpy.md:354 +#: python-novice-inflammation/_episodes/02-numpy.md:516 +#: python-novice-inflammation/_episodes/02-numpy.md:632 +#: python-novice-inflammation/_episodes/02-numpy.md:706 +#: python-novice-inflammation/_episodes/02-numpy.md:725 +#: python-novice-inflammation/_episodes/04-loop.md:184 +#: python-novice-inflammation/_episodes/04-loop.md:336 +#: python-novice-inflammation/_episodes/04-loop.md:401 +#: python-novice-inflammation/_episodes/05-lists.md:144 +#: python-novice-inflammation/_episodes/05-lists.md:160 +#: python-novice-inflammation/_episodes/05-lists.md:198 +#: python-novice-inflammation/_episodes/05-lists.md:208 +#: python-novice-inflammation/_episodes/05-lists.md:218 +#: python-novice-inflammation/_episodes/05-lists.md:383 +#: python-novice-inflammation/_episodes/05-lists.md:424 +#: python-novice-inflammation/_episodes/05-lists.md:441 +#: python-novice-inflammation/_episodes/05-lists.md:460 +#: python-novice-inflammation/_episodes/07-cond.md:378 +#: python-novice-inflammation/_episodes/07-cond.md:427 +#: python-novice-inflammation/_episodes/07-cond.md:436 +#: python-novice-inflammation/_episodes/08-func.md:666 +#: python-novice-inflammation/_episodes/08-func.md:729 +#: python-novice-inflammation/_episodes/10-defensive.md:504 +#: python-novice-inflammation/_episodes/10-defensive.md:514 +#: python-novice-inflammation/_episodes/11-debugging.md:279 +#: python-novice-inflammation/_episodes/12-cmdline.md:679 +#: python-novice-inflammation/_episodes/12-cmdline.md:689 +#: python-novice-inflammation/_episodes/12-cmdline.md:744 +#: python-novice-inflammation/_episodes/12-cmdline.md:1015 +#: python-novice-inflammation/_episodes/12-cmdline.md:1025 +# SC/DC Template label +msgid "> {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:159 +msgid ">\n" +"> ![Value of 65.0 with weight_kg label stuck on it, and value of 143.0 with weight_lb label stuck on it](../fig/python-sticky-note-variables-02.svg)\n" +">\n" +"> Let's now change `weight_kg`:\n" +">\n" +"> ~~~\n" +"> weight_kg = 100.0\n" +"> print('weight in kilograms is now:', weight_kg, 'and weight in pounds is still:', weight_lb)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> weight in kilograms is now: 100.0 and weight in pounds is still: 143.0\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:174 +msgid ">\n" +"> ![Value of 100.0 with label weight_kg stuck on it, and value of 143.0 with label weight_lb stuck on it](../fig/python-sticky-note-variables-03.svg)\n" +">\n" +"> Since `weight_lb` doesn't \"remember\" where its value comes from,\n" +"> it is not updated when we change `weight_kg`." +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:179 +#: python-novice-inflammation/_episodes/02-numpy.md:103 +#: python-novice-inflammation/_episodes/02-numpy.md:179 +#: python-novice-inflammation/_episodes/02-numpy.md:256 +#: python-novice-inflammation/_episodes/02-numpy.md:359 +#: python-novice-inflammation/_episodes/02-numpy.md:397 +#: python-novice-inflammation/_episodes/04-loop.md:188 +#: python-novice-inflammation/_episodes/05-lists.md:166 +#: python-novice-inflammation/_episodes/05-lists.md:222 +#: python-novice-inflammation/_episodes/05-lists.md:230 +#: python-novice-inflammation/_episodes/07-cond.md:112 +#: python-novice-inflammation/_episodes/07-cond.md:147 +#: python-novice-inflammation/_episodes/09-errors.md:104 +#: python-novice-inflammation/_episodes/09-errors.md:224 +#: python-novice-inflammation/_episodes/11-debugging.md:202 +#: python-novice-inflammation/_episodes/12-cmdline.md:32 +#: python-novice-inflammation/_episodes/12-cmdline.md:307 +#: python-novice-inflammation/_episodes/12-cmdline.md:321 +#: python-novice-inflammation/_episodes/12-cmdline.md:437 +# SC/DC Template label +msgid "{: .callout}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:182 +# blockquote, which can be cascaded +msgid "> ## Check Your Understanding" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:183 +msgid ">\n" +"> What values do the variables `mass` and `age` have after each of the following statements?\n" +"> Test your answer by executing the lines.\n" +">\n" +"> ~~~\n" +"> mass = 47.5\n" +"> age = 122\n" +"> mass = mass * 2.0\n" +"> age = age - 20\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > `mass` holds a value of 47.5, `age` does not exist\n" +"> > `mass` still holds a value of 47.5, `age` holds a value of 122\n" +"> > `mass` now has a value of 95.0, `age`'s value is still 122\n" +"> > `mass` still has a value of 95.0, `age` now holds 102\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:203 +#: python-novice-inflammation/_episodes/01-intro.md:222 +#: python-novice-inflammation/_episodes/02-numpy.md:529 +#: python-novice-inflammation/_episodes/02-numpy.md:540 +#: python-novice-inflammation/_episodes/02-numpy.md:548 +#: python-novice-inflammation/_episodes/02-numpy.md:573 +#: python-novice-inflammation/_episodes/02-numpy.md:590 +#: python-novice-inflammation/_episodes/02-numpy.md:661 +#: python-novice-inflammation/_episodes/02-numpy.md:682 +#: python-novice-inflammation/_episodes/02-numpy.md:743 +#: python-novice-inflammation/_episodes/02-numpy.md:752 +#: python-novice-inflammation/_episodes/02-numpy.md:799 +#: python-novice-inflammation/_episodes/03-matplotlib.md:137 +#: python-novice-inflammation/_episodes/03-matplotlib.md:158 +#: python-novice-inflammation/_episodes/03-matplotlib.md:169 +#: python-novice-inflammation/_episodes/03-matplotlib.md:210 +#: python-novice-inflammation/_episodes/03-matplotlib.md:224 +#: python-novice-inflammation/_episodes/03-matplotlib.md:261 +#: python-novice-inflammation/_episodes/04-loop.md:292 +#: python-novice-inflammation/_episodes/04-loop.md:319 +#: python-novice-inflammation/_episodes/04-loop.md:349 +#: python-novice-inflammation/_episodes/04-loop.md:368 +#: python-novice-inflammation/_episodes/04-loop.md:413 +#: python-novice-inflammation/_episodes/05-lists.md:333 +#: python-novice-inflammation/_episodes/05-lists.md:400 +#: python-novice-inflammation/_episodes/05-lists.md:479 +#: python-novice-inflammation/_episodes/05-lists.md:559 +#: python-novice-inflammation/_episodes/06-files.md:136 +#: python-novice-inflammation/_episodes/07-cond.md:271 +#: python-novice-inflammation/_episodes/07-cond.md:335 +#: python-novice-inflammation/_episodes/07-cond.md:348 +#: python-novice-inflammation/_episodes/07-cond.md:358 +#: python-novice-inflammation/_episodes/07-cond.md:404 +#: python-novice-inflammation/_episodes/07-cond.md:480 +#: python-novice-inflammation/_episodes/07-cond.md:503 +#: python-novice-inflammation/_episodes/08-func.md:674 +#: python-novice-inflammation/_episodes/08-func.md:709 +#: python-novice-inflammation/_episodes/08-func.md:737 +#: python-novice-inflammation/_episodes/08-func.md:756 +#: python-novice-inflammation/_episodes/08-func.md:781 +#: python-novice-inflammation/_episodes/08-func.md:802 +#: python-novice-inflammation/_episodes/08-func.md:836 +#: python-novice-inflammation/_episodes/08-func.md:885 +#: python-novice-inflammation/_episodes/08-func.md:921 +#: python-novice-inflammation/_episodes/09-errors.md:499 +#: python-novice-inflammation/_episodes/09-errors.md:529 +#: python-novice-inflammation/_episodes/09-errors.md:571 +#: python-novice-inflammation/_episodes/09-errors.md:595 +#: python-novice-inflammation/_episodes/10-defensive.md:488 +#: python-novice-inflammation/_episodes/10-defensive.md:539 +#: python-novice-inflammation/_episodes/11-debugging.md:287 +#: python-novice-inflammation/_episodes/12-cmdline.md:724 +#: python-novice-inflammation/_episodes/12-cmdline.md:764 +#: python-novice-inflammation/_episodes/12-cmdline.md:808 +#: python-novice-inflammation/_episodes/12-cmdline.md:859 +#: python-novice-inflammation/_episodes/12-cmdline.md:905 +#: python-novice-inflammation/_episodes/12-cmdline.md:949 +#: python-novice-inflammation/_episodes/12-cmdline.md:998 +#: python-novice-inflammation/_extras/extra_exercises.md:48 +#: python-novice-inflammation/_extras/extra_exercises.md:72 +#: python-novice-inflammation/setup.md:71 +#: python-novice-inflammation/setup.md:82 +#: python-novice-inflammation/setup.md:91 +#: python-novice-inflammation/setup.md:98 +# SC/DC Template label +msgid "> {: .solution}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:204 +#: python-novice-inflammation/_episodes/01-intro.md:223 +#: python-novice-inflammation/_episodes/02-numpy.md:574 +#: python-novice-inflammation/_episodes/02-numpy.md:591 +#: python-novice-inflammation/_episodes/02-numpy.md:683 +#: python-novice-inflammation/_episodes/02-numpy.md:800 +#: python-novice-inflammation/_episodes/03-matplotlib.md:170 +#: python-novice-inflammation/_episodes/03-matplotlib.md:211 +#: python-novice-inflammation/_episodes/03-matplotlib.md:225 +#: python-novice-inflammation/_episodes/03-matplotlib.md:262 +#: python-novice-inflammation/_episodes/04-loop.md:293 +#: python-novice-inflammation/_episodes/04-loop.md:320 +#: python-novice-inflammation/_episodes/04-loop.md:350 +#: python-novice-inflammation/_episodes/04-loop.md:369 +#: python-novice-inflammation/_episodes/04-loop.md:414 +#: python-novice-inflammation/_episodes/05-lists.md:334 +#: python-novice-inflammation/_episodes/05-lists.md:401 +#: python-novice-inflammation/_episodes/05-lists.md:480 +#: python-novice-inflammation/_episodes/05-lists.md:560 +#: python-novice-inflammation/_episodes/06-files.md:137 +#: python-novice-inflammation/_episodes/06-files.md:192 +#: python-novice-inflammation/_episodes/07-cond.md:272 +#: python-novice-inflammation/_episodes/07-cond.md:296 +#: python-novice-inflammation/_episodes/07-cond.md:315 +#: python-novice-inflammation/_episodes/07-cond.md:359 +#: python-novice-inflammation/_episodes/07-cond.md:405 +#: python-novice-inflammation/_episodes/07-cond.md:481 +#: python-novice-inflammation/_episodes/07-cond.md:504 +#: python-novice-inflammation/_episodes/08-func.md:675 +#: python-novice-inflammation/_episodes/08-func.md:710 +#: python-novice-inflammation/_episodes/08-func.md:738 +#: python-novice-inflammation/_episodes/08-func.md:757 +#: python-novice-inflammation/_episodes/08-func.md:782 +#: python-novice-inflammation/_episodes/08-func.md:803 +#: python-novice-inflammation/_episodes/08-func.md:837 +#: python-novice-inflammation/_episodes/08-func.md:886 +#: python-novice-inflammation/_episodes/08-func.md:922 +#: python-novice-inflammation/_episodes/08-func.md:930 +#: python-novice-inflammation/_episodes/09-errors.md:500 +#: python-novice-inflammation/_episodes/09-errors.md:530 +#: python-novice-inflammation/_episodes/09-errors.md:572 +#: python-novice-inflammation/_episodes/09-errors.md:596 +#: python-novice-inflammation/_episodes/10-defensive.md:489 +#: python-novice-inflammation/_episodes/10-defensive.md:540 +#: python-novice-inflammation/_episodes/11-debugging.md:247 +#: python-novice-inflammation/_episodes/11-debugging.md:288 +#: python-novice-inflammation/_episodes/12-cmdline.md:725 +#: python-novice-inflammation/_episodes/12-cmdline.md:765 +#: python-novice-inflammation/_episodes/12-cmdline.md:809 +#: python-novice-inflammation/_episodes/12-cmdline.md:860 +#: python-novice-inflammation/_episodes/12-cmdline.md:906 +#: python-novice-inflammation/_episodes/12-cmdline.md:950 +#: python-novice-inflammation/_episodes/12-cmdline.md:999 +#: python-novice-inflammation/_episodes/12-cmdline.md:1026 +#: python-novice-inflammation/_extras/discuss.md:176 +#: python-novice-inflammation/_extras/discuss.md:357 +#: python-novice-inflammation/_extras/discuss.md:362 +#: python-novice-inflammation/_extras/discuss.md:369 +#: python-novice-inflammation/_extras/discuss.md:375 +#: python-novice-inflammation/_extras/discuss.md:381 +#: python-novice-inflammation/_extras/extra_exercises.md:49 +#: python-novice-inflammation/_extras/extra_exercises.md:73 +# SC/DC Template label +msgid "{: .challenge}" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:206 +# blockquote, which can be cascaded +msgid "> ## Sorting Out References" +msgstr "" + +#: python-novice-inflammation/_episodes/01-intro.md:207 +msgid ">\n" +"> What does the following program print out?\n" +">\n" +"> ~~~\n" +"> first, second = 'Grace', 'Hopper'\n" +"> third, fourth = second, first\n" +"> print(third, fourth)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > Hopper Grace\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/05__02-numpy.md.ja.po b/transifex/python-novice-inflammation/po/05__02-numpy.md.ja.po new file mode 100644 index 00000000..36db12e6 --- /dev/null +++ b/transifex/python-novice-inflammation/po/05__02-numpy.md.ja.po @@ -0,0 +1,1037 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/02-numpy.md:1 +# Front Matter +msgid "---\n" +"title: Analyzing Patient Data\n" +"teaching: 40\n" +"exercises: 20\n" +"questions:\n" +"- \"How can I process tabular data files in Python?\"\n" +"objectives:\n" +"- \"Explain what a library is and what libraries are used for.\"\n" +"- \"Import a Python library and use the functions it contains.\"\n" +"- \"Read tabular data from a file into a program.\"\n" +"- \"Select individual values and subsections from data.\"\n" +"- \"Perform operations on arrays of data.\"\n" +"keypoints:\n" +"- \"Import a library into a program using `import libraryname`.\"\n" +"- \"Use the `numpy` library to work with arrays in Python.\"\n" +"- \"The expression `array.shape` gives the shape of an array.\"\n" +"- \"Use `array[x, y]` to select a single element from a 2D array.\"\n" +"- \"Array indices start at 0, not 1.\"\n" +"- \"Use `low:high` to specify a `slice` that includes the indices from `low` to `high-1`.\"\n" +"- \"Use `# some kind of explanation` to add comments to programs.\"\n" +"- \"Use `numpy.mean(array)`, `numpy.max(array)`, and `numpy.min(array)` to calculate simple statistics.\"\n" +"- \"Use `numpy.mean(array, axis=0)` or `numpy.mean(array, axis=1)` to calculate statistics across the specified axis.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:25 +msgid "Words are useful, but what's more useful are the sentences and stories we build with them.\n" +"Similarly, while a lot of powerful, general tools are built into Python,\n" +"specialized tools built up from these basic units live in\n" +"[libraries]({{ page.root }}/reference.html#library)\n" +"that can be called upon when needed." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:31 +# header +msgid "## Loading data into Python" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:33 +msgid "To begin processing inflammation data, we need to load it into Python.\n" +"We can do that using a library called\n" +"[NumPy](http://docs.scipy.org/doc/numpy/ \"NumPy Documentation\"), which stands for Numerical Python.\n" +"In general, you should use this library when you want to do fancy things with lots of numbers,\n" +"especially if you have matrices or arrays. To tell Python that we'd like to start using NumPy,\n" +"we need to [import]({{ page.root }}/reference.html#import) it:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:40 +#: python-novice-inflammation/_episodes/07-cond.md:157 +# code block +msgid "~~~\n" +"import numpy\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:45 +msgid "Importing a library is like getting a piece of lab equipment out of a storage locker and setting it\n" +"up on the bench. Libraries provide additional functionality to the basic Python package, much like\n" +"a new piece of equipment adds functionality to a lab space. Just like in the lab, importing too\n" +"many libraries can sometimes complicate and slow down your programs - so we only import what we\n" +"need for each program." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:51 +msgid "Once we've imported the library, we can ask the library to read our data file for us:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:53 +# code block +msgid "~~~\n" +"numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:58 +#: python-novice-inflammation/_episodes/08-func.md:416 +# code block +msgid "~~~\n" +"array([[ 0., 0., 1., ..., 3., 0., 0.],\n" +" [ 0., 1., 2., ..., 1., 0., 1.],\n" +" [ 0., 1., 1., ..., 2., 1., 1.],\n" +" ...,\n" +" [ 0., 1., 1., ..., 1., 1., 1.],\n" +" [ 0., 0., 0., ..., 0., 2., 0.],\n" +" [ 0., 0., 1., ..., 1., 1., 0.]])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:69 +msgid "The expression `numpy.loadtxt(...)` is a [function call]({{ page.root }}/reference.html#function-call)\n" +"that asks Python to run the [function]({{ page.root }}/reference.html#function) `loadtxt` which\n" +"belongs to the `numpy` library. This [dotted notation]({{ page.root }}/reference.html#dotted-notation)\n" +"is used everywhere in Python: the thing that appears before the dot contains the thing that\n" +"appears after." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:75 +msgid "As an example, John Smith is the John that belongs to the Smith family.\n" +"We could use the dot notation to write his name `smith.john`,\n" +"just as `loadtxt` is a function that belongs to the `numpy` library." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:79 +msgid "`numpy.loadtxt` has two [parameters]({{ page.root }}/reference.html#parameter): the name of the file\n" +"we want to read and the [delimiter]({{ page.root }}/reference.html#delimiter) that separates values on\n" +"a line. These both need to be character strings (or [strings]({{ page.root }}/reference.html#string)\n" +"for short), so we put them in quotes." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:84 +msgid "Since we haven't told it to do anything else with the function's output,\n" +"the [notebook]({{ page.root }}/reference.html#notebook) displays it.\n" +"In this case,\n" +"that output is the data we just loaded.\n" +"By default,\n" +"only a few rows and columns are shown\n" +"(with `...` to omit elements when displaying big arrays).\n" +"Note that, to save space when displaying NumPy arrays, Python does not show us trailing zeros, so `1.0` becomes `1.`." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:93 +# blockquote, which can be cascaded +msgid "> ## Importing libraries with shortcuts" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:94 +msgid ">\n" +"> In this lesson we use the `import numpy` [syntax]({{ page.root }}/reference.html#syntax) to import NumPy.\n" +"> However, shortcuts such as `import numpy as np` are frequently used. Importing NumPy this way means that after the\n" +"> inital import, rather than writing `numpy.loadtxt(...)`, you can now write `np.loadtxt(...)`. Some\n" +"> people prefer this as it is quicker to type and results in shorter lines of code - especially for libraries\n" +"> with long names! You will frequently see Python code online using a NumPy function with `np`, and it's\n" +"> because they've used this shortcut. It makes no difference which approach you choose to take, but you must be\n" +"> consistent as if you use `import numpy as np` then `numpy.loadtxt(...)` will not work, and you must use `np.loadtxt(...)`\n" +"> instead. Because of this, when working with other people it is important you agree on how libraries are imported." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:105 +msgid "Our call to `numpy.loadtxt` read our file\n" +"but didn't save the data in memory.\n" +"To do that,\n" +"we need to assign the array to a variable. In a similar manner to how we assign a single\n" +"value to a variable, we can also assign an array of values to a variable using the same syntax.\n" +"Let's re-run `numpy.loadtxt` and save the returned data:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:112 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:117 +msgid "This statement doesn't produce any output because we've assigned the output to the variable `data`.\n" +"If we want to check that the data have been loaded,\n" +"we can print the variable's value:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:121 +# code block +msgid "~~~\n" +"print(data)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:126 +# code block +msgid "~~~\n" +"[[ 0. 0. 1. ..., 3. 0. 0.]\n" +" [ 0. 1. 2. ..., 1. 0. 1.]\n" +" [ 0. 1. 1. ..., 2. 1. 1.]\n" +" ...,\n" +" [ 0. 1. 1. ..., 1. 1. 1.]\n" +" [ 0. 0. 0. ..., 0. 2. 0.]\n" +" [ 0. 0. 1. ..., 1. 1. 0.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:137 +msgid "Now that the data are in memory,\n" +"we can manipulate them.\n" +"First,\n" +"let's ask what [type]({{ page.root }}/reference.html#type) of thing `data` refers to:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:142 +# code block +msgid "~~~\n" +"print(type(data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:147 +# code block +msgid "~~~\n" +"\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:152 +msgid "The output tells us that `data` currently refers to\n" +"an N-dimensional array, the functionality for which is provided by the NumPy library.\n" +"These data correspond to arthritis patients' inflammation.\n" +"The rows are the individual patients, and the columns\n" +"are their daily inflammation measurements." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:158 +# blockquote, which can be cascaded +msgid "> ## Data Type" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:159 +msgid ">\n" +"> A Numpy array contains one or more elements\n" +"> of the same type. The `type` function will only tell you that\n" +"> a variable is a NumPy array but won't tell you the type of\n" +"> thing inside the array.\n" +"> We can find out the type\n" +"> of the data contained in the NumPy array.\n" +">\n" +"> ~~~\n" +"> print(data.dtype)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> float64\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:176 +msgid ">\n" +"> This tells us that the NumPy array's elements are\n" +"> [floating-point numbers]({{ page.root }}/reference.html#floating-point number)." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:181 +msgid "With the following command, we can see the array's [shape]({{ page.root }}/reference.html#shape):" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:183 +# code block +msgid "~~~\n" +"print(data.shape)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:188 +# code block +msgid "~~~\n" +"(60, 40)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:193 +msgid "The output tells us that the `data` array variable contains 60 rows and 40 columns. When we\n" +"created the variable `data` to store our arthritis data, we did not only create the array; we also\n" +"created information about the array, called [members]({{ page.root }}/reference.html#member) or\n" +"attributes. This extra information describes `data` in the same way an adjective describes a noun.\n" +"`data.shape` is an attribute of `data` which describes the dimensions of `data`. We use the same\n" +"dotted notation for the attributes of variables that we use for the functions in libraries because\n" +"they have the same part-and-whole relationship." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:201 +msgid "If we want to get a single number from the array, we must provide an\n" +"[index]({{ page.root }}/reference.html#index) in square brackets after the variable name, just as we\n" +"do in math when referring to an element of a matrix. Our inflammation data has two dimensions, so\n" +"we will need to use two indices to refer to one specific value:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:206 +# code block +msgid "~~~\n" +"print('first value in data:', data[0, 0])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:211 +# code block +msgid "~~~\n" +"first value in data: 0.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:216 +# code block +msgid "~~~\n" +"print('middle value in data:', data[30, 20])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:221 +# code block +msgid "~~~\n" +"middle value in data: 13.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:226 +msgid "The expression `data[30, 20]` accesses the element at row 30, column 20. While this expression may\n" +"not surprise you,\n" +" `data[0, 0]` might.\n" +"Programming languages like Fortran, MATLAB and R start counting at 1\n" +"because that's what human beings have done for thousands of years.\n" +"Languages in the C family (including C++, Java, Perl, and Python) count from 0\n" +"because it represents an offset from the first value in the array (the second\n" +"value is offset by one index from the first value). This is closer to the way\n" +"that computers represent arrays (if you are interested in the historical\n" +"reasons behind counting indices from zero, you can read\n" +"[Mike Hoye's blog post](http://exple.tive.org/blarg/2013/10/22/citation-needed/)).\n" +"As a result,\n" +"if we have an M×N array in Python,\n" +"its indices go from 0 to M-1 on the first axis\n" +"and 0 to N-1 on the second.\n" +"It takes a bit of getting used to,\n" +"but one way to remember the rule is that\n" +"the index is how many steps we have to take from the start to get the item we want." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:245 +msgid "![Zero Index](../fig/python-zero-index.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:247 +# blockquote, which can be cascaded +msgid "> ## In the Corner" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:248 +msgid ">\n" +"> What may also surprise you is that when Python displays an array,\n" +"> it shows the element with index `[0, 0]` in the upper left corner\n" +"> rather than the lower left.\n" +"> This is consistent with the way mathematicians draw matrices\n" +"> but different from the Cartesian coordinates.\n" +"> The indices are (row, column) instead of (column, row) for the same reason,\n" +"> which can be confusing when plotting data." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:258 +# header +msgid "## Slicing data" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:259 +msgid "An index like `[30, 20]` selects a single element of an array,\n" +"but we can select whole sections as well.\n" +"For example,\n" +"we can select the first ten days (columns) of values\n" +"for the first four patients (rows) like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:265 +# code block +msgid "~~~\n" +"print(data[0:4, 0:10])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:270 +# code block +msgid "~~~\n" +"[[ 0. 0. 1. 3. 1. 2. 4. 7. 8. 3.]\n" +" [ 0. 1. 2. 1. 2. 1. 3. 2. 2. 6.]\n" +" [ 0. 1. 1. 3. 3. 2. 6. 2. 5. 9.]\n" +" [ 0. 0. 2. 0. 4. 2. 2. 1. 6. 7.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:278 +msgid "The [slice]({{ page.root }}/reference.html#slice) `0:4` means, \"Start at index 0 and go up to, but not\n" +"including, index 4\". Again, the up-to-but-not-including takes a bit of getting used to, but the\n" +"rule is that the difference between the upper and lower bounds is the number of values in the slice." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:282 +msgid "We don't have to start slices at 0:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:284 +# code block +msgid "~~~\n" +"print(data[5:10, 0:10])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:289 +# code block +msgid "~~~\n" +"[[ 0. 0. 1. 2. 2. 4. 2. 1. 6. 4.]\n" +" [ 0. 0. 2. 2. 4. 2. 2. 5. 5. 8.]\n" +" [ 0. 0. 1. 2. 3. 1. 2. 3. 5. 3.]\n" +" [ 0. 0. 0. 3. 1. 5. 6. 5. 5. 8.]\n" +" [ 0. 1. 1. 2. 1. 3. 5. 3. 5. 8.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:298 +msgid "We also don't have to include the upper and lower bound on the slice. If we don't include the lower\n" +"bound, Python uses 0 by default; if we don't include the upper, the slice runs to the end of the\n" +"axis, and if we don't include either (i.e., if we use ':' on its own), the slice includes\n" +"everything:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:303 +# code block +msgid "~~~\n" +"small = data[:3, 36:]\n" +"print('small is:')\n" +"print(small)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:308 +msgid "{: .language-python}\n" +"The above example selects rows 0 through 2 and columns 36 through to the end of the array." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:311 +# code block +msgid "~~~\n" +"small is:\n" +"[[ 2. 3. 0. 0.]\n" +" [ 1. 1. 0. 1.]\n" +" [ 2. 2. 1. 1.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:319 +# header +msgid "## Analyzing data" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:321 +msgid "NumPy has several useful functions that take an array as input to perform operations on its values.\n" +"If we want to find the average inflammation for all patients on\n" +"all days, for example, we can ask NumPy to compute `data`'s mean value:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:325 +# code block +msgid "~~~\n" +"print(numpy.mean(data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:330 +# code block +msgid "~~~\n" +"6.14875\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:335 +msgid "`mean` is a [function]({{ page.root }}/reference.html#function) that takes\n" +"an array as an [argument]({{ page.root }}/reference.html#argument)." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:338 +# blockquote, which can be cascaded +msgid "> ## Not All Functions Have Input" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:339 +msgid ">\n" +"> Generally, a function uses inputs to produce outputs.\n" +"> However, some functions produce outputs without\n" +"> needing any input. For example, checking the current time\n" +"> doesn't require any input.\n" +">\n" +"> ~~~\n" +"> import time\n" +"> print(time.ctime())\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Sat Mar 26 13:07:33 2016\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:355 +msgid ">\n" +"> For functions that don't take in any arguments,\n" +"> we still need parentheses (`()`)\n" +"> to tell Python to go and do something for us." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:361 +msgid "Let's use three other NumPy functions to get some descriptive values about the dataset.\n" +"We'll also use multiple assignment,\n" +"a convenient Python feature that will enable us to do this all in one line." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:365 +# code block +msgid "~~~\n" +"maxval, minval, stdval = numpy.max(data), numpy.min(data), numpy.std(data)\n" +"\n" +"print('maximum inflammation:', maxval)\n" +"print('minimum inflammation:', minval)\n" +"print('standard deviation:', stdval)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:374 +msgid "Here we've assigned the return value from `numpy.max(data)` to the variable `maxval`, the value\n" +"from `numpy.min(data)` to `minval`, and so on." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:377 +# code block +msgid "~~~\n" +"maximum inflammation: 20.0\n" +"minimum inflammation: 0.0\n" +"standard deviation: 4.61383319712\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:384 +# blockquote, which can be cascaded +msgid "> ## Mystery Functions in IPython" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:385 +msgid ">\n" +"> How did we know what functions NumPy has and how to use them?\n" +"> If you are working in IPython or in a Jupyter Notebook, there is an easy way to find out.\n" +"> If you type the name of something followed by a dot, then you can use tab completion\n" +"> (e.g. type `numpy.` and then press Tab)\n" +"> to see a list of all functions and attributes that you can use. After selecting one, you\n" +"> can also add a question mark (e.g. `numpy.cumprod?`), and IPython will return an\n" +"> explanation of the method! This is the same as doing `help(numpy.cumprod)`.\n" +"> Similarly, if you are using the \"plain vanilla\" Python interpreter, you can type `numpy.`\n" +"> and press the Tab key twice for a listing of what is available. You can then use the\n" +"> `help()` function to see an explanation of the function you're interested in,\n" +"> for example: `help(numpy.cumprod)`." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:399 +msgid "When analyzing data, though,\n" +"we often want to look at variations in statistical values,\n" +"such as the maximum inflammation per patient\n" +"or the average inflammation per day.\n" +"One way to do this is to create a new temporary array of the data we want,\n" +"then ask it to do the calculation:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:406 +# code block +msgid "~~~\n" +"patient_0 = data[0, :] # 0 on the first axis (rows), everything on the second (columns)\n" +"print('maximum inflammation for patient 0:', numpy.max(patient_0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:412 +# code block +msgid "~~~\n" +"maximum inflammation for patient 0: 18.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:417 +msgid "Everything in a line of code following the '#' symbol is a\n" +"[comment]({{ page.root }}/reference.html#comment) that is ignored by Python.\n" +"Comments allow programmers to leave explanatory notes for other\n" +"programmers or their future selves." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:422 +msgid "We don't actually need to store the row in a variable of its own.\n" +"Instead, we can combine the selection and the function call:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:425 +# code block +msgid "~~~\n" +"print('maximum inflammation for patient 2:', numpy.max(data[2, :]))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:430 +# code block +msgid "~~~\n" +"maximum inflammation for patient 2: 19.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:435 +msgid "What if we need the maximum inflammation for each patient over all days (as in the\n" +"next diagram on the left) or the average for each day (as in the\n" +"diagram on the right)? As the diagram below shows, we want to perform the\n" +"operation across an axis:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:440 +msgid "![Per-patient maximum inflammation is computed row-wise across all columns using numpy.max(data, axis=1).\n" +"Per-day average inflammation is computed column-wise across all rows using numpy.mean(data, axis=0).](../fig/python-operations-across-axes.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:443 +msgid "To support this functionality,\n" +"most array functions allow us to specify the axis we want to work on.\n" +"If we ask for the average across axis 0 (rows in our 2D example),\n" +"we get:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:448 +# code block +msgid "~~~\n" +"print(numpy.mean(data, axis=0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:453 +# code block +msgid "~~~\n" +"[ 0. 0.45 1.11666667 1.75 2.43333333 3.15\n" +" 3.8 3.88333333 5.23333333 5.51666667 5.95 5.9\n" +" 8.35 7.73333333 8.36666667 9.5 9.58333333\n" +" 10.63333333 11.56666667 12.35 13.25 11.96666667\n" +" 11.03333333 10.16666667 10. 8.66666667 9.15 7.25\n" +" 7.33333333 6.58333333 6.06666667 5.95 5.11666667 3.6\n" +" 3.3 3.56666667 2.48333333 1.5 1.13333333\n" +" 0.56666667]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:465 +msgid "As a quick check,\n" +"we can ask this array what its shape is:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:468 +# code block +msgid "~~~\n" +"print(numpy.mean(data, axis=0).shape)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:473 +# code block +msgid "~~~\n" +"(40,)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:478 +msgid "The expression `(40,)` tells us we have an N×1 vector,\n" +"so this is the average inflammation per day for all patients.\n" +"If we average across axis 1 (columns in our 2D example), we get:" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:482 +# code block +msgid "~~~\n" +"print(numpy.mean(data, axis=1))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:487 +# code block +msgid "~~~\n" +"[ 5.45 5.425 6.1 5.9 5.55 6.225 5.975 6.65 6.625 6.525\n" +" 6.775 5.8 6.225 5.75 5.225 6.3 6.55 5.7 5.85 6.55\n" +" 5.775 5.825 6.175 6.1 5.8 6.425 6.05 6.025 6.175 6.55\n" +" 6.175 6.35 6.725 6.125 7.075 5.725 5.925 6.15 6.075 5.75\n" +" 5.975 5.725 6.3 5.9 6.75 5.925 7.225 6.15 5.95 6.275 5.7\n" +" 6.1 6.825 5.975 6.725 5.7 6.25 6.4 7.05 5.9 ]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:497 +msgid "which is the average inflammation per patient across all days." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:500 +# blockquote, which can be cascaded +msgid "> ## Slicing Strings" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:501 +msgid ">\n" +"> A section of an array is called a [slice]({{ page.root }}/reference.html#slice).\n" +"> We can take slices of character strings as well:\n" +">\n" +"> ~~~\n" +"> element = 'oxygen'\n" +"> print('first three characters:', element[0:3])\n" +"> print('last three characters:', element[3:6])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> first three characters: oxy\n" +"> last three characters: gen\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:517 +msgid ">\n" +"> What is the value of `element[:4]`?\n" +"> What about `element[4:]`?\n" +"> Or `element[:]`?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > oxyg\n" +"> > en\n" +"> > oxygen\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:530 +msgid ">\n" +"> What is `element[-1]`?\n" +"> What is `element[-2]`?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > n\n" +"> > e\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:541 +msgid ">\n" +"> Given those answers,\n" +"> explain what `element[1:-1]` does.\n" +">\n" +"> > ## Solution\n" +"> > Creates a substring from index 1 up to (not including) the final index,\n" +"> > effectively removing the first and last letters from 'oxygen'" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:549 +msgid ">\n" +"> How can we rewrite the slice for getting the last three characters of `element`,\n" +"> so that it works even if we assign a different string to `element`?\n" +"> Test your solution with the following strings: `carpentry`, `clone`, `hi`.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > element = 'oxygen'\n" +"> > print('last three characters:', element[-3:])\n" +"> > element = 'carpentry'\n" +"> > print('last three characters:', element[-3:])\n" +"> > element = 'clone'\n" +"> > print('last three characters:', element[-3:])\n" +"> > element = 'hi'\n" +"> > print('last three characters:', element[-3:])\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> > ~~~\n" +"> > last three characters: gen\n" +"> > last three characters: try\n" +"> > last three characters: one\n" +"> > last three characters: hi\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:576 +# blockquote, which can be cascaded +msgid "> ## Thin Slices" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:577 +msgid ">\n" +"> The expression `element[3:3]` produces an [empty string]({{ page.root }}/reference.html#empty-string),\n" +"> i.e., a string that contains no characters.\n" +"> If `data` holds our array of patient data,\n" +"> what does `data[3:3, 4:4]` produce?\n" +"> What about `data[3:3, :]`?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > array([], shape=(0, 0), dtype=float64)\n" +"> > array([], shape=(0, 40), dtype=float64)\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:593 +# blockquote, which can be cascaded +msgid "> ## Stacking Arrays" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:594 +msgid ">\n" +"> Arrays can be concatenated and stacked on top of one another,\n" +"> using NumPy's `vstack` and `hstack` functions for vertical and horizontal stacking, respectively.\n" +">\n" +"> ~~~\n" +"> import numpy\n" +">\n" +"> A = numpy.array([[1,2,3], [4,5,6], [7, 8, 9]])\n" +"> print('A = ')\n" +"> print(A)\n" +">\n" +"> B = numpy.hstack([A, A])\n" +"> print('B = ')\n" +"> print(B)\n" +">\n" +"> C = numpy.vstack([A, A])\n" +"> print('C = ')\n" +"> print(C)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> A =\n" +"> [[1 2 3]\n" +"> [4 5 6]\n" +"> [7 8 9]]\n" +"> B =\n" +"> [[1 2 3 1 2 3]\n" +"> [4 5 6 4 5 6]\n" +"> [7 8 9 7 8 9]]\n" +"> C =\n" +"> [[1 2 3]\n" +"> [4 5 6]\n" +"> [7 8 9]\n" +"> [1 2 3]\n" +"> [4 5 6]\n" +"> [7 8 9]]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:633 +msgid ">\n" +"> Write some additional code that slices the first and last columns of `A`,\n" +"> and stacks them into a 3x2 array.\n" +"> Make sure to `print` the results to verify your solution.\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > A 'gotcha' with array indexing is that singleton dimensions\n" +"> > are dropped by default. That means `A[:, 0]` is a one dimensional\n" +"> > array, which won't stack as desired. To preserve singleton dimensions,\n" +"> > the index itself can be a slice or array. For example, `A[:, :1]` returns\n" +"> > a two dimensional array with one singleton dimension (i.e. a column\n" +"> > vector).\n" +"> >\n" +"> > ~~~\n" +"> > D = numpy.hstack((A[:, :1], A[:, -1:]))\n" +"> > print('D = ')\n" +"> > print(D)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > D =\n" +"> > [[1 3]\n" +"> > [4 6]\n" +"> > [7 9]]\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:662 +msgid ">\n" +"> > ## Solution\n" +"> >\n" +"> > An alternative way to achieve the same result is to use Numpy's\n" +"> > delete function to remove the second column of A.\n" +"> >\n" +"> > ~~~\n" +"> > D = numpy.delete(A, 1, 1)\n" +"> > print('D = ')\n" +"> > print(D)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > D =\n" +"> > [[1 3]\n" +"> > [4 6]\n" +"> > [7 9]]\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:685 +# blockquote, which can be cascaded +msgid "> ## Change In Inflammation" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:686 +msgid ">\n" +"> The patient data is _longitudinal_ in the sense that each row represents a\n" +"> series of observations relating to one individual. This means that\n" +"> the change in inflammation over time is a meaningful concept.\n" +"> Let's find out how to calculate changes in the data contained in an array\n" +"> with NumPy.\n" +">\n" +"> The `numpy.diff()` function takes an array and returns the differences\n" +"> between two successive values. Let's use it to examine the changes\n" +"> each day across the first week of patient 3 from our inflammation dataset.\n" +">\n" +"> ~~~\n" +"> patient3_week1 = data[3, :7]\n" +"> print(patient3_week1)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> [0. 0. 2. 0. 4. 2. 2.]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:707 +msgid ">\n" +"> Calling `numpy.diff(patient3_week1)` would do the following calculations\n" +">\n" +"> ~~~\n" +"> [ 0 - 0, 2 - 0, 0 - 2, 4 - 0, 2 - 4, 2 - 2 ]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> and return the 6 difference values in a new array.\n" +">\n" +"> ~~~\n" +"> numpy.diff(patient3_week1)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> array([ 0., 2., -2., 4., -2., 0.])\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:726 +msgid ">\n" +"> Note that the array of differences is shorter by one element (length 6).\n" +">\n" +"> When calling `numpy.diff` with a multi-dimensional array, an `axis` argument may\n" +"> be passed to the function to specify which axis to process. When applying\n" +"> `numpy.diff` to our 2D inflammation array `data`, which axis would we specify?\n" +">\n" +"> > ## Solution\n" +"> > Since the row axis (0) is patients, it does not make sense to get the\n" +"> > difference between two arbitrary patients. The column axis (1) is in\n" +"> > days, so the difference is the change in inflammation -- a meaningful\n" +"> > concept.\n" +"> >\n" +"> > ~~~\n" +"> > numpy.diff(data, axis=1)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:744 +msgid ">\n" +"> If the shape of an individual data file is `(60, 40)` (60 rows and 40\n" +"> columns), what would the shape of the array be after you run the `diff()`\n" +"> function and why?\n" +">\n" +"> > ## Solution\n" +"> > The shape will be `(60, 39)` because there is one fewer difference between\n" +"> > columns than there are columns in the data." +msgstr "" + +#: python-novice-inflammation/_episodes/02-numpy.md:753 +msgid ">\n" +"> How would you find the largest change in inflammation for each patient? Does\n" +"> it matter if the change in inflammation is an increase or a decrease?\n" +">\n" +"> > ## Solution\n" +"> > By using the `numpy.max()` function after you apply the `numpy.diff()`\n" +"> > function, you will get the largest difference between days.\n" +"> >\n" +"> > ~~~\n" +"> > numpy.max(numpy.diff(data, axis=1), axis=1)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > array([ 7., 12., 11., 10., 11., 13., 10., 8., 10., 10., 7.,\n" +"> > 7., 13., 7., 10., 10., 8., 10., 9., 10., 13., 7.,\n" +"> > 12., 9., 12., 11., 10., 10., 7., 10., 11., 10., 8.,\n" +"> > 11., 12., 10., 9., 10., 13., 10., 7., 7., 10., 13.,\n" +"> > 12., 8., 8., 10., 10., 9., 8., 13., 10., 7., 10.,\n" +"> > 8., 12., 10., 7., 12.])\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > If inflammation values *decrease* along an axis, then the difference from\n" +"> > one element to the next will be negative. If\n" +"> > you are interested in the **magnitude** of the change and not the\n" +"> > direction, the `numpy.absolute()` function will provide that.\n" +"> >\n" +"> > Notice the difference if you get the largest _absolute_ difference\n" +"> > between readings.\n" +"> >\n" +"> > ~~~\n" +"> > numpy.max(numpy.absolute(numpy.diff(data, axis=1)), axis=1)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > array([ 12., 14., 11., 13., 11., 13., 10., 12., 10., 10., 10.,\n" +"> > 12., 13., 10., 11., 10., 12., 13., 9., 10., 13., 9.,\n" +"> > 12., 9., 12., 11., 10., 13., 9., 13., 11., 11., 8.,\n" +"> > 11., 12., 13., 9., 10., 13., 11., 11., 13., 11., 13.,\n" +"> > 13., 10., 9., 10., 10., 9., 9., 13., 10., 9., 10.,\n" +"> > 11., 13., 10., 10., 12.])\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/06__03-matplotlib.md.ja.po b/transifex/python-novice-inflammation/po/06__03-matplotlib.md.ja.po new file mode 100644 index 00000000..da688c6e --- /dev/null +++ b/transifex/python-novice-inflammation/po/06__03-matplotlib.md.ja.po @@ -0,0 +1,344 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:1 +# Front Matter +msgid "---\n" +"title: Visualizing Tabular Data\n" +"teaching: 30\n" +"exercises: 20\n" +"questions:\n" +"- \"How can I visualize tabular data in Python?\"\n" +"- \"How can I group several plots together?\"\n" +"objectives:\n" +"- \"Plot simple graphs from data.\"\n" +"- \"Group several graphs in a single figure.\"\n" +"keypoints:\n" +"- \"Use the `pyplot` module from the `matplotlib` library for creating simple visualizations.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:15 +# header +msgid "## Visualizing data" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:16 +msgid "The mathematician Richard Hamming once said, \"The purpose of computing is insight, not numbers,\" and\n" +"the best way to develop insight is often to visualize data. Visualization deserves an entire\n" +"lecture of its own, but we can explore a few features of Python's `matplotlib` library here. While\n" +"there is no official plotting library, `matplotlib` is the _de facto_ standard. First, we will\n" +"import the `pyplot` module from `matplotlib` and use two of its functions to create and display a\n" +"[heat map]({{ page.root }}/reference.html#heat-map) of our data:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:23 +# code block +msgid "~~~\n" +"import matplotlib.pyplot\n" +"image = matplotlib.pyplot.imshow(data)\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:30 +msgid "![Heat map representing the `data` variable. Each cell is colored by value along a color gradient from blue to yellow.](../fig/inflammation-01-imshow.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:32 +msgid "Blue pixels in this heat map represent low values, while yellow pixels represent high values. As we\n" +"can see, inflammation rises and falls over a 40-day period. Let's take a look at the average inflammation over time:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:35 +# code block +msgid "~~~\n" +"ave_inflammation = numpy.mean(data, axis=0)\n" +"ave_plot = matplotlib.pyplot.plot(ave_inflammation)\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:42 +msgid "![Average Inflammation Over Time](../fig/inflammation-01-average.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:44 +msgid "Here, we have put the average inflammation per day across all patients in the variable `ave_inflammation`, then\n" +"asked `matplotlib.pyplot` to create and display a line graph of those values. The result is a\n" +"roughly linear rise and fall, which is suspicious: we might instead expect a sharper rise and slower\n" +"fall. Let's have a look at two other statistics:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:49 +# code block +msgid "~~~\n" +"max_plot = matplotlib.pyplot.plot(numpy.max(data, axis=0))\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:55 +msgid "![Maximum Value Along The First Axis](../fig/inflammation-01-maximum.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:57 +# code block +msgid "~~~\n" +"min_plot = matplotlib.pyplot.plot(numpy.min(data, axis=0))\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:63 +msgid "![Minimum Value Along The First Axis](../fig/inflammation-01-minimum.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:65 +msgid "The maximum value rises and falls smoothly, while the minimum seems to be a step function. Neither\n" +"trend seems particularly likely, so either there's a mistake in our calculations or something is\n" +"wrong with our data. This insight would have been difficult to reach by examining the numbers\n" +"themselves without visualization tools." +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:70 +# header +msgid "### Grouping plots" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:71 +msgid "You can group similar plots in a single figure using subplots.\n" +"This script below uses a number of new commands. The function `matplotlib.pyplot.figure()`\n" +"creates a space into which we will place all of our plots. The parameter `figsize`\n" +"tells Python how big to make this space. Each subplot is placed into the figure using\n" +"its `add_subplot` [method]({{ page.root }}/reference.html#method). The `add_subplot` method takes 3\n" +"parameters. The first denotes how many total rows of subplots there are, the second parameter\n" +"refers to the total number of subplot columns, and the final parameter denotes which subplot\n" +"your variable is referencing (left-to-right, top-to-bottom). Each subplot is stored in a\n" +"different variable (`axes1`, `axes2`, `axes3`). Once a subplot is created, the axes can\n" +"be titled using the `set_xlabel()` command (or `set_ylabel()`).\n" +"Here are our three plots side by side:" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:83 +# code block +msgid "~~~\n" +"import numpy\n" +"import matplotlib.pyplot\n" +"\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"\n" +"fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"\n" +"axes1 = fig.add_subplot(1, 3, 1)\n" +"axes2 = fig.add_subplot(1, 3, 2)\n" +"axes3 = fig.add_subplot(1, 3, 3)\n" +"\n" +"axes1.set_ylabel('average')\n" +"axes1.plot(numpy.mean(data, axis=0))\n" +"\n" +"axes2.set_ylabel('max')\n" +"axes2.plot(numpy.max(data, axis=0))\n" +"\n" +"axes3.set_ylabel('min')\n" +"axes3.plot(numpy.min(data, axis=0))\n" +"\n" +"fig.tight_layout()\n" +"\n" +"matplotlib.pyplot.savefig('inflammation.png')\n" +"matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:111 +msgid "![The Previous Plots as Subplots](../fig/inflammation-01-group-plot.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:113 +msgid "The [call]({{ page.root }}/reference.html#function-call) to `loadtxt` reads our data,\n" +"and the rest of the program tells the plotting library\n" +"how large we want the figure to be,\n" +"that we're creating three subplots,\n" +"what to draw for each one,\n" +"and that we want a tight layout.\n" +"(If we leave out that call to `fig.tight_layout()`,\n" +"the graphs will actually be squeezed together more closely.)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:122 +msgid "The call to `savefig` stores the plot as a graphics file. This can be\n" +"a convenient way to store your plots for use in other documents, web\n" +"pages etc. The graphics format is automatically determined by\n" +"Matplotlib from the file name ending we specify; here PNG from\n" +"'inflammation.png'. Matplotlib supports many different graphics\n" +"formats, including SVG, PDF, and JPEG." +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:130 +# blockquote, which can be cascaded +msgid "> ## Plot Scaling" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:131 +msgid ">\n" +"> Why do all of our plots stop just short of the upper end of our graph?\n" +">\n" +"> > ## Solution\n" +"> > Because matplotlib normally sets x and y axes limits to the min and max of our data\n" +"> > (depending on data range)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:138 +msgid ">\n" +"> If we want to change this, we can use the `set_ylim(min, max)` method of each 'axes',\n" +"> for example:\n" +">\n" +"> ~~~\n" +"> axes3.set_ylim(0,6)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Update your plotting code to automatically set a more appropriate scale.\n" +"> (Hint: you can make use of the `max` and `min` methods to help.)\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # One method\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(data, axis=0))\n" +"> > axes3.set_ylim(0,6)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:159 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # A more automated approach\n" +"> > min_data = numpy.min(data, axis=0)\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(min_data)\n" +"> > axes3.set_ylim(numpy.min(min_data), numpy.max(min_data) * 1.1)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:172 +# blockquote, which can be cascaded +msgid "> ## Drawing Straight Lines" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:173 +msgid ">\n" +"> In the center and right subplots above, we expect all lines to look like step functions because\n" +"> non-integer value are not realistic for the minimum and maximum values. However, you can see\n" +"> that the lines are not always vertical or horizontal, and in particular the step function\n" +"> in the subplot on the right looks slanted. Why is this?\n" +">\n" +"> > ## Solution\n" +"> > Because matplotlib interpolates (draws a straight line) between the points.\n" +"> > One way to do avoid this is to use the Matplotlib `drawstyle` option:\n" +"> >\n" +"> > ~~~\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"> >\n" +"> > fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"> >\n" +"> > axes1 = fig.add_subplot(1, 3, 1)\n" +"> > axes2 = fig.add_subplot(1, 3, 2)\n" +"> > axes3 = fig.add_subplot(1, 3, 3)\n" +"> >\n" +"> > axes1.set_ylabel('average')\n" +"> > axes1.plot(numpy.mean(data, axis=0), drawstyle='steps-mid')\n" +"> >\n" +"> > axes2.set_ylabel('max')\n" +"> > axes2.plot(numpy.max(data, axis=0), drawstyle='steps-mid')\n" +"> >\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(data, axis=0), drawstyle='steps-mid')\n" +"> >\n" +"> > fig.tight_layout()\n" +"> >\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> ![Plot with step lines](../fig/inflammation-01-line-styles.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:213 +# blockquote, which can be cascaded +msgid "> ## Make Your Own Plot" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:214 +msgid ">\n" +"> Create a plot showing the standard deviation (`numpy.std`)\n" +"> of the inflammation data for each day across all patients.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > std_plot = matplotlib.pyplot.plot(numpy.std(data, axis=0))\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:227 +# blockquote, which can be cascaded +msgid "> ## Moving Plots Around" +msgstr "" + +#: python-novice-inflammation/_episodes/03-matplotlib.md:228 +msgid ">\n" +"> Modify the program to display the three plots on top of one another\n" +"> instead of side by side.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"> >\n" +"> > # change figsize (swap width and height)\n" +"> > fig = matplotlib.pyplot.figure(figsize=(3.0, 10.0))\n" +"> >\n" +"> > # change add_subplot (swap first two parameters)\n" +"> > axes1 = fig.add_subplot(3, 1, 1)\n" +"> > axes2 = fig.add_subplot(3, 1, 2)\n" +"> > axes3 = fig.add_subplot(3, 1, 3)\n" +"> >\n" +"> > axes1.set_ylabel('average')\n" +"> > axes1.plot(numpy.mean(data, axis=0))\n" +"> >\n" +"> > axes2.set_ylabel('max')\n" +"> > axes2.plot(numpy.max(data, axis=0))\n" +"> >\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(data, axis=0))\n" +"> >\n" +"> > fig.tight_layout()\n" +"> >\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/07__04-loop.md.ja.po b/transifex/python-novice-inflammation/po/07__04-loop.md.ja.po new file mode 100644 index 00000000..0fde18a6 --- /dev/null +++ b/transifex/python-novice-inflammation/po/07__04-loop.md.ja.po @@ -0,0 +1,565 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/04-loop.md:1 +# Front Matter +msgid "---\n" +"title: Repeating Actions with Loops\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I do the same operations on many different values?\"\n" +"objectives:\n" +"- \"Explain what a `for` loop does.\"\n" +"- \"Correctly write `for` loops to repeat simple calculations.\"\n" +"- \"Trace changes to a loop variable as the loop runs.\"\n" +"- \"Trace changes to other variables as they are updated by a `for` loop.\"\n" +"keypoints:\n" +"- \"Use `for variable in sequence` to process the elements of a sequence one at a time.\"\n" +"- \"The body of a `for` loop must be indented.\"\n" +"- \"Use `len(thing)` to determine the length of something that contains other values.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:18 +msgid "In the last episode, we wrote Python code that plots values of interest from our first\n" +"inflammation dataset (`inflammation-01.csv`), which revealed some suspicious features in it." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:21 +msgid "![Analysis of inflammation-01.csv](../fig/03-loop_2_0.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:23 +msgid "We have a dozen data sets right now, though, and more on the way.\n" +"We want to create plots for all of our data sets with a single statement.\n" +"To do that, we'll have to teach the computer how to repeat things." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:27 +msgid "An example task that we might want to repeat is printing each character in a\n" +"word on a line of its own." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:30 +# code block +msgid "~~~\n" +"word = 'lead'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:35 +msgid "In Python, a string is basically an ordered collection of characters, and every\n" +"character has a unique number associated with it -- its index. This means that\n" +"we can access characters in a string using their indices.\n" +"For example, we can get the first character of the word `'lead'`, by using\n" +"`word[0]`. One way to print each character is to use four `print` statements:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:41 +# code block +msgid "~~~\n" +"print(word[0])\n" +"print(word[1])\n" +"print(word[2])\n" +"print(word[3])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:49 +#: python-novice-inflammation/_episodes/04-loop.md:110 +# code block +msgid "~~~\n" +"l\n" +"e\n" +"a\n" +"d\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:57 +msgid "This is a bad approach for three reasons:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:59 +# ordered list +msgid "1. **Not scalable**. Imagine you need to print characters of a string that is hundreds" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:60 +msgid " of letters long. It might be easier to type them in manually." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:62 +# ordered list +msgid "2. **Difficult to maintain**. If we want to decorate each printed character with an" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:63 +msgid " asterisk or any other character, we would have to change four lines of code. While\n" +" this might not be a problem for short strings, it would definitely be a problem for\n" +" longer ones." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:67 +# ordered list +msgid "3. **Fragile**. If we use it with a word that has more characters than what we initially" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:68 +msgid " envisioned, it will only display part of the word's characters. A shorter string, on\n" +" the other hand, will cause an error because it will be trying to display part of the\n" +" string that doesn't exist." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:72 +# code block +msgid "~~~\n" +"word = 'tin'\n" +"print(word[0])\n" +"print(word[1])\n" +"print(word[2])\n" +"print(word[3])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:81 +# code block +msgid "~~~\n" +"t\n" +"i\n" +"n\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:88 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"IndexError Traceback (most recent call last)\n" +" in ()\n" +" 3 print(word[1])\n" +" 4 print(word[2])\n" +"----> 5 print(word[3])\n" +"\n" +"IndexError: string index out of range\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:98 +#: python-novice-inflammation/_episodes/05-lists.md:113 +#: python-novice-inflammation/_episodes/08-func.md:448 +#: python-novice-inflammation/_episodes/09-errors.md:76 +#: python-novice-inflammation/_episodes/09-errors.md:164 +#: python-novice-inflammation/_episodes/09-errors.md:189 +#: python-novice-inflammation/_episodes/09-errors.md:245 +#: python-novice-inflammation/_episodes/09-errors.md:271 +#: python-novice-inflammation/_episodes/09-errors.md:294 +#: python-novice-inflammation/_episodes/09-errors.md:322 +#: python-novice-inflammation/_episodes/09-errors.md:361 +#: python-novice-inflammation/_episodes/09-errors.md:391 +#: python-novice-inflammation/_episodes/09-errors.md:427 +#: python-novice-inflammation/_episodes/10-defensive.md:92 +#: python-novice-inflammation/_episodes/10-defensive.md:168 +#: python-novice-inflammation/_episodes/10-defensive.md:190 +#: python-novice-inflammation/_episodes/10-defensive.md:230 +#: python-novice-inflammation/_episodes/10-defensive.md:325 +#: python-novice-inflammation/_episodes/10-defensive.md:398 +#: python-novice-inflammation/_episodes/10-defensive.md:457 +#: python-novice-inflammation/_extras/discuss.md:104 +#: python-novice-inflammation/_extras/discuss.md:287 +# SC/DC Template label +msgid "{: .error}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:100 +msgid "Here's a better approach:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:102 +# code block +msgid "~~~\n" +"word = 'lead'\n" +"for char in word:\n" +" print(char)\n" +"\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:118 +msgid "This is shorter --- certainly shorter than something that prints every character in a\n" +"hundred-letter string --- and more robust as well:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:121 +# code block +msgid "~~~\n" +"word = 'oxygen'\n" +"for char in word:\n" +" print(char)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:128 +# code block +msgid "~~~\n" +"o\n" +"x\n" +"y\n" +"g\n" +"e\n" +"n\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:138 +msgid "The improved version uses a [for loop]({{ page.root }}/reference.html#for-loop)\n" +"to repeat an operation --- in this case, printing --- once for each thing in a sequence.\n" +"The general form of a loop is:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:142 +# code block +msgid "~~~\n" +"for variable in collection:\n" +" # do things using variable, such as print\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:148 +msgid "Using the oxygen example above, the loop might look like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:150 +msgid "![loop_image](../fig/loops_image.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:152 +msgid "where each character (`char`) in the variable `word` is looped through and printed one character\n" +"after another. The numbers in the diagram denote which loop cycle the character was printed in (1\n" +"being the first loop, and 6 being the final loop)." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:156 +msgid "We can call the [loop variable]({{ page.root }}/reference.html#loop-variable) anything we like, but\n" +"there must be a colon at the end of the line starting the loop, and we must indent anything we\n" +"want to run inside the loop. Unlike many other languages, there is no command to signify the end\n" +"of the loop body (e.g. `end for`); what is indented after the `for` statement belongs to the loop." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:162 +# blockquote, which can be cascaded +msgid "> ## What's in a name?" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:163 +msgid ">\n" +">\n" +"> In the example above, the loop variable was given the name `char` as a mnemonic;\n" +"> it is short for 'character'. We can choose any name we want for variables.\n" +"> We can even call our loop variable `banana`, as long as we use this name consistently:\n" +">\n" +"> ~~~\n" +"> word = 'oxygen'\n" +"> for banana in word:\n" +"> print(banana)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> o\n" +"> x\n" +"> y\n" +"> g\n" +"> e\n" +"> n\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:185 +msgid ">\n" +"> It is a good idea to choose variable names that are meaningful, otherwise it would be more\n" +"> difficult to understand what the loop is doing." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:190 +msgid "Here's another loop that repeatedly updates a variable:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:192 +# code block +msgid "~~~\n" +"length = 0\n" +"for vowel in 'aeiou':\n" +" length = length + 1\n" +"print('There are', length, 'vowels')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:200 +# code block +msgid "~~~\n" +"There are 5 vowels\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:205 +msgid "It's worth tracing the execution of this little program step by step.\n" +"Since there are five characters in `'aeiou'`,\n" +"the statement on line 3 will be executed five times.\n" +"The first time around,\n" +"`length` is zero (the value assigned to it on line 1)\n" +"and `vowel` is `'a'`.\n" +"The statement adds 1 to the old value of `length`,\n" +"producing 1,\n" +"and updates `length` to refer to that new value.\n" +"The next time around,\n" +"`vowel` is `'e'` and `length` is 1,\n" +"so `length` is updated to be 2.\n" +"After three more updates,\n" +"`length` is 5;\n" +"since there is nothing left in `'aeiou'` for Python to process,\n" +"the loop finishes\n" +"and the `print` statement on line 4 tells us our final answer." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:223 +msgid "Note that a loop variable is a variable that's being used to record progress in a loop.\n" +"It still exists after the loop is over,\n" +"and we can re-use variables previously defined as loop variables as well:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:227 +# code block +msgid "~~~\n" +"letter = 'z'\n" +"for letter in 'abc':\n" +" print(letter)\n" +"print('after the loop, letter is', letter)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:235 +# code block +msgid "~~~\n" +"a\n" +"b\n" +"c\n" +"after the loop, letter is c\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:243 +msgid "Note also that finding the length of a string is such a common operation\n" +"that Python actually has a built-in function to do it called `len`:" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:246 +# code block +msgid "~~~\n" +"print(len('aeiou'))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:251 +# code block +msgid "~~~\n" +"5\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:256 +msgid "`len` is much faster than any function we could write ourselves,\n" +"and much easier to read than a two-line loop;\n" +"it will also give us the length of many other things that we haven't met yet,\n" +"so we should always use it when we can." +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:261 +# blockquote, which can be cascaded +msgid "> ## From 1 to N" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:262 +msgid ">\n" +"> Python has a built-in function called `range` that generates a sequence of numbers. `range` can\n" +"> accept 1, 2, or 3 parameters.\n" +">\n" +"> * If one parameter is given, `range` generates a sequence of that length,\n" +"> starting at zero and incrementing by 1.\n" +"> For example, `range(3)` produces the numbers `0, 1, 2`.\n" +"> * If two parameters are given, `range` starts at\n" +"> the first and ends just before the second, incrementing by one.\n" +"> For example, `range(2, 5)` produces `2, 3, 4`.\n" +"> * If `range` is given 3 parameters,\n" +"> it starts at the first one, ends just before the second one, and increments by the third one.\n" +"> For example, `range(3, 10, 2)` produces `3, 5, 7, 9`.\n" +">\n" +"> Using `range`,\n" +"> write a loop that uses `range` to print the first 3 natural numbers:\n" +">\n" +"> ~~~\n" +"> 1\n" +"> 2\n" +"> 3\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > for number in range(1, 4):\n" +"> > print(number)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:298 +# blockquote, which can be cascaded +msgid "> ## Understanding the loops" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:299 +msgid ">\n" +"> Given the following loop:\n" +"> ~~~\n" +"> word = 'oxygen'\n" +"> for char in word:\n" +"> print(char)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> How many times is the body of the loop executed?\n" +">\n" +"> * 3 times\n" +"> * 4 times\n" +"> * 5 times\n" +"> * 6 times\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > The body of the loop is executed 6 times.\n" +"> >" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:324 +# blockquote, which can be cascaded +msgid "> ## Computing Powers With Loops" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:325 +msgid ">\n" +"> Exponentiation is built into Python:\n" +">\n" +"> ~~~\n" +"> print(5 ** 3)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 125\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:337 +msgid ">\n" +"> Write a loop that calculates the same result as `5 ** 3` using\n" +"> multiplication (and without exponentiation).\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > result = 1\n" +"> > for number in range(0, 3):\n" +"> > result = result * 5\n" +"> > print(result)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:352 +# blockquote, which can be cascaded +msgid "> ## Reverse a String" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:353 +msgid ">\n" +"> Knowing that two strings can be concatenated using the `+` operator,\n" +"> write a loop that takes a string\n" +"> and produces a new string with the characters in reverse order,\n" +"> so `'Newton'` becomes `'notweN'`.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > newstring = ''\n" +"> > oldstring = 'Newton'\n" +"> > for char in oldstring:\n" +"> > newstring = char + newstring\n" +"> > print(newstring)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:371 +# blockquote, which can be cascaded +msgid "> ## Computing the Value of a Polynomial" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:372 +msgid ">\n" +"> The built-in function `enumerate` takes a sequence (e.g. a [list]({{ page.root }}/05-lists/)) and generates a\n" +"> new sequence of the same length. Each element of the new sequence is a pair composed of the index\n" +"> (0, 1, 2,...) and the value from the original sequence:\n" +">\n" +"> ~~~\n" +"> for idx, val in enumerate(a_list):\n" +"> # Do something using idx and val\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> The code above loops through `a_list`, assigning the index to `idx` and the value to `val`.\n" +">\n" +"> Suppose you have encoded a polynomial as a list of coefficients in\n" +"> the following way: the first element is the constant term, the\n" +"> second element is the coefficient of the linear term, the third is the\n" +"> coefficient of the quadratic term, etc.\n" +">\n" +"> ~~~\n" +"> x = 5\n" +"> coefs = [2, 4, 3]\n" +"> y = coefs[0] * x**0 + coefs[1] * x**1 + coefs[2] * x**2\n" +"> print(y)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 97\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/04-loop.md:402 +msgid ">\n" +"> Write a loop using `enumerate(coefs)` which computes the value `y` of any\n" +"> polynomial, given `x` and `coefs`.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > y = 0\n" +"> > for idx, coef in enumerate(coefs):\n" +"> > y = y + coef * x**idx\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/08__05-lists.md.ja.po b/transifex/python-novice-inflammation/po/08__05-lists.md.ja.po new file mode 100644 index 00000000..b9a40733 --- /dev/null +++ b/transifex/python-novice-inflammation/po/08__05-lists.md.ja.po @@ -0,0 +1,736 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/05-lists.md:1 +# Front Matter +msgid "---\n" +"title: Storing Multiple Values in Lists\n" +"teaching: 30\n" +"exercises: 15\n" +"questions:\n" +"- \"How can I store many values together?\"\n" +"objectives:\n" +"- \"Explain what a list is.\"\n" +"- \"Create and index lists of simple values.\"\n" +"- \"Change the values of individual elements\"\n" +"- \"Append values to an existing list\"\n" +"- \"Reorder and slice list elements\"\n" +"- \"Create and manipulate nested lists\"\n" +"keypoints:\n" +"- \"`[value1, value2, value3, ...]` creates a list.\"\n" +"- \"Lists can contain any Python object, including lists (i.e., list of lists).\"\n" +"- \"Lists are indexed and sliced with square brackets (e.g., list[0] and\n" +"list[2:9]), in the same way as strings and arrays.\"\n" +"- \"Lists are mutable (i.e., their values can be changed in place).\"\n" +"- \"Strings are immutable (i.e., the characters in them cannot be changed).\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:23 +msgid "Similar to a string that can contain many characters, a list is a container that can store many values.\n" +"Unlike NumPy arrays,\n" +"lists are built into the language (so we don't have to load a library\n" +"to use them).\n" +"We create a list by putting values inside square brackets and separating the values with commas:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:29 +# code block +msgid "~~~\n" +"odds = [1, 3, 5, 7]\n" +"print('odds are:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:35 +# code block +msgid "~~~\n" +"odds are: [1, 3, 5, 7]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:40 +msgid "We can access elements of a list using indices -- numbered positions of elements in the list.\n" +"These positions are numbered starting at 0, so the first element has an index of 0." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:43 +# code block +msgid "~~~\n" +"print('first element:', odds[0])\n" +"print('last element:', odds[3])\n" +"print('\"-1\" element:', odds[-1])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:50 +# code block +msgid "~~~\n" +"first element: 1\n" +"last element: 7\n" +"\"-1\" element: 7\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:57 +msgid "Yes, we can use negative numbers as indices in Python. When we do so, the index `-1` gives us the\n" +"last element in the list, `-2` the second to last, and so on.\n" +"Because of this, `odds[3]` and `odds[-1]` point to the same element here." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:61 +msgid "If we loop over a list, the loop variable is assigned to its elements one at a time:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:63 +# code block +msgid "~~~\n" +"for number in odds:\n" +" print(number)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:69 +# code block +msgid "~~~\n" +"1\n" +"3\n" +"5\n" +"7\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:77 +msgid "There is one important difference between lists and strings:\n" +"we can change the values in a list,\n" +"but we cannot change individual characters in a string.\n" +"For example:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:82 +# code block +msgid "~~~\n" +"names = ['Curie', 'Darwing', 'Turing'] # typo in Darwin's name\n" +"print('names is originally:', names)\n" +"names[1] = 'Darwin' # correct the name\n" +"print('final value of names:', names)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:90 +# code block +msgid "~~~\n" +"names is originally: ['Curie', 'Darwing', 'Turing']\n" +"final value of names: ['Curie', 'Darwin', 'Turing']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:96 +msgid "works, but:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:98 +# code block +msgid "~~~\n" +"name = 'Darwin'\n" +"name[0] = 'd'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:104 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"TypeError Traceback (most recent call last)\n" +" in ()\n" +" 1 name = 'Darwin'\n" +"----> 2 name[0] = 'd'\n" +"\n" +"TypeError: 'str' object does not support item assignment\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:115 +msgid "does not." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:117 +# blockquote, which can be cascaded +msgid "> ## Ch-Ch-Ch-Ch-Changes" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:118 +msgid ">\n" +"> Data which can be modified in place is called [mutable]({{ page.root }}/reference.html#mutable),\n" +"> while data which cannot be modified is called [immutable]({{ page.root }}/reference.html#immutable).\n" +"> Strings and numbers are immutable. This does not mean that variables with string or number values\n" +"> are constants, but when we want to change the value of a string or number variable, we can only\n" +"> replace the old value with a completely new value.\n" +">\n" +"> Lists and arrays, on the other hand, are mutable: we can modify them after they have been\n" +"> created. We can change individual elements, append new elements, or reorder the whole list. For\n" +"> some operations, like sorting, we can choose whether to use a function that modifies the data\n" +"> in-place or a function that returns a modified copy and leaves the original unchanged.\n" +">\n" +"> Be careful when modifying data in-place. If two variables refer to the same list, and you modify\n" +"> the list value, it will change for both variables!\n" +">\n" +"> ~~~\n" +"> salsa = ['peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> my_salsa = salsa # <-- my_salsa and salsa point to the *same* list data in memory\n" +"> salsa[0] = 'hot peppers'\n" +"> print('Ingredients in my salsa:', my_salsa)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Ingredients in my salsa: ['hot peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:145 +msgid ">\n" +"> If you want variables with mutable values to be independent, you\n" +"> must make a copy of the value when you assign it.\n" +">\n" +"> ~~~\n" +"> salsa = ['peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> my_salsa = list(salsa) # <-- makes a *copy* of the list\n" +"> salsa[0] = 'hot peppers'\n" +"> print('Ingredients in my salsa:', my_salsa)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Ingredients in my salsa: ['peppers', 'onions', 'cilantro', 'tomatoes']\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:161 +msgid ">\n" +"> Because of pitfalls like this, code which modifies data in place can be more difficult to\n" +"> understand. However, it is often far more efficient to modify a large data structure in place\n" +"> than to create a modified copy for every small change. You should consider both of these aspects\n" +"> when writing your code." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:168 +# blockquote, which can be cascaded +msgid "> ## Nested Lists" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:169 +# blockquote, which can be cascaded +msgid "> Since a list can contain any Python variables, it can even contain other lists." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:170 +msgid ">\n" +"> For example, we could represent the products in the shelves of a small grocery shop:\n" +">\n" +"> ~~~\n" +"> x = [['pepper', 'zucchini', 'onion'],\n" +"> ['cabbage', 'lettuce', 'garlic'],\n" +"> ['apple', 'pear', 'banana']]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Here is a visual example of how indexing a list of lists `x` works:\n" +">\n" +"> [![x is represented as a pepper shaker containing several packets of pepper. [x[0]] is represented\n" +"> as a pepper shaker containing a single packet of pepper. x[0] is represented as a single packet of\n" +"> pepper. x[0][0] is represented as single grain of pepper. Adapted\n" +"> from @hadleywickham.](../fig/indexing_lists_python.png)][hadleywickham-tweet]\n" +">\n" +"> Using the previously declared list `x`, these would be the results of the\n" +"> index operations shown in the image:\n" +">\n" +"> ~~~\n" +"> print([x[0]])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> [['pepper', 'zucchini', 'onion']]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:199 +msgid ">\n" +"> ~~~\n" +"> print(x[0])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> ['pepper', 'zucchini', 'onion']\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:209 +msgid ">\n" +"> ~~~\n" +"> print(x[0][0])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 'pepper'\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:219 +msgid ">\n" +"> Thanks to [Hadley Wickham][hadleywickham-tweet]\n" +"> for the image above." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:224 +# blockquote, which can be cascaded +msgid "> ## Heterogeneous Lists" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:225 +# blockquote, which can be cascaded +msgid "> Lists in Python can contain elements of different types. Example:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:226 +#: python-novice-inflammation/_episodes/05-lists.md:228 +#: python-novice-inflammation/_episodes/07-cond.md:429 +#: python-novice-inflammation/_episodes/07-cond.md:431 +#: python-novice-inflammation/_episodes/07-cond.md:433 +#: python-novice-inflammation/_episodes/07-cond.md:435 +# blockquote, which can be cascaded +msgid "> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:227 +# blockquote, which can be cascaded +msgid "> sample_ages = [10, 12.5, 'Unknown']" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:229 +#: python-novice-inflammation/_episodes/07-cond.md:432 +# blockquote, which can be cascaded +msgid "> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:232 +msgid "There are many ways to change the contents of lists besides assigning new values to\n" +"individual elements:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:235 +# code block +msgid "~~~\n" +"odds.append(11)\n" +"print('odds after adding a value:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:241 +# code block +msgid "~~~\n" +"odds after adding a value: [1, 3, 5, 7, 11]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:246 +# code block +msgid "~~~\n" +"removed_element = odds.pop(0)\n" +"print('odds after removing the first element:', odds)\n" +"print('removed_element:', removed_element)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:253 +# code block +msgid "~~~\n" +"odds after removing the first element: [3, 5, 7, 11]\n" +"removed_element: 1\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:259 +# code block +msgid "~~~\n" +"odds.reverse()\n" +"print('odds after reversing:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:265 +# code block +msgid "~~~\n" +"odds after reversing: [11, 7, 5, 3]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:270 +msgid "While modifying in place, it is useful to remember that Python treats lists in a slightly\n" +"counter-intuitive way." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:273 +msgid "As we saw earlier, when we modified the `salsa` list item in-place, if we make a list, (attempt to) copy it and then modify this list, we can cause all sorts of trouble. This also applies to modifying the list using the above functions:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:275 +# code block +msgid "~~~\n" +"odds = [1, 3, 5, 7]\n" +"primes = odds\n" +"primes.append(2)\n" +"print('primes:', primes)\n" +"print('odds:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:284 +# code block +msgid "~~~\n" +"primes: [1, 3, 5, 7, 2]\n" +"odds: [1, 3, 5, 7, 2]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:290 +msgid "This is because Python stores a list in memory, and then can use multiple names to refer to the\n" +"same list. If all we want to do is copy a (simple) list, we can again use the `list` function, so we do\n" +"not modify a list we did not mean to:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:294 +# code block +msgid "~~~\n" +"odds = [1, 3, 5, 7]\n" +"primes = list(odds)\n" +"primes.append(2)\n" +"print('primes:', primes)\n" +"print('odds:', odds)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:303 +# code block +msgid "~~~\n" +"primes: [1, 3, 5, 7, 2]\n" +"odds: [1, 3, 5, 7]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:309 +# blockquote, which can be cascaded +msgid "> ## Turn a String Into a List" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:310 +msgid ">\n" +"> Use a for-loop to convert the string \"hello\" into a list of letters:\n" +">\n" +"> ~~~\n" +"> ['h', 'e', 'l', 'l', 'o']\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Hint: You can create an empty list like this:\n" +">\n" +"> ~~~\n" +"> my_list = []\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > my_list = []\n" +"> > for char in 'hello':\n" +"> > my_list.append(char)\n" +"> > print(my_list)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:336 +msgid "Subsets of lists and strings can be accessed by specifying ranges of values in brackets,\n" +"similar to how we accessed ranges of positions in a NumPy array.\n" +"This is commonly referred to as \"slicing\" the list/string." +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:340 +# code block +msgid "~~~\n" +"binomial_name = 'Drosophila melanogaster'\n" +"group = binomial_name[0:10]\n" +"print('group:', group)\n" +"\n" +"species = binomial_name[11:23]\n" +"print('species:', species)\n" +"\n" +"chromosomes = ['X', 'Y', '2', '3', '4']\n" +"autosomes = chromosomes[2:5]\n" +"print('autosomes:', autosomes)\n" +"\n" +"last = chromosomes[-1]\n" +"print('last:', last)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:357 +# code block +msgid "~~~\n" +"group: Drosophila\n" +"species: melanogaster\n" +"autosomes: ['2', '3', '4']\n" +"last: 4\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:365 +# blockquote, which can be cascaded +msgid "> ## Slicing From the End" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:366 +msgid ">\n" +"> Use slicing to access only the last four characters of a string or entries of a list.\n" +">\n" +"> ~~~\n" +"> string_for_slicing = 'Observation date: 02-Feb-2013'\n" +"> list_for_slicing = [['fluorine', 'F'],\n" +"> ['chlorine', 'Cl'],\n" +"> ['bromine', 'Br'],\n" +"> ['iodine', 'I'],\n" +"> ['astatine', 'At']]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> '2013'\n" +"> [['chlorine', 'Cl'], ['bromine', 'Br'], ['iodine', 'I'], ['astatine', 'At']]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:384 +msgid ">\n" +"> Would your solution work regardless of whether you knew beforehand\n" +"> the length of the string or list\n" +"> (e.g. if you wanted to apply the solution to a set of lists of different lengths)?\n" +"> If not, try to change your approach to make it more robust.\n" +">\n" +"> Hint: Remember that indices can be negative as well as positive\n" +">\n" +"> > ## Solution\n" +"> > Use negative indices to count elements from the end of a container (such as list or string):\n" +"> >\n" +"> > ~~~\n" +"> > string_for_slicing[-4:]\n" +"> > list_for_slicing[-4:]\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:403 +# blockquote, which can be cascaded +msgid "> ## Non-Continuous Slices" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:404 +msgid ">\n" +"> So far we've seen how to use slicing to take single blocks\n" +"> of successive entries from a sequence.\n" +"> But what if we want to take a subset of entries\n" +"> that aren't next to each other in the sequence?\n" +">\n" +"> You can achieve this by providing a third argument\n" +"> to the range within the brackets, called the _step size_.\n" +"> The example below shows how you can take every third entry in a list:\n" +">\n" +"> ~~~\n" +"> primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]\n" +"> subset = primes[0:12:3]\n" +"> print('subset', subset)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> subset [2, 7, 17, 29]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:425 +msgid ">\n" +"> Notice that the slice taken begins with the first entry in the range,\n" +"> followed by entries taken at equally-spaced intervals (the steps) thereafter.\n" +"> If you wanted to begin the subset with the third entry,\n" +"> you would need to specify that as the starting point of the sliced range:\n" +">\n" +"> ~~~\n" +"> primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]\n" +"> subset = primes[2:12:3]\n" +"> print('subset', subset)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> subset [5, 13, 23, 37]\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:442 +msgid ">\n" +"> Use the step size argument to create a new string\n" +"> that contains only every other character in the string\n" +"> \"In an octopus's garden in the shade\". Start with\n" +"> creating a variable to hold the string:\n" +">\n" +"> ~~~\n" +"> beatles = \"In an octopus's garden in the shade\"\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> What slice of `beatles` will produce the\n" +"> following output (i.e., the first character, third\n" +"> character, and every other character through the end\n" +"> of the string)?\n" +"> ~~~\n" +"> I notpssgre ntesae\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:461 +msgid ">\n" +"> > ## Solution\n" +"> > To obtain every other character you need to provide a slice with the step\n" +"> > size of 2:\n" +"> >\n" +"> > ~~~\n" +"> > beatles[0:35:2]\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > You can also leave out the beginning and end of the slice to take the whole string\n" +"> > and provide only the step argument to go every second\n" +"> > element:\n" +"> >\n" +"> > ~~~\n" +"> > beatles[::2]\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:482 +msgid "If you want to take a slice from the beginning of a sequence, you can omit the first index in the\n" +"range:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:485 +# code block +msgid "~~~\n" +"date = 'Monday 4 January 2016'\n" +"day = date[0:6]\n" +"print('Using 0 to begin range:', day)\n" +"day = date[:6]\n" +"print('Omitting beginning index:', day)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:494 +# code block +msgid "~~~\n" +"Using 0 to begin range: Monday\n" +"Omitting beginning index: Monday\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:500 +msgid "And similarly, you can omit the ending index in the range to take a slice to the very end of the\n" +"sequence:" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:503 +# code block +msgid "~~~\n" +"months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']\n" +"sond = months[8:12]\n" +"print('With known last position:', sond)\n" +"sond = months[8:len(months)]\n" +"print('Using len() to get last entry:', sond)\n" +"sond = months[8:]\n" +"print('Omitting ending index:', sond)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:514 +# code block +msgid "~~~\n" +"With known last position: ['sep', 'oct', 'nov', 'dec']\n" +"Using len() to get last entry: ['sep', 'oct', 'nov', 'dec']\n" +"Omitting ending index: ['sep', 'oct', 'nov', 'dec']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:521 +# blockquote, which can be cascaded +msgid "> ## Overloading" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:522 +msgid ">\n" +"> `+` usually means addition, but when used on strings or lists, it means \"concatenate\".\n" +"> Given that, what do you think the multiplication operator `*` does on lists?\n" +"> In particular, what will be the output of the following code?\n" +">\n" +"> ~~~\n" +"> counts = [2, 4, 6, 8, 10]\n" +"> repeats = counts * 2\n" +"> print(repeats)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> 1. `[2, 4, 6, 8, 10, 2, 4, 6, 8, 10]`\n" +"> 2. `[4, 8, 12, 16, 20]`\n" +"> 3. `[[2, 4, 6, 8, 10],[2, 4, 6, 8, 10]]`\n" +"> 4. `[2, 4, 6, 8, 10, 4, 8, 12, 16, 20]`\n" +">\n" +"> The technical term for this is *operator overloading*:\n" +"> a single operator, like `+` or `*`,\n" +"> can do different things depending on what it's applied to.\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > The multiplication operator `*` used on a list replicates elements of the list and concatenates\n" +"> > them together:\n" +"> >\n" +"> > ~~~\n" +"> > [2, 4, 6, 8, 10, 2, 4, 6, 8, 10]\n" +"> > ~~~\n" +"> > {: .output}\n" +"> >\n" +"> > It's equivalent to:\n" +"> >\n" +"> > ~~~\n" +"> > counts + counts\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/05-lists.md:562 +msgid "[hadleywickham-tweet]: https://twitter.com/hadleywickham/status/643381054758363136" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/09__06-files.md.ja.po b/transifex/python-novice-inflammation/po/09__06-files.md.ja.po new file mode 100644 index 00000000..29c0286a --- /dev/null +++ b/transifex/python-novice-inflammation/po/09__06-files.md.ja.po @@ -0,0 +1,254 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/06-files.md:1 +# Front Matter +msgid "---\n" +"title: Analyzing Data from Multiple Files\n" +"teaching: 20\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I do the same operations on many different files?\"\n" +"objectives:\n" +"- \"Use a library function to get a list of filenames that match a wildcard pattern.\"\n" +"- \"Write a `for` loop to process multiple files.\"\n" +"keypoints:\n" +"- \"Use `glob.glob(pattern)` to create a list of files whose names match a pattern.\"\n" +"- \"Use `*` in a pattern to match zero or more characters, and `?` to match any single character.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:15 +msgid "We now have almost everything we need to process all our data files.\n" +"The only thing that's missing is a library with a rather unpleasant name:" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:18 +# code block +msgid "~~~\n" +"import glob\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:23 +msgid "The `glob` library contains a function, also called `glob`,\n" +"that finds files and directories whose names match a pattern.\n" +"We provide those patterns as strings:\n" +"the character `*` matches zero or more characters,\n" +"while `?` matches any one character.\n" +"We can use this to get the names of all the CSV files in the current directory:" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:30 +# code block +msgid "~~~\n" +"print(glob.glob('inflammation*.csv'))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:35 +# code block +msgid "~~~\n" +"['inflammation-05.csv', 'inflammation-11.csv', 'inflammation-12.csv', 'inflammation-08.csv',\n" +"'inflammation-03.csv', 'inflammation-06.csv', 'inflammation-09.csv', 'inflammation-07.csv',\n" +"'inflammation-10.csv', 'inflammation-02.csv', 'inflammation-04.csv', 'inflammation-01.csv']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:42 +msgid "As these examples show,\n" +"`glob.glob`'s result is a list of file and directory paths in arbitrary order.\n" +"This means we can loop over it\n" +"to do something with each filename in turn.\n" +"In our case,\n" +"the \"something\" we want to do is generate a set of plots for each file in our inflammation dataset.\n" +"If we want to start by analyzing just the first three files in alphabetical order, we can use the\n" +"`sorted` built-in function to generate a new sorted list from the `glob.glob` output:" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:51 +# code block +msgid "~~~\n" +"import glob\n" +"import numpy\n" +"import matplotlib.pyplot\n" +"\n" +"filenames = sorted(glob.glob('inflammation*.csv'))\n" +"filenames = filenames[0:3]\n" +"for filename in filenames:\n" +" print(filename)\n" +"\n" +" data = numpy.loadtxt(fname=filename, delimiter=',')\n" +"\n" +" fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"\n" +" axes1 = fig.add_subplot(1, 3, 1)\n" +" axes2 = fig.add_subplot(1, 3, 2)\n" +" axes3 = fig.add_subplot(1, 3, 3)\n" +"\n" +" axes1.set_ylabel('average')\n" +" axes1.plot(numpy.mean(data, axis=0))\n" +"\n" +" axes2.set_ylabel('max')\n" +" axes2.plot(numpy.max(data, axis=0))\n" +"\n" +" axes3.set_ylabel('min')\n" +" axes3.plot(numpy.min(data, axis=0))\n" +"\n" +" fig.tight_layout()\n" +" matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:83 +# code block +msgid "~~~\n" +"inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:88 +msgid "![Analysis of inflammation-01.csv](../fig/03-loop_49_1.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:90 +# code block +msgid "~~~\n" +"inflammation-02.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:95 +msgid "![Analysis of inflammation-02.csv](../fig/03-loop_49_3.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:97 +# code block +msgid "~~~\n" +"inflammation-03.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:102 +msgid "![Analysis of inflammation-03.csv](../fig/03-loop_49_5.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:104 +msgid "Sure enough,\n" +"the maxima of the first two data sets show exactly the same ramp as the first,\n" +"and their minima show the same staircase structure;\n" +"a different situation has been revealed in the third dataset,\n" +"where the maxima are a bit less regular, but the minima are consistently zero." +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:110 +# blockquote, which can be cascaded +msgid "> ## Plotting Differences" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:111 +msgid ">\n" +"> Plot the difference between the average inflammations reported in the first and second datasets\n" +"> (stored in `inflammation-01.csv` and `inflammation-02.csv`, correspondingly),\n" +"> i.e., the difference between the leftmost plots of the first two figures.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import glob\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > filenames = sorted(glob.glob('inflammation*.csv'))\n" +"> >\n" +"> > data0 = numpy.loadtxt(fname=filenames[0], delimiter=',')\n" +"> > data1 = numpy.loadtxt(fname=filenames[1], delimiter=',')\n" +"> >\n" +"> > fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"> >\n" +"> > matplotlib.pyplot.ylabel('Difference in average')\n" +"> > matplotlib.pyplot.plot(numpy.mean(data0, axis=0) - numpy.mean(data1, axis=0))\n" +"> >\n" +"> > fig.tight_layout()\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:139 +# blockquote, which can be cascaded +msgid "> ## Generate Composite Statistics" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:140 +msgid ">\n" +"> Use each of the files once to generate a dataset containing values averaged over all patients:\n" +">\n" +"> ~~~\n" +"> filenames = glob.glob('inflammation*.csv')\n" +"> composite_data = numpy.zeros((60,40))\n" +"> for filename in filenames:\n" +"> # sum each new file's data into composite_data as it's read\n" +"> #\n" +"> # and then divide the composite_data by number of samples\n" +"> composite_data = composite_data / len(filenames)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Then use pyplot to generate average, max, and min for all patients.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import glob\n" +"> > import numpy\n" +"> > import matplotlib.pyplot\n" +"> >\n" +"> > filenames = glob.glob('inflammation*.csv')\n" +"> > composite_data = numpy.zeros((60,40))\n" +"> >\n" +"> > for filename in filenames:\n" +"> > data = numpy.loadtxt(fname = filename, delimiter=',')\n" +"> > composite_data = composite_data + data\n" +"> >\n" +"> > composite_data = composite_data / len(filenames)\n" +"> >\n" +"> > fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"> >\n" +"> > axes1 = fig.add_subplot(1, 3, 1)\n" +"> > axes2 = fig.add_subplot(1, 3, 2)\n" +"> > axes3 = fig.add_subplot(1, 3, 3)\n" +"> >\n" +"> > axes1.set_ylabel('average')\n" +"> > axes1.plot(numpy.mean(composite_data, axis=0))\n" +"> >\n" +"> > axes2.set_ylabel('max')\n" +"> > axes2.plot(numpy.max(composite_data, axis=0))\n" +"> >\n" +"> > axes3.set_ylabel('min')\n" +"> > axes3.plot(numpy.min(composite_data, axis=0))\n" +"> >\n" +"> > fig.tight_layout()\n" +"> >\n" +"> > matplotlib.pyplot.show()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/06-files.md:191 +# SC/DC Template label +msgid ">{: .solution}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/10__07-cond.md.ja.po b/transifex/python-novice-inflammation/po/10__07-cond.md.ja.po new file mode 100644 index 00000000..377d39f4 --- /dev/null +++ b/transifex/python-novice-inflammation/po/10__07-cond.md.ja.po @@ -0,0 +1,657 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/07-cond.md:1 +# Front Matter +msgid "---\n" +"title: Making Choices\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can my programs do different things based on data values?\"\n" +"objectives:\n" +"- \"Write conditional statements including `if`, `elif`, and `else` branches.\"\n" +"- \"Correctly evaluate expressions containing `and` and `or`.\"\n" +"keypoints:\n" +"- \"Use `if condition` to start a conditional statement, `elif condition` to\n" +" provide additional tests, and `else` to provide a default.\"\n" +"- \"The bodies of the branches of conditional statements must be indented.\"\n" +"- \"Use `==` to test for equality.\"\n" +"- \"`X and Y` is only true if both `X` and `Y` are true.\"\n" +"- \"`X or Y` is true if either `X` or `Y`, or both, are true.\"\n" +"- \"Zero, the empty string, and the empty list are considered false;\n" +" all other numbers, strings, and lists are considered true.\"\n" +"- \"`True` and `False` represent truth values.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:22 +msgid "In our last lesson, we discovered something suspicious was going on\n" +"in our inflammation data by drawing some plots.\n" +"How can we use Python to automatically recognize the different features we saw,\n" +"and take a different action for each? In this lesson, we'll learn how to write code that\n" +"runs only when certain conditions are true." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:28 +# header +msgid "## Conditionals" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:30 +msgid "We can ask Python to take different actions, depending on a condition, with an `if` statement:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:32 +# code block +msgid "~~~\n" +"num = 37\n" +"if num > 100:\n" +" print('greater')\n" +"else:\n" +" print('not greater')\n" +"print('done')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:42 +# code block +msgid "~~~\n" +"not greater\n" +"done\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:48 +msgid "The second line of this code uses the keyword `if` to tell Python that we want to make a choice.\n" +"If the test that follows the `if` statement is true,\n" +"the body of the `if`\n" +"(i.e., the set of lines indented underneath it) is executed, and \"greater\" is printed.\n" +"If the test is false,\n" +"the body of the `else` is executed instead, and \"not greater\" is printed.\n" +"Only one or the other is ever executed before continuing on with program execution to print \"done\":" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:56 +msgid "![A flowchart diagram of the if-else construct that tests if variable num is greater than 100](../fig/python-flowchart-conditional.png)" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:58 +msgid "Conditional statements don't have to include an `else`.\n" +"If there isn't one,\n" +"Python simply does nothing if the test is false:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:62 +# code block +msgid "~~~\n" +"num = 53\n" +"print('before conditional...')\n" +"if num > 100:\n" +" print(num,' is greater than 100')\n" +"print('...after conditional')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:71 +# code block +msgid "~~~\n" +"before conditional...\n" +"...after conditional\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:77 +msgid "We can also chain several tests together using `elif`,\n" +"which is short for \"else if\".\n" +"The following Python code uses `elif` to print the sign of a number." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:81 +# code block +msgid "~~~\n" +"num = -3\n" +"\n" +"if num > 0:\n" +" print(num, 'is positive')\n" +"elif num == 0:\n" +" print(num, 'is zero')\n" +"else:\n" +" print(num, 'is negative')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:93 +# code block +msgid "~~~\n" +"-3 is negative\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:98 +msgid "Note that to test for equality we use a double equals sign `==`\n" +"rather than a single equals sign `=` which is used to assign values." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:101 +# blockquote, which can be cascaded +msgid "> ## Comparing in Python" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:102 +msgid ">\n" +"> Along with the `>` and `==` operators we have already used for comparing values in our conditionals, \n" +"> there are a few more options to know about:\n" +">\n" +"> - `>`: greater than\n" +"> - `<`: less than\n" +"> - `==`: equal to\n" +"> - `!=`: does not equal\n" +"> - `>=`: greater than or equal to\n" +"> - `<=`: less than or equal to" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:114 +msgid "We can also combine tests using `and` and `or`.\n" +"`and` is only true if both parts are true:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:117 +# code block +msgid "~~~\n" +"if (1 > 0) and (-1 >= 0):\n" +" print('both parts are true')\n" +"else:\n" +" print('at least one part is false')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:125 +# code block +msgid "~~~\n" +"at least one part is false\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:130 +msgid "while `or` is true if at least one part is true:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:132 +# code block +msgid "~~~\n" +"if (1 < 0) or (1 >= 0):\n" +" print('at least one test is true')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:138 +# code block +msgid "~~~\n" +"at least one test is true\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:143 +# blockquote, which can be cascaded +msgid "> ## `True` and `False`" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:144 +# blockquote, which can be cascaded +msgid "> `True` and `False` are special words in Python called `booleans`," +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:145 +# blockquote, which can be cascaded +msgid "> which represent truth values. A statement such as `1 < 0` returns" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:146 +# blockquote, which can be cascaded +msgid "> the value `False`, while `-1 < 0` returns the value `True`." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:149 +# header +msgid "## Checking our Data" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:151 +msgid "Now that we've seen how conditionals work,\n" +"we can use them to check for the suspicious features we saw in our inflammation data.\n" +"We are about to use functions provided by the `numpy` module again.\n" +"Therefore, if you're working in a new Python session, make sure to load the\n" +"module with:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:162 +msgid "From the first couple of plots, we saw that maximum daily inflammation exhibits\n" +"a strange behavior and raises one unit a day.\n" +"Wouldn't it be a good idea to detect such behavior and report it as suspicious?\n" +"Let's do that!\n" +"However, instead of checking every single day of the study, let's merely check\n" +"if maximum inflammation in the beginning (day 0) and in the middle (day 20) of\n" +"the study are equal to the corresponding day numbers." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:170 +# code block +msgid "~~~\n" +"max_inflammation_0 = numpy.max(data, axis=0)[0]\n" +"max_inflammation_20 = numpy.max(data, axis=0)[20]\n" +"\n" +"if max_inflammation_0 == 0 and max_inflammation_20 == 20:\n" +" print('Suspicious looking maxima!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:179 +msgid "We also saw a different problem in the third dataset;\n" +"the minima per day were all zero (looks like a healthy person snuck into our study).\n" +"We can also check for this with an `elif` condition:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:183 +# code block +msgid "~~~\n" +"elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:189 +msgid "And if neither of these conditions are true, we can use `else` to give the all-clear:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:191 +# code block +msgid "~~~\n" +"else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:197 +msgid "Let's test that out:" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:199 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"\n" +"max_inflammation_0 = numpy.max(data, axis=0)[0]\n" +"max_inflammation_20 = numpy.max(data, axis=0)[20]\n" +"\n" +"if max_inflammation_0 == 0 and max_inflammation_20 == 20:\n" +" print('Suspicious looking maxima!')\n" +"elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +"else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:214 +# code block +msgid "~~~\n" +"Suspicious looking maxima!\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:219 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-03.csv', delimiter=',')\n" +"\n" +"max_inflammation_0 = numpy.max(data, axis=0)[0]\n" +"max_inflammation_20 = numpy.max(data, axis=0)[20]\n" +"\n" +"if max_inflammation_0 == 0 and max_inflammation_20 == 20:\n" +" print('Suspicious looking maxima!')\n" +"elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +"else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:234 +# code block +msgid "~~~\n" +"Minima add up to zero!\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:239 +msgid "In this way,\n" +"we have asked Python to do something different depending on the condition of our data.\n" +"Here we printed messages in all cases,\n" +"but we could also imagine not using the `else` catch-all\n" +"so that messages are only printed when something is wrong,\n" +"freeing us from having to manually examine every plot for features we've seen before." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:246 +# blockquote, which can be cascaded +msgid "> ## How Many Paths?" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:247 +msgid ">\n" +"> Consider this code:\n" +">\n" +"> ~~~\n" +"> if 4 > 5:\n" +"> print('A')\n" +"> elif 4 == 5:\n" +"> print('B')\n" +"> elif 4 < 5:\n" +"> print('C')\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Which of the following would be printed if you were to run this code?\n" +"> Why did you pick this answer?\n" +">\n" +"> 1. A\n" +"> 2. B\n" +"> 3. C\n" +"> 4. B and C\n" +">\n" +"> > ## Solution\n" +"> > C gets printed because the first two conditions, `4 > 5` and `4 == 5`, are not true,\n" +"> > but `4 < 5` is true." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:274 +# blockquote, which can be cascaded +msgid "> ## What Is Truth?" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:275 +msgid ">\n" +"> `True` and `False` booleans are not the only values in Python that are true and false.\n" +"> In fact, *any* value can be used in an `if` or `elif`.\n" +"> After reading and running the code below,\n" +"> explain what the rule is for which values are considered true and which are considered false.\n" +">\n" +"> ~~~\n" +"> if '':\n" +"> print('empty string is true')\n" +"> if 'word':\n" +"> print('word is true')\n" +"> if []:\n" +"> print('empty list is true')\n" +"> if [1, 2, 3]:\n" +"> print('non-empty list is true')\n" +"> if 0:\n" +"> print('zero is true')\n" +"> if 1:\n" +"> print('one is true')\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:298 +# blockquote, which can be cascaded +msgid "> ## That's Not Not What I Meant" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:299 +msgid ">\n" +"> Sometimes it is useful to check whether some condition is not true.\n" +"> The Boolean operator `not` can do this explicitly.\n" +"> After reading and running the code below,\n" +"> write some `if` statements that use `not` to test the rule\n" +"> that you formulated in the previous challenge.\n" +">\n" +"> ~~~\n" +"> if not '':\n" +"> print('empty string is not true')\n" +"> if not 'word':\n" +"> print('word is not true')\n" +"> if not not True:\n" +"> print('not not True is true')\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:317 +# blockquote, which can be cascaded +msgid "> ## Close Enough" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:318 +msgid ">\n" +"> Write some conditions that print `True` if the variable `a` is within 10% of the variable `b`\n" +"> and `False` otherwise.\n" +"> Compare your implementation with your partner's:\n" +"> do you get the same answer for all possible pairs of numbers?\n" +">\n" +"> > ## Hint\n" +"> > There is a [built-in function `abs`][abs-function] that returns the absolute value of\n" +"> > a number:\n" +"> > ~~~\n" +"> > print(abs(-12))\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> > ~~~\n" +"> > 12\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:336 +msgid ">\n" +"> > ## Solution 1\n" +"> > ~~~\n" +"> > a = 5\n" +"> > b = 5.1\n" +"> >\n" +"> > if abs(a - b) <= 0.1 * abs(b):\n" +"> > print('True')\n" +"> > else:\n" +"> > print('False')\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:349 +msgid ">\n" +"> > ## Solution 2\n" +"> > ~~~\n" +"> > print(abs(a - b) <= 0.1 * abs(b))\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > This works because the Booleans `True` and `False`\n" +"> > have string representations which can be printed." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:361 +# blockquote, which can be cascaded +msgid "> ## In-Place Operators" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:362 +msgid ">\n" +"> Python (and most other languages in the C family) provides\n" +"> [in-place operators]({{ page.root }}/reference.html#in-place-operators)\n" +"> that work like this:\n" +">\n" +"> ~~~\n" +"> x = 1 # original value\n" +"> x += 1 # add one to x, assigning result back to x\n" +"> x *= 3 # multiply x by 3\n" +"> print(x)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 6\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:379 +msgid ">\n" +"> Write some code that sums the positive and negative numbers in a list separately,\n" +"> using in-place operators.\n" +"> Do you think the result is more or less readable\n" +"> than writing the same without in-place operators?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > positive_sum = 0\n" +"> > negative_sum = 0\n" +"> > test_list = [3, 4, 6, 1, -1, -5, 0, 7, -8]\n" +"> > for num in test_list:\n" +"> > if num > 0:\n" +"> > positive_sum += num\n" +"> > elif num == 0:\n" +"> > pass\n" +"> > else:\n" +"> > negative_sum += num\n" +"> > print(positive_sum, negative_sum)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > Here `pass` means \"don't do anything\".\n" +"> In this particular case, it's not actually needed, since if `num == 0` neither\n" +"> > sum needs to change, but it illustrates the use of `elif` and `pass`." +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:407 +# blockquote, which can be cascaded +msgid "> ## Sorting a List Into Buckets" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:408 +msgid ">\n" +"> In our `data` folder, large data sets are stored in files whose names start with\n" +"> \"inflammation-\" and small data sets -- in files whose names start with \"small-\". We\n" +"> also have some other files that we do not care about at this point. We'd like to break all\n" +"> these files into three lists called `large_files`, `small_files`, and `other_files`,\n" +"> respectively.\n" +">\n" +"> Add code to the template below to do this. Note that the string method\n" +"> [`startswith`](https://docs.python.org/3/library/stdtypes.html#str.startswith)\n" +"> returns `True` if and only if the string it is called on starts with the string\n" +"> passed as an argument, that is:\n" +">\n" +"> ~~~\n" +"> 'String'.startswith('Str')\n" +"> ~~~\n" +"> {: .language-python}\n" +"> ~~~\n" +"> True\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:428 +# blockquote, which can be cascaded +msgid "> But" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:430 +# blockquote, which can be cascaded +msgid "> 'String'.startswith('str')" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:434 +# blockquote, which can be cascaded +msgid "> False" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:437 +msgid ">Use the following Python code as your starting point:\n" +"> ~~~\n" +"> filenames = ['inflammation-01.csv',\n" +"> 'myscript.py',\n" +"> 'inflammation-02.csv',\n" +"> 'small-01.csv',\n" +"> 'small-02.csv']\n" +"> large_files = []\n" +"> small_files = []\n" +"> other_files = []\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Your solution should:\n" +">\n" +"> 1. loop over the names of the files\n" +"> 2. figure out which group each filename belongs in\n" +"> 3. append the filename to that list\n" +">\n" +"> In the end the three lists should be:\n" +">\n" +"> ~~~\n" +"> large_files = ['inflammation-01.csv', 'inflammation-02.csv']\n" +"> small_files = ['small-01.csv', 'small-02.csv']\n" +"> other_files = ['myscript.py']\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > for filename in filenames:\n" +"> > if filename.startswith('inflammation-'):\n" +"> > large_files.append(filename)\n" +"> > elif filename.startswith('small-'):\n" +"> > small_files.append(filename)\n" +"> > else:\n" +"> > other_files.append(filename)\n" +"> >\n" +"> > print('large_files:', large_files)\n" +"> > print('small_files:', small_files)\n" +"> > print('other_files:', other_files)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:483 +# blockquote, which can be cascaded +msgid "> ## Counting Vowels" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:484 +msgid ">\n" +"> 1. Write a loop that counts the number of vowels in a character string.\n" +"> 2. Test it on a few individual words and full sentences.\n" +"> 3. Once you are done, compare your solution to your neighbor's.\n" +"> Did you make the same decisions about how to handle the letter 'y'\n" +"> (which some people think is a vowel, and some do not)?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > vowels = 'aeiouAEIOU'\n" +"> > sentence = 'Mary had a little lamb.'\n" +"> > count = 0\n" +"> > for char in sentence:\n" +"> > if char in vowels:\n" +"> > count += 1\n" +"> >\n" +"> > print('The number of vowels in this string is ' + str(count))\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/07-cond.md:506 +msgid "[abs-function]: https://docs.python.org/3/library/functions.html#abs" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/11__08-func.md.ja.po b/transifex/python-novice-inflammation/po/11__08-func.md.ja.po new file mode 100644 index 00000000..80b90e0e --- /dev/null +++ b/transifex/python-novice-inflammation/po/11__08-func.md.ja.po @@ -0,0 +1,1155 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/08-func.md:1 +# Front Matter +msgid "---\n" +"title: Creating Functions\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I define new functions?\"\n" +"- \"What's the difference between defining and calling a function?\"\n" +"- \"What happens when I call a function?\"\n" +"objectives:\n" +"- \"Define a function that takes parameters.\"\n" +"- \"Return a value from a function.\"\n" +"- \"Test and debug a function.\"\n" +"- \"Set default values for function parameters.\"\n" +"- \"Explain why we should divide programs into small, single-purpose functions.\"\n" +"keypoints:\n" +"- \"Define a function using `def function_name(parameter)`.\"\n" +"- \"The body of a function must be indented.\"\n" +"- \"Call a function using `function_name(value)`.\"\n" +"- \"Numbers are stored as integers or floating-point numbers.\"\n" +"- \"Variables defined within a function can only be seen and used within the body of the function.\"\n" +"- \"If a variable is not defined within the function it is used,\n" +" Python looks for a definition before the function call\"\n" +"- \"Use `help(thing)` to view help for something.\"\n" +"- \"Put docstrings in functions to provide help for that function.\"\n" +"- \"Specify default values for parameters when defining a function using `name=value`\n" +" in the parameter list.\"\n" +"- \"Parameters can be passed by matching based on name, by position,\n" +" or by omitting them (in which case the default value is used).\"\n" +"- \"Put code whose parameters change frequently in a function,\n" +" then call it with different parameter values to customize its behavior.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:33 +msgid "At this point,\n" +"we've written code to draw some interesting features in our inflammation data,\n" +"loop over all our data files to quickly draw these plots for each of them,\n" +"and have Python make decisions based on what it sees in our data.\n" +"But, our code is getting pretty long and complicated;\n" +"what if we had thousands of datasets,\n" +"and didn't want to generate a figure for every single one?\n" +"Commenting out the figure-drawing code is a nuisance.\n" +"Also, what if we want to use that code again,\n" +"on a different dataset or at a different point in our program?\n" +"Cutting and pasting it is going to make our code get very long and very repetitive,\n" +"very quickly.\n" +"We'd like a way to package our code so that it is easier to reuse,\n" +"and Python provides for this by letting us define things called 'functions' ---\n" +"a shorthand way of re-executing longer pieces of code.\n" +"Let's start by defining a function `fahr_to_celsius` that converts temperatures\n" +"from Fahrenheit to Celsius:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:51 +# code block +msgid "~~~\n" +"def fahr_to_celsius(temp):\n" +" return ((temp - 32) * (5/9))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:57 +msgid "![Labeled parts of a Python function definition](../fig/python-function.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:60 +msgid "The function definition opens with the keyword `def` followed by the\n" +"name of the function (`fahr_to_celsius`) and a parenthesized list of parameter names (`temp`). The\n" +"[body]({{ page.root }}/reference.html#body) of the function --- the\n" +"statements that are executed when it runs --- is indented below the\n" +"definition line. The body concludes with a `return` keyword followed by the return value." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:66 +msgid "When we call the function,\n" +"the values we pass to it are assigned to those variables\n" +"so that we can use them inside the function.\n" +"Inside the function,\n" +"we use a [return statement]({{ page.root }}/reference.html#return-statement) to send a result\n" +"back to whoever asked for it." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:73 +msgid "Let's try running our function." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:75 +# code block +msgid "~~~\n" +"fahr_to_celsius(32)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:80 +msgid "This command should call our function, using \"32\" as the input and return the function value." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:82 +msgid "In fact, calling our own function is no different from calling any other function:\n" +"~~~\n" +"print('freezing point of water:', fahr_to_celsius(32), 'C')\n" +"print('boiling point of water:', fahr_to_celsius(212), 'C')\n" +"~~~\n" +"{: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:89 +# code block +msgid "~~~\n" +"freezing point of water: 0.0 C\n" +"boiling point of water: 100.0 C\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:95 +msgid "We've successfully called the function that we defined,\n" +"and we have access to the value that we returned." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:99 +# header +msgid "## Composing Functions" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:101 +msgid "Now that we've seen how to turn Fahrenheit into Celsius,\n" +"we can also write the function to turn Celsius into Kelvin:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:104 +# code block +msgid "~~~\n" +"def celsius_to_kelvin(temp_c):\n" +" return temp_c + 273.15\n" +"\n" +"print('freezing point of water in Kelvin:', celsius_to_kelvin(0.))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:112 +# code block +msgid "~~~\n" +"freezing point of water in Kelvin: 273.15\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:117 +msgid "What about converting Fahrenheit to Kelvin?\n" +"We could write out the formula,\n" +"but we don't need to.\n" +"Instead,\n" +"we can [compose]({{ page.root }}/reference.html#compose) the two functions we have already created:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:123 +# code block +msgid "~~~\n" +"def fahr_to_kelvin(temp_f):\n" +" temp_c = fahr_to_celsius(temp_f)\n" +" temp_k = celsius_to_kelvin(temp_c)\n" +" return temp_k\n" +"\n" +"print('boiling point of water in Kelvin:', fahr_to_kelvin(212.0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:133 +# code block +msgid "~~~\n" +"boiling point of water in Kelvin: 373.15\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:138 +msgid "This is our first taste of how larger programs are built:\n" +"we define basic operations,\n" +"then combine them in ever-larger chunks to get the effect we want.\n" +"Real-life functions will usually be larger than the ones shown here --- typically half a dozen\n" +"to a few dozen lines --- but they shouldn't ever be much longer than that,\n" +"or the next person who reads it won't be able to understand what's going on." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:145 +# header +msgid "## Tidying up" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:147 +msgid "Now that we know how to wrap bits of code up in functions,\n" +"we can make our inflammation analysis easier to read and easier to reuse.\n" +"First, let's make a `visualize` function that generates our plots:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:151 +# code block +msgid "~~~\n" +"def visualize(filename):\n" +"\n" +" data = numpy.loadtxt(fname=filename, delimiter=',')\n" +"\n" +" fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))\n" +"\n" +" axes1 = fig.add_subplot(1, 3, 1)\n" +" axes2 = fig.add_subplot(1, 3, 2)\n" +" axes3 = fig.add_subplot(1, 3, 3)\n" +"\n" +" axes1.set_ylabel('average')\n" +" axes1.plot(numpy.mean(data, axis=0))\n" +"\n" +" axes2.set_ylabel('max')\n" +" axes2.plot(numpy.max(data, axis=0))\n" +"\n" +" axes3.set_ylabel('min')\n" +" axes3.plot(numpy.min(data, axis=0))\n" +"\n" +" fig.tight_layout()\n" +" matplotlib.pyplot.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:176 +msgid "and another function called `detect_problems` that checks for those systematics\n" +"we noticed:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:179 +# code block +msgid "~~~\n" +"def detect_problems(filename):\n" +"\n" +" data = numpy.loadtxt(fname=filename, delimiter=',')\n" +"\n" +" if numpy.max(data, axis=0)[0] == 0 and numpy.max(data, axis=0)[20] == 20:\n" +" print('Suspicious looking maxima!')\n" +" elif numpy.sum(numpy.min(data, axis=0)) == 0:\n" +" print('Minima add up to zero!')\n" +" else:\n" +" print('Seems OK!')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:193 +msgid "Wait! Didn't we forget to specify what both of these functions should return? Well, we didn't.\n" +"In Python, functions are not required to include a `return` statement and can be used for\n" +"the sole purpose of grouping together pieces of code that conceptually do one thing. In such cases,\n" +"function names usually describe what they do, _e.g._ `visualize`, `detect_problems`." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:198 +msgid "Notice that rather than jumbling this code together in one giant `for` loop,\n" +"we can now read and reuse both ideas separately.\n" +"We can reproduce the previous analysis with a much simpler `for` loop:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:202 +# code block +msgid "~~~\n" +"filenames = sorted(glob.glob('inflammation*.csv'))\n" +"\n" +"for filename in filenames[:3]:\n" +" print(filename)\n" +" visualize(filename)\n" +" detect_problems(filename)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:212 +msgid "By giving our functions human-readable names,\n" +"we can more easily read and understand what is happening in the `for` loop.\n" +"Even better, if at some later date we want to use either of those pieces of code again,\n" +"we can do so in a single line." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:217 +# header +msgid "## Testing and Documenting" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:219 +msgid "Once we start putting things in functions so that we can re-use them,\n" +"we need to start testing that those functions are working correctly.\n" +"To see how to do this,\n" +"let's write a function to offset a dataset so that it's mean value\n" +"shifts to a user-defined value:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:225 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value):\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:231 +msgid "We could test this on our actual data,\n" +"but since we don't know what the values ought to be,\n" +"it will be hard to tell if the result was correct.\n" +"Instead,\n" +"let's use NumPy to create a matrix of 0's\n" +"and then offset its values to have a mean value of 3:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:238 +# code block +msgid "~~~\n" +"z = numpy.zeros((2,2))\n" +"print(offset_mean(z, 3))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:244 +#: python-novice-inflammation/_episodes/08-func.md:479 +# code block +msgid "~~~\n" +"[[ 3. 3.]\n" +" [ 3. 3.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:250 +msgid "That looks right,\n" +"so let's try `offset_mean` on our real data:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:253 +# code block +msgid "~~~\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"print(offset_mean(data, 0))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:259 +# code block +msgid "~~~\n" +"[[-6.14875 -6.14875 -5.14875 ... -3.14875 -6.14875 -6.14875]\n" +" [-6.14875 -5.14875 -4.14875 ... -5.14875 -6.14875 -5.14875]\n" +" [-6.14875 -5.14875 -5.14875 ... -4.14875 -5.14875 -5.14875]\n" +" ...\n" +" [-6.14875 -5.14875 -5.14875 ... -5.14875 -5.14875 -5.14875]\n" +" [-6.14875 -6.14875 -6.14875 ... -6.14875 -4.14875 -6.14875]\n" +" [-6.14875 -6.14875 -5.14875 ... -5.14875 -5.14875 -6.14875]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:270 +msgid "It's hard to tell from the default output whether the result is correct,\n" +"but there are a few tests that we can run to reassure us:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:273 +# code block +msgid "~~~\n" +"print('original min, mean, and max are:', numpy.min(data), numpy.mean(data), numpy.max(data))\n" +"offset_data = offset_mean(data, 0)\n" +"print('min, mean, and max of offset data are:',\n" +" numpy.min(offset_data),\n" +" numpy.mean(offset_data),\n" +" numpy.max(offset_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:283 +# code block +msgid "~~~\n" +"original min, mean, and max are: 0.0 6.14875 20.0\n" +"min, mean, and and max of offset data are: -6.14875 2.84217094304e-16 13.85125\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:289 +msgid "That seems almost right:\n" +"the original mean was about 6.1,\n" +"so the lower bound from zero is now about -6.1.\n" +"The mean of the offset data isn't quite zero --- we'll explore why not in the challenges --- but\n" +"it's pretty close.\n" +"We can even go further and check that the standard deviation hasn't changed:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:296 +# code block +msgid "~~~\n" +"print('std dev before and after:', numpy.std(data), numpy.std(offset_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:301 +# code block +msgid "~~~\n" +"std dev before and after: 4.61383319712 4.61383319712\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:306 +msgid "Those values look the same,\n" +"but we probably wouldn't notice if they were different in the sixth decimal place.\n" +"Let's do this instead:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:310 +# code block +msgid "~~~\n" +"print('difference in standard deviations before and after:',\n" +" numpy.std(data) - numpy.std(offset_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:316 +# code block +msgid "~~~\n" +"difference in standard deviations before and after: -3.5527136788e-15\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:321 +msgid "Again,\n" +"the difference is very small.\n" +"It's still possible that our function is wrong,\n" +"but it seems unlikely enough that we should probably get back to doing our analysis.\n" +"We have one more task first, though:\n" +"we should write some [documentation]({{ page.root }}/reference.html#documentation) for our function\n" +"to remind ourselves later what it's for and how to use it." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:329 +msgid "The usual way to put documentation in software is\n" +"to add [comments]({{ page.root }}/reference.html#comment) like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:332 +# code block +msgid "~~~\n" +"# offset_mean(data, target_mean_value):\n" +"# return a new array containing the original data with its mean offset to match the desired value.\n" +"def offset_mean(data, target_mean_value):\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:340 +msgid "There's a better way, though.\n" +"If the first thing in a function is a string that isn't assigned to a variable,\n" +"that string is attached to the function as its documentation:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:344 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value):\n" +" \"\"\"Return a new array containing the original data\n" +" with its mean offset to match the desired value.\"\"\"\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:352 +msgid "This is better because we can now ask Python's built-in help system to show us\n" +"the documentation for the function:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:355 +# code block +msgid "~~~\n" +"help(offset_mean)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:360 +# code block +msgid "~~~\n" +"Help on function offset_mean in module __main__:\n" +"\n" +"offset_mean(data, target_mean_value)\n" +" Return a new array containing the original data with its mean offset to match the desired value.\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:368 +msgid "A string like this is called a [docstring]({{ page.root }}/reference.html#docstring).\n" +"We don't need to use triple quotes when we write one,\n" +"but if we do,\n" +"we can break the string across multiple lines:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:373 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value):\n" +" \"\"\"Return a new array containing the original data\n" +" with its mean offset to match the desired value.\n" +"\n" +" Examples\n" +" --------\n" +" >>> offset_mean([1, 2, 3], 0)\n" +" array([-1., 0., 1.])\n" +" \"\"\"\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"\n" +"help(offset_mean)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:389 +# code block +msgid "~~~\n" +"Help on function offset_mean in module __main__:\n" +"\n" +"offset_mean(data, target_mean_value)\n" +" Return a new array containing the original data\n" +" with its mean offset to match the desired value.\n" +"\n" +" Examples\n" +" --------\n" +" >>> offset_mean([1, 2, 3], 0)\n" +" array([-1., 0., 1.])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:403 +# header +msgid "## Defining Defaults" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:405 +msgid "We have passed parameters to functions in two ways:\n" +"directly, as in `type(data)`,\n" +"and by name, as in `numpy.loadtxt(fname='something.csv', delimiter=',')`.\n" +"In fact,\n" +"we can pass the filename to `loadtxt` without the `fname=`:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:411 +# code block +msgid "~~~\n" +"numpy.loadtxt('inflammation-01.csv', delimiter=',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:427 +msgid "but we still need to say `delimiter=`:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:429 +#: python-novice-inflammation/_episodes/08-func.md:591 +# code block +msgid "~~~\n" +"numpy.loadtxt('inflammation-01.csv', ',')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:434 +# code block +msgid "~~~\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"/Users/username/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py\", line 1041, in loa\n" +"dtxt\n" +" dtype = np.dtype(dtype)\n" +" File \"/Users/username/anaconda3/lib/python3.6/site-packages/numpy/core/_internal.py\", line 199, in\n" +"_commastring\n" +" newitem = (dtype, eval(repeats))\n" +" File \"\", line 1\n" +" ,\n" +" ^\n" +"SyntaxError: unexpected EOF while parsing\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:450 +msgid "To understand what's going on,\n" +"and make our own functions easier to use,\n" +"let's re-define our `offset_mean` function like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:454 +# code block +msgid "~~~\n" +"def offset_mean(data, target_mean_value=0.0):\n" +" \"\"\"Return a new array containing the original data\n" +" with its mean offset to match the desired value, (0 by default).\n" +"\n" +" Examples\n" +" --------\n" +" >>> offset_mean([1, 2, 3])\n" +" array([-1., 0., 1.])\n" +" \"\"\"\n" +" return (data - numpy.mean(data)) + target_mean_value\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:468 +msgid "The key change is that the second parameter is now written `target_mean_value=0.0`\n" +"instead of just `target_mean_value`.\n" +"If we call the function with two arguments,\n" +"it works as it did before:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:473 +# code block +msgid "~~~\n" +"test_data = numpy.zeros((2, 2))\n" +"print(offset_mean(test_data, 3))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:485 +msgid "But we can also now call it with just one parameter,\n" +"in which case `target_mean_value` is automatically assigned\n" +"the [default value]({{ page.root }}/reference.html#default-value) of 0.0:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:489 +# code block +msgid "~~~\n" +"more_data = 5 + numpy.zeros((2, 2))\n" +"print('data before mean offset:')\n" +"print(more_data)\n" +"print('offset data:')\n" +"print(offset_mean(more_data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:498 +# code block +msgid "~~~\n" +"data before mean offset:\n" +"[[ 5. 5.]\n" +" [ 5. 5.]]\n" +"offset data:\n" +"[[ 0. 0.]\n" +" [ 0. 0.]]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:508 +msgid "This is handy:\n" +"if we usually want a function to work one way,\n" +"but occasionally need it to do something else,\n" +"we can allow people to pass a parameter when they need to\n" +"but provide a default to make the normal case easier.\n" +"The example below shows how Python matches values to parameters:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:515 +# code block +msgid "~~~\n" +"def display(a=1, b=2, c=3):\n" +" print('a:', a, 'b:', b, 'c:', c)\n" +"\n" +"print('no parameters:')\n" +"display()\n" +"print('one parameter:')\n" +"display(55)\n" +"print('two parameters:')\n" +"display(55, 66)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:528 +# code block +msgid "~~~\n" +"no parameters:\n" +"a: 1 b: 2 c: 3\n" +"one parameter:\n" +"a: 55 b: 2 c: 3\n" +"two parameters:\n" +"a: 55 b: 66 c: 3\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:538 +msgid "As this example shows,\n" +"parameters are matched up from left to right,\n" +"and any that haven't been given a value explicitly get their default value.\n" +"We can override this behavior by naming the value as we pass it in:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:543 +# code block +msgid "~~~\n" +"print('only setting the value of c')\n" +"display(c=77)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:549 +# code block +msgid "~~~\n" +"only setting the value of c\n" +"a: 1 b: 2 c: 77\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:555 +msgid "With that in hand,\n" +"let's look at the help for `numpy.loadtxt`:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:558 +# code block +msgid "~~~\n" +"help(numpy.loadtxt)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:563 +# code block +msgid "~~~\n" +"Help on function loadtxt in module numpy.lib.npyio:\n" +"\n" +"loadtxt(fname, dtype=, comments='#', delimiter=None, converters=None, skiprows=0, use\n" +"cols=None, unpack=False, ndmin=0, encoding='bytes')\n" +" Load data from a text file.\n" +"\n" +" Each row in the text file must have the same number of values.\n" +"\n" +" Parameters\n" +" ----------\n" +"...\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:578 +msgid "There's a lot of information here,\n" +"but the most important part is the first couple of lines:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:581 +# code block +msgid "~~~\n" +"loadtxt(fname, dtype=, comments='#', delimiter=None, converters=None, skiprows=0, use\n" +"cols=None, unpack=False, ndmin=0, encoding='bytes')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:587 +msgid "This tells us that `loadtxt` has one parameter called `fname` that doesn't have a default value,\n" +"and eight others that do.\n" +"If we call the function like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:596 +msgid "then the filename is assigned to `fname` (which is what we want),\n" +"but the delimiter string `','` is assigned to `dtype` rather than `delimiter`,\n" +"because `dtype` is the second parameter in the list. However `','` isn't a known `dtype` so\n" +"our code produced an error message when we tried to run it.\n" +"When we call `loadtxt` we don't have to provide `fname=` for the filename because it's the\n" +"first item in the list, but if we want the `','` to be assigned to the variable `delimiter`,\n" +"we *do* have to provide `delimiter=` for the second parameter since `delimiter` is not\n" +"the second parameter in the list." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:605 +# header +msgid "## Readable functions" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:607 +msgid "Consider these two functions:" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:609 +# code block +msgid "~~~\n" +"def s(p):\n" +" a = 0\n" +" for v in p:\n" +" a += v\n" +" m = a / len(p)\n" +" d = 0\n" +" for v in p:\n" +" d += (v - m) * (v - m)\n" +" return numpy.sqrt(d / (len(p) - 1))\n" +"\n" +"def std_dev(sample):\n" +" sample_sum = 0\n" +" for value in sample:\n" +" sample_sum += value\n" +"\n" +" sample_mean = sample_sum / len(sample)\n" +"\n" +" sum_squared_devs = 0\n" +" for value in sample:\n" +" sum_squared_devs += (value - sample_mean) * (value - sample_mean)\n" +"\n" +" return numpy.sqrt(sum_squared_devs / (len(sample) - 1))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:635 +msgid "The functions `s` and `std_dev` are computationally equivalent (they\n" +"both calculate the sample standard deviation), but to a human reader,\n" +"they look very different. You probably found `std_dev` much easier to\n" +"read and understand than `s`." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:640 +msgid "As this example illustrates, both documentation and a programmer's\n" +"_coding style_ combine to determine how easy it is for others to read\n" +"and understand the programmer's code. Choosing meaningful variable\n" +"names and using blank spaces to break the code into logical \"chunks\"\n" +"are helpful techniques for producing _readable code_. This is useful\n" +"not only for sharing code with others, but also for the original\n" +"programmer. If you need to revisit code that you wrote months ago and\n" +"haven't thought about since then, you will appreciate the value of\n" +"readable code!" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:650 +# blockquote, which can be cascaded +msgid "> ## Combining Strings" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:651 +msgid ">\n" +"> \"Adding\" two strings produces their concatenation:\n" +"> `'a' + 'b'` is `'ab'`.\n" +"> Write a function called `fence` that takes two parameters called `original` and `wrapper`\n" +"> and returns a new string that has the wrapper character at the beginning and end of the original.\n" +"> A call to your function should look like this:\n" +">\n" +"> ~~~\n" +"> print(fence('name', '*'))\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> *name*\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:667 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def fence(original, wrapper):\n" +"> > return wrapper + original + wrapper\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:677 +# blockquote, which can be cascaded +msgid "> ## Return versus print" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:678 +msgid ">\n" +"> Note that `return` and `print` are not interchangeable.\n" +"> `print` is a Python function that *prints* data to the screen.\n" +"> It enables us, *users*, see the data.\n" +"> `return` statement, on the other hand, makes data visible to the program.\n" +"> Let's have a look at the following function:\n" +">\n" +"> ~~~\n" +"> def add(a, b):\n" +"> print(a + b)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> **Question**: What will we see if we execute the following commands?\n" +"> ~~~\n" +"> A = add(7, 3)\n" +"> print(A)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > Python will first execute the function `add` with `a = 7` and `b = 3`,\n" +"> > and, therefore, print `10`. However, because function `add` does not have a\n" +"> > line that starts with `return` (no `return` \"statement\"), it will, by default, return\n" +"> > nothing which, in Python world, is called `None`. Therefore, `A` will be assigned to `None`\n" +"> > and the last line (`print(A)`) will print `None`. As a result, we will see:\n" +"> > ~~~\n" +"> > 10\n" +"> > None\n" +"> > ~~~\n" +"> > {: .output}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:712 +# blockquote, which can be cascaded +msgid "> ## Selecting Characters From Strings" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:713 +msgid ">\n" +"> If the variable `s` refers to a string,\n" +"> then `s[0]` is the string's first character\n" +"> and `s[-1]` is its last.\n" +"> Write a function called `outer`\n" +"> that returns a string made up of just the first and last characters of its input.\n" +"> A call to your function should look like this:\n" +">\n" +"> ~~~\n" +"> print(outer('helium'))\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> hm\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:730 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def outer(input_string):\n" +"> > return input_string[0] + input_string[-1]\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:740 +# blockquote, which can be cascaded +msgid "> ## Rescaling an Array" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:741 +msgid ">\n" +"> Write a function `rescale` that takes an array as input\n" +"> and returns a corresponding array of values scaled to lie in the range 0.0 to 1.0.\n" +"> (Hint: If `L` and `H` are the lowest and highest values in the original array,\n" +"> then the replacement for a value `v` should be `(v-L) / (H-L)`.)\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def rescale(input_array):\n" +"> > L = numpy.min(input_array)\n" +"> > H = numpy.max(input_array)\n" +"> > output_array = (input_array - L) / (H - L)\n" +"> > return output_array\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:759 +# blockquote, which can be cascaded +msgid "> ## Testing and Documenting Your Function" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:760 +msgid ">\n" +"> Run the commands `help(numpy.arange)` and `help(numpy.linspace)`\n" +"> to see how to use these functions to generate regularly-spaced values,\n" +"> then use those values to test your `rescale` function.\n" +"> Once you've successfully tested your function,\n" +"> add a docstring that explains what it does.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > \"\"\"Takes an array as input, and returns a corresponding array scaled so\n" +"> > that 0 corresponds to the minimum and 1 to the maximum value of the input array.\n" +"> >\n" +"> > Examples:\n" +"> > >>> rescale(numpy.arange(10.0))\n" +"> > array([ 0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444,\n" +"> > 0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ])\n" +"> > >>> rescale(numpy.linspace(0, 100, 5))\n" +"> > array([ 0. , 0.25, 0.5 , 0.75, 1. ])\n" +"> > \"\"\"\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:784 +# blockquote, which can be cascaded +msgid "> ## Defining Defaults" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:785 +msgid ">\n" +"> Rewrite the `rescale` function so that it scales data to lie between `0.0` and `1.0` by default,\n" +"> but will allow the caller to specify lower and upper bounds if they want.\n" +"> Compare your implementation to your neighbor's:\n" +"> do the two functions always behave the same way?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def rescale(input_array, low_val=0.0, high_val=1.0):\n" +"> > \"\"\"rescales input array values to lie between low_val and high_val\"\"\"\n" +"> > L = numpy.min(input_array)\n" +"> > H = numpy.max(input_array)\n" +"> > intermed_array = (input_array - L) / (H - L)\n" +"> > output_array = intermed_array * (high_val - low_val) + low_val\n" +"> > return output_array\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:805 +# blockquote, which can be cascaded +msgid "> ## Variables Inside and Outside Functions" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:806 +msgid ">\n" +"> What does the following piece of code display when run --- and why?\n" +">\n" +"> ~~~\n" +"> f = 0\n" +"> k = 0\n" +">\n" +"> def f2k(f):\n" +"> k = ((f - 32) * (5.0 / 9.0)) + 273.15\n" +"> return k\n" +">\n" +"> print(f2k(8))\n" +"> print(f2k(41))\n" +"> print(f2k(32))\n" +">\n" +"> print(k)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> >\n" +"> > ~~~\n" +"> > 259.81666666666666\n" +"> > 278.15\n" +"> > 273.15\n" +"> > 0\n" +"> > ~~~\n" +"> > {: .output}\n" +"> > `k` is 0 because the `k` inside the function `f2k` doesn't know\n" +"> > about the `k` defined outside the function." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:839 +# blockquote, which can be cascaded +msgid "> ## Mixing Default and Non-Default Parameters" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:840 +msgid ">\n" +"> Given the following code:\n" +">\n" +"> ~~~\n" +"> def numbers(one, two=2, three, four=4):\n" +"> n = str(one) + str(two) + str(three) + str(four)\n" +"> return n\n" +">\n" +"> print(numbers(1, three=3))\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> what do you expect will be printed? What is actually printed?\n" +"> What rule do you think Python is following?\n" +">\n" +"> 1. `1234`\n" +"> 2. `one2three4`\n" +"> 3. `1239`\n" +"> 4. `SyntaxError`\n" +">\n" +"> Given that, what does the following piece of code display when run?\n" +">\n" +"> ~~~\n" +"> def func(a, b=3, c=6):\n" +"> print('a: ', a, 'b: ', b, 'c:', c)\n" +">\n" +"> func(-1, 2)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> 1. `a: b: 3 c: 6`\n" +"> 2. `a: -1 b: 3 c: 6`\n" +"> 3. `a: -1 b: 2 c: 6`\n" +"> 4. `a: b: -1 c: 2`\n" +">\n" +"> > ## Solution\n" +"> > Attempting to define the `numbers` function results in `4. SyntaxError`.\n" +"> > The defined parameters `two` and `four` are given default values. Because\n" +"> > `one` and `three` are not given default values, they are required to be\n" +"> > included as arguments when the function is called and must be placed\n" +"> > before any parameters that have default values in the function definition.\n" +"> >\n" +"> > The given call to `func` displays `a: -1 b: 2 c: 6`. -1 is assigned to\n" +"> > the first parameter `a`, 2 is assigned to the next parameter `b`, and `c` is\n" +"> > not passed a value, so it uses its default value 6." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:888 +# blockquote, which can be cascaded +msgid "> ## The Old Switcheroo" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:889 +msgid ">\n" +"> Consider this code:\n" +">\n" +"> ~~~\n" +"> a = 3\n" +"> b = 7\n" +">\n" +"> def swap(a, b):\n" +"> temp = a\n" +"> a = b\n" +"> b = temp\n" +">\n" +"> swap(a, b)\n" +">\n" +"> print(a, b)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Which of the following would be printed if you were to run this code?\n" +"> Why did you pick this answer?\n" +">\n" +"> 1. `7 3`\n" +"> 2. `3 7`\n" +"> 3. `3 3`\n" +"> 4. `7 7`\n" +">\n" +"> > ## Solution\n" +"> > `3 7` is the correct answer. Initially, `a` has a value of 3 and `b` has a value of 7.\n" +"> > When the `swap` function is called, it creates local variables (also called\n" +"> > `a` and `b` in this case) and trades their values. The function does not\n" +"> > return any values and does not alter `a` or `b` outside of its local copy.\n" +"> > Therefore the original values of `a` and `b` remain unchanged." +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:924 +# blockquote, which can be cascaded +msgid "> ## Readable Code" +msgstr "" + +#: python-novice-inflammation/_episodes/08-func.md:925 +msgid ">\n" +"> Revise a function you wrote for one of the previous exercises to try to make\n" +"> the code more readable. Then, collaborate with one of your neighbors\n" +"> to critique each other's functions and discuss how your function implementations\n" +"> could be further improved to make them more readable." +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/12__09-errors.md.ja.po b/transifex/python-novice-inflammation/po/12__09-errors.md.ja.po new file mode 100644 index 00000000..f00f3ace --- /dev/null +++ b/transifex/python-novice-inflammation/po/12__09-errors.md.ja.po @@ -0,0 +1,762 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/09-errors.md:1 +# Front Matter +msgid "---\n" +"title: Errors and Exceptions\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How does Python report errors?\"\n" +"- \"How can I handle errors in Python programs?\"\n" +"objectives:\n" +"- \"To be able to read a traceback, and determine where the error took place and what type it is.\"\n" +"- \"To be able to describe the types of situations in which syntax errors,\n" +" indentation errors, name errors, index errors, and missing file errors occur.\"\n" +"keypoints:\n" +"- \"Tracebacks can look intimidating, but they give us a lot of useful information about\n" +" what went wrong in our program, including where the error occurred and\n" +" what type of error it was.\"\n" +"- \"An error having to do with the 'grammar' or syntax of the program is called a `SyntaxError`.\n" +" If the issue has to do with how the code is indented,\n" +" then it will be called an `IndentationError`.\"\n" +"- \"A `NameError` will occur when trying to use a variable that does not exist. Possible causes are\n" +" that a variable definition is missing, a variable reference differs from its definition\n" +" in spelling or capitalization, or the code contains a string that is missing quotes around it.\"\n" +"- \"Containers like lists and strings will generate errors if you try to access items\n" +" in them that do not exist. This type of error is called an `IndexError`.\"\n" +"- \"Trying to read a file that does not exist will give you an `FileNotFoundError`.\n" +" Trying to read a file that is open for writing, or writing to a file that is open for reading,\n" +" will give you an `IOError`.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:29 +msgid "Every programmer encounters errors,\n" +"both those who are just beginning,\n" +"and those who have been programming for years.\n" +"Encountering errors and exceptions can be very frustrating at times,\n" +"and can make coding feel like a hopeless endeavour.\n" +"However,\n" +"understanding what the different types of errors are\n" +"and when you are likely to encounter them can help a lot.\n" +"Once you know *why* you get certain types of errors,\n" +"they become much easier to fix." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:40 +msgid "Errors in Python have a very specific form,\n" +"called a [traceback]({{ page.root }}/reference.html#traceback).\n" +"Let's examine one:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:44 +# code block +msgid "~~~\n" +"# This code has an intentional error. You can type it directly or\n" +"# use it for reference to understand the error message below.\n" +"def favorite_ice_cream():\n" +" ice_creams = [\n" +" 'chocolate',\n" +" 'vanilla',\n" +" 'strawberry'\n" +" ]\n" +" print(ice_creams[3])\n" +"\n" +"favorite_ice_cream()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:59 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"IndexError Traceback (most recent call last)\n" +" in ()\n" +" 9 print(ice_creams[3])\n" +" 10\n" +"----> 11 favorite_ice_cream()\n" +"\n" +" in favorite_ice_cream()\n" +" 7 'strawberry'\n" +" 8 ]\n" +"----> 9 print(ice_creams[3])\n" +" 10\n" +" 11 favorite_ice_cream()\n" +"\n" +"IndexError: list index out of range\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:78 +msgid "This particular traceback has two levels.\n" +"You can determine the number of levels by looking for the number of arrows on the left hand side.\n" +"In this case:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:82 +# ordered list +msgid "1. The first shows code from the cell above," +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:83 +msgid " with an arrow pointing to Line 11 (which is `favorite_ice_cream()`)." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:85 +# ordered list +msgid "2. The second shows some code in the function `favorite_ice_cream`," +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:86 +msgid " with an arrow pointing to Line 9 (which is `print(ice_creams[3])`)." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:88 +msgid "The last level is the actual place where the error occurred.\n" +"The other level(s) show what function the program executed to get to the next level down.\n" +"So, in this case, the program first performed a\n" +"[function call]({{ page.root }}/reference.html#function-call) to the function `favorite_ice_cream`.\n" +"Inside this function,\n" +"the program encountered an error on Line 6, when it tried to run the code `print(ice_creams[3])`." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:95 +# blockquote, which can be cascaded +msgid "> ## Long Tracebacks" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:96 +msgid ">\n" +"> Sometimes, you might see a traceback that is very long\n" +"> -- sometimes they might even be 20 levels deep!\n" +"> This can make it seem like something horrible happened,\n" +"> but the length of the error message does not reflect severity, rather,\n" +"> it indicates that your program called many functions before it encountered the error.\n" +"> Most of the time, the actual place where the error occurred is at the bottom-most level,\n" +"> so you can skip down the traceback to the bottom." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:106 +msgid "So what error did the program actually encounter?\n" +"In the last line of the traceback,\n" +"Python helpfully tells us the category or type of error (in this case, it is an `IndexError`)\n" +"and a more detailed error message (in this case, it says \"list index out of range\")." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:111 +msgid "If you encounter an error and don't know what it means,\n" +"it is still important to read the traceback closely.\n" +"That way,\n" +"if you fix the error,\n" +"but encounter a new one,\n" +"you can tell that the error changed.\n" +"Additionally,\n" +"sometimes knowing *where* the error occurred is enough to fix it,\n" +"even if you don't entirely understand the message." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:121 +msgid "If you do encounter an error you don't recognize,\n" +"try looking at the\n" +"[official documentation on errors](http://docs.python.org/3/library/exceptions.html).\n" +"However,\n" +"note that you may not always be able to find the error there,\n" +"as it is possible to create custom errors.\n" +"In that case,\n" +"hopefully the custom error message is informative enough to help you figure out what went wrong." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:130 +# header +msgid "## Syntax Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:132 +msgid "When you forget a colon at the end of a line,\n" +"accidentally add one space too many when indenting under an `if` statement,\n" +"or forget a parenthesis,\n" +"you will encounter a [syntax error]({{ page.root }}/reference.html#syntax-error).\n" +"This means that Python couldn't figure out how to read your program.\n" +"This is similar to forgetting punctuation in English:\n" +"for example,\n" +"this text is difficult to read there is no punctuation there is also no capitalization\n" +"why is this hard because you have to figure out where each sentence ends\n" +"you also have to figure out where each sentence begins\n" +"to some extent it might be ambiguous if there should be a sentence break or not" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:144 +msgid "People can typically figure out what is meant by text with no punctuation,\n" +"but people are much smarter than computers.\n" +"If Python doesn't know how to read the program,\n" +"it will give up and inform you with an error.\n" +"For example:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:150 +# code block +msgid "~~~\n" +"def some_function()\n" +" msg = 'hello, world!'\n" +" print(msg)\n" +" return msg\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:158 +# code block +msgid "~~~\n" +" File \"\", line 1\n" +" def some_function()\n" +" ^\n" +"SyntaxError: invalid syntax\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:166 +msgid "Here, Python tells us that there is a `SyntaxError` on line 1,\n" +"and even puts a little arrow in the place where there is an issue.\n" +"In this case the problem is that the function definition is missing a colon at the end." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:170 +msgid "Actually, the function above has *two* issues with syntax.\n" +"If we fix the problem with the colon,\n" +"we see that there is *also* an `IndentationError`,\n" +"which means that the lines in the function definition do not all have the same indentation:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:175 +# code block +msgid "~~~\n" +"def some_function():\n" +" msg = 'hello, world!'\n" +" print(msg)\n" +" return msg\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:183 +# code block +msgid "~~~\n" +" File \"\", line 4\n" +" return msg\n" +" ^\n" +"IndentationError: unexpected indent\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:191 +msgid "Both `SyntaxError` and `IndentationError` indicate a problem with the syntax of your program,\n" +"but an `IndentationError` is more specific:\n" +"it *always* means that there is a problem with how your code is indented." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:195 +# blockquote, which can be cascaded +msgid "> ## Tabs and Spaces" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:196 +msgid ">\n" +"> Some indentation errors are harder to spot than others.\n" +"> In particular, mixing spaces and tabs can be difficult to spot\n" +"> because they are both [whitespace]({{ page.root }}/reference.html#whitespace).\n" +"> In the example below, the first two lines in the body of the function\n" +"> `some_function` are indented with tabs, while the third line — with spaces.\n" +"> If you're working in a Jupyter notebook, be sure to copy and paste this example\n" +"> rather than trying to type it in manually because Jupyter automatically replaces\n" +"> tabs with spaces.\n" +">\n" +"> ~~~\n" +"> def some_function():\n" +"> msg = 'hello, world!'\n" +"> print(msg)\n" +"> return msg\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Visually it is impossible to spot the error.\n" +"> Fortunately, Python does not allow you to mix tabs and spaces.\n" +">\n" +"> ~~~\n" +"> File \"\", line 4\n" +"> return msg\n" +"> ^\n" +"> TabError: inconsistent use of tabs and spaces in indentation\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:223 +#: python-novice-inflammation/_episodes/09-errors.md:491 +# SC/DC Template label +msgid "> {: .error}" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:226 +# header +msgid "## Variable Name Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:228 +msgid "Another very common type of error is called a `NameError`,\n" +"and occurs when you try to use a variable that does not exist.\n" +"For example:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:232 +# code block +msgid "~~~\n" +"print(a)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:237 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 print(a)\n" +"\n" +"NameError: name 'a' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:247 +msgid "Variable name errors come with some of the most informative error messages,\n" +"which are usually of the form \"name 'the_variable_name' is not defined\"." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:250 +msgid "Why does this error message occur?\n" +"That's a harder question to answer,\n" +"because it depends on what your code is supposed to do.\n" +"However,\n" +"there are a few very common reasons why you might have an undefined variable.\n" +"The first is that you meant to use a\n" +"[string]({{ page.root }}/reference.html#string), but forgot to put quotes around it:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:258 +# code block +msgid "~~~\n" +"print(hello)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:263 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 print(hello)\n" +"\n" +"NameError: name 'hello' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:273 +msgid "The second reason is that you might be trying to use a variable that does not yet exist.\n" +"In the following example,\n" +"`count` should have been defined (e.g., with `count = 0`) before the for loop:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:277 +# code block +msgid "~~~\n" +"for number in range(10):\n" +" count = count + number\n" +"print('The count is:', count)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:284 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +" 1 for number in range(10):\n" +"----> 2 count = count + number\n" +" 3 print('The count is:', count)\n" +"\n" +"NameError: name 'count' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:296 +msgid "Finally, the third possibility is that you made a typo when you were writing your code.\n" +"Let's say we fixed the error above by adding the line `Count = 0` before the for loop.\n" +"Frustratingly, this actually does not fix the error.\n" +"Remember that variables are [case-sensitive]({{ page.root }}/reference.html#case-sensitive),\n" +"so the variable `count` is different from `Count`. We still get the same error,\n" +"because we still have not defined `count`:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:303 +# code block +msgid "~~~\n" +"Count = 0\n" +"for number in range(10):\n" +" count = count + number\n" +"print('The count is:', count)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:311 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +" 1 Count = 0\n" +" 2 for number in range(10):\n" +"----> 3 count = count + number\n" +" 4 print('The count is:', count)\n" +"\n" +"NameError: name 'count' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:324 +# header +msgid "## Index Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:326 +msgid "Next up are errors having to do with containers (like lists and strings) and the items within them.\n" +"If you try to access an item in a list or a string that does not exist,\n" +"then you will get an error.\n" +"This makes sense:\n" +"if you asked someone what day they would like to get coffee,\n" +"and they answered \"caturday\",\n" +"you might be a bit annoyed.\n" +"Python gets similarly annoyed if you try to ask it for an item that doesn't exist:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:335 +# code block +msgid "~~~\n" +"letters = ['a', 'b', 'c']\n" +"print('Letter #1 is', letters[0])\n" +"print('Letter #2 is', letters[1])\n" +"print('Letter #3 is', letters[2])\n" +"print('Letter #4 is', letters[3])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:344 +# code block +msgid "~~~\n" +"Letter #1 is a\n" +"Letter #2 is b\n" +"Letter #3 is c\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:351 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"IndexError Traceback (most recent call last)\n" +" in ()\n" +" 3 print('Letter #2 is', letters[1])\n" +" 4 print('Letter #3 is', letters[2])\n" +"----> 5 print('Letter #4 is', letters[3])\n" +"\n" +"IndexError: list index out of range\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:363 +msgid "Here,\n" +"Python is telling us that there is an `IndexError` in our code,\n" +"meaning we tried to access a list index that did not exist." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:367 +# header +msgid "## File Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:369 +msgid "The last type of error we'll cover today\n" +"are those associated with reading and writing files: `FileNotFoundError`.\n" +"If you try to read a file that does not exist,\n" +"you will receive a `FileNotFoundError` telling you so.\n" +"If you attempt to write to a file that was opened read-only, Python 3\n" +"returns an `UnsupportedOperationError`.\n" +"More generally, problems with input and output manifest as\n" +"`IOError`s or `OSError`s, depending on the version of Python you use." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:378 +# code block +msgid "~~~\n" +"file_handle = open('myfile.txt', 'r')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:383 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"FileNotFoundError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 file_handle = open('myfile.txt', 'r')\n" +"\n" +"FileNotFoundError: [Errno 2] No such file or directory: 'myfile.txt'\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:393 +msgid "One reason for receiving this error is that you specified an incorrect path to the file.\n" +"For example,\n" +"if I am currently in a folder called `myproject`,\n" +"and I have a file in `myproject/writing/myfile.txt`,\n" +"but I try to open `myfile.txt`,\n" +"this will fail.\n" +"The correct path would be `writing/myfile.txt`.\n" +"It is also possible that the file name or its path contains a typo." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:402 +msgid "A related issue can occur if you use the \"read\" flag instead of the \"write\" flag.\n" +"Python will not give you an error if you try to open a file for writing\n" +"when the file does not exist.\n" +"However,\n" +"if you meant to open a file for reading,\n" +"but accidentally opened it for writing,\n" +"and then try to read from it,\n" +"you will get an `UnsupportedOperation` error\n" +"telling you that the file was not opened for reading:" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:412 +# code block +msgid "~~~\n" +"file_handle = open('myfile.txt', 'w')\n" +"file_handle.read()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:418 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"UnsupportedOperation Traceback (most recent call last)\n" +" in ()\n" +" 1 file_handle = open('myfile.txt', 'w')\n" +"----> 2 file_handle.read()\n" +"\n" +"UnsupportedOperation: not readable\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:429 +msgid "These are the most common errors with files,\n" +"though many others exist.\n" +"If you get an error that you've never seen before,\n" +"searching the Internet for that error type\n" +"often reveals common reasons why you might get that error." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:435 +# blockquote, which can be cascaded +msgid "> ## Reading Error Messages" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:436 +msgid ">\n" +"> Read the Python code and the resulting traceback below, and answer the following questions:\n" +">\n" +"> 1. How many levels does the traceback have?\n" +"> 2. What is the function name where the error occurred?\n" +"> 3. On which line number in this function did the error occur?\n" +"> 4. What is the type of error?\n" +"> 5. What is the error message?\n" +">\n" +"> ~~~\n" +"> # This code has an intentional error. Do not type it directly;\n" +"> # use it for reference to understand the error message below.\n" +"> def print_message(day):\n" +"> messages = {\n" +"> 'monday': 'Hello, world!',\n" +"> 'tuesday': 'Today is Tuesday!',\n" +"> 'wednesday': 'It is the middle of the week.',\n" +"> 'thursday': 'Today is Donnerstag in German!',\n" +"> 'friday': 'Last day of the week!',\n" +"> 'saturday': 'Hooray for the weekend!',\n" +"> 'sunday': 'Aw, the weekend is almost over.'\n" +"> }\n" +"> print(messages[day])\n" +">\n" +"> def print_friday_message():\n" +"> print_message('Friday')\n" +">\n" +"> print_friday_message()\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> ---------------------------------------------------------------------------\n" +"> KeyError Traceback (most recent call last)\n" +"> in ()\n" +"> 14 print_message('Friday')\n" +"> 15\n" +"> ---> 16 print_friday_message()\n" +">\n" +"> in print_friday_message()\n" +"> 12\n" +"> 13 def print_friday_message():\n" +"> ---> 14 print_message('Friday')\n" +"> 15\n" +"> 16 print_friday_message()\n" +">\n" +"> in print_message(day)\n" +"> 9 'sunday': 'Aw, the weekend is almost over.'\n" +"> 10 }\n" +"> ---> 11 print(messages[day])\n" +"> 12\n" +"> 13 def print_friday_message():\n" +">\n" +"> KeyError: 'Friday'\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:492 +msgid ">\n" +"> > ## Solution\n" +"> > 1. 3 levels\n" +"> > 2. `print_message`\n" +"> > 3. 11\n" +"> > 4. `KeyError`\n" +"> > 5. There isn't really a message; you're supposed to infer that `Friday` is not a key in `messages`." +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:502 +# blockquote, which can be cascaded +msgid "> ## Identifying Syntax Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:503 +msgid ">\n" +"> 1. Read the code below, and (without running it) try to identify what the errors are.\n" +"> 2. Run the code, and read the error message. Is it a `SyntaxError` or an `IndentationError`?\n" +"> 3. Fix the error.\n" +"> 4. Repeat steps 2 and 3, until you have fixed all the errors.\n" +">\n" +"> ~~~\n" +"> def another_function\n" +"> print('Syntax errors are annoying.')\n" +"> print('But at least Python tells us about them!')\n" +"> print('So they are usually not too hard to fix.')\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > `SyntaxError` for missing `():` at end of first line,\n" +"> `IndentationError` for mismatch between second and third lines.\n" +"> > A fixed version is:\n" +"> >\n" +"> > ~~~\n" +"> > def another_function():\n" +"> > print('Syntax errors are annoying.')\n" +"> > print('But at least Python tells us about them!')\n" +"> > print('So they are usually not too hard to fix.')\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:532 +# blockquote, which can be cascaded +msgid "> ## Identifying Variable Name Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:533 +msgid ">\n" +"> 1. Read the code below, and (without running it) try to identify what the errors are.\n" +"> 2. Run the code, and read the error message.\n" +"> What type of `NameError` do you think this is?\n" +"> In other words, is it a string with no quotes,\n" +"> a misspelled variable,\n" +"> or a variable that should have been defined but was not?\n" +"> 3. Fix the error.\n" +"> 4. Repeat steps 2 and 3, until you have fixed all the errors.\n" +">\n" +"> ~~~\n" +"> for number in range(10):\n" +"> # use a if the number is a multiple of 3, otherwise use b\n" +"> if (Number % 3) == 0:\n" +"> message = message + a\n" +"> else:\n" +"> message = message + 'b'\n" +"> print(message)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > 3 `NameError`s for `number` being misspelled, for `message` not defined,\n" +"> > and for `a` not being in quotes.\n" +"> >\n" +"> > Fixed version:\n" +"> >\n" +"> > ~~~\n" +"> > message = ''\n" +"> > for number in range(10):\n" +"> > # use a if the number is a multiple of 3, otherwise use b\n" +"> > if (number % 3) == 0:\n" +"> > message = message + 'a'\n" +"> > else:\n" +"> > message = message + 'b'\n" +"> > print(message)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:574 +# blockquote, which can be cascaded +msgid "> ## Identifying Index Errors" +msgstr "" + +#: python-novice-inflammation/_episodes/09-errors.md:575 +msgid ">\n" +"> 1. Read the code below, and (without running it) try to identify what the errors are.\n" +"> 2. Run the code, and read the error message. What type of error is it?\n" +"> 3. Fix the error.\n" +">\n" +"> ~~~\n" +"> seasons = ['Spring', 'Summer', 'Fall', 'Winter']\n" +"> print('My favorite season is ', seasons[4])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > `IndexError`; the last entry is `seasons[3]`, so `seasons[4]` doesn't make sense.\n" +"> > A fixed version is:\n" +"> >\n" +"> > ~~~\n" +"> > seasons = ['Spring', 'Summer', 'Fall', 'Winter']\n" +"> > print('My favorite season is ', seasons[-1])\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/13__10-defensive.md.ja.po b/transifex/python-novice-inflammation/po/13__10-defensive.md.ja.po new file mode 100644 index 00000000..d0f567e3 --- /dev/null +++ b/transifex/python-novice-inflammation/po/13__10-defensive.md.ja.po @@ -0,0 +1,747 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/10-defensive.md:1 +# Front Matter +msgid "---\n" +"title: Defensive Programming\n" +"teaching: 30\n" +"exercises: 10\n" +"questions:\n" +"- \"How can I make my programs more reliable?\"\n" +"objectives:\n" +"- \"Explain what an assertion is.\"\n" +"- \"Add assertions that check the program's state is correct.\"\n" +"- \"Correctly add precondition and postcondition assertions to functions.\"\n" +"- \"Explain what test-driven development is, and use it when creating new functions.\"\n" +"- \"Explain why variables should be initialized using actual data values\n" +" rather than arbitrary constants.\"\n" +"keypoints:\n" +"- \"Program defensively, i.e., assume that errors are going to arise,\n" +" and write code to detect them when they do.\"\n" +"- \"Put assertions in programs to check their state as they run,\n" +" and to help readers understand how those programs are supposed to work.\"\n" +"- \"Use preconditions to check that the inputs to a function are safe to use.\"\n" +"- \"Use postconditions to check that the output from a function is safe to use.\"\n" +"- \"Write tests before writing code in order to help determine exactly\n" +" what that code is supposed to do.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:25 +msgid "Our previous lessons have introduced the basic tools of programming:\n" +"variables and lists,\n" +"file I/O,\n" +"loops,\n" +"conditionals,\n" +"and functions.\n" +"What they *haven't* done is show us how to tell\n" +"whether a program is getting the right answer,\n" +"and how to tell if it's *still* getting the right answer\n" +"as we make changes to it." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:36 +msgid "To achieve that,\n" +"we need to:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:39 +# unordered list +msgid "* Write programs that check their own operation." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:40 +# unordered list +msgid "* Write and run tests for widely-used functions." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:41 +# unordered list +msgid "* Make sure we know what \"correct\" actually means." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:43 +msgid "The good news is,\n" +"doing these things will speed up our programming,\n" +"not slow it down.\n" +"As in real carpentry --- the kind done with lumber --- the time saved\n" +"by measuring carefully before cutting a piece of wood\n" +"is much greater than the time that measuring takes." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:50 +# header +msgid "## Assertions" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:52 +msgid "The first step toward getting the right answers from our programs\n" +"is to assume that mistakes *will* happen\n" +"and to guard against them.\n" +"This is called [defensive programming]({{ page.root }}/reference.html#defensive-programming),\n" +"and the most common way to do it is to add\n" +"[assertions]({{ page.root }}/reference.html#assertion) to our code\n" +"so that it checks itself as it runs.\n" +"An assertion is simply a statement that something must be true at a certain point in a program.\n" +"When Python sees one,\n" +"it evaluates the assertion's condition.\n" +"If it's true,\n" +"Python does nothing,\n" +"but if it's false,\n" +"Python halts the program immediately\n" +"and prints the error message if one is provided.\n" +"For example,\n" +"this piece of code halts as soon as the loop encounters a value that isn't positive:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:70 +# code block +msgid "~~~\n" +"numbers = [1.5, 2.3, 0.7, -0.001, 4.4]\n" +"total = 0.0\n" +"for num in numbers:\n" +" assert num > 0.0, 'Data should only contain positive values'\n" +" total += num\n" +"print('total is:', total)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:80 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +" 2 total = 0.0\n" +" 3 for num in numbers:\n" +"----> 4 assert num > 0.0, 'Data should only contain positive values'\n" +" 5 total += num\n" +" 6 print('total is:', total)\n" +"\n" +"AssertionError: Data should only contain positive values\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:94 +msgid "Programs like the Firefox browser are full of assertions:\n" +"10-20% of the code they contain\n" +"are there to check that the other 80–90% are working correctly.\n" +"Broadly speaking,\n" +"assertions fall into three categories:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:100 +# unordered list +msgid "* A [precondition]({{ page.root }}/reference.html#precondition)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:101 +msgid " is something that must be true at the start of a function in order for it to work correctly." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:103 +# unordered list +msgid "* A [postcondition]({{ page.root }}/reference.html#postcondition)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:104 +msgid " is something that the function guarantees is true when it finishes." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:106 +# unordered list +msgid "* An [invariant]({{ page.root }}/reference.html#invariant)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:107 +msgid " is something that is always true at a particular point inside a piece of code." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:109 +msgid "For example,\n" +"suppose we are representing rectangles using a [tuple]({{ page.root }}/reference.html#tuple)\n" +"of four coordinates `(x0, y0, x1, y1)`,\n" +"representing the lower left and upper right corners of the rectangle.\n" +"In order to do some calculations,\n" +"we need to normalize the rectangle so that the lower left corner is at the origin\n" +"and the longest side is 1.0 units long.\n" +"This function does that,\n" +"but checks that its input is correctly formatted and that its result makes sense:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:119 +# code block +msgid "~~~\n" +"def normalize_rectangle(rect):\n" +" \"\"\"Normalizes a rectangle so that it is at the origin and 1.0 units long on its longest axis.\n" +" Input should be of the format (x0, y0, x1, y1).\n" +" (x0, y0) and (x1, y1) define the lower left and upper right corners\n" +" of the rectangle, respectively.\"\"\"\n" +" assert len(rect) == 4, 'Rectangles must contain 4 coordinates'\n" +" x0, y0, x1, y1 = rect\n" +" assert x0 < x1, 'Invalid X coordinates'\n" +" assert y0 < y1, 'Invalid Y coordinates'\n" +"\n" +" dx = x1 - x0\n" +" dy = y1 - y0\n" +" if dx > dy:\n" +" scaled = float(dx) / dy\n" +" upper_x, upper_y = 1.0, scaled\n" +" else:\n" +" scaled = float(dx) / dy\n" +" upper_x, upper_y = scaled, 1.0\n" +"\n" +" assert 0 < upper_x <= 1.0, 'Calculated upper X coordinate invalid'\n" +" assert 0 < upper_y <= 1.0, 'Calculated upper Y coordinate invalid'\n" +"\n" +" return (0, 0, upper_x, upper_y)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:146 +msgid "The preconditions on lines 6, 8, and 9 catch invalid inputs:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:148 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (0.0, 1.0, 2.0) )) # missing the fourth coordinate\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:153 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in \n" +"----> 1 print(normalize_rectangle( (0.0, 1.0, 2.0) )) # missing the fourth coordinate\n" +"\n" +" in normalize_rectangle(rect)\n" +" 4 (x0, y0) and (x1, y1) define the lower left and upper right corners\n" +" 5 of the rectangle, respectively.\"\"\"\n" +"----> 6 assert len(rect) == 4, 'Rectangles must contain 4 coordinates'\n" +" 7 x0, y0, x1, y1 = rect\n" +" 8 assert x0 < x1, 'Invalid X coordinates'\n" +"\n" +"AssertionError: Rectangles must contain 4 coordinates\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:170 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (4.0, 2.0, 1.0, 5.0) )) # X axis inverted\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:175 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in \n" +"----> 1 print(normalize_rectangle( (4.0, 2.0, 1.0, 5.0) )) # X axis inverted\n" +"\n" +" in normalize_rectangle(rect)\n" +" 6 assert len(rect) == 4, 'Rectangles must contain 4 coordinates'\n" +" 7 x0, y0, x1, y1 = rect\n" +"----> 8 assert x0 < x1, 'Invalid X coordinates'\n" +" 9 assert y0 < y1, 'Invalid Y coordinates'\n" +" 10\n" +"\n" +"AssertionError: Invalid X coordinates\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:192 +msgid "The post-conditions on lines 20 and 21 help us catch bugs by telling us when our\n" +"calculations might have been incorrect.\n" +"For example,\n" +"if we normalize a rectangle that is taller than it is wide everything seems OK:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:197 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (0.0, 0.0, 1.0, 5.0) ))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:202 +# code block +msgid "~~~\n" +"(0, 0, 0.2, 1.0)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:207 +msgid "but if we normalize one that's wider than it is tall,\n" +"the assertion is triggered:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:210 +# code block +msgid "~~~\n" +"print(normalize_rectangle( (0.0, 0.0, 5.0, 1.0) ))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:215 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in \n" +"----> 1 print(normalize_rectangle( (0.0, 0.0, 5.0, 1.0) ))\n" +"\n" +" in normalize_rectangle(rect)\n" +" 19\n" +" 20 assert 0 < upper_x <= 1.0, 'Calculated upper X coordinate invalid'\n" +"---> 21 assert 0 < upper_y <= 1.0, 'Calculated upper Y coordinate invalid'\n" +" 22\n" +" 23 return (0, 0, upper_x, upper_y)\n" +"\n" +"AssertionError: Calculated upper Y coordinate invalid\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:232 +msgid "Re-reading our function,\n" +"we realize that line 14 should divide `dy` by `dx` rather than `dx` by `dy`.\n" +"In a Jupyter notebook, you can display line numbers by typing Ctrl+M\n" +"followed by L.\n" +"If we had left out the assertion at the end of the function,\n" +"we would have created and returned something that had the right shape as a valid answer,\n" +"but wasn't.\n" +"Detecting and debugging that would almost certainly have taken more time in the long run\n" +"than writing the assertion." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:242 +msgid "But assertions aren't just about catching errors:\n" +"they also help people understand programs.\n" +"Each assertion gives the person reading the program\n" +"a chance to check (consciously or otherwise)\n" +"that their understanding matches what the code is doing." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:248 +msgid "Most good programmers follow two rules when adding assertions to their code.\n" +"The first is, *fail early, fail often*.\n" +"The greater the distance between when and where an error occurs and when it's noticed,\n" +"the harder the error will be to debug,\n" +"so good code catches mistakes as early as possible." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:254 +msgid "The second rule is, *turn bugs into assertions or tests*.\n" +"Whenever you fix a bug, write an assertion that catches the mistake\n" +"should you make it again.\n" +"If you made a mistake in a piece of code,\n" +"the odds are good that you have made other mistakes nearby,\n" +"or will make the same mistake (or a related one)\n" +"the next time you change it.\n" +"Writing assertions to check that you haven't [regressed]({{ page.root }}/reference.html#regression)\n" +"(i.e., haven't re-introduced an old problem)\n" +"can save a lot of time in the long run,\n" +"and helps to warn people who are reading the code\n" +"(including your future self)\n" +"that this bit is tricky." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:268 +# header +msgid "## Test-Driven Development" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:270 +msgid "An assertion checks that something is true at a particular point in the program.\n" +"The next step is to check the overall behavior of a piece of code,\n" +"i.e.,\n" +"to make sure that it produces the right output when it's given a particular input.\n" +"For example,\n" +"suppose we need to find where two or more time series overlap.\n" +"The range of each time series is represented as a pair of numbers,\n" +"which are the time the interval started and ended.\n" +"The output is the largest range that they all include:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:280 +msgid "![Overlapping Ranges](../fig/python-overlapping-ranges.svg)" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:282 +msgid "Most novice programmers would solve this problem like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:284 +# ordered list +msgid "1. Write a function `range_overlap`." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:285 +# ordered list +msgid "2. Call it interactively on two or three different inputs." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:286 +# ordered list +msgid "3. If it produces the wrong answer, fix the function and re-run that test." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:288 +msgid "This clearly works --- after all, thousands of scientists are doing it right now --- but\n" +"there's a better way:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:291 +# ordered list +msgid "1. Write a short function for each test." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:292 +# ordered list +msgid "2. Write a `range_overlap` function that should pass those tests." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:293 +# ordered list +msgid "3. If `range_overlap` produces any wrong answers, fix it and re-run the test functions." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:295 +msgid "Writing the tests *before* writing the function they exercise\n" +"is called [test-driven development]({{ page.root }}/reference.html#test-driven-development) (TDD).\n" +"Its advocates believe it produces better code faster because:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:299 +# ordered list +msgid "1. If people write tests after writing the thing to be tested," +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:300 +msgid " they are subject to confirmation bias,\n" +" i.e.,\n" +" they subconsciously write tests to show that their code is correct,\n" +" rather than to find errors.\n" +"2. Writing tests helps programmers figure out what the function is actually supposed to do." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:306 +msgid "Here are three test functions for `range_overlap`:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:308 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +"assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +"assert range_overlap([ (0.0, 1.0), (0.0, 2.0), (-1.0, 1.0) ]) == (0.0, 1.0)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:315 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +" 2 assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +" 3 assert range_overlap([ (0.0, 1.0), (0.0, 2.0), (-1.0, 1.0) ]) == (0.0, 1.0)\n" +"\n" +"AssertionError:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:327 +msgid "The error is actually reassuring:\n" +"we haven't written `range_overlap` yet,\n" +"so if the tests passed,\n" +"it would be a sign that someone else had\n" +"and that we were accidentally using their function." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:333 +msgid "And as a bonus of writing these tests,\n" +"we've implicitly defined what our input and output look like:\n" +"we expect a list of pairs as input,\n" +"and produce a single pair as output." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:338 +msgid "Something important is missing, though.\n" +"We don't have any tests for the case where the ranges don't overlap at all:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:341 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == ???\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:346 +msgid "What should `range_overlap` do in this case:\n" +"fail with an error message,\n" +"produce a special value like `(0.0, 0.0)` to signal that there's no overlap,\n" +"or something else?\n" +"Any actual implementation of the function will do one of these things;\n" +"writing the tests first helps us figure out which is best\n" +"*before* we're emotionally invested in whatever we happened to write\n" +"before we realized there was an issue." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:355 +msgid "And what about this case?" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:357 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == ???\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:362 +msgid "Do two segments that touch at their endpoints overlap or not?\n" +"Mathematicians usually say \"yes\",\n" +"but engineers usually say \"no\".\n" +"The best answer is \"whatever is most useful in the rest of our program\",\n" +"but again,\n" +"any actual implementation of `range_overlap` is going to do *something*,\n" +"and whatever it is ought to be consistent with what it does when there's no overlap at all." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:370 +msgid "Since we're planning to use the range this function returns\n" +"as the X axis in a time series chart,\n" +"we decide that:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:374 +# ordered list +msgid "1. every overlap has to have non-zero width, and" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:375 +# ordered list +msgid "2. we will return the special value `None` when there's no overlap." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:377 +msgid "`None` is built into Python,\n" +"and means \"nothing here\".\n" +"(Other languages often call the equivalent value `null` or `nil`).\n" +"With that decision made,\n" +"we can finish writing our last two tests:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:383 +# code block +msgid "~~~\n" +"assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +"assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:389 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +" 2 assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +"\n" +"AssertionError:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:400 +msgid "Again,\n" +"we get an error because we haven't written our function,\n" +"but we're now ready to do so:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:404 +# code block +msgid "~~~\n" +"def range_overlap(ranges):\n" +" \"\"\"Return common overlap among a set of [left, right] ranges.\"\"\"\n" +" max_left = 0.0\n" +" min_right = 1.0\n" +" for (left, right) in ranges:\n" +" max_left = max(max_left, left)\n" +" min_right = min(min_right, right)\n" +" return (max_left, min_right)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:416 +msgid "Take a moment to think about why we calculate the left endpoint of the overlap as\n" +"the maximum of the input left endpoints, and the overlap right endpoint as the minimum\n" +"of the input right endpoints.\n" +"We'd now like to re-run our tests,\n" +"but they're scattered across three different cells.\n" +"To make running them easier,\n" +"let's put them all in a function:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:424 +# code block +msgid "~~~\n" +"def test_range_overlap():\n" +" assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +" assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +" assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +" assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +" assert range_overlap([ (0.0, 1.0), (0.0, 2.0), (-1.0, 1.0) ]) == (0.0, 1.0)\n" +" assert range_overlap([]) == None\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:435 +msgid "We can now test `range_overlap` with a single function call:" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:437 +# code block +msgid "~~~\n" +"test_range_overlap()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:442 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"AssertionError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 test_range_overlap()\n" +"\n" +" in test_range_overlap()\n" +" 1 def test_range_overlap():\n" +"----> 2 assert range_overlap([ (0.0, 1.0), (5.0, 6.0) ]) == None\n" +" 3 assert range_overlap([ (0.0, 1.0), (1.0, 2.0) ]) == None\n" +" 4 assert range_overlap([ (0.0, 1.0) ]) == (0.0, 1.0)\n" +" 5 assert range_overlap([ (2.0, 3.0), (2.0, 4.0) ]) == (2.0, 3.0)\n" +"\n" +"AssertionError:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:459 +msgid "The first test that was supposed to produce `None` fails,\n" +"so we know something is wrong with our function.\n" +"We *don't* know whether the other tests passed or failed\n" +"because Python halted the program as soon as it spotted the first error.\n" +"Still,\n" +"some information is better than none,\n" +"and if we trace the behavior of the function with that input,\n" +"we realize that we're initializing `max_left` and `min_right` to 0.0 and 1.0 respectively,\n" +"regardless of the input values.\n" +"This violates another important rule of programming:\n" +"*always initialize from data*." +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:471 +# blockquote, which can be cascaded +msgid "> ## Pre- and Post-Conditions" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:472 +msgid ">\n" +"> Suppose you are writing a function called `average` that calculates\n" +"> the average of the numbers in a list.\n" +"> What pre-conditions and post-conditions would you write for it?\n" +"> Compare your answer to your neighbor's:\n" +"> can you think of a function that will pass your tests but not his/hers or vice versa?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # a possible pre-condition:\n" +"> > assert len(input_list) > 0, 'List length must be non-zero'\n" +"> > # a possible post-condition:\n" +"> > assert numpy.min(input_list) <= average <= numpy.max(input_list),\n" +"> > 'Average should be between min and max of input values (inclusive)'\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:491 +# blockquote, which can be cascaded +msgid "> ## Testing Assertions" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:492 +msgid ">\n" +"> Given a sequence of a number of cars, the function `get_total_cars` returns\n" +"> the total number of cars.\n" +">\n" +"> ~~~\n" +"> get_total_cars([1, 2, 3, 4])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> 10\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:505 +msgid ">\n" +"> ~~~\n" +"> get_total_cars(['a', 'b', 'c'])\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> ValueError: invalid literal for int() with base 10: 'a'\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/10-defensive.md:515 +msgid ">\n" +"> Explain in words what the assertions in this function check,\n" +"> and for each one,\n" +"> give an example of input that will make that assertion fail.\n" +">\n" +"> ~~~\n" +"> def get_total(values):\n" +"> assert len(values) > 0\n" +"> for element in values:\n" +"> assert int(element)\n" +"> values = [int(element) for element in values]\n" +"> total = sum(values)\n" +"> assert total > 0\n" +"> return total\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> > ## Solution\n" +"> > * The first assertion checks that the input sequence `values` is not empty.\n" +"> > An empty sequence such as `[]` will make it fail.\n" +"> > * The second assertion checks that each value in the list can be turned into an integer.\n" +"> > Input such as `[1, 2,'c', 3]` will make it fail.\n" +"> > * The third assertion checks that the total of the list is greater than 0.\n" +"> > Input such as `[-10, 2, 3]` will make it fail." +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/14__11-debugging.md.ja.po b/transifex/python-novice-inflammation/po/14__11-debugging.md.ja.po new file mode 100644 index 00000000..ac807ca0 --- /dev/null +++ b/transifex/python-novice-inflammation/po/14__11-debugging.md.ja.po @@ -0,0 +1,415 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/11-debugging.md:1 +# Front Matter +msgid "---\n" +"title: Debugging\n" +"teaching: 30\n" +"exercises: 20\n" +"questions:\n" +"- \"How can I debug my program?\"\n" +"objectives:\n" +"- \"Debug code containing an error systematically.\"\n" +"- \"Identify ways of making code less error-prone and more easily tested.\"\n" +"keypoints:\n" +"- \"Know what code is supposed to do *before* trying to debug it.\"\n" +"- \"Make it fail every time.\"\n" +"- \"Make it fail fast.\"\n" +"- \"Change one thing at a time, and for a reason.\"\n" +"- \"Keep track of what you've done.\"\n" +"- \"Be humble.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:19 +msgid "Once testing has uncovered problems,\n" +"the next step is to fix them.\n" +"Many novices do this by making more-or-less random changes to their code\n" +"until it seems to produce the right answer,\n" +"but that's very inefficient\n" +"(and the result is usually only correct for the one case they're testing).\n" +"The more experienced a programmer is,\n" +"the more systematically they debug,\n" +"and most follow some variation on the rules explained below." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:29 +# header +msgid "## Know What It's Supposed to Do" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:31 +msgid "The first step in debugging something is to\n" +"*know what it's supposed to do*.\n" +"\"My program doesn't work\" isn't good enough:\n" +"in order to diagnose and fix problems,\n" +"we need to be able to tell correct output from incorrect.\n" +"If we can write a test case for the failing case --- i.e.,\n" +"if we can assert that with *these* inputs,\n" +"the function should produce *that* result ---\n" +"then we're ready to start debugging.\n" +"If we can't,\n" +"then we need to figure out how we're going to know when we've fixed things." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:43 +msgid "But writing test cases for scientific software is frequently harder than\n" +"writing test cases for commercial applications,\n" +"because if we knew what the output of the scientific code was supposed to be,\n" +"we wouldn't be running the software:\n" +"we'd be writing up our results and moving on to the next program.\n" +"In practice,\n" +"scientists tend to do the following:" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:51 +# ordered list +msgid "1. *Test with simplified data.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:52 +msgid " Before doing statistics on a real data set,\n" +" we should try calculating statistics for a single record,\n" +" for two identical records,\n" +" for two records whose values are one step apart,\n" +" or for some other case where we can calculate the right answer by hand." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:58 +# ordered list +msgid "2. *Test a simplified case.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:59 +msgid " If our program is supposed to simulate\n" +" magnetic eddies in rapidly-rotating blobs of supercooled helium,\n" +" our first test should be a blob of helium that isn't rotating,\n" +" and isn't being subjected to any external electromagnetic fields.\n" +" Similarly,\n" +" if we're looking at the effects of climate change on speciation,\n" +" our first test should hold temperature, precipitation, and other factors constant." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:67 +# ordered list +msgid "3. *Compare to an oracle.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:68 +msgid " A [test oracle]({{ page.root }}/reference.html#test-oracle) is something whose results are trusted,\n" +" such as experimental data, an older program, or a human expert.\n" +" We use test oracles to determine if our new program produces the correct results.\n" +" If we have a test oracle,\n" +" we should store its output for particular cases\n" +" so that we can compare it with our new results as often as we like\n" +" without re-running that program." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:76 +# ordered list +msgid "4. *Check conservation laws.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:77 +msgid " Mass, energy, and other quantities are conserved in physical systems,\n" +" so they should be in programs as well.\n" +" Similarly,\n" +" if we are analyzing patient data,\n" +" the number of records should either stay the same or decrease\n" +" as we move from one analysis to the next\n" +" (since we might throw away outliers or records with missing values).\n" +" If \"new\" patients start appearing out of nowhere as we move through our pipeline,\n" +" it's probably a sign that something is wrong." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:87 +# ordered list +msgid "5. *Visualize.*" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:88 +msgid " Data analysts frequently use simple visualizations to check both\n" +" the science they're doing\n" +" and the correctness of their code\n" +" (just as we did in the [opening lesson]({{ page.root }}/01-numpy/) of this tutorial).\n" +" This should only be used for debugging as a last resort,\n" +" though,\n" +" since it's very hard to compare two visualizations automatically." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:96 +# header +msgid "## Make It Fail Every Time" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:98 +msgid "We can only debug something when it fails,\n" +"so the second step is always to find a test case that\n" +"*makes it fail every time*.\n" +"The \"every time\" part is important because\n" +"few things are more frustrating than debugging an intermittent problem:\n" +"if we have to call a function a dozen times to get a single failure,\n" +"the odds are good that we'll scroll past the failure when it actually occurs." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:106 +msgid "As part of this,\n" +"it's always important to check that our code is \"plugged in\",\n" +"i.e.,\n" +"that we're actually exercising the problem that we think we are.\n" +"Every programmer has spent hours chasing a bug,\n" +"only to realize that they were actually calling their code on the wrong data set\n" +"or with the wrong configuration parameters,\n" +"or are using the wrong version of the software entirely.\n" +"Mistakes like these are particularly likely to happen when we're tired,\n" +"frustrated,\n" +"and up against a deadline,\n" +"which is one of the reasons late-night (or overnight) coding sessions\n" +"are almost never worthwhile." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:120 +# header +msgid "## Make It Fail Fast" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:122 +msgid "If it takes 20 minutes for the bug to surface,\n" +"we can only do three experiments an hour.\n" +"This means that we'll get less data in more time and that\n" +"we're more likely to be distracted by other things as we wait for our program to fail,\n" +"which means the time we *are* spending on the problem is less focused.\n" +"It's therefore critical to *make it fail fast*." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:129 +msgid "As well as making the program fail fast in time,\n" +"we want to make it fail fast in space,\n" +"i.e.,\n" +"we want to localize the failure to the smallest possible region of code:" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:134 +# ordered list +msgid "1. The smaller the gap between cause and effect," +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:135 +msgid " the easier the connection is to find.\n" +" Many programmers therefore use a divide and conquer strategy to find bugs,\n" +" i.e.,\n" +" if the output of a function is wrong,\n" +" they check whether things are OK in the middle,\n" +" then concentrate on either the first or second half,\n" +" and so on." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:143 +# ordered list +msgid "2. N things can interact in N! different ways," +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:144 +msgid " so every line of code that *isn't* run as part of a test\n" +" means more than one thing we don't need to worry about." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:147 +# header +msgid "## Change One Thing at a Time, For a Reason" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:149 +msgid "Replacing random chunks of code is unlikely to do much good.\n" +"(After all,\n" +"if you got it wrong the first time,\n" +"you'll probably get it wrong the second and third as well.)\n" +"Good programmers therefore\n" +"*change one thing at a time, for a reason*.\n" +"They are either trying to gather more information\n" +"(\"is the bug still there if we change the order of the loops?\")\n" +"or test a fix\n" +"(\"can we make the bug go away by sorting our data before processing it?\")." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:160 +msgid "Every time we make a change,\n" +"however small,\n" +"we should re-run our tests immediately,\n" +"because the more things we change at once,\n" +"the harder it is to know what's responsible for what\n" +"(those N! interactions again).\n" +"And we should re-run *all* of our tests:\n" +"more than half of fixes made to code introduce (or re-introduce) bugs,\n" +"so re-running all of our tests tells us whether we have regressed." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:170 +# header +msgid "## Keep Track of What You've Done" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:172 +msgid "Good scientists keep track of what they've done\n" +"so that they can reproduce their work,\n" +"and so that they don't waste time repeating the same experiments\n" +"or running ones whose results won't be interesting.\n" +"Similarly,\n" +"debugging works best when we\n" +"*keep track of what we've done*\n" +"and how well it worked.\n" +"If we find ourselves asking,\n" +"\"Did left followed by right with an odd number of lines cause the crash?\n" +"Or was it right followed by left?\n" +"Or was I using an even number of lines?\"\n" +"then it's time to step away from the computer,\n" +"take a deep breath,\n" +"and start working more systematically." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:188 +msgid "Records are particularly useful when the time comes to ask for help.\n" +"People are more likely to listen to us\n" +"when we can explain clearly what we did,\n" +"and we're better able to give them the information they need to be useful." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:193 +# blockquote, which can be cascaded +msgid "> ## Version Control Revisited" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:194 +msgid ">\n" +"> Version control is often used to reset software to a known state during debugging,\n" +"> and to explore recent changes to code that might be responsible for bugs.\n" +"> In particular,\n" +"> most version control systems (e.g. git, Mercurial) have:\n" +"> 1. a `blame` command that shows who last changed each line of a file;\n" +"> 2. a `bisect` command that helps with finding the commit that introduced an\n" +"> issue." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:204 +# header +msgid "## Be Humble" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:206 +msgid "And speaking of help:\n" +"if we can't find a bug in 10 minutes,\n" +"we should *be humble* and ask for help.\n" +"Explaining the problem to someone else is often useful,\n" +"since hearing what we're thinking helps us spot inconsistencies and hidden assumptions.\n" +"If you don't have someone nearby to share your problem description with, get a\n" +"[rubber duck](https://en.wikipedia.org/wiki/Rubber_duck_debugging)!" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:214 +msgid "Asking for help also helps alleviate confirmation bias.\n" +"If we have just spent an hour writing a complicated program,\n" +"we want it to work,\n" +"so we're likely to keep telling ourselves why it should,\n" +"rather than searching for the reason it doesn't.\n" +"People who aren't emotionally invested in the code can be more objective,\n" +"which is why they're often able to spot the simple mistakes we have overlooked." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:222 +msgid "Part of being humble is learning from our mistakes.\n" +"Programmers tend to get the same things wrong over and over:\n" +"either they don't understand the language and libraries they're working with,\n" +"or their model of how things work is wrong.\n" +"In either case,\n" +"taking note of why the error occurred\n" +"and checking for it next time\n" +"quickly turns into not making the mistake at all." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:231 +msgid "And that is what makes us most productive in the long run.\n" +"As the saying goes,\n" +"*A week of hard work can sometimes save you an hour of thought*.\n" +"If we train ourselves to avoid making some kinds of mistakes,\n" +"to break our code into modular, testable chunks,\n" +"and to turn every assumption (or mistake) into an assertion,\n" +"it will actually take us *less* time to produce working programs,\n" +"not more." +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:240 +# blockquote, which can be cascaded +msgid "> ## Debug With a Neighbor" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:241 +msgid ">\n" +"> Take a function that you have written today, and introduce a tricky bug.\n" +"> Your function should still run, but will give the wrong output.\n" +"> Switch seats with your neighbor and attempt to debug\n" +"> the bug that they introduced into their function.\n" +"> Which of the principles discussed above did you find helpful?" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:249 +# blockquote, which can be cascaded +msgid "> ## Not Supposed to be the Same" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:250 +msgid ">\n" +"> You are assisting a researcher with Python code that computes the\n" +"> Body Mass Index (BMI) of patients. The researcher is concerned because\n" +"> all patients seemingly have unusual and identical BMIs, despite having different\n" +"> physiques. BMI is calculated as **weight in kilograms**\n" +"> divided by the square of **height in metres**.\n" +">\n" +"> Use the debugging principles in this exercise and locate problems\n" +"> with the code. What suggestions would you give the researcher for\n" +"> ensuring any later changes they make work correctly?\n" +">\n" +"> ~~~\n" +"> patients = [[70, 1.8], [80, 1.9], [150, 1.7]]\n" +">\n" +"> def calculate_bmi(weight, height):\n" +"> return weight / (height ** 2)\n" +">\n" +"> for patient in patients:\n" +"> weight, height = patients[0]\n" +"> bmi = calculate_bmi(height, weight)\n" +"> print(\"Patient's BMI is: %f\" % bmi)\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> ~~~\n" +"> Patient's BMI is: 0.000367\n" +"> Patient's BMI is: 0.000367\n" +"> Patient's BMI is: 0.000367\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/11-debugging.md:280 +msgid ">\n" +"> > ## Solution\n" +"> > * The loop is not being utilised correctly. `height` and `weight` are always\n" +"> > set as the first patient's data during each iteration of the loop.\n" +"> >\n" +"> > * The height/weight variables are reversed in the function call to\n" +"> > `calculate_bmi(...)`, the correct BMIs are 21.604938, 22.160665 and 51.903114." +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/15__12-cmdline.md.ja.po b/transifex/python-novice-inflammation/po/15__12-cmdline.md.ja.po new file mode 100644 index 00000000..32e98bf9 --- /dev/null +++ b/transifex/python-novice-inflammation/po/15__12-cmdline.md.ja.po @@ -0,0 +1,1306 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1 +# Front Matter +msgid "---\n" +"title: Command-Line Programs\n" +"teaching: 30\n" +"exercises: 0\n" +"questions:\n" +"- \"How can I write Python programs that will work like Unix command-line tools?\"\n" +"objectives:\n" +"- \"Use the values of command-line arguments in a program.\"\n" +"- \"Handle flags and files separately in a command-line program.\"\n" +"- \"Read data from standard input in a program so that it can be used in a pipeline.\"\n" +"keypoints:\n" +"- \"The `sys` library connects a Python program to the system it is running on.\"\n" +"- \"The list `sys.argv` contains the command-line arguments that a program was run with.\"\n" +"- \"Avoid silent failures.\"\n" +"- \"The pseudo-file `sys.stdin` connects to a program's standard input.\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:18 +msgid "The Jupyter Notebook and other interactive tools are great for prototyping code and exploring data,\n" +"but sooner or later we will want to use our program in a pipeline\n" +"or run it in a shell script to process thousands of data files.\n" +"In order to do that,\n" +"we need to make our programs work like other Unix command-line tools.\n" +"For example,\n" +"we may want a program that reads a dataset\n" +"and prints the average inflammation per patient." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:27 +# blockquote, which can be cascaded +msgid "> ## Switching to Shell Commands" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:28 +msgid ">\n" +"> In this lesson we are switching from typing commands in a Python interpreter to typing\n" +"> commands in a shell terminal window (such as bash). When you see a `$` in front of a\n" +"> command that tells you to run that command in the shell rather than the Python interpreter." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:34 +msgid "This program does exactly what we want - it prints the average inflammation per patient\n" +"for a given file." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:37 +# code block +msgid "~~~\n" +"$ python ../code/readings_04.py --mean inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:40 +#: python-novice-inflammation/_episodes/12-cmdline.md:58 +#: python-novice-inflammation/_episodes/12-cmdline.md:65 +#: python-novice-inflammation/_episodes/12-cmdline.md:100 +#: python-novice-inflammation/_episodes/12-cmdline.md:126 +#: python-novice-inflammation/_episodes/12-cmdline.md:140 +#: python-novice-inflammation/_episodes/12-cmdline.md:159 +#: python-novice-inflammation/_episodes/12-cmdline.md:183 +#: python-novice-inflammation/_episodes/12-cmdline.md:192 +#: python-novice-inflammation/_episodes/12-cmdline.md:215 +#: python-novice-inflammation/_episodes/12-cmdline.md:333 +#: python-novice-inflammation/_episodes/12-cmdline.md:343 +#: python-novice-inflammation/_episodes/12-cmdline.md:354 +#: python-novice-inflammation/_episodes/12-cmdline.md:392 +#: python-novice-inflammation/_episodes/12-cmdline.md:415 +#: python-novice-inflammation/_episodes/12-cmdline.md:448 +#: python-novice-inflammation/_episodes/12-cmdline.md:482 +#: python-novice-inflammation/_episodes/12-cmdline.md:511 +#: python-novice-inflammation/_episodes/12-cmdline.md:558 +#: python-novice-inflammation/_episodes/12-cmdline.md:581 +#: python-novice-inflammation/_episodes/12-cmdline.md:593 +#: python-novice-inflammation/_episodes/12-cmdline.md:613 +#: python-novice-inflammation/_episodes/12-cmdline.md:654 +msgid "{: .language-bash}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:42 +# code block +msgid "~~~\n" +"5.45\n" +"5.425\n" +"6.1\n" +"...\n" +"6.4\n" +"7.05\n" +"5.9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:53 +msgid "We might also want to look at the minimum of the first four lines" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:55 +# code block +msgid "~~~\n" +"$ head -4 inflammation-01.csv | python ../code/readings_06.py --min\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:60 +msgid "or the maximum inflammations in several files one after another:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:62 +# code block +msgid "~~~\n" +"$ python ../code/readings_04.py --max inflammation-*.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:67 +msgid "Our scripts should do the following:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:69 +# ordered list +msgid "1. If no filename is given on the command line, read data from" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:70 +msgid "[standard input]({{ page.root }}/reference.html#standard-input).\n" +"2. If one or more filenames are given, read data from them and report statistics for each file\n" +"separately.\n" +"3. Use the `--min`, `--mean`, or `--max` flag to determine what statistic to print." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:75 +msgid "To make this work,\n" +"we need to know how to handle command-line arguments in a program,\n" +"and understand how to handle standard input.\n" +"We'll tackle these questions in turn below." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:80 +# header +msgid "## Command-Line Arguments" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:82 +msgid "Using the text editor of your choice,\n" +"save the following in a text file called `sys_version.py`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:85 +# code block +msgid "~~~\n" +"import sys\n" +"print('version is', sys.version)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:91 +msgid "The first line imports a library called `sys`,\n" +"which is short for \"system\".\n" +"It defines values such as `sys.version`,\n" +"which describes which version of Python we are running.\n" +"We can run this script from the command line like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:97 +# code block +msgid "~~~\n" +"$ python sys_version.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:102 +# code block +msgid "~~~\n" +"version is 3.4.3+ (default, Jul 28 2015, 13:17:50)\n" +"[GCC 4.9.3]\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:108 +msgid "Create another file called `argv_list.py` and save the following text to it." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:110 +# code block +msgid "~~~\n" +"import sys\n" +"print('sys.argv is', sys.argv)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:116 +msgid "The strange name `argv` stands for \"argument values\".\n" +"Whenever Python runs a program,\n" +"it takes all of the values given on the command line\n" +"and puts them in the list `sys.argv`\n" +"so that the program can determine what they were.\n" +"If we run this program with no arguments:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:123 +# code block +msgid "~~~\n" +"$ python argv_list.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:128 +# code block +msgid "~~~\n" +"sys.argv is ['argv_list.py']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:133 +msgid "the only thing in the list is the full path to our script,\n" +"which is always `sys.argv[0]`.\n" +"If we run it with a few arguments, however:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:137 +# code block +msgid "~~~\n" +"$ python argv_list.py first second third\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:142 +# code block +msgid "~~~\n" +"sys.argv is ['argv_list.py', 'first', 'second', 'third']\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:147 +msgid "then Python adds each of those arguments to that magic list." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:149 +msgid "With this in hand, let's build a version of `readings.py` that always prints\n" +"the per-patient mean of a single data file.\n" +"The first step is to write a function that outlines our implementation,\n" +"and a placeholder for the function that does the actual work.\n" +"By convention this function is usually called `main`,\n" +"though we can call it whatever we want:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:156 +# code block +msgid "~~~\n" +"$ cat ../code/readings_01.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:161 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" filename = sys.argv[1]\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +" for row_mean in numpy.mean(data, axis=1):\n" +" print(row_mean)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:175 +msgid "This function gets the name of the script from `sys.argv[0]`,\n" +"because that's where it's always put,\n" +"and the name of the file to process from `sys.argv[1]`.\n" +"Here's a simple test:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:180 +# code block +msgid "~~~\n" +"$ python ../code/readings_01.py inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:185 +msgid "There is no output because we have defined a function,\n" +"but haven't actually called it.\n" +"Let's add a call to `main`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:189 +# code block +msgid "~~~\n" +"$ cat ../code/readings_02.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:194 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" filename = sys.argv[1]\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +" for row_mean in numpy.mean(data, axis=1):\n" +" print(row_mean)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:210 +msgid "and run that:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:212 +# code block +msgid "~~~\n" +"$ python ../code/readings_02.py inflammation-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:217 +# code block +msgid "~~~\n" +"5.45\n" +"5.425\n" +"6.1\n" +"5.9\n" +"5.55\n" +"6.225\n" +"5.975\n" +"6.65\n" +"6.625\n" +"6.525\n" +"6.775\n" +"5.8\n" +"6.225\n" +"5.75\n" +"5.225\n" +"6.3\n" +"6.55\n" +"5.7\n" +"5.85\n" +"6.55\n" +"5.775\n" +"5.825\n" +"6.175\n" +"6.1\n" +"5.8\n" +"6.425\n" +"6.05\n" +"6.025\n" +"6.175\n" +"6.55\n" +"6.175\n" +"6.35\n" +"6.725\n" +"6.125\n" +"7.075\n" +"5.725\n" +"5.925\n" +"6.15\n" +"6.075\n" +"5.75\n" +"5.975\n" +"5.725\n" +"6.3\n" +"5.9\n" +"6.75\n" +"5.925\n" +"7.225\n" +"6.15\n" +"5.95\n" +"6.275\n" +"5.7\n" +"6.1\n" +"6.825\n" +"5.975\n" +"6.725\n" +"5.7\n" +"6.25\n" +"6.4\n" +"7.05\n" +"5.9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:281 +# blockquote, which can be cascaded +msgid "> ## Running Versus Importing" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:282 +msgid ">\n" +"> Running a Python script in bash is very similar to\n" +"> importing that file in Python.\n" +"> The biggest difference is that we don't expect anything\n" +"> to happen when we import a file,\n" +"> whereas when running a script, we expect to see some\n" +"> output printed to the console.\n" +">\n" +"> In order for a Python script to work as expected\n" +"> when imported or when run as a script,\n" +"> we typically put the part of the script\n" +"> that produces output in the following if statement:\n" +">\n" +"> ~~~\n" +"> if __name__ == '__main__':\n" +"> main() # Or whatever function produces output\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> When you import a Python file, `__name__` is the name\n" +"> of that file (e.g., when importing `readings.py`,\n" +"> `__name__` is `'readings'`). However, when running a\n" +"> script in bash, `__name__` is always set to `'__main__'`\n" +"> in that script so that you can determine if the file\n" +"> is being imported or run as a script." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:309 +#: python-novice-inflammation/_episodes/12-cmdline.md:425 +# blockquote, which can be cascaded +msgid "> ## The Right Way to Do It" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:310 +msgid ">\n" +"> If our programs can take complex parameters or multiple filenames,\n" +"> we shouldn't handle `sys.argv` directly.\n" +"> Instead,\n" +"> we should use Python's `argparse` library,\n" +"> which handles common cases in a systematic way,\n" +"> and also makes it easy for us to provide sensible error messages for our users.\n" +"> We will not cover this module in this lesson\n" +"> but you can go to Tshepang Lekhonkhobe's\n" +"> [Argparse tutorial](http://docs.python.org/3/howto/argparse.html)\n" +"> that is part of Python's Official Documentation." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:323 +# header +msgid "## Handling Multiple Files" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:325 +msgid "The next step is to teach our program how to handle multiple files.\n" +"Since 60 lines of output per file is a lot to page through,\n" +"we'll start by using three smaller files,\n" +"each of which has three days of data for two patients:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:330 +# code block +msgid "~~~\n" +"$ ls small-*.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:335 +# code block +msgid "~~~\n" +"small-01.csv small-02.csv small-03.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:340 +# code block +msgid "~~~\n" +"$ cat small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:345 +# code block +msgid "~~~\n" +"0,0,1\n" +"0,1,2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:351 +# code block +msgid "~~~\n" +"$ python ../code/readings_02.py small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:356 +#: python-novice-inflammation/_episodes/12-cmdline.md:656 +# code block +msgid "~~~\n" +"0.333333333333\n" +"1.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:362 +msgid "Using small data files as input also allows us to check our results more easily:\n" +"here,\n" +"for example,\n" +"we can see that our program is calculating the mean correctly for each line,\n" +"whereas we were really taking it on faith before.\n" +"This is yet another rule of programming:\n" +"*test the simple things first*." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:370 +msgid "We want our program to process each file separately,\n" +"so we need a loop that executes once for each filename.\n" +"If we specify the files on the command line,\n" +"the filenames will be in `sys.argv`,\n" +"but we need to be careful:\n" +"`sys.argv[0]` will always be the name of our script,\n" +"rather than the name of a file.\n" +"We also need to handle an unknown number of filenames,\n" +"since our program could be run for any number of files." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:380 +msgid "The solution to both problems is to loop over the contents of `sys.argv[1:]`.\n" +"The '1' tells Python to start the slice at location 1,\n" +"so the program's name isn't included;\n" +"since we've left off the upper bound,\n" +"the slice runs to the end of the list,\n" +"and includes all the filenames.\n" +"Here's our changed program\n" +"`readings_03.py`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:389 +# code block +msgid "~~~\n" +"$ cat ../code/readings_03.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:394 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" for filename in sys.argv[1:]:\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +" for row_mean in numpy.mean(data, axis=1):\n" +" print(row_mean)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:410 +msgid "and here it is in action:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:412 +# code block +msgid "~~~\n" +"$ python ../code/readings_03.py small-01.csv small-02.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:417 +# code block +msgid "~~~\n" +"0.333333333333\n" +"1.0\n" +"13.6666666667\n" +"11.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:426 +msgid ">\n" +"> At this point,\n" +"> we have created three versions of our script called `readings_01.py`,\n" +"> `readings_02.py`, and `readings_03.py`.\n" +"> We wouldn't do this in real life:\n" +"> instead,\n" +"> we would have one file called `readings.py` that we committed to version control\n" +"> every time we got an enhancement working.\n" +"> For teaching,\n" +"> though,\n" +"> we need all the successive versions side by side." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:439 +# header +msgid "## Handling Command-Line Flags" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:441 +msgid "The next step is to teach our program to pay attention to the `--min`, `--mean`, and `--max` flags.\n" +"These always appear before the names of the files,\n" +"so we could do this:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:445 +# code block +msgid "~~~\n" +"$ cat ../code/readings_04.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:450 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" action = sys.argv[1]\n" +" filenames = sys.argv[2:]\n" +"\n" +" for filename in filenames:\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +"\n" +" if action == '--min':\n" +" values = numpy.min(data, axis=1)\n" +" elif action == '--mean':\n" +" values = numpy.mean(data, axis=1)\n" +" elif action == '--max':\n" +" values = numpy.max(data, axis=1)\n" +"\n" +" for val in values:\n" +" print(val)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:477 +msgid "This works:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:479 +# code block +msgid "~~~\n" +"$ python ../code/readings_04.py --max small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:484 +# code block +msgid "~~~\n" +"1.0\n" +"2.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:490 +msgid "but there are several things wrong with it:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:492 +# ordered list +msgid "1. `main` is too large to read comfortably." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:494 +# ordered list +msgid "2. If we do not specify at least two additional arguments on the" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:495 +msgid " command-line, one for the **flag** and one for the **filename**, but only\n" +" one, the program will not throw an exception but will run. It assumes that the file\n" +" list is empty, as `sys.argv[1]` will be considered the `action`, even if it\n" +" is a filename. [Silent failures]({{ page.root }}/reference.html#silence-failure) like this\n" +" are always hard to debug." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:501 +# ordered list +msgid "3. The program should check if the submitted `action` is one of the three recognized flags." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:503 +msgid "This version pulls the processing of each file out of the loop into a function of its own.\n" +"It also checks that `action` is one of the allowed flags\n" +"before doing any processing,\n" +"so that the program fails fast:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:508 +# code block +msgid "~~~\n" +"$ cat ../code/readings_05.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:513 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" action = sys.argv[1]\n" +" filenames = sys.argv[2:]\n" +" assert action in ['--min', '--mean', '--max'], \\\n" +" 'Action is not one of --min, --mean, or --max: ' + action\n" +" for filename in filenames:\n" +" process(filename, action)\n" +"\n" +"def process(filename, action):\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +"\n" +" if action == '--min':\n" +" values = numpy.min(data, axis=1)\n" +" elif action == '--mean':\n" +" values = numpy.mean(data, axis=1)\n" +" elif action == '--max':\n" +" values = numpy.max(data, axis=1)\n" +"\n" +" for val in values:\n" +" print(val)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:544 +msgid "This is four lines longer than its predecessor,\n" +"but broken into more digestible chunks of 8 and 12 lines." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:547 +# header +msgid "## Handling Standard Input" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:549 +msgid "The next thing our program has to do is read data from standard input if no filenames are given\n" +"so that we can put it in a pipeline,\n" +"redirect input to it,\n" +"and so on.\n" +"Let's experiment in another script called `count_stdin.py`:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:555 +# code block +msgid "~~~\n" +"$ cat ../code/count_stdin.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:560 +# code block +msgid "~~~\n" +"import sys\n" +"\n" +"count = 0\n" +"for line in sys.stdin:\n" +" count += 1\n" +"\n" +"print(count, 'lines in standard input')\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:571 +msgid "This little program reads lines from a special \"file\" called `sys.stdin`,\n" +"which is automatically connected to the program's standard input.\n" +"We don't have to open it --- Python and the operating system\n" +"take care of that when the program starts up ---\n" +"but we can do almost anything with it that we could do to a regular file.\n" +"Let's try running it as if it were a regular command-line program:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:578 +# code block +msgid "~~~\n" +"$ python ../code/count_stdin.py < small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:583 +# code block +msgid "~~~\n" +"2 lines in standard input\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:588 +msgid "A common mistake is to try to run something that reads from standard input like this:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:590 +# code block +msgid "~~~\n" +"$ python ../code/count_stdin.py small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:595 +msgid "i.e., to forget the `<` character that redirects the file to standard input.\n" +"In this case,\n" +"there's nothing in standard input,\n" +"so the program waits at the start of the loop for someone to type something on the keyboard.\n" +"Since there's no way for us to do this,\n" +"our program is stuck,\n" +"and we have to halt it using the `Interrupt` option from the `Kernel` menu in the Notebook." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:603 +msgid "We now need to rewrite the program so that it loads data from `sys.stdin`\n" +"if no filenames are provided.\n" +"Luckily,\n" +"`numpy.loadtxt` can handle either a filename or an open file as its first parameter,\n" +"so we don't actually need to change `process`.\n" +"Only `main` changes:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:610 +# code block +msgid "~~~\n" +"$ cat ../code/readings_06.py\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:615 +# code block +msgid "~~~\n" +"import sys\n" +"import numpy\n" +"\n" +"def main():\n" +" script = sys.argv[0]\n" +" action = sys.argv[1]\n" +" filenames = sys.argv[2:]\n" +" assert action in ['--min', '--mean', '--max'], \\\n" +" 'Action is not one of --min, --mean, or --max: ' + action\n" +" if len(filenames) == 0:\n" +" process(sys.stdin, action)\n" +" else:\n" +" for filename in filenames:\n" +" process(filename, action)\n" +"\n" +"def process(filename, action):\n" +" data = numpy.loadtxt(filename, delimiter=',')\n" +"\n" +" if action == '--min':\n" +" values = numpy.min(data, axis=1)\n" +" elif action == '--mean':\n" +" values = numpy.mean(data, axis=1)\n" +" elif action == '--max':\n" +" values = numpy.max(data, axis=1)\n" +"\n" +" for val in values:\n" +" print(val)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:649 +msgid "Let's try it out:" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:651 +# code block +msgid "~~~\n" +"$ python ../code/readings_06.py --mean < small-01.csv\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:662 +msgid "That's better.\n" +"In fact,\n" +"that's done:\n" +"the program now does everything we set out to do." +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:667 +# blockquote, which can be cascaded +msgid "> ## Arithmetic on the Command Line" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:668 +msgid ">\n" +"> Write a command-line program that does addition and subtraction:\n" +">\n" +"> ~~~\n" +"> $ python arith.py add 1 2\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> 3\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:680 +msgid ">\n" +"> ~~~\n" +"> $ python arith.py subtract 3 4\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> -1\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:690 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> >\n" +"> > def main():\n" +"> > assert len(sys.argv) == 4, 'Need exactly 3 arguments'\n" +"> >\n" +"> > operator = sys.argv[1]\n" +"> > assert operator in ['add', 'subtract', 'multiply', 'divide'], \\\n" +"> > 'Operator is not one of add, subtract, multiply, or divide: bailing out'\n" +"> > try:\n" +"> > operand1, operand2 = float(sys.argv[2]), float(sys.argv[3])\n" +"> > except ValueError:\n" +"> > print('cannot convert input to a number: bailing out')\n" +"> > return\n" +"> >\n" +"> > do_arithmetic(operand1, operator, operand2)\n" +"> >\n" +"> > def do_arithmetic(operand1, operator, operand2):\n" +"> >\n" +"> > if operator == 'add':\n" +"> > value = operand1 + operand2\n" +"> > elif operator == 'subtract':\n" +"> > value = operand1 - operand2\n" +"> > elif operator == 'multiply':\n" +"> > value = operand1 * operand2\n" +"> > elif operator == 'divide':\n" +"> > value = operand1 / operand2\n" +"> > print(value)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:727 +# blockquote, which can be cascaded +msgid "> ## Finding Particular Files" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:728 +msgid ">\n" +"> Using the `glob` module introduced [earlier]({{ page.root }}/04-files/),\n" +"> write a simple version of `ls` that shows files in the current directory\n" +"> with a particular suffix.\n" +"> A call to this script should look like this:\n" +">\n" +"> ~~~\n" +"> $ python my_ls.py py\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> left.py\n" +"> right.py\n" +"> zero.py\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:745 +msgid ">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> > import glob\n" +"> >\n" +"> > def main():\n" +"> > \"\"\"prints names of all files with sys.argv as suffix\"\"\"\n" +"> > assert len(sys.argv) >= 2, 'Argument list cannot be empty'\n" +"> > suffix = sys.argv[1] # NB: behaviour is not as you'd expect if sys.argv[1] is *\n" +"> > glob_input = '*.' + suffix # construct the input\n" +"> > glob_output = sorted(glob.glob(glob_input)) # call the glob function\n" +"> > for item in glob_output: # print the output\n" +"> > print(item)\n" +"> > return\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:767 +# blockquote, which can be cascaded +msgid "> ## Changing Flags" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:768 +msgid ">\n" +"> Rewrite `readings.py` so that it uses `-n`, `-m`, and `-x`\n" +"> instead of `--min`, `--mean`, and `--max` respectively.\n" +"> Is the code easier to read?\n" +"> Is the program easier to understand?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # this is code/readings_07.py\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > action = sys.argv[1]\n" +"> > filenames = sys.argv[2:]\n" +"> > assert action in ['-n', '-m', '-x'], \\\n" +"> > 'Action is not one of -n, -m, or -x: ' + action\n" +"> > if len(filenames) == 0:\n" +"> > process(sys.stdin, action)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > process(filename, action)\n" +"> >\n" +"> > def process(filename, action):\n" +"> > data = numpy.loadtxt(filename, delimiter=',')\n" +"> >\n" +"> > if action == '-n':\n" +"> > values = numpy.min(data, axis=1)\n" +"> > elif action == '-m':\n" +"> > values = numpy.mean(data, axis=1)\n" +"> > elif action == '-x':\n" +"> > values = numpy.max(data, axis=1)\n" +"> >\n" +"> > for val in values:\n" +"> > print(val)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:811 +# blockquote, which can be cascaded +msgid "> ## Adding a Help Message" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:812 +msgid ">\n" +"> Separately,\n" +"> modify `readings.py` so that if no parameters are given\n" +"> (i.e., no action is specified and no filenames are given),\n" +"> it prints a message explaining how it should be used.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # this is code/readings_08.py\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > if len(sys.argv) == 1: # no arguments, so print help message\n" +"> > print(\"\"\"Usage: python readings_08.py action filenames\n" +"> > action must be one of --min --mean --max\n" +"> > if filenames is blank, input is taken from stdin;\n" +"> > otherwise, each filename in the list of arguments is processed in turn\"\"\")\n" +"> > return\n" +"> >\n" +"> > action = sys.argv[1]\n" +"> > filenames = sys.argv[2:]\n" +"> > assert action in ['--min', '--mean', '--max'], \\\n" +"> > 'Action is not one of --min, --mean, or --max: ' + action\n" +"> > if len(filenames) == 0:\n" +"> > process(sys.stdin, action)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > process(filename, action)\n" +"> >\n" +"> > def process(filename, action):\n" +"> > data = numpy.loadtxt(filename, delimiter=',')\n" +"> >\n" +"> > if action == '--min':\n" +"> > values = numpy.min(data, axis=1)\n" +"> > elif action == '--mean':\n" +"> > values = numpy.mean(data, axis=1)\n" +"> > elif action == '--max':\n" +"> > values = numpy.max(data, axis=1)\n" +"> >\n" +"> > for val in values:\n" +"> > print(val)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:862 +# blockquote, which can be cascaded +msgid "> ## Adding a Default Action" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:863 +msgid ">\n" +"> Separately,\n" +"> modify `readings.py` so that if no action is given\n" +"> it displays the means of the data.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > # this is code/readings_09.py\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > action = sys.argv[1]\n" +"> > if action not in ['--min', '--mean', '--max']: # if no action given\n" +"> > action = '--mean' # set a default action, that being mean\n" +"> > filenames = sys.argv[1:] # start the filenames one place earlier in the argv list\n" +"> > else:\n" +"> > filenames = sys.argv[2:]\n" +"> >\n" +"> > if len(filenames) == 0:\n" +"> > process(sys.stdin, action)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > process(filename, action)\n" +"> >\n" +"> > def process(filename, action):\n" +"> > data = numpy.loadtxt(filename, delimiter=',')\n" +"> >\n" +"> > if action == '--min':\n" +"> > values = numpy.min(data, axis=1)\n" +"> > elif action == '--mean':\n" +"> > values = numpy.mean(data, axis=1)\n" +"> > elif action == '--max':\n" +"> > values = numpy.max(data, axis=1)\n" +"> >\n" +"> > for val in values:\n" +"> > print(val)\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:908 +# blockquote, which can be cascaded +msgid "> ## A File-Checker" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:909 +msgid ">\n" +"> Write a program called `check.py` that takes the names of one or more\n" +"> inflammation data files as arguments\n" +"> and checks that all the files have the same number of rows and columns.\n" +"> What is the best way to test your program?\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> > import numpy\n" +"> >\n" +"> > def main():\n" +"> > script = sys.argv[0]\n" +"> > filenames = sys.argv[1:]\n" +"> > if len(filenames) <=1: #nothing to check\n" +"> > print('Only 1 file specified on input')\n" +"> > else:\n" +"> > nrow0, ncol0 = row_col_count(filenames[0])\n" +"> > print('First file %s: %d rows and %d columns' % (filenames[0], nrow0, ncol0))\n" +"> > for filename in filenames[1:]:\n" +"> > nrow, ncol = row_col_count(filename)\n" +"> > if nrow != nrow0 or ncol != ncol0:\n" +"> > print('File %s does not check: %d rows and %d columns' % (filename, nrow, ncol))\n" +"> > else:\n" +"> > print('File %s checks' % filename)\n" +"> > return\n" +"> >\n" +"> > def row_col_count(filename):\n" +"> > try:\n" +"> > nrow, ncol = numpy.loadtxt(filename, delimiter=',').shape\n" +"> > except ValueError:\n" +"> > # 'ValueError' error is raised when numpy encounters lines that\n" +"> > # have different number of data elements in them than the rest of the lines,\n" +"> > # or when lines have non-numeric elements\n" +"> > nrow, ncol = (0, 0)\n" +"> > return nrow, ncol\n" +"> >\n" +"> > main()\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:952 +# blockquote, which can be cascaded +msgid "> ## Counting Lines" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:953 +msgid ">\n" +"> Write a program called `line_count.py` that works like the Unix `wc` command:\n" +">\n" +"> * If no filenames are given, it reports the number of lines in standard input.\n" +"> * If one or more filenames are given, it reports the number of lines in each,\n" +"> followed by the total number of lines.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > import sys\n" +"> >\n" +"> > def main():\n" +"> > \"\"\"print each input filename and the number of lines in it,\n" +"> > and print the sum of the number of lines\"\"\"\n" +"> > filenames = sys.argv[1:]\n" +"> > sum_nlines = 0 #initialize counting variable\n" +"> >\n" +"> > if len(filenames) == 0: # no filenames, just stdin\n" +"> > sum_nlines = count_file_like(sys.stdin)\n" +"> > print('stdin: %d' % sum_nlines)\n" +"> > else:\n" +"> > for filename in filenames:\n" +"> > nlines = count_file(filename)\n" +"> > print('%s %d' % (filename, nlines))\n" +"> > sum_nlines += nlines\n" +"> > print('total: %d' % sum_nlines)\n" +"> >\n" +"> > def count_file(filename):\n" +"> > \"\"\"count the number of lines in a file\"\"\"\n" +"> > f = open(filename,'r')\n" +"> > nlines = len(f.readlines())\n" +"> > f.close()\n" +"> > return(nlines)\n" +"> >\n" +"> > def count_file_like(file_like):\n" +"> > \"\"\"count the number of lines in a file-like object (eg stdin)\"\"\"\n" +"> > n = 0\n" +"> > for line in file_like:\n" +"> > n = n+1\n" +"> > return n\n" +"> >\n" +"> > main()\n" +"> >\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1001 +# blockquote, which can be cascaded +msgid "> ## Generate an Error Message" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1002 +msgid ">\n" +"> Write a program called `check_arguments.py` that prints usage\n" +"> then exits the program if no arguments are provided.\n" +"> (Hint: You can use `sys.exit()` to exit the program.)\n" +">\n" +"> ~~~\n" +"> $ python check_arguments.py\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> usage: python check_argument.py filename.txt\n" +"> ~~~" +msgstr "" + +#: python-novice-inflammation/_episodes/12-cmdline.md:1016 +msgid ">\n" +"> ~~~\n" +"> $ python check_arguments.py filename.txt\n" +"> ~~~\n" +"> {: .language-bash}\n" +">\n" +"> ~~~\n" +"> Thanks for specifying arguments!\n" +"> ~~~" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/16__about.md.ja.po b/transifex/python-novice-inflammation/po/16__about.md.ja.po new file mode 100644 index 00000000..3f37dc20 --- /dev/null +++ b/transifex/python-novice-inflammation/po/16__about.md.ja.po @@ -0,0 +1,34 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/about.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/about.md:1 +# Front Matter +msgid "---\n" +"title: About\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/about.md:4 +msgid "{% include carpentries.html %}" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/_extras/about.md:4 +msgid "{% include carpentries.html %}\n" +"{% include links.md %}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/17__additional_material.md.ja.po b/transifex/python-novice-inflammation/po/17__additional_material.md.ja.po new file mode 100644 index 00000000..1dbb75df --- /dev/null +++ b/transifex/python-novice-inflammation/po/17__additional_material.md.ja.po @@ -0,0 +1,168 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/additional_material.md:1 +# Front Matter +msgid "---\n" +"title: \"Additional material\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:4 +msgid "A collection of facts about Python that do not fit into the main lesson\n" +"either due to the scope or time constraints of the main lesson." +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:8 +# header +msgid "## Jupyter Notebook/IPython: Who's Who in Memory" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:10 +msgid "You can use the `%whos` command at any time to see what\n" +"variables you have created and what modules you have loaded into the computer's memory.\n" +"As this is an IPython command, it will only work if you are in an IPython terminal or the\n" +"Jupyter Notebook." +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:15 +# code block +msgid "~~~\n" +"%whos\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:20 +# code block +msgid "~~~\n" +"Variable Type Data/Info\n" +"--------------------------------\n" +"weight_kg float 100.0\n" +"weight_lb float 143.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:29 +msgid "
\n" +"## Integer Division" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:32 +msgid "We are using Python 3, where division always returns a floating point number:" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:34 +# code block +msgid "~~~\n" +"5/9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:37 +msgid "{: .language-python}\n" +"~~~\n" +"0.5555555555555556\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:43 +msgid "Unfortunately, this wasn't the case in Python 2:\n" +"~~~\n" +"5/9\n" +"~~~\n" +"{: .language-python}\n" +"~~~\n" +"0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:53 +msgid "If you are using Python 2 and want to keep the fractional part of division\n" +"you need to convert one or the other number to floating point:" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:56 +# code block +msgid "~~~\n" +"float(5)/9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:61 +#: python-novice-inflammation/_extras/additional_material.md:71 +#: python-novice-inflammation/_extras/additional_material.md:81 +#: python-novice-inflammation/_extras/additional_material.md:90 +# code block +msgid "~~~\n" +"0.555555555556\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:66 +# code block +msgid "~~~\n" +"5/float(9)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:76 +# code block +msgid "~~~\n" +"5.0/9\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:85 +# code block +msgid "~~~\n" +"5/9.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:95 +msgid "And if you want an integer result from division in Python 3,\n" +"use a double-slash:" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:98 +# code block +msgid "~~~\n" +"4//2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:103 +# code block +msgid "~~~\n" +"2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:108 +# code block +msgid "~~~\n" +"3//2\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/additional_material.md:113 +# code block +msgid "~~~\n" +"1\n" +"~~~" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/18__discuss.md.ja.po b/transifex/python-novice-inflammation/po/18__discuss.md.ja.po new file mode 100644 index 00000000..d85064ae --- /dev/null +++ b/transifex/python-novice-inflammation/po/18__discuss.md.ja.po @@ -0,0 +1,592 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/discuss.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/discuss.md:1 +# Front Matter +msgid "---\n" +"title: Discussion\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:4 +# header +msgid "## Rules of Debugging" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:6 +# ordered list +msgid "1. Fail early, fail often." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:7 +# ordered list +msgid "2. Always initialize from data." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:8 +# ordered list +msgid "3. Know what it's supposed to do." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:9 +# ordered list +msgid "4. Make it fail every time." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:10 +# ordered list +msgid "5. Make it fail fast." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:11 +# ordered list +msgid "6. Change one thing at a time, for a reason." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:12 +# ordered list +msgid "7. Keep track of what we've done." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:13 +# ordered list +msgid "8. Be humble." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:14 +# ordered list +msgid "9. Test the simple things first." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:16 +msgid "And remember,\n" +"a week of hard work can sometimes save you an hour of thought." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:19 +# header +msgid "## The Call Stack" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:21 +msgid "Let's take a closer look at what happens when we call `fahr_to_celsius(32.0)`.\n" +"To make things clearer,\n" +"we'll start by putting the initial value 32.0 in a variable\n" +"and store the final result in one as well:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:26 +# code block +msgid "~~~\n" +"original = 32.0\n" +"final = fahr_to_celsius(original)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:32 +msgid "The diagram below shows what memory looks like after the first line has been executed:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:34 +msgid "![Call Stack (Initial State)](../fig/python-call-stack-01.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:36 +msgid "When we call `fahr_to_celsius`,\n" +"Python *doesn't* create the variable `temp` right away.\n" +"Instead,\n" +"it creates something called a [stack frame]({{ page.root }}/reference.html#stack-frame)\n" +"to keep track of the variables defined by `fahr_to_kelvin`.\n" +"Initially,\n" +"this stack frame only holds the value of `temp`:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:44 +msgid "![Call Stack Immediately After First Function Call](../fig/python-call-stack-02.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:46 +msgid "When we call `fahr_to_kelvin` inside `fahr_to_celsius`,\n" +"Python creates another stack frame to hold `fahr_to_kelvin`'s variables:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:49 +msgid "![Call Stack During First Nested Function Call](../fig/python-call-stack-03.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:51 +msgid "It does this because there are now two variables in play called `temp`:\n" +"the parameter to `fahr_to_celsius`,\n" +"and the parameter to `fahr_to_kelvin`.\n" +"Having two variables with the same name in the same part of the program would be ambiguous,\n" +"so Python (and every other modern programming language) creates\n" +"a new stack frame for each function call\n" +"to keep that function's variables separate from those defined by other functions." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:59 +msgid "When the call to `fahr_to_kelvin` returns a value,\n" +"Python throws away `fahr_to_kelvin`'s stack frame\n" +"and creates a new variable in the stack frame for `fahr_to_celsius`\n" +"to hold the temperature in Kelvin:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:64 +msgid "![Call Stack After Return From First Nested Function Call](../fig/python-call-stack-04.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:66 +msgid "It then calls `kelvin_to_celsius`,\n" +"which means it creates a stack frame to hold that function's variables:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:69 +msgid "![Call Stack During Call to Second Nested Function](../fig/python-call-stack-05.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:71 +msgid "Once again,\n" +"Python throws away that stack frame when `kelvin_to_celsius` is done\n" +"and creates the variable `result` in the stack frame for `fahr_to_celsius`:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:75 +msgid "![Call Stack After Second Nested Function Returns](../fig/python-call-stack-06.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:77 +msgid "Finally,\n" +"when `fahr_to_celsius` is done,\n" +"Python throws away *its* stack frame\n" +"and puts its result in a new variable called `final`\n" +"that lives in the stack frame we started with:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:83 +msgid "![Call Stack After All Functions Have Finished](../fig/python-call-stack-07.svg)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:85 +msgid "This final stack frame is always there;\n" +"it holds the variables we defined outside the functions in our code.\n" +"What it *doesn't* hold is the variables that were in the various stack frames.\n" +"If we try to get the value of `temp` after our functions have finished running,\n" +"Python tells us that there's no such thing:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:91 +# code block +msgid "~~~\n" +"print('final value of temp after all function calls:', temp)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:96 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"NameError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 print('final value of temp after all function calls:', temp)\n" +"\n" +"NameError: name 'temp' is not defined\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:106 +# code block +msgid "~~~\n" +"final value of temp after all function calls:\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:111 +msgid "Why go to all this trouble?\n" +"Well,\n" +"here's a function called `span` that calculates the difference between\n" +"the minimum and maximum values in an array:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:116 +# code block +msgid "~~~\n" +"import numpy\n" +"\n" +"def span(a):\n" +" diff = numpy.max(a) - numpy.min(a)\n" +" return diff\n" +"\n" +"data = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"print('span of data:', span(data))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:128 +#: python-novice-inflammation/_extras/discuss.md:142 +# code block +msgid "~~~\n" +"span of data: 20.0\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:133 +msgid "Notice that `span` assigns a value to a variable called `diff`.\n" +"We might very well use a variable with the same name to hold data:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:136 +# code block +msgid "~~~\n" +"diff = numpy.loadtxt(fname='inflammation-01.csv', delimiter=',')\n" +"print('span of data:', span(diff))\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:147 +msgid "We don't expect `diff` to have the value 20.0 after this function call,\n" +"so the name `diff` cannot refer to the same thing inside `span`\n" +"as it does in the main body of our program.\n" +"And yes,\n" +"we could probably choose a different name than `diff` in our main program in this case,\n" +"but we don't want to have to read every line of NumPy to see what variable names its functions use\n" +"before calling any of those functions,\n" +"just in case they change the values of our variables." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:156 +msgid "The big idea here is [encapsulation]({{ page.root }}/reference.html#encapsulation),\n" +"and it's the key to writing correct, comprehensible programs.\n" +"A function's job is to turn several operations into one\n" +"so that we can think about a single function call\n" +"instead of a dozen or a hundred statements\n" +"each time we want to do something.\n" +"That only works if functions don't interfere with each other;\n" +"if they do,\n" +"we have to pay attention to the details once again,\n" +"which quickly overloads our short-term memory." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:167 +# blockquote, which can be cascaded +msgid "> ## Following the Call Stack" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:168 +msgid ">\n" +"> We previously wrote functions called `fence` and `outer`.\n" +"> Draw a diagram showing how the call stack changes when we run the following:\n" +">\n" +"> ~~~\n" +"> print(outer(fence('carbon', '+')))\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:178 +# header +msgid "## Image Grids" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:180 +msgid "Let's start by creating some simple heat maps of our own\n" +"using a library called `ipythonblocks`.\n" +"The first step is to create our own \"image\":" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:184 +# code block +msgid "~~~\n" +"from ipythonblocks import ImageGrid\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:189 +msgid "Unlike the `import` statements we have seen earlier,\n" +"this one doesn't load the entire `ipythonblocks` library.\n" +"Instead,\n" +"it just loads `ImageGrid` from that library,\n" +"since that's the only thing we need (for now)." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:195 +msgid "Once we have `ImageGrid` loaded,\n" +"we can use it to create a very simple grid of colored cells:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:198 +# code block +msgid "~~~\n" +"grid = ImageGrid(5, 3)\n" +"grid.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:204 +msgid "![](../fig/grid-01.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:206 +msgid "Just like a NumPy array,\n" +"an `ImageGrid` has some properties that hold information about it:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:209 +# code block +msgid "~~~\n" +"print('grid width:', grid.width)\n" +"print('grid height:', grid.height)\n" +"print('grid lines on:', grid.lines_on)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:216 +# code block +msgid "~~~\n" +"grid width: 5\n" +"grid height: 3\n" +"grid lines on: True\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:223 +msgid "The obvious thing to do with a grid like this is color in its cells,\n" +"but in order to do that,\n" +"we need to know how computers represent color.\n" +"The most common schemes are [RGB]({{ page.root }}/reference.html#rgb),\n" +"which is short for \"red, green, blue\".\n" +"RGB is an [additive color model]({{ page.root }}/reference.html#additive-color-model):\n" +"every shade is some combination of red, green, and blue intensities.\n" +"We can think of these three values as being the axes in a cube:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:232 +msgid "![RGB Color Cube](../fig/color-cube.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:234 +msgid "An RGB color is an example of a multi-part value:\n" +"like a Cartesian coordinate,\n" +"it is one thing with several parts.\n" +"We can represent such a value in Python using a [tuple]({{ page.root }}/reference.html#tuple),\n" +"which we write using parentheses instead of the square brackets used for a list:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:240 +# code block +msgid "~~~\n" +"position = (12.3, 45.6)\n" +"print('position is:', position)\n" +"color = (10, 20, 30)\n" +"print('color is:', color)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:248 +# code block +msgid "~~~\n" +"position is: (12.3, 45.6)\n" +"color is: (10, 20, 30)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:254 +msgid "We can select elements from tuples using indexing,\n" +"just as we do with lists and arrays:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:257 +# code block +msgid "~~~\n" +"print('first element of color is:', color[0])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:262 +# code block +msgid "~~~\n" +"first element of color is: 10\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:267 +msgid "Unlike lists and arrays,\n" +"though,\n" +"tuples cannot be changed after they are created --- in technical terms,\n" +"they are [immutable]({{ page.root }}/reference.html#immutable):" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:272 +# code block +msgid "~~~\n" +"color[0] = 40\n" +"print('first element of color after change:', color[0])\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:278 +# code block +msgid "~~~\n" +"---------------------------------------------------------------------------\n" +"TypeError Traceback (most recent call last)\n" +" in ()\n" +"----> 1 color[0] = 40\n" +"2 print('first element of color after change:', color[0])\n" +"\n" +"TypeError: 'tuple' object does not support item assignment\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:289 +msgid "If a tuple represents an RGB color,\n" +"its red, green, and blue components can take on values between 0 and 255.\n" +"The upper bound may seem odd,\n" +"but it's the largest number that can be represented in an 8-bit byte\n" +"(i.e., 28-1).\n" +"This makes it easy for computers to manipulate colors,\n" +"while providing fine enough gradations to fool most human eyes,\n" +"most of the time." +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:298 +msgid "Let's see what a few RGB colors actually look like:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:300 +# code block +msgid "~~~\n" +"row = ImageGrid(8, 1)\n" +"row[0, 0] = (0, 0, 0) # no color => black\n" +"row[1, 0] = (255, 255, 255) # all colors => white\n" +"row[2, 0] = (255, 0, 0) # all red\n" +"row[3, 0] = (0, 255, 0) # all green\n" +"row[4, 0] = (0, 0, 255) # all blue\n" +"row[5, 0] = (255, 255, 0) # red and green\n" +"row[6, 0] = (255, 0, 255) # red and blue\n" +"row[7, 0] = (0, 255, 255) # green and blue\n" +"row.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:314 +msgid "![](../fig/grid-02.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:316 +msgid "Simple color values like `(0,255,0)` are easy enough to decipher with a bit of practice,\n" +"but what color is `(214,90,127)`?\n" +"To help us,\n" +"`ipythonblocks` provides a function called `show_color`:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:321 +# code block +msgid "~~~\n" +"from ipythonblocks import show_color\n" +"show_color(214, 90, 127)\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:327 +msgid "![](../fig/ipythonblocks_show_color_example.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:329 +msgid "It also provides a table of standard colors:" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:331 +# code block +msgid "~~~\n" +"from ipythonblocks import colors\n" +"c = ImageGrid(3, 2)\n" +"c[0, 0] = colors['Fuchsia']\n" +"c[0, 1] = colors['Salmon']\n" +"c[1, 0] = colors['Orchid']\n" +"c[1, 1] = colors['Lavender']\n" +"c[2, 0] = colors['LimeGreen']\n" +"c[2, 1] = colors['HotPink']\n" +"c.show()\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:344 +msgid "![](../fig/grid-03.png)" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:346 +# blockquote, which can be cascaded +msgid "> ## Making a Colorbar" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:347 +msgid ">\n" +"> Fill in the `____` in the code below to create a bar that changes color from dark blue to black.\n" +">\n" +"> ~~~\n" +"> bar = ImageGrid(10, 1)\n" +"> for x in range(10):\n" +"> bar[x, 0] = (0, 0, ____)\n" +"> bar.show()\n" +"> ~~~\n" +"> {: .language-python}" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:359 +# blockquote, which can be cascaded +msgid "> ## Why RGB?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:360 +msgid ">\n" +"> Why do computers use red, green, and blue as their primary colors?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:364 +# blockquote, which can be cascaded +msgid "> ## Nested Loops" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:365 +msgid ">\n" +"> Will changing the nesting of the loops in the code above --- i.e.,\n" +"> wrapping the Y-axis loop around the X-axis loop --- change the final image?\n" +"> Why or why not?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:371 +# blockquote, which can be cascaded +msgid "> ## Where to Change Data" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:372 +msgid ">\n" +"> Why did we transpose our data outside our heat map function?\n" +"> Why not have the function perform the transpose?" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:377 +# blockquote, which can be cascaded +msgid "> ## Return Versus Display" +msgstr "" + +#: python-novice-inflammation/_extras/discuss.md:378 +msgid ">\n" +"> Why does the heat map function return the grid rather than displaying it immediately?\n" +"> Do you think this is a good or bad design choice?" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/19__extra_exercises.md.ja.po b/transifex/python-novice-inflammation/po/19__extra_exercises.md.ja.po new file mode 100644 index 00000000..b0e6e29f --- /dev/null +++ b/transifex/python-novice-inflammation/po/19__extra_exercises.md.ja.po @@ -0,0 +1,108 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/extra_exercises.md:1 +# Front Matter +msgid "---\n" +"title: \"Additional Exercises\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:4 +msgid "A collection of exercises that have been either removed from\n" +"or not (yet) added to the main lesson." +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:8 +# blockquote, which can be cascaded +msgid "> ## Swapping the contents of variables (5 min)" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:9 +msgid ">\n" +"> Explain what the overall effect of this code is:\n" +">\n" +"> ~~~\n" +"> left = 'L'\n" +"> right = 'R'\n" +">\n" +"> temp = left\n" +"> left = right\n" +"> right = temp\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Compare it to:\n" +">\n" +"> ~~~\n" +"> left, right = [right, left]\n" +"> ~~~\n" +"> {: .language-python}\n" +">\n" +"> Do they always do the same thing?\n" +"> Which do you find easier to read?\n" +">\n" +"> > ## Solution\n" +"> > Both examples exchange the values of `left` and `right`:\n" +"> >\n" +"> > ~~~\n" +"> > print(left, right)\n" +"> > ~~~\n" +"> > {: .language-python}\n" +"> >\n" +"> > ~~~\n" +"> > R L\n" +"> > ~~~\n" +"> > {: .output}\n" +"> >\n" +"> > In the first case we used a temporary variable `temp` to keep the value of `left` before we\n" +"> > overwrite it with the value of `right`. In the second case, `right` and `left` are packed into a\n" +"> > list and then unpacked into `left` and `right`." +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:51 +# blockquote, which can be cascaded +msgid "> ## Fixing and Testing" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:52 +# blockquote, which can be cascaded +msgid "> From: \"Defensive Programming\"" +msgstr "" + +#: python-novice-inflammation/_extras/extra_exercises.md:53 +msgid ">\n" +"> Fix `range_overlap`. Re-run `test_range_overlap` after each change you make.\n" +">\n" +"> > ## Solution\n" +"> > ~~~\n" +"> > def range_overlap(ranges):\n" +"> > '''Return common overlap among a set of [left, right] ranges.'''\n" +"> > if not ranges:\n" +"> > # ranges is None or an empty list\n" +"> > return None\n" +"> > max_left, min_right = ranges[0]\n" +"> > for (left, right) in ranges[1:]:\n" +"> > max_left = max(max_left, left)\n" +"> > min_right = min(min_right, right)\n" +"> > if max_left >= min_right: # no overlap\n" +"> > return None\n" +"> > return (max_left, min_right)\n" +"> > ~~~\n" +"> > {: .language-python}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/20__figures.md.ja.po b/transifex/python-novice-inflammation/po/20__figures.md.ja.po new file mode 100644 index 00000000..d113d067 --- /dev/null +++ b/transifex/python-novice-inflammation/po/20__figures.md.ja.po @@ -0,0 +1,112 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/figures.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:1 +# Front Matter +msgid "---\n" +"title: Figures\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:5 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:5 +msgid "{% include base_path.html %}\n" +"{% include manual_episode_order.html %}" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:8 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:8 +# inline html +msgid "" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:68 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:68 +msgid "{% comment %} Create anchor for each one of the episodes. {% endcomment %}" +msgstr "" + +#: python-novice-inflammation/_extras/figures.md:70 +#: python-novice-inflammation/bin/boilerplate/_extras/figures.md:70 +msgid "{% for lesson_episode in lesson_episodes %}\n" +" {% if site.episode_order %}\n" +" {% assign episode = site.episodes | where: \"slug\", lesson_episode | first %}\n" +" {% else %}\n" +" {% assign episode = lesson_episode %}\n" +" {% endif %}\n" +"
\n" +"{% endfor %}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/21__guide.md.ja.po b/transifex/python-novice-inflammation/po/21__guide.md.ja.po new file mode 100644 index 00000000..95072305 --- /dev/null +++ b/transifex/python-novice-inflammation/po/21__guide.md.ja.po @@ -0,0 +1,238 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_extras/guide.md:1 +#: python-novice-inflammation/bin/boilerplate/_extras/guide.md:1 +# Front Matter +msgid "---\n" +"title: \"Instructor Notes\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:5 +# header +msgid "## About the lesson" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:7 +msgid "Our real goal isn't to teach workshop attendees Python as a programming language,\n" +"but to teach them the basic concepts that all programming depends on.\n" +"We use Python in our lessons because:" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:11 +# ordered list +msgid "1. It is free and open-source software." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:12 +# ordered list +msgid "2. It is well-documented and runs on all platforms." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:13 +# ordered list +msgid "3. It has a large and constantly growing user-base which includes scientists." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:14 +# ordered list +msgid "4. It is easier for novices to pick up than most other languages." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:16 +# header +msgid "## Legend" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:18 +msgid "We are using a dataset with records on inflammation from patients following an\n" +"arthritis treatment." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:21 +msgid "We make reference in the lesson that this data is somehow strange. It is strange\n" +"because it is fabricated! The script used to generate the inflammation data\n" +"is included as [`code/gen_inflammation.py`](../code/gen_inflammation.py)." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:25 +# header +msgid "## Overall" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:27 +msgid "This lesson is written as an introduction to Python,\n" +"but its real purpose is to introduce the single most important idea in programming:\n" +"how to solve problems by building functions,\n" +"each of which can fit in a programmer's working memory.\n" +"In order to teach that,\n" +"we must teach people a little about\n" +"the mechanics of manipulating data with lists and file I/O\n" +"so that their functions can do things they actually care about.\n" +"Our teaching order tries to show practical uses of every idea as soon as it is introduced;\n" +"instructors should resist the temptation to explain\n" +"the \"other 90%\" of the language\n" +"as well." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:40 +msgid "The final example asks them to build a command-line tool\n" +"that works with the Unix pipe-and-filter model.\n" +"We do this because it is a useful skill\n" +"and because it helps learners see that the software they use isn't magical.\n" +"Tools like `grep` might be more sophisticated than\n" +"the programs our learners can write at this point in their careers,\n" +"but it's crucial they realize this is a difference of scale rather than kind." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:48 +msgid "Explain that we use Python because:" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:50 +# unordered list +msgid "* It's free." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:51 +# unordered list +msgid "* It has a lot of scientific libraries, and more are constantly being added." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:52 +# unordered list +msgid "* It has a large scientific user community." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:53 +# unordered list +msgid "* It's easier for novices to learn than most of the mature alternatives." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:54 +msgid " (Software Carpentry originally used Perl;\n" +" when we switched,\n" +" we found that we could cover as much material in two days in Python\n" +" as we'd covered in three days in Perl,\n" +" and that retention was higher.)" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:60 +msgid "We do *not* include instructions on running the Jupyter Notebook in the tutorial\n" +"because we want to focus on the language rather than the tools.\n" +"Instructors should, however, walk learners through some basic operations:" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:64 +# unordered list +msgid "* Launch from the command line with `jupyter notebook`." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:65 +# unordered list +msgid "* Create a new notebook." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:66 +# unordered list +msgid "* Enter code or data in a cell and execute it." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:67 +# unordered list +msgid "* Explain the difference between `In[#]` and `Out[#]`." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:69 +msgid "Watching the instructor grow programs step by step\n" +"is as helpful to learners as anything to do with Python.\n" +"Resist the urge to update a single cell repeatedly\n" +"(which is what you'd probably do in real life).\n" +"Instead,\n" +"clone the previous cell and write the update in the new copy\n" +"so that learners have a complete record of how the program grew.\n" +"Once you've done this,\n" +"you can say,\n" +"\"Now why don't we just break things into small functions right from the start?\"" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:80 +msgid "The discussion of command-line scripts\n" +"assumes that students understand standard I/O and building filters,\n" +"which are covered in the lesson on the shell." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:84 +# header +msgid "## Frequently Argued Issues (FAI)" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:86 +# unordered list +msgid "* `import ... as ...` syntax." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:88 +msgid " This syntax is commonly used in the scientific Python community;\n" +" it is explicitly recommended in documentation to `import numpy as np`\n" +" and `import matplotlib.pyplot as plt`. Despite that, we have decided\n" +" not to introduce aliasing imports in this novice lesson due to the\n" +" additional cognitive load it puts on students, despite the typing that\n" +" it saves. A good summary of arguments for and against can be found in\n" +" [PR #61](https://github.com/swcarpentry/python-novice-inflammation/pull/61)." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:96 +msgid " It is up to you as an individual instructor whether you want to introduce\n" +" these aliases when you teach this lesson, but we encourage you to please\n" +" read those arguments thoroughly before deciding one way or the other." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:100 +# unordered list +msgid "* NumPy methods." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:102 +msgid " We used to use NumPy array methods in the first [NumPy topic]({{ page.root }}/01-numpy/).\n" +" We switched these methods to the equivalent functions because a majority\n" +" of instructors supported the change; see\n" +" [PR #244](https://github.com/swcarpentry/python-novice-inflammation/pull/244)\n" +" for detailed arguments for and against the change." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:108 +# unordered list +msgid "* Underscores vs. hyphens in filenames" +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:110 +msgid " We used to use hyphens in filenames in order to signify that these Python\n" +" files should only be run as scripts and never imported. However, after some\n" +" [discussion](https://github.com/swcarpentry/python-novice-inflammation/pull/254),\n" +" including an informal Twitter poll, we switched over to underscores because\n" +" many files that start off as Python scripts end up being imported eventually.\n" +" For that reason, we also added `if __name__ == '__main__'` guards around\n" +" `main()` calls, which is how real-world Python scripts ensure that imports\n" +" do not result in side-effects." +msgstr "" + +#: python-novice-inflammation/_extras/guide.md:119 +msgid "After discussing the challenges is a good time to introduce the `b *= 2` syntax." +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/22__aio-script.md.ja.po b/transifex/python-novice-inflammation/po/22__aio-script.md.ja.po new file mode 100644 index 00000000..9bcaed56 --- /dev/null +++ b/transifex/python-novice-inflammation/po/22__aio-script.md.ja.po @@ -0,0 +1,60 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_includes/aio-script.md:1 +#: python-novice-inflammation/aio.md:5 +msgid "{% comment %}\n" +"As a maintainer, you don't need to edit this file.\n" +"If you notice that something doesn't work, please\n" +"open an issue: https://github.com/carpentries/styles/issues/new\n" +"{% endcomment %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:7 +msgid "{% include manual_episode_order.html %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:9 +msgid "{% for lesson_episode in lesson_episodes %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:11 +msgid "{% if site.episode_order %}\n" +" {% assign e = site.episodes | where: \"slug\", lesson_episode | first %}\n" +"{% else %}\n" +" {% assign e = lesson_episode %}\n" +"{% endif %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:17 +msgid "

{{ e.title }}

" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:19 +msgid "{% include episode_overview.html teaching_time=e.teaching exercise_time=e.exercises episode_questions=e.questions episode_objectives=e.objectives %}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:21 +msgid "{{ e.content }}" +msgstr "" + +#: python-novice-inflammation/_includes/aio-script.md:23 +msgid "{% include episode_keypoints.html episode_keypoints=e.keypoints %}\n" +"
\n" +"{% endfor %}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/23__links.md.ja.po b/transifex/python-novice-inflammation/po/23__links.md.ja.po new file mode 100644 index 00000000..4baef972 --- /dev/null +++ b/transifex/python-novice-inflammation/po/23__links.md.ja.po @@ -0,0 +1,69 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/_includes/links.md:1 +msgid "{% include base_path.html %}\n" +"[cc-by-human]: https://creativecommons.org/licenses/by/4.0/\n" +"[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode\n" +"[ci]: http://communityin.org/\n" +"[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html\n" +"[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html\n" +"[concept-maps]: https://carpentries.github.io/instructor-training/05-memory/\n" +"[contrib-covenant]: https://contributor-covenant.org/\n" +"[contributing]: {{ repo_url }}/blob/{{ source_branch }}/CONTRIBUTING.md\n" +"[cran-checkpoint]: https://cran.r-project.org/package=checkpoint\n" +"[cran-knitr]: https://cran.r-project.org/package=knitr\n" +"[cran-stringr]: https://cran.r-project.org/package=stringr\n" +"[dc-lessons]: http://www.datacarpentry.org/lessons/\n" +"[email]: mailto:team@carpentries.org\n" +"[github-importer]: https://import.github.com/\n" +"[importer]: https://github.com/new/import\n" +"[jekyll-collection]: https://jekyllrb.com/docs/collections/\n" +"[jekyll-install]: https://jekyllrb.com/docs/installation/\n" +"[jekyll-windows]: http://jekyll-windows.juthilo.com/\n" +"[jekyll]: https://jekyllrb.com/\n" +"[jupyter]: https://jupyter.org/\n" +"[kramdown]: https://kramdown.gettalong.org/\n" +"[lc-lessons]: https://librarycarpentry.org/lessons/\n" +"[lesson-aio]: {{ relative_root_path }}{% link aio.md %}\n" +"[lesson-coc]: {{ relative_root_path }}{% link CODE_OF_CONDUCT.md %}\n" +"[lesson-example]: https://carpentries.github.io/lesson-example/\n" +"[lesson-license]: {{ relative_root_path }}{% link LICENSE.md %}\n" +"[lesson-mainpage]: {{ relative_root_path }}{% link index.md %}\n" +"[lesson-reference]: {{ relative_root_path }}{% link reference.md %}\n" +"[lesson-setup]: {{ relative_root_path }}{% link setup.md %}\n" +"[mit-license]: https://opensource.org/licenses/mit-license.html\n" +"[morea]: https://morea-framework.github.io/\n" +"[numfocus]: https://numfocus.org/\n" +"[osi]: https://opensource.org\n" +"[pandoc]: https://pandoc.org/\n" +"[paper-now]: https://github.com/PeerJ/paper-now\n" +"[python-gapminder]: https://swcarpentry.github.io/python-novice-gapminder/\n" +"[pyyaml]: https://pypi.org/project/PyYAML/\n" +"[r-markdown]: https://rmarkdown.rstudio.com/\n" +"[rstudio]: https://www.rstudio.com/\n" +"[ruby-install-guide]: https://www.ruby-lang.org/en/downloads/\n" +"[ruby-installer]: https://rubyinstaller.org/\n" +"[rubygems]: https://rubygems.org/pages/download/\n" +"[styles]: https://github.com/carpentries/styles/\n" +"[swc-lessons]: https://software-carpentry.org/lessons/\n" +"[swc-releases]: https://github.com/swcarpentry/swc-releases\n" +"[training]: https://carpentries.github.io/instructor-training/\n" +"[workshop-repo]: {{ site.workshop_repo }}\n" +"[yaml]: http://yaml.org/" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/24__aio.md.ja.po b/transifex/python-novice-inflammation/po/24__aio.md.ja.po new file mode 100644 index 00000000..cffac14d --- /dev/null +++ b/transifex/python-novice-inflammation/po/24__aio.md.ja.po @@ -0,0 +1,32 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/aio.md:1 +# Front Matter +msgid "---\n" +"permalink: /aio/index.html\n" +"---" +msgstr "" + +#: python-novice-inflammation/aio.md:11 +msgid "{% include base_path.html %}" +msgstr "" + +#: python-novice-inflammation/aio.md:13 +msgid "{% include aio-script.md %}" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/25__01-introduction.md.ja.po b/transifex/python-novice-inflammation/po/25__01-introduction.md.ja.po new file mode 100644 index 00000000..5f94d587 --- /dev/null +++ b/transifex/python-novice-inflammation/po/25__01-introduction.md.ja.po @@ -0,0 +1,40 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/bin/boilerplate/_episodes/01-introduction.md:1 +# Front Matter +msgid "---\n" +"title: \"Introduction\"\n" +"teaching: 0\n" +"exercises: 0\n" +"questions:\n" +"- \"Key question (FIXME)\"\n" +"objectives:\n" +"- \"First learning objective. (FIXME)\"\n" +"keypoints:\n" +"- \"First key point. Brief Answer to questions. (FIXME)\"\n" +"---" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/_episodes/01-introduction.md:12 +#: python-novice-inflammation/bin/boilerplate/_extras/discuss.md:4 +#: python-novice-inflammation/bin/boilerplate/_extras/guide.md:4 +#: python-novice-inflammation/bin/boilerplate/reference.md:7 +#: python-novice-inflammation/bin/boilerplate/setup.md:4 +msgid "FIXME" +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/26__index.md.ja.po b/transifex/python-novice-inflammation/po/26__index.md.ja.po new file mode 100644 index 00000000..5b6c110f --- /dev/null +++ b/transifex/python-novice-inflammation/po/26__index.md.ja.po @@ -0,0 +1,151 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/bin/boilerplate/index.md:1 +# Front Matter +msgid "---\n" +"layout: lesson\n" +"root: . # Is the only page that doesn't follow the pattern /:path/index.html\n" +"permalink: index.html # Is the only page that doesn't follow the pattern /:path/index.html\n" +"---" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:6 +msgid "FIXME: home page introduction" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:8 +msgid "" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:10 +msgid "{% comment %} This is a comment in Liquid {% endcomment %}" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:12 +#: python-novice-inflammation/index.md:37 +# blockquote, which can be cascaded +msgid "> ## Prerequisites" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:13 +msgid ">\n" +"> FIXME" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/index.md:15 +#: python-novice-inflammation/index.md:44 +# SC/DC Template label +msgid "{: .prereq}" +msgstr "" + +#: python-novice-inflammation/index.md:1 +# Front Matter +msgid "---\n" +"layout: lesson\n" +"root: .\n" +"permalink: index.html\n" +"---" +msgstr "" + +#: python-novice-inflammation/index.md:7 +msgid "The best way to learn how to program is to do something useful,\n" +"so this introduction to Python is built around a common scientific task:\n" +"**data analysis**." +msgstr "" + +#: python-novice-inflammation/index.md:11 +# header +msgid "### Arthritis Inflammation" +msgstr "" + +#: python-novice-inflammation/index.md:12 +msgid "We are studying **inflammation in patients** who have been given a new treatment for arthritis, and\n" +"need to analyze the first dozen data sets of their daily inflammation. The data sets are stored in\n" +"[comma-separated values]({{ page.root }}/reference.html#comma-separated-values) (CSV) format:" +msgstr "" + +#: python-novice-inflammation/index.md:16 +# unordered list +msgid "- each row holds information for a single patient," +msgstr "" + +#: python-novice-inflammation/index.md:17 +# unordered list +msgid "- columns represent successive days." +msgstr "" + +#: python-novice-inflammation/index.md:19 +msgid "The first three rows of our first file look like this:\n" +"~~~\n" +"0,0,1,3,1,2,4,7,8,3,3,3,10,5,7,4,7,7,12,18,6,13,11,11,7,7,4,6,8,8,4,4,5,7,3,4,2,3,0,0\n" +"0,1,2,1,2,1,3,2,2,6,10,11,5,9,4,4,7,16,8,6,18,4,12,5,12,7,11,5,11,3,3,5,4,4,5,5,1,1,0,1\n" +"0,1,1,3,3,2,6,2,5,9,5,7,4,5,4,15,5,11,9,10,19,14,12,17,7,12,11,7,4,2,10,5,4,2,2,3,2,2,1,1\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/index.md:25 +#: python-novice-inflammation/setup.md:118 +#: python-novice-inflammation/setup.md:128 +#: python-novice-inflammation/setup.md:134 +# SC/DC Template label +msgid "{: .source}" +msgstr "" + +#: python-novice-inflammation/index.md:26 +msgid "Each number represents the number of inflammation bouts that a particular patient experienced on a\n" +"given day. For example, value \"6\" at row 3 column 7 of the data set above means that the third\n" +"patient was experiencing inflammation six times on the seventh day of the clinical study." +msgstr "" + +#: python-novice-inflammation/index.md:30 +msgid "So, we want to:" +msgstr "" + +#: python-novice-inflammation/index.md:32 +# ordered list +msgid "1. Calculate the average inflammation per day across all patients." +msgstr "" + +#: python-novice-inflammation/index.md:33 +# ordered list +msgid "2. Plot the result to discuss and share with colleagues." +msgstr "" + +#: python-novice-inflammation/index.md:35 +msgid "To do all that, we'll have to learn a little bit about programming." +msgstr "" + +#: python-novice-inflammation/index.md:38 +msgid ">\n" +"> You need to understand the concepts of **files** and **directories** and how to start a Python\n" +"> interpreter before tackling this lesson. This lesson sometimes references Jupyter\n" +"> Notebook although you can use any Python interpreter mentioned in the [Setup][lesson-setup].\n" +">\n" +"> The commands in this lesson pertain to **Python 3**." +msgstr "" + +#: python-novice-inflammation/index.md:46 +# header +msgid "### Getting Started" +msgstr "" + +#: python-novice-inflammation/index.md:47 +msgid "To get started, follow the directions on the \"[Setup][lesson-setup]\" page to download data\n" +"and install a Python interpreter." +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/27__reference.md.ja.po b/transifex/python-novice-inflammation/po/27__reference.md.ja.po new file mode 100644 index 00000000..3681005d --- /dev/null +++ b/transifex/python-novice-inflammation/po/27__reference.md.ja.po @@ -0,0 +1,441 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/bin/boilerplate/reference.md:1 +#: python-novice-inflammation/reference.md:1 +# Front Matter +msgid "---\n" +"layout: reference\n" +"---" +msgstr "" + +#: python-novice-inflammation/bin/boilerplate/reference.md:5 +#: python-novice-inflammation/reference.md:5 +# header +msgid "## Glossary" +msgstr "" + +#: python-novice-inflammation/reference.md:7 +msgid "{:auto_ids}\n" +"additive color model\n" +": A way to represent colors as the sum of contributions from primary colors\n" +" such as [red, green, and blue](#rgb)." +msgstr "" + +#: python-novice-inflammation/reference.md:12 +msgid "argument\n" +": A value given to a function or program when it runs.\n" +" The term is often used interchangeably (and inconsistently) with [parameter](#parameter)." +msgstr "" + +#: python-novice-inflammation/reference.md:16 +msgid "assertion\n" +": An expression which is supposed to be true at a particular point in a program.\n" +" Programmers typically put assertions in their code to check for errors;\n" +" if the assertion fails (i.e., if the expression evaluates as false),\n" +" the program halts and produces an error message.\n" +" See also: [invariant](#invariant), [precondition](#precondition),\n" +" [postcondition](#postcondition)." +msgstr "" + +#: python-novice-inflammation/reference.md:24 +msgid "assign\n" +": To give a value a name by associating a variable with it." +msgstr "" + +#: python-novice-inflammation/reference.md:27 +msgid "body\n" +": (of a function): the statements that are executed when a function runs." +msgstr "" + +#: python-novice-inflammation/reference.md:30 +msgid "call stack\n" +": A data structure inside a running program that keeps track of active function calls." +msgstr "" + +#: python-novice-inflammation/reference.md:33 +msgid "case-insensitive\n" +": Treating text as if upper and lower case characters of the same letter were the same.\n" +" See also: [case-sensitive](#case-sensitive)." +msgstr "" + +#: python-novice-inflammation/reference.md:37 +msgid "case-sensitive\n" +": Treating text as if upper and lower case characters of the same letter are different.\n" +" See also: [case-insensitive](#case-insensitive)." +msgstr "" + +#: python-novice-inflammation/reference.md:41 +msgid "comment\n" +": A remark in a program that is intended to help human readers understand what is going on,\n" +" but is ignored by the computer.\n" +" Comments in Python, R, and the Unix shell start with a `#` character and\n" +" run to the end of the line;\n" +" comments in SQL start with `--`,\n" +" and other languages have other conventions." +msgstr "" + +#: python-novice-inflammation/reference.md:49 +msgid "compose\n" +": To apply one function to the result of another, such as `f(g(x))`." +msgstr "" + +#: python-novice-inflammation/reference.md:52 +msgid "conditional statement\n" +": A statement in a program that might or might not be executed\n" +" depending on whether a test is true or false." +msgstr "" + +#: python-novice-inflammation/reference.md:56 +msgid "comma-separated values\n" +": (CSV) A common textual representation for tables\n" +" in which the values in each row are separated by commas." +msgstr "" + +#: python-novice-inflammation/reference.md:60 +msgid "default value\n" +": A value to use for a [parameter](#parameter) if nothing is specified explicitly." +msgstr "" + +#: python-novice-inflammation/reference.md:63 +msgid "defensive programming\n" +": The practice of writing programs that check their own operation\n" +" to catch errors as early as possible." +msgstr "" + +#: python-novice-inflammation/reference.md:67 +msgid "delimiter\n" +": A character or characters used to separate individual values,\n" +" such as the commas between columns in a [CSV](#comma-separated-values) file." +msgstr "" + +#: python-novice-inflammation/reference.md:71 +msgid "docstring\n" +": Short for \"documentation string\",\n" +" this refers to textual documentation embedded in Python programs.\n" +" Unlike comments, docstrings are preserved in the running program\n" +" and can be examined in interactive sessions." +msgstr "" + +#: python-novice-inflammation/reference.md:77 +msgid "documentation\n" +": Human-language text written to explain what software does,\n" +" how it works, or how to use it." +msgstr "" + +#: python-novice-inflammation/reference.md:81 +msgid "dotted notation\n" +": A two-part notation used in many programming languages\n" +" in which `thing.component` refers to the `component` belonging to `thing`." +msgstr "" + +#: python-novice-inflammation/reference.md:85 +msgid "empty string\n" +": A character string containing no characters,\n" +" often thought of as the \"zero\" of text." +msgstr "" + +#: python-novice-inflammation/reference.md:89 +msgid "encapsulation\n" +": The practice of hiding something's implementation details\n" +" so that the rest of a program can worry about *what* it does\n" +" rather than *how* it does it." +msgstr "" + +#: python-novice-inflammation/reference.md:94 +msgid "floating-point number\n" +": A number containing a fractional part and an exponent.\n" +" See also: [integer](#integer)." +msgstr "" + +#: python-novice-inflammation/reference.md:98 +msgid "for loop\n" +": A loop that is executed once for each value in some kind of set, list, or range.\n" +" See also: [while loop](#while-loop)." +msgstr "" + +#: python-novice-inflammation/reference.md:102 +msgid "function\n" +": A named group of instructions that is executed when the function's name is used in\n" +" the code. Occurrence of a function name in the code is a [function call](#function-call).\n" +" Functions may process input [arguments](#argument) and return the result back. Functions\n" +" may also be used for logically grouping together pieces of code. In such cases, they don't\n" +" need to return any meaningful value and can be written without the\n" +" [`return` statement](#return-statement) completely.\n" +" Such functions return a special value `None`, which is a way of saying \"nothing\" in Python." +msgstr "" + +#: python-novice-inflammation/reference.md:111 +msgid "function call\n" +": A use of a function in another piece of software." +msgstr "" + +#: python-novice-inflammation/reference.md:114 +msgid "heat map\n" +": A graphical representation of two-dimensional data in which colors,\n" +" ranging on a scale of hue or intensity, represent the data values." +msgstr "" + +#: python-novice-inflammation/reference.md:118 +msgid "immutable\n" +": Unchangeable.\n" +" The value of immutable data cannot be altered after it has been created.\n" +" See also: [mutable](#mutable)." +msgstr "" + +#: python-novice-inflammation/reference.md:123 +msgid "import\n" +": To load a [library](#library) into a program." +msgstr "" + +#: python-novice-inflammation/reference.md:126 +msgid "in-place operators\n" +": An operator such as `+=` that provides a shorthand notation for\n" +" the common case in which the variable being assigned to\n" +" is also an operand on the right hand side of the assignment.\n" +" For example, the statement `x += 3` means the same thing as `x = x + 3`." +msgstr "" + +#: python-novice-inflammation/reference.md:132 +msgid "index\n" +": A subscript that specifies the location of a single value in a collection,\n" +" such as a single pixel in an image." +msgstr "" + +#: python-novice-inflammation/reference.md:136 +msgid "inner loop\n" +": A loop that is inside another loop. See also: [outer loop](#outer-loop)." +msgstr "" + +#: python-novice-inflammation/reference.md:139 +msgid "integer\n" +": A whole number, such as -12343. See also: [floating-point number](#floating-point-number)." +msgstr "" + +#: python-novice-inflammation/reference.md:142 +msgid "invariant\n" +": An expression whose value doesn't change during the execution of a program,\n" +" typically used in an [assertion](#assertion).\n" +" See also: [precondition](#precondition), [postcondition](#postcondition)." +msgstr "" + +#: python-novice-inflammation/reference.md:147 +msgid "library\n" +": A family of code units (functions, classes, variables) that implement a set of\n" +" related tasks." +msgstr "" + +#: python-novice-inflammation/reference.md:151 +msgid "loop variable\n" +": The variable that keeps track of the progress of the loop." +msgstr "" + +#: python-novice-inflammation/reference.md:154 +msgid "member\n" +": A variable contained within an [object](#object)." +msgstr "" + +#: python-novice-inflammation/reference.md:157 +msgid "method\n" +": A function which is tied to a particular [object](#object).\n" +" Each of an object's methods typically implements one of the things it can do,\n" +" or one of the questions it can answer." +msgstr "" + +#: python-novice-inflammation/reference.md:162 +msgid "mutable\n" +": Changeable. The value of mutable data can be altered after it has been\n" +" created. See [immutable](#immutable).\"" +msgstr "" + +#: python-novice-inflammation/reference.md:166 +msgid "notebook\n" +": Interactive computational environment accessed via your web browser, in which you can write\n" +" and execute Python code and combine it with explanatory text, mathematics and visualizations.\n" +" Examples are IPython or Jupyter notebooks." +msgstr "" + +#: python-novice-inflammation/reference.md:171 +msgid "object\n" +": A collection of conceptually related variables ([members](#member)) and\n" +" functions using those variables ([methods](#method))." +msgstr "" + +#: python-novice-inflammation/reference.md:175 +msgid "outer loop\n" +": A loop that contains another loop.\n" +" See also: [inner loop](#inner-loop)." +msgstr "" + +#: python-novice-inflammation/reference.md:179 +msgid "parameter\n" +": A variable named in the function's declaration that is used to\n" +" hold a value passed into the call.\n" +" The term is often used interchangeably (and inconsistently) with [argument](#argument)." +msgstr "" + +#: python-novice-inflammation/reference.md:184 +msgid "pipe\n" +": A connection from the output of one program to the input of another.\n" +" When two or more programs are connected in this way, they are called a \"pipeline\"." +msgstr "" + +#: python-novice-inflammation/reference.md:188 +msgid "postcondition\n" +": A condition that a function (or other block of code) guarantees is true\n" +" once it has finished running.\n" +" Postconditions are often represented using [assertions](#assertion)." +msgstr "" + +#: python-novice-inflammation/reference.md:193 +msgid "precondition\n" +": A condition that must be true in order for a function (or other block of code)\n" +" to run correctly." +msgstr "" + +#: python-novice-inflammation/reference.md:197 +msgid "regression\n" +": To re-introduce a bug that was once fixed." +msgstr "" + +#: python-novice-inflammation/reference.md:200 +msgid "return statement\n" +": A statement that causes a function to stop executing and return a value\n" +" to its caller immediately." +msgstr "" + +#: python-novice-inflammation/reference.md:204 +msgid "RGB\n" +": An [additive model](#additive-color-model)\n" +" that represents colors as combinations of red, green, and blue.\n" +" Each color's value is typically in the range 0..255\n" +" (i.e., a one-byte integer)." +msgstr "" + +#: python-novice-inflammation/reference.md:210 +msgid "sequence\n" +": A collection of information that is presented in a specific order.\n" +" For example, in Python, a [string](#string) is a sequence of characters,\n" +" while a list is a sequence of any variable." +msgstr "" + +#: python-novice-inflammation/reference.md:215 +msgid "shape\n" +": An array's dimensions, represented as a vector.\n" +" For example, a 5×3 array's shape is `(5,3)`." +msgstr "" + +#: python-novice-inflammation/reference.md:219 +msgid "silent failure\n" +": Failing without producing any warning messages.\n" +" Silent failures are hard to detect and debug." +msgstr "" + +#: python-novice-inflammation/reference.md:223 +msgid "slice\n" +": A regular subsequence of a larger sequence,\n" +" such as the first five elements or every second element." +msgstr "" + +#: python-novice-inflammation/reference.md:227 +msgid "stack frame\n" +": A data structure that provides storage for a function's local variables.\n" +" Each time a function is called, a new stack frame is created\n" +" and put on the top of the [call stack](#call-stack). When the function returns,\n" +" the stack frame is discarded." +msgstr "" + +#: python-novice-inflammation/reference.md:233 +msgid "standard input\n" +": A process's default input stream.\n" +" In interactive command-line applications,\n" +" it is typically connected to the keyboard; in a [pipe](#pipe),\n" +" it receives data from the [standard output](#standard-output) of the preceding process." +msgstr "" + +#: python-novice-inflammation/reference.md:239 +msgid "standard output\n" +": A process's default output stream.\n" +" In interactive command-line applications,\n" +" data sent to standard output is displayed on the screen;\n" +" in a [pipe](#pipe),\n" +" it is passed to the [standard input](#standard-input) of the next process." +msgstr "" + +#: python-novice-inflammation/reference.md:246 +msgid "string\n" +": Short for \"character string\",\n" +" a [sequence](#sequence) of zero or more characters." +msgstr "" + +#: python-novice-inflammation/reference.md:250 +msgid "syntax\n" +": The rules that define how code must be written for a computer to understand." +msgstr "" + +#: python-novice-inflammation/reference.md:253 +msgid "syntax error\n" +": A programming error that occurs when statements are in an order or contain characters\n" +" not expected by the programming language." +msgstr "" + +#: python-novice-inflammation/reference.md:257 +msgid "test oracle\n" +": A program, device, data set, or human being\n" +" against which the results of a test can be compared." +msgstr "" + +#: python-novice-inflammation/reference.md:261 +msgid "test-driven development\n" +": The practice of writing unit tests *before* writing the code they test." +msgstr "" + +#: python-novice-inflammation/reference.md:264 +msgid "traceback\n" +": The sequence of function calls that led to an error." +msgstr "" + +#: python-novice-inflammation/reference.md:267 +msgid "tuple\n" +": An [immutable](#immutable) [sequence](#sequence) of values." +msgstr "" + +#: python-novice-inflammation/reference.md:270 +msgid "type\n" +": The classification of something in a program (for example, the contents of a variable)\n" +" as a kind of number (e.g. [floating-point](#float), [integer](#integer)),\n" +" [string](#string), or something else." +msgstr "" + +#: python-novice-inflammation/reference.md:275 +msgid "type of error\n" +": Indicates the nature of an error in a program. For example, in Python,\n" +" an `IOError` to problems with file input/output.\n" +" See also: [syntax error](#syntax-error)." +msgstr "" + +#: python-novice-inflammation/reference.md:280 +msgid "variable\n" +": A value that has a name associated with it." +msgstr "" + +#: python-novice-inflammation/reference.md:283 +msgid "while loop\n" +": A loop that keeps executing as long as some condition is true.\n" +" See also: [for loop](#for-loop)." +msgstr "" + diff --git a/transifex/python-novice-inflammation/po/28__setup.md.ja.po b/transifex/python-novice-inflammation/po/28__setup.md.ja.po new file mode 100644 index 00000000..89513100 --- /dev/null +++ b/transifex/python-novice-inflammation/po/28__setup.md.ja.po @@ -0,0 +1,232 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: i18n\n" +"Report-Msgid-Bugs-To: https://github.com/haiwen/seafile-docs/issues\n" +"POT-Creation-Date: 2020-12-11 17:59:01+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: python-novice-inflammation/bin/boilerplate/setup.md:1 +#: python-novice-inflammation/setup.md:1 +# Front Matter +msgid "---\n" +"title: Setup\n" +"---" +msgstr "" + +#: python-novice-inflammation/setup.md:5 +# header +msgid "## Overview" +msgstr "" + +#: python-novice-inflammation/setup.md:7 +msgid "This lesson is designed to be run on a personal computer.\n" +"All of the software and data used in this lesson are freely available online,\n" +"and instructions on how to obtain them are provided below." +msgstr "" + +#: python-novice-inflammation/setup.md:11 +# header +msgid "## Install Python" +msgstr "" + +#: python-novice-inflammation/setup.md:13 +msgid "In this lesson, we will be using Python 3 with some of its most popular scientific libraries.\n" +"Although one can install a plain-vanilla Python and all required libraries by hand,\n" +"we recommend installing [Anaconda][anaconda-website],\n" +"a Python distribution that comes with everything we need for the lesson.\n" +"Detailed installation instructions for various operating systems can be found\n" +"on The Carpentries [template website for workshops][anaconda-instructions]\n" +"and in [Anaconda documentation][anaconda-install]." +msgstr "" + +#: python-novice-inflammation/setup.md:21 +# header +msgid "## Obtain lesson materials" +msgstr "" + +#: python-novice-inflammation/setup.md:23 +# ordered list +msgid "1. Download [python-novice-inflammation-data.zip][zipfile1]" +msgstr "" + +#: python-novice-inflammation/setup.md:24 +msgid " and [python-novice-inflammation-code.zip][zipfile2].\n" +"2. Create a folder called `swc-python` on your Desktop.\n" +"3. Move downloaded files to `swc-python`.\n" +"4. Unzip the files." +msgstr "" + +#: python-novice-inflammation/setup.md:29 +msgid "You should see two folders called `data` and `code` in the `swc-python` directory on your\n" +"Desktop." +msgstr "" + +#: python-novice-inflammation/setup.md:32 +# header +msgid "## Launch Python interface" +msgstr "" + +#: python-novice-inflammation/setup.md:34 +msgid "To start working with Python, we need to launch a program that will interpret and execute our Python\n" +"commands. Below we list several options. If you don't have a preference, proceed with the top\n" +"option in the list that is available on your machine. Otherwise, you may use any interface you like." +msgstr "" + +#: python-novice-inflammation/setup.md:38 +# header +msgid "## Option A: Jupyter Notebook" +msgstr "" + +#: python-novice-inflammation/setup.md:40 +msgid "A Jupyter Notebook provides a browser-based interface for working with Python.\n" +"If you installed Anaconda, you can launch a notebook in two ways:" +msgstr "" + +#: python-novice-inflammation/setup.md:43 +# blockquote, which can be cascaded +msgid "> ## Anaconda Navigator" +msgstr "" + +#: python-novice-inflammation/setup.md:44 +msgid ">\n" +"> 1. Launch Anaconda Navigator.\n" +"> It might ask you if you'd like to send anonymized usage information to Anaconda developers:\n" +"> ![Anaconda Navigator first launch]({{ page.root }}{% link fig/anaconda-navigator-first-launch.png %})\n" +"> Make your choice and click \"Ok, and don't show again\" button.\n" +"> 2. Find the \"Notebook\" tab and click on the \"Launch\" button:\n" +"> ![Anaconda Navigator Notebook launch]({{ page.root }}{% link fig/anaconda-navigator-notebook-launch.png %})\n" +"> Anaconda will open a new browser window or tab with a Notebook Dashboard showing you the\n" +"> contents of your Home (or User) folder.\n" +"> 3. Navigate to the `data` directory by clicking on the directory names leading to it:\n" +"> `Desktop`, `swc-python`, then `data`:\n" +"> ![Anaconda Navigator Notebook directory]({{ page.root }}{% link fig/jupyter-notebook-data-directory.png %})\n" +"> 4. Launch the notebook by clicking on the \"New\" button and then selecting \"Python 3\":\n" +"> ![Anaconda Navigator Notebook directory]({{ page.root }}{% link fig/jupyter-notebook-launch-notebook.png %})" +msgstr "" + +#: python-novice-inflammation/setup.md:58 +#: python-novice-inflammation/setup.md:103 +# SC/DC Template label +msgid "{: .solution}" +msgstr "" + +#: python-novice-inflammation/setup.md:60 +# blockquote, which can be cascaded +msgid "> ## Command line (Terminal)" +msgstr "" + +#: python-novice-inflammation/setup.md:61 +msgid ">\n" +"> 1\\. Navigate to the `data` directory:\n" +">\n" +"> > ## Unix shell\n" +"> > If you're using a Unix shell application, such as Terminal app in macOS, Console or Terminal\n" +"> > in Linux, or [Git Bash][gitbash] on Windows, execute the following command:\n" +"> > ~~~\n" +"> > cd ~/Desktop/swc-python/data\n" +"> > ~~~\n" +"> > {: .language-bash}" +msgstr "" + +#: python-novice-inflammation/setup.md:72 +msgid ">\n" +"> > ## Command Prompt (Windows)\n" +"> > On Windows, you can use its native Command Prompt program. The easiest way to start it up is\n" +"> > pressing Windows Logo Key+R, entering `cmd`, and hitting\n" +"> > Return. In the Command Prompt, use the following command to navigate to\n" +"> > the `data` folder:\n" +"> > ~~~\n" +"> > cd /D %userprofile%\\Desktop\\swc-python\\data\n" +"> > ~~~\n" +"> > {: .source}" +msgstr "" + +#: python-novice-inflammation/setup.md:83 +msgid ">\n" +"> 2\\. Start Jupyter server\n" +">\n" +"> > ## Unix shell\n" +"> > ~~~\n" +"> > jupyter notebook\n" +"> > ~~~\n" +"> > {: .language-bash}" +msgstr "" + +#: python-novice-inflammation/setup.md:92 +msgid ">\n" +"> > ## Command Prompt (Windows)\n" +"> > ~~~\n" +"> > python -m notebook\n" +"> > ~~~\n" +"> > {: .source}" +msgstr "" + +#: python-novice-inflammation/setup.md:99 +msgid ">\n" +"> 3\\. Launch the notebook by clicking on the \"New\" button on the right and selecting \"Python 3\"\n" +"> from the drop-down menu:\n" +"> ![Anaconda Navigator Notebook directory]({{ page.root }}{% link fig/jupyter-notebook-launch-notebook2.png %})" +msgstr "" + +#: python-novice-inflammation/setup.md:105 +#: python-novice-inflammation/setup.md:120 +msgid "  " +msgstr "" + +#: python-novice-inflammation/setup.md:107 +# header +msgid "## Option B: IPython interpreter" +msgstr "" + +#: python-novice-inflammation/setup.md:109 +msgid "IPython is an alternative solution situated somewhere in between the plain-vanilla Python\n" +"interpreter and Jupyter Notebook. It provides an interactive command-line based interpreter with\n" +"various convenience features and commands. You should have IPython on your system if you installed\n" +"[Anaconda][anaconda-instructions]." +msgstr "" + +#: python-novice-inflammation/setup.md:114 +msgid "To start using IPython, execute:\n" +"~~~\n" +"ipython\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/setup.md:122 +# header +msgid "## Option C: plain-vanilla Python interpreter" +msgstr "" + +#: python-novice-inflammation/setup.md:124 +msgid "To launch a plain-vanilla Python interpreter, execute:\n" +"~~~\n" +"python\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/setup.md:130 +msgid "If you are using [Git Bash on Windows][gitbash], you have to call Python _via_ `winpty`:\n" +"~~~\n" +"winpty python\n" +"~~~" +msgstr "" + +#: python-novice-inflammation/setup.md:136 +msgid "[anaconda-install]: https://docs.anaconda.com/anaconda/install\n" +"[anaconda-instructions]: https://carpentries.github.io/workshop-template/#python\n" +"[anaconda-website]: https://www.anaconda.com/\n" +"[gitbash]: https://gitforwindows.org\n" +"[zipfile1]: {{ page.root }}/data/python-novice-inflammation-data.zip\n" +"[zipfile2]: {{ page.root }}/code/python-novice-inflammation-code.zip" +msgstr "" +