« first day (3695 days earlier)      last day (1236 days later) » 

12:00 AM
I have a matplotlib plot that is updated periodically with plt.pause(.001), and by calling plt.ion() before the figure and axes are created. However, the UI seems to be frozen most of the time. Any way to keep the UI working at all times?
 
First, try setting a longer interval for debugging, 1 ms might be too ambitious. Say, 0.1 for now. And then see if fig.canvas.draw() helps.
if that's not your issue then you will probably have to provide a small example, "UI working" sound a bit like interacting with the figure as it's being replotted and I don't know how well these things play together
Actually, I've never seen plt.pause() so I might be missing something here
"Run the GUI event loop for interval seconds" sounds like it would work non-interactively. With an interactive plot I'd just think to use a sleep(). But as I said I have no experience with this, so I could easily be wrong.
Yeah, I'm at least partly wrong: non-interactively plt.show() blocks so you don't get a chance to call plt.pause.
 
12:18 AM
Matplotlib's system is pretty confusing. I'm looking at matplotlib.org/3.3.2/users/interactive.html.
I tried all sorts of things/combinations but can't get it right.
 
Are you familiar with how GUI event loops work?
because I'm not and I'm pretty sure that doesn't help with my understanding of this aspect of mpl
In any case that page explicitly says that plt.pause should keep the figure responsive. So have you checked whether a longer pause helps?
 
@AndrasDeak Not very.
@AndrasDeak Yes, I tried increasing the pause interval. Didn't work, unfortunately.
But the problem is really that the UI seems to be frozen outside that interval.
 
Matplotlib sucks for this, btw
 
I'm looking at what they wrote about event loop integration.
 
@user76284 that sounds reasonable, based on what plt.pause claims to do
If I understand correctly it's like a limited-time plt.show()
 
12:23 AM
Yeah.
 
While the pause is running execution passes to the GUI which is then responsive. When the pause returns you're back in user python land.
 
In my case, I just want the plot to remain active while the program occasionally updates it.
 
I have to go to bed really soon but live plots can be done in other ways, if you can give a 30 second brief on what you're doing
 
@roganjosh See above.
 
@user76284 I'd expect that plt.ion() should readily do that, without any other trick
 
12:24 AM
@user76284 Not enough for me to understand. mpl can't really be embedded in a lot of applications these days
 
I'm running a heavy computation that outputs values at each iteration, and would like to have a plot of those values in the background to see how it's progressing.
 
For just you and not others?
 
I'm not sure what you mean.
Specifically I'm plotting learning curves in an ML setting, while the training is taking place.
 
JS plotting outstrips Python plotting by far. Plotly, for example, could embed JS in a Jupyter script. That would only be visible to you, as the runner of the Jupyter script. Or, you want to give feedback to someone else on how their script is running, in which case you could use Dash or Flask, for example
I guess what I'm asking is; does this boil down to you just sense-checking a long-running process as it runs? Or is it something that should make sense to people that aren't you?
 
Both, ideally. Why?
 
12:32 AM
Because mpl is unlikely to be the way forward in the latter case
 
Are you suggesting another plotting framework?
You mentioned Plotly.
 
I haven't used much of plotly in Python, I generally use Plotly.js embedded into sites, but that's one. The other is Dash, which is built on Flask. Maybe I'm biased but mpl will be difficult to share
Both (I think) will spawn browser windows vs. GUI windows
I best get that one figured out before I give a tutorial to the company next week... deadlines are fun
rbrb
 
12:58 AM
So @user76284 I think the problem is that you can't have an ongoing calculation of your data and a responsive GUI at the same time, at the end of the day due to the GIL. As long as the GUI is responsive it's in control of execution, so you can't be computing further data points in the background. And vice versa.
That being said ipython and friends somehow pull this off. I have no idea how.
 
 
3 hours later…
4:18 AM
cbg all, can anyone tell me how they remember all([]) # True ? I read something about vacuous truth, I just want an easy way to remember this
I just want to associate this with something so I dont have to go to the repl after a couple weeks to check
all elements are "Not False", is that justified?
 
4:39 AM
any() and all() are all about short-circuiting. When any() finds its first True value, it returns True immediately, else False. When all() finds its first False value, it returns False immediately, else True. When the sequences they are iterating over are empty, then each goes to its "else" part; so any([]) return False, and all([]) returns True.
 
