|
jusion posted:Ok - I think you may be talking past each other then, because his link (http://floating-point-gui.de/basic/) is not that. QuarkJets posted:Is writing bad analogies required for numerical analysis, now? Malcolm XML posted:well it keeps me in a job, so pragmatically no That page is "here are the basics", Malcolm's posts are saying that you actually need much more than a basic understanding. I think his intention was that a beginner should read all of the pages on that web site, not just the page that was linked.
|
# ¿ Jun 12, 2017 03:08 |
|
|
# ¿ May 15, 2024 02:51 |
|
Symbolic Butt posted:oh man, I vaguely remember hearing about this fiasco, do you have a link? Nah that was years ago, sorry. I recall several different reddit threads about the problem appearing on "professional" exchanges though, back when everyone in the ecosystem had no more experience than "I built my gaming rig from parts I ordered on newegg"
|
# ¿ Jun 12, 2017 21:28 |
|
Malcolm XML posted:Yes I'm going to take life advice from posting on the something awful comedy forums Did anyone actually say that? I thought it was more "you need this basic level of knowledge" vs "you need this advanced level of knowledge"
|
# ¿ Jun 13, 2017 21:40 |
|
Cingulate posted:Thanks everyone. This could be an opportunity to learn multiprocessing, if that's something you don't know already. I think your problem just calls for 2 Queues, and a Process that reads requests from queue1 and places X, y tuples into that queue2. Your main process reads X,y tuples from queue 2 and places restricted numbers of requests (which can just be None or whatever you want) into queue1 (this is to restrict the subprocess from just processing everything at once; if you don't mind all of your X,y tuples sitting in memory at the same time, you can skip having queue1 and just have your subprocess continuously pumping data into queue2) Multiprocessing sidesteps the GIL by launching multiple processes instead of multiple threads, so the best design is to generate simple data in separate processes and use more complex objects (such as the model) in your main process.
|
# ¿ Jun 15, 2017 21:03 |
|
Cingulate posted:I know joblib and multiprocessing's pool - I use them a lot actually, because most of my problems are trivially parallelizable. This one, I fear, is not: the training happens in Theano (I think I hosed something up with my Tensorflow installation?), so it compiles CUDA code for the GPU and then it sits there. So the training always needs to happen in the main thread/kernel/session. But yes, if I can send the data generation to a secondary process, that would save me some time. So this can be done with the multiprocessing module, did I get that right?.. Yes, you can do that with the multiprocessing module. In your main thread you'd start by adding a request for (X,y) to an input Queue, then you'd set up a for loop that reads (X,y) from an output Queue, places a new entry in the input Queue, and then begins running the model. A separate Process reads from the request Queue and writes to the output Queue. This creates a situation where your main process is handling the model training while at the same time a Process is creating the (X,y) tuple for the next iteration of model training. If you have enough memory to hold all of the (X,y) tuples in memory simultaneously then you can do all of the above with just 1 Queue instead of 2 (you can start a Process that just fills the output Queue with as many (X,y) tuples as you want without ever checking an input Queue for requests). Or you can use an input queue and just make sure that it never has more than M requests, in case you're worried about the generation of (X,y) tuples sometimes taking longer than a model training iteration QuarkJets fucked around with this message at 00:37 on Jun 16, 2017 |
# ¿ Jun 16, 2017 00:34 |
|
Mirthless posted:I'm using classes already though maybe incorrectly? It looks like your Fighter class defines ages for various Races. It might be better if a single Age value is defined under CClass (because all characters should have an age), and then Fighter and Race can modify it, maybe using if statements to check the race and class type and then adjusting age appropriately.
|
# ¿ Jul 5, 2017 21:17 |
|
Look into the json and ConfigParser modules, there should be relatively little required modification (or maybe even no required modification) to the dictionary that you get from json in order for ConfigParser to write out the INI file that you want
|
# ¿ Jul 6, 2017 21:56 |
|
Methanar posted:Got it working, thanks for the suggestion. It's fine code but I'd have written it like this: code:
|
# ¿ Jul 7, 2017 01:18 |
|
Loezi posted:What's the easiest library to make a GUI with, given that I require hassle-free licensing (which rules out PyQt)? PySide is LGPL which is hassle-free
|
# ¿ Jul 30, 2017 00:28 |
|
No, I don't think there's a definitive answer on whether importing a GPL module is legally distinct from linking to a GPL library. I don't think it matters so much for LGPL but it's a pretty important distinction for GPL, so I understand why people developing commercial software might want to avoid GPL code
|
# ¿ Jul 30, 2017 13:46 |
|
Thermopyle posted:Keep in mind that most answers to these type of questions will come from people who have only seriously used one or two of the options. Yeah we're all going to have our biases My thoughts are that the HTML/CSS/JS route is abhorrent, Qt (and therefore PySide) is love, wxPython is an acceptable alternative to Qt, and tKinter is a bit ugly and has a bad API
|
# ¿ Jul 31, 2017 02:57 |
|
The Coding Horrors thread killed any mild interest I had in golang
|
# ¿ Aug 28, 2017 20:28 |
|
now that python has overtaken javascript hopefully we can enjoy the rich bounty of coding horrors associated with novices using that language
|
# ¿ Sep 6, 2017 22:52 |
|
IIRC the people who made Spyder were actively trying to mimic the Matlab IDE, to act as an entry point to former Matlab users who aren't already fully consumed by Stockholm's Syndrome
|
# ¿ Sep 14, 2017 22:40 |
|
Use github
|
# ¿ Sep 16, 2017 21:46 |
|
Boris Galerkin posted:So update on the whole offline anaconda thing: The shebangs at the top of all of the miniconda (or anaconda) files are pointing to whatever directory that you installed to. So for instance if you move the folder and then try to run Spyder then it won't launch because it can't find Python (because Spyder thinks your Python lives in a specific place, but then you moved it) You have two solutions to this dilemma 1) Write a script that goes through all of the files and modifies all of the shebangs to whatever you want 2) Install miniconda or anaconda to whatever directory path that you want to use on your target system (so the shebangs will be set correctly once moved) Do either of those and then move miniconda to your target system, and it will simply work.
|
# ¿ Sep 19, 2017 08:46 |
|
Burn the Heretic. Kill the Mutant. Purge the Unclean. ... using assertions
|
# ¿ Sep 22, 2017 22:38 |
|
It's in the Science subforum: https://forums.somethingawful.com/showthread.php?threadid=3359430
|
# ¿ Oct 8, 2017 02:01 |
|
The March Hare posted:Been a while since I've had to do this but I need to make a GUI for a Python project. Need it to work on Python 3, absolutely needs to work on Windows (better if cross platform, but not required), absolutely need to be able to put it in the system tray, and would prefer it not make me want to die while working with it. Qt is pretty easy to use
|
# ¿ Nov 4, 2017 23:20 |
|
The March Hare posted:I used qt a while back and I don't remember it being difficult, but I do remember the documentation for pyqt sort of sucking. I checked out the kivy docs this afternoon and it looks totally fine, probably just going to use it and see what happens. Thanks y'all~ The documentation for Qt is extensive, and pyqt is basically just a wrapper for that. Anytime that you have a question about pyqt there's a very good chance that your question is actually about qt
|
# ¿ Nov 5, 2017 07:44 |
|
Yeah your environment probably only has 1 version of pandas installed, so your script is going to use that version. If you want a different version then you would need to either downgrade pandas in that environment (which is the easier option) or create a new environment with the downgraded pandas and then either activate that environment whenever you want to use this script or modify your script's shebang to use the correct environment's python binary
|
# ¿ Nov 21, 2017 04:22 |
|
Do you use conda? Conda lets you downgrade packages really easily, then you can just upgrade again when you're done
|
# ¿ Nov 22, 2017 06:37 |
|
Seventh Arrow posted:I'm trying to comprehend numpy arrays - I have an assignment and the first question is to create a random vector of size 20 and sort it in descending order. This is what I came up with: np is the numpy module, importing it as np just gives you a shorthand way of accessing everything in numpy. The other way is to just "import numpy" and then you'd be calling numpy.random.random(). It's very common to see numpy aliased to np in this way, it's convenient and common practice What you're really doing is giving arguments to the random() function of the np.random module. The arguments you provided are a tuple: (1,20). The tuple you provide defines what shape the output array will have. You could have also provided (20,) and it would have still given you a 20-element array. If you wanted a 4x10 array (40 elements), you'd give it (4,10), ie: np.random.random((4,10)) QuarkJets fucked around with this message at 02:12 on Nov 24, 2017 |
# ¿ Nov 24, 2017 02:09 |
|
For more information on random, you can try googling for the numpy random module: https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.random.html You can call any of the functions defined there by invoking np.random.whatever_function_you_want() with the proper arguments. The docs will describe what the arguments are and what they're used for. For instance, you invoked numpy.random.random, which according to the documentation returns a random array of floats. But what if you want integers? That page shows there's a randint function: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.random.randint.html#numpy.random.randint You'd call it with np.random.randint
|
# ¿ Nov 24, 2017 02:28 |
|
Seventh Arrow posted:Ok great, thanks! I did know about the "np" thing but thanks anyhoo So in the next question it says to create a 5x5 array with 6's on the borders and 0's on the inside. So I guess I would use ((5,5)) for the tuple, yes? I'll have to look into arranging the numbers in such a specific fashion though. random.random((5,5)) would give you a 5x5 array of random floats. You don't really want a random array of values though; you may want to use something like np.zeros or np.ones
|
# ¿ Nov 24, 2017 02:29 |
|
Learned today that PyCharm's debugger can display huge arrays in a separate window as a table of cells. I always thought this was something that pycharm lacked but I was just totally wrong
|
# ¿ Dec 7, 2017 07:01 |
|
creatine posted:Does anyone have a clear and concise resource that talks about using native C code in Python? If you have actual C-style functions dealing with regular old primitive types (float, int, etc) you can just compile a shared library and load it with ctypes. I would not recommend using Cython... for anything, really. There are better alternatives no matter what you want to do
|
# ¿ Dec 27, 2017 01:33 |
|
VikingofRock posted:Okay, so I asked a friend and he said that it's because the lambda is storing a reference to val, and so when val is updated throughout the dictionary comprehension it changes the val "pointed to" by all the lambdas. And this works: Is there a reason that you're returning a lambda instead of just x/val?
|
# ¿ Dec 27, 2017 01:37 |
|
Cingulate posted:What's bad about Cython? Don't a bunch of scientific packages use it a lot? Most scientific packages are written in compiled C or Fortran. For instance many of the Numpy libraries are compiled FORTRAN77. It's true that there are a number of packages that use Cython (including some parts of Numpy), but that's more due to Cython having been around forever than it being the optimal choice for building extension packages today. For compiling Python, Numba is faster and way easier to use than Cython. No need to write separate .pyx files that get precompiled into a huge amount of boilerplate, simply write Python functions without vectorization and then attach decorators to them; boom, C performance with much less mess For compiling small snippets of C code to be called from Python, ctypes is the fastest and easiest to use option For compiling large amounts of basically anything to be used with Python, SWIG is the go-to option and is faster and easier to use than Cython's C-interfacing features.
|
# ¿ Dec 29, 2017 02:23 |
|
Why don't dictionaries have an extend(dict) method?
|
# ¿ Jan 6, 2018 04:17 |
|
Wallet posted:I have very limited programming experience generally and even less experience with Python, so I'll apologize if this is a really stupid question, but I wasn't able to find much from googling: The best approach may depend on what you want to do with the keys and values. Do you want to iterate over every key/value pair? code:
code:
code:
QuarkJets fucked around with this message at 06:10 on Jan 9, 2018 |
# ¿ Jan 9, 2018 06:08 |
|
ufarn posted:Is there a canonical way to parallellize a for loop that is compatible with 2.7? I've seen stuff like multiprocessing, concurrent.futures, and all sorts of stuff, but no idea which is the preferred option. There are lots of options but I've always found multiprocessing the easiest to use and most widely applicable. If you have no idea what to use and don't want to explain the problem further then maybe give that a shot
|
# ¿ Jan 13, 2018 07:48 |
|
Seventh Arrow posted:Ok that does indeed make sense, thanks. But I think classes or their objects do need to be defined I think, right? That what "def __init__" is for? You don't have to pre-define cl, because it's definitely being defined in your if/elif/else block. You're setting cl to a string (eg "red", "blue", etc are all instances of the string class) in those blocks of code. This effectively means that the "cl = color" line does nothing and can just be deleted. An IDE like pycharm would point this out for you as well. If you want an instance of a color class, then you would indeed need to define a color class first. But it doesn't sound like that's what you actually want; the function you're accessing just wants a string with the name of the requested color
|
# ¿ Jan 24, 2018 10:23 |
|
Cingulate posted:What do you want to do with the data? is it literally only sorting? Because if you want to do anything more with that, you'll probably want to use Pandas, or at least Numpy. It looks like the data is such that any line with 1 integer is just a count of the number of subsequent rows until the next single-integer line wasey if you wanted to use classes you could do something like this: Python code:
|
# ¿ Feb 4, 2018 01:11 |
|
vikingstrike posted:Anybody had any issues with PyCharm skipping over breakpoints when debugging? My Google searches have failed me, and it's getting super annoying because I can't figure out how to replicate the issues. Only when I've accidentally Run the code instead of Debugging it.
|
# ¿ Feb 9, 2018 21:52 |
|
Rocko Bonaparte posted:Is there a good article somewhere that goes through some of the idiosyncrasies of Popen? I'm sure anybody here that has used it many times in different circumstances have found little quirks based on things like the OS, how the application handles pipes, what happens with arguments, shell=True, etc. I don't know of any such article, and while I'm sure one exists I will instead offer some recommendations from my own limited experience: A) shell=True will actually launch a new shell, which you want to avoid if you can; it's going to almost always be possible to use the sequence form of Popen instead of just passing in a string and shell=True, so just do that. Basically you can just build your entire command string with arguments and flags as a list or a tuple and then pass that in as the first argument of Popen, bada-bing bada-boom B) the stdout and stderr variables basically work like you'd expect, and if you want to read from them from within your Python session then there's the helpful subprocess.PIPE object. If you don't set stdout or stderr to anything then they'll just do whatever your stdout / stderr normally do (e.g. print to the terminal) C) if your Popen object goes out of scope while executing, such as when you start a long-running Popen inside of a function and then that function suddenly exits, then Python will helpfully close it for you; be sure to do something like call Popen.wait() if you actually want to keep the process running until it completes D) I only code in *nix so who the gently caress knows what a Windows environment is going to do but the same advice is probably all still true
|
# ¿ Feb 15, 2018 06:55 |
|
German Joey posted:I'm a very long-time Python user, but most of my experience has been with the 2.x line. I've used a few versions of 3.x, but mostly kept my code to be compatible with 2.x. However! I now have a job-interview coming up at a place that uses 3.6. A number of the features added to 3.x were backported to 2.7, which is good. But there are cheat sheets for the remainder. This python.org article is a starting point: https://docs.python.org/3/howto/pyporting.html Especially this section: https://docs.python.org/3/howto/pyporting.html#learn-the-differences-between-python-2-3 It links to a number of documents cheat sheets, and here's another: http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html What does your new employer do?
|
# ¿ Feb 17, 2018 03:18 |
|
Boris Galerkin posted:About the notebooks: I guess I’m asking why would you do that? What I would do, if I really needed to do this, is just open up a new blank script in PyCharm, type in my multiplication and hit f5 or whatever the hotkey is to run the script. Like I said Jupyter Notebooks seems like a great tool but I just don’t get it. Most of the stuff I’m finding online remind me of when I didn’t get Docker: lots of people saying how great they are but nobody really “showing” how great they are. I think if you're already a PyCharm user then the only other reason to open a notebook is if you plan to share the results (not just code) with someone else.
|
# ¿ Feb 23, 2018 04:38 |
|
What are those attributes? Strings? Floats? Other classes?
|
# ¿ Mar 3, 2018 22:02 |
|
|
# ¿ May 15, 2024 02:51 |
|
I would use a for loop to do the thing twice.
|
# ¿ Mar 5, 2018 01:32 |