User Tools

Site Tools


other:python:jyp_steps

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
other:python:jyp_steps [2016/01/22 17:02]
jypeter More changes
other:python:jyp_steps [2016/01/29 15:41]
jypeter Added the numpy for matlab users references
Line 1: Line 1:
-====== ​Following ​JYP's recommended steps ======+====== JYP's recommended steps for learning python ​======
  
 As can be expected, there is **a lot** of online python documentation available, and it's easy to get lost. You can always use google to find an answer to your problem, and you will probably end up looking at lots of answers on [[http://​stackoverflow.com/​questions/​tagged/​python|Stack Overflow]] or a similar site. But it's always better to know where you can find some good documentation... and to spend some time to read the documentation As can be expected, there is **a lot** of online python documentation available, and it's easy to get lost. You can always use google to find an answer to your problem, and you will probably end up looking at lots of answers on [[http://​stackoverflow.com/​questions/​tagged/​python|Stack Overflow]] or a similar site. But it's always better to know where you can find some good documentation... and to spend some time to read the documentation
Line 51: Line 51:
 How to get started? How to get started?
   - always remember that indices start at ''​0''​ and that the last element of an array is at index ''​-1''​!\\ First learn about //​indexing//​ and //slicing// by manipulating strings, as shown in [[#​part1|Part 1]] above (try '''​This document by JY is awesome!'​[::​-1]''​ and '''​This document by JY is awesome!'​[slice(None,​ None, -1)]''​) 8-)   - always remember that indices start at ''​0''​ and that the last element of an array is at index ''​-1''​!\\ First learn about //​indexing//​ and //slicing// by manipulating strings, as shown in [[#​part1|Part 1]] above (try '''​This document by JY is awesome!'​[::​-1]''​ and '''​This document by JY is awesome!'​[slice(None,​ None, -1)]''​) 8-)
 +  - if you are a Matlab user (but the references are interesting for others as well), you can read the following:
 +    - [[https://​docs.scipy.org/​doc/​numpy-dev/​user/​numpy-for-matlab-users.html|Numpy for Matlab users]]
 +    - [[http://​mathesaurus.sourceforge.net/​matlab-numpy.html|NumPy for MATLAB users]] (nice, but does not seem to be maintained any more)
   - read the [[https://​docs.scipy.org/​doc/​numpy-dev/​user/​quickstart.html|Quickstart tutorial]]   - read the [[https://​docs.scipy.org/​doc/​numpy-dev/​user/​quickstart.html|Quickstart tutorial]]
   - have a quick look at the full documentation to know where things are   - have a quick look at the full documentation to know where things are
Line 135: Line 138:
   * **make sure that your script is not using too much memory** (the amount depends on the computer you are using)! Your script should be scalable (e.g. keeps on working even when your data gets bigger), so it's a good idea to load only the data you need in memory (e.g. not all the time steps), and learn how to load chunks of data   * **make sure that your script is not using too much memory** (the amount depends on the computer you are using)! Your script should be scalable (e.g. keeps on working even when your data gets bigger), so it's a good idea to load only the data you need in memory (e.g. not all the time steps), and learn how to load chunks of data
  
-  * **make sure that you are using array/​vector syntax and masks**, instead of using explicit loops and tests. The numpy documentation is big, because there are lots of optimized functions to help you! If you are stuck, ask JY or somebody else who is used to numpy.+  * **make sure that you are using array/​vector syntax and masks**, instead of using explicit loops and tests. The [[#​numpy_and_scipy|numpy documentation]] is big, because there are lots of optimized functions to help you! If you are stuck, ask JY or somebody else who is used to numpy.
  
 If your script is still not fast enough, there is a lot you can do to improve it, without resorting to parallelization (that may introduce extra bugs rather that extra performance). See the sections below If your script is still not fast enough, there is a lot you can do to improve it, without resorting to parallelization (that may introduce extra bugs rather that extra performance). See the sections below
Line 149: Line 152:
  
 The official [[https://​docs.python.org/​2.7/​howto/​pyporting.html|Porting Python 2 Code to Python 3]] page gives the required information to make the transition from python 2 to python 3. It is still safe to use Python 2.7, so there is no rush to change to Python 3. The official [[https://​docs.python.org/​2.7/​howto/​pyporting.html|Porting Python 2 Code to Python 3]] page gives the required information to make the transition from python 2 to python 3. It is still safe to use Python 2.7, so there is no rush to change to Python 3.
 +
 +===== What now? =====
 +
 +You can do a lot more with python! But if you have read at least a part of this page, you should be able to find and use the modules you need. Make sure you do not reinvent the wheel! Use existing packages when possible, and make sure to report bugs or errors in the documentations when you find some
  
 /* standard page footer */ /* standard page footer */
other/python/jyp_steps.txt · Last modified: 2024/03/07 10:15 by jypeter