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
Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Glad to see you're having fun! Keep at it!

Adbot
ADBOT LOVES YOU

NtotheTC
Dec 31, 2007


I love PyCharm so much. The solo-dev license is a bit of a steep price for someone just messing about with Python in their spare time but if you plan on using Python a lot then really you owe it to yourself to give the 30 day trial a go. It does a good job of getting you into good habits like using virtual environments/source control/unit testing without abstracting what's going on underneath TOO much so that it all becomes a bit voodoo.

I am seriously pissed off that I didn't take advantage of that offer a while back where they dropped the price to £10 or so. "Psh, waste of money Eclipse with PyDev does anything PyCharm can do :smug:". drat you 6-months-ago-me.

VVV That's awesome. It looks like the free version is Python only, so you don't get any of the framework support like Django etc. I'm using Django most of the time so I'd still need a pro license but for python projects I really don't think there's a better alternative out there.

NtotheTC fucked around with this message at 12:58 on Sep 25, 2013

redleader
Aug 18, 2005

Engage according to operational parameters

NtotheTC posted:

I love PyCharm so much. The solo-dev license is a bit of a steep price for someone just messing about with Python in their spare time but if you plan on using Python a lot then really you owe it to yourself to give the 30 day trial a go. It does a good job of getting you into good habits like using virtual environments/source control/unit testing without abstracting what's going on underneath TOO much so that it all becomes a bit voodoo.

I am seriously pissed off that I didn't take advantage of that offer a while back where they dropped the price to £10 or so. "Psh, waste of money Eclipse with PyDev does anything PyCharm can do :smug:". drat you 6-months-ago-me.

In a somewhat-uncanny coincidence, JetBrains have just released a free edition of PyCharm. I haven't tried it yet and don't quite know what it's missing when compared to the full edition, but hopefully it isn't horrendously gimped!

sharktamer
Oct 30, 2011

Shark tamer ridiculous
Has anyone used comments withing a ConfigParser config file? I can set up comments within the file like so:

code:
; This is a section
[SECTION]
; This is a setting
setting = value
but when I call the write method on the config file object, the comments are removed. I don't see any options in the documentation and I am using what seems to be the sanctioned comment syntax.

I know json is meant to be a bit more robust, but the configparser config files are a lot more readable, which is important. Please don't reccomend json.

NtotheTC posted:

I love PyCharm so much. The solo-dev license is a bit of a steep price for someone just messing about with Python in their spare time but if you plan on using Python a lot then really you owe it to yourself to give the 30 day trial a go. It does a good job of getting you into good habits like using virtual environments/source control/unit testing without abstracting what's going on underneath TOO much so that it all becomes a bit voodoo.

I've not tried pycharm, but sublime text with a few of the python-centric bells and whistles looks like it covers almost the same feature set. Anaconda is a big help, gives you a lot in one easy to use package.

Dominoes
Sep 20, 2007

NtotheTC posted:

I love PyCharm so much. The solo-dev license is a bit of a steep price for someone just messing about with Python in their spare time but if you plan on using Python a lot then really you owe it to yourself to give the 30 day trial a go. It does a good job of getting you into good habits like using virtual environments/source control/unit testing without abstracting what's going on underneath TOO much so that it all becomes a bit voodoo.

I am seriously pissed off that I didn't take advantage of that offer a while back where they dropped the price to £10 or so. "Psh, waste of money Eclipse with PyDev does anything PyCharm can do :smug:". drat you 6-months-ago-me.

VVV That's awesome. It looks like the free version is Python only, so you don't get any of the framework support like Django etc. I'm using Django most of the time so I'd still need a pro license but for python projects I really don't think there's a better alternative out there.
I'm going to check it out again. Are the advantages it provides over a text editor like Notepad++ useful for things other than large projects?

Dominoes fucked around with this message at 15:27 on Sep 25, 2013

Dren
Jan 5, 2001

Pillbug

sharktamer posted:

Has anyone used comments withing a ConfigParser config file? I can set up comments within the file like so:

code:
; This is a section
[SECTION]
; This is a setting
setting = value
but when I call the write method on the config file object, the comments are removed. I don't see any options in the documentation and I am using what seems to be the sanctioned comment syntax.