I knew they short circuited but thinking of them as if...else make much more sense, thanks Paul
 
4:55 AM
That being said, when I use them in code, I still fire up a Python repl (very easy in PyCharm) just to be sure.
 
ahh the Disclaimer :D, I mainly use them in code sites and only check if the tests fail
I have the repl at sublime but for some reason it uses a different python, would rather have terminal open
 
5:17 AM
ufufu
waiting for 1.2 docs to update with cross join
 
@python_learner As you get more accustomed to writing tests for your own code, you'll start to think more about "what if the list that gets passed to this function is empty?" and "What if the list that gets passed to this function isn't a list, but a generator, or a database cursor, or a set, or a tuple or a dict?"
The big gotcha is usually when you assume you are getting a list, and so you iterate over it multiple times. Then when you get passed a generator, only the first iteration gets anything, all the rest silently get no items.
Which I think is a flaw in the design of generators. After having served up a StopIteration exception, generators should subsequently raise a different exception, like InvalidGenerator or ExhaustedGenerator, to differentiate from the nominal StopIteration that you get from reading through a generator to the end.
 
Is there some way to set the default pickle protocol version globally? So that very time you pickle.dump it uses that protocol version?
 
Try assigning to pickle.DEFAULT_PROTOCOL. In the Python version I'm looking at (3.8.6) it defaults to 4.
But it looks like if you change that value, the pickle module code will choose whatever you assign there as the new default.
 
5:38 AM
you can post the suggestion here if its python related
not sure about self promotion if that is what you are up to
 
I am sure that spam is not tolerated here - flag it as spam for moderator attention
Wow, they spammed a bunch of chats!
 
even sand box
 
nuked from orbit, I believe
 
 
2 hours later…
7:54 AM
@Mikhail Can you shed some details on what you are trying to do? Usually, the protocol version only needs fixing for a specific conversation. Depending on your use-case, preparing a separate Pickler or just a partial pickle.dump might work.
 
 
1 hour later…
cbg folks
 
9:49 AM
scrapy_proxy_pool raises Response content isn't text. Please help me with the problem. It's killing me....

https://stackoverflow.com/questions/64971689/raise-attributeerror-response-content-isnt-text-scarpy-proxy-pool-how-to-solv
 
if you have enough reps you can post a bounty
 
I have 71 reps
 
if you are not aware you can go through that
 
Okay thank you.
 
I guess if you post a bounty for 50, you come to 21 reps and if anyone downvotes it I guess you will lose access to chat, not sure
 
9:57 AM
and setting up for bounty requires 75 reps.
That is my next privilege.
 
you can try editing questions on main that you are confident on, once your edit is approved you will get 2 rep
so try doing some meaningful and useful edits to two questions on main, of course if you want to answer and gain votes that is all yours
nvm, I actually upvoted your question since it already had 2, you are at 81
 
10:33 AM
Bountied....
 
@python_learner that's a very bad reason for an upvote
 
10:53 AM
@python_learner what does nvm mean?
 
11:10 AM
Hi is anyone here? :)
 
11:24 AM
@CharlieShuffler Hello :)
 
12:01 PM
how can i identify the font of a text in an image?
 
@Praveen first do OCR to identify letters, then compare the letter shapes to very single font that exists
 
and font size?
 
if you know the font type you can match the size, I bet :P
 
no
 
it can't take more than 6 months to implement all that
 
12:04 PM
i have only 15 days left to do all that
 
Have fun with it :)
 
and font colour
how can i identify the font colour?
 
Is this part of your "write a browser from scratch" project or is this another endeavour?
@Praveen I would expect that looking at the colour would help
Assuming it's not a grayscale image.
 
well its another, why do u always compare my question with an old one?
 
@Praveen because you keep asking how to solve grossly complex questions. That's usually a sign that someone is not approaching problems correctly.
 
12:06 PM
i got how to do it, i will extract the location of the text in an image and see which colour is dominant
 
It's possible to write a browser from scratch, and it's possible to identify fonts with sizes, but the people who can typically do that don't have to ask "How do I write a browser from scratch?".
 
@AndrasDeak yeah i get confused all the time
 
@Praveen perhaps you should start smaller. Like, a lot smaller.
 
@AndrasDeak i already wrote a html and css parser but i am looking forward to the gui part of it
 
