« first day (3887 days earlier)      last day (1053 days later) » 
00:00 - 23:0023:00 - 00:00

12:00 AM
The problem, I fails to install pyvista.
 
Interesting. When I do pip install pyvista on the command line, it installs pyvista without reporting any problems... But then when I do import pyvista, it says ModuleNotFoundError: No module named 'vtk'
So clearly vtk is a problem either way. But it's quite curious that our errors don't match.
 
@Kevin: OK. Thank you for your time and useful infos. I think I have to go to sleep. It is 7:04 AM. :-)
 
For the record, here is my exact output: dpaste.org/aWCr
 
I think we need to install vtk by invoking the installer.
 
I'm curious why it did Downloading pyvista about ten times... Maybe it kept trying older and older versions until it found one that installed properly. And maybe 0.25.1 is the first version that doesn't say vtk is required. Evidently it is required, but the installer doesn't say it is.
 
12:07 AM
I gave up with this VTK and pyvista. It is too time consuming. :-)
The strange thing is that there is no binary installer for the version 9.
 
Relatable. I have little patience for installing something so I can install something so I can install something.
Perhaps there's no installer for version 9 because they think having wheel files is easy enough. Wheels usually are pretty easy to install... You just download them and do pip install full_name_of_wheel_goes_here.
The only hard part is figuring out which wheel works for your OS and processor and Python version by looking at the cryptic filenames :-P
 
But I don't know how to install the downloaded stuffs from virtual environment.
most of the time I install by letting the pip download the stuffs automatically.
 
Have you tried pip install vtk? It doesn't work for me, but it might work for you
 
not work for me too
ERROR: Could not find a version that satisfies the requirement vtk (from versions: none)
ERROR: No matching distribution found for vtk
Choosing Three.js might be my last resort.
@Kevin: See you later. Thank you !
 
12:24 AM
What Python version do you have? 3.9? The latest vtk package on pypi is for 3.8, so it might not be compatible. If you really want to try everything before resorting to three.js, then maybe you could uninstall Python 3.9 and install 3.8.
Yeah, I gotta go too actually. Best of luck
 
 
2 hours later…
2:23 AM
@Kevin: I will take a look what you said above later today.

By the way, is there any trick to render opencv document properly in vs code, too many backslashes are really distracting as shown below:
TeX macros and escape sequences should be rendered properly.
Or I have to open the HTML version of the doc, right?
 
 
2 hours later…
4:05 AM
hello
s=input("Enter a String: ")
vowel={"a","e","i","o","u"}
counter =0
v=[]
for i in set(s):
    if i in vowel:
        counter+=1
        v.append(i)
    else:
        pass

if counter ==5:
    print("Your String Contains All the Vowels")
else:
    print(f"Sorry!! Your String contain only {counter} vowels, which is/are: {v}")
I was trying this.. The Code is working perfectly, I just want to know ,, When I am Printing V (is a list which is Containing the Vowels found in the string) it's Not printing at the same order in which it is appending.. Like. if the Input is : a e i o then the output is ['o', 'e', 'i', 'a'] , how can i print in the same order in which it is appending, Can anyone Please Help me,, and Explain me why it is happening?
 
4:32 AM
Because you are converting input to set and in set theory order is immaterial.
@PallabTewary Perhaps you might need to use collections.OrderedDict.fromkeys(s)
Interesting, there is also dict.fromkeys(s), so you can use that too.
 
