|
suffix posted:It depend on the framework and the server. IIRC CherryPy has a decent threaded server for development mode, while Flask and Bottle just uses a single-threaded server. In bottle, it's as easy as Python code:
|
# ? Jul 20, 2014 21:16 |
|
|
# ? May 8, 2024 05:59 |
|
Carrier posted:I'm basically trying to simulate an object responding to commands to move to a certain position and I want to simulate some sort of delay in this response so that sometimes, it might not make it to the position its supposed to reach before it gets given another command. Sorta simulating like a car being told to go to point A, then to point B, and so on but it can only travel at a certain speed to get there. In the long term I was hoping to plot this movement on a graph as I read a set of preset target positions from a file, but for now I'd settle for just numerically being able to do this kind of simulation. So visually, I'd have something like (using O for object, T for target position): Yeah I understand all that but I'm not sure where threading comes in. Is there a real-time component? I think you're making it more complicated than you need to. Here's what I would do: create an object with attributes x and dx_dt (i.e. velocity). They can be scalars, or vectors for multidimensional position. To update the simulated position, do self.x += self.dx_dt * dt where dt is the time since the last update. To represent a new command being received, assign a new value to dx_dt. From there it's pretty easy to simulate things like a delay in command time or to calculate the commanded dx_dt based on some target position compared to the simulated position.
|
# ? Jul 20, 2014 21:22 |
|
HardDisk posted:I need to parse ISO 8601 dates and I found the dateutil module (https://pypi.python.org/pypi/python-dateutil/1.5). However, the latest version for python 2.X is 1.5, which is 4 years old by now. Is there any recommendations against it? Python code:
|
# ? Jul 20, 2014 21:38 |
|
Looks very interesting. Will take a look as soon as possible. Thanks.
|
# ? Jul 20, 2014 21:56 |
|
SurgicalOntologist posted:Yeah I understand all that but I'm not sure where threading comes in. Is there a real-time component? Would this method work for more complicated velocities? I was eventually hoping to have the object move towards the target following a critically damped harmonic oscillator motion.
|
# ? Jul 20, 2014 22:12 |
|
Carrier posted:Would this method work for more complicated velocities? I was eventually hoping to have the object move towards the target following a critically damped harmonic oscillator motion. Look into Kalman filters.
|
# ? Jul 20, 2014 22:20 |
|
Carrier posted:Would this method work for more complicated velocities? I was eventually hoping to have the object move towards the target following a critically damped harmonic oscillator motion. It sounds like you might want to represent the object's behavior as a dynamical system (system of first-order ODEs) given some control parameters. Then you could use scipy.integrate to update its real position (what I suggested previously was basically this but with the dynamics being simply dx_dt = velocity with velocity as the only control parameter, and using an Euler solver to integrate). Then you could implement an input function that updates the controller's perceived position of the object, perhaps with delay and noise, and an output function that updates the control parameters of the object, perhaps with delay and noise. And finally the controller logic that takes the controller's perceived position of the object and decides what commands to send to the output function. This is where a Kalman filter could go if I'm understanding that suggestion correctly.
|
# ? Jul 20, 2014 22:30 |
|
Thanks for everyones help! Looks like this is going to be a little more involved than I had first hoped... Should be fun!
|
# ? Jul 20, 2014 22:37 |
|
Is there a way to use list.count() for a 2 dimensional list? I have a list that's like: mylist = [['dog',True],['cat',False],['horse',True]] And mylist.count('dog') and mylist.count(True) both return 0. If the command doesn't work, is there another way? I was just going to do something like: code:
|
# ? Jul 20, 2014 22:41 |
|
Well you could either flatten the list first, then use count, or if you know you're only looking for dogs and cats in the first element (etc.) something likecode:
code:
|
# ? Jul 20, 2014 23:58 |
|
the posted:Is there a way to use list.count() for a 2 dimensional list? What are you trying to do? Without knowing any more details and just trying to provide a quick solution I'm going to suggest using a dictionary. code:
|
# ? Jul 21, 2014 00:00 |
|
Lyon posted:What are you trying to do? I have a list that contains two columns: Column A is made up a mix of 4 different strings, and Column B is True or False. I want to easily get a count of one of the strings in Column A and the amount of Trues.
|
# ? Jul 21, 2014 00:07 |
|
the posted:I have a list that contains two columns: Column A is made up a mix of 4 different strings, and Column B is True or False. If you want to deal with tables of data in python you should very seriously consider using pandas.
|
# ? Jul 21, 2014 00:28 |
|
Nippashish posted:If you want to deal with tables of data in python you should very seriously consider using pandas. SurgicalOntologist has already been grumbling at me to use it for my 5k data experiment earlier in this thread, I'll give it a look eventually!
|
# ? Jul 21, 2014 00:41 |
|
the posted:SurgicalOntologist has already been grumbling at me to use it for my 5k data experiment earlier in this thread, I'll give it a look eventually! Although in truth you should be using pandas, I don't believe that's what I grumbled. SurgicalOntologist posted:You don't need pandas for that though (well you need it installed as a dependency), you can make the plots straight from your existing lists
|
# ? Jul 21, 2014 02:06 |
|
the posted:I have a list that contains two columns: Column A is made up a mix of 4 different strings, and Column B is True or False. Python code:
(Any word on wesm's next thing? I cannot remember what it's called for the life of me, but it's supposed to be a better pandas IIRC)
|
# ? Jul 21, 2014 02:14 |
|
ohgodwhat posted:(Any word on wesm's next thing? I cannot remember what it's called for the life of me, but it's supposed to be a better pandas IIRC) It's an online data analytics system or something like that. He gave a talk about it at pydata: https://www.youtube.com/watch?v=wPEmoT018s8
|
# ? Jul 21, 2014 02:38 |
|
the posted:SurgicalOntologist has already been grumbling at me to use it for my 5k data experiment earlier in this thread, I'll give it a look eventually Instead of coming in here all the time asking about the best way to do some convoluted task, you should probably start taking the advice of the people in this thread and use some of the tools they recommend. Have you noticed that the first response to your posts is typically "what are you trying to do?"? Maybe devote a little time to something like pandas and then look back at what you were trying to do before and have a good laugh. On a somewhat related note, are you related to forums user Pollyanna by chance?
|
# ? Jul 21, 2014 03:01 |
|
I've been working through Pandas tonight And No, why do you ask? edit: \/\/\/ I was assuming that PollyAnna was "another forums user who asks way too many annoying questions." the fucked around with this message at 03:48 on Jul 21, 2014 |
# ? Jul 21, 2014 03:38 |
|
Modern Pragmatist posted:Instead of coming in here all the time asking about the best way to do some convoluted task, you should probably start taking the advice of the people in this thread and use some of the tools they recommend. Have you noticed that the first response to your posts is typically "what are you trying to do?"? Maybe devote a little time to something like pandas and then look back at what you were trying to do before and have a good laugh. This is a pretty rude response for the Python information and short questions megathread, and the has clearly learned how to do a lot of things coming from a non-programmer background.
|
# ? Jul 21, 2014 03:42 |
|
kraftwerk singles posted:This is a pretty rude response for the Python information and short questions megathread, and the has clearly learned how to do a lot of things coming from a non-programmer background. Sorry for the tone. I guess I'm turning into a crotchety old man. I realize everyone has to start somewhere and the really has made some good progress, but I get a little frustrated when the first instinct of some posters is to post in the forum rather than thinking through a problem for a bit or googling around. I think this only got to me because I read the past few pages of posts in rapid succession. the, keep doing what you're doing.
|
# ? Jul 21, 2014 12:52 |
|
It seems like Pandas just making numpy behave like data frames from R or tables from Matlab. Is that the basic idea or is there more to it?
|
# ? Jul 21, 2014 16:50 |
|
That's the basic idea, yes. It's a relatively simple library when you realize it's fundamentally just providing a single data structure (really, three: Series, DataFrame, Panel).
|
# ? Jul 21, 2014 16:54 |
|
Weird question: is there a Python library that acts as an alternative to the Make utility? I.e. dispatching function calls based on missing or outdated links in a dependency graph?
|
# ? Jul 21, 2014 17:24 |
|
SurgicalOntologist posted:Weird question: is there a Python library that acts as an alternative to the Make utility? I.e. dispatching function calls based on missing or outdated links in a dependency graph? Do you just want to write your Makefile in Python, or do you need an actual library that you can invoke programatically?
|
# ? Jul 21, 2014 18:50 |
|
good jovi posted:Do you just want to write your Makefile in Python, or do you need an actual library that you can invoke programatically? The latter I guess. Although I'm not really sure what you mean by the former. Really I'm just curious what's out there. I have some ideas for a domain-specific build system I'd like to put together, and I don't want to start from scratch. It could work with Python scripts running from the Makefile but that would be less than ideal.
|
# ? Jul 21, 2014 19:09 |
|
https://wiki.python.org/moin/ConfigurationAndBuildTools
|
# ? Jul 21, 2014 19:17 |
|
Fantastic, thanks. E: Any of these particularly well-respected or does anyone have a particular recommendation? After a quick browse (Python 3 support, Pythonic API, active development) my list is down to paver, doit, fabricate, and pynt. SurgicalOntologist fucked around with this message at 19:29 on Jul 21, 2014 |
# ? Jul 21, 2014 19:22 |
|
the posted:Find every prime number between 0 and 100. I did this! Any recommendations for more projects?
|
# ? Jul 21, 2014 20:28 |
|
rock2much posted:I did this! Just work through the problems on Project Euler.
|
# ? Jul 21, 2014 21:40 |
|
Something weird's going on in Pandas. So, I loaded up that race data. It's in a CSV with three columns:code:
code:
code:
|
# ? Jul 22, 2014 01:08 |
|
rock2much posted:I did this! Write a code that checks to see if a supplied string is a palindrome or not.
|
# ? Jul 22, 2014 01:10 |
|
the posted:Something weird's going on in Pandas. So, I loaded up that race data. It's in a CSV with three columns: What does it mean to plot MEAN age vs time? Your last result gives you the mean time at each distinct age in the data frame. Do you want to plot the mean time for each distinct age?
|
# ? Jul 22, 2014 01:23 |
|
Jose Cuervo posted:What does it mean to plot MEAN age vs time? Excuse me, I miswrote that. I want to plot the Age vs. Mean Time (for that age)
|
# ? Jul 22, 2014 01:25 |
|
rock2much posted:I did this! Project Euler is alright, so is checkio.
|
# ? Jul 22, 2014 01:26 |
|
the posted:How come this gets put into one column? I'm trying to find the mean for each age and then plot mean age vs time, but it ends up throwing errors afterwards because there's only one column now in the data. I'm not sure what else you expected. Those numbers are the mean times for each age. Of the three original columns, time is still there, gender is gone because you can't take the mean of strings, and age is in the index because it's what you grouped by. You should be able to plot a single column no problem, it will use the index for the x axis. What happens when you do Python code:
code:
Python code:
Python code:
|
# ? Jul 22, 2014 01:28 |
|
And the mean plot follows the path I was more or less expecting originally. Peaks at the really young and really old: the fucked around with this message at 03:53 on Jul 22, 2014 |
# ? Jul 22, 2014 03:50 |
|
Cool! Now try it again without the outlier, and use the "advanced" syntax to customize a bit:Python code:
|
# ? Jul 22, 2014 04:29 |
|
Interesting, I don't know what you did there, but interesting:
|
# ? Jul 22, 2014 04:34 |
|
|
# ? May 8, 2024 05:59 |
|
1. You removed the outlier with the methods drop and argmax (since you only wanted to get rid of one outlier it was straightforward). 2. Instead of using the "shortcut" function jointplot, you used the JointGrid object, allowing you to specify which plotting functions to use on each axes. 3. On the bivariate axes, you used regplot isntead of the default scatter, which added the best-fit line. 4. On the two univariate axes, you used distplot instead of the default histogram, which added the kernel density estimate. In the end, it looks like you don't have much of a correlation. You might try the gender plot I suggested earlier, simply because you have that variable you may as well examine. Also, do you have data as to which race each data point is from? That could be interesting.
|
# ? Jul 22, 2014 04:43 |