« first day (3305 days earlier)      last day (1658 days later) » 

5:39 AM
How can I extract the time from datetime.timedelta object?
 
pardon? the point of a timedelta is not being an absolute time
there is no time to extract
 
OK, I found a variable seconds which stores the time in seconds, and from there I can get time
@MisterMiyagi I mean the duration
 
I am still confused, but if what you have works for you... jolly good.
 
5:59 AM
Hi everyone
I was using timeit to compare lists and list comprehensions in jupyter
%timeit [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]
For this I got 2.39 µs ± 298 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
def test_function():
    combs = []
    for x in [1,2,3]:
        for y in [3,1,4]:
            if x != y:
                combs.append((x, y))
%timeit test_function
For this I got 75.1 ns ± 15.6 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
Can someone tell me why the second one is taking less time than the first?
 
you are not calling the test_function
 
Ok, what would have been the correct way to compare the times here then?
 
well, time calling the test_function
%timeit test_function()
note the ()
 
I know that test_function without the braces would display <function main.test_function()>
Never mind, got it thanks! @MisterMiyagi
 
yes, you were initially just timing how long it takes to look up the function, not executing it.
 
 
2 hours later…
8:00 AM
hello guys
 
 
1 hour later…
9:19 AM
Does anyone else use Chrome? Have I hit some weird key combination or is it a new feature; I get a popover on every tab now that expands the full name of the link
 
9:54 AM
cbg
 
10:37 AM
@roganjosh I have it too, it's a new feature it seems
 
Boo hiss. I wish it would wait like 0.5 secs or something, I find it annoying. But thanks for confirming :)
 
cbg
 
10:53 AM
urgh. After spending an hour before figuring out that TYPE << TYPING | STENOTYPE is not the same as TYPE << (TYPING | STENOTYPE) -- now it's back to a RecursiveGrammarException for me :/
 
11:03 AM
I'm confused about what I've missed in my answer here. What is the OP hoping for?
Ilja Everilä corrected me and I added it to point 2. Are they asking me to make an explicit reference to that code? I'm guessing they didn't follow the link, but that's my best guess
 
I guess they are asking you to reply "yes".
 
If I tag them in the comment then it should go over the character limit and my current mood is making that sound appealing :P
 
11:20 AM
@roganjosh in advance for your confirmation whether
 
"You can use those connections and avoid SQLAlchemy"? :P
 
Maybe. Haven't read the tech stuff.
 
Audio books of documentation. Yey or Nay as a business idea?
 
It is a business idea. :P
 
So you won't be joining me on Dragon's Den/Shark Tank? :/
 
11:26 AM
The future is instagram
 
So, screenshot the docs and add some cute filters?
 
Low-level tiers on snapchat
 
Today I referenced Tools.scripts.find_recursionlimit.RecursiveBlowup5.__getattr__ in an answer the class name still gives me a chuckle every time I read it
 
I hope stackless pythons implement that ;)
Raymond Hettinger has been quite active on SO stackoverflow.com/users/1001643/raymond-hettinger
 
@Aran-Fey "NB: A program that does not use __methods__ can set a higher limit." -- what's __methods__?
 
11:38 AM
@MisterMiyagi dunders in general?
 
ah, that makes sense
 
I just realized I accidentally a word
I wonder how often that happens without me noticing
 
Is it an omnipropriate word?
 
If "and" is a valid answer to your question, then yes, otherwise no
 
Hmmm, it appears I cannot answer that. We're in the twilight zone of language
 
11:49 AM
I suppose "and" is omnipropriate if you make it a question.
"and?"
 
I googled omnipropriate. Google said at the top: Did you mean: inappropriate
Well google, i wouldn't be asking if i knew, now would i! :(
 
Steady on the omnipropriatiety of words. "Will you marry me?" -- > "and?"
When spellcheck runs out, it exposes the fact that I can barely type :/
 
hmm, good point. I was a bit too hasty
 