I am not able to understand how to use post method on requests module i was trying to do web scraping on this website https://noonies.tech/award/top-programming-guru where i found data is present in network xhr tab and the url is https://noonies-yoga-2020-p-fgh56hrn22.herokuapp.com/ this but post method is requires but how to send others parameter i dont know i have tried below code: import requests
url="https://noonies-yoga-2020-p-fgh56hrn22.herokuapp.com/"
headers={"referer":"https://noonies.tech/",
 
@BhavyaParikh Hi, please take a read over here before posting code
 
 
1 hour later…
@PallabTewary, try sorted(['o', 'e', 'i', 'a']) or sorted(v) to get the list in ascending order
 
6:36 AM
@BlackRaven yes, It will print in sorted order, but i don't need it in sorted order, I need the same order in which it is appending
@CoolCloud Okay, I understood why it's not appending in the same order, as set is unordered
 
@BhavyaParikh Any RO here to move this unformatted code out?
 
6:59 AM
cbg
guys not sure if i am going about this the right way
df.loc[df["TIPO"] == "OFICINA" and df["DIRECCION"]== [df.loc[df["TIPO"] == "CAJERO"].loc[0]["DIRECCION"]]]
essentially trying to find values with the same direction but of different type within a df to set a value within each
 
7:34 AM
You want to find values with the same direction as what? The same direction as another row? So you want to find pairs of values?
 
7:49 AM
tbf I found the answer in the end thanks anyway
The idea was to find items with the same values to replicate otherwise
fpund this the longwinded way to do it not sure if there is a better way
for i in df.loc[df["TIPO"] == "CAJERO"].index:
    if len(df.loc[df["TIPO"] == "OFICINA"].loc[df["CODSUCURSAL"] ==df.loc[i]["CODCAJERO"]]) > 0:
        df.loc[i,"CODSUCURSAL"] = df.loc[i]["CODCAJERO"]
 
8:06 AM
@Kwsswart As a rule of thumb, never use and/or to create a numpy/pandas mask. Use the binary operators &/|.
 
hmm not heard of a numpy pandas mask
 
Hmm the prosus news is interesting
 
@Kwsswart It's the thing you use when you do data[data == value] and such.
 
Oh why wouldn't you want to use that to select and change data?
@Hakaishin you refering to siliconcanals.com/news/startups/… ?
 
@Kwsswart Because and/or are boolean operators, and the boolean meaning of many numpy/pandas things are not well-defined.
Usually, you want element-wise meaning expressed by &/|.
 
8:12 AM
yes
 
ahh ok so the better way is reutilizing .loc to locate it or is there a better way than the final method I used
 
8:22 AM
The name has it: pro sus
 
it was pro guys ;)
 
9:11 AM
Is there any proper way to deal with duplicate answers? Or perhaps answer copying? How to align the ttk widgets in your application?
 
@CoolCloud You can flag for moderator intervention if you feel an answer is plagiarism. Keep in mind that moderators generally do not have domain knowledge, so be sure to explain the case succinctly but thoroughly.
 
If it's exactly the same answer, report it for plagiarim. Otherwise, just downvote
 
To me the core region looks same(the code too), what do you guys think?
 
I think there's a grey area where the code is identical but the description differs substantially. A succinct explanation might be better than a longer one.
That said, it seems pretty clear to me they copied your code, seeing how they have the same weird whitespace.
 
Mmmmm I was writing the message and noticed the user deleted the post, guess its fine now
 
9:23 AM
They probably reacted to the downvote.
 
Prolly, but I do not mind if a person copies the answer and expresses it in a clearer manner but this user has also been posting answers without any explanation and I have pointed it out before many times, and never got a reply or an improvement in the answer. And when seeing user trying to copy an answer, it seemed unacceptable
 
Yeah, there are tons of people rep-farming in shameless ways.
These days, I just try to keep clear of questions that are likely to attract rep-farming. It's easier than handling the drama.
 
9:41 AM
cbg folks
ah, the rep-farmers work in mysterious ways. :P
 
Laurel
 
10:00 AM
:52361252 This will append in the list in sequence without sorting
for i in s:
    if i in vowel and i not in v:
        counter+=1
        v.append(i)
 
What was wrong with the way I suggested?
 
10:14 AM
Is there any other way to find the difference of two lists, other than use set? Something instead of set().difference()? I want to find the difference but also preserve the order of the item
 
set1 = set(list1); result = [value for value in list2 if value not in set1]
 
10:30 AM
hi
what is going on
 
10:56 AM
September 1993
 
@Aran-Fey Mmmm cool, can you tell why converting to set?
 
Because in is faster with sets
 
Oh okay, many melons!
 
11:34 AM
hi guys, i need help with vwmc (vmware module) for connecting to vmware exsi server, anyone here have used this module?
 
12:13 PM
this? Have you seen their examples yet? Say, try this first. i haven't used it though.
 
is there any way to search questions (not limited to my questions, all questions) by date asked? for example, the first question in python tag
 
12:33 PM
thanks for this answer, i am actually able to connect using this, but i need a method through which deploying a vm using ovf file should be possible, in examples or docs i couldn't find any
 
1:07 PM
After yesterday's conversation on Bayes' theory, I finally was able to write some test cases for my conditional probability scenario, and produce output that makes sense to me
I think one of the parts I was missing for my earlier failed attempts, was the formula p_b = x*z + y*(1-z), which I 50% made up and 50% remembered from classes from ten years ago
I'm curious is there's a formal description of this property... If I were to restate it in general terms, I'd write it as something like p(B) = p(B|A)*p(A) + p(B|~A)*p(~A)
Where p(~A) is "the probability that A does not occur", which is equal to 1-p(A). and p(B|~A) is "the probability that B will occur, given that A did not occur". I don't think you can rewrite that purely in terms of p(A) and p(B|A).
Hmm, might be equivalent to the law of total probability for the specific case of n=2.
 