I know json is meant to be a bit more robust, but the configparser config files are a lot more readable, which is important. Please don't reccomend json.

Comments are ignored when the config is parsed. So when you write a parsed config back out you will lose the comments.

You can try a hack in your config writing code to get comments. http://stackoverflow.com/questions/6620637/python-configparser-question-about-writing-comments-to-files
edit: here is a hack with a nicer end result but a more involved implementation http://stackoverflow.com/questions/8533797/adding-comment-with-configparser

Thermopyle
Jul 1, 2003

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

sharktamer posted:



I've not tried pycharm, but sublime text with a few of the python-centric bells and whistles looks like it covers almost the same feature set. Anaconda is a big help, gives you a lot in one easy to use package.
ST2+packages doesn't have anywhere close to the same feature set as PyCharm.

That being said ST2 is easier for small one-file projects, and I use it extensively for those.

NtotheTC
Dec 31, 2007


Dominoes posted:

I'm going to check it out again. Are the advantages it provides over a text editor like Notepad++ useful for things other than large projects?

If you're doing anything with source control or anything that requires pulling in dependencies (meaning you should be using pip+venv) then yes it's leagues ahead of notepad++ and even ST2. If you're bashing out a 10 line script just to test something then obviously you're not going to be using any of the extra functionality it has over something like notepad++. Code completion/navigation are huge productivity boosters when you get used to them, I'm not sure if Notepad++ handles that for Python? I came from Eclipse+PyDev and thought it covered pretty much everything in terms of making the developers life easier, but PyCharm still consistently surprises me with small quality of life things.

It might also depend on what you like as a developer. Personally I'm one of those people that adores PEP8, so I like the prompting you get from that. Some people may find that annoying and want to turn it off however. In any sort of advanced IDE you're going to get window encroachment what with all the additional panes, which can be troublesome for people with small monitors but PyCharm has easy ways to tuck them away out of site when you don't need them.

Dominoes
Sep 20, 2007

NtotheTC posted:

If you're doing anything with source control or anything that requires pulling in dependencies (meaning you should be using pip+venv) then yes it's leagues ahead of notepad++ and even ST2. If you're bashing out a 10 line script just to test something then obviously you're not going to be using any of the extra functionality it has over something like notepad++. Code completion/navigation are huge productivity boosters when you get used to them, I'm not sure if Notepad++ handles that for Python? I came from Eclipse+PyDev and thought it covered pretty much everything in terms of making the developers life easier, but PyCharm still consistently surprises me with small quality of life things.

It might also depend on what you like as a developer. Personally I'm one of those people that adores PEP8, so I like the prompting you get from that. Some people may find that annoying and want to turn it off however. In any sort of advanced IDE you're going to get window encroachment what with all the additional panes, which can be troublesome for people with small monitors but PyCharm has easy ways to tuck them away out of site when you don't need them.
OK, I'll do a full-immersion switch to see what I've been missing.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



sharktamer posted:

Has anyone used comments withing a ConfigParser config file? I can set up comments within the file like so:

code:
; This is a section
[SECTION]
; This is a setting
setting = value
but when I call the write method on the config file object, the comments are removed. I don't see any options in the documentation and I am using what seems to be the sanctioned comment syntax.

Write your changes to a different file and have ConfigParser merge them with the base options?

Dominoes
Sep 20, 2007

Is there a way to add .py files to Pycharm projects without changing their directory on the drive?

The official tutorial's geared at Django. I tried to get into Django, but put it off because it (or the approach the tutorials took) involved a lot of complicated things that normal Python doesn't, and broken dependencies/third-party software. Are PyCharm's features geared towards complex projects beyond normal Python?

Dominoes fucked around with this message at 17:20 on Sep 25, 2013

NtotheTC
Dec 31, 2007


Dominoes posted:

Is there a way to add .py files to Pycharm projects without changing their directory on the drive?

The official tutorial's geared at Django. I tried to get into Django, but put it off because it (or the approach the tutorials took) involved a lot of complicated things that normal Python doesn't, and broken dependencies/third-party software. Are PyCharm's features geared towards complex projects beyond normal Python?

If you want to get into Django I'd recommend following the official Django tutorial. There's definitely a fair amount of stuff to pick up on top of regular Python.

