Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
fritz
Jul 26, 2003

the posted:

It's more appropriate for the Scientific/Computing thread in SAL, but here goes:

I'm simulating an Ising Model.

The first portion of the assignment was to create a 4x4 Array, where each spot was a -1 or 1. I had to create all 2^16 possible configurations. Then I had to calculate the "energy" by performing a calculation where each spot is multiplied by it's nearest neighbor and then summed over the entire configuration.

The second portion of the assignment used what was called a Metropolis Algorithm, where a 4x4 matrix was randomly generated (or chosen from the list of all in part one). Then a random spot in the array was flipped in sign, and the energy was recalculated. If the energy level was within a certain parameter, the new array was kept and the cycle was repeated about 50000 times. The resulting data should equal part one.

For the third part, I have to do the Metropolis algorithm for a 10x10 and 20x20 matrix, hence the 2^100 and 2^400 possible total configurations.

Presumably the reason you had to explicitly generate the space of configurations for the 4x4 example were so you could verify your MCMC was exploring the sample space, then once you were confident in that you could scale up to larger systems. (and also consider this: if there weren't anything stopping us from considering all spin states why would we bother with doing the hill climb in the first place).


And furthermore for numpy arrays "metro2 = 1*metro" will work to make a copy, but it turns out to be a little bit slower than .copy, at least sometimes.

Adbot
ADBOT LOVES YOU

fritz
Jul 26, 2003

Houston Rockets posted:

Memory considerations are always important, especially in a language like Python. If you don't mind sharing, what exactly are you working on? Could you go a step further and use generators?

You're probably not going to generate more than about 2**(low 30s).

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

the posted:

It's more appropriate for the Scientific/Computing thread in SAL, but here goes:

I'm simulating an Ising Model.

The first portion of the assignment was to create a 4x4 Array, where each spot was a -1 or 1. I had to create all 2^16 possible configurations. Then I had to calculate the "energy" by performing a calculation where each spot is multiplied by it's nearest neighbor and then summed over the entire configuration.

The second portion of the assignment used what was called a Metropolis Algorithm, where a 4x4 matrix was randomly generated (or chosen from the list of all in part one). Then a random spot in the array was flipped in sign, and the energy was recalculated. If the energy level was within a certain parameter, the new array was kept and the cycle was repeated about 50000 times. The resulting data should equal part one.

For the third part, I have to do the Metropolis algorithm for a 10x10 and 20x20 matrix, hence the 2^100 and 2^400 possible total configurations.

No part of an Mcmc algorithm to sample from a density needs you to keep 2^400 of anything around. There's something off with how you're approaching this problem. Think of a better data structure or method to avoid keeping trivial samples.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

fritz posted:

You're probably not going to generate more than about 2**(low 30s).

Simulating a markov chain is something that generators with local state were born to do. It's a slick interface if you need to scan over all the candidate samples.

fritz
Jul 26, 2003

Malcolm XML posted:

Simulating a markov chain is something that generators with local state were born to do. It's a slick interface if you need to scan over all the candidate samples.

Oh dang I never thought of using a generator to pull states from the posterior, that's a top quality idea.

the
Jul 18, 2004

by Cowcaster
Yeah I have no idea what you guys are talking about.

fritz
Jul 26, 2003

fritz posted:

Oh dang I never thought of using a generator to pull states from the posterior, that's a top quality idea.

Wait wouldn't you need to have logic in there to handle rejecting proposed draws?

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

the posted:

It's more appropriate for the Scientific/Computing thread in SAL, but here goes:

I'm simulating an Ising Model.

The first portion of the assignment was to create a 4x4 Array, where each spot was a -1 or 1. I had to create all 2^16 possible configurations. Then I had to calculate the "energy" by performing a calculation where each spot is multiplied by it's nearest neighbor and then summed over the entire configuration.

The second portion of the assignment used what was called a Metropolis Algorithm, where a 4x4 matrix was randomly generated (or chosen from the list of all in part one). Then a random spot in the array was flipped in sign, and the energy was recalculated. If the energy level was within a certain parameter, the new array was kept and the cycle was repeated about 50000 times. The resulting data should equal part one.

For the third part, I have to do the Metropolis algorithm for a 10x10 and 20x20 matrix, hence the 2^100 and 2^400 possible total configurations.

Use Markov Chains like wikipedia says and you can turn it into a sort of generator instead of 2^100 and 2^400 configurations. Any time you want to access a specific configuration you iterate through the simulation.

e: fb; waaay late on this I guess.

deimos fucked around with this message at 17:01 on Sep 26, 2013

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

fritz posted:

Wait wouldn't you need to have logic in there to handle rejecting proposed draws?

and? a generator is a black box that yields values. you could have one spin in an infinite loop if you really wanted to

onionradish
Jul 6, 2006

That's spicy.
I'm migrating some of the helper scripts I've written over the years in AutoIt to Python to improve my Python coding. Some of these AutoIt scripts have minimalist Windows GUI elements like a system tray icon that shows that the script is running and can display status as a tooltip on that icon. I'd like to replicate that functionality with the least-possible effort and module dependencies.

wxPython seems to be a decent cross-platform library for basic GUI stuff like tray icons, though the documentation seems thin. Can anyone vouch for it and whether or not any of the reference books ("wxPython in Action", "wxPython 2.8 Application Development Cookbook") are worthwhile?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

onionradish posted:

I'm migrating some of the helper scripts I've written over the years in AutoIt to Python to improve my Python coding. Some of these AutoIt scripts have minimalist Windows GUI elements like a system tray icon that shows that the script is running and can display status as a tooltip on that icon. I'd like to replicate that functionality with the least-possible effort and module dependencies.

wxPython seems to be a decent cross-platform library for basic GUI stuff like tray icons, though the documentation seems thin. Can anyone vouch for it and whether or not any of the reference books ("wxPython in Action", "wxPython 2.8 Application Development Cookbook") are worthwhile?

Years ago I did something similar. I don't really have an answer for you, but I thought I'd note that I found it easiest to use the AutoIT COM bindings from Python as they make it super easy to do AutoIT-type of stuff like getting window sizes and whatnot.

Python code:
import win32com.client
oAutoItX = win32com.client.Dispatch( "AutoItX3.Control" )

oAutoItX.Opt("WinTitleMatchMode", 2) #Match text anywhere in a window title

width = oAutoItX.WinGetClientSizeWidth("Firefox")
height = oAutoItX.WinGetClientSizeHeight("Firefox")

print width, height

NOTinuyasha
Oct 17, 2006

 
The Great Twist
wxPython isn't well maintained, or maybe 'abandoned' depending on who you ask. PyQt is better. Neither is good.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
wxWidgets isn't maintained either, so it's no surprise that wxPython isn't maintained.

I hack on GTK+ as a day job, but you guys would probably hate it.

In my opinion, the easiest way to get a UI up with Python is to make a web-based UI. Which isn't great.

Pollyanna
Mar 5, 2005

Milk's on them.


I've been using Kivy, and it works pretty well for building UIs. I suggest at least reading the intro to it.

edit: Be warned that the documentation is kinda crap. :(

Pollyanna fucked around with this message at 23:49 on Sep 26, 2013

Dominoes
Sep 20, 2007

Does anyone have a dev version of cx_freeze compiled? (the folder in site-packages or wherever) The only lead on the compiling-with-scipy bug I posted about is that it might be a bug in cx_freeze that's been fixed in the dev version. I've mostly given up on building modules from setup.pys.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Things that suck about python:

  • Lack of good, actively maintained GUI frameworks. "Good" is subjective, but I think it's pretty telling that everytime they get asked about here you could summarize the response as "meh".
  • Lack of good, actively maintained gaming frameworks.
  • Lack of good, actively maintained installer things like cx_freeze.

Dominoes
Sep 20, 2007

Thermopyle posted:

Things that suck about python:

  • Lack of good, actively maintained GUI frameworks. "Good" is subjective, but I think it's pretty telling that everytime they get asked about here you could summarize the response as "meh".
To add to this, PyQT(and presumably PySide) seems like a strong framework, but the available docs and tutorials are too unintuitive or outdated, making it very difficult to learn. Also, standalone programs made with it have unnecessarily-large file sizes, especially with Qt5.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dominoes posted:

To add to this, PyQT(and presumably PySide) seems like a strong framework, but the available docs and tutorials are too unintuitive or outdated, making it very difficult to learn. Also, standalone programs made with it have unnecessarily-large file sizes, especially with Qt5.

Yeah, the last time I tried doing non-web UI's with Python it was with PySide, and while I got the job done, I hated doing it largely because of the docs.

QuarkJets
Sep 8, 2008

Thermopyle posted:

Things that suck about python:

  • Lack of good, actively maintained GUI frameworks. "Good" is subjective, but I think it's pretty telling that everytime they get asked about here you could summarize the response as "meh".
  • Lack of good, actively maintained gaming frameworks.
  • Lack of good, actively maintained installer things like cx_freeze.

I disagree with the first point, PyQt is a great GUI framework, probably because of its C++ origins.

I would also suggest that no language has a good gaming framework, but that is a line of discussion that I don't care to go down

Pollyanna
Mar 5, 2005

Milk's on them.


Kivy is unfortunately not much better in that regard. Ugh, what a loving pain.

Thermopyle posted:

Things that suck about python:

  • Lack of good, actively maintained GUI frameworks. "Good" is subjective, but I think it's pretty telling that everytime they get asked about here you could summarize the response as "meh".
  • Lack of good, actively maintained gaming frameworks.
  • Lack of good, actively maintained installer things like cx_freeze.

So that rules out applications and games...which is quite a big chunk of the programming world. I'm actually considering just making applications in Objective-C instead ( :( ).

QuarkJets posted:

I disagree with the first point, PyQt is a great GUI framework, probably because of its C++ origins.

Don't you have to pay for PyQt?

a lovely poster
Aug 5, 2011

by Pipski

Pollyanna posted:

Don't you have to pay for PyQt?

PySide, what I posted earlier, is python bindings for the Qt framework

http://qt-project.org/wiki/Category:LanguageBindings::PySide

I never tried Kivy but PySide wasn't that bad (I had application development experience prior though) The documentation certainly leaves something to be desired, but that's not too uncommon in the python world.

Dominoes
Sep 20, 2007

Pollyanna posted:

Don't you have to pay for PyQt?
PyQT is available under the GPL or a paid license; you can't release closed-source, or non-GPL software using it without buying a license. PySide's raison d'etre is it can be distributed in non-GPL programs without buying a license.

Pollyanna
Mar 5, 2005

Milk's on them.


Oh dang, I had tried to install that but it hosed up for some reason. According to Python tho it has a really old version installed. Lemme try again with PySide, thanks.

Also, I kinda feel spoiled on syntax and grammar by starting out with Python. Everything else looks like a mess to me, especially C-style. Makes moving to Objective-C or Java something again to culture shock.

quote:

error: Setup script exited with error: Error configuring shiboken

:cry:

Pollyanna fucked around with this message at 02:50 on Sep 27, 2013

The March Hare
Oct 15, 2006

Je rêve d'un
Wayne's World 3
Buglord
Is it extremely difficult to make a py2exe type thing or is it just a space no one seems to care about enough to bother with currently? I (obviously) know nothing about this, so this is a real question.

The March Hare fucked around with this message at 02:54 on Sep 27, 2013

Dominoes
Sep 20, 2007

The March Hare posted:

Is it extremely difficult to make a py2exe type thing or is it just a space no one seems to care about enough to bother with currently? I (obviously) know nothing about this, so this is a real question.
I'm curious too. If I start contributing to an open-source project, this will be it.

Does anyone have current instructions for compiling modules from source on Windows? The first answer here is the best guide I've found, but I'm stuck at "error: command 'gcc' failed with exit status 1". I removed all references to '-mno-cygwin' from cygwinccompiler.py, and still get the error.

Dominoes fucked around with this message at 03:13 on Sep 27, 2013

Pollyanna
Mar 5, 2005

Milk's on them.


What version of PyGame do I want to download from here? I don't think I see a Python 2.7.5 64-bit version on there.

Dominoes
Sep 20, 2007

Pollyanna posted:

What version of PyGame do I want to download from here? I don't think I see a Python 2.7.5 64-bit version on there.
God bless you, Christoph Gohlke.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dominoes posted:

I'm curious too. If I start contributing to an open-source project, this will be it.

Does anyone have current instructions for compiling modules from source on Windows? The first answer here is the best guide I've found, but I'm stuck at "error: command 'gcc' failed with exit status 1". I removed all references to '-mno-cygwin' from cygwinccompiler.py, and still get the error.

This is the exact thing that caused me to switch to Linux. pip install some_package and its downloaded and compiled easy-peasy.

However, when I was on Windows I had the most success (meaning a very fragile set up) with Visual Studio Express and setting that up to compile with lots of Googlin'.

Dren
Jan 5, 2001

Pillbug
If you dudes would like to contribute to python I have heard that http://pythonmentors.com is the place to go to get started.

I am of the opinion that python very much needs someone to streamline package management and binary deliverables on windows.

BigRedDot
Mar 6, 2008

Dren posted:

If you dudes would like to contribute to python I have heard that http://pythonmentors.com is the place to go to get started.

I am of the opinion that python very much needs someone to streamline package management and binary deliverables on windows.

Have you looked at Anaconda?

NtotheTC
Dec 31, 2007


I've never had to create a binary for a python application so I haven't been through that pain. What exactly are the difficulties inherent in turning a python package into a binary? I can't get my head around why Python is so weak in this area.

Dren
Jan 5, 2001

Pillbug

BigRedDot posted:

Have you looked at Anaconda?

That looks pretty good. They seem to have a handle on the scientific/data stuff. Does the community have repos for it to support packages that continuum doesn't provide? E.g. How would I go about getting beautifulsoup with it?

Dominoes
Sep 20, 2007

NtotheTC posted:

I've never had to create a binary for a python application so I haven't been through that pain. What exactly are the difficulties inherent in turning a python package into a binary? I can't get my head around why Python is so weak in this area.
And is it fixable? Is this an inherent weakness in Python? Is it something the devs feel is out of the scope of the main language, and should be left to third parties, but third parties haven't really paid it attention?

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!
Package management on windows has always been a loving nightmare, on any language. The closest thing to usefulness on windows came first from Maven (which still hosed up on any package with actual DLL bindings) then on the .NET front from NuGet.

The problem with getting packages to work with windows is that there is no well established toolchain that can be easily installed. On pretty much every *nix you can expect a semi-well behaved gcc toolchain helping the package find it's headers and libraries and if not the package might have an easy way to get those libraries and headers to the right location.

Where are headers stored in Windows? %PROGRAMFILES%\Microsoft SDKs\Windows
Guess what, it's not non-admin writeable, and you can't really go shoving your own headers in there.

Every package (or manager) would have to guess what headers are needed to build a binary because again, there is no well defined behavior. That's why compiling things like mysql packages is a loving nightmare on windows.

deimos fucked around with this message at 16:20 on Sep 27, 2013

nonathlon
Jul 9, 2004
And yet, somehow, now it's my fault ...

NOTinuyasha posted:

wxPython isn't well maintained, or maybe 'abandoned' depending on who you ask. PyQt is better. Neither is good.

I used wxWindows and wxPython some years ago. I wouldn't say they were bad, but there was a definite feel to the community wx that you sometimes see where:

- "What do you mean, there is absolutely nothing wrong with wx ..."
- You're expected to spend all your time keeping up with wx, know instantly about changes and new releases, and be reading all the mailing lists
- "Oh yeah, that doesn't work with version X. Get the new version from the repo / recompile all your tools and libraries / it'll be fixed in the next version ..."

I've wasted too much time over the years on "tools that are a way of life", so I moved on. Qt looked far more promising, but I haven't kept up with developments in recent years.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

outlier posted:

"tools that are a way of life"

I like this way of phrasing it.

Dren
Jan 5, 2001

Pillbug

deimos posted:

Package management on windows has always been a loving nightmare, on any language. The closest thing to usefulness on windows came first from Maven (which still hosed up on any package with actual DLL bindings) then on the .NET front from NuGet.

The problem with getting packages to work with windows is that there is no well established toolchain that can be easily installed. On pretty much every *nix you can expect a semi-well behaved gcc toolchain helping the package find it's headers and libraries and if not the package might have an easy way to get those libraries and headers to the right location.

Where are headers stored in Windows? %PROGRAMFILES%\Microsoft SDKs\Windows
Guess what, it's not non-admin writeable, and you can't really go shoving your own headers in there.

Every package (or manager) would have to guess what headers are needed to build a binary because again, there is no well defined behavior. That's why compiling things like mysql packages is a loving nightmare on windows.

Pie in the sky here but someone could theoretically be the middle man between pip and windows, providing up to date windows binaries for stuff that's on pip. (only for stuff that can build on windows, of course).

Dominoes
Sep 20, 2007

Dren posted:

Pie in the sky here but someone could theoretically be the middle man between pip and windows, providing up to date windows binaries for stuff that's on pip. (only for stuff that can build on windows, of course).
http://www.lfd.uci.edu/~gohlke/pythonlibs/
I hope this guy doesn't quit.

nonathlon
Jul 9, 2004
And yet, somehow, now it's my fault ...

Thermopyle posted:

(Re: "tools that are a way of life")

I like this way of phrasing it.

Thanks. It's a frequent irritant of mine, and an idea that came to me after working with Plone for several years. You spend too much time futzing around with the tool, trying to solve tool issues or work within tool idioms, rather than solving the problem domain you're actually interested in. Especially since I work as a computational biologist and programming is really, truly just a means to an end.

Adbot
ADBOT LOVES YOU

QuarkJets
Sep 8, 2008

The March Hare posted:

Is it extremely difficult to make a py2exe type thing or is it just a space no one seems to care about enough to bother with currently? I (obviously) know nothing about this, so this is a real question.

Most people using Python don't have a need for compiling executables, so there's relatively little community interest.

  • Locked thread