1:46 PM
Still trying to work out how to do Bayesian inference once I've calculated all these numbers. For example, consider the counterfeit coin scenario, except I don't know the actual probability of a coin being fake, and my z value is merely a reasonable guess. I want to improve my z guess by flipping coins and plugging evidence into the formula. I just don't know how to do that symbolically.
 
2:00 PM
what's your end goal with this? Or is it the usual impressive but useless display :P
 
I'm hoping that if I work out the mathematics of a couple toy examples, I'll gain a better intuition for estimating the result of the formula for real-world scenarios.
 
I tried to use a kalman filter even had a course about it. In the end I still had so many open questions I couldn't use it. Especially about the initialization of certain covariances and other variables. Kinda a frustrating experience. Especially because all toy example just say. Take 0.5 for epsilon or 1.0 for xy and we will derive that later. But later never comes. So I'm wary of toy examples
 
I know that True Rationalists don't sit down with pen and paper every time they encounter evidence that challenges or reinforces their pre-existing beliefs, but maybe they do something a bit more diligent than saying "this event reinforces my belief, so I'll add, idk, 5% to my prior probability. That sounds about right"
 
@Kevin so that is your github account :o I recall seeing it once thanks to this gist, but never put the dot together
 
Yes it's me
 
2:10 PM
nice
 
Wow mars helicopter contributor? Crazy. Oh for Python wow that's really amazing
 
Oh, does my profile say that? I know they awarded badges for it but I didn't know if people had to apply, or what.
Yeah, I've corrected a missing apostrophe in the Python docs, so I guess you could say I'm a pretty big deal ∠( ᐛ 」∠)_
 
@Kevin Is this a joke or for real :D If that was your contribution this badge seems so hilarious :D But I also got arctic code vault contributor and don't think I deserve it
 
I forget if it was an apostrophe specifically, but I really did correct some kind of typo in the docs.
(Me being a pretty big deal is a joke, though)
 
Haha yeah I got that part ;) only the usual IT on the spectrum person here nothing out of the ordinary
 
2:18 PM
I am but a humble hovering chrome orb, tending to my crops
 
I'm running into some weird issues with my ML model deployment
So we have multiple functions for preprocessing, and I'm calling them in main file along with my model training function
When I'm saving the output of preprocessing in a variable, and then passing it to model training function, I'm getting error because of some filed mismatch
But when I'm saving the output of preprocessing steps, reading that file again, and then passing that as argument in my model training func, it's working fine
What could be the possible reason for this?
I've tried deleting pycache as well
 
I wonder if saving the data to a file and reading it is changing its contents somehow. Try comparing your original data against the saved-and-loaded data and see if they're equal.
 
2:34 PM
Alright
 
I know that if you open a file with universal newlines mode, then it can take creative liberties with what bytes it uses to represent line breaks. Bad news if you were depending on your string to have specific ordinal values or a specific length. If you need to preserve those kinds of properties, consider opening in "b" mode.
 
@Hakaishin a lot of people who met the requirements for Artic code vault didn't get the badge iirc
 
@JackDaniels How do you create the file in that case?
 
3:01 PM
late morning cabbages, folks
 
3:16 PM
cbg!
 
I found another simple way to clear terminal window instead of the yesterday solution with subprocess.


import subprocess as sp
sp.call("cls", shell=True)

The shorter way is:

import os

print("testing...")

os.system('cls')

print("ok...")


I hope it is also useful for others. :-)
 
I believe that was one of the solutions in the post I linked, yes
 
anyone snack at their desk? I have a problem: I haven't been able to find a snack that isn't oily or crumbly so that my keyboard doesn't get ruined after I eat it. Thoughts? (this is somewhat related to my rant about chips from the other day)
 
@Kevin This rang some bells from math class. So far what I know is p(A|B) = p(A∩B)/p(B) and then we can re-arrange to find p(B)
 
Good ol' Bayes' Theorem!
 
3:21 PM
...and if they are independent events then the numerator will be p(A)*p(B) and then we cancel with the denominator and end up getting p(A)
 
Yeah, that sounds consistent with what I've seen so far
 
@inspectorG4dget I was amused when I learned that the equation of Bayes Theorem has Total Probability Theorem in the denominator.
 
I'm now looking at Bayesian inference, trying to relate my toy example to the variables required here
 
I merely get the concept of probability already, and then when conditional probability came, I got started, I am worried about how my future is going to be if I don't get a good grasp of these simple concepts
Perhaps a little bit of Monty Hall problem can help make things worse :P
 
If H is "a coin I find on the ground is fake", and E is "I flipped a coin and got heads", then I know how to find every value I need except for P(E), aka "the odds of getting heads on a coin, without knowing whether it's fake or not"
 