"How do I build a Porsche?". Well, you normally don't. Or at least not starting with a Porsche.
3
 
12:08 PM
^
 
lol
 
Especially if you have things like a 15-day deadline
know your scope
 
@AndrasDeak the browser one isnt 15 day
 
@Praveen that's reassuring
 
browser one is like an year
maybe more than tht
 
12:09 PM
then there's hope you'll be able to finish it
 
yep but i have to do this ocr, wer i was confused at first now i got it
 
@Praveen "have to"? Ask the person who makes you do it for help.
 
its me and its my self imposed deadline LMAO
 
Oh my Lord cabbage
 
Side note: Usually, setting deadlines without understanding scopes and the tasks involved is left to bad managers and bad bosses. "Scoping" comes first, just declaring "i must finish this in 3 seconds" doesn't make it happen.
 
12:38 PM
@ParitoshSingh well its because i am lazy and i dont know when to do what so, well tht ocr thing can be finished in 15 days its not tht hard
 
"tht ocr thing can be finished in 15 days its not tht hard" This part...how do you know it's not that hard? Did you sit down and figure out the steps involved in getting a working solution?
 
i am going to use pytesseract
i wont do tht from scratch lol
 
Essentially, try to reason out the silent assumptions you're making here, and see which ones make sense and which ones dont. As always, if you're making guesses about the difficulty of some tasks, make a mental note about it.
 
ok
 
1:31 PM
Hi everyone!
I'm using flask framework i made an API and getting werid error whenever i'm trying to hit the function it says:
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a Urlbuilder.


While i am returning object and this error is making me going nuts since i'm new to this framework and python, could you please tell what silly thing i'm missing here?
 
can you copy the content of your view function into some pasting tool (like dpaste) and link it here?
 
sure
please check the code in the link
 
huh, I've never seen a class getting turned into a view.
 
1:48 PM
the example in the docs dont decorate the class
 
I don't really get it, if it's already decorated as a view, why add it to the api explicitly? @HabibRehman did you follow some kind of tutorial that advised you to use this pattern?
 
2:11 PM
@Praveen One way would be to train a neural net on the possible fonts and colours. Of course it wouldn't be perfect, but with a large enough training set I'd have thought you could get there in a week.
Unless you actually have to recognise and distinguish between individual characters, but I didn't see that in the requirements ...
As to size, that would assume all samples were scanned at the same resolution, wouldn't it? Or would size in pixels be good enough?
 
@Arne Nope, it was working fine just after i wrote this new class it started throwing error
that's why its really weird to me, i thought there must be something silly which i am unable to see
@python_learner sorry, didn't get that how can it be un decorcated ?
 
morning cabbages, folks
 
Good morning @inspectorG4dget , i see you, i see some hope
 
One typically undecorates a function or class by deleting the decorator line
 
@HabibRehman where? I could use some hope this morning
 
2:29 PM
@inspectorG4dget I'm not new to programming but definitely new to flask / python.
And this the explanation https://dpaste.org/CRyO

My class is throwing error of view, coul you please help identify what i'm doing wrong here.

@Kevin sorry mate, went over my head as i disturb the indentation of function i get error straight away
 
I'd love to help and I'll certainly take a look. But I want to set the expectations correctly: I know nothing about flask
Also, that page 404s
correction - I know one thing about flask: it's really useful to hold a single malt for when you need it
 
haha, no worries we would just need the experience I guess and nice suggestion btw
 
yeah, so I can't even look at your code because your link 404s
 
wow, i just tried and it works for me on normal window and doesnt on incogeto
hmmm, let me make a new one real quick
could you try this one please dpaste.org/tOXB
 
your code is now visible. What's the error? Do you have a traceback? nvm I see it
 
2:38 PM
yes i have written the traces in the end of the file
i am staring at my code for long now hoping it confesses itself
 
my guess is that MasterSignup.get is not being called. Rather, the MasterSignup instance is being returned. If I were you, I'd put a print inside that get method to see if it's actually being called (my guess is that it is not being called). Meanwhile, you still need a way to get that dataresponse to come through. I don't know how to do that, but I might start by looking at the __repr__. Though I'm sure someone else here might be able to say something more useful
 
yes let me try to check this first, easy thing to forget quickly
 
