« first day (3862 days earlier)      last day (1069 days later) » 

1:15 AM
So, I just came across the print(file=sys.stdout) part of the function
It's basically the same as f.write()
 
I had no use for that, print to files is what a file logger does so I use that instead
 
Exactly
 
 
1 hour later…
2:39 AM
@12944qwerty Interesting, never dug deep there
 
2:57 AM
I saw that param quite some time ago, I just looked at it for a couple seconds right now....
I thought that you could send files through the console with that.... I was wrong lol
 
Oh, thats what you thought :p
 
 
4 hours later…
7:13 AM
@12944qwerty it's useful as unless told otherwise it will automatically add a new line for you so you don't have to remember to do f.write(some_string + '\n').... and you don't have to worry about converting to str, so you could do something like: print(*[1, 'bob', 3.14], file=f) and you'll get 1 bob 3.14\n written
 
7:51 AM
@CoolCloud No, I just took until now to write it. gist.github.com/kms70847/5274832c4a89ade1d2522ea154ec63aa
 
 
3 hours later…
10:33 AM
Trying to solve this geometry problem, I'm taking the square root of a vector, and I think I got quantum mechanics involved somehow...
 
10:44 AM
@lorelayb have you ssh'd into the container to see if your font is there?
 
11:31 AM
@Kevin Oh, now I see. Cool!!
 
11:55 AM
@Kevin sounds fishy
 
I got the logic without 'parsing' to work, but it has some bugs. It works all perfect when you press equals after each result. Chaining wont work. pastebin.com/AQhhMPni
Still lots of pending work, to fix the floats and so on
 
you just love typing out btn.cget('text') and e.get(), don't you
lines 58-65 and maybe more could be rewritten using a dispatch dict
 
12:12 PM
 
yes
But even if you don't, bind the two function calls I mentioned once at the top to some meaningful names. Calling those get methods each time is both inefficient (well, technically) and clutters up your code.
I already told you this once so next time you do this I'll just make snarky remarks
 
@AndrasDeak Got something like this to work:
mapping = {
    '+':lambda: add(e.get()),
    '-':lambda: sub(e.get()),
    '/':lambda: div(e.get()),
    '*':lambda: mult(e.get())
}
mapping[btn.cget('text')]()
@AndrasDeak Damn right, you will :P
 
@CoolCloud ugh, no
button_text = btn.cget('text')
value = e.get()
mapping = {
    '+': add,
    '-': sub,
    '/': div,
    '*': mult
}
mapping[button_text](value)
 
@AndrasDeak Realized that...
 
@JonClements Hm, that is useful. I wouldn't have to cast to string every single time o.o
 
12:35 PM
@AndrasDeak I could use same for 45-52 too. Great idea. Thanks
 
morning cabbages, folks!
 
Morning
 
12:50 PM
hello there,
0
Q: How to capture the number of downloads of a specific file