3:26 PM
@TheShortestMustacheTheorem Don't use os.system. Python recommends using subprocess instead of os.system. In fact the subprocess module intends to replace os.system. Source - docs.python.org/3/library/subprocess.html
 
If I know the exact true amount of fake and real coins on the ground, then I can calculate P(E) easily using the same "law of total probability" approach from earlier. But I don't know the exact true amount -- the entire point of this exercise is to find a more precise estimate of the exact true amount.
I think either 1) I'm misunderstanding what P(E) represents conceptually, and I'm allowed to use my mediocre estimate of the fake/real coin population to calculate it; or 2) I can apply the inference formula to two different hypotheses, and combine them in some way that cancels out P(E) entirely while still giving me a useful P(H|E) value.
It may help that H's logical negation, "a coin I pick up is real", is the only other possible hypothesis, so I know that P(fakeCoinHypothesis) + P(realCoinHypothesis) = 1. That might help me bridge two inference formulas.
 
cabbage
 
How are things in Room 6 today?
 
Today we are driven by kevins fake coin story here :P Or was that yesterday...
 
3:40 PM
I am stymied by math I only half-understand, same as usual. I had hoped it would be easier because all of the numbers are between zero and one. But no luck -- it's almost as if [0, 1] and the set of all reals are equivalent somehow 🤔
Ah, the wiki page has a second representation of the formula, and it swaps out P(E) in favor of some terms relating to ~H. Exactly what I wanted.
 
@Kevin feel the same too. Usually the actual "simple" explanation/understanding of a math formula/concept is so easier and simpler to understand that it feel kinda anti-climatic when you then look back on the official terms/etc
 
@Kevin I sense some sarcasm here...
 
@TheShortestMustacheTheorem Thanks for this! wanted to do something similar too. Look here more alternative :) Also, nice beard!
 
@Code-Apprentice ;-)
Surely the set of real numbers between 0 and 1 must be much smaller than the set of all real numbers. I mean, just look at them.
 
4:03 PM
infinity steps in. intuition steps out.
cbg
 
@Kevin OK. Thanks!
@ShreyanAvigyan Nice info. Thank you!
@NordineLotfi Thank you!
 
@pythonRcpp please read our room rules: sopython.com/chatroom
 
4:23 PM
which python shows correct virtualenv jupyter, but jupyter --version points to native jupiter, any suggestion to fix this
 
What does type jupyter say?
 
Ok, I'm getting sensible looking values out of my bayesian inference test cases... Except for "counterfeit coins are double-tailed and your coin just flipped heads", which says my updated belief should be infinity percent.
 
```
type jupyter
jupyter is hashed (/usr/bin/jupyter)
```
 
Seems a tad high for a probability of a hypothesis that literally can't fit the evidence
 
4:47 PM
my_dict = [
"taste": "good",
"smell": "good"
]


how about `your_dict`? :-)
 
@MisterMiyagi thanks ` hash -d jupyter` worked
 
5:07 PM
@Kevin I think that's a case of countably infinite?
 
Close! You were only off by one cardinality. Natural numbers are countable but reals aren't.
(disclaimer: the claim that reals and naturals are "one cardinality apart" is dependent upon the continuum hypothesis, which is unprovable. Offer void in Wisconson. Not known to not cause cancer in the state of California.)
 
Oof, didn't expect to land myself straight in reading about space-filling curves
 
5:31 PM
cbg folks
 
Sanity check: is M*(M*V) equal to (M*M)*V, when M is a matrix and V is a vector?
en.wikipedia.org/wiki/Matrix_multiplication#Associativity says yes, if you think of vectors as a special case of matrix. So that can't be the cause of the weird result I'm getting...
 
6:10 PM
 while True:
    something()
#or
(while true
    (.moveLeft this)
)
#or
while(true,
    moveLeft()
)
I know you can do while True loop like the first one above, but what is the point/advantages in doing the other ones I posted under the first one?
(beside syntax choice/preferences I mean)
 
The others aren't python, surely
true isn't recognised, the brackets are mostly pointless, the camelCase suggests another language
 
I think the others are algorithm notation
I've never seen this type of while loop in C, Java or any other programming languages
 
So I think the point/advantage is that only the first version can actually run
 
If the question is "there are a variety of syntaxes that different languages use to indicate things such as conditional and while blocks, etc. For example, Python uses whitespace, and C++ uses curly brackets. What are the advantages of using one over the other?", then the difference is largely a matter of taste.
 
@roganjosh this is mostly from a python game which use "python" syntax, without real (afaik) python interpreter/compiler behind the hood (the name of that is "codecombat" if you're curious)
I saw the different syntax i mentioned previously and got curious, which is why I asked :)
 
