« first day (4117 days earlier)      last day (814 days later) » 

user17921218
2:09 AM
Can anyone help me with a question regarding loading saved checkboxes in the database? Thank you
 
user17921218
Is anyone available? Thank you
 
3:04 AM
Weekends are generally pretty quiet. But surely you don't mean saving checkboxes, so much as saving bool values that are obtained from checkboxes, and then later used to populate checkboxes after being read from the database.
 
 
3 hours later…
6:31 AM
@NathanMüller You have already had 2 answers to your question that works as per your original question right?
 
 
2 hours later…
9:00 AM
Hey all, what should you do if no one answered a question but it received an upvote? I asked a PyCharm related question but fell into oblivion with not many views and an upvote
 
@Jzbach it doesn't do any harm lying around with an upvote
you can delete it without repercussions, although you will lose the +10 rep from the upvote
 
Should I then be patient? It only got 26 views and I have the feeling no one will look at it again for a looooong time hahaha
@AndrasDeak I care more about the answer, tbh
 
Ah, I see. Well you can try seeing if anything is missing from the question. If you add something to it, the edit will bump it to the front page as a side-effect. I can see you asked it on December 30; a lot of places are already in party mode then ;) Similarly, I'd wait for a (US/Europe) workday with an edit, because weekend traffic is much lower.
 
You are right, I didn't consider that hahaha
 
For instance if "break" in your question is supposed to be "brake" as in "slow down a Car", I'd fix that.
 
9:04 AM
Thanks for the input, I'll edit (bc I just saw a typo) but I'll wait until idk, tuesday or so
@AndrasDeak Yeah, that's the typo I just saw hahahahah
 
OK, that should work, or you'll see
since your question is more than 2 days old you can also ask here too, but this doesn't mean you can't do that edit later
 
It's a PyCharm minor inconvenience – I just wanted to switch to pytest but (my) PyCharm doesn't seem to have it properly integrated, so when I follow the tutorial to get automatic tests of class methods, it doesn't import the class
 
Exactly
Any hints on that will be appreciated
 
9:21 AM
> Users have asked 325 new log4j questions in the first 30 days since the vulnerability was announced, nearly double the total number of questions asked previously. For the first seven days after the announcement, the tag averaged 20 new questions a day. Compare that with the volume before the announcement: an average of one lonely question per day.
I wish they also disclosed how many were closed as duplicates
 
 
4 hours later…
1:45 PM
Cbg. I would like to learn python version of regex. Can you recommend best resource / course?
I want for example to be able to check if "both phrases are in string" or "one of phrases is in string" using regex only.
I say python version of regex because not all example of regex work in python.
 
2:02 PM
@KarolZlot Did you already check out the regex docs? There's also the regex HOWTO.
 
