« first day (3492 days earlier)      last day (1439 days later) » 

12:18 AM
Has anybody used fuzzy matching to check if two strings are misspellings of each other?
 
how does pygame.time.get_ticks() work?
 
@jigglypuff The usual approach for comparing to strings for similarity is to compute Levinshtein Distance. I've never done it myself, but it should be easily googled.
 
wim
how about Unproductive Robot? makes bad questions disappear
 
@PaulMcG Levenshtein, I believe
 
^^ Yes, what Andras said
 
12:31 AM
@PaulMcG Yes, I've just installed fuzzywuzzy, just wondering if anybody has done it before. I want to catch misspellings as my users are fairly careless and they always come to me with exceptions.
 
not that google or duckduckgo wouldn't manage to guess it anyway
guess they could find common search terms that are close in Levenshtein distance
 
 
3 hours later…
3:42 AM
Hi, need help with pytest, def test_bigquery_query(mocker):
mocker.patch(f'{module_ns_bq_client}.query', return_value=(1,))
bigquery_instance = BigQuery()
sql = 'SELECT 1'
res = bigquery_instance.query(sql)
assert res == (1,) pytest-cover is not covering the test case. could you please help ?
 
Can I talk about Python's 'fastai' library installation problem here?
I am new here that's why I am asking this.
 
 
4 hours later…
7:22 AM
@sush Hi such, please have a look at the code formatting guide.
@HumayunAhmadRajib As long as it is within the room rules, go ahead. For very specific questions, it might take a while until someone comes by that is familiar with the topic.
 
 
1 hour later…
8:45 AM
@MisterMiyagi not as such :P
 
9:40 AM
That's such an embarrassment indeed. disables autocorrect
 
9:56 AM
Hi, I just joined few seconds ago
 
welcome =)
 
10:19 AM
Hey y'all, been a long time! For the past few weeks, my scraper has been getting a weird new error out of nowhere and simply just trying the same thing again works.
Basically I get AttributeError: 'NoneType' object has no attribute 'get_text' and I try the same command again and this time it gets the data.
So I guess my question is, what could cause different responses to the same requests.get and how do I get to the bottom of this ;-;
 
10:51 AM
Check what the server is returning? Maybe you're getting rate limited or something
 
The documentation for the Tk.update method says
> This method should be used with care, since it may lead to really nasty race conditions if called from the wrong place (from within an event callback, for example, or from a function that can in any way be called from an event callback, etc.)
I don't understand how that can cause race conditions. There's only one thread running, so... who's the 2nd racer?
I tried to use update_idletasks instead, but unfortunately that doesn't do everything I need it to do. Not entirely sure what is and isn't executed by that method
 
Hi guys
someone posted a comment to my question
and wanted your opinion
 
11:33 AM
@Hassan Care to give some details to that?
 
could i just change the common() function to be more efficient than changing some other parts of the program
2
Q: friendship program using graph type python/algorithm