6:21 PM
That would be good info to include in the question, because it's not clear why you'd suggest the other two otherwise
It's odd that the game doesn't include an option with curly braces. Maybe that's too hot-potato
 
mainly because this could be possible syntax, either in past version or current (probably not current though since I checked and it doesn't work for the other two, unless it's something weird)
@roganjosh yeah, indeed
@Kevin I see. that does make sense yeah. Just thought there would be some underlying reason beside that :D (eg: speed? something else?)
 
Intelligibility
 
Curly-bracketed blocks are nice because you can usually remove all the newlines from your code, and it will still work the same. space-indented blocks are nice because your code is slightly less "cluttered" with a bunch curly brackets.
 
gotcha, that does make sense when said like that too
 
Neither is a world-shaking advantage, so I'm happy to use either.
 
6:24 PM
yeah, me too. Although more used to the normal version with space/tab indented, thus the question earlier :)
 
Re: "speed?". whitespace blocks and curly blocks can be parsed with identical efficiency.
 
yeah, I guess it would hmm
 
There's no speed increase or decrease. But curly blocks doesn't have "Inconsistent use of tabs and spaces" error. :-)
Many editors have tab and space problems and suddenly Python can't parse those files!
That's one advantage of curly blocks
 
I agree with the facts of your statement, although my opinion is that this drawback is quite small when handled properly.
For example, I never have tab/space problems with code that I have written myself, because my editor, Notepad++, has an option to automatically convert all tab keypresses into four spaces.
Of course, I can still have tab/space problems if I'm running code that came from someone else. Another Notepad++ option is helpful when reviewing such code: "Show White Space and Tab". It becomes easy to visually distinguish tabs from spaces, because they will appear as arrows and dots respectively.
 
@Kevin I used Notepad++ before and never noticed/used those option o-o That kinda make me wanna use it just for those
@ShreyanAvigyan Interesting use-case. Guess I'll try them more often :D
 
6:38 PM
One last fun fact: Python does allow you to mix spaces and tabs in one line. But the formula Python uses to calculate the indent level of a line, may differ significantly from the formula your editor uses. If so, you may end up with code that looks like it should work, but doesn't work; or vice versa.
 
@Kevin that explain why some editor prevent me from using certain mix of tab and space, but the Python interpreter/most python compiler will let me get away with them, most of the time...
 
