« first day (2791 days earlier)      last day (2151 days later) » 
00:00 - 19:0019:00 - 00:00

7:00 PM
cbg.
 
well the loyalty which binds it to its owner probably gives it a kind of fulfillment it wouldn't have experienced as a tree
 
avidly googles Discworld
 
Sheesh, 4 elephants holding up a world while riding on an turtle, sounds dangerous.
 
it is, especially during mating season
 
No more dangerous than a world shaped like a ball, of all things. Everything would just fall off the bottom. Bad design.
 
7:04 PM
yet we allow a single titan to do so? it doesn't bold well to have only one fail point rather than multiple ones
 
It italicizes perfectly tho
 
user7659542
Hi

I amtrying to run an opensource python script. When trying to do so I get the following error:
 
user7659542
./egohands_dataset_clean.py: line 17: syntax error near unexpected token `('
./egohands_dataset_clean.py: line 17: `def save_csv(csv_path, csv_content):'
 
user7659542
 17 def save_csv(csv_path, csv_content):
 18     with open(csv_path, 'w') as csvfile:
 19         wr = csv.writer(csvfile)
 20         for i in range(len(csv_content)):
 21             wr.writerow(csv_content[i])
 
user7659542
Does anybody know what the issue is with that code snippet? To me it looks ok
 
7:11 PM
The code alright to me. But the error message looks a little strange. Are you sure you're running it in Python?
 
user7659542
@Kevin it runs for a few minutes, and then I get that error
 
user7659542
and the code doesn't contain a shebang
 
Syntax errors are usually formatted as SyntaxError: invalid syntax. "syntax error", lowercase with spaces, is curious.
 
user7659542
@Kevin Hmmm didn't pay attention to that...
 
7:12 PM
You get a syntax error after it's been running for a few minutes?
 
I thought all definitions were made upon a file being imported. strange that it would only happen after 5 minutes?
 
user7659542
I run it as follows ./egohands_dataset_clean.py
 
user7659542
@Aran-Fey yep
 
It's probably being executed by bash instead of python
 
@traducerad How are you actually running it? That looks like a shell error message, e.g. from Bash.
 
user7659542
7:13 PM
I think you may be right, in that it isn't being executed as a Python script, because I dont specify anything and it doesnt contain a shebang. But it runs smoothly for a few minutes in the beginning. Well.. it seems to do something in the background...
 
user7659542
@PM2Ring ./egohands_dataset_clean.py
 
You probably have a few screenshots lying around somewhere now
 
maybe run it with python egohands_dataset_clean.py?
 
Because import x is conveniently a valid bash command that takes a screenshot and names it x
 
lol rly^ ?
 
user7659542
7:14 PM
@Aran-Fey didn't know import is valid in bash...
 
@FélixGagnon-Grenier Welllll. Definitions are made during an import, yes, but only because all* of the code in the file executes during an import. So they're not special in that respect.
 
user7659542
lol you re right hahah import has a manpage!
 
Yep, you're trying to run it a shell script, which means it's going to bash, or sh, or something similar
 
(*not counting code in an if __name__ == "__main__": block, and assuming you haven't already imported the file)
But syntax errors should get rooted out near-instantaneously after the file is first read by the interpreter
 
user7659542
I ll add a shebang and see how far that gets me
 
7:16 PM
airport-lounge-cbg
 
er.
I need some kind of reminder that chat is not my cli
@Kevin thanks for confirming / further explaining
unrelatingly, bandwagoning over Davidism kicking Marine1 gave me a gold badge. I kinda like that.
 
Or, hmm, I guess it depends on what you mean by "made". Compiled to bytecode? That happens during (...slightly after?) parsing, before anything in the file has executed. Bound to a name? That happens during the regular flow of the program
 
hmmm... yeah I'm not so fluent with bytecode in this context, I was mostly thinking of binding to a name, yes
 
rbrb
 
... actually, I'm not quite sure what bytecode refers to in pretty much any context
 
7:23 PM
@traducerad I hope that code is for Python 3. It may not behave correctly on Python 2, depending on the OS. Fortunately, that shouldn't be an issue on Unix-like systems.
 
bytecode = some kind of opcode in the context of an interpreting vm?
(opcode being the transformed php scripts instructions)
 
Bytecode is the intermediary language that human-readable Python compiles into.
 
user7659542
@PM2Ring just realised: Tensorflow is installed for Python3, scipy is installed for python2 and IDK what version of Python this opensource code is
 
@PM2Ring It's incorrect in both python 2 and python 3, actually. In python 2 it needs to be opened in binary mode, and in python 3 it needs newline=''
 
It's a less ugly and more portable assembly, more or less
@FélixGagnon-Grenier Pretty much.
 
7:26 PM
@Aran-Fey Yeah, I was alluding to binary mode for Py2. I keep forgetting about the newline thing. Also, that for loop doesn't fill me with confidence.
 
user7659542
Nice it s working :)
 
