Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73361 > unrolled thread
| Started by | Maura E Monville <maura.monville@gmail.com> |
|---|---|
| First post | 2014-06-18 05:10 -0700 |
| Last post | 2014-06-18 12:11 -0700 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
python newbie Maura E Monville <maura.monville@gmail.com> - 2014-06-18 05:10 -0700
Re: python newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-18 12:50 +0000
Re: python newbie Maura E Monville <maura.monville@gmail.com> - 2014-06-18 05:57 -0700
Re: python newbie Jim Gibson <jimsgibson@gmail.com> - 2014-06-18 12:11 -0700
| From | Maura E Monville <maura.monville@gmail.com> |
|---|---|
| Date | 2014-06-18 05:10 -0700 |
| Subject | python newbie |
| Message-ID | <fa433710-0953-4b4a-96f6-2f7d1b9affb3@googlegroups.com> |
My supervisor has palmed me off with a python code, written by a collaborator, which implements an algorithm aimed at denoising the dose distribution (energy per unit mass) output from a radiation transport Monte Carlo code. My task is to translate the python code into a MatLab code. A colleague of mine and I stared at the python code for a while without understanding the logic. To me that code looks like Chinese or Arabian. I don't have clear ideas about the syntax and python variables. For instance, in MatLab there is the cell array storage type to host data of different type. I have no idea how a 3D matrix can be loaded through python. Does a debugger exist for python code ? Is there an easy concise user's manual ? Thank you in advance for any help. Regards, maura
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-06-18 12:50 +0000 |
| Message-ID | <53a18b2e$0$29988$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #73361 |
On Wed, 18 Jun 2014 05:10:03 -0700, Maura E Monville wrote: > My supervisor has palmed me off with a python code, written by a > collaborator, which implements an algorithm aimed at denoising the dose > distribution (energy per unit mass) output from a radiation transport > Monte Carlo code. My task is to translate the python code into a MatLab > code. A colleague of mine and I stared at the python code for a while > without understanding the logic. To me that code looks like Chinese or > Arabian. I don't have clear ideas about the syntax and python variables. > For instance, in MatLab there is the cell array storage type to host > data of different type. I have no idea how a 3D matrix can be loaded > through python. Does a debugger exist for python code ? Is there an easy > concise user's manual ? If you don't understand how to even read Python code, using a debugger isn't going to help you. Start by spending an hour or two to go through the tutorial, to get up to speed with the basic principles of the syntax: https://docs.python.org/2/tutorial/ If you're using Python 3, you should use this instead: https://docs.python.org/3/tutorial/ Although there aren't very many differences between the versions, when you're learning something for the first time, those differences can be perplexing. Once you've done that, you'll be better able to ask sensible questions about your code. Feel free to show us your code (especially snippets) if there is anything unclear. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Maura E Monville <maura.monville@gmail.com> |
|---|---|
| Date | 2014-06-18 05:57 -0700 |
| Message-ID | <d16e17c3-b2e4-4f08-9fb1-cb559a00228f@googlegroups.com> |
| In reply to | #73362 |
On Wednesday, June 18, 2014 1:50:54 PM UTC+1, Steven D'Aprano wrote: > On Wed, 18 Jun 2014 05:10:03 -0700, Maura E Monville wrote: > > > > > My supervisor has palmed me off with a python code, written by a > > > collaborator, which implements an algorithm aimed at denoising the dose > > > distribution (energy per unit mass) output from a radiation transport > > > Monte Carlo code. My task is to translate the python code into a MatLab > > > code. A colleague of mine and I stared at the python code for a while > > > without understanding the logic. To me that code looks like Chinese or > > > Arabian. I don't have clear ideas about the syntax and python variables. > > > For instance, in MatLab there is the cell array storage type to host > > > data of different type. I have no idea how a 3D matrix can be loaded > > > through python. Does a debugger exist for python code ? Is there an easy > > > concise user's manual ? > > > > > > If you don't understand how to even read Python code, using a debugger > > isn't going to help you. > > > > Start by spending an hour or two to go through the tutorial, to get up to > > speed with the basic principles of the syntax: > > > > https://docs.python.org/2/tutorial/ > > > > If you're using Python 3, you should use this instead: > > > > https://docs.python.org/3/tutorial/ > > > > > > Although there aren't very many differences between the versions, when > > you're learning something for the first time, those differences can be > > perplexing. > > > > Once you've done that, you'll be better able to ask sensible questions > > about your code. Feel free to show us your code (especially snippets) if > > there is anything unclear. > > > > > > > > -- > > Steven Thank you so much. I am pretty sure you'll have to put up with my naive questions for a while. The python code though is not long. Best regards, Maura
[toc] | [prev] | [next] | [standalone]
| From | Jim Gibson <jimsgibson@gmail.com> |
|---|---|
| Date | 2014-06-18 12:11 -0700 |
| Message-ID | <180620141211574594%jimsgibson@gmail.com> |
| In reply to | #73361 |
In article <fa433710-0953-4b4a-96f6-2f7d1b9affb3@googlegroups.com>, Maura E Monville <maura.monville@gmail.com> wrote: > My supervisor has palmed me off with a python code, written by a > collaborator, which implements an algorithm aimed at denoising the dose > distribution (energy per unit mass) output from a radiation transport Monte > Carlo code. > My task is to translate the python code into a MatLab code. Interestingly, I was recently given the task of translating a Matlab program into Python. Just the opposite of your problem. And I knew neither! > A colleague of mine and I stared at the python code for a while without > understanding the logic. > To me that code looks like Chinese or Arabian. > I don't have clear ideas about the syntax and python variables. For instance, > in MatLab there is the cell array storage type to host data of different > type. I have no idea how a 3D matrix can be loaded through python. Does the Python program use scipy and numpy modules? Those, in my short experience, provide the closest equivalent to Matlab matrices and functions. They allowed me to do almost a line-by-line translation of Matlab code into Python. The h5py module allows you to read and write Matlab "save" files in Python, too. Some of the differences between Matlab and Python: 1. Matlab array indexing starts at 1; Python starts at 0. 2. Matlab uses parentheses () for sequence indexing; Python uses brackets []. 3. Matlab arrays are column-major order; Numpy arrays are row-major order, Post Python code here or provide a link to code posted elsewhere for additional help. Good luck. -- Jim Gibson
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web