I'm not sure what you mean by adding .py files without changing their directory, do you mean you have some project files already on disk somewhere that you want to create a pycharm project from?

Pollyanna
Mar 5, 2005

Milk's on them.


What's considered the "best" GUI toolkit for Python? Nothing super specialized, just learning how to make message boxes and windows and buttons.

Also, I'm still trying to decide between Django and Rails for web development purposes...I want to learn another language, but Django's already installed on my computer. :v:

Haystack
Jan 23, 2005





Dominoes posted:

Is there a way to add .py files to Pycharm projects without changing their directory on the drive?

The official tutorial's geared at Django. I tried to get into Django, but put it off because it (or the approach the tutorials took) involved a lot of complicated things that normal Python doesn't, and broken dependencies/third-party software. Are PyCharm's features geared towards complex projects beyond normal Python?

You might try creating a symbolic link to the orginal .py file within your project. Alternately, you can add any directory tree to a pycharm project via Settings-> Project Settings-> Project Structure-> + Add Content Root, and then set any folder within that tree as a source folder that will be added to the PYTHONPATH of any python process pycharm runs (I think). The former solution might not mesh well with some of pycharm's internal mechanisms, while the latter can't add just single files to the PYTHONPATH. Both solutions have their own issues with versioning, project portability, and interpreter availability.

All told, Pycharm is probably the best tool out there for managing large, complex python projects. However, intelligently managing any sizable code project adds a layer of complexity and headaches that no tool can totally abstract away.

Pollyanna
Mar 5, 2005

Milk's on them.


Haystack posted:

You might try creating a symbolic link to the orginal .py file within your project. Alternately, you can add any directory tree to a pycharm project via Settings-> Project Settings-> Project Structure-> + Add Content Root, and then set any folder within that tree as a source folder that will be added to the PYTHONPATH of any python process pycharm runs (I think). The former solution might not mesh well with some of pycharm's internal mechanisms, while the latter can't add just single files to the PYTHONPATH. Both solutions have their own issues with versioning, project portability, and interpreter availability.

All told, Pycharm is probably the best tool out there for managing large, complex python projects. However, intelligently managing any sizable code project adds a layer of complexity and headaches that no tool can totally abstract away.

This is something I've been having trouble with. I am poo poo at organization and a tool that would help me just template a project structure would be awesome. I think I'll try out this PyCharm thing.

Dominoes
Sep 20, 2007

CX_Freeze/Scipy problem: I'm creating a Windows EXE using cx_freeze, Python3 and the Scipy installation from lfd.uci.edu. Upon running the exe, I receive the error: ImportError: cannot import name nonlin.

The Scipy file line this references, in site-packages\scipy\optimize_root.py: from . import nonlin. I can load a console with Python, and successfully run import scipy.optimize.nonlin. Adding scipy.optimize.nonlin to my setup.py includes doesn't solve the problem.

nonlin.py is located in the optimize directory in my scipy install, and its corresponding location as a compiled file in the library file cx_freeze generates.

Any ideas?

the
Jul 18, 2004

by Cowcaster
I think I might be getting into trouble with an equals sign and arrays.

I have a code here with one array, metro, that I start with. I then need to make another array, metro2, that I need to equal metro. I make changes to metro2 (flipping one random value), and then calculate information from it and compare two values. If the changes pass, I make metro equal to metro2 and start the loop over again.

My problem is that I just ran into a situation where the value mHp was larger than mH, so it should not have triggered any changes, yet at the end metro was equal to metro2.

Is there another way to copy the information from one array to the other rather than equal signs? Because I think with the way python defines "equal" I might be getting into trouble. Thanks.

edit: This is specifically what I'm referring to: http://www.saltycrane.com/blog/2007/11/how-to-copy-python-lists-or-other/

Here's my code