user7659542
Thanks! I had to add the shebang and install a few Python modules
 
user7659542
TIL import is a valid bash command
 
@FélixGagnon-Grenier In this context, bytecode is the machine code for the Python virtual machine. You can convert it back to human-readable form with dis.
 
import dis should display De Zen of Pydhon, by Dim Peders
12
 
7:32 PM
I don't think he'd appreciate being called "dim" :D
 
can touch dis
... so, is there an "instruction set" (not sure how it's called here) that groups all bytecode commands that can be generated, or am I mixing things here?
 
The predecessor of POV-ray, DKBTrace, used the .dat extension for its input data files, and .dis for its output files.
 
(googling python instruction set does not seem to return what I thought)
 
@FélixGagnon-Grenier docs.python.org/3/library/dis.html#python-bytecode-instructions has a big list of all the opcodes.
 
7:36 PM
♪ You can go with dis, or you can go with dat ♪
[Christopher Walken dances energetically through the background]
 
JUMP_FORWARD(delta)
Increments bytecode counter by delta.
is that a goto with high charisma?
 
I wonder if you can give that a negative delta. Not sure if bytecode arguments are signed.
I think I see JUMP_ABSOLUTE used more often for your everyday for loops and what have you
 
at low level goto is where it's at
 
but thinking about it, JUMP_FORWARD would be fine for if-else blocks
 
dis might just be my new favorite thing, but I don't get the naming. I think I've just learned that bytecode is the actual instructions fed to the interpret, yet by using dis I see... the opcodes mentioned in the doc
dis(todotxt.parse_line)
 14           0 LOAD_GLOBAL              0 (print)
              2 LOAD_FAST                0 (line)
              4 CALL_FUNCTION            1
              6 POP_TOP
 15           8 LOAD_GLOBAL              1 (TodoItem)
             10 LOAD_FAST                0 (line)
             12 LOAD_CONST               1 (('description',))
             14 CALL_FUNCTION_KW         1
             16 RETURN_VALUE
if that^ is disassembled bytecode, bytecode would be some binary stuff?
 
7:53 PM
>>> def f(): pass
...
>>> f.__code__.co_code
b'd\x00S\x00'
^ actual bytecode
 
The actual condensed bytecode, I believe, is at yourfunction.__code__.co_code. Oops beaten.
 
at least I'd think thore are the same numbers as bytes
 
New sport: python functions the bytecode of which is something interesting when decoded as utf8
3
 
Huh!
 
7:56 PM
guys i am new to python and wanted to know how to lowercase a particular column in csv
 
DSM
Do you know how to read and write a csv file without lowercasing anything?
 
i have been trying to find some information on SO and python document, but found no luck yet
yes i have done trhat
 
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 4: invalid start byte
 
DSM
@KaranM: using the csv module or just iterating over the lines?
 
@FélixGagnon-Grenier yes, that's why that's not a good entry for the sport
 
7:58 PM
@DSM using the csv module
 
Man, I'm sniped
 
hehe
 
DSM
@KaranM: that's the hard part! Where's the problem coming in?
 
wish I could run ./get_my_life_together.py
 
7:59 PM
well, at least you don't have multiple tabs with the python chat to have the impression of having a busy evening
 
@GabrielFernandes no, please don't link fresh questions here
 
ok, sorry
:c
 
I have been trying to implement case insensitive filter on a column in 2 csvs and filter only the ones that are different. because both the columns contain names that are either lowercase or uppercase and i dont need redundant data
 
compare the .lower() in both datasets
 
DSM
8:02 PM
normcase? Do you mean casefold?
 
For a second I thought it actually existed :/
 
Too much JS lately :D
 
yeah that can take its toll
 
I was like "Should I double-check if that's correct? Naaaah"
 
okay! so how should i apply .lower() to a particular column in csv? and then compare both
 
8:05 PM
Are your data always in the same row? Or all over the place?
 
DSM
Both what? It feels like we've moved from lowercasing a column in one csv to aligning and comparing two csvs.
 
lowercasing in order to compare with another lowercased one I guess...
 
DSM
Within the same csv, you mean? Like there's ABC and also aBc?
 
that's generally my pattern when comparing strings which casing should not matter. but at that point I also wonder why the casing does not matter, and if that's really intended oh yeah it does
@KaranM do you mean to say that you only want the columns that happen once, or some kind of sql-like DISTINCT?
 
DSM
As usual, an mcve would help.
 
8:09 PM
@FélixGagnon-Grenier I got 2 csvs that are having one particular column that i need to match
applying case insensitive filter
so that i can remove redundant data
 
"match"
 
But i will need to lowercase those two columns first right? before matching
 
5 mins ago, by Andras Deak
Are your data always in the same row? Or all over the place?
 
same row
 
8:11 PM
or they want to treat the two csvs as two parts of the same dataset
@KaranM in that case it's enough to lowercase when checking
colA = 'badgerbadger'
colB = 'MUSHROOMMUSHROOM'
test = colA.lower() == colB.lower()
 
DSM
Not sure I've seen someone use None as pass before:
                    if i == j or i == k or j == k:
                        None
 
@AndrasDeak Yep that's what i thought. so if i want to lowercase those 2 column from two csvs which i am matching, how should it be?
 
@DSM that...doesn't look very good :/
especially instead of if len({i,j,k}) < 3 ;)
 