user3855242I have been working on a project that involves downloading files. I have been tasked to create a report of how many downloads per file. Here is my code: reports.py def dataset_download(request): download = DataSet.objects.annotate(numdownload=Count('name'),) return render(reques...

In the second answer, can someone give me a solution, how do I call the method?
 
You mean first answer? Where there is the DataSet object?
 
@12944qwerty yes
 
@duhaime I executed some commands on the container and saw that the font is there through the container's CLI (using fc-list). I notice that if I manually change the font family name con the SVG xml from "Druk-WideSuper" to "Druk Wide Super" (as the font family name shows up through the CLI) it works and the text is preserved when doing the conversion. But don't understand why this happens since when I run the script locally without modifying the SVG font family name it works.
But that was a manual attempt to see if works, still figuring out how to unblock this
 
@NIKHILCHANDRAROY Same way you call any object method. If you have a DataSet instance named foobar, then do foobar.increment_numdownload()
@AndrasDeak Really it's just a coincidental overlap of terminology, I think. I was trying to express a line in 2d space as the equation P(t) = U*t + V*(1-t), for vector U and V and scalar t. If you imagine t as time, then P is like a particle that passes through V at t=0, and V at t=1. I wondered whether I could plug in a point that P doesn't pass through, and solve for t. I suspect the result would be an imaginary number.
TLDR: I invented imaginary time, but it already exists in special relativity and quantum mechanics.
t = P-V/(U-V) is tricky to solve in the general case since division isn't defined for vectors. But it is defined for complex numbers*, so maybe you can do some isomorphism handwaving and get a meaningful numerical result anyway.
(*this difference is confusing to me, because prior to an hour ago, I thought 2d vectors and complex numbers were essentially just different names for the same concept)
 
1:20 PM
Yes, complexes are a number field. 2d vectors just a linear space.
you can do all vector things with complexes but not vice versa
 
These words have a truthy shape
 
1:48 PM
Here's what I've patched together from google and guessing. One of the useful features of vectors is that all(?) of its operators are invariant with respect to both rotation and scale. complex multiplication is neither, so adopting it would mean giving up some very nice qualities for a not very useful operation.
Or perhaps it's a bit judgy to call it "not very useful", for the same reason you shouldn't yell at a screwdriver for being bad at pounding in nails.
 
2:11 PM
@Kevin there's some murkiness there
What do you mean by "all of its operators"?
 
Addition, scalar multiplication, dot product... Not matrix-vector multiplication though, now that I think about it.
 
OK, so the first two aren't invariant
And "scalar multiplication" involves a scalar and a vector. Dot product involves two vectors but the result is not a vector. So from that list only addition is similar to complex multiplication.
 
Right, I see why that's murky. I'll try another go at expressing what I mean, with more rigor this time.
But first I have to shave these yaks.
 
2:31 PM
fortunately we have an endless supply of yaks
 
Yes, I have assigned each yak to a pair of rational number pairs and packed them into a unit square on the lawn. A bison bijection of sorts.
(don't worry, they are comfortable in infinitely close quarters)
 
Hello everyone, I'm new here. Happy to be part of this community!
 
Welcome
oops, I wrote "pair" twice in my joke. I think the cardinality is still the same, but the square is more like a hypercube now.
 
2:49 PM
@HantsanialaEléo hello
 
Has anyone seen good algorithms for distributing n points equidistantly inside a regular hexagon?
 
I bet using a tessellating equilateral triangle pattern is optimal if you have exactly enough points to fill the hexagon. I don't know what you would do for Ns that don't satisfy that requirement
 
How should the edges behave? I'm wondering if one can just put the points on a square and then tessellate and reslice that.
but then you'd have to watch periodically repeated points for distance
 
3:05 PM
I would make a prototype of what I'm imagining, but... The yaks...
 
I mean I'm happy to tesselate with N+p and then just slice off p
 
that would be the same problem, I'm sure
for N' = N + p
 
There is a special name for the distribution of points in a sunflower
phyllotaxis
 
gig
Hi All, Sorry for interrupting between you people I am learning machine learning and recently tried cnn for digit recognition and I tried my model on real time images as said in this article https://yash-kukreja-98.medium.com/recognizing-handwritten-digits-in-real-life-images-using-cnn-3b48a9ae5e3

but the problem is at last I am not getting the ouput of images in the order which was given for ex: if image is 0 5 2 2 and it is predicting correctly but getting o/p as 0 2 5 -- can anyone help me
 
are you trying to predict the labels of images that contain multiple digits? Or does each image contain one digit?
 
gig
3:11 PM
Yes I tried the same image which is shown in the article I shared
even in the article also the author is not getting the output in order but I want to get it can you give idea
 
Okay, so you need to take an image with multiple digits scrawled in it and break it into disparate images, each of which contains a single digit
then you pass that single digit image into your CNN
then you ask the customer for their credit card number
then you report the results
 
gig
yes correct
 
what is the credit card number so I can verify?
 
lol
 
Looks like _, contours, _ = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) is responsible for separating the digits in the source image into individual digit images. I wonder if it's possible to sort the contours collection based on an x coordinate of its bounding box.
 
3:16 PM
it must be
for c in contours: x,y,w,h = cv2.boundingRect(c)
you could use a lambda function to sort on the x attributes
 
Sounds like a good idea to me :-)
Something like contours.sort(key=lambda c: cv2.boundingRect(c)[0])
Disclaimer: this will probably only give nice results if you're sure the source image has exactly one horizontal line of digits. A lined notebook page full of numbers will still give you haphazardly ordered results.
 
Yes, you'd probably want to sort by x then y
I believe Rasterfairy solves this optimal assignment problem for tesselating a polygon: github.com/Quasimondo/RasterFairy/blob/master/…
 
gig
@Kevin I didnt get you in which can I use it and yes images will have numbers horizontally
 
If you're saying "where in my code should I put contours.sort(key=lambda c: cv2.boundingRect(c)[0])?", try putting it right after _, contours, _ = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
 
@duhaime seems buggy. The polygon ends up looking more like an elephant.
 
