|
Before I go and spend a bunch of time trying out a bunch of different libraries, anyone have any suggestions for making graphs with python? I'm looking for something simple to use and that makes pretty graphs easily. I can barely make graphs with Excel, and I barely want to make these graphs anyway so I don't have a lot of motivation to learn something complex. CairoPlot almost fits the bill, but it hasn't had a release since 2008.
|
# ? Feb 25, 2012 18:28 |
|
|
# ? May 9, 2024 17:32 |
|
Thermopyle posted:Before I go and spend a bunch of time trying out a bunch of different libraries, anyone have any suggestions for making graphs with python? I use matplotlib for python plots. Their pyplot module is pretty easy to use.
|
# ? Feb 25, 2012 18:43 |
|
This is kinda tangentially related to Python and ultra specific but maybe someone has dealt with something similar, since this is driving me crazy. I have a bunch of code that deals with XML with the QtXml module from PyQt4. Right now I can feed it XML files and it will validate it and do a bunch of stuff with it. I intend to move this program to a Unix server, so I upload files to the server and have the validate the files with a Python script. The problem is that there doesn't seem to be any way to install only QtXml into the Unix server. If there is I couldn't figure it out. All the Unix installers for Qt just want to install the whole SDK thing, and I don't have the permissions for that, not to mention I'd still have to somehow gently caress around with PyQt to make the QtXml communicate with Python... seems overly complicated. So I thought I'd just use lxml that's already installed to the server I'm going to use, and restructure the code to use lxml instead of QtXml. The problem is that I can't seem to install lxml on my Windows machine, where I'll actually do all the development. The lxml module seems to have dependencies to libxml2 and libxlst, but I haven't got the faintest clue how to install those for Windows or where they are even supposed to be installed. All the instructions are just for Unix machines. Any ideas? Where the gently caress does lxml assume those packages are installed? Why is installing a simple loving XML module so god drat hard Another idea was using xml.dom.minidom, but it seems too simple for my purposes and doesn't offer Schema validation, which is something I need to do.
|
# ? Feb 25, 2012 22:23 |
|
Cukel posted:This is kinda tangentially related to Python and ultra specific but maybe someone has dealt with something similar, since this is driving me crazy.
|
# ? Feb 25, 2012 22:30 |
|
Scaevolus posted:You can get binary packages for lxml 2.3 here.
|
# ? Feb 25, 2012 22:56 |
|
Cukel posted:Wow, that was much easier than I expected. I swear I googled eggs but couldn't find any for lxml. Thanks! Don't use eggs. Use the Windows installers. setuptools is terrible, eggs are terrible, PJE is terrible.
|
# ? Feb 25, 2012 23:01 |
|
Cukel posted:This is kinda tangentially related to Python and ultra specific but maybe someone has dealt with something similar, since this is driving me crazy. code:
|
# ? Feb 26, 2012 00:27 |
|
Function default arguments being retained can let you do some cute tricks, like simple memoization:code:
|
# ? Feb 26, 2012 03:51 |
|
Thermopyle posted:Before I go and spend a bunch of time trying out a bunch of different libraries, anyone have any suggestions for making graphs with python? Echoing matplotlib. It loving rules, and I've even used it in graphs for my professional academic journal articles. I heartily endorse it. Pretty much the first thing I do when I get a new machine is Python 2.7, NumPy, SciPy, PyFits and matplotlib. I also recently got turned on to how awesome iPython really is. I'm really annoyed at myself for resisting using it for so long!
|
# ? Feb 26, 2012 05:47 |
|
Actually, that's not a bad thing to bring up. I don't know how popular it is outside of scientific circles, but PyFits loving rules for dealing with FITS files. Space Telescope puts it out. http://www.stsci.edu/institute/software_hardware/pyfits
|
# ? Feb 26, 2012 05:58 |
|
JetsGuy posted:Echoing matplotlib. It loving rules, and I've even used it in graphs for my professional academic journal articles. I recently switched to doing a lot of data analysis in R to IPython + the libraries you mentioned. One of the nice features is the interactive cluster functionality. Also the notebook option is amazing if you haven't tried it yet. Both of these features require zeromq and the latter requires tornado. Here is an example of it in use: http://healthyalgorithms.com/2012/02/09/powells-method-for-maximization-in-pymc/. It would be cool if ipython notebook had a nice export to html function though. Also check out: http://pandas.pydata.org/. It's a really great data munging package.
|
# ? Feb 26, 2012 06:19 |
|
JetsGuy posted:Pretty much the first thing I do when I get a new machine is Python 2.7, NumPy, SciPy, PyFits and matplotlib. If you're using python for scientific computing I highly recommend enthought's python distribution if you're not already using it. Its killer feature IMO is that it comes with numpy backed by Intel's MKL, meaning numpy is really, really fast. it's free if you're attached to a university
|
# ? Feb 26, 2012 07:08 |
|
code:
|
# ? Feb 26, 2012 17:11 |
|
how!! posted:
I think if you're specifying fromlist you might need to do: code:
|
# ? Feb 26, 2012 17:28 |
|
The Gripper posted:Backwards to the way you're using it, fromlist is a list of things you're importing from giotto.contrib, so __import__('giotto.contrib', fromlist=['wsgi']) the problem was that I was missing the "globals(), locals(), -1" thing: code:
|
# ? Feb 27, 2012 02:26 |
|
I am doing Zed Shaw's Learn Python the Hard Way and I've got a quick question about lesson 15. In this lesson, I am importing a simple text file into my python script, then printing it to the terminal. The entire program's code is this: code:
code:
What is going on?
|
# ? Feb 27, 2012 09:17 |
|
Chimp_On_Stilts posted:I am doing Zed Shaw's Learn Python the Hard Way and I've got a quick question about lesson 15. File operations are usually sequential, so there's a special (hidden) thing keeping track of where you are in a file. If you try fy.read(20), it will only read 20 bytes from the file, and put them in a string, and move the internal location 20 bytes from where it was before the read, so that the next call to read() will pick up where it left off. This happens until you reach the end of file, which is signified with EOF. When you call read() without arguments, it reads the whole file until it reaches EOF, and returns the entire contents in a string. So basically, after a call to read() without parameters, the whole file is read, and the pointer is stuck at EOF, meaning subsequent calls don't have anything left to read. e: This is the behavior you're talking about right? code:
Look Around You fucked around with this message at 09:54 on Feb 27, 2012 |
# ? Feb 27, 2012 09:28 |
|
http://travis-ci.org now support python
|
# ? Feb 27, 2012 20:46 |
|
I'm not sure if this has been posted, but I just found this and it's pretty awesome: http://fonnesbeck.github.com/ScipySuperpack/ quote:This shell script will install recent 64-bit builds of Numpy (2.0) and Scipy (0.11), Matplotlib (1.2), iPython (0.13), Pandas (0.7), as well as PyMC (2.2 alpha) for OS X 10.7 (Lion) on Intel Macintosh. All builds are based on recent development code from each package, which means though some bugs may be fixed and features added, they also may be more unstable than the official releases[1]. Distributing them together should improve interoperability, since the supporting packages (Scipy, Matplotlib, PyMC) were all built against the accompanying build of Numpy. I encourage all users to run the appropriate unit tests on each package to ensure that any extant issues do not affect your work. Please report any errors that may be the result of build issues.
|
# ? Feb 27, 2012 23:42 |
|
tef posted:http://travis-ci.org now support python I saw that this morning and threw a project up on it. I really like it! I just wish I could use my tox.ini file instead of some extra .travis.yml file :/
|
# ? Feb 28, 2012 04:36 |
|
Look Around You posted:
Exactly. You answered my question EDIT: A new question: My current Python lesson has me simply copying the contents of one .txt file to another .txt file. What types of files can Python use the built in open and read functions with? Could I copy a .doc the same way? .psd? .xls? Chimp_On_Stilts fucked around with this message at 05:38 on Feb 28, 2012 |
# ? Feb 28, 2012 05:29 |
|
Chimp_On_Stilts posted:Exactly. You answered my question Yeah, you can, but it's a bit different. You need to open the file in binary mode as opposed to text mode. To do this, you append 'b' to the mode string. So you use rd_file = open(in_fname, "rb") for the thing you're copying and wr_file = open(out_fname, "wb") for the one to write to. e: The difference is that text mode (the default mode) typically only handles printable characters well, while binary mode will handle all types of data, at the cost of not really being able to print it. Look Around You fucked around with this message at 05:52 on Feb 28, 2012 |
# ? Feb 28, 2012 05:50 |
|
I need to learn enough Python in the next 4 days to be able to solve three physics problems involving oscillations, fourier series, euler approximation, and the Lyapunov exponent. I hope I can do this. I have limited programming knowledge but have never used Python.
|
# ? Feb 28, 2012 07:25 |
|
the posted:I need to learn enough Python in the next 4 days to be able to solve three physics problems involving oscillations, fourier series, euler approximation, and the Lyapunov exponent. Are you using Sage (or SciPy/NumPy)?
|
# ? Feb 28, 2012 08:55 |
|
I've never programmed those problems before but if you know the math, writing functions should be pretty straight forward. I'd use SciPy/NumPy. I'd bet with a little searching you could find example code online that probably does what you need.
|
# ? Feb 28, 2012 13:08 |
|
Looking for some advice on creating an elegant "Type" framework for this simulation engine that I'm working on. I've got this base class, DataUnit, that stores data in piecewise waveforms. Until now, data in these waveforms were binary numbers, and, subsequently, the only attribute that DataUnit needed to represent different signals was "num_bits." Needless to say, validation of data was pretty easy, as was conversion between different numbers of bits. However, now I'd like to make things a little more general. I want to also support hex, integer, float, fixed-point, and string data natively, as well as allow support (without it being a pain in the rear end) to add new datatypes depending on whatever is using the engine (e.g. one type that I'm 99% sure we'll want is waveform data). Each type, however many their are and whatever they are, needs to be able to describe and decode itself (not its data) in a simple string format (e.g. "float" being a float, "fixedpoint9_14" being a fixed-point number with 9 digit to the left of the decimal and 14 to the right, etc), and also convert data in its format to the other formats, with parameters when necessary. My initial idea here was to create a class called DataType, that could be subclassed by various named types, etc, etc etc. But conversions in that case would be a mess, have trouble dealing with new types, and would mostly replicate already built-in Python types at any rate. So, I figure there's gotta be an easier way here. Does anyone have any ideas?
|
# ? Feb 28, 2012 19:47 |
|
Look Around You posted:Are you using Sage (or SciPy/NumPy)? I haven't started using anything, really. What would you recommend? I would think I'd just need something that can run a text file I've done up of the code, just to output a number that I need... ?
|
# ? Feb 28, 2012 21:11 |
|
the posted:I haven't started using anything, really. What would you recommend? I would think I'd just need something that can run a text file I've done up of the code, just to output a number that I need... ? It sounds like, from what you said, that just using regular python is fine for your purposes unless you're also processing quite a lot of data.
|
# ? Feb 28, 2012 21:18 |
|
So I can put all my code in a .py text file, open a command window, and just run it.. right? edit: \/\/ running on Windows 7 32 bit the fucked around with this message at 22:05 on Feb 28, 2012 |
# ? Feb 28, 2012 21:52 |
|
the posted:So I can put all my code in a .py text file, open a command window, and just run it.. right? Yep, call python whatever.py. Or add the right shabang (#!/path/to/my/python/) and make it executable and you can skip the Python -- assuming you're on a *NIX.
|
# ? Feb 28, 2012 22:02 |
|
the posted:So I can put all my code in a .py text file, open a command window, and just run it.. right? Yeah pretty much this. If you're doing like... serious numerical or symbolic stuff you may want to try Sage out. It's basically Python bundled with SciPy and NumPy which are two really good libraries for this stuff. It's also got really good documentation. Um, I just noticed that Sage wants you to set it up w/ VirtualBox on Windows. If you don't want to do that they have an online workbook thing that does the same thing except ~in the cloud~ or whatever. I've heard that's supposed to be pretty good too. e: To run a python script from the command line you literally need to type python myscript.py . I don't think Windows does shebang lines/auto execution, but I could be wrong. Look Around You fucked around with this message at 04:52 on Feb 29, 2012 |
# ? Feb 29, 2012 04:50 |
|
Anyone here know about the csv module? I have a CSV file that includes quoted fields, like so:code:
Can the csv module can correctly parse those lines so that I get a list like this? code:
stray fucked around with this message at 23:15 on Feb 29, 2012 |
# ? Feb 29, 2012 23:10 |
|
The CSV module can. The first example of the reader object also shows how to set delimiters and quote characters, so that should help you a lot.
|
# ? Feb 29, 2012 23:17 |
|
I have to program a bifurcation diagram for a physics homework question. I have the following: code:
quote:Traceback (most recent call last):
|
# ? Mar 1, 2012 03:26 |
|
That code is really loving hard to follow. Here's a code:
x = (5.0 + 3.0 * float(500) / (999)) * 1.0001990246762804 * (1 - 1.0001990246762804) x = 6.501501501501501 * 1.0001990246762804 * -0.00019902467628041265 x = -0.0007964564119593775 hi there, now you're going to accelerate really quickly to -inf When xb = 4.0 x doesn't go over 1.0 (I checked) so your system remains stable. The big problem here: the way you're converting back and forth from int <-> float is really loving scary and you shouldn't do it. It's very possible that what you're doing is algorithmically correct but an accumulation of error bumps x > 1. It's more likely that what you're doing will never give you the result you need. Read this: http://floating-point-gui.de/ Johnny Cache Hit fucked around with this message at 04:19 on Mar 1, 2012 |
# ? Mar 1, 2012 04:14 |
|
I'm sorry, my programming knowledge is rather limited. I'm trying to do a bifurcation diagram of a logistic map. The map is given by xi+1 = a*xi(1-xi)^2, for 0 <= x <= 1 and 3 <= a <= 6.5 I need to start at x0 = 0.1 and da = 0.1 as well, and then plot what happens. What I have there is some code I found online that I am trying to modify to solve this problem, but as you can see it is not going well. The code I put up does draw a fairly good bifurcation map, but it doesn't represent the function or values that I need.
|
# ? Mar 1, 2012 04:21 |
|
Alright, I rewrote something by myself instead. Why am I getting an invalid syntax for the <= sign? code:
|
# ? Mar 1, 2012 06:16 |
|
the posted:Alright, I rewrote something by myself instead. Because the for statement in Python is always paired with an in. You want code:
|
# ? Mar 1, 2012 06:33 |
|
the posted:Alright, I rewrote something by myself instead. You can't use just a boolean expression in a for loop, try while instead. for loops can only operate on sequences (or other iterable objects) in Python. e: or you can do what No Safe Word suggested. range() only does integers I think though, so you may have to try something different for the floats.
|
# ? Mar 1, 2012 06:35 |
|
|
# ? May 9, 2024 17:32 |
|
Just come across this little snippet of code.code:
|
# ? Mar 1, 2012 15:18 |