Python code:
    for count in range (numpy.int(metrosize.size-waitperiod),metrosize.size,1):
        
        mH = 0.
        mHp = 0.
        
        for i in range (0,asize,1):
            mH += -(metro[0,i]*metro[asize-1,i])
            mH += -(metro[i,0]*metro[i,asize-1])
            for k in range (0, asize-1,1):
                mH += -(metro[i,k]*metro[i,k+1])
                mH += -(metro[k,i]*metro[k+1,i])

        metro2 = metro

        choice = random.randint(0,3)
        choice2 = random.randint(0,3)

        metro2[choice,choice2] = metro2[choice,choice2]*-1

        for i in range (0,asize,1):
            mHp += -(metro2[0,i]*metro2[asize-1,i])
            mHp += -(metro2[i,0]*metro2[i,asize-1])
            for k in range (0, asize-1,1):
                mHp += -(metro2[i,k]*metro2[i,k+1])
                mHp += -(metro2[k,i]*metro2[k+1,i])

        if abs(mHp) < abs(mH):
            metro = metro2

        if (mHp-mH) > 0:
            ran = numpy.random.rand()
            if  ran < numpy.exp(-B[j]*(mHp-mH)):
                metro = metro2
        mH = 0.
        
        for i in range (0,asize,1):
            mH += -(metro[0,i]*metro[asize-1,i])
            mH += -(metro[i,0]*metro[i,asize-1])
            for k in range (0, asize-1,1):
                mH += -(metro[i,k]*metro[i,k+1])
                mH += -(metro[k,i]*metro[k+1,i])

        if count >= 0:
            metrosize[count] += mH

Third
Sep 9, 2004
The most noble title any child can have.
metro2 = metro is making metro2 point to the same object as metro. When you modify one you are modifying both.

metro2 = metro[:] will make a new copy and modifying one will only modify that copy.

the
Jul 18, 2004

by Cowcaster
Thanks, that's exactly what I was looking for.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

the posted:

I think I might be getting into trouble with an equals sign and arrays.

metro2 = metro

This results in metro2 being assigned the same object as metro, i.e. both variables point to the same thing.

Without knowing what kind of object metro is I can't tell you how to get a copy, but maybe it has a copy() method or something like that which you can use.

the
Jul 18, 2004

by Cowcaster
It's a 2d array, metro2 = metro[:] seems to work

a lovely poster
Aug 5, 2011

by Pipski

Pollyanna posted:

What's considered the "best" GUI toolkit for Python? Nothing super specialized, just learning how to make message boxes and windows and buttons.

Also, I'm still trying to decide between Django and Rails for web development purposes...I want to learn another language, but Django's already installed on my computer. :v:

PySide is my personal recommendation

TkInter is another popular one, never personally used it

https://wiki.python.org/moin/GuiProgramming has a decent list, you're probably going to have to filter through a lot of trash though

Dren
Jan 5, 2001

Pillbug
fwiw, I don't like tkinter. I think it's popular mainly because it comes with a lot of python distributions. I liked PyGTK + glade pretty well and I believe the PyQt bindings provide a similarly nice experience.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

a lovely poster posted:

PySide is my personal recommendation

TkInter is another popular one, never personally used it

https://wiki.python.org/moin/GuiProgramming has a decent list, you're probably going to have to filter through a lot of trash though
Kivy is also interesting.

the
Jul 18, 2004

by Cowcaster
Alright, the earlier problem is still happening and I don't know why

Here is my code. I added in questions and breaks in order to figure out what was going on. I'll only include the relevant part for the sake of brevity:

Python code:
metro = numpy.reshape(isingarray[0,:], (asize,asize))
        
    metrosize = numpy.zeros(10000)    
    waitperiod = metrosize.size*1.1
    
    for count in range (numpy.int(metrosize.size-waitperiod),metrosize.size,1):
        
        mH = 0.
        mHp = 0.
        
        for i in range (0,asize,1):
            mH += -(metro[0,i]*metro[asize-1,i])
            mH += -(metro[i,0]*metro[i,asize-1])
            for k in range (0, asize-1,1):
                mH += -(metro[i,k]*metro[i,k+1])
                mH += -(metro[k,i]*metro[k+1,i])
        print ('First calculated mH value ',mH)       
        metro2 = metro[:]

        choice = random.randint(0,3)
        choice2 = random.randint(0,3)
        print ('Pre flip metro ',metro)
        print ('Pre flip metro2 ', metro2)
        print ('Flipped coord = [',choice,',',choice2,']')
        metro2[choice,choice2] = metro2[choice,choice2]*-1
        print ('Post flip metro ',metro)
        print ('Post flip metro2 ', metro2)