@inspectorG4dget Closed - delete-worthy too, I'd say
 
indeed. And done
 
2:58 PM
@inspectorG4dget lol
 
3:17 PM
Hey guys been learning about git today and I was able to integrate it with my pycharm
Indicates using pineapple repository but what advantages does it have or should I use github instead?
 
> This can be interfaced with Pineapple, Champlain’s own project management server, in order to backup and save your project in a versioned way.
Champlain's tutorial explains how you can use Champlain's project management server
 
Yeah although I can't seem to find any info about pineapple when I google it
 
Git doesn't need a remote server, you can even use it locally. But yeah, github is one of the largest (if not the greatest) player. But it's owned by microsoft now.
 
Except lots of github pages wondering what benefit it has
Ohh so pineapple is basically like github right?
 
I assumed that was the case from your question; I have no idea
 
3:24 PM
Yeah my house got flooded terribly
Find it difficult downloading all from google drive was thinking I needed some remote server like github
 
don't kno whow google drives comes into play
 
Also a drag downloading all libraries again to run my .py file lol
I meant my scripts :P
 
@AndrasDeak I'm guessing this was what they were using as cloud storage.
 
Yeah i'm new to git but will take a look at the references @AndrasDeak linked before. I suppose i'll just use github
 
@Pherdindy git won't help with that
 
3:34 PM
I'm still watching a tutorial by Gwendolyn Faraday and seems quite nice to follow but I suppose i'll finish it to have a better idea. How do people keep the libraries needed by each script to be bundled together though?
I normally just code at home but my PC is in shambles after it got flooded so I move around
 
@Pherdindy your code has dependencies which you install in a virtualenv. You don't bundle your dependencies.
 
So the common practice is copying the env folder in the miniconda folder or something and carry it around with the script?
 
Git is about versioning your code.
@Pherdindy how did my messages lead to that conclusion?
 
Sorry jumped a bit too far there should be reading a bit more lol
Right I just know about git being version control and github being a project folder being on a server
 
Git tutorials won't tell you about python envs. But you don't carry envs around. On each system you create an env for your projects.
 
3:47 PM
I do have virtualenvs for my projects but I usually just copy the .py file around
 
@Pherdindy git does version control, and github offers to store your repos and adds some bells and whistles above git. So does gitlab.
@Pherdindy copying the py file is fine, but can be replaced with pulling from git. I'm talking about your dependencies like pandas. You don't copy those.
 
Dependencies only go into git/GitHub as entries in a requirements.txt file, not the actual lib
 
Right that makes sense now
 
And I hope you didn't copy all your pandas lib files up to Google Drive
 
Was considering it just a couple minutes ago
Lol
 
4:01 PM
@AndrasDeak This is one of the main reasons also I tend to get duplicate codes and forget which one is newer when I make changes and back up manually and forget to change the title
 
that's one of the things git helps with
 
Thanks already have a good idea lol just gonna try it out a bit
 
just 1. make it a habit to fetch your newest version from some remote, 2. push your changed when you make them, and 3. preferably make your own code installable packages, using which you can install it and all its dependencies in a new env with a single call to pip
 
4:29 PM
Push your changes.
 
 
1 hour later…
5:40 PM
Hey guys if writing small scripts to practice such as convert int to roman numerals is it worth keeping these stored on git to refer later or just redo as needed? just wondering how useful they are to keeping
 
just keep it in git, some Romanian dev would need it in hurray and would send you prayers
 
@HabibRehman see Roman numerals. Roman as in Rome, not as in Romania.
 
How are negative numbers or zeros represented in Roman numerals?
 
@AndrasDeak xD I know roman numerals just quoted the different region I hope you get the point of what I meant.
too much political correctnes
 
@HabibRehman no, I have no idea what you're saying.
 
5:48 PM
okay
 
@HabibRehman if you were somehow implying that Romanian developers are worse than non-Romanian developers then it's even worse
 
Nope i'm not implying that
 
So what do you mean by "too much political correctness", for instance?
 
lol guessing you were being sarcastic? was genuinely curious as to if it is worth it
 
you missed the point, let me try again.
"Just keep it on git, anybody who would need it would be happy to see your work "
 
5:50 PM
@HabibRehman if you say it like that I get it.
 
@Kwsswart hhhh...
God bless you @AndrasDeak
 
