« first day (3379 days earlier)      last day (1792 days later) » 
06:00 - 18:0018:00 - 00:00

18:09
@Kevin I'm back and digging into that threading example more
@PaulMcG I saw your tweet about record players. I still self-identify as 'young', so I disagree with you :p
Just to make sure I'm not firing up a thousand superfluous on_idle calls a second or anything, I've been running my threading code for the last 108 minutes. It seems as responsive as it was when I first started it.
So there probably isn't any kind of runaway resource allocation going on
Yea I'm not sure. I ran it again and it acted slightly differently
I do have /some/ logic going on in there, but that shouldn't matter should it? Or is that what's killing it?
And by some logic: I'm parsing a small xml file pulling one child out to display on the screen as well
I wouldn't expect anything like that to cause a fifteen second lag like you described earlier
Hmmm I'm going to check something else. May try to see if it's something in my logic hanging. Going to see about inserting some way to see how long a loop is taking
So it looks like it's working fine when I debug which is weird.
18:32
dost thou haz a heisenbug?
kevined
Kevin: is there a good way to flush the queue?
Not that I know of. It's not an issue for my example code because the queue almost certainly never grows larger than one item long. The worker thread adds an item once a second, and the GUI thread removes an item sixty times a second.
i even put in a check to make sure the queue was empty before putting another message in the queue
and it's still lagging
How mysterious
18:38
Yup, worst part you don't have the hardware to test with it to help to see what's going on haha
I think it's something with that
If you're suspicious of the peripheral, it should be easy enough to switch out your hardware-interfacing code with something that returns fake data
Much like the get_temperature function in my code, which makes zero effort to monitor the actual temperature
Yup that's what I'm getting ready to test.
This seems like a good time to mention that when it comes to MCVEs I have very low standards for "minimal" as long as the example is complete and verifiable
I can, have, and will debug programs for strangers that are a thousand lines long
What's interesting though, is that it's a laser distance thing. I'll change the distance (I know I am) and it will show up 10 seconds later, then I move the distance further and it takes 10 seconds to change back to the far distance...but the values are still changing in the range you'd expect at the relative distances. So it truly seems like the message queue is getting "clogged" so to speak
Haha lemme see what I can come up with, sometimes talking through it just with strangers helps. Although at this point, I'm going to pull a Bobby Bouche and say talking it over with friends ;)
@Kevin I have this "Windows 10" program running on my machine...
18:43
You will need an exorcist
@Kevin I just had a thought tho...while I'm checking my code with dummy data: can you verify that what your RNG is spitting out is what is on the screen?
Since it's random...you never really know if it's showing the same iteration?
I can add print(message) to the worker loop, which would at least verify that only a small amount of time passes in between "worker adds message to queue" and "gui takes message from queue and displays it"
On a fresh instance, the amount of time is seemingly instantaneous. Ask me again in 108 minutes.
You see where I'm coming from at least on that? My stuff is changing....it just seems to be lagging.
Whereas in your example it's all RNG so you'll never know if it's displaying the proper iteration or not....just curious more than anything.
Each of my messages has a timestamp, so I can tell whether the gui is lagging behind.
Lazy solution: when you create your queue, give it a maxsize of 1
wim
wim
@MisterMiyagi would like to hear more on that
18:51
Kevin (I dont' want to keep pinging ya ;)) I've got it set to check to make sure the queue is empty before adding any other messages to the queue
wim
wim
I think the concurrency in go is effective. It's the lack of exceptions in the language that mainly annoys me.
however, the notation says it's not reliable.
if my_queue.qsize() == 0: my_queue.put(x) Is unreliable in the sense that, by the time .put(x) is about to execute, the qsize may have changed to something larger than 0 because another thread also called .put(). But if you have only one thread that can call .put(), it's reliable enough.
The tooltip I'm referring to says that queue.empty() is unreliable
18:57
Same reasoning there.
Why can't I change Python. Why does reading with open(False) work to "Why does reading with open(False) work" when that exact phrase gives me no google matches?
Gotcha.
You seeing any inconsistancies in your rng vs display?
Nope
> False (aka 0)
well that's a bit misleading
i am having a little trouble: rn i've a project where, when a user does [something], a message is sent to a queue, a worker picks up on that message and sends a text. when that text is responded to, some other stuff happens
wim
wim
19:02
hah, funny
now we want some means of "timing out" (i.e. - if that text isn't responded to within an hour, send a timeout message)
@roganjosh Hmm, it rejected my edit, too. Then it accepted "Why does reading with open(False) work?". I can't explain it.
The bar on me renaming suggests to me that it's a dupe name. But it's not
Maybe it likes question marks and backticks
how might i go about implementing a timer, though? since this is a production-level product, i don't want like... separate processes with a timer for each text (that'd bloat things up in a huge way)
i was thinking somethingsomething signals, but that doesn't seem to actually solve the problem
19:05
Hmm, seems tricky. If the worker pool is too busy to handle the message, then surely it's also too busy to handle the timeout
i wouldn't mind if the worker had to handle the time out message (that is, if it had to send the "your message has timed out text), but, yeah, it certainly shouldn't handle the keeping-track-of-timing-out itself
i just don't know what could handle it, without severely bloating things
wim
wim
If you can read from False I wonder if you can print to True
hello>>> with open(True, "w") as file: file.write("hello")
...
5
hello>>>
wim
wim
works in plain REPL. crashes horribly in IPython REPL.
@Kevin except in KevinOS where it sends the stream to Alpha Centauri using the Arecibo Observatory
(here's hoping that Alpha Centauri passes through zenith)
19:10
@AmagicalFishy perhaps you could have a single process that is responsible for all timeout messages. If all messages have the same timeout duration, then you only need to check the topmost element of the queue to see if it has timed out. Since presumably everything else in the queue has a later timeout time, if the topmost element hasn't timed out yet, then neither has anything else
Kevin: better question. Since I'm a newb and just need to get something working for a demo, would it be possible to do this without threading and manually push updates to the tkinter window? Or is threading necessary?
i may end up doing something like that, yeah. as it is, the different workers we have already run in their own little docker container
maybe the best solution is just making another worker devoted to handling timeout-stuff
@biggi_ Not that I'm aware of.
I'm running into an issue with pandas that I'm not quite understanding. I'm attempting to use "vectorization" which, being relatively new to python (I come from the .net world) is unfamiliar to me (I read about it an hour ago in a handy blog post on speeding up pandas data transformations).

I have managed to add a column to my dataframe that is populated with booleans using (psuedocode)

`def Calculations(a, b, c, d)`
` result = a < b & d > d`
` return result`

`df[newColumn] = Calculations(df[a], df[b], df[d], df[d])`
@Sidney for what it's worth vectorization is not a native python thing
19:14
Oh well that makes life much less simple.
please see our code formatting guide for chat and practice in the sandbox if necessary
Ok, I'll clean it up and be back in a bit.
sure thing
Looks like I've got some digging to do.
Also, since ETH is officially ded, we'll get rid of my crypto image :(
@Sidney And in order to vectorize you at least need result = (a < b) & (c > d) (fixing the typo), and maybe more. Note the parentheses.
since you have series as inputs this will probably work
19:18
Yeah, but when I try it (the 1 if result else 0) it gives me 'Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()'
Ah, I didn't read all of your question, sorry. Let me do that.
Well, what you have right now in the pseudocode (what I wrote) should exactly be "1 if result else 0" for each row...
wim
wim
officially dead? huh?
if you take my expression and feed it 4 pandas series of the same length, as in your pseudocode example, it should do that
Ok, I'll give it a shot. I have a meeting at 1:30, so I can't at the moment. Thank you though!
Many C# linq expressions have exact equivalents in Python list comprehensions. But, alas, you (usually?) can't use list comp syntax on dataframes / np.arrays. They're more of a list thing.
19:21
@Sidney Sure thing, no rush. You can ping me when you get around to checking it. If it doesn't work, write a non-pseudo example that doesn't work and post it to pastebin/github gist/etc. and link here.
@Kevin well you can, just often shouldn't. With pandas you often even should...
Well with dummy data this is running fine. So at this point it's either a) not getting the data I'm looking for (which it appears I am) b) I have wonky variable stuff or c) I'm doing something goofy in loading the queue.
@Kevin I fixed it by moving where I'm loading the queue to right after getting my data instead of after some logic...doesn't make sense. Putting together a gist now to see if I'm missing something.
Kevin: Here's a rough/sanitized gist. If you want one to run, I can maybe make that happen, but as of now, moving it up to where it is now runs fine. If it was down below where the comment was, it lagged. No idea why? gist.github.com/biggidvs/72376f2e79f26aab6f4a92d965d8206b
19:44
¯\_(ツ)_/¯
I mean any reason it would work there and not where it was originally????
I'm so confused now :(
I know this is just a gist, but you do know that "except: pass" is one of the Classic Blunders
Yes; I have it letting me know what happens/etc in the non-sanitized version :)
I guess I shouldn't be as cautious on some of this haha. It probably doesn't matter if I sanitize or not
removing fluff is fine (even preferred) as long as you're not removing the bug and not introducing confusion
19:58
Right. This doesn't remove the bug and introduce confusion. All that's in that except bracket is a print message that the device is either still spinning up.
The runaround of "oops, my attempt to remove cruft also removed the bug" is why I accept 1,000 line CVEs :^)
Can't accidentally excise the problem if you don't excise anything
Jun 7 '18 at 13:13, by PM 2Ring
Bare except is bad enough, but except: pass is the Python equivalent of sticking your fingers in your ears and shouting "La la la, I can't hear you".
^ I agree. But literally, I changed variable names/comments out and removed what's going on in the except (which is literally just that it doesn't have a value for that particular index)
And still no idea why changing position like that made it work real time vs lagging 10 seconds.
Programming is confusing. Hardware all the things.
Wild guess: for angle in range(140,161,1): if angle in scan1_raw: ... takes ten seconds to execute
but it doesn't....which is weird
If I put a breakpoint at the top for debugging, it takes <1 second to get back up to that point again
20:02
@PM2Ring :(
So the only thing I can think of is there's some sort of reference issue or something going on
In the absence of a CVE I can give no helpful counsel
I really dunno how to do it without you having one of these devices
:shrug:
Contact the manufacturer? National Instruments or whatever
@biggi_ When using random numbers to test stuff like that, you should call random.seed (with a fixed seed number or string arg) to get a reproducible stream of random numbers.
@AndrasDeak Well, mods have had a timeline icon since forever, and I assume that's where it normally sits. See meta.stackexchange.com/a/342316/334566 BTW, we have Shog9 to thank for the new timeline code.
20:18
yeah, I've read it
@biggi_ Ok, sorry if I derailed the discussion from your actual issue
Haha you're fine ;) Anyone want to remote in to my PC for the MVCE? XD
I'm not really opposed to teamviewer haha
21:01
@Kevin found it, my raw data is lagging that much....which is also confusing in itself. Need to clear the buffer on the lidar after taking my reading it looks like.
*reset_input_buffer
21:24
Pro-tip: vars() and locals() within a generator expr or list comp will only give you variables you have defined within the genexp or listcomp.
21:42
I'm trying to think of in what scenario did you run into for you to hit this case
@MooingRawr Nothing flattering
@Sidney Andras was asking you for a clear MCVE. Anyway I think you mean you want a 2-way or n-way select operation. See Pandas conditional creation of a series/dataframe column.
@Sidney : vectorization is a concept in numpy and pandas. Not base Python. Just say your question is about numpy or pandas, rather than Python, since not everyone here is into those.
@smci I asked after that post, which they understood, they just have to leave. I told them there's no rush, because there's none.
@AndrasDeak Right. But I betcha Pandas conditional creation of a series/dataframe column is what they're trying to do. Vectorized 2-way or n-way select.
21:52
probably, yes
user10984358
22:10
If I want my python script to schedule other python scripts (I have a PyQt gui that lets me choose scripts) in Windows, is using “schtasks” from a subprocess call the better way or are there better options? I looked at a third party scheduler module and this stackoverflow.com/q/26160900/10984358
wim
wim
psychic debuggers: who can guess the X of the XY problem here? How to inline lazy evaluation
The question as written leaves me pretty confused, but maybe there is something useful behind it..
@MooingRawr probably fixing a 2.7 code (which did not have a hidden scope for list comprehensions)
22:31
No, just fixing 2.7-thinking in a 3.x-world
@wim I think they want short circuiting (a la and) when calling all().
what float object can I use instead of find in here
raw_data['CLUB_DEBUT'].apply(lambda x: x[x.find("("):].replace("(","").replace(")",""))
What do you mean "float object"?
2 days ago, by Andras Deak
@ruben.lfdz then I suggest that you first read a python tutorial then a pandas tutorial
@ruben.lfdz what are you attempting to do here? Can you provide a full working example that gives the exact error you are trying to fix?
22:39
you're getting close to "not even wrong" territory
@Code-Apprentice attribute sorry
@ruben.lfdz Your question is unclear, confusing and grossly incomplete. Please come back with an MCVE.
@ruben.lfdz That still doesn't clarify what you are asking. See my previous requests.
:48353581 Error: 'float' object has no attribute 'find'
find() is a method on str's, and you are (or pandas is at your behest) calling it on a float -> fail
wim
wim
22:44
aww, where did the _[1] symbol go that you could use to get a reference on the target list itself during a list comprehension
It looks like you are trying to extract a parenthesized bit from a string, and then removing the parens. Not pretty, but a guaranteed fail when x is not a str.
fixed I guess
@wim In my recent list comp heresy, I found something like ".0" on Py3.6
wim
wim
yeah , that's the iterator obj not the target
that's still there, but not useful for nefarious purposes.
@PaulMcG that's what I'm trying to do and why I'm failing, also why I'm here, to see if you could help. thanks a lot!
wim
wim
22:48
and it's not even useful when iterating a list obj (which are "rewindable" iterators) because it seems to get implicitly transformed into a tuple iterator! d'oh!
>>> type([locals()[".0"] for v in b'0'][0]).__name__
'bytes_iterator'
>>> type([locals()[".0"] for v in u'0'][0]).__name__
'str_iterator'
>>> type([locals()[".0"] for v in {'0'}][0]).__name__
'set_iterator'
>>> type([locals()[".0"] for v in {'0':'0'}][0]).__name__
'dict_keyiterator'
>>> type([locals()[".0"] for v in ('0',)][0]).__name__
'tuple_iterator'
>>> type([locals()[".0"] for v in ['0',]][0]).__name__
'tuple_iterator'
@ruben.lfdz Go to separate chat room I just opened
Thanks, Paul
wim
wim
removed by Martijn in 3.8 bugs.python.org/issue32836
23:48
Turns out that if you leave SO because of the overwhelming quantity of low-quality content, moving to r/learnpython isn't going to work out for you either. In hindsight, this shouldn't have taken me multiple weeks to figure out.
wim
wim
pip is so hacky it's unbelievable sometimes: github.com/pypa/pip/blob/master/src/pip/_internal/utils/…
@Aran-Fey sounds like you learned that the hard way
Yup. Correcting/fixing bad code on reddit is even more fruitless than doing it on SO.
@wim it doesn't even check the marker contents?
Unlikely file name I guess...
@Aran-Fey at least learnpython sounds like it's designed for that
Well, like on SO, the low-quality content isn't only created by the askers...
06:00 - 18:0018:00 - 00:00

« first day (3379 days earlier)      last day (1792 days later) »