« first day (2523 days earlier)      last day (2426 days later) » 

7:00 PM
@Kevin Sensibly uses enumerate and doesn't abuse a default lambda - booo! :p
 
Full points for execution, but none for daring to tread where no man was meant to go
 
Can somebody help me with a regular expression
 
It's not impossible that someone might.
 
wim
oh yeah what about
 
I want to get Names of Person , they either one word or one or more word seperated by space
 
wim
7:02 PM
 
Like Either - Pawan or Pawan Sharma
 
@wim no start/step
 
wim
sorry that's the same as Paul's
 
yup
 
@TemporalWolf English war? They should be stopping soon for tea ;)
 
7:04 PM
I tried many RegEx(s) but none of them worked as I want them to
 
do you really need a regex?
 
couldn't you split on a space?
 
I tried ... umm can I paste a lill long text here ??
 
use pastebin or something
 
7:07 PM
If it's long, use pastebin.
 
please read the room rules, which among other things asks that you don't paste large blocks of code here
 
oh , thanks , let me do it on pastebin
 
It's going to be hard to write a regex that can distinguish names from other kinds of words. "Pawan Sharma" and "Hello World" are both collections of words separated by spaces, but only one is a name... And even that is a matter of opinion
 
So my new earbuds are so noise canceling I can't hear when someone is standing next to me greeting me, they end up usually having to tap me on the shoulder or wave a hand, while I'm to focus on my work. I feel like I should get a different pair :(
@Kevin Jokes on you, I'm sure someone will name their child Hello World.
If North West can be a name anything can be a name!
 
wim
yeah, I will name my first-born '\N{PILE OF POO}'
 
7:13 PM
 
no "drop table" middle name?
 
AD :D <3
 
ok , here's the pastebin
 
So we're agreed that the only valid name-checking regex is ".*"
 
@Kevin no, that doesn't account for newlines
 
7:14 PM
I used re.DOTALL
 
I'm not sure what I'm looking at Pawan.. you have to give us a MCVE
 
@MooingRawr Actually, DELETE STUDENTS would be more likely to succeed, since it would not require DDL privs, just delete privs - and are tables named with plural or singular?
 
MVCE ?
 
that input looks like a mess
 
yeah , but that's repeating
 
a repeating mess is still a mess :P
 
haha
ok, creating MVCE
 
Has anyone updated Django urls.py to 1.9+? The problem I'm facing is that I need to add app_name as well but it's not clear to me where some apps come from. E.g. I have include('social.apps.django_app.urls', namespace='social'), what would the app_name be - django_apps?
 
does the python import system have a well-defined order when it comes to module vs package? Like, if I have a foo.py module and a foo package in the same folder, which one will import foo import?
 
I should point out that I'm getting `RemovedInDjango20Warning: Specifying a namespace in django.conf.urls.include() without providing an app_name is deprecated. Set the app_name attribute in the included module, or pass a 2-tuple containin
g the list of patterns and app_name instead.` when running the tests.
 
7:30 PM
Here is a new paste that explains everything
 
@Rawing iirc it takes package only
I remember saying one day I will learn Django, today is not the day :\
 
@PawanSharma I'd probably try to parse that using pyparsing
 
Now you are making sense Pawan, if you know the file layout, you don't need regex, just parse it line by line and since you know the file layout you know what you are reading. unless some lines can have multiple lines
 
pyparsing ? well never heard of it .
 
if you want to stick with a regex, then keep control of the newlines
then "whatever is on this line" will be your Relation Name
 
7:34 PM
yeah
 
@MooingRawr thanks. I guess I'll play it safe and rename one of them though
 
that's probably best
you should also consider renaming them from foo, sounds a bit too generic
 
@AndrasDeak Probably easier/quicker to just iterate over the lines and looking for line.startswith('Name:') or whatever than writing a parser with pyparsing. The format looks pretty rigid.
 
possible; I said "try to parse", then I might realize after 5 minutes that it's not the right tool ;)
I mean, that was my notion before you gave your two cents :D
 
I still stand by my 'if you know the format and it's static just parse it line by line' :D
 
Yeah "parse it line by line" has the best effort-to-robustness ratio, as long as you're not jumping through too many hoops to recognize state changes
 
@Rawing , So no re.DOTALL in this . Isn't it ?
 
yep
 
ok , let me try this
 
@Kevin you kevin'd me on the main site :( Time to just sit back and twiddle my thumbs I suppose ...
 
7:49 PM
Joke's on him, rotating a list by one element is O(N) no matter what you do
 
:P not unless you do some voodoo magic which we haven't invented yet
 
The answerer is wise to suggest deque, or perhaps foolish to get involved at all
Ooh, OP needs constant time indexing too. I think OP is doomed.
@Kevin, Yes I want to remove it. — Adam 34 secs ago
Oh, never mind then. He doesn't need rotation at all.
In which case if len(heap) != 1: heap[0] = heap.pop() is perfectly fine
 
Vague OP is very vague
 
Vague questions are the only ones we talk about in here. Clear questions prompt no conversation, nor do completely incomprehensible ones.
 
I read somewhere that if you need to compare high floating point numbers you should convert it to a string and then compare the string values.... which got me to thinking general math solutions
@Kevin Sometimes they do, for example when the Ninja answers a question and we start a conversation on the origin of the Ninja.
IF you are referring the conversation to be on topic of said question then I would agree.
If you were making your question vague to prompt my current statement and last one, well then well played
 
7:56 PM
I can't imagine it ever being a good idea to convert floats to strings before comparing them.
 
which is why I was thinking of math solutions
 
Maybe there's a game of Chinese Whispers going on here, and what was really meant was "floats can't exactly represent numbers of arbitrarily large sizes, so for languages that don't have unlimited precision numbers, it may make sense to store huge number data in strings, even though this makes even simple arithmetic difficult, since you have no other choice"
But Python has native unlimited precision integers, and it has the fractions module, and it has the decimal module... We're good on that front.
@MooingRawr Not sure what you mean by that. No math is required to compare two large floats; you merely need to do large_float_a > large_float_b
 
I meant to see if the floats are the same, if there are more than 10000 digits.
I can't think of the practical sense for it though
 
large_float_a == large_float_b, then
The largest float on my machine only has 308 digits, though
>>> sys.float_info
sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
Or maybe you're saying "I want to compare large floats and see if they are approximately equal, but I'm worried that the usual approach of abs(a-b) < epsilon will fail because subtraction might work funny for really big numbers"
Which... Might be a valid concern, actually. I don't know enough about float arithmetic logic to be sure either way
 
well you shouldn't use epsilon, you should use an appropriately chosen tol
floating-point errors are usually more than epsilon
 
8:04 PM
tol?
 
short for tolerance ;)
 
Isn't that what epsilon is? A fancy way of saying "the tolerance I have chosen"?
 
nope
Machine epsilon gives an upper bound on the relative error due to rounding in floating point arithmetic. This value characterizes computer arithmetic in the field of numerical analysis, and by extension in the subject of computational science. The quantity is also called macheps or unit roundoff, and it has the symbols Greek epsilon ϵ {\displaystyle \epsilon } or bold Roman u, respectively. == Values for standard hardware floating point arithmetics == The following values of machine epsilon apply to standard floating point formats: == Formal de...
see sys.float_info.epsilon you have up there
 
Is this one of those things where a word can mean different things
 
@Rawing and all other people - Thanks a lot guys . It worked !
 
8:05 PM
so if you take the dot product of two 1000-length vectors, you possibly add up 1000 floating point errors
@Kevin yeah, and the word "context" comes to mind
 
Finally made it to work
 
but just 2 lines above you used "epsilon" in another context so I thought I'd note that :P
 
Nothing wrong with that.
 
8:35 PM
English language Bug Report: Word mapping is surjective
leads to confusion and puns
 
*and non-injective ;)
actually; I think most puns come from word mapping not being a function to begin with
sorry to be that guy again
Why is for k in val1,val2: valid but if k in val1,val2: a SyntaxError? :(
I can't see the ambiguity in the latter right now
 
if k in (val1,val2): vs if ((k in val1),val2):
I guess.
 
I'm half convinced
only half because the latter case would be stupid
 
8:52 PM
yeah but it's stupid on a semantical level, not on the syntactical level :p
 
yeah, I guess :)
thanks
 
9:07 PM
Huh, I just stumbled upon numpy.linalg.multi_dot. I might have used it in the past had I known about it. What about you, @DSM?
looks really handy, especially the hint about estimating computational cost (which I never know how to do)
pretty straightforward now that I see the formula, but I never sat down to think about it
 
@AndrasDeak: The in in a for-in is part of the for loop syntax. The in in if thing in other_thing is the in operator. Two very different usages of the keyword, with different interaction with precedence and different rules for what can go on either side.
 
ah, that's what I was missing, thank you
 
interesting idea for an interview question in python: "how would you make an immutable class in python?" (would generate good discussion I'd hope! hah)
 
It's trivial in hindsight; but my if k in was inserted among a dozen for loops, and I hit a blind spot :)
 
wim
9:44 PM
@AndrasDeak that just says to me that np.dot has a crap interface
it should be like np.dot(*arrs, *, out=None)
 
a dot product is a very strongly binary operation in mathematics
and I'm already unhappy about how np.dot works with two multidimensional arrays
 
wim
does a*b use dot or element wise?
I forgot
 
elementwise for arrays (matmul for matrices)
 
wim
ughhh
 
otherwise we wouldn't need multi_dot
 
wim
9:48 PM
numpy why you so unpythonic
 
the whole rationale for the matrix class is *
@wim why is that unpythonic?
 
wim
but @ is for matmul
 
now it is, and matrix has been de facto deprecated for a long time
 
wim
@AndrasDeak 'one obvious way to do it'
 
but originally they thought that v*M*w beats v.dot(M.dot(w)) or something, and there was no @ to do v@M@w
@wim I don't think that's violated here
 
wim
9:51 PM
I never saw anyone use the matrix class
they all use ndarray and then use a.dot(other) if they need that
or a @ other if they are cool kats
 
yes, because most if its advantage was *===matmul, but it had a bunch of restrictions compared to arrays
so by the time I started with numpy (not that that was long ago) it was well established that "yeah there's a matrix class but don't use it please"
 
wim
right because it was a dumb idea to have it in the first place
 
arguably, yes
 
wim
my other pet peeve is those r_ and c_ objects
like, wtf crazy kind of interface is that
 
I never got the hang of those
I only use .ix_
I just used it an hour ago :P
 
wim
9:53 PM
what's .ix_
not so obvious from the name
 
are you familiar with matlab?
 
wim
yes
 
.ix_ gives you fancy indices that slice an array with non-contiguous indices
so matlab's A([1,3,4],[1,3,4]) gives you a submatrix, while numpy A[[0,2,3],[0,2,3]] gives you a length-3 1d array via fancy indexing
if you want the subarray, you need A[np.ix_([0,2,3],[0,2,3])]
it generates the fancy indices that corresponds to that subarray
 
wim
so python have min(4, 7) but then imagine you had to do multi_min(4, 2, 7) or min(4, min(2, 7)) or, worse, use reduce
 
I'm pretty sure the maths motivation beats the programming one in this case
dot is binary, period (pun unintended)
 
wim
9:57 PM
@AndrasDeak that's a good point though
just got excited to see a python question with .send .. .but it was socket.send not generator.send
boring
 
/me goes to write a question about generators for wim
 
tag:reopen-pls OP has narrowed his question (although I would say his original question was focused enough for an answer).
Apparently I messed that up, oh well
 
why can't i use regex in a search engine ????
 
@TemporalWolf you can edit for 2 minutes
@Idle001 chill
@TemporalWolf I'm not sure "how does this code work?" kind of questions are a good fit for SO
side note: there's some Yoda logic in there
 
At worst it's a dupe
 
10:04 PM
this steers too close to a hand-holding tutorial problem for my taste
 
wim
it's wildcard, he means "why can't i use regex in a search engine guys" or "why can't i use regex in a search engine heck"
 
or an expletive?
 
wim
nah expletives are censored in rm 6, so if you type them it just looks like this now: ****
 
**** hunter2
 
wim
you got it
 
10:09 PM
Did anyone say ****?
 
wim
thats a greedy regex ****
how you knew my password, deak?!
 
What do you mean? My last message only contained 4+7 asterisks
 
Wait, I'm seeing my password too! Does it just magically replace the * stars with my password? What if someone was reading my screen?
 
10:27 PM
i'v got a ****
silly widget, how come something that just $(input[type='masked']).val() be in the store
 
10:45 PM
recbg
 
cbg
 
11:15 PM
and rbrb
 
11:34 PM
@ThiefMaster I'm going to try to devote some time to Flask-SQLAlchemy. Pretty sure 512 is just another part of the tablename issue.
Just need to turn these very clear notes I wrote months ago into code. :-/
 
import pandas as pd
s = pd.Series({'A': [{'a': 1}], 'B': [{'b': 2}, {'c': 3}]} )
s.where(lambda x: len(x) == 1)
ValueError
how do i do this?
 

« first day (2523 days earlier)      last day (2426 days later) »