That output looks like:

code:
('First calculated mH value ', -32.0)
('Pre flip metro ', array([[-1., -1., -1., -1.],
       [-1., -1., -1., -1.],
       [-1., -1., -1., -1.],
       [-1., -1., -1., -1.]]))
('Pre flip metro2 ', array([[-1., -1., -1., -1.],
       [-1., -1., -1., -1.],
       [-1., -1., -1., -1.],
       [-1., -1., -1., -1.]]))
('Flipped coord = [', 3, ',', 0, ']')
('Post flip metro ', array([[-1., -1., -1., -1.],
       [-1., -1., -1., -1.],
       [-1., -1., -1., -1.],
       [ 1., -1., -1., -1.]]))
('Post flip metro2 ', array([[-1., -1., -1., -1.],
       [-1., -1., -1., -1.],
       [-1., -1., -1., -1.],
       [ 1., -1., -1., -1.]]))
As you can see in the code, I'm ONLY flipping a digit in metro2. So, the pre and post flip metro should be equal, and the pre and post flip metro2 should be different (by the indicated coordinate). Yet, they're both showing changed. Why is this happening?

Pollyanna
Mar 5, 2005

Milk's on them.


Wow, Kivy looks right up my alley. I'll try it out and see what it can do.

Third
Sep 9, 2004
The most noble title any child can have.

the posted:

Alright, the earlier problem is still happening and I don't know why

In the code you posted previously, you have this part:

Python code:
if abs(mHp) < abs(mH):
    metro = metro2

if (mHp-mH) > 0:
    ran = numpy.random.rand()
    if  ran < numpy.exp(-B[j]*(mHp-mH)):
        metro = metro2
If those conditions happen, you end up pointing metro to the new metro 2 object. Did you fix that too?

the
Jul 18, 2004

by Cowcaster
Yes, I've fixed that. Sorry, here's the whole piece:

Python code:
metroarray = numpy.zeros(B.size)


for j in range(0,B.size,1):
    bug = float(j)
    print('Percent complete: ',(bug/B.size)*100)
    
    #metro = numpy.reshape(isingarray[numpy.random.randint(0,65537),:], (asize,asize))
    metro = numpy.reshape(isingarray[0,:], (asize,asize))
        
    metrosize = numpy.zeros(10000)    
    waitperiod = metrosize.size*1.1
    
    for count in range (numpy.int(metrosize.size-waitperiod),metrosize.size,1):
        
        mH = 0.
        mHp = 0.
        
        for i in range (0,asize,1):
            mH += -(metro[0,i]*metro[asize-1,i])
            mH += -(metro[i,0]*metro[i,asize-1])
            for k in range (0, asize-1,1):
                mH += -(metro[i,k]*metro[i,k+1])
                mH += -(metro[k,i]*metro[k+1,i])
        print ('First calculated mH value ',mH)       
        metro2 = metro[:]

        choice = random.randint(0,3)
        choice2 = random.randint(0,3)
        print ('Pre flip metro ',metro)
        print ('Pre flip metro2 ', metro2)
        print ('Flipped coord = [',choice,',',choice2,']')
        metro2[choice,choice2] = metro2[choice,choice2]*-1
        print ('Post flip metro ',metro)
        print ('Post flip metro2 ', metro2)
        for i in range (0,asize,1):
            mHp += -(metro2[0,i]*metro2[asize-1,i])
            mHp += -(metro2[i,0]*metro2[i,asize-1])
            for k in range (0, asize-1,1):
                mHp += -(metro2[i,k]*metro2[i,k+1])
                mHp += -(metro2[k,i]*metro2[k+1,i])
        print ('mHp calc ',mHp)
        print ('mH pre decision ',mH)
        if mHp < mH:
            metro = metro2[:]
            print ('Yes ONE')
        if (mHp-mH) > 0:
            ran = numpy.random.rand()
            if  ran < numpy.exp(-B[j]*(mHp-mH)):
                print ran,' < ', numpy.exp(-B[j]*(mHp-mH))
                metro = metro2[:]
        print ('post decision metro ',metro)
        print ('post decision metro2 ',metro2)
        print ('Difference = ',metro2 - metro)        
        mH = 0.
        
        for i in range (0,asize,1):
            mH += -(metro[0,i]*metro[asize-1,i])
            mH += -(metro[i,0]*metro[i,asize-1])
            for k in range (0, asize-1,1):
                mH += -(metro[i,k]*metro[i,k+1])
                mH += -(metro[k,i]*metro[k+1,i])
        print ('final mH calc ',mH)
        print ('Current count ',count)
        if count >= 0:
            metrosize[count] += mH
            print ('Current metrosize ',metrosize[count])
        raw_input()