@AndrasDeak This is the logic i am looking for.
 
hmmm... with all that, now I want a steak that is both "rare" and "pedantic"
 
8:15 PM
but ColA and ColB consists of 400+ data, so i am confused if i have to pass it as a list or dictionary
 
There are still a lot of ambiguities, for instance: you seem to start from two equal-length csvs (since you compare them row-wise), but then you start filtering and keep only rows from the one. You'll end up with csvs of different length. As DSM said, an MCVE would help and I don't think we can help further until that happens.
 
Cool, let me try that and post in a question with the output
 
You don't necessarily need to post a question, anybody who wants to help you will need an MCVE. But go ahead as you see fit.
 
Thanks Andras. I am fairly new to python, and I'm trying to understand whatever terms that comes along the way
 
@DSM It vaguely rings a bell. Which reminds me, I saw a classic a few days ago, it may have been in a page linked here already, though.
 
8:18 PM
the concept of an MCVE is language-agnostic :) It's even programming-agnostic.
 
engineering profession agnostic, if I may
 
while 1 == (2 - 1):
 
lol. I just imagined some patient/psychiatrist scene
psy: so please mcve me your love problem
 
@KaranM We just need to see a few lines of each CSV, and the code you're currently using to read them and do the matching. And we need to see the desired output that corresponds to that input. You could even simplify the CSV down to 2 or 3 columns of fake data.
 
wim
@traducerad pasting python code into the shell again?
 
8:33 PM
Yo, maybe somebody has worked on these problems. So, I need to numerically integrate some functions that give out complex numbers. Anybody have experience, of a quick way to evaluate the performance of different integration algorithms? To prototype before implementing the thing in CUDA.
 
wim
@AndrasDeak wild hashability assumption spotted
@PM2Ring to be fair, I would also like my code to halt when mathematics stops working. just safer that way.
 