HassanI have created a program but I feel the def common(friendships, person1, person2) function can be more efficient, if anyone has any good idea how I can improve it I would appreciate it. from My_graph import Graph def friends_of_friends(friendships, person): """Return the set of friends of...

 
I meant what comment was posted and wanted an opinion on what?
 
so on that post someone posted a answer
but i wanted to know could i just make the common() function more efficient
without changing anything else?
 
That's what they answered.
 
yeah but they have change other functions
 
11:47 AM
Not directly related to your question (since it's still in the 48h period), but did you write that Graph class yourself?
 
yeah using info on the web it all works
 
For an adjacency graph, some of its methods are very inefficient. It doesn't seem to rely on its own layout at all.
 
im am a beginner lol
 
Did you take a look at existing Graph libraries?
 
yeah but i wanted to keep my graph class im happy with that but wanted to see if i can make the common() function more efficient
 
11:52 AM
have you tried just using the commons that's been suggested without changing other methods?
 
See, the Graph class pretty much demonstrates that you haven't groked the how and why of an Adjacency Graph. The class is the first point to apply said knowledge, since it inherently uses itself. There is little point, both for learning and efficiency, in optimising its usage elsewhere when it doesn't handle itself properly.
Some more technical feedback, since you use that a lot: There is no point fillings sets (or lists, dicts, ...) by looping over containers. You can directly initialise them.
# current
    result = set()
    for neighbour in self.graph[node]:
        result.add(neighbour)
    return result
# idiomatic
    return set(self.graph[node])
 
@JonClements yeah mate but coming up with error when im testing it out
 
and did you attempt to fix that error / understand why your methods have had other changes suggested?
 
12:07 PM
@JonClements im still working on it 🤓
i been here all morning lol
 
Hi everyone.
Why aren't yields in this code returning the result of the function calls one by one?
def example_generator():
    yield print("Red")
    yield print("Blue")
    yield print("OK")

next(example_generator())
next(example_generator())
next(example_generator())
 
you create a new generator each time...
create it once... then call next on that
 
also, print calls return None
 
and... kevin'd...
 
right, thank you both
 
12:12 PM
@Aran-Fey I don't use tkinter but it strikes me as surprising that you'd have everything running in a single thread, which would be the main event loop? Surely there are reasonable cases where you'd actually offload work to another process, let alone another thread?
 
Sure, but tkinter isn't thread-safe anyway, so any changes to the GUI must go through the mainloop
 
not thread safe? But it's the bestest biggliest featured GUI out there! :p
 
do the event callback go through the event loop as well?
 
@JonClements continuing with your "wibbly wobbly timey wimey" theme :P If you keep going down this route, we'll have a whole new dialect of English :P
 
@MisterMiyagi callbacks executed by widget.bind and such are executed by the mainloop thread, yeah
 
12:16 PM
@MisterMiyagi thank you so much your code works perfectly
 
heh... ooo look it's lunch time... anyone else fancy some fish fingers and custard? :p
 
better stick to pizza :P
 
with custard?
 
no comment
 
You guys clearly aren't Whovians... youtube.com/watch?v=Oo2RKAHu-kI
 
12:18 PM
Hey, I know you've watched enough Ramsey to make informed decisions. I'm not questioning it :P
 
I'd completely forgotten in that scene the Dr says: "You're Scottish - fry something"... :p
 
Vaguely food-related (though disastrous), one of my facebook groups found this news article. Just about every detail is epic. The constitution needed to be able to quack immediately before exploding is... admirable?
 
@Aran-Fey As far as I can piece together from the docs (OMG...) the problem is that .update is not strictly re-entrant. Calling it from inside an event being processed, the loop will end up processing both the triggering and triggered event at the same time.
2
Q: Odd function behaviour with Tkinter

nair.ashvinWe have some code in an event callback that looks like: ... self.position.side = -self.position.side self.update_with_board() # displays self.position graphically ai_move = self.brain.get_move(self.position) ... update() is called immediately but does not affect the GUI until the ai_move line....

 
@roganjosh I hope not too many see that... people are becoming increasingly mentally unhinged and bored with this social-distancing stuff... wouldn't want it to be a trend that makes newspaper headlines :p
 
@JonClements one of the comments was "Peking blinders" :P
 
12:30 PM
love it... very clever :)
 
@MisterMiyagi Not sure what "triggered event" you mean. You're saying that one of the queued tasks could do something to trigger a new event?
 
Anyway... I bet it "mulard hurt" or something... groan
 
@Aran-Fey As far as I understand, .update processes all pending events. So if you have two pending events and the loop starts processing the first, but its callback calls .update again, it will then process the second (since the first is no longer pending) while still not done processing the first.
 
@rogan bloomin' heck... interesting track to come on, on random... youtube.com/watch?v=syOK6zmpOe0 - must be 20 years old now or something?
 
@JonClements Rhadamanthus deserves better than that pun :'(
 
12:37 PM
@MisterMiyagi Well, sure. I don't see the problem with that, though
 
plum sauce and noodles?
 
@Aran-Fey I'm not sure how TKInter works internally, but my event loops would be fried by handling two events at the same time. Single-threaded event loops usually assume there is only one event handled at a time.
 
To make all this a little less theoretical, what I actually want to do is to query a widget's size after modifying it. Like this. Swapping out update() for update_idletasks() won't update the widget's size
 
Not sure how tkinter works in that case. In an async framework, you'd requeue/sleep(0) to run the event loop.
 
Cutting the callback in half with after(0) or after_idle doesn't work either:
def callback():
    label['text'] = 'hello world'
    win.after_idle(callback2)
def callback2():
    print('label width:', label.winfo_width())
 
12:43 PM
Let me hobble to the Ruprecht mobile...
 
So yeah, I actually can not find a way to make this work without update
 
@Aran I avoid GUI stuff like the plague, but is effbot.org/zone/tkinter-window-size.htm of any use?
 
Yup, using a <Configure> event handler does the trick!
Welp, now I have to think about how I want my library to wrap this behavior. I sure don't want to handle every single widget's <Configure> event just in case that someone wants to query the widget's size...
Umm, can someone confirm that this prints the correct size, but removing either one of the update_idletasks() calls breaks it?
def callback():
    label['text'] = 'hello world'
    win.update_idletasks()
    win.after_idle(callback2)
def callback2():
    win.update_idletasks()
    print('label width:', label.winfo_width())
 
yepp
 
Is it just me or does that not make any sense?
 
12:55 PM
none at all
 
ok, good
sort of
 
if you do win.after(1, callback2) in callback1, you can skip the first .update_idletask but not the second.
 
actually either one works for me
 
hey everyone
!!
 
i have a question what would be the initial insight of this function ?
    assert person1 != person2
    assert person1 in friendships.nodes()
    assert person2 in friendships.nodes()

    mutual_friends = friendships.neighbours(person1) & friendships.neighbours(person2)
    return len(mutual_friends)
 
12:58 PM
For my own curiosity, what's the general theme of the thing you're building with tkinter? Waaay back when I knew even less than I do now, I started trying to use it and distribution of the software across the company just seemed horrific, which is why I just went with Flask.
 
i have
Initialise mutual to neighbours in friendships, person1 and to person2 then return the length of mutual
would that be right??
 
@d02d33pak hello :)
 
@roganjosh Well, I'm actually writing a GUI library that wraps tkinter. But I am also using it to create a small program that displays images with some other widgets below - so what I wanna do is query how much space those widgets take up and then scale the image to a size that still fits on the screen
 
I one day still want to get a good bit of time to play with Kivy - cross platform, has lots of nice features, a not too bad yaml configuration for layouts and can also build stuff to stuff ios/android apps
@Aran I take it images don't automatically get resized if you put them in something that isn't large enough to hold them?
 
Nope. Tkinter doesn't really have a concept of a "minimum size" - if the window's too small to hold everything, the widgets just get clipped
 
1:03 PM
I have seen a tutorial for kivy where the end result looked... passable as an app but I can't see how it'll keep up with the app market
 
PyQt5 perhaps?
 
@Hassan are you running everything in memory?
 
no mate
 
@roganjosh some of the stuff in the gallery looks impressive to me: kivy.org/#gallery
 
@JonClements I think it's a game of hedging bets and I just didn't get a sense that it was working as they hoped. That's why I started learning Kotlin for cross-platform on mobile, but I've failed hopelessly at keeping up with that :(
 
1:08 PM
Unless you're the maintainer/author of something - I don't think it's really practical to keep up to date with active frameworks etc...
 
mmm, do you really agree with that? There'll be plenty of people on top of pandas, numpy, flask etc without being contributors
@Hassan so what is the storage you're using? You wouldn't typically be taking sets of users when you could solve that in the query itself
 
My career goal is to specialize in a tech stack that is both elegantly designed and deeply unfashionable, so I never need to keep up with trendy libraries, and desperate employers will pay me giant sacks of money because everybody else is busy learning the tech of the week
I want the syntactical clarity of Python and the irreplacability of COBOL
 
Maybe I should clarify my position on that. I'm not on the bleeding edge of pandas developments. Many of them, I'm probably aware of in my periphery at best. But the kivy library just seems behind in what it can support
 
I suspect this is one of those "choose two: fun, high demand, low supply" trilemmas, and PyBOL can't ever exist
 
Lol, I'll just loop back on myself and agree with Jon. It was a fun stroll out but I'm just wrong :P
 
1:18 PM
@Kevin As in, Python2?
 
@MisterMiyagi 1.5?
 
Py2 is half as fun as it once was and has twice as many new learners as I'd like it to have
 
@roganjosh i just wanted to know if my initial insight was correct for the common() function
 
1:37 PM
Could you name a Tensorflow program that's well structured and documented so as to serve as an exemplar/tutorial on how to write good tf programs?
 
1:52 PM
@wim Probably small child...
@Kevin Why not? Is a compiler that compiles Python down to COBOL impossible?
 
A Python to COBOL transpiler would certainly be nontrivial, but I'm not prepared to say it's impossible. But I'm more using "PyBOL" as short hand for "a fun language with high demand and low supply" rather than as a literal combination of Python and COBOL.
 
@Kevin I got that, but the thought occurred to me...if that would make maintaining the COBOL infrastructure easier/more accessible...
 
90% of my COBOL knowledge comes from scrolling through this article very quickly, but my impression from looking at the code blocks is that it's substantially different from the usual Java-like languages that you see in CS 101
Without implicit typing or nested scopes in the target language, I imagine a Python-to-COBOL transpiler would end up looking more like a full Python bytecode evaluator written in COBOL
Adding a full layer of abstraction like that would probably be a no-go for performance-critical code
 
2:09 PM
The point of all that cobol debt is that it works. Writing a correct transpiler is as good as rewriting the code from scratch
"We can't port the code because we know the cobol is bug-free"
 
Fair enough
 
Extreme hard mode: also write a COBOL-to-Python transpiler that guarantees that python_to_cobol(cobol_to_python(x)) == x
 
you know there is a loophole the size of the atlantic in that requirement?
 
Define both functions as return x? :-P
Ten dimensional galaxy brain mode: formally prove that the Cobol program generated by python_to_cobol(x) always produces identical output to the Python program x, and vice versa for cobol_to_python
 
I'm decently sure that's easy to prove impossible.
I have Python programs that don't produce identical output to themselves.
 
2:16 PM
Can you assume the halting problem is solved?
 
@Hassan A better answer would use language that describes what friendships.neighbours returns for each node, and what that mysterious '&' operator does. I usually reserve "initializes" for attributes of objects or variables with some long-lasting state, not for temporary variables within a method whose lifetime is about 10 byte codes. Really all you have here is just restating in imprecise terms what the Python statement contains, so low marks from me.
 
I'm pretty sure there's a formal name for the proof that you can't always show that mathematical functions f and g are equal even if you have access to both their definitions
Something along the lines of cs.stackexchange.com/questions/45683/…
 
As a phycisist, I find the CS' tendency to cry "halting problem, d'uh" seriously unsatisfactory
 
@MisterMiyagi ballpark correct though
 
it's probably due to quantum, I guess
 
2:30 PM
I think the undecideability of program/function/turing machine equality probably does boil down to the halting problem, but not in a completely trivial way
Obviously the linked question makes use of it but I'm not sure it applies completely the the formulation of the problem that I have in mind
 
as a hunch, if you were able to prove equivalency of any f/g then you could solve the halting problem by knowing some f that halts and dis-/proving its equivalency to any g
 
Hmm, you're persuading me
 
@PaulMcG thanks you for your response, so what would you suggest bearing in mind i want a initial insight
 
@Kevin I am? Just applying the only thing I've learned from my CS colleagues. Wave your hands, say "halting problem", and recap the question in your own words.
 
Hmm, maybe Rice's theorem is a good fit here? "always produces the same result as this other function" counts as a semantic property about the program's behavior, I assume
 
2:41 PM
...easy-to-read programs that demonstrate how to use TF correctly?
 
In my experience, if easy-to-read examples of a library aren't prominently advertised on the homepage of the library, then they don't exist
 
sorry, can't help. never seen a readable ML program in my life.
For once, that's not an exaggeration.
 
I'm led to believe that tensorflow.org/tutorials contains "end-to-end examples" but I'm not inclined to go digging for them
 
@MisterMiyagi inequivalence would be inconclusive though
 
Currently trying to come up with two example programs that always halt and are most likely equal, but which can't be proven equal without a fields medal...
 
2:55 PM
@AndrasDeak If the only output is does/doesn't halt, then inequivalency with halt should prove non-halt'iness, no? waves hands
 
I almost had it with "f(x) == 1; g(x) == the final result of applying the Collatz function repeatedly until it starts to loop", but that fails because it's not known that all inputs do loop; it's possible that the sequence could grow larger forever.
(AFAICT)
 
@MisterMiyagi no.
 
@Hassan Reread the part where I said, "A better answer would use language that describes what friendships.neighbours returns for each node, and what that mysterious '&' operator does." That is all I'm going to say, no matter how many times you ask.
 
A = B -> if A halts, B halts
A ≠ B-> if A halts, nothing
 
yet there is only to halt or not to halt.
the only way for B not to equal the halt/nothalt output of A is not to halt. waves hand
 
3:02 PM
To halt or not to halt, that is not the question
 
but if it was would the answer be 42?
 
The only reason I took ToC in college was to 1: git moar gud at regexes and 2: nod half-knowingly as I follow this convo
 
Table of Contents?
 
theory of computation
 
Animistic theory of computation: with the power of lightning, rocks can be tricked into thinking. But most rocks are pretty stupid, so research is ongoing to find better rocks.
Quantum computers are made out of rocks that are clever enough to hide from people so that we're not sure they're there half the time
 
3:12 PM
Well, the material of your CPU is basically rocks.
 
computation is just a chemical
 
Silicon: rocks. Copper: rocks
LCDs: liquid rocks
 
@PaulMcG what about now mate? Set mutual to neighbours in friendships, person1 and to person2 then this will add the nodes up if they are both equal then return the length of mutual
 
3:30 PM
I sense simplification.
 
@Hassan do you know what the & operator does for sets?
 
3:57 PM
I'm not sure Hassan even knows that friendships.neighbours returns a set, let alone what the '&' operator does, nor even what a Python set is and how it behaves. Hassan - "neighbours in friendships, person1, and person2" tells me you still don't really get what is going on. read these docs (docs.python.org/3/library/stdtypes.html?highlight=set#set), do some manual experiments with Python sets, with different operators and simple sets (like set("abc") or set("def")).
@Hassan - think back about what you learned about sets in school. What union and intersection mean, for instance.
 
4:41 PM
i'm writing my own hashtable code and i need to unit test collision handling, however i'm having trouble patching the built-in hash() function in python
i'm getting TypeError: Need a valid target to patch. You supplied: 'hash'
@patch('hash')
def test_custom_hash(self, hash):
    hash.return_value('hello')
    hash_table = HashTable()
    hash_table.set('test', 1)
    print(hash_table.get_hash_table())
 
5:11 PM
wild guess: @patch('__builtins__.hash')
 
i was able to get it to work with <module_name>.hash
i'm assuming the built-in python function get namespaced in a way to the current module
i'm fairly new to python so i'm unsure how any of this works under the hood
 
anyone have experience starting a new project? When do you create a separate devel branch? Do you do so almost immediately after setting up the scaffolding of the project? Or do you wait until you have a 1.0 release?
 
name lookup usually "falls through" to the surrounding scope if the name can't be found in the current scope. So (simplified) python first checks your (function) local scope, then the global scope, and finally the builtins. Patching module_name.hash will create a global hash variable in module_name, so from that point on all functions in that module will use that patched hash (instead of the builtin one)
 
I.e. shadowing the builtin, not replacing it
other_module will still see builtin hash
 
FWIW, most of my projects only have a master branch. I'm aware that this is not best practice
 
5:21 PM
yah, we are pretty strict that the head of master is always the latest stable release
and by "we" I mean I am. I work with a small team so I have quite a bit of influence on our branching strategies
 
I'm lucky that I'm a one-man team and none of my stuff is actually published
 
are you the only user of the code you write?
 
Well, I can't say for sure, because some of my stuff is up on github. But unless there are some intrepid adventurers who use random undocumented code they found on someone's github, then I am probably the only one
 
even then, it's not a deployed system with multiple users. I'm fully aware of that kind of software since it's mostly all I wrote until the last 3 years or so.
maintaining a system that is constantly live and requires periodic updates take a whole different process than something for a single user.
 
Why not master + feature branches + release tags?
 
5:30 PM
yeah, learning that workflow is something I've yet to do
 
@AndrasDeak We have release tags, too. master is always tagged with the latest release. I think the main reason to have a separate devel branch that hasn't been released is to allow easily deploying hotfixes directly on the current master.
 
That would just be merging to master, would it not?
 
In your scheme, when do you merge finished feature branches into master?
immediately when it is finished? or do you gather them all up just before a release?
 
Surely the sooner you merge the better? That way new branches already have the changes and are less likely to cause merge conflicts, no?
 
so imagine this scenario...your repo has a tag 1.0.0 which is released to production. You are working on some new features to 1.1.0 some of which are merged into master. Now the user finds a bug that requires a hotfix for 1.0.1. How do you create a branch to fix the problem and deploy it without deploying the unfinished 1.1.0 work?
I think there is probably a solution to this in your proposed scheme. The methods I use are loosely based off of git flow which has a separate devel branch for unreleased work. So the short answer to your "why not" question is because that's not how git flow does it.
with that said, git flow certainly isn't the only way
 
5:41 PM
I suppose you'd check out 1.0.0 and merge the hotfix into it, then tag that as version 1.0.1? (And then you'd merge the hotfix into master)
 
you can't really merge into a tag
there would be a few details to iron out there because of that, but something along those lines would probably work.
You could probably do something like git checkout -b hotfix 1.0.0, make the fix and commit it, then git tag 1.0.1 && git checkout master && git merge hotfix.
 
@Code-Apprentice OK. The way that is handled in the open-source projects I'm familiar with is that releases have their own branches. You'd have branch 1.0.0 which eventually gets released, master collects new features in the meantime. What you call hotfixes are mostly called backports, which are pushed onto the 1.0.0 branch in your case
in this scenario you probably have to commit the same changes in each corresponding version branch, but you don't normally support too many versions at once, or when you do these backports are comparatively rare
At least that's my impression. I'm also the lone user of my code.
 
or you could have a backport branch that gets merged into each pending version branch
 
Well, yeah. That's just a different implementation of the same thing ("commit the same change in each corresponding branch")
 
the difference is whether you have multiple commits with the same textual change or a single commit.
the end result to the code base is the same, yah.
 
5:52 PM
Wouldn't merging cause the commit to be copied anyway?
 
no
merging creates a new commit with two (or more) children
 
ah, right
Anyway, specifically, the open-source projects that follow this strategy make it a point that master is not sacred, and it isn't even really needed for contributors
 
interesting
I'm aware that there are multiple branching strategies out there. My current workflows are based on git flow which is quite different from what you describe.
It's not open source and we are a small team, too, so we have different problems to address with our branching.
 
yeah, I'm sure there's no silver bullet
seems that the new numpy docs no longer suggest outright deleting your local master, but anyway their workflow is here
 
I was introduced to git flow early in my git education for my personal projects and ended up adopting a lot of it in my professional work.
I've become a fan of deleting local master and just using origin/master directly.
in fact, I think you are the one that suggested it to me a while back
 
5:58 PM
sound advice ;)
 
AAA
6:08 PM
Could someone guide me towards how I could download a data image like this in python?
data:image/svg+xml;utf8,<%3Fxml%20version%3D"1.0"%20encoding%3D"UTF-8"%20standalone%3D"no"%3F>%0A<svg%20xm
 
6:19 PM
check out this question
 
AAA
Thanks but this uri is not base64. I will still check out the question to see if it can help :)
 
it can if you scroll past the first answer
don't forget to downvote while you're there
 
AAA
why would I downvote?
 
because the accepted answer only supports base64 URLs
 
I've used Gitflow before and I think its great for big projects. For smaller projects, I find feature branches good enough.
 
6:33 PM
@Code-Apprentice What is the utility of this?
 
7:07 PM
@toonarmycaptain I frequently git fetch in my work flow which keeps origin/master up to date. I don't have to also remember to git checkout master && git pull before merging master into my current working branch.
@RoadRunner how do you define "big" and "small"? even just roughly?
 
7:40 PM
@PaulMcG yeah im not to sure
@PaulMcG im beginner and have not learn this , im trying to teach my self by the info given by you guys
@MisterMiyagi Sets each bit to 1 if both bits are 1
 
@Hassan Let's take a step back. Do you know what a set is? In math, and in python?
If not, you might want to start there, in that order
 
@MisterMiyagi yeah between the brackets?
@AndrasDeak in python it is an unordered collection data type that is iterable, mutable and has no duplicate elements
 
@Hassan OK, you can copy-paste content from geeksforgeeks. But do you understand what all that means?
 
my previous initial insight was Initialise mutual to zero. For each node in friendships, if that node has edges to person1 and to person2, then it is a mutual friend and so increment mutual.
yeah that how im learning using info from you guys and the web
 
This is not a test, this is not an exam or an interview. This is real life. If you give dishonest answers you're only fooling yourself and making your own job harder.
 
7:53 PM
@AndrasDeak yeah i read the stuff i get recommended and google the rest so i can understand it more
 
@Hassan OK. I don't know if anyone has told you this yet but first read a proper, structured tutorial. If this is your first programming language then a tutorial that also introduces programming concepts. Without this you'll just be cargo culting
 
@AndrasDeak ok im reading about sets atm
@AndrasDeak would you say the geekforgeeks is a good source?
 
@Hassan not a tutorial. And I think we've seen crap from them, not sure
 
yeah im read it and then google more info im not sure about
 
8:28 PM
@Hassan - before you deal with Python sets, review the concepts of sets that you learned in math class at school. Here are two links that describe what I mean: mathsisfun.com/sets/sets-introduction.html and mathsisfun.com/sets/venn-diagrams.html . No Python yet, just basics.
 
Is ASCII character number 0x1B different from "\" in "\n" in Python?
 
I think I should just hang my boots up with physics. I'm better at just confusing people than articulating my questions :P
 
there isn't really a backslash in a newline character
 
@Aran-Fey Is \n a line feed? How does Python realize we've actually put \n in a string and not \x5C\x6E?
 
@AndrasDeak any good?
 
8:33 PM
so while I'm not entirely sure what you're asking, I am fairly confident that chr(0x1b) is indeed different from whatever you're referring to
 
@AndrasDeak Set mutual to neighbours in friendships, person1 and to person2 will return the set of neighbours of node then this will add the nodes up if they are both equal then return the length of mutual
 
@aderchox That is the <ESC> (escape) character (ASCII 27, which is 1B in hex)
 
@Aran-Fey it's escape character
 
@aderchox When python sees a backslash followed by an n in a string, it converts it to a newline character. If you want to have a literal backslash followed by an n, you have to escape it with a 2nd backslash
'\\n' <- like that
or use a raw string literal: r'\n'
 
@PaulMcG im be thinking about it all day, am i improving in my answer for initial insight? Set mutual to neighbours in friendships, person1 and to person2 will return the set of neighbours of node then this will add the nodes up if they are both equal then return the length of mutual
 
8:35 PM
@Aran-Fey I see... but \x5C\x6E is a \ and an n too... why doesn't Python convert that to a newline character?
 
Because \x5C\x6E is different from \n. The source code is different.
 
thanks
 
It's kind of like asking "why does python convert 5 to an int but 5.0 to a float"
different source code = different result
 
@Aran-Fey \0
 
Dumb question time; what's broken if python actually could do int("5.0")?
 
8:41 PM
You could theoretically have it do int("0.9999999999999999999999999999999999999...") and it'll give you 0, but it should be 1 :-p
 
That'd be screwed as a float, too, no? :P
 
I think the suggestion was to allow zeros after a comma, not chop off any numbers after the decimal point :P
 
@Hassan "neighbours in friendships, person1 and to person2" is not correct (there are no "neighbours in friendships") and there is no addition going on. But there is a set operation happening. What set operation will show you the elements in common between 2 sets? What are the two sets in this statement? Do not answer in Python terms, answer in set concept terms. If you describe the set concepts and set operation going on here, that will be the perfect comment.
 
@PaulMcG ok paul back to the drawing board lol
 
@roganjosh On a serious note, then why would you just stop as "5.0", why not do "1e-4" and any other scientific representations?
 
8:45 PM
Please review the mathisfun links - think in sets, not Python.
 
@Aran-Fey this is not to continue the previous question, I got the answer to that, but this works print("Hello\x0AWorld") as expected (0x0A is line feed). But I think it is the shell that is interpreting it like that. Probably Python is sending the 0x0A "as-is" to the output.
 
No, that's python's work. The hex escape \x0A is converted to a line feed by python
just like \n would be
 
@shad0w_wa1k3r a genuine question back; why not? It's a rabbit hole, I'm just curious why the line was drawn where it is
 
@Aran-Fey Does Python use Unicode?
 
For what, exactly? I suspect the answer is "it doesn't matter, you don't need to care about that"
Python strings allow all unicode characters, if that's what you're asking
 
8:49 PM
@roganjosh I'm thinking it would be just, make it a library, keep this one simple, or along those lines.
 
right, I shouldn't care about that :) I had to convert some bytes to string and had some problems, but it's fixed now.
 
@shad0w_wa1k3r I guess it makes sense. I was just devil's advocating to see if I was missing an obvious "kaboom" :)
 
@roganjosh as expected, can always do int(Decimal("0.99999e2")) # 99
:)
 
eh, but Decimal is cheating :P
Still, yeah, that output is wonky
 
9:11 PM
I have a DataFrame created and I have Jupyter Notebook running, but display(df) or print(df) doesn't display the DataFrame inside the notebook
How do I display my DataFrame in the notebook?
 
is the dataframe created inside the notebook?
 
Yes
By "yes", I mean I create a .py file, and when I run jupyter notebook the .py file is contained in it
 
9:30 PM
What do you get if you try to plot even basic graphs?
 
@roganjosh Tried to plot swcarpentry.github.io/python-novice-gapminder/09-plotting, all I get is that jupyter shows an updated directory, but no plot.
 
I'm probably not going to be able to set a working env up in Jupyter but, at least, we've identified that the plotting issue is more-fundamental than your problem
 
9:53 PM
@JossieCalderon Just type df inside Jupyter. That should show your dataframe. What happends when you do that?
dupe - needs target, I looked for good targets on SO but can't find one. Another ML question from an OP who doesn't understand the difference between a classifier and a regressor. stackoverflow.com/questions/61664772/…
 
@smci It worked
 
@JossieCalderon Great. Isn't that covered in jupyter tutorial/quickstart? If not, send them a docbug.
Re explaining when to use Classification vs Regression, things like the following are not a good general resource: stackoverflow.com/questions/33908127/…
 
Is SO even the right site for this question?
Seems more like a theoretical data science question than a programming one. Not the one you linked (which I don't have time to look at), just "classification vs regression".
 
@AndrasDeak I'm saying it's borderline offtopic, but my point is we need something terse here on SO as a good close-target here on SO.
 
10:08 PM
@AndrasDeak I know. The answer is a one-liner: regression means estimating continuous quantities, classification means estimating discrete ones (e.g. labels, or binary outcomes, or class membership). That's not deep theory. But it's very basic and very important. Basic terminology. We constantly get users copying from bad tutorials who don't understand the difference. Admittedly sklearn doesn't spell it out in very basic terms.
^ well at least it's not organ harvesting
 
perhaps furniture is codeword for kidney
 
10:56 PM
Hello guys, I have a question (that may be a little broad). Suppose I have this code
def do_something():
# do calculations, heavy use of memory
pass

for _ in range(100):
do_something()

In my original code, as iterations go by, I'm observing an increasing usage of RAM. How can this happen? IMO if I enclose all calculations inside a function, as soon as the function ends, it should free all memory used since its scope has ended. Am I wrong?
(Sorry, formatting did not work)
 
@ihavenoidea for formatting you can check out our code formatting guide to chat and practice in the sandbox if necessary
@ihavenoidea If your function doesn't mutate global (nonlocal) variables and you don't store any return values then yeah, one would not expect too severe gradual increase in memory. Although it's not trivial how python and the OS work together to allocate memory.
python is usually pretty good at reusing memory on its own
Are you sure the memory increase happens throughout the for loop and not already in the first iteration (first function call)?
 
Yeah. I'm observing an increase of 10~15mb per iteration. I don't think that's dismissable. And I am not using nonlocal variables (except for the parameters that are only integers and strings, so I guess it's not that).
 
15 MB in 100 iterations is not too bad...
ah, I miscomputed a factor of 10, sorry :D getting late
 
I'm sure of it. I'm printing the memory used at every iteration before and after the do_something() function.

The 15mb I said is per iteration, so that would total 150mb if I loop it 100 times.
 
I came to that same result...but I think it should be 1500 MB :)
 
11:08 PM
Oops! :P
 
How are you printing the memory used? Are you checking an OS-provided system monitor?
1.5 GB of memory should be quite visible by the time the code is done
 
I am using psutil like this "psutil.Process(os.getpid()).memory_info().rss".
Do you have a memory profiler that you recommend?
 
no, I've never done that with python
OK, I can't reproduce with dummy code
import os
import psutil
import numpy as np

def mem_heavy():
    return np.arange(1000_000).sum()

for i in range(100):
    print(i, psutil.Process(os.getpid()).memory_info().rss)
    mem_heavy()
0 29011968
1 29741056
2 37638144
and then it stays that third value until the end
You have to take a good look at your CPU-heavy function and see what might be off. Note that you can still be using global names without an explicit global/nonlocal keyword (which might or might not be trivial to you). See if you're using any dodgy C extensions that might have memory leaks.
 
In my mem_heavy() function there's tons of Keras models usage. I have had problems with Keras before in terms of memory, but I would think since I am encapsulating all in a function, regardless if Keras is leaking memory or not, Python would "ignore" this and sweep the floors once the function is done.
 
No, a memory leak means that a piece of code allocates memory and forgets/neglects to free it. Once that allocated memory loses any reference (pointer) to it, it will only be accessible to the OS once the program terminates. (I'm talking about C code. You can't create a memory leak with native python.)
but actual memory leaks in library code are rare (they are severe bugs and tracked down with extreme prejudice)
It's more likely that keras does something magical caching or memoizing, keeping references to whatever large objects you create, for safe keeping.
 
11:27 PM
Except for Keras, all other computations I do is with pure Python. So I guess the problem is there. And Keras has had (and still have) their fair share of memory leaks. (github.com/keras-team/keras/issues/13118 is just one example that it is still open). There are many other examples
 
You're not using lru_cache or anything yourself, right?
 
Nope
I'll see if I can come up with a minimal reproducible example
Thanks for the help by the way @AndrasDeak
 
No problem. I probably won't be able to help when you do put together an MCVE because I don't use any ML frameworks.
 

« first day (3492 days earlier)      last day (1439 days later) »