Re: how to install all python plugins
2010-07-15 18:18, Daniel Fetchinson skrev: If you mean all python packages that are available through the package manager of ubuntu, then you'll need to search the entire list of available packages using ubuntu's package manager, pick out the ones that have 'python' in their names (presumably, this is how it works on fedora) and install them using the above mentioned package manager software. To install all packages whose names start with python- in ubuntu: apt-get install python-* (as root, or prepended with sudo) / johan -- http://mail.python.org/mailman/listinfo/python-list
Re: Plot problem.. ?? No sign at all
Hi Ritchy, This is the first time I am doing this, but it's a standard response given on lists like this. 2010-07-13 18:17, Ritchy lelis skrev: This is how looks like the flash residue transference function that i was talking about... http://www.iadc.ca/Imran_ADC_tutorial_files/image048.gif I'm suposed to obtain a figure like that in my plot. From the hints you have been given, and your answers to those hints, my conclusion is that the issue is not with the programming, but with your understanding of the problem. I get the feeling you do not understand what you are trying to do, and therefore our programming hints do not help you. Based on the we will not do your homework-principle, I will therefore not read up on your theory, and therefore not produce your plot for you. That will not change until you show better understanding for the plot you are trying to generate. Regards Johan -- http://mail.python.org/mailman/listinfo/python-list
Re: Plot problem.. ?? No sign at all
2010-07-11 02:12, Ritchy lelis skrev: On 7 jul, 08:38, Johan Grönqvistjohan.gronqv...@gmail.com wrote: About the plot draw it's a curve that it's a set of points wich it's the result of the comput of the Vref and Vi together. I don't know if i had to make a break instruction (like in other's languages) after the If instructions if i want the else-condition to be executed? ... (do you have some sujestions?) I would have expected a code structure similar to this: (NOTE: This is a very inefficient solution, and not the one suggested earlier, but it is closer to the code snippet you posted originally, and it does produce a plot.) -- import numpy as np import matplotlib.pyplot as plt Vref = np.linspace(1,20, 100) Vi = np.linspace(1,10,100) for ref in Vref: # Loop over Vref and Vi for i in Vi: if i ref/4: # Compute V0 V0 = 2*i-ref elif (-ref/4) = ref and ref = ref/4: V0 = 2*i elif i -ref/4: V0 = 2*i+ref plt.plot(i, V0, .) # Plot one single point at x = i, y = V0 plt.show() # Display the plot in a window -- Anyway i have a picture of a tuturial that i found but in this forum i can't post it. That pic would show what a really want... Can you give a link? Relatively to the axis, the Vi takes the x-axis and the Vref takes the y-axis. To me this sound like you want to make a 3D-plot, as there is the x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis? As i said, i have a good 2 pic of a doc that has the information about this ADC that i'm developing. I looked on wikipedia http://en.wikipedia.org/wiki/Analog-to-digital_converter, and saw some figures. Is any of those similar to what you look for? I see that they have (Vi - Vref) on the x-axis, and the computed value on the y-axis. Regards Johan -- http://mail.python.org/mailman/listinfo/python-list
Re: Plot problem.. ?? No sign at all
2010-07-06 19:18, Ritchy lelis skrev: On 6 jul, 17:29, Alan G Isaacalan.is...@gmail.com wrote: Unfortunately I cannot make sense of the code you posted. Provide a detailed description in words (or psuedocode) of what you are trying to accomplish. Be very careful and detailed is you want a useful response. Alan Isaac hummm... ok, i will try to make that detailed description. I can tell you why I do not understand from your posted code what you are trying to do. Firstly, I do not understand if you are trying to plot a surface, a set of curves, or a curve, or just a set of points? In your posted code, the plot command is part of the else clause, and my guess is that you never intend the else-clause to be executed at all. In your code snippet you loop over two arrays (Vi and Vref), compute a scalar value V0, and all plot-commands you issue are of the form plot(V0). This will probably draw a line of one point (for each value in Vi and Vref), which may not be what you want, and if it draws anything at all, then all points will be drawn at the same x-value, which is also probably not what you want. Secondly, how are the Vi and Vref related to your axes? I assume you want to plot all values you compute for V0, but as a function of what? When I use the plot command, I usually give it (at least) two arguments, where the first is the x-axis, and the second is the y-axis. After I have understood those things, the next question would be about the maths relating the Vi and Vref values to the V0 values, but I do not think I will understand those until after the above points are explained clearer. I definitely think your english is not a problem here. Johan -- http://mail.python.org/mailman/listinfo/python-list
Re: python as pen and paper substitute
Manuel Graune skrev: To clarify, I just start an editor, write a file that might look something like this: -snip- code= a = 1 b = 2 c = 3 result = a + b exec(code) print(code) print(result =\t, result) print(result + c =\t, result + c) -snip-- and feed this to python. I do not understand your use-case, but as one way of performing the same task as the above code, without sacrificing syntax-highlighting, I would suggest: - from __future__ import with_statement import sys def print_source(): print sys.argv with open(sys.argv[0]) as file: for line in file: print line, a = 1 b = 2 c = 3 result = a + b print_source() print(result =\t, result) print(result + c =\t, result + c) Does that help towards a solution of your problem? / johan -- http://mail.python.org/mailman/listinfo/python-list
Re: python as pen and paper substitute
Manuel Graune skrev: Thanks for your reply. The output should 1) show manually selected python code and comments (whatever I think is important), 2) show selected results (final and intermediate) and 3) *not* show python code that for someone only interested in the calculation and the results (and probably not knowing python) would just be noise (e. g. import-statements, actual print()-functions, etc.). Here is my second attempt. This version introduces what I might optimistically call a very simple markup language in the code. Printing of source can selectively be turned on and off by inserting lines beginning with ## Ignore or ## Show into the source file. -- ## Ignore from __future__ import with_statement import sys def print_selected_source(): is_printing = True with open(sys.argv[0]) as file: for line in file: if line.startswith(## Ignore): is_printing = False elif line.startswith(## Show): is_printing = True elif is_printing: print line, ## Show a = 1 b = 2 c = 3 result = a + b ## Ignore print_selected_source() print(result =\t, result) print(result + c =\t, result + c) -- Is this getting closer? / johan -- http://mail.python.org/mailman/listinfo/python-list
Re: python as pen and paper substitute
Manuel Graune skrev: Manuel Graune manuel.gra...@koeln.de writes: Just as an additional example, let's assume I'd want to add the area of to circles. [...] which can be explained to anyone who knows basic math and is not at all interested in python. Third attempt. The markup now includes tagging of different parts of the code, and printing parts of the source based on a tag. (Sorry about the mixture of python 2.X and python 3.X print statements, I use 2.5) - ## Ignore from __future__ import with_statement import sys def print_selected_source(tag = ): is_printing = True with open(sys.argv[0]) as file: for line in file: if line.startswith(## Ignore): is_printing = False elif line.startswith(## Show) and tag in line: is_printing = True elif is_printing: print line, from math import pi as PI ## Show Code1 d1= 3.0 A1= d1**2 * PI / 4.0 ## Ignore print_selected_source(tag = Code1) print (Area of Circle 1:\t, A1) ## Show Code2 d2= 5.0 A2= d2**2 * PI / 4.0 ## Ignore print_selected_source(tag = Code2) print (Area of Circle 2:\t, A2) Sum_Of_Areas= A1 + A2 print (Sum of areas:\t, Sum_Of_Areas) - / johan -- http://mail.python.org/mailman/listinfo/python-list
Re: pylab/matplotlib large plot memory management - bug? or tuning parameter needed?
bdb112 skrev: Summary: It is not straightforward to avoid memory leaks/consumption in pylab. If we define x = arange(1e6) # adjust size to make the increment visible, yet fast enough to plot # then repetition of plot(x,hold=0) # consumes increasing memory according to ubuntu system monitor [...] I do not know what closing the window does, but in my programs, running on debian and opensuse, I found that explicitly calling close() solved my memory leaks with matplotlib. 3/ Are there python/matplotlib memory management tuning parameters I can tweak? You could try to import gc, and then call gc.collect() after each call to close(). docs at: http://docs.python.org/library/gc.html Hope it helps / johan -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating a local variable scope.
Thanks for all replies. First, two general comments, and then my conclusions: I did not intend to ask for new features, but my interest was in writing readable code that works in python 2.5, although I may upgrade to 2.6 soon. Also, what I gave was intended as a minimal example, and not a complete use case. Summarizing the answers, it seems that I will try to follow three suggestions: 1) In general, try to restructure the code into smaller modules and smaller functions. 2) When using many local variables bindings to create one larger object, define an inner function that hides those bindings. 3) If I define a few values intended to be used very locally, delete those after use. Thanks again, Johan -- http://mail.python.org/mailman/listinfo/python-list
Re: Shebang line problems and python
Blaine skrev: I'm not sure if there is a Ctrl+Z in here... but, here's the output: bla...@attila ~/tmp $ hexdump shebang-test 000 2123 752f 7273 622f 6e69 702f 7479 6f68 010 0a6e 6d69 6f70 7472 7320 7379 730a 7379 020 732e 6474 756f 2e74 7277 7469 2865 4822 030 6c65 6f6c 202c 6f77 6c72 2e64 6e5c 2922 040 000a 041 You can perhaps use hexdump -c shebang-test to get characters instead of hexadecimals. / johan -- http://mail.python.org/mailman/listinfo/python-list
Creating a local variable scope.
Hi All, I find several places in my code where I would like to have a variable scope that is smaller than the enclosing function/class/module definition. One representative example would look like: -- spam = { ... } eggs = { ... } ham = (a[eggs], b[spam]) -- The essence is that for readability, I want spam and eggs in separate definitions, but for clarity, I would like to express the fact that they are local to the definition of ham, i.e., they are not used outside of the definition of ham. The language reference at http://docs.python.org/reference/executionmodel.html says that The following are blocks: a module, a function body, and a class definition. (all other cases seem to refer to dynamic execution using eval() or similar). Python 3 and 2.6 seem to have identical scope rules. In the other languages I have used I can either use braces (C and descendants) or use let-bindings (SML, Haskell etc.) to form local scopes. Are there suggestions or conventions to maximize readability for these cases in python? (Execution time is not important in the cases I currently consider.) Regards Johan -- http://mail.python.org/mailman/listinfo/python-list