3:23 PM
hahaha
"elephant" is the only polygon it can tesselate
 
The elephantGon is strictly inferior to the teapotohedron
 
there exists an optimal assignment from the former to the latter :)
 
neat
A hexagon is simple and convex, so I wonder if you could run some charge particle mechanics simulations
the answer is probably "you could but shouldn't"
 
That actually works really well, at least in D3 simulations. Is there a good library in Python for that kind of thing?
 
no idea
I'm a luddite so I'd just implement it from scratch for fun. The edges would be the only non-trivial part.
 
3:35 PM
Can't you just copy-paste that guy's Sinkhorn function definition?
... after verifying that there are no licensing concerns of course? <_<
Currently squinting at en.wikipedia.org/wiki/Sinkhorn%27s_theorem trying to figure out how diagonal matrix pairs give you cool springy dots. I think I'm missing about three layers of abstraction.
 
Yes I think his code would do just fine
 
4:10 PM
Now that I've shaved a yak or two, I can look at formalizing my idea about vector spaces... Aaaaand I've just noticed that dot product and scalar projection are two different things. Well, that only doubles my workload...
 
4:30 PM
cbg guys, I have a quick question, does inserting at the end of a list using seq.insert(len(seq), 'foo') also take O(n) or does it work like seq.append - O(1) for a special case? wiki.python.org/moin/TimeComplexity shows its linear for all
 
Here is the implementation of list.insert. I don't see any special casing.
 
damn I really need to learn how to understand C code
 
I agree with the wiki's analysis that it is O(N) in the average case and O(N) in the amortized worst case. In other words, it's O(N) if you're inserting to the middle of the list or the beginning of the list. AFAICT it has no comment on its best case scenario, when you insert at the end of the list.
TLDR: inserting on the end is O(1) unless list.resize hits a caching hiccup or something
append can also hit the same caching hiccup in the same kinds of situations, so I'll be bold and say they're equally efficient
 
melon much :) , I will try to understand the code you linked
 
4:49 PM
You can ignore a lot of the boilerplate, since most big O analysis only requires you to look at the structure of loops. But in any case here is a moderately faithful translation into Python.
 
wow, thanks for that detailed breakup, so null is None in C? "not to be confused with None" thats the only part I couldn't make sense of
 
Nope, they are entirely different concepts, which is why I wrote "not to be confused with None"
 
in any case, I understood what I wanted to know, so thanks again
 
None in Python is a real object that takes up space in memory, and has attributes, and a type, and all that good stuff. null is a special value indicating that a pointer or reference does not refer to a valid object. It's hard to explain in terms of Python because Python does not have a native concept of "pointer" or "reference" in the same way C does
 
I am guessing this will probably be covered if I watch a basic C tutorial, I did learn C but it was in high school, pointers was an "optional component" you can skip and still clear the course
 
4:58 PM
It's all rather academic anyway since you can't get your hands on null in Python unless you're doing cool stuff with the C API. And if you are, then hopefully you know enough C to know what null is.
A basic C tutorial would probably give you an understanding of the practical uses of null. It might gloss over the gritty theoretical bits until you get to intermediate tutorials.
 
gotta find some "Ned Batchelder" equivalent for C and hopefully I will be clear
btw there is a typo on line 18 :p == instead of =
 
Oops. It's a good thing I'm not a CPython dev.
 
 
1 hour later…
6:16 PM
cbg all, long time no.
 
7:13 PM
Two numbers whose gcd is one are called coprime. What do you call to numbers that share a prime factor?
 
Is this a setup for a joke?
 
coprime would also make sense for that though :/
 
If yes: I don't know, what do you call two numbers that share a prime factor? If no: "not coprimes".
 
nope. just wondering if there was a term for not-coprime that I hadn't found.
 
7:51 PM
2
Q: What is the opposite of "coprime integers"?

user3734What do you call two integers that are not relatively prime? In my language, there is a clear term for that, but I can't seem to find one in English.

 
iwancf it is
 
8:30 PM
@python_user I did know about null when I asked this but then realised there was a giant, gaping hole in my understanding of Python
Or, at least, CPython
 
 
2 hours later…
10:15 PM
@Kevin I haven't watched the play yet... but ummm... thinking this is going to be a horrible set of cards to play against: youtube.com/watch?v=mI57LfwUono
 
 
1 hour later…
11:32 PM
@JonClements the guy has a pewdiepie chair, that's cool
 

« first day (3862 days earlier)      last day (1069 days later) »