« first day (3502 days earlier)      last day (1443 days later) » 
00:00 - 17:0017:00 - 00:00

5:00 PM
Every couple of weeks we get someone in here lamenting that you can't do my_instance.__repr__ = whatever and make it behave differently than type(my_instance).__repr__.
 
@Kevin It's certainly unlikely for a dundermethod to even exist on an instance, but we mustn't forget that classes are instances too. So if some_obj is a class, then there's actually a fair chance that something will go wrong
 
I guess this is basically related to that, except the lamentor wants an implicit lookup, and you want an explicit one
 
Yeah, their curse is my blessing. If it worked like that, I'd definitely have to rewrite my code forget I said that
 
too late
 
dang
 
5:04 PM
it's forever etched into my oh look a butterfly
 
Perhaps you could do something with __dict__, although it might have enough corner cases that it doesn't qualify as an "easy way"
It would probably be more than one line long, if you want to handle metaclasses and __slots__ and, I don't know, diamond inheritance
 
That's the next problem: I'm not convinced that I could implement it correctly even if I tried, considering descriptors and __getattribute__ and whatnot
Even vars(some_obj) can fail if some psycho shadowed the __dict__ slot and/or did something crazy with __getattribute__
 
True.
Classes were a mistake. Python4 will only have structs.
7
 
sounds good to me
 
5:20 PM
I have landed into one more problem relating to bringing up consoles in .pyw files
 self.UI = d['Interface']                           #information of UI
        #self.UI = 'GUI1' #temporary replacement with above statement
        self.datalocation = d['datalocation']              #information of the location where the UserData folder of the user resides
        #self.InterfaceNum = d['InterfaceNum']

        if self.UI == 'CUI':
            import CUI as userUI           #user's selected User Interface

            #showing the console window
            ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 4)
I want to bring up console window if self.UI == 'CUI' and have written
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 4)
but, it is neither working nor showing errors.
This is only a piece of the complete code.
Here, is the complete code if someone wants
 
@Abhijeet.py please don't post so much code here. Post it to some code paste service and only link here.
@Abhijeet.py As you may have noticed you have various problems, and you often find it difficult to use the help you are given. We should at least not have to scroll through pages of your code as you're trying to get someone to help you with your next obstacle.
 
5:36 PM
Ok!
 
Not sure how helpful this is, but I once wrote a tkinter application that looks and behaves like a console window... More or less. stackoverflow.com/a/19796085/953482
 
Hi guys,
I am still struggling to understand why this is happening
I'm calculating the eigenvectors of a sparse matrix with scipy sparse linalg
My matrix turns out to be symmetric and real so I can use eigsh
 
It's basically just a textbox with a black background, but sometimes that's all you need
 
I'm only interested in the smallest eigenvalue, so I can just set rank 1, I appear to be getting a transpose of the result that np.eigh would give me, but fair enough
The problem however is the following: my eigenvector looks nothing (!!!) like the one obtained from the dense matrix + np.eigh (which is the exact computation)
I have tried a variety of methods, cayley, buckling and so on, changing around the iterations and tolerances
 
@Kevin No, I need to bring up the console, Sir!
 
5:43 PM
It does not seem to matter
What can I do at this point? This seems too simple to be a problem but alas
 
It's relatively easy to rig it to respond to print calls rather than having to invoke fake_console.show, as well
 
@Euryris 1. do you have an example? 2. any chance that the subspace is degenerate? In that case you can get multiple, linearly independent eigenvectors for the same eigenvalue. Try asking for more eigenvalues: are they the same?
 
@AndrasDeak The eigenvalues are not degenerate
Give me 5-10 minutes to prepare an example that should illustrate the problem
 
@Euryris 3. How ill-conditioned is your matrix? 4. what do you get when you feed back M * v?
Sure, take your time
 
@AndrasDeak The matrix is a representation of the Hubbard model, so it should be the computational scientist's dream
 
5:45 PM
neat!
Of course nightmares are dreams too...
 
I can confirm that from experience, one sec
 
but then I won't ask if the matrix really is hermitian, unless the implementation is borked
 
@Kevin But, I want interactive console because its a Character user Interface and needs both - input and output.
 