@ParitoshSingh I found it on English SE in the comments but there's an even better word, I just can't think of it right now :(
The word that the OP was looking for was "universal" but the comments got imaginative
Ubiquiplicable
 
12:10 PM
:|
 
If you don't think "Ubiquiplicable" is a fantastic word, we can't be friends, I'm afraid
 
How do I break this to you...
 
I can't even pronounce that :P
 
@ParitoshSingh it's meant to be a portmanteau of ubiquitous and applicable, but...
 
12:18 PM
Words like those make me feel im getting too old for the new generation of folks these days, and im supposed to be one of them dangit
 
Don't worry about buzzwordsmiths
 
It's a bit of fun. You aren't gonna encounter youths on a street corner saying "Ubiquiplicable" :) ... yet
 
Those yutes can only communicate via emoji
 
12:50 PM
@roganjosh I remembered another chronic woe considering dells: chargers are quite volatile
I have to buy a new one every few years
 
Volatile chargers are definitely not what you want
 
I've had only one that said BANG before it stopped working...they usually just fray here or there
but to be fair I'm very rough on my chargers, I just roll them up a bit and throw them into my backpack
I bet they'd be in much better shape if I had a separate laptop shoulder bag
I guess volatile is not the best word, I just couldn't think of a better one right now :P
("short-lived" doesn't sound fancy enough (and "ephemeral" might be a stretch :P))
 
Sorry, was cooking. I like "ephemeral" bags, the recycling problem would vanish. You just physics it into a new dimension
 
1:44 PM
this question is barely an hour old. please give people on SO a chance to respond.
on a sidenote, I doubt this channel is the proper place to find help for such a question -- the question appears to be 100% about pymol and 0% about python.
 
2:31 PM
I have two sequences, A and B, I can perform two operations on A: (i) can convert 0 or more lower case letters to uppercase and (ii) remove any number of lowercase letters.
If I can get the string B by editing A using the above-mentioned rules I will need to return True otherwise False.
I've written an algorithm which became very complicated. Can anyone give me a better idea?
 
I think this should be doable in O(n). Compare the first characters of both strings, if they match move on to the next, if they don't match either capitalize it or remove it
 
But, later we can have the same letter
 
I don't see the problem
 
eg; for A = xoxWE and B = XWE we will have true
I can skip the first two lower case letter
then start at 3rd letter
 
Or you can capitalize the first x and remove the 2nd and 3rd letters. What does it matter?
ah, there is a problem if you capitalize a letter and then later find the same letter already capitalized. Like aA and A. If you capitalize the a, you later can't remove the A (because you can only remove lower case characters). So that's something you need to watch out for
 
2:43 PM
Ok, then for A = xsEGgGb and B = SEGGB
@Aran-Fey Yes
 
3:18 PM
I hear Christmas music. It's that time of year to forget November.
 
3:50 PM
@AndrasDeak I wonder if he's doing it as part of training...
 
Heavy-duty psychological pressure as practice? Might be ;)
 
Since water-boarding is illegal - I suppose one has to go for the next closest? :p
 
"You can't do anything to me, I spend four hours every day looking at the front page. Even in September."
 
"how do you answer questions? I tried and it's hard." "Nothing magic about it, I don't instantly get upvotes just because I'm RH, but everyone probably will over time, you just need more answers out there because some will be duds, so here I'll show you."
 
I bet he does get a lot of upvotes if someone recognizes his name :)
 
4:02 PM
Yeah, if the Python room is following him... oops...
 
You never know - having a recognised name can be a two-edged sword... sometimes you'll get upvotes because of the halo-effect and other times if you don't do that terrific an answer then because of expectations that you really should do better - you might not get upvotes...
 
I would expect blind fandom to be a much more prevalent effect on Stack Overflow. The people who'd "expect more from you" are the kind who tend to vote on content anyway.
(^[citation needed])
 
4:21 PM
link german question originally, was translated.
oof, clearly i haven't used these things in a while :/
ty!
 
that's a dupe
 
looks like no MCVE
 
yeah, the question now has other issues, the person in the original version had a comma. 2,54 instead of 2.54
 
 
2 hours later…
6:36 PM
@MisterMiyagi This looks like a pyparsing issue, yes?
 
6:53 PM
recbg
 
cbg
 
7:11 PM
Hello, please cut back on the caps lock.
 
okay, got it
 
And the excessive exclamation marks, please. Thanks.
:)
 
7:47 PM
Anyone know how to construct (in a vectorized manner) the numpy array a such that a[i,j,k] = b[i,j,c[i,j],k] for two arrays b and c?
i.e. c selects an index for dimension 2 of b
 
@user76284 I probably can, but it helps if you can give me reasonable inputs
(something small and generated, where all dimensions have different size)
 
Heh, the old "I ask you to give me a small example and hopefully in doing so you'll work out the answer for yoursefl" ploy...
 
Well, it should work with anything of the right shape. For example:
b = np.random.randn(10, 11, 12, 13)
c = np.random.randint(b.shape[2], size=b.shape[:2])
I know how to do it if the first dimension didn't exist, by using b[np.arange(b.shape[0]), c].
 
yeah, we need to spice that up
 
I think a meshgrid might be needed.
I hope that, in the future, we'll be able to use index notation directly instead of having to figure out how to mash arrays together.
One can hope.
 
7:54 PM
>>> a = np.zeros((b.shape[0], b.shape[1], b.shape[3]))
... i,j,k = np.mgrid[:b.shape[0], :b.shape[1], :b.shape[3]]
... for ii,jj,kk in zip(i.ravel(), j.ravel(), k.ravel()):
...     a[ii, jj, kk] = b[ii, jj, c[ii, jj], kk]
... a2 = b[i, j, c[i,j], k]
... np.array_equal(a, a2)
True
you need the second and the fifth line, the rest is just checking that it's correct
 
Oh nice.
 
fancy indexing can be a huge pain beyond the most straightforward cases, and it needs a lot of getting used to :)
 
I'm going to use mgrid instead of meshgrid from now on.
 
for instance I tried with np.ogrid first to spare memory, and it "worked", even the shape looked OK, but the result was wrong
 
Actually, is mgrid faster or slower than meshgrid?
I hate how they chose the wrong indexing order by default for meshgrid (you have to use indexing='ij').
 
7:56 PM
it's just syntactical sugar, might even be a bit slower because it has to decide about the inputs
I prefer it because
1. it can generate both arange-like and linspace-like inputs, and
2. it returns a single array which can be reshaped for looping
>>> for i,j in np.mgrid[:3, :4].reshape(2, -1).T:
...     print(i, j)
0 0
0 1
0 2
0 3
1 0
1 1
1 2
1 3
2 0
2 1
2 2
2 3
this won't work with meshgrid because that returns a tuple of arrays
again this is just for convenience, but I'm lazy :)
 
I believe there's a project in the works called the tensor algebra compiler to do this kind of stuff automatically in the most efficient way.
 
aaah nevermind, np.ogrid works just fine, I messed up the comparison :D
i,j,k = np.ogrid[:b.shape[0], :b.shape[1], :b.shape[3]]
like that
 
ogrid is faster than mgrid?
 
no, it uses broadcasting and takes up much less memory
>>> i,j = np.mgrid[:2, :3]
... print(i.shape, j.shape)
... i,j = np.ogrid[:2,:3]
... print(i.shape, j.shape)
(2, 3) (2, 3)
(2, 1) (1, 3)
If you're going to use operations that broadcast anyway (such as broadcasting or arithmetic operations) you can usually use ogrid, which constructs a sparse mesh. You still have to keep the broadcast result in memory, but at least you don't have n more arrays of the same size for the grid in n dimensions.
 
Perfect
 
8:05 PM
@AndrasDeak "such as broadcasting indexing ..."
 
cabbage
I've been considering flask as an alternative to django (DRF)
In particular with SQLAlchemy (postgres) alongside Marshmallow serializers
I've noticed that like DRF serializers Marshmallow also has support for nested serializers
But my question is two fold
1. Is there a "viewset" equivalent in flask such that I don't have to write all my CRUD routes
2. Is there a nested serializer update (like drf-writable-nested) or do I have to create my own create and update functionality as per usual
 
@AndrasDeak Just realized the last k isn't necessary, it'll broadcast automatically. You just need a meshgrid for the first 2 dimensions of b.
 
8:32 PM
@user76284 good point
I like to be explicit with trailing indices but in this case it's actual gain to ignore that
 
home, sweet home. After sitting on a wooden chair that's too small for the past 3 days, my exercise ball makes me feel like I'm floating on a cloud
 
I'm sure your ball is also happier now
 
I fed it some air and it got fat. I'm sure it liked that
unlike its name suggests, it doesn't exercise much
 
Is there something faster than np.linalg.solve for large batches?
Each linear system is not very large, it's just that I have many of them.
 
@user76284 use a single call to solve as a batch-of-matrices
I wouldn't think that's easy to beat
 
8:45 PM
Yep, I'm doing that.
I'm just wondering whether there's some faster solver out there.
 
then again I don't have much practical experience, just a hunch knowing numpy
 
I believe numpy uses LAPACK?
 
yup
 
If it's installed and compiled with it
 
Do you know how I can check that?
I got numpy through pip3.
 
8:47 PM
When Spyder stops crashing, I think I do :P
something like numpy.show_settings()
 
For solving linear programs, when I switched from scipy.optimize.linprog to cvxopt.solvers.lp I got a huge speed improvement. I got another huge improvement when I used the latter with GLPK rather than the default setting.
I believe there are even faster solvers out there like CPLEX.
 
np.show_config()
 
Hmm I see several NOT AVAILABLE lines.
 
That will show BLAS/LAPACK/MKL linkages
 
I have NOT AVAILABLE for blas_mkl_info, blis_info, lapack_mkl_info.
 
8:51 PM
Any ATLAS or OPENBLAS?
 
What OS?
 
openblas yes, atlas no.
 
@user76284 question is what you do have
 
macOS Mojave.
Should I dump my config here?
 
Side note: have you profiled your code to be sure that the linalg.solve call is your bottleneck?
 
8:52 PM
Oh, then I'm out of suggestions sorry
 
>>> np.show_config()
blas_mkl_info:
  NOT AVAILABLE
blis_info:
  NOT AVAILABLE
openblas_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
lapack_mkl_info:
  NOT AVAILABLE
openblas_lapack_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
 
that's a lot of 'openblas'
 
@AndrasDeak I'll run some tests.
 
I've started using snakeviz for profiling, it's delightful
 
9:43 PM
@PaulMcG after further thought, it looks like a MisterMiyagi issue. I figured out where the problem was coming from. Now I just need to figure out how to best solve it.
 
Apr 4 at 18:24, by Andras Deak
User error -- hit any user to continue.
 
10:23 PM
IntelliJ wouldn't accept my self-made python.exe as a valid python interpreter, so I solved my windows/linux PYTHONPATH problem by setting it to :/c/some/path:;C:\some\path; ¯\_(ツ)_/¯
 
11:21 PM
does anyone know the python thing to get, from a list 'list' to
[(0,list[0]),(1,list[1]),...]
or do I just zip(range(len(list)),list) or something?
 
looks like you want enumerate
 
but on python 3 that returns an iterator which you have to consume with list() if you really need a list
 
@PaulMcG To give some context: I am trying to parse an expression of the form UNION = TYPE + Keyword("or") + TYPE where TYPE: Forward. However, the result is also a TYPE; this is of course non-terminating, because it can always try to parse the first TYPE as UNION infinitely deep before seeing the "or".
 
11:41 PM
@MisterMiyagi thanks
 
So what I am looking for right now is how to comfortably avoid recursion in the ambiguous position. Something akin to UNION = TYPE.exclude(UNION) + Keyword("or") + TYPE. My workaround currently is a manually defined TYPE_exclude_UNION from all TYPE elements excluding UNION; this isn't particularly ergonomic as it duplicates a lot of code and must be kept in sync.
 
you just need async
 
I have async :D
 
11:58 PM
oh wait, I got the joke now...
9.5 hour jet lag sure is a pain :/
 
ouch
daylight saving is getting brutal
ah, you're in the EU
 

« first day (3305 days earlier)      last day (1658 days later) »