(Or, hmm, did they depreciate tab/space mixing since 2.7ish? Admittedly, I haven't tested it out lately)
 
@Kevin I think you're right about it, because I vaguely recall being able to do that but it probably depend on the "level" of indentation and how much you would mix tab and space
not sure of the exact limit, but I guess the doc probably wouldn't give the exact limit to trigger the error "Indentation Error: Mixed tab and space" or similar
 
Ah, it still allows mixed lines. Paragraph 2 of docs.python.org/3/reference/lexical_analysis.html#indentation describes the algorithm
 
nice :D
 
6:44 PM
@NordineLotfi The second one is LISP. Google has some useful notes on it. "Homoiconicity" might be useful to look up as well.
 
@Kevin So basically if you used tab-space in the first line of the indented code then you also you have to use tab-space in all of the lines of indented code
 
That TabError paragraph is new to me... I must experiment
 
@MisterMiyagi Thanks! I'll look it up :D
 
RE tabs: The python3 behaviour is so that you cannot mix tabs/spaces to express the same indentation across separate lines. So if you have <indent 1><indent 2><indent 3> in two lines of a block, then each <indent n> can be tab or space but it must be the same on both lines.
Say you have \t \t on both lines that's fine, but you cannot have \t on one and \t\t on the other.
The upside is that indentation is consistent no matter the tab width.
 
So if we have TAB SPACE then all indented code must be TAB SPACE, right?
 
6:51 PM
Here's an interesting case that I'm surprised is valid:
 
@Kevin is that (It's been a while since I used Notepad++) tab+space then space+tab?
 
so <TAB><8 spaces> is considered the same as <8 spaces><TAB>
 
interesting
 
But <TAB><4 spaces> is not the same as <4 spaces><TAB>. That gives IndentationError.
 
maybe because there that one convention that 8 space is seen as a tab/replaced as one?
I know some editor replace 8 space to a tab or so behind the hood and you wouldn't know unless you look at the cursor or look at the hex values
 
6:54 PM
I know that Notepad++ isn't doing that right now, because the arrows and dots faithfully represent the underlying hex values
 
PyCharm and IDLE doesn't give IndentationError. They are treating both <TAB><4 spaces> and <4 spaces><TAB> as the same thing
 
I believe I understand the formula that the lexer uses to turn tabs into spaces. What I find confusing is the exact meaning of " the worth of a tab in spaces" in the paragraph that talks about TabError.
 
@Kevin I'm guessing that part of the doc would be considered "opinionated", especially since they didn't give more reasoning behind the convention/working of the formula
but then again, we all probably know the "tab vs space" trend, so that could explain this on some level
 
I found a stack overflow question for this - stackoverflow.com/questions/18225712/taberror-in-python-3
 
I find it funny this convo emerged from a while True loop related question though
(not complaining since I did learn quite a bit here)
 
7:09 PM
Ok, I found out how the lexer decides to raise a TabError. when it sees a tab character, it calculates two different values indicating how many spaces the tab is worth. The "true" value uses the round-up-to-next-multiple-of-eight formula described in the docs. The "alt" value simply replaces the tab with a single space.
In order to determine when an indentation block begins or ends, the lexer must compare the indentation levels of the current line and the previous line. If the lines' true values are different, then a block must have started or ended. If they're identical, it goes on to compare the line's alt values. If the alt values differ, then the programmer must have been doing something silly with tabs and spaces, so it crashes with TabError. If the alt values are the same, then it continues as normal.
 
@Kevin very detailed and insightful :O Thanks for this!
 
<TAB><8 spaces> has a true value of 8+8=16, and an alt value of 1+8=9. <8 spaces><TAB> has a true value of 8+8=16, and an alt value of 8+1 = 9. The values match up, so the lexer considers these whitespace sequences identical.
 
@Kevin I guess I'll go and have a look at the implementation. Then probably the algorithm would make sense. But thanks for the explanation!
 
On the other hand, <TAB><4 spaces> has a true value of 8+4=12, and <4 spaces><TAB> has a true value of 4+4=8. So the lexer assumes a block is ending, and doesn't even bother looking at the alt values. It later crashes because print(bar)'s true value doesn't match the indentation level of any other line in the program, but that can happen whether you use tabs or not.
 
@Kevin I guess this could be accepted as a bug/or pull request :o
unless this was already done before and rejected hmm
 
7:20 PM
It's not so much a bug as it is... An inconsistency in stylistic choices made by editors across the last five decades.
 
Yes exactly. It depends on the editor. IDLE and PyCharm strip of all peculiarity about the code. While notepad++ keeps the inconsistency and then crashes
 
If you're on a classic Unix box and you're using a classic text-only editor, then there will be a perfect match between Python and editor. Indentation levels that look the same will parse properly, and indentation levels that don't look the same won't parse.
Notepad++ can simulate classic Unix styling if you set Tab size to 8, in the "Settings -> Preferences -> Language Menu / Tab Settings" menu. With classic tab size, it's obvious that g() has invalid indentation.
 
7:38 PM
What do you use for C# @Kevin?
 
Visual Studio.
hmm, 4 spaces + tab + 3 spaces + tab has the same true and alt values as tab + 8 spaces, that's interesting... So you don't even need to use the same amount of tabs on successive lines.
 
TabError shouldn't be raised unless the text editor has really messed up the indentation level. The algorithm goes to its very extent without raising error. But if the editor messes up the indentation level the algorithm emits IndentationError or TabError.
 
I want to be perfectly clear: the text editor has not made any mistake. The text editor is doing exactly what is asked of it. The text editor saves exactly the character codes that you give it.
If you make unfounded assumptions about the behavior of tabs based on their appearance, then only you are ultimately responsible for the surprising behavior that your code produces.
If you're saying "Python is too strict about IndentationErrors. It should try to make a reasonable guess at what you actually meant to type, and run that instead", then I strongly disagree. Computers are very bad at making reasonable guesses about the intentions of humans.
 
I think, actually in this case, Shreyan was saying that the blame falls on the editor
FWIW the IDEs I've used (even Spyder) go to long lengths to try get something that's valid indentation
I think I've lost the comment that provided the impetus behind this convo. But I don't think there was any suggestion of "Python is too strict about IndentationErrors.". Maybe I'm reading wrong
 
7:59 PM
I also wonder if I'm reading wrong. Whenever I say "If you're saying...", that is an implicit admission that I do not fully understand what the other person said.
 
So I didn't say "Python is too strict about IndentationErrors.". I said text editors - Simple Text Editors - like Sublime Text and notepad sometimes messes up the indentation. It's not Python's fault. In fact, Python does it's very best but if the text editors don't cooperate then Python has no choice but to raise error.
 
I hope people don't look at that rhetorical device and think of it as a way for me to steer the conversation into something more interesting to me personally. If my guess is wrong, I dearly want the other person to tell me my guess is wrong.
@ShreyanAvigyan Ok, I think I understand more this time. I'm sorry that I assumed too much.
"notepad sometimes messes up the indentation". I believe this is an unfair framing of the situation. Notepad has made a stylistic decision about how wide tabs should be. Python has made a stylistic decision too. If the decisions are different, an IndentationError may occur. But neither piece of software has "messed up".
 
I think this was just a general misunderstanding and that we're all agreeing, tbh
 
Wise. That is always a possibility whenever two humans make noises at one another. I would do well to remember that.
 
I wish there were a ceildiv operator. I'm feeling too lazy to do math.ceil(n/d). I'm pretty sure though that nobody is going to implement n\\d (ceildiv) as the opposite of n//d (floordiv)
 
8:12 PM
I'll put it in KevinScript for a reasonable fee
 
@inspectorG4dget there is this though
not sure if this help however
 
@Kevin see, I /knew/ I should have pushed harder to start this project on KevinScript. Alas, it is too late to change langauges
@NordineLotfi actually, it does help! I'm pleasantly surprised and somewhat disappointed in myself for not thinking of the math
 
@inspectorG4dget Glad it helped!
 
8:25 PM
rbrb
 
One last point of moderate interest: the longest possible function that has a "true indent" of 16, and never uses the same indent combination more than once
 
oh no
 
Oh yes
 
python 3 should have just disallowed mixed indentation
first indentation is 4 spaces? whole file is 4 spaces!
 
It disallowed certain kinds -- it crashes if the "alt indent" doesn't match up
 
8:30 PM
(is there any good reason for mixing indentation sizes/styles in the same file?)
 
I can think of justifications along the lines of "you and your coworker use different indents while working on the same code, and you can't agree on a common style, and the boss refuses to integrate automatic style enforcement into your commit process"
All of them basically boil down to "you live in an imperfect world where you must sometimes grit your teeth and tolerate a bad situation"
 
tbh for that first case the language making a decision for you is the best that can happen
 
Yeah, when VS re-indents my code for me, sometimes it rustles my jimmies, but at the end of the day it's better for the project.
I kind of wish it would wait to make changes until I wasn't looking, though. Sometimes it looks at my code while I'm halfway through typing it, and makes several incorrect guesses about what block I'm in. "Let me indent you by four spaces... No, eight. Actually, is this a global? Let's go back to the left margin"
 
i still miss something like eslint for python. i know there's black, but it's a bit too opinionated for my taste - i'd like to have some autoformatting feature but not let a tool do EVERYTHING (including trying to squeeze as much as possible in the max line length, no matter how ridiculous it looks like)
 
Mm hmm, I believe this is a common opinion of black. I've never used it for anything serious, myself.
Let's just make our own highly customizable style configurator. How hard could it possibly be?
 
8:47 PM
probably not too hard if you can get an AST that includes all the comments and whitespace between lines and write a "compiler" that compiles it back to python code, using whatever rules you have
actually, no need for the extra whitespace handling as long as you require users to use some spacing rules
(so it wouldn't support e.g. a mix of 1-3 empty lines between top-level functions, but always normalize it to whatever you specified)
lib2to3 could probably do much of it
there's also redbaron
 
From previous experiments I know that the built-in ast module does not preserve stylistic tidbits like the whitespace around operators, or the exact way you type a float literal. 1.0 and 1.0000 turn into identical nodes, for example. So doing a round trip from source to AST to source would be challenging
 
if the ast has exact positioning information (ie not just line but also start/end within the line) it could probably still be used, you'd just need to get that extra data separately
OTOH, turning 1.000 into 1.0 seems reasonable
but 1_000_000 to 1000000 maybe not (even though one could have a rule to always write big numbers with/without the thousand separator)
 
The last time I dabbled in source rewriting, I ran up against that problem. I tried integrating the tokenize module, which (AFAICT) does preserve tidbits, but there ended up being some weird corner case where I couldn't find the token associated with some particular terminal in the AST.
 
was it before or after the new python parser?
 
Probably before.
The ast must retain some line/pos information, because otherwise it would not be able to report useful line numbers when a stack trace gets printed. I don't think it tracks the position of everything though.
 
9:27 PM
From infinity to asts, @Kevin is covering a lot of ground today
does anyone have experience with time series dbs? Any recommendations?
 
10:10 PM
GeeksForGeeks just earned a spot on my "don't recommend" list with z = (int)(x / 2);
 
in what language?
 
Python :|
 
@Aran-Fey Took me a moment... ouch.
 
Wow, I'm actually using numpy of my own free will for a personal project... I thought this day would never come
 
Image manipulation?
 
10:17 PM
Graph problems. In particular, I want a PageRank-like rating for each node, based on how many nodes link to it.
 
Sounds like a job for collections.Counter rather than numpy, but I guess you know what you're doing
 
I also want to take into account the PageRank of each node linking to the node, so it becomes a recursive problem
 
@Aran-Fey slash scratch head
 
en.wikipedia.org/wiki/PageRank#Simplified_algorithm describes the system of equations that you might use to represent a small four node graph. Systems of equations are quite easily turned into matrices, and finding the eigenvectors of the matrix tells you all the stable states the system can reach at time t=infinity.
(warning: oversimplification)
My prototype works, but I haven't tested it on my real data set, which has about 200 nodes. I'm scared to try it and disccover that eigenvalue finding is O(Nodes!) time, or something.
 
10:39 PM
I see a return in a for loop on a first trip of an if :P
Is it guaranteed that eig returns the eigenvalues in the order you assume them to be?
 
If I read the docs right, the eigenvalues are in no particular order, but the eigenvectors table is guaranteed to match up with their respective eigenvalues.
 
I'd loop for value, vector in zip(values, vectors.T). And your error after the loop mentions a "nonzero eigenvector"
@Kevin so do you really want to find "one" real nonzero eigenvalue, whichever that is?
I think for even-sized real square matrices you have to have an even number of real eigenvalues (because complex eigenvalues come in complex conjugate pairs)
Although it's possible that only one is nonzero... but you'd have to have pretty funky matrices for that. But who knows, that might be the case.
 
I'm trying to think about it in terms of business logic. I want a vector representing the PageRank of my variables, and I want that vector to keep the same direction if I multiply it by my matrix, and if possible I want it to keep the same magnitude too.
Oh, and I want the vector to be real.
 
The first part is "an eigenvector", that's fine. If you want to keep the same magnitude then you should find the real eigenvalue that's closest to 1.
 
Makes sense to me
 
10:45 PM
real matrix + real eigenvalue -> real eigenvector, so you're good
 
Apparently, since each of the columns of my matrix sum to 1, this makes it a "left stochastic matrix", which guarantees that the largest eigenvalue is exactly one.
 
Neat. Then just snatch the largest eigenvalue
 
Ok 👍
That zip(values, vectors.T) will certainly help me from making a tremendous mess here
 
real_indices = np.isclose(values.imag, 0)
real_values = values[real_indices]
real_vectors = vectors[:, real_indices]
largest_real_index = real_values.argmax()
value = real_values[largest_real_index]  # should be np.isclose(. , 1)
vector = real_vectors[:, largest_real_index]
 
if I have d={1: {'s': 1, 'd': 2, 'f': 3}, 2: {'s': 1, 'd': 2, 'f': 3}}, and I want to iterate over each key (i.e. 1,2) and a specific key in each value (say, 's'), is there a terse way to something like this (without walrus - prod is v3.7)?
for k,v['s'] in d.items():
    print(k, <magic>)
 
10:49 PM
ew, come on
And what exactly is "something like this" when most of your code is missing?
for k, v in d.items():
    s_value = v['s']
Brain fart on your part or misunderstanding on mine?
 
I suppose I could do for k,v in (k,v['s'] for k,v in d.items()):
 
No.
Are you writing a 3-line comprehension?
 
@AndrasDeak possibly both. I couldn't replace <magic> with v['s'] because v isn't exactly defined due to the syntax error on the previous line
 
So how about what I wrote?
 
@AndrasDeak I'm going crazy trying to optimize a simulation
 
10:52 PM
@inspectorG4dget let me help: s_value = v['s'] is not the bottleneck
 
trying to cut down on extra lines
@AndrasDeak touche! I think I need to call it a day
 
@inspectorG4dget are you optimizing to maximize maintenance time? :P
You don't profile your code with wc -l, you profile it with a profiler.
 
I deserved that :P
 
But you should absolutely run a profiler. I recommend cProfile -> snakeviz.
and only sacrifice readability when it's really worth it
 
Hmm, there's a certain appeal to doing highly fancy matrix manipulations without ever using more than one level of indentation...
 
10:55 PM
@inspectorG4dget (I mean it would've worked if you'd defined v = {} before the loop... but please don't do that :P) ((then again that would be the same amount of "unoptimized"))
@Kevin unfortunately from numpy import * is a doozy for code golf
@Kevin the real win is performance
not that this is your main concern here
 
We need a code golf category that tries to minimize the number of conditional branches in your code. Numpy will sweep the results with a score of 0, so it's more of a performance art than a competition.
 
00:00 - 23:0023:00 - 00:00

« first day (3887 days earlier)      last day (1053 days later) »