« first day (3996 days earlier)      last day (935 days later) » 

2:00 AM
cbg!
 
 
2 hours later…
4:24 AM
cbg
 
cbg!
 
 
2 hours later…
6:48 AM
@duhaime You can parse it "manually".
s = '1/6'
p, q  = s.split('/')
v = float(p) / float(q)
print(v)
 
7:02 AM
I have a really dumb question, why can't we define a function without the parantheses? For instance just def func: print("hello") instead of def func(): print("hello"). The motivation for this question is that classes can be defined without the parantehses, simply via class Class: .Afterall, not every function needs parameters, so I'm wondering why the empty parantheses are still required when defining afunction?
 
I guess because classes often not need arguments...
@astralwolf But the point of functions are that they are reusable, they can apply a function to an argument.
 
7:41 AM
@astralwolf It's not dumb. We could permit that syntax. I suspect that such a proposal would lead to rather heated discussions. And silly puns (& Monty Python references) involving the word "argument". ;)
 
@astralwolf to answer your direct question, you can't define a function without parenthesis because the syntax of the language was defined that way. As for "why" it was defined that way, honestly i dont think there's a good benefit or justification one way or another
oops, PM 2Ring'd :P
basically, simply put. it can be done, but why do it? Doesn't really offer any real benefits and adds complexity for no good reason (..and no, saving 2 characters is not a good reason)
 
@ParitoshSingh they did that for classes. I think it's also about readability
Functions always get called, but most* classes don't have parent classes
 
I was also thinking of that, i think with classes it's also about how often we define classes without inheritance vs how often we define functions without args.
to me, without any real statistics to back it up, i presume classes ...er... yeah AD'd
 
The normal thing for a function is to have args. The normal thing for classes is not to have parents.
 
mhm, indeed
 
7:46 AM
100% subjective reasoning, but many might agree
The bottom line is as you've said: the parser isn't implemented to allow that
 
Well, main doesn't (usually) have args... I'm undecided. I prefer to keep the parentheses, but I wouldn't be upset if it were permitted to drop them for argless function definitions.
 
same, i dont strongly feel one way or another
 
I suspect my brain could go BONK seeing def foo:. But not sure.
 
FWIW, JavaScript allows you to drop the () for argless functions. It looks a bit weird at first, but you get used to it. :)
 
@astralwolf The parentheses in class and def statements aren't the same thing. In a def, they define parameters. In a class, they define arguments. Leaving away the parentheses means "use the default arguments", which are a lot more complex than "nothing".
From a language point of view (this is my own opinion) having classes defined without arguments is a good thing whereas having functions defined without arguments is a bad thing.
So you want to encourage the first but not the second.
 
7:57 AM
The thing about Python classes is that they originally permitted the argless form. Then when new-style classes were introduced in Py 2.2, you used class ClassName(object): to get a new-style class.
 
Hmm I see, thanks for the collective input
 