2:31 PM
The way I learned regex (many flavors, including Python's) was O'Reilly's Regular Expressions Cookbook. It goes from simple to more complex, covering variants along the way. It's one of the "easy reach" books near my main computer at home. regex101.com is also a great resource. This canonical question is good, too.
 
2:41 PM
@MisterMiyagi @MattDMo Thank you, but all those resources seem overly complicated. I wonder if it needs to be that difficult... :(
 
I have to say that regex is just a very complicated beast, on account of it being an extremely dense language.
If it's just to parse things, I vastly prefer PEGs these days.
 
Start with the basics, then work your way up, but as MisterMiyagi said, regex is complicated. Start with the different character classes and symbols - what does . mean? How about .*? What's the difference between .* and .*?? What is \s, or \d, or \w, and how are they different from \S, \D, and \W? A couple of the things (out of many) that I like about regex101 are the quick reference in the lower right and the explanation of patterns and matches on the upper right.
Now that I think about it, Mastering Regular Expressions might be a better beginning resource than the Regex Cookbook - it all depends on how you learn.
 
3:01 PM
In my experience, the best way to learn regex is to learn only the basics, and the progressively learn the harder stuff only when you need it. Essentially, when you inevitably need to google something, like "regex check if string contains both words", your reaction to seeing the solution is "aha, so that's how that's done!" and not "what the heck do these symbols mean?!"
If you spend an hour reading the regex docs, you'll forget 80% of it again because you can't associate most of it with specific use cases. You see things like "lookahead assertion" and have no idea what you would use that for. It's much easier to remember if you learn about it because you need it for something specific
 
3:22 PM
Actually, I phrased that poorly. When you google "How to check if string contains both foo and bar with regex" and you see the solution is (?=.*foo)(?=.*bar), your reaction shouldn't be "I don't know what any of this means", it should be more like "Hmm, what does ?= mean again?" -> "Oh, it's a lookahead assertion" -> "Oh, so this is what lookahead assertions are good for. Neat."
 
Hey all!
Looking for advice here:
I want to build a reinforcement-learning model of a billiard table. If the AI can create a path that repeats on itself after N turns (i.e., it's periodic), it gets a point. If it doesn't, it loses a point.
Can anyone suggest where I can start with this?
In the past, I've built CNNs for Image Classification using TensorFlow, but here I'm trying to combine AI with a Dynamical System, and I'm quite new to this.
If someone can provide any suggestions, that would be great.
Perhaps an image of the dynamical system I'm thinking of will be useful:
 
What is scipy sparse matrix format most appropriate for quick lookup of nonzero elements in a row?
 
I don't quite see how RL is useful there. The AI would basically just pick a starting location and direction, right? The rest is geometry, and I assume that there isn't really a clear relation between what the AI does and the resulting N.
So, poor feedback for the AI and thus not much to learn.
 
@MisterMiyagi Right, so the AI would be responsible for picking the initial conditions $(P_0,V_0)$
 
There doesn't seem to be any step-wise relation of optimising towards a goal for which RL works well.
 
3:35 PM
My hope is that the AI can discern some kind of an underlying pattern that dictates all periodic paths, but does not exist for non-periodic paths.
@MisterMiyagi Is there any way I can modify my approach so that it suits RL? In addition, what packages/tools would you recommend for this (i.e., billiards + AI)?
 
Hm, actually you are right, there could be some fixed angle and every n*angle gets you N hits.
There would certainly be a relation on a regular board, though as far as I can tell it would not be a fixed angle but something like "hit the 1/n th section of the side".
 
@MisterMiyagi Well, that's the thing -- perhaps there is some kind of formulation or pattern that as a human, I just can't figure out, but that exists for all periodic paths, but which a RL model could -- with sufficient data -- extract. Perhaps.
Yes, I've read a bit on the literature for this topic, but I'd like to take my own approach, which is more computational than mathematical.
Are there any packages/libraries/etc. you would suggest for modeling a system like this and combining it with RL?
As I'm quite new to this area (dynamical systems + RL), I'd appreciate any advice or suggestions.
 
4:11 PM
I think the "repeats on itself" detection will be tricky also, since I suspect you will be computing ball paths as a tuple of 2 contact points, or as a contact point and an angle. (I was originally envisioning that you would look at X-Y points on a path. You can't just compare a single point because the same point could be visited from multiple directions. So you need to look for a repeated line segment.)
In any event, you will be comparing floating point values, so you'll have to use math.isclose() to compare them.
 
@PaulMcG Regarding your point about an repeated line segment, that's what I was thinking.
Although there may be better approaches.
 
@MisterMiyagi @MattDMo @Aran-Fey Thank you for suggestions!
 
 
1 hour later…
5:22 PM
@MisterMiyagi I would imagine that, from a random walk, you could probably discern the boundaries (Monte Carlo might be better but I don't know if that could be applied in this domain. I'm thinking more about networks that learn computer games and the associated physics purely from the physics engine). Then again, the physics engine already exists and it's approximating that. I guess that might not be the case here
Huh, Smashbot was taking out the champs in 2017. I wonder what the newest nightmare AIs have been created to ruin childhood games since
 
Half baked geometry puzzle: find all points within the continental US that are equidistant from the Pacific and Atlantic oceans.
 
I seem to remember that in one classification, it actually happened to land on a town called Central and they went in hard on the obscure marketing, and then it got revised to be a town down the road and ended up in a bitter PR battle but it's not easy to search :/
 
Sounds familiar. I think they were competing to be the geometric center of the US. That's also a plot point in American Gods.
Yesterday a family member told me that El Paso TX is one such point. Looking at a map, I guess it's plausible, if the Gulf of Mexico counts as part of the Atlantic and the Gulf of California doesn't count as part of the Pacific.
 
@Kevin ahh... there you are :)
 
Howdy
 
5:37 PM
Ah, the town was called Center. One report full of ads but the Wall Street Journal version of the story is paywalled :/
 
Avv
Hello Guys,

Have you worked with Abstract Syntax Tree in Python? Ever saw that you can track API calls using AST?
 
What's the connection between api calls and ast?
 
Avv
I saw similar question on SO, "How to extract all functions and API calls used in a Python source code?"
 
en.wikipedia.org/wiki/… gives a bit of information about the actual center, but not about Center ND and its rivals
 
America does have some "interesting" place names...
 
5:42 PM
I'm fond of the ones where we simply stole a name from another country, like Memphis, or Paris.
 
Avv
@JonClements. I don't know what's the relation :/ Probably since AST represents all source code, its paths can have API calls.
Not sure honestly.
 
5:55 PM
I've used ASTs quite a bit. It's not too hard to find all calls, or find all calls with the speccific form some_name.some_other_name(whatever).
So for example you could look for all inline usages of the math module, e.g. math.sin(0), math.sqrt(x+y), etc. You wouldn't find things like from math import cos followed by cos(z), and m = math; print(m.tan(q)), but you can probably pick up 95% of the easy cases
Finding 100% of cases would require you to solve the Halting Problem, so let's try to be happy with 95%
 
Avv
Thanks Kevin. Appreciated. So it's because AST reflects source code, then some API calls can be catched as you mentioned. But since from ... is far from math, it can not be catched?
This is what you mean?
But AST also has paths not related to API calls like variable and function declarations, so we can skip these I guesS?
I though of using RegExp to get some information from parsed AST tree
But, I have to specify all API calls I might think of, but there are thousands of APIs, math, keras, time,...etc.
So, should we write RegExp for all APIs in mind please?
 
How do you intend to use regex on an AST? regex operates only on text
 
I'm trying to decide whether regex will be sufficient here. regex is notorious for not being able to fully parse any nested syntax, and AST representations are very nested. But maybe you can get useful information here without having to "fully parse" anything.
 
Avv
Aran, Antler can give parsed AST in a file like JSON, etc.
So it will similar to text
 
I don't know where the AST came into this but I much rather think they were looking for something like snakeviz
 
Avv
6:05 PM
Thanks Rogan.
 
That or something like callgraph or the much more sophisticated version (in terms of visualisations) that I forget the name of
 
Avv
Yes Kevin, you are right. And also we might have thousands of APIs in Python!
I think this could mean we have to write thousands of RegExp
 
Actually, I shouldn't have been so hard on callgraph; this is pretty detailed
 
What do we consider an "API call", here? math.sin(0) counts, if I understand correctly. How about float.fromhex("0x1")? It has identical syntactical structure as far as the AST is concerned. But it's all builtin types, no imports required, so it doesn't quite fit my subjective criteria of APIness.
 
Preemptive follow-up question: Is accessing math.inf an API?
 
Avv
6:12 PM
yes Kevin. Correct. Math.sin, etc. is an API call.
 
Why?
 
It would be much easier to just link the original question Avv. At this point, I'm really just thinking that you might have created your own version of the question, and the fact that the AST and regex are relevant
 
(Not trying to be difficult, just trying to nail down requirements)
 
Avv
library that serves functions is considered API as I understood from article I read on SO
 
30 mins ago, by Avv
@JonClements. I don't know what's the relation :/ Probably since AST represents all source code, its paths can have API calls.
 
Avv
6:14 PM
"How to extract all functions and API calls used in a Python source code?"
 
Yes, that doesn't talk about the AST or regex. At least in the title
 
Avv
Aran, math.inf is API call. math is an API
 
Had you linked the question rather than just giving what appeared to be a paraphrased title, we would have known it has an answer already
 
Avv
Sure. Thanks.
 
Well, you knew that it had an answer already. The fact that you asked here means that clearly you would like some clarification on something. My remark is that you've made everyone in this room start from scratch to understand what you're even trying to do, when there's already a defined problem and solution which would have given everyone a head start for free
 
6:21 PM
As far as I can tell, regex doesn't help with this problem. If you consider an attribute access on a module (like math.inf) an "API", then the problem is figuring out whether math is a module or not. You don't need regex, you need a static code analyzer.
 
I worry that some help-seekers are hesitant to link to any SO question related to their problem. Maybe they think we don't like problems that have already had some discussion on the main site. Granted, we do move 90% of question links to the Ouroboros and tell the help-seeker to try again later... But that's only for posts less than 48 hours old (appx).
 
@Aran-Fey Is (?=.*foo)(?=.*bar) any better than any(s in search_string for s in "foo bar".split())
 
Following Kevin's point, my own point didn't give a resolution. If you have info that you think can explain the starting point of the confusion you're having, please do link it in future @avv as it'll save a lot of questions and make it much easier for people to help you
 
@PaulMcG Well, we were discussing regex, so...
 
I guess you might get it to go in a single pass if you wrote (?=.*(foo|bar))
 
6:26 PM
I will now put on my Room Owner hat and promise not to scold anyone just for posting a link to a question older than 48 hours. (as long as it follows the usual rules of decency, etc)
 
(And it's equivalent to all(...), not any(...))
 
Are those really equivalent
 
Ah, so my alternative would also be for just any, not all
 
@vaultah Yes, as long as you enable the s (single-line) mode
 
Doesn't it imply that foo comes before bar?
 
6:30 PM
In particular I promise not to scold anyone for asking "I tried running the code in this answer, and I expected output X, but it gave me Y instead. What gives?"
 
...which, just like the name suggests, makes . match newline characters. Yeah, I don't know what they were thinking either.
 
Or is it tricky because lookaheads don't consume anything.
 
Coders that specialize in copy-paste oriented development, deserve troubleshooting help too :-)
 
@AndrasDeak Correct
 
Thanks, my ancient yet instinctive regex foundations sorely miss lookanythings so I find it harder to reason about them
of lookaheads perldoc says "An assertion that peeks at the string to the right of the current match location" which is actually a really helpful way to put it
it's really the same phrasing as "lookahead" yet it helps me form a better mental model
 
6:37 PM
I think that would be too subtle for me. If there's nothing equivalent to "without consuming anything" in there, I wouldn't get it
 
Ok, this I think could work as single pass: (?=.*(foo)?.*bar(?(1)|.*foo)) The (?(1) conditional looks at group 1, if present, uses the part before the '|', if absent uses the part after '|'. (regex101 to the rescue)
 
@Aran-Fey it might be the same for me, but I know that it "doesn't consume anything". I still didn't have a clear idea of what that implies (apparently). Now I think I do.
arguably it's just me being dumb about the "doesn't consume anything" part up till now
@PaulMcG do you have an idea about double pass vs more complex single pass? (Something something catastrophic backtracking)
 
@PaulMcG That may have a problem with catastrophic backtracking. Not entirely sure, I never quite got the hang of that
Andras'd
 
I mean, can you tell if either is better?
arguably the much more readable option would be far superior unless it's Perl
 
I'm not sure if it's worth optimizing for a single pass, but I'd probably go for something like .*(?:foo()|bar).*(?:\1bar|foo). (The \1 will only match if the first word was "foo", not if it was "bar")
Empty capture groups are probably my favorite trick :D
 
6:48 PM
ooh neat
 
Wait, actually that can match foo twice. Oh well, nothing you can't fix by adding more empty capture groups...
 
just sprinkle it on the regex like parmesan
 
Still neat
 
To guard against backtracking, we might need to de-greedyize all the .*s as .*?
 
Pretty sure that only changes the direction of the backtracking
.* backtracking is like "let's try that again with 1 character less". .*? backtracking is like "let's try that again with 1 character more"
 
6:55 PM
sounds like foretracking
 
7:28 PM
First question I land on and the first comment: "just let pandas to_datetime infer the format". That has to be a new record for the fastest "welp, that's enough of the main feed for today"
 

« first day (4117 days earlier)      last day (814 days later) »