@Mikhail I assume you're talking about the accuracy of the result, since you can measure speed using timeit.
 
Yep
 
@wim Lol
 
@wim ah, true
@Mikhail integrate real and imaginary separately?
Oh that wasn't the question
 
8:48 PM
The question is: whats the fastest way to go through the zoo of integration schemes, and compare their performance.
 
@Mikhail Well, it depends on the integrator. There are ways to calculate bounds on the error. But in general you can get a rough estimate by performing the integral at 2 different step sizes and seeing how much they vary. With Simpson's rule there's a nice simple formula which I can't remember offhand, but I'm sure Wiki mentions it. However, I've only ever done this stuff with real functions.
 
@PM2Ring Sure, I am posting it here: stackoverflow.com/questions/50749955/…
 
@PM2Ring should complexness matter? It's just addition
 
Complexity doesn't matter in this case because the bounds are real. The underlying concern is that these functions are rapidly oscillating. So I want to try a bunch of methods and compare.
This guy looks pretty nifty: chebfun.org
 
By doing a 3 point and a 5 point evaluation of Simpson's, you can calculate the max error, and if it's not small enough you recurse, breaking the previous 5 point group into two 3 point groups. IIRC, I've posted Python code to do that in a SO answer, or maybe on xkcd. I'll have a quick look.
 
8:56 PM
Yeah, I know how to do that. Real question is if there is some library or function or library that already has many of these implemented.
 
scipy.integrate has a few
But that's not what you asked
if there are methods with adaptive meshes you'll want one
 
@AndrasDeak Not much. Just when you're comparing the errors you need to convert them to reals, with abs().
 
Naively I'd say "double the density until it converges" for a rapidly oscillating function
 
Of course, that recursive algorithm I just described generally works ok with reals, unless the function is evil. I guess it wouldn't be hard to adapt it to using a mesh instead of 1D
 
9:16 PM
Ah. I just read the bounds are real, which makes things easier. :) If all your functions have a similar form you may be able to perform some general error analysis that can help in picking a reasonable initial step size. And of course your step size needs to be somewhat smaller than the period of your highest frequency component. :)
@AndrasDeak And hope he's not trying to, say integrate something containing sin(1/x) near the origin. ;)
 
@KaranM I've added a somewhat more extendable solution. Basically, it builds a list of unduped values as it reads the name from any number of csv files
as such, it only needs to iterate over the lines once
also, if anyone can be arsed, I'd gladly receive feedback on that being an horrible or not solution
... is it just me, or was there a sudden fall in activity just around a few mins ago. Is r6 mostly in EST tz?
 
9:36 PM
no
there are also a lot of Europeans, but it's past 10 PM on the continent
 
near midnight for most
 
9:49 PM
What do you call "r6" ?
@AndrasDeak You'd say most people from SO are European ?
 
@IMCoins no, but my guess is that most Europeans are in CE(S)T
 
I will stop attempting to make jokes. I will stop attempting to make jokes.
 
@FélixGagnon-Grenier As for your answer, it's cool to respect the OP boundaries imo. It sometime gives a little bit of challenge to the question. But if his work is not for homework, I'd say to point the OP in the best direction : meaning using pandas for csv manipulation, in addition to your solution.
 
10:04 PM
I'm not really aware of pandas however. I'll take this occasion to instruct myself
 
You could just talk about it linking to doc. ;)
OP could take a peak itself. Who knows.
Let's make this world a better place with more knowledge for more people. :D
 
heh. I'd feel a bit like an imposter though. I'll think about including it :)
rhubarb for now, got to go!
 
@FélixGagnon-Grenier meh, suggesting pandas for vanilla csv problems usually induces frowns
rbrb
 
10:23 PM
@Jan so I finally got the time to look into that csc_matrix problem of yours. csc_matrix inherits from _cs_matrix inherits from _data_matrix inherits from spmatrix
oh, you asked this on main in the mean time, I guess I can post this there too
 
11:38 PM
cbg
 
00:00 - 19:0019:00 - 00:00

« first day (2791 days earlier)      last day (2151 days later) »