@MisterMiyagi Right. I get suspicious when I see a function def without parameters (unless it's main).
 
I do wonder if there's a PEP out there shooting down or talking about this suggestion
 
@PM2Ring I'm biased by int argc, char *argv[] there too, tbh. :P
 
@MisterMiyagi Coming from C, it took me a while to get used to Python's argless main.
 
8:03 AM
@astralwolf If there is, it's from before 3.8 because the new direction is adding pointless syntax changes to Python
I liked your previous avatar better, by the way
 
@AndrasDeak does that mean there already "pointless syntax change" already added to, say, 3.9 (since it's one of the version I use the most)?
 
@NordineLotfi yes
 
@AndrasDeak if so, which one would you think are pointless in 3.9?
 
"Pointless" is inaccurate, because it suggests harmlessness.
 
8:05 AM
@MisterMiyagi walrus operator?
 
@AndrasDeak To the detriment of "There should be one-- and preferably only one --obvious way to do it".
 
@NordineLotfi Don't mind me. Just sitting on a corn flake, waiting for the van to come…
 
Don't the crumbs chafe your butt?
 
Yellow matter custard can fix that too.
 
8:20 AM
In other news, SO are adding a benign tracking pixel to answers. There are some concerns that the collected data won't be very useful, but the accepted answer (mostly) addresses that.
 
 
1 hour later…
9:39 AM
Semantics: do classes take "arguments"? I notice that Andras was clear in saying "parents"
I only ask because I'm curious whether there is an OOP principle that means that the fact you can define classes without parentheses might be totally irrelevant in the context of functions in the first place and not just the decision of Python
 
The class statement takes arguments, which correspond to arguments of the meta-class methods.
I don't think there's an equivalent for these in the lingo of Java/C# like classes.
 
9:56 AM
Nice. That clears that up, thanks :)
 
OOP gets easier once you understand classes are homeomorphic endofunctors mapping submanifolds of the metaclass universe hierarchy.
 
.... nods head slowly
i guess OOP is not getting easier for me then :P
 
10:13 AM
If it helps, I'm just as confused as you are.
 
Do you even Java, Paritosh?
I forget that poem that was re-written in Java now that MM posted a while back. I might need to dig it back up and see if the second half makes any more sense to me now than it did back then :P
 
Did I ever post Java? Oh my, the sins of youth…
 
It was a famous (though, I think American that I wasn't familiar with) poem, I think about riding a horse and I couldn't work out from the code who shot who
 
haha, no i've never touched java in my whole life
 
Nor did I
 
10:20 AM
Not a poem. It was something like "there was an old woman who swallowed a fly" that gradually just got more and more incomprehensible in Java
 
That's the one!
Gosh, my memory got away with a lot of hand-waving there. Thanks :P
 
In case pf doubt, just cite obscure Beatles songs. As badness would desire.
 
10:55 AM
A-ha!
 
^ closed.
 
Yeah
 
11:46 AM
Hey, I remember that blog. A rare combination of informative and funny.
 
12:01 PM
OOP is a powerful and versatile hammer, but I think it tricks people into thinking that pounding nails is the only thing worth doing
 
12:44 PM
Can someone explain why my Loss Function looks good, but my confusion matrix looks bad?
 
Far too theoretical for me, I'm afraid
My area of expertise is more in the field of diagnosing problems from MCVEs and stack traces
 
1:00 PM
I'm feeling a strong sense of deja vu on this question
 
Last time it was 3000 data points.
I still don't get what the categories even mean.
None of the plots showed directly cubic/linear/quadratic functions.
 
@rb3652 I think I'm prepared to call it. It doesn't belong here. There's a lot of unknowns
 
Ok, I at least tried to look up the concepts. A loss function takes the NN's inputs and returns a real number representing how much you dislike those inputs. A confusion matrix visualizes your AI's ability to categorize inputs. You want the big numbers to be in the cells that have matching column/row labels.
Since a loss function's output is one-dimensional and a categorization function is N-dimensional (?), I wouldn't necessarily expect the accuracy of one to be equal to the accuracy of another
As a contrived example, suppose my NN identifies the color of a rubber ball. Its loss function returns the ball's lightness, and its categorization function returns confidence values for the ball's redness and blueness and greenness. The NN's input is a high-resolution black-and-white camera. The system is very very good at identifying lightness, and terrible at identifying color.
Ok, now that I've written my rant and my fugue state has subsided, I agree with roganjosh
 
1:15 PM
I guess if you shoot a 1 dimensional plane at the two dimensional matrix in just the right way, the shape of objects might stay recognizable.
 
If it doesn't, turn the pile until it does.
 
I was thinking of that too, like how IRL you can sometimes identify 3d shapes from their shadow
But if you urgently need to distinguish cylinders from spheres, maybe shadows aren't the right approach
 
I think Miyagi's remark was a callback to the 2d Dark Forest discussion from earlier :P
 
Ah, perceptive. Although in this case we don't need the projection to be bijective.
 
there are no bijective projections
 
1:18 PM
Apparently there are in the Dark Forest literary universe :-P
 
Hmm... I guess identity is technically a projection.
 
@AndrasDeak I just like to Stay on These Roads.
 
Have you tried rubbing the projection with unobtanium
 
Add monads to the pile until it's too complicated for people to disagree.
 
I guess "projection" is the wrong term for what I was thinking of. I just want a bijection between R^3 and R^2. I... think they have the same cardinality?
 
1:22 PM
@rb3652 is your training data uniformly distributed among your classes?
 
@Kevin good luck
 
Oops, did I invent a millennium prize problem
 
@duhaime if you want to help rb3652 I suggest opening a separate room for this, otherwise they'll keep coming back asking the room with no domain expert around
 
@duhaime Let me check ...
@duhaime Yes, I have 20 Linear, 20 Quadratic, and 20 Cubic. So yes, I have an equal # of each class
 
Hmm rb3652 if you set up a room and send your model code I'm happy to take a look. I'd just post on the main SO though
 
1:25 PM
@duhaime Thanks so much. How do I set up a room?
 
There's a "create room" button near the bottom of chat.stackoverflow.com
 
Try right clicking my little thumbnail in the room image queue and then select "start a new room"
 
Trying to remember if there's a minimum required reputation needed to make a room
 
No, I don't see that
 
Guys if I'm not back in 10 minutes rb has hid my body somewhere
 
1:26 PM
Probably because of my reputation
 
Ok, I'll make one for ya
 
OK, Thank you
 
I just invited you
 
Oops I guess I was too slow
 
thanks, both of you
 
1:30 PM
math.stackexchange.com/questions/245141/… asserts that you can biject between R^1 and R^2, but none of the proofs give a concrete example. Nonconstructive proofs, I shake my fist at thee
Oh, I overlooked one of the answers. Map R^2 to the unit square, then interleave the digits of your two reals into one real, then map the unit interval to R^1. I guess that's concrete enough.
 
Like a space filling curve? Dr. Hilbert?
 
I'm guessing it's harder to make a closed-form expression so you don't have to spend infinity years interleaving digits, when the inputs are irrational
 
@Kevin and that won't be a projection, because the result embedded in the original R^2 (for an automorphism) is the real line, but if you appliy the transformation to a point on that real line you get a different point (due to the interleaved zeros from the imaginary part). So it's not true that T^2 = T, which is what a projection would do.
 
@duhaime I was thinking of that myself, but the chilly reception of math.stackexchange.com/a/245148/46020 perhaps indicates it's not a perffect fit
 
"and the square is Hausdorff" Sheesh, and people say programming is confusing…
 
1:37 PM
Space-filling curves even in the infinite limit smell rational to me. But I'm just guessing.
 
@AndrasDeak Oh, interesting. So projections are idempotent? Just like IRL shadows, kinda
 
@Kevin shadows are projections, and yes, that is the defining property as far as I know. Project twice and you get nothing new.
 
Ok, this information pleases me
 
in order to make sense of this, you have to define it as an automorphism (which you normally do by embedding the result into the original space)
@Kevin and P^2 = P implies that eigenvalues are either 0 or 1, which makes sense with the intuitive picture: there are "projection leaves alone" eigendirections and "projection maps to zero" eigendirections. Which is why identity is technically a projection, I think.
You can decompose any vector as the sum of a "leaves alone" component and a "maps to zero" component. With the colloquial projection, the "maps to zero" is along the projection direction, and "leaves alone" is the rest.
 
This information has a trustworthy truth-like shape, but I don't think I would be able to explain it to my grandmother
 
1:43 PM
Well I am using jargon without defining it. I could probably explain it to your grandmother if she could give me feedback.
In case of your cylinder and sphere, their points only differ along the "maps to zero" axis, so they both get projected to a circle.
 
Alright grandma, first you need to read these fifteen wikipedia articles... What do you mean you've been blind for thirty years? Who's going to look at all the diagrams I drew?
The answer is "grandma will, and she'll tell you that they're beautiful, and she doesn't need to see them to know that". Thank you grandma.
 
all those macaroni paintings paid out
 
Your undefined jargon is all things that I have looked up before and then forgotten about. I think everything will come into focus when I find a spare ten minutes to google them
"eigen" is german for "moderately advanced math thing"
 
in case you're not just joking, it means "own-" :P
 
80% joking, 20% couldn't remember its actual meaning
 
1:53 PM
@AndrasDeak I get what you mean, but in the limit they do visit every point. So the classic Hilbert plane-filling curve en.wikipedia.org/wiki/Hilbert_curve has (Hausdorff) dimension 2.
 
Do you need denseness for finite Hausdorff dimension? I forget.
 
I wouldn't mind a space-filling curve that only touches some of the real unit square and all of the rational unit square. My hypothetical NN is only going to use floats for inputs and outputs, after all.
 
A Sierpinski carpet like
 
"in the limit they do visit every point" -- darn, once again I'm stuck doing infinity calculations for certain inputs
 
xxx
x x
xxx
 
1:57 PM
> The Hausdorff dimension of the Cantor set is equal to ln(2)/ln(3) ≈ 0.631.
Oops, Cantor set is uncountable. Carry on.
 
Has Hausdorff dimension ln(8)/ln(3) because when you triple its scale, it only gets 8 times bigger
@AndrasDeak Finite, or integer?
 
Good point, I meant integer.
either way I remember too little and I'm way too tired for this level of mathematics :)
 
The Mandelbrot set boundary obviously doesn't densely fill a square, but it's still maximally "fractal", so it has dimension 2.
IIRC. :D
 
Don't don't sleep and fractal.
 
2:08 PM
I like the concept of Hausdorff dimensions as a measurement of fractalness. The basic examples Wikipedia gives all seem intuitively correct to me. But when I look at the formal definition, I bounce off of it in about half a sentence
"Let X be a" -- ok, so far so good --"metric space" -- what's this crazy gibberish!
 
@Kevin I just noticed that the Sierpiński tetrahedron has dimension 2. Good luck intuiting that :D
 
It's easy to see once you fold your mind into an origami samurai
 
@Kevin just use your evolutionary intuition for a metric space, it's literally just something with a distance defined.
but I suspect you're just being hyperbolic again
 
Yeah :-) Metric space is yet another term that I once knew, and can't explain to grandma
I always get a kick out of it when I look up some concept and the formal definition is way complicated, but then the Examples section mentions the natural numbers, and it becomes apparent that an intuitive understanding only requires a kindergarten level education
 
@AndrasDeak Easy. To iterate to the next level down, you need 4 half sized tetrahedra, but each of those has 1/8 the volume.
In the UK, they prefer Imperial space to metric space.
 
2:17 PM
@PM2Ring I know the formula, but it's not intuitive at all that this tetrahedron with holes in it has the same dimensionality as a rectangle.
at least to me
 
"A ring is a homeomorphism on the endofunctor of categories yadda yadda axiom of choice yadda yadda Zermelo Fraenkel set theory... For example, basic addition and multiplication on whole numbers is a ring"
Maybe lead with that next time
 
@AndrasDeak Fair enough. And it's not intuitively obvious that you can't "tile" space with (equal size, regular) tetrahedra, but you can with tetrahedra and octohedra.
 
@PM2Ring Can confirm, I've spent many DnD sessions fruitlessly trying to build a serviceable pyramid out of four-sided dice
 
The word for "die" in this context is "throwing cube" in Hungarian. Imagine one's annoyance when one has to say "20-sided throwing cube".
 
I don't think incorporating eight-sided dice would be practical, unfortunately, because the side lengths tend not to match up. Perhaps the manufacturer designed them to have equal volume.
Pointless exercise: find the volume of a tetrahedron with side length 1, and find the side length of the octahedron that has that same volume
I bet their ratio is some elegant nonsense involving phi
 
2:26 PM
simplices and cross polytopes... yumm...
 
I've done animated ray-tracings of the octa-tet tessellation. They look nice, but it's not easy to see the structure. :)
@Kevin More likely sqrt(2), IIRC.
 