Third
Sep 9, 2004
The most noble title any child can have.
Try metro2 = metro.copy() then. Sorry, based on the link in your earlier post I assumed you were talking about lists and I didn't look too closely at it.

the
Jul 18, 2004

by Cowcaster

returnh posted:

Try metro2 = metro.copy() then. Sorry, based on the link in your earlier post I assumed you were talking about lists and I didn't look too closely at it.

Ok, thanks! Why doesn't metro2 = metro[:] work, though?

edit: I got the whole thing working, finally, Thanks for your help guys

the fucked around with this message at 02:08 on Sep 26, 2013

Third
Sep 9, 2004
The most noble title any child can have.

the posted:

Ok, thanks! Why doesn't metro2 = metro[:] work, though?

That is just a clever trick that works on python lists.

Hed
Mar 31, 2004

Fun Shoe
My problem with PyCharm (which I picked up when it went on sale) was that it seemed like I had to set my entire environment up in my native OS (Windows at the time). I usually ssh into a linux VM to run things and edit text files in a native editor over nfs/samba shares so it seemed like overkill, especially when sometimes I develop on my Mac and sometimes here. Maybe it's easier than I am making it out to be but ST2 seems to be working great for me.

the
Jul 18, 2004

by Cowcaster
Houston, I have a problem.

I am working on a problem where I have to work with some *really* large numbers.

I.e. 2^100 and 2^400

I need to create arrays of those sizes.

Numpy is borking out, (ValueError: Maximum allowed dimension exceeded). What can I do?

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Is that even physically possible? An array of length 2^100 would require more bytes of memory than there are atoms in the observable universe

the
Jul 18, 2004

by Cowcaster

MeramJert posted:

Is that even physically possible? An array of length 2^100 would require more bytes of memory than there are atoms in the observable universe

Anything's possible when you can imagine it!

I decided that it was probably best to create each one individually on the fly and do what I needed with it then create all 2^100 at once.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

the posted:

Anything's possible when you can imagine it!

I decided that it was probably best to create each one individually on the fly and do what I needed with it then create all 2^100 at once.

http://www.freemars.org/jeff/2exp100/question.htm

BeefofAges
Jun 5, 2004

Cry 'Havoc!', and let slip the cows of war.

Hed posted:

My problem with PyCharm (which I picked up when it went on sale) was that it seemed like I had to set my entire environment up in my native OS (Windows at the time). I usually ssh into a linux VM to run things and edit text files in a native editor over nfs/samba shares so it seemed like overkill, especially when sometimes I develop on my Mac and sometimes here. Maybe it's easier than I am making it out to be but ST2 seems to be working great for me.

You can set up most IDEs to SCP files over to your target and run them when you click build. Alternatively, I think PyCharm has Vagrant support, so it could even build the VM for you, if necessary.

Houston Rockets
Apr 15, 2006

the posted:

Anything's possible when you can imagine it!

I decided that it was probably best to create each one individually on the fly and do what I needed with it then create all 2^100 at once.

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?

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

the posted:

Anything's possible when you can imagine it!

I decided that it was probably best to create each one individually on the fly and do what I needed with it then create all 2^100 at once.

I think you're going to need to reconsider the problem. If you were able to create and process 5 billion values per second, it would still take you 8,034,049,677,726 years to finish processing 2^100 items. It would take you 16,365,648,229,188,348,669,769,622,693,617,633,758,353,505,071,270,657,019,287,917,011,380,868,608,709,999,588,234,284,181,058,663,913,016 years to process your 2^400 items.

Adbot
ADBOT LOVES YOU

the
Jul 18, 2004

by Cowcaster

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?

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.

  • Locked thread