but with "git" it could still be 1. a local repo, 2. a private repo on some server 3. a public repo on some server
 
Also, if it is a one-off script that doesn't really merit a full repo, GitHub also offers Gists - they still do versioning, just not as well integrated with IDE's.
 
there are also gitlab snippets, but those can't be "you can view them with a link but otherwise private"
at least they couldn't be, last time I checked months ago
 
@AndrasDeak You can check GIST instead
 
5:56 PM
a gist is "a repo on some server"
 
yea you'll have acc on github and you can make gist public
 
@Mikhail The concept of negative numbers antedates Roman numeric notation, which therefore felt no need of such a concept.
 
@holdenweb iirc - it took the number zero a while to be a "thing" as well
 
Can we invent something, I think somebody may be Romanian here :-)
 
6:19 PM
@JonClements Yup. That was an Indian contribution. Ironically, our contribution to mathematics was zero
 
Hey, there were plenty of Canadian contributions to Mathematics, like the Blackberry!
 
@inspectorG4dget and a few brainyam results by Ramanujan
(along with probably dozens of other, less-universally-known examples)
 
hmm, I didn't realise Bose was a mathematician
 
these days more likely known for being a rather expensive but very decent sound system? :p
 
6:28 PM
probably :'(
 
6:44 PM
tee hee. We actually have thinkgeek-style ironic tshirts about our zero contribution to math. I think that reference was out of scope (heh) here
 
7:35 PM
How do I call an ipynb file (just like how importing from a file without anything like `if name == "main" will cause said file to run by default) from a py file?
 
8:20 PM
@JohnnyApplesauce mm, I thought you "don't"? Can't you just convert the notebook to a regular script and then call that?
There's lots of hand-waving in my approach to Jupyter but I think that's an approach from my understanding of how the notebooks work
 
Be careful in saying just "ok" to my suggestion here :P I don't want to send you down the wrong path. It seems to me, though, that something you want to import/call doesn't fit the format of a notebook. Do you have concerns in doing that?
 
9:19 PM
Hello
 
9:48 PM
Hello
 
10:10 PM
I have a question about python vm
 
You may have to explain what you mean by "python vm". Do you mean the process environment and object/memory model within the Python interpreter while a script or interactive session is running? Or do you mean Python running in a VM (a virtualized computer running within a host)? Go ahead and ask your question.
 
I have jenkinsfile. in one of the stages I'm using python3 vm
once the stage completed, it means all the requirements file I've installed using pip are gone?
on the next stage, I should run again the pip install on the requirements file?
 
Ok, so this sounds like a virtualized machine provisioned with Python 3 in a Jenkins CI (continuous integration). If a VM is spun up new for each Jenkins stage (warning - guesswork is starting here), then your pip installs will probably need to be redone (since the VM lifetime is just for that stage, ?). If the installs are extensive, maybe you can figure a way to merge the work from multiple stages to avoid needless reinstalls.
 
unless something something docker?
 
Instead of us guessing, you could just not do the pip install in the second stage - if things break on import errors, then you probably need the pip installs. If they keep breaking, then maybe you don't need the pip installs, but something else is the problem, and you'll need help from someone more Jenkins-literate.
 
10:25 PM
Ok I'll give it a try
I was just wondering if it exists for each shell
or it enough I raised vm + pip install, and in the next stage I would only have to activate it
 
"activate" is something you do with a Python virtualenv. Is that what you are referring to when you say "python3 vm"?
virtualenvs should persist across shells, and subsequent shells should be able to just activate it without re-pipping everything.
It is unfortunate that "virtual" is getting used in many contexts these days, so it is easy to mistake one concept for another.
 
yes, I meant for python virtaul env
I will try that. tnx
 
Then yes absolutely. The main points of the virtualenv (sometimes called a venv, but never a vm) are: to encapsulate a set of pip installed modules; to isolate them from other projects' venvs and from the system Python environment; and to easily switch among them using activate/deactivate.
and the element of surprise
fear and surprise
 
11:08 PM
and what about activate and deactiave?
when stage is finish and shell close, it's automatically deactivated?
 
Yes. All that activate does is just change the running shell's state. Once the shell closes there's no more state to speak of. Another shell will have to activate again.
You can open the activate file and see what it does
 

« first day (3695 days earlier)      last day (1236 days later) »