This is also acceptable to me.
 
sqrt(2) is the vanilla of irrationals
 
You can make an octahedron by joining the centre points of the faces of a cube. You can make a tetrahedron from the diagonals of the cube faces.
 
lacks a cool demo ;-)
 
2:29 PM
@FélixAdriyelGagnon-Grenier Give me a few minutes & I'll do the cube tetrahedron thing.
 
That would be literally delightful
 
@AndrasDeak Considered exotic and exciting in olden times, but its novelty faded away as civilization developed... Metaphor checks out
 
I've got this for a given crystal structure's unit (actually Bravais) cell
 
Can we rotate that just a smidgen so the back corner isn't obstructed? And can the lines be in the shape of a cat, please
 
fixed exactly one of those
 
2:39 PM
My respect and fear of you has grown measurably
 
I could also post some code if this were about the cube and octahedron, but what I have now is the equivalent of whittling down an 800-year-old sequoia to get a toothpick. If you remind me in three weeks when I have the time I can put together a dedicated script for that.
 
Ok, keeping in mind that the ideal amount of time for anybody to spend appeasing my whims is zero
Only when my whims intersect with the appeaser's whims, should action be taken
 
It's just a crazy busy two weeks right now, so I'm trying to stay on track :D
 
Sorry boss, I can't publish my new proof of Fermat's last theorem, I'm busy explaining to Kevin's grandma how to square the circle
 
^ Tetrahedron in a cube
 
2:55 PM
you boys designing tea bags?
 
Nice. It seemed intuitively correct that you could make a tetrahedron from a subset of a cube's corners, but I couldn't visualize how to choose the correct corners. That demo does a good job filling in the blanks for me.
 
My cup runneth over with whim satisfaction
 
pyvista is a biggie due to vtk, so consider a separate env
 
Will do
 
3:01 PM
@PM2Ring niiiiiiiiiiice
 
I better crank up the sensitivity on my nerd snipe detector so I don't accidentally DOS Andras again
 
heh, I just realized that I can use .cell_centers() to grab the face centers without any extra work
 
Any message I write with "exercise:" in it will go into a time capsule, to be unsealed three weeks from now
 
the critical amount of work I wasn't going to put in now was figuring out all the (1/2, 1/2, 1) coordinates
 
Valid, I've spent many minutes figuring that out during my own geometry projects
 
3:05 PM
@FélixAdriyelGagnon-Grenier Thanks. The line3d function takes a thickness parameter, if you want chunky edges.
The underlying 3D engine, three.js, can do amazing surface textures, lighting, etc, but Sage doesn't expose those features.
 
three.js has just been added as a backend for pyvista, to be used in notebooks and other webapp contexts
 
Sometimes I would derive an octahedron's coordinates by taking its geometric center and adding {i, -i, j, -j, k,-k} to it in a for loop. And then some additional magic to figure out the edges.
 
pythreejs, to be specific
 
The end result is usually longer than just doing it on paper and putting the solution into the program as a constant literal. But it's not about the LOC, it's about sending a message.
 
@AndrasDeak Interesting. There are some impressive examples on the site: threejs.org Here's an animated one: threejs.org/examples/#webgl_animation_cloth
 
3:12 PM
@Kevin yeah, it's worth spending a few hours of coding to save a few minutes of mindless chores
@PM2Ring neat
 
It blows me away that it's doing that cloth movement in real-time on the client, in JavaScript.
 
Heck, somebody foolishly installed 32 bit Python on my computer, and vtk doesn't like that
 
huh
at least you'll have someting to do in the next 3 weeks ;)
 
Backporting vtk to 32 bit, yes, my most ambitious feat yet
 
hehe
I've built it from source. Would not recommend.
 
3:20 PM
is there a library that converts string representations of fractions to floats? Like 'eighth' -> float(1/8)
 
The word "eighth" hurts my brain because I do not think "hth" should be a valid English trigram
 
seems like Old Englysh
 
Also, I am not aware of any such library, sorry
 
indeed it is
 
I'm just going to spell it like "eit" from now on
 
Ah, I see this dog is a being of taste and refinement as well
 
@Felix You might like my program that draws a 3D Bézier curve through the points on a Hamiltonian path on a regular dodecahedron. chat.stackexchange.com/transcript/message/58972241#58972241 There's some more info at chat.stackoverflow.com/transcript/message/52929083#52929083
 
yes, I very much do :O
 
3:42 PM
Coincidentally, they've just been discussing cubes & octahedra in the Math chat.
Yay! A SF&F story ID question I answered has hit the HNQ. scifi.stackexchange.com/q/254187/116908 I was lucky to see it just a few minutes after it was posted.
 
4:06 PM
I did that once and I've never felt more powerful
 
4:18 PM
sshfs and lsyncd - such wonderful tools!
 
I have used the first one to mount a server's drive in my laptop and use my own IDE to edit files :D
 
@PM2Ring Congrats... perhaps a bigger achievement though is you getting an answer in before Valorum :p
 
5:20 PM
@JonClements You gotta be quick to beat him. :)
 
^^^ like that quick :p
 
John Rennie's pretty fast too, and knows a vast number of stories. But I think he's been a bit busy lately.
 
5:37 PM
hi folks,
need some help about django
if youtube used django, how they handle redux, state management?
I don't use webpack, react or other, Is there any way to use redux or like this feature in Django project without webpack?
 
6:35 PM
@NIKHILCHANDRAROY If you do not use either React or any JavaScript framework, I am quite confused as to what you would want Redux to be doing when calling it from Python scripts? Am I correctly understanding that you are talking about the JavaScript state management tool named Redux?
 
 
1 hour later…
7:36 PM
Hi @Kevin, I simplified the pseudocode as well as your version of the pastebin to the code here: pastebin.com/Sf349gsi. All the producer does is adds the interger 1 to the queue, while the consumer removes the integer 1. Once again, the pseudocode for refernce is here
var q := new queue

coroutine produce
    loop
        while q is not full
            create some new items
            add the items to q
        yield to consume

coroutine consume
    loop
        while q is not empty
            remove some items from q
            use the items
        yield to produce

call produce
 
thanks for the text
 
My question, is there any possible way to make the source code more like the pseudocode via the usage of the yield from syntax? (instead of a yield to). So the while loop outside the 2 functions I assume can be incorporated into the generator functions or something
 
 
2 hours later…
10:02 PM
@YoussefDir hello. If you're writing python then asking about your IDE to work with it is fine.
 
Hi all
I'm working in Python but my question is actually in VSCode.
If this violates the chat group please ignore it.
When debugging, I use step into F11, when I continue if another module opens, it replaces the one just been there.
I want it to be next to the previous one.
In Android Studio, it acts the way I wanted
I scrolled through the settings in VSCode but ...
Have you been in this ?
 
I don't use VS Code so I won't be able to help, but just so I understand correctly: "step in" replaces the tab with your original file, and instead you want for it to open a new tab next to it?
 
exactly
 
OK, thanks
 
 
1 hour later…
11:06 PM
I also dont use VScode, sry
result = yield from subgenerator(). Is it possible for result to actually hold any data? How are you able to send values into it? Or is result only for storing exception information returned by the subgenerator? Can result hold any other info besides exception info/ None?
 
Isn't that what send()'s argument binds to?
 
(disclaimer about being wrong) when I was testing it seems that send() actually sends the value to the subgenerator
 
If you send to the subgenerator then yes
 
the generator that implements yield from never actually receives or holds any arguments made by send on that function
no I was sending to the first generator, not the subgenerator
def delegating_generator():
    subgen_obj = subgenerator()

    value = yield from subgen_obj
    print(value)

def subgenerator():
    for i in range(0,3):
        caller_receive = yield i
        print("JUST PRINTING", caller_receive)

gen_obj = delegating_generator()
subgen_receive = next(gen_obj)
print(subgen_receive)

received = gen_obj.send("PERSONAL DETAILS")
print(received)
An example
 
11:31 PM
 
alright, goodnight and thanks
 
(I guess the behaviour makes sense if I actually think about it)
 

« first day (3996 days earlier)      last day (935 days later) »