HELLOE!
(im new)
 
@personthehuman hello, please refrain from shouting. Welcome.
 
5:48 PM
I suspect designing a tkinter console that allows both output and input is possible, albeit considerably more complicated
 
@Kevin Ok! but is there any way to bring up that pretty old console if at some point, I need it to?
 
what is a tkinter console? does it have to do with AIs investing for you?
 
If I knew how to bring up real consoles in the middle of a program, I wouldn't be recommending you create your own :-)
 
@personthehuman why would you think that?
 
it's alright to just lurk here, see what people are talking about, reading back the discussion to see the context of that they are talking about
 
5:51 PM
@Kevin Ok! I got your point. :)
 
i am working on something similar to it and investable companies have somethings called tkinter codes/ids.
 
tkinter is a GUI library. If the thing you're working on has a GUI, then perhaps the tkinter codes you're seeing are part of the GUI logic and not the AI investing logic.
 
actually i think i was thinking about kinter codes without the "t"
 
5:52 PM
I find it unlikely that they have tkinter ids. Maybe a "ticker" id
 
sorry
oh yea
either way it has nothing to do with python so i dunno why i'm here. bye!
 
take care
 
I've received a message from The Bureaucracy: "your malformed submission will be corrected and processed... If you complete the Fifteen Great Trials." Still easier than filling out the form again. I'm in.
 
somehow "corrected" in this context brings up vivid imagery of lobotomies and electroshock therapy
 
Famous last words. First-borns take 9 months to regenerate
I think there's something to be said that we've jumped to extremes on both the corrections and sacrifices to be made :P
 
5:58 PM
@AndrasDeak Ok, here is "something"
And I must confess that I am using transpose because I'm merely guessing that scipy somehow transposes the eigenvectors
import numpy as np
import scipy.sparse as sp
import scipy.sparse.linalg as spl

denseM = [[ 0.5,  0.,   0.,   0.,   0.,   0.,   0.,   0.],
 [ 0.,   0.,   0.5,  0.,   0.,   0.,   0.,   0.],
 [ 0.,   0.5, -0.5,  0.,   0.5,  0.,   0.,   0.],
 [ 0.,   0.,   0.,   0.,   0.,   0.5,  0.,   0.],
 [ 0.,   0.,   0.5,  0.,   0.,   0.,   0.,   0.],
 [ 0.,   0.,   0.,   0.5,  0.,  -0.5,  0.5,  0.],
 [ 0.,   0.,   0.,   0.,   0.,   0.5,  0.,   0.],
 [ 0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.5]]

sparseM = sp.csr_matrix(denseM)
 
Whenever I work on projects that involve geometry, I invariably get results whose coordinates are mirrored or rotated, etc. And it's a pain in the butt to identify why this has happened, so I'll just quietly mirror/rotate it back at the end.
I've noticed that the programs where I take the time to understand why things are going haywire, tend to succeed more than the programs where I apply a quick fix without thinking too much about it
Basically this is a long way of saying that investigating why scipy is transposing your eigenvectors, may pay dividends in the long run.
 
Well to this moment I am still guessing that this is what is happening, because as it is appears now Lanczos does not converge for a well-behaved matrix that satisfies the hermitian property
 
Even if the solution turns out to be "yes, scipy's documentation confirms that it transposes the results in a surprising way, and transposing it back the way I've been doing is exactly the right approach", you've still learned something valuable
 
Or *something
 
6:04 PM
there's no good reason for a transpose I think
 
im not quite sure what's going on (please don't kick me), but i think i saw the word geometry somewhere here and if the program doesn't have to be python you should probably see the language "processing 3". it's really good with geometry.
 
I've heard good things about processing. I need to play with it eventually.
 
it's great! ill show you an example of a project i did in a language super similar to processing, only i can program it online. i'm getting the link now...
 
java and java-likes are not my first choice for hobby projects. Maybe when I get a computer that doesn't gobble up all my RAM when I open Eclipse...
 
@Kevin Here is the link to my complete code - dpaste.com/3YAB7X0
 
6:09 PM
@Kevin I'm sure you've mentioned it before, but what IDE do you use for python?
 
Notepad++ :P
 
Notepad++ and a cmd prompt :>
 
>>> sparseM @ sparse_vals[1] - (sparse_vals[0] * sparse_vals[1])
array([[ 0.00000000e+00],
       [ 5.55111512e-17],
       [-1.66533454e-16],
       [ 0.00000000e+00],
       [ 3.05311332e-16],
       [ 3.33066907e-16],
       [-2.77555756e-16],
       [-2.49800181e-16]])

>>> denseM @ dense_vals[1][:, 0] - (dense_vals[0][0] * dense_vals[1][:, 0])
array([ 0.00000000e+00, -5.55111512e-17,  1.11022302e-16,  0.00000000e+00,
        2.22044605e-16,  0.00000000e+00,  0.00000000e+00,  0.00000000e+00])
 
@Aran-Fey VSCode and IDLE
 
6:10 PM
try changing the variables a bit. you could be on it for hours!
 
>>> dense_vals[0]
array([-1.00000000e+00, -1.00000000e+00, -5.43456339e-17, -5.43456339e-17,
        5.00000000e-01,  5.00000000e-01,  5.00000000e-01,  5.00000000e-01])
@Euryris that ^ is a degenerate ground state, or your example is not representative
 
I don't recommend my setup for sane programmers. It is only satisfactory for my particular strain of brainworms.
 
Not entirely sure why Notepad++ is a viable IDE for python but not for Java, but to each their own I suppose
 
i'm pretty sure notpad++ has java.
sorry if i interupted
 
Sure, you can build jars and exes and such from cmd. But I wouldn't know how to handle, like, external dependencies and stuff.
The last Java project I contributed to for fun had a relatively complex build process, and the only step-by-step walkthrough was for Eclipse specifically.
 
6:14 PM
ah, right, learning your way around the ecosystem takes some effort
 
Do you use Notepad++ for your C-based (C# and C++) projects @kevin?
 
Or, even, Kevinscript :)
 
Shockingly, out of the 2 popular dependency managers for Java, I prefer the one that uses XML for its config file
 
I use Visual Studio for my C# work, Notepad++ for the very small amount of C++ I've done this decade, and Notepad++ for KevinScript
 
6:16 PM
@Aran-Fey maven?
 
I was about to ask if maven was a package manager. Or gradle?
 
@AnttiHaapala yeah
 
ah no, the latter is a build system or whatever
 
maven is "ok".
I like kotlin <3
 
and gradle?
 
6:17 PM
and gradle I stay away from
 
@AndrasDeak You are right, it is degenerate and the example is not rep
 
@AndrasDeak maven and gradle are the two I was talking about. "dependency manager" may not be an accurate description, I don't know
 
@Aran-Fey Yay! :D
@Euryris OK. In any case I don't see a transpose in your example.
(nor in the docs)
 
but all java bashers should try Kotlin. it is an amazing language.
almost even more fun than Python.
and fast.
 
@AndrasDeak I converted the scipy'd transpose with another np.transpose, see the print of the sparse eigenvector
 
6:19 PM
@Aran-Fey and works with maven.
 
I also couldn't find any documentation for it
 
@AnttiHaapala Do Kotlin have more libraries than python?
 
the best language i have found for android is Unity game enjine, even if you'r not making games!
 
Wait, gradle doesn't work with kotlin?
 
@Euryris sorry, I don't understand that
 
6:19 PM
@Abhijeet.py kotlin can use any java libraries.
 
I can only stop bashing Java if I find another language to start bashing. PHP already has a slot. Two there should be. No more, no less.
 
it just make thm more fun.
@Kevin python 2.
 
try processing!
 
at least java can do unicode.
 
@AnttiHaapala I don't speak ill of the dead ;-)
 
This is the 4 site case
 
@Euryris a smaller example could do, or a pastebin..
 
Python can do unicode!!:D
 
it'll have to be a pastebin
 
@AndrasDeak I'm referring to this line: print(np.transpose(sparse_vals[1])), which contains np.transpose to counteract the one from the output
Without it, the shape is precisely opposite, so (1,dim)
 
6:22 PM
@Euryris ah, I see
 
@AnttiHaapala Pastebin is not working for me, so I can't post on there : Bad gateway
 
@Euryris dpaste/github gist/...
but anyway I've got your matrix
 
@JonClements Sure
 
Cheers, can you see this? dpaste.com/23QHGTD
 
@Kevin submission to what?
@Euryris Yes I can see that
 
6:24 PM
If I set which = 'SA' in spl.eigsh, I'm getting a non-degenerate ground state
 
@Euryris no. sparse_vals[1].shape is (dim, 1), as it should be. When you're transposing for printing you're converting it to (1, dim) which prints similarly to dense_vals[1][:, 0] which is a 1d array
@Euryris agreed
>>> dense_vals[1][:, 0] - sparse_vals[1].ravel()
array([-5.55368089e-17, -1.22314784e-16, -5.88123978e-17, -1.66533454e-16,
       -1.28768830e-17,  2.22044605e-16, -1.66533454e-16, -5.86368014e-17,
        9.90742213e-17, -3.33066907e-16, -2.22044605e-16,  1.62363893e-16,
        2.22044605e-16,  1.28713779e-16, -6.81949494e-17, -1.25981113e-16])
your ground state eigenvectors are the same
it's just that one carries a singleton dimension, probably due to how scipy.sparse uses the deprecated matrix class under the hood (and matrices are always 2d)
 
Interesting, now it gets spooky because here they are not!
 
@smci I'm requisitioning a resource from a monolithic conglomeration, the specifics of which are of no particular interest to anybody but me. Mostly it's a useful framing device for complaining in a way I find humorous.
 
@Euryris Do both have float64 dtype for you? Along with your matrix?
 
@Kevin SO, tkinter, AWS, your employer, ...? PS you haven't posted any numerical puzzles in ages...
 
6:27 PM
@smci are you referring to me?!
 
@Abhijeet.py What? Not unless you claim to be Kevin's employer. Or AWS. Or a numerical puzzle :S
 
Puzzle rec: I've been perusing through the puzzle collections at krazydad.com recently. They remind me of Simon Tatham's puzzle collection, in the sense that they each ostensibly have one unique solution, which is derivable with pure logic. At least, the easy and medium ones are...
 
@smci Ok! That "tkinter" got me to tkink that. I have been posting that for a while.
Sorry
 
I can get about three moves into a Hard level Two Not Touch puzzle before I run out of obvious avenues of attack
 
@Kevin wow, jigsaw sudoku seems evil
 
6:30 PM
@Kevin If you get any good Pythonic ones, post one here...
 
Yep, everything is float64
 
@Euryris then I have no idea without a hands-on example. Do you get a difference for that actual matrix you just posted? Using that as literal input?
 
Most of my homebrew math puzzles come from my surroundings. If I discover that Animal Crossing is NP hard, I'll pass it along
 
check that np.array_equal(np.array(denseM), np.array(denseM).T), etc...
 
@AndrasDeak I have been using this as literal input already
 
6:32 PM
Until then, I'm just waiting for the other apple to drop
 
@Abhijeet.py Next to the @ you will see there is an arrow on the left hand side. Clicking that arrow will take you to the message they were replying to - it's a directed response to a particular message. You can see it with this very message as I'm directing it to you
 
be right back, cheese emergency
 
And the bool is true
 
Actually do you or Andras or PM2Ring or anyone know about matrix formulations of directed graphs, e.g. All-Pairs-Shortest-Path? I'm trying to calculate mininimum-hops (rather than path diversity), i.e. min k s.t. (A^k) [i,j] > 0 for some (directed) adjacency matrix A, which strangely doesn't seem to have much study. But to do that simultaneously for all i,j. And in a weighted graph. I only strictly need to go up to k=3, and I have a hacky solution for that...
 
I am aware of the concept of graphs-as-matrices, but don't know enough to make any interesting observations
 
6:35 PM
...but I wondered what a generalized formulation would look like.
@Kevin It's just some generalized big matrix-multiplication-based problem, you can see room for optimization if you start to look at it. I'll brush up my MCVE
And if we don't care about counting path diversity (how many paths of length k exist from node i -> j), but only about binary reachability ("Is node j reachable from node i in some path of length exactly k?" 0 or 1), then we don't need matrix multiplication, only a lazily-evaluated binary vector dot-product producing 0 or 1. (helps reduce big-O complexity for large matrices and large orders k)
 
@smci nope
 
I wonder if it would be helpful to investigate efficient methods of calculating A^k that use fewer than k multiplication operations
... But since you're trying to find K for multiple i's and j's, it's probably harder than just shoehorning these into your program
 
@Kevin Yes I've been looking at it. We keep A^(k-1) from the previous iteration, so each iteration only involves multiplying A^(k-1) * A. (This is actually more optimal in this case than exponentiation-by-squaring). But the catch is the easiest way to determine minimum reachability runs from largest possible k down to 1. The hard part is actually assigning into the sparse result matrix. I suppose I could do a masked assign and run k increasing.
 
I'm curious about the application you're building, @smci
 
Insert obligatory suggestion of binary search here
 
6:48 PM
@roganjosh That one is not a really an application, it's some numerical analysis of a boardgame with N=7 nodes, in a directed weighted graph where each node 'i' connects unidirectionally to its three neighbors (i+1)%, (i+2)%7, (i+4)%7. Route planning, if you like. But the more I looked into it, I found that it's not well described in literature or tutorials. Probably because it's 'easy' compared to APSP and so on.
@Kevin No, binary search is not relevant to this one.
 
I suspected as much, but obligatory is obligatory
 
@Euryris what things go wrong when you run gist.github.com/adeak/a2a3db398f7e614ea2cf53d9311e25ec ? I get zero prints.
 
I get "not the same eigenvectors"
 
And what are your numpy, scipy versions if you get prints? Mine are 1.18.4 and 1.4.1, respectively
@Euryris nice. What eigenvectors do you get, and how large is the difference?
 
@Kevin Well, binary search doesn't work ideally because if you omit the (null) transition i->i for each i (i.e. the diagonal A[i,i] = 1), then it's possible for A^k [i,j] and A^(2k) [i,j] to both be zero ('unreachable' in exactly k hops or 2k hops), and yet nonzero for some other order k in between. I suppose we have to include the (null) transition i->i then.
 
6:54 PM
And any chance that you have some custom arpack that's acting up?
 
For example, I get:
[-1.66533454e-16 -3.46727855e-16  2.22044605e-16  2.98858491e-01
 -3.60822483e-16 -1.11535507e+00  8.16496581e-01 -3.74700271e-16
  5.55111512e-17  8.16496581e-01 -1.11535507e+00  4.85559348e-16
  2.98858491e-01 -4.60918929e-16  1.57165176e-16 -1.66533454e-16]
Some of the differences are of order 1 as you can see
 
yeah, that's not good
Do you have nontrivial linalg/arpack libraries? np.show_config() and scipy.show_config() come to mind.
 
Oh, ok. I thought the value of each cell was monotonically increasing w.r.t. k.
 
Scipy 1.4.1, I have a completely neutral Anaconda installation with virtually nothing exotic installed
 
Windows or linux?
 
6:56 PM
Numpy 1.18.1
Windows 10 64
But on the numpy end there are no issues at all
 
Such is the quality of my thinking if I don't write down manic symbols on cocktail napkins as a cognitive aid
 
OK. Could any windows users with the scipy stack try running my gist above, please?
 
It's a shame that also both my macos and linux laptops both broke down and are now off-site to be fixed
 
@AndrasDeak Let's see... SyntaxError on line 6
 
@Kevin eh?
 
6:57 PM
Feels like being in a hollywood movie
It's missing a comma somewhere
 
oh crap, thanks
should've told me
how did that even work for me?
 
Sorry, it was such a trivial fix that I didn't bother to mention it
Probably because you had an old version of denseM loaded in the kernel
Comma included
 
If I add a comma, i get... ModuleNotFoundError: No module named 'scipy'. Oops, I must have put that on my other computer.
Ok, one pip install later, I get... no output.
 
The comma is somehow there in my ipython. Oh well.
@Kevin perfect, thank you. @Euryris bug report time :)
Feel free to quote my example code, and mention that there's at least one linux and at least one windows box where it works.
there might be a simple explanation but "running the exact same code on three machines produces two distinct results" should not normally happen
 
Wonderful
 
7:01 PM
I hope you've restarted whatever IDE and kernel you might have
 
Yup, fresh kernel and I'm getting again:
[-1.66533454e-16  5.55111512e-17 -1.11022302e-16  2.98858491e-01
  5.59448321e-17 -1.11535507e+00  8.16496581e-01 -5.55111512e-17
 -5.55111512e-17  8.16496581e-01 -1.11535507e+00  4.14701379e-17
  2.98858491e-01 -1.68297190e-17  6.00206609e-17  8.32667268e-17]
Interestingly it's exactly the same output
 
OK, the wrong is consistent
 
What the heck..
 
@Euryris it would be pretty crazy if it weren't :)
 
I'm throwing a dart at the Wheel of Blame, and... ~thunk~ floating point numbers is the culprit
 
7:02 PM
even if the methods start from a random state
 
Well, would it be? The scipy algorithm uses a random starting vector, so it's random with the same seed
 
@Kevin I didn't post it but the condition number is 13. Which is ...not bad at all
@Euryris not sure about the seed...but in convergence I guess it shouldn't matter
 
After running a few times, I'm getting a correct result for the firs ttime:
[ 2.77555756e-17 -1.52655666e-16  2.77555756e-17  3.60822483e-16
 -4.16333634e-17  0.00000000e+00 -5.55111512e-17 -1.11022302e-16
  1.11022302e-16  3.33066907e-16  1.11022302e-16  3.19025894e-16
 -2.77555756e-16 -2.94385475e-16  3.22650852e-17  4.16333634e-17]
All within machine precision
 
ugh
I get 0 prints in 100 reruns (each from a fresh interpreter with a bash loop)
 
Hmm now my kernel crashed altogether
 
7:06 PM
I'll go out on a limb and say that's not normal either :)
Is this ipython? Jupyter notebook?
 
Anaconda Spyder
 
ohhhhhh
sorry for misspelling your name in the gist originally, I can't read
*picks up Kevin's blame dart and pins it on Spyder*
 
Bleugh, I've just opened the tab to see a Spyder issue
 
maybe not
 
I'll be right back now though, I got to get away from this screen for a moment after non-stop frustration with what seems to be a bug now
 
7:10 PM
Sure thing. At least you're not going crazy.
 
@Euryris Spyder sometimes has crashbugs, run it in plain console, or ipython.
 
@smci half baked idea: At the beginning of the algorithm, set A[x,x] = 1 for all integer x's in range. Then each cell value will increase monotonically as k increases*, and you can perform binary search to find the lowest k where each A[i,j] first goes from zero to nonzero.
(*tremendous conjecture that I only tested with a single example)
 
@Kevin Honestly, I'm telling you you don't want binary-search, because we're simultaneously computing minimum hops k for all [i,j] and storing those results into an NxN result matrix at each step, not just for a single [i,j] or row i or column j.
 
Hmm, I'll need to go off and play with some toy examples if I want to convince myself either way
 
@Kevin But yes, A^k [i,j] increases monotonically iff we include the null transition A[i,i] = 1 (and of course all edge weights are nonnegative). If we don't, we get the non-monotonicity I mentioned.
@Kevin Take the 7x7 matrix adjacency A where each node 'i' connects unidirectionally to its three neighbors (i+1)%7, (i+2)%7, (i+4)%7. For now let's take those edge weights as 1 (but the version I'm working on is more complicated). (And as mentioned, we probably also have to include the (null) transition i->i with weight 1(?) even though that's zero hops.)
 
7:26 PM
Ok, with you so far
 
>>> A = np.stack(np.roll([1,1,1,0,1,0,0], i) for i in range(7))
>>> A
array([[1, 1, 1, 0, 1, 0, 0],
       [0, 1, 1, 1, 0, 1, 0],
       [0, 0, 1, 1, 1, 0, 1],
       [1, 0, 0, 1, 1, 1, 0],
       [0, 1, 0, 0, 1, 1, 1],
       [1, 0, 1, 0, 0, 1, 1],
       [1, 1, 0, 1, 0, 0, 1]])
 
seems like a Toeplitz matrix
(just FYI)
 
# ... compute Distance matrix, given we know the upper-bound is 3
D = np.full((7,7), np.nan)
D[A@A@A > 0] = 3
D[A@A   > 0] = 2
D[A     > 0] = 1
np.fill_diagonal(D, 0) # hack to fix that node i->i is zero hops
D = D.astype(int) # HACK to cast down to int

print('\nDistance matrix:')
print(np.array2string(D, separator=''))
Distance matrix:
[[0112122]
 [2011212]
 [2201121]
 [1220112]
 [2122011]
 [1212201]
 [1121220]]
@AndrasDeak Oh ok. How can I apply that knowledge to the calculation?
 
@smci just an alternative way to set up your matrix. Doesn't help solving the problem.
 
Ok, thanks for the example input/output. I'll try to prototype my concept and see if I get a sensible result.
 
7:37 PM
@smci Another pedantic side note: you should initialize the matrix to -1 rather than np.nan to have an int array
again won't help, but it's semantically nicer
 
This exercise ought to knock the dust off my numpy knowledge (such as it is)
 
@AndrasDeak Good point. Or maybe MAXINT, or 999. So that taking max() on intermediate results is a pessimistic heuristic.
 
yeah
 
I have a creeping feeling that whatever I come up with will work only for graphs with edge weight 1
 
@Kevin Yes, All-Pairs-Shortest-Path only seems to be generally quoted for edge weights = 1. This MCVE is unweighted. The more interesting question to me is "What is the total cost (in $, or actions) + time to reach node j from node i?" (As mentioned the boardgame has formulation has ...
 
7:41 PM
The MCVE is not weighted; is it?
Weights would imply a non-binary adjacency matrix, correct?
OK, edit-answered
 
(As mentioned the boardgame has a more complicated formulation with actions, money and turns. So really 'reachability' has three components. Like I said, let me brush up my MCVE on that before posting.)
 
@smci without having to perform the k subsequent matrix products, right? Just trying to see if I understand the frame of your problem correctly.
 
Off I go to the prototypatorium
 
@AndrasDeak ? I don't follow. But in this specific N=7 case, it's trivial to compute the matrix exponentiations A@A, A@A@A... up to order at most 7. Obviously in the general case that would not be scaleable. (By the way, with numpy, the notation pow(A, k)does not do @ multiplication, only element-wise multiplication, which is not what we want. So how do I generally write A@A@....A with k terms, like with pow(A,k)?)
 
@smci Are you looking for the lowest k (fewest hops), or the lowest cost (shortest path)?
 
7:48 PM
@smci np.linalg.matrix_power
for broad range of k I'm wondering if it might make sense to do a spectral decomposition
it might be slower than just gradually multiplying by A in each iteration
you definitely don't want to recompute A^k from scratch each time
 
@MisterMiyagi As said, I have to think about the formulation, for the version that has three components. For feeding into route planning, could we produce the generalized result of all triples (Hops, Actions, Money)? possibly pruned by constraints on each of those three.
@AndrasDeak Yes obviously. I noted above we could do it iteratively in increasing order k by storing A^(k-1) from previous step, then computing A @ A^(k-1) = A^k. Since we need to inspect if A^k [i,j] > 0 or not at each iteration, at least for the subset of [i,j] which we haven't yet reached.
 
I think Hops/Connectedness are generally much easier to compute, since you can clearly define an early exit condition. Money/Cost should strictly require comparing all A^k (k=0...n) variants, since you can have long but cheap paths.
 
@smci OK
 
@MisterMiyagi Uhuh. (The actual boardgame has several rules quirks which I'm trying to model, including some non-determinism. Let me brush up the MCVE, it'll take some days)
@AndrasDeak Thanks but I meant not a function but an actual notation, like "A@A@....A with k terms", that the Python interpreter will accept; there isn't one analogous to pow(A,k) for element-wise multiplication. e.g. A@@k is illegal syntax, but A**k is legal (for element-wise mult).
 
I don't believe there is syntax for it
> According to Upton, the name "Raspberry Pi" was chosen with "Raspberry" as an ode to a tradition of naming early computer companies after fruit, and "Pi" as a reference to the Python programming language.
Why has nobody told me this?
 
8:11 PM
In how far is "Pi" a reference to "Python"? Other than sharing a capital P, of course.
 
named after it, presumably/allegedly
 
Raspberry Py?
I don't think it'd catch on :)
 
8:27 PM
 
What has happened with that Q&A? Even when you get to sensible suggestions they say things like "'Even if your IDE has some space-indentation cleverness it will never be as good as tabs."
 
isn't that opinion based anyways?
 
Yes, and the answers have the wrong opinion. Hence my question.
 
Even this is wrong because it only applies to Linux
 
it's wrong because python doesn't allow a mixture of tabs and spaces
 
8:35 PM
I'm torn with "needs more focus" since the count of ? is off my scale.
@AndrasDeak Yes, yes it does.
Only ambiguous mixtures are disallowed.
 
for a certain meaning of "mixture", but noted
 
Note it to be noted purely to be a pedantic smartass. If any newbie asks, I've never said that, and will deny having said that.
 
derp
 
isn't it late for you as well?
 
at least PEP 8 is here to help: "Python 3 disallows mixing the use of tabs and spaces for indentation."
@MisterMiyagi I was going to say "as late as for you", but probably a lot later today. Got up at 7, have been working almost all day
 
so I guess yeah, late here too :D
rbrb
 
Ok so what to do now? I am missing the deadline for tonight of course, :D
Where do I report this bug and what do I include
 
first try the same code in a vanllla python shell in the same environment
meaning not ipython, not spyder, but the same python modules
 
8:58 PM
stackoverflow.com/q/61878834/4799172 dupe. The old "multiple conditions" trope
 
done
multiply broken code
 
What do you mean with this? Running from terminal?
 
@Euryris if you type, uh, py or python or something in the command prompt you should get a python REPL
so yeah, from a terminal
just make sure it has the same environment as spyder's ipython, if possible
 
python opens the "windows store", and that's where I started throwing up
 
how about py?
 
9:02 PM
That one isn't recognised, but maybe python is not in PATH and that's why this happens
 
Probably. Unfortunately I can't help with windows stuff...
 
I'm only on windows because all my machines are in repair, it's the worst timing of the century
 
it would be prudent to see how much spyder makes the problem worse, but anyway you'd open a bug report as an issue on github
 
Why is python not on PATH? Did you install via Anaconda?
@Euryris it's not that bad, but you do have some hoops to jump
 
I installed via anaconda yea
 
9:05 PM
ok, and you didn't set it as the default python installation, I guess?
 
I did, idk
I ticked the box but can't see the choice reflected in PATH
 
But you can run Spyder from cmd?
 
wim
9:28 PM
@AndrasDeak would delvote if I could
40 answers worth of trash
 
9:57 PM
@wim 2 days
 
wim
10:18 PM
ahh is that how it goes? thought it had to be under a certain negative score
 
No. If it's -3 or less 20k can delvote instantly. You can always delvote after 2 days, but the more positive the score is, the more delvotes it needs. That one will need around 10.
 
10:48 PM
I couldn't find what command spyder runs on
I've sent out word that the deadline would be a no go regardless
 
@Euryris actually, something's really really weird which I hadn't noticed...both vectors are eigenvectors of the respective matrices
 
Is Type[type] the correct annotation for a metaclass?
 
so @Euryris I'll update my gist with one more block:
if not (denseM == sparseM).all():
    print('dense != sparse')
Could you please try that too? I'll tie my brain in a knot if the matrices are equal, the non-degenerate eigenvalues are equal, the eigenvectors are eigenvectors and unequal.
 
wim
11:28 PM
@AndrasDeak how do you know all this stuff?!
 
I just pay attention I guess :)
 
11:40 PM
@AndrasDeak This MCVE is Toeplitz, in fact it's circulant. But the general MCVE likely won't be.
 
@wim and ultimately my brain judges that the arbitrary technicalities of an imaginary place are important. Unlike dumb things, like dates or names...
 
wim
11:59 PM
@AndrasDeak hmm, not the exact scale though
 
00:00 - 17:0017:00 - 00:00

« first day (3502 days earlier)      last day (1443 days later) »