« first day (2566 days earlier)      last day (2607 days later) » 
01:00 - 21:0021:00 - 23:00

01:23
stackoverflow.com/questions/46922425/… I wish "no effort" was still an option
02:01
cbg
hello
I got a question, how to implement a Game Room (which manager user websocket connection)
02:54
Hi there.. Just new to this room!
03:18
!Aminu
@AminuKano
How do u do
03:53
@landpack Fine, Hope you guys are doing great!
04:11
@AminuKano Are you familiar with tornado?
 
3 hours later…
06:47
cbg
07:19
Hi! I have never experienced such thing but the python string comparison is somewhat not working properly.
https://ibb.co/kxtnFm
Meanwhile the value of font_color is "'rgba(0, 0, 0, 1)'" and im comparing it with "font_color is not 'rgba(0, 0, 0, 1)':
The debugger still gets into the if-clause
Text identation should be correct, as I have replaced "font_color" with a string var "asd" and copared it against "is not "asd"" and then it didn't step into the if clause
It is driving me crazy
cbg
cbg!
07:40
cbg
@Ph03n1x Umm, are you comparing 'rgba(0, 0, 0, 1)' or just rgba(0, 0, 0, 1) (without the single quotes)?
Also, I would check for the "space" character just in case. It doesn't have to be the regular ASCII 32
Hi!
@AshishNitinPatil I have actually tried doing that. But now i got something even more interesting: I iterated thorugh the rgba(...) and extracted the numbers only. Thus ''rgba(0,0,0,1)" will be converted to "0001" string. And even so the comparison is not working. :S
Maybe char encoding?
Nope. :(
Proably the ugliest hacking I had to ever do...
Anyway any ideas why the original solution didn't work?
08:08
@Ph03n1x: don't use is on strings.
Strings are not singletons, you are comparing them by identity.
foo = 'rgba(0, 0, 0, 1)'
print(foo is 'rgba(0, 0, 0, 1)') # False
Use == and !=.
You want to test for value equality, not if they are the same object in memory.
Wow.
Im speachless and dumb.
i guess i have coded too much in java recently, where we have to use the .equals instead of the == operator.
Thank you!
is may work for some strings, as CPython interns certain strings or otherwise may end up with the same reference. But this is an optimisation strategy, an implementation detail.
Yes, == in Java is is in Python.
and object.equals(...) in Java is == in Python. So that's confusing.
@MartijnPieters ahhhh...
Thanks for clearing that up :)
I shall have an image in a blob in db, anyone here who has done flask-admin ImageUploadField support such?!
imageuploadfield by default stores filename only
hmmm...
guy wants normal distribution in range [0, 1]. That doesn't seem very normal to me :D
08:32
Cbg
I've got a shed load of data which i'm using as training data to model a few supervised learning models (neural net, random forest)

After splitting up im left with training data with ~3million records.. waay to large to chuck all into a model

can someone briefly explain or point me in the direction of some material on how to combat this please? I've seen batch training for neural nets etc but I'm unsure of the implications of splitting data into samples, wouldnt that create a bias?
@Daruchini I would be tempted to say you should have ask your question here -> ai.stackexchange.com
@AndyK wrong site
that's for some "singularity nutjobs"
@AnttiHaapala you think?
08:39
And as Antti mentionned, the cross validated stack exchange
or idk,
it seems they ask everything in ai...
For ai the list is
What topics can I ask about here?

If you have a question about...

    social issues in a world where artificial intelligence is common,
    concept/theory of AI,
    AI as an academic discipline/science, or
    human factors in AI development

...and it is not about...

    the implementation of machine learning, or
    asking for a development tool or career path recommendation

...then you're in the right place to ask your question!
Cheers guys thanks
 
1 hour later…
09:46
Cabbage
Cbg PM
@PM2Ring Cabbage
@Daruchini As Antti said, that question is off-topic here. But if you want to split your data with minimal bias, you can divide it randomly into a number of bins. Eg
from random import randrange
nbins = 100
bins = [[] for _ in nbins]
for x in records:
    bins[randrange(nbins)].append(x)
Hi, Andy. Bon matin.
10:05
@PM2Ring cheers
@PM2Ring Hi, yeh apologies, didn't realise. But thanks for your input that seems the most reasonable approach. I've been looking into batch training with SGD for optimisation. Thanks again :D
@Daruchini No worries. General basic algorithm questions, and questions about Python syntax are ok here, but it's better to ask specialized questions in a room that specializes in that topic.
10:27
@Ph03n1x same here. I got more fixated on the strings and didn't look at the actual comparison operation :|
10:51
Cabbage
12:11
@poke is
I forgot what I wanted to do… >_<
@Daruchini many people here are working with ML though, but you should go to the general ML (ie. stats first :D) and see if there is some discussion about the subject :D
the starboard is back to normal.
@poke aaand gone 😕
typo stackoverflow.com/questions/46932191/… : the good old missing self in method signature ;)
@vaultah huh
12:29
cbg
after 16 years there's scipy 1.0 \o/
Check out this awesome canonical on U&L: Why is Kali Linux so hard to set up? Why won't people help me? Vote early, vote often. ;)
@AndrasDeak after 16 years, scipy is python 3 only?!
no way for now
> This release requires Python 2.7 or >=3.4 and NumPy 1.8.2 or greater.
it's made for scientists by scientists, and a shameful ratio of computer clusters only has python 2
"If you need to ask, then Kali Linux is not the right distribution for you" sounds quite arrogant, even if it's the truth
just like "If you need to ask this question, you probably don't know enough about cryptography to implement a secure system" and "If You’re Typing the Letters A-E-S Into Your Code You’re Doing It Wrong"
12:44
@PM2Ring so how will I h4x0r?
@PM2Ring brb, installing Kali
inb4 kaali
@vaultah I guess it is a bit arrogant, but I doubt the average OP who asks a Kali question on U&L would even notice. ;)
A certain level of tolerance for arrogance is required when working with Unix anyway.
12:56
everyone's a git
I have a dumb question. suppose I wanted to pass arguments in the form of a dictionary, but didn't want to specify defaults. What's the correct way to do this? Normally I do:
class Blah():
  def __init__(self, name='some default'):
    self.name = name
U&L has a pretty high tolerance for clueless newbies, and it's generally easy to get help with Bash / awk / sed / perl stuff over there that would be closed as Too Broad on SO. But the quality of the vast majority of Kali questions is abysmal, so I can fully understand that the U&L regulars are fed up with it by now.
>>> def foo(x,y):
...     print(x,y)
...
>>> foo(2,**{'y':3})
2 3
@corvid ^
is that what you mean?
>>> foo(**{'y':3,'x':4})
4 3
I think that's it, yeah, but ideally I would just pass the dictionary in without the unpacking, is that possible?
I don't think so but I'll let others weigh in
what you want to do is exactly unpacking, so I don't see why you would want to remove that
13:01
You could create a dictionary with defaults, then update it with the actual dictionary
or just take the dict, and set self.<attr>=dct['attr'] inside...
but that would be way too dynamic for my taste
>>> def f(arguments):
...     defaults = {'a': 1, 'b': 2}
...     return {**defaults, **arguments}
...
>>> f({'a': 11, 'c': 3})
{'a': 11, 'b': 2, 'c': 3}
maybe I am doing it wrong because I usually use JS, but I think it feels very strange to use positional arguments over 2-3 long
that's fine, but why do you want to skip the splat?
@AndrasDeak Because he wants to pass the whole dict as a single arg.
13:08
sooner or later he'll have to name those args
I'm probably misunderstanding the use case
yeah so basically imagine a use case like JavaScript, you could do something like:
function createUser({ name, username, email }) {
  // ... whatever
}
ah
I don't think def createUser(name,username,email): along with createUser(**attrs) is any worse, but then again I don't use JS
and you could call it with an object, like createUser({ name: 'corvid', username: 'corvid', email: '[email protected]' });
just more clear when it's called, imo
"clear"? :P
I keep remembering this when it comes to JS semantics. And also this.
5
one thing I really hate in JS is that you can't catch specific errors
13:18
@corvid You can create keyword args without defaults like this:
def createUser(*, name, username, email):
    print(name, username, email)
And then you can either call it with keyword args, or with a dict:
createUser(email='[email protected]', name='Fred Smith', username='neo')
params = {'name': 'John Doe', 'email': '[email protected]', 'username': 'coolguy'}
createUser(**params)
#output
Fred Smith neo [email protected]
John Doe coolguy [email protected]
defaultUser = { 'name': 'default name', 'email': 'default email', 'username': 'default username' }
def createUser(**kwargs):
    user = defaultUser.copy()
    user.update(kwargs)
    return user

createUser(name = 'Fred')
# {'email': 'default email', 'name': 'Fred', 'username': 'default username'}
maybe it's just me but it's as if this was the second suggestion which ignores the whole "keyword arguments to my function" aspect
13:46
you know one exercise that's actually really hard is figuring out how to model data for a movie database
DSM
DSM
Another day, another "what the heck does corvid do" moment.
Cabbage for all.
I don't even know what I do
Why's it difficult?
Modelling movies in a database is easy - you start with the KevinBacon table and go from there
DSM
DSM
I'm now using keyword-only arguments all over the place.
14:04
@PM2Ring btw, thanks for that one, it solved it
my use case was basically a command to commit a pretty large item into the database using an ORM
14:22
What is better, “proficient” or “very good”?
Hey folks, does anybody knows how to use Flask-SQLAlchemy to bypass Date validation? I mean, I want to save a blank field to the database, but SQLAlchemy is preventing me by saying that I have to provide da Python date object...
@RicardoSilva Hi - paste the minimum code illustrating the problem into a pasting service eg pastebin
DSM
DSM
@poke: hard to say. They differ more in register than in meaning, I think, you don't typically use "proficient" in casual conversation.
It’s about requirements for a job. “Proficient in X; very good Y experience”
DSM
DSM
I guess I'd give proficient the slight edge, but I'd basically use "proficient at X" to mean "very good at X" as opposed to "familiar with X" or "passably competent at X" when writing in a formal context. Maybe this is a DSM thing, though..
14:30
hmm
rather confusing
I'd attibute connotations of some minimal level of mastery to "proficient" - so I would not necessarily say most teens/college students were proficient at driving a car, but I would also not say I personally am "very good" at driving a car.
THen again "proficient" is a very middling/passing term on a work evaluation, eg proficient/passing but not "exceeds expectations"
So it’s more “meh”
@RobertGrant Hey, unfortunately, I can't use those tools from within my company's network. But you can find the code here github.com/ricardolopes86/change-management-api.git in my github.
DSM
DSM
Ehh, I don't think it's "meh". It's skilled, or well-advanced. There's definitely adjective inflation on resumes, though.
I meant more meh than very good
14:37
@RobertGrant I just need to know how to bypass Flask validation to allow me to save a blank field in a Date field
@RicardoSilva please read our room rules, don't ask about your recent questions here
actually I was just coming in re: that
@davidism I am asking here because nobody understood the question and also didn't answer nothing beyond criticize me
@davidism including you
You need to reduce your code to an mcve. Most of what you've shown is not relevant to the question, and the code in general is a mess of seemingly unnecessary indirection. Carefully read the mcve help.
@RicardoSilva don't assume that they're doing that with no good reason. E.g. why on earth are you mentioning that you're using bootstrap-datepicker? How to make an MCVE.
Good morning everyone
14:44
@RicardoSilva one of the rules of SO is that you, Sir, bring clarity to your question.
@davidism man, the question is one and the answer should be as simple as the question: how to bypass the validation from Flask-SQLAlchemy to allow me to save a blank content into the table field
simple like that
Great, if it's that simple, then edit the question to be just that. See the mcve help.
@davidism +1
> why do you think this is not showing Minimal, Complete and Verifiable example?
@RicardoSilva because it’s far away from being minimal?
And also not verifiable because we have no idea what data comes in?
But in general the question is still pretty low quality. The code shows a pretty profound lack of understanding of your data.
14:46
@RobertGrant because I am using it in the view just to facilitate the user to input date
@RicardoSilva also, searching "sqlalchemy insert null" immediately returns this duplicate: stackoverflow.com/questions/32959336/…
Try to build a short example that just does what is causing the error. Use static input for that. There is really no need to have all that form data when your code is failing somewhere later. – Just focus on what is actually failing and include those bits that are required for it to fail.
Chances are, while doing that, you’re already solving the problem yourself.
But that’s how this job works.
Is it possible to pass a string, variable, or set of arg through a tag binding in a Text widget? something like txt.insert('end', 'hello', 'tagname', 'variabletopass')
14:53
my googles keep finding ways to do it with an object bind
nice, this is how you treat people with less knowledge than you
good to know
Fats Domino died (I like to be on-topic)
Hey, has anyone here used python's socket library before?
@tburrows13 hi :-) please read the room rules before asking a question!
Ah nvm
15:06
Anyone here have experienced this weird for loop phenomenon in python?
So basically I have a nested for loop of the form
for i in somelist1:
----for j in somelist2:

When I ran the whole program it give me an error. After debugging it using Pycharm, it is found somehow when i = 1st element, j is already assigned the 1st element in somelist2, thus when the execution move to the line where the j for loop is located, j jumps to the 2nd element in somelist2 and thus screwing up all the calculation inside the loop. What can be responsible for this skipping behaviour?
@RobertGrant That's a shame.
@Secret I guess that could happen if somelist1 and somelist2 aren't really lists, but are actually references to the same iterator. We need to see a MCVE to give an accurate diagnosis.
15:21
hmm... I need to figure out how to do a MCVE for this one cause the full function reads from 2 text files and somelist1 and somelist2 are made by using the comprehension over the lines read from those files
e.g. somelistfull = [line[i].split(",") for i in range(start +1, end)] where start end marks the lines which in between are two lines (thus a list within a list like a 2D array) and then somelist1=somelistfull[0], somelist2=somelistfull[1]
so the code is not easily reducibale to a MCVE since nearly every step involves readling the lines from the file, split it into entries with comma delimiters and then producing somelist1 and somelist2
Does it still do it if you hardcode a much smaller list?
That I have not try yet. Let me quickly code that up and see if it is reproducible with a smaller list harcoded
anyone ever used py paypalrestsdk ?
@Secret you should already be testing your code in this way, both manually and writing automated tests that can run every time
@RobertGrant omg!!!
the man was legend
15:35
cabbage
15:46
ok I think I have figured out what's going on. The program is working as intended. It's just when you set the break near the end of the loop in pycharm and then debug it, it has already ran through the 1st cycle, and so the loop is at the iteration where the exit code=1 pops up, and that is understandable, because for the 2nd iteration of the nested loop, the data to be extracted had not been placed into the files yet, thus it gets an empty list and then give error because of dimension mismatch
Initially, I thought the debug had not ran the loop hence I mistaken it to skip the 2nd element in somelilst2 when it gave the dimensionally mismatched 2D list
recbg for the afternoon
@Secret cool
jjj
jjj
cbg
So I guess the code should be working now. Hopefully it will be finished coding soon cause I need that code to reduce 500+ calculation jobs into just 20 clicks
how do people usually manage interpolated strings in i18ns?
15:50
@Secret given it's going to be important AND save loads of time when it's ready, I'd spend the time writing some tests.
I am really new to this automated test thing (in fact, I dont even know pycharm exists before my friend told me about it 2 days ago and Ihave been manually checking my code in notepad before then) I will see if pycharm have some nice tuts on how to set up a good automated test. The data is quite varied because they are molecules but the results are predictable so it shoudl be easy to create tests
Cool. It's definitely worth doing at least for key calculations, but it'll make everything faster
jjj
jjj
Molecules? Are you doing chemical computing or sth like that?
E.g. you could've written the tests for this code first, then coded it and seen it work every step of the way
So: " Merged warsaw merged 5 commits into python:master from toonarmycaptain:master 25 minutes ago"
15:56
jjj: Indeed, my PhD is on computational chemistry, and in the past half a year I have not really doing any actual chemistry yet besides collecting data and manually putting molecules and I am so fed up of manually inputting 200 molecules so I wrote a st of scripts in python and bash to sped things up 2 months ago. Now the project is in Phase III which involve more molecules per batch thus I am improving my code to handle the new data structure of these moelcules to send them to be calculated
The actual computational chemistry is already implemented in a software called gaussian, and the codes I have been writing just helps me to submit a lot of jobs in parallel easier (which is very boring because it is not chemistry and computer infrastructure is not a pretty thing to look at in a linux terminal)
I felt I have spent a lot of time just to submit jobs efficiently and not doing much comp chem
FWIW, many of the room regulars use Linux, and we actually like using the terminal...
I like the simplicity of terminals too, because they are fast, direct and you don't need to worry about some backgroudn process or special characters screwing your files, but I just don't like to stare at no pictures for too long
But yeah, it does help when you know how to do stuff with Bash & various standard *nix tools.
Having said all of that, I felt like there will still be one aspect of the computational project that I cannot automate, and it is involve a molecule viewer to measure bonds and angles with mouse. Unless I can somehow train a machine learning program to autofit a tetrahedral skeleton to the molecule and then multiclick all the measurements I need, then port these values to excel in a certain format, I have yet to figure out another way
jjj
jjj
I think I know what you mean, it can be really frustrating when most of the time you do preparation instead of the actual work. Chemical computing sound interesting though
16:03
Some of my friends and collegues suggest I should collaborate with some machine learning people and that they might have some idea on how to automate that data extraction step
jjj
jjj
Re measuring bonds and stuff: probably you've heard about it but can't rdkit do at least some of it?
@Secret What's your research focused on?
@Secret that sounds likely
16:07
The software our group are using to extract the molecule measurements is https://www.ccdc.cam.ac.uk/solutions/csd-system/components/mercury/ which is a graphical application. I have yet to find any information on whether it can do scripts similar to pymol. Also currently I have my data in excel because the raw data is measured using that software. If the machine learning plan or some alternative worked, then I will be able to get the measurements
directly and I can then code up a cleaner database instead of excel because it is getting a bit laggy due to the amount of stuff in it
@toonarmycaptain My research in focus on understanding a certain class of organometallic catalysis. In the first 1.5 year, I will be mainly using DFT calculations to investigate electronic and structural relationships, which is needed to establish a trend that guides the synthesis to be coming soon next year
@Secret That sounds messy. If you have XYZ coordinates of atoms then it's fairly simple geometry / trigonometry to calculate distances and angles.
OTOH, I guess you don't have that data, and you need fancy software to compute the actual geometry of your molecules.
Well, we do have xyz files (because gaussian gives xyz outputs as well many others), The issue is that what we need to compute is not just bond angles lengths and torsions, but a few parameters related to intersecting planes. Those can be quite hard to code
@Secret Sounds interesting. Derek Lowe was writing something about using computers to figure out custom catalysts awhile back. I don't know if that's what you're working toward?
I think not that sophisticated. Just like the drug discovery groups, we put different ligands onto the molecule and see how the electronics affect the geometry and relative stability of the enantiomers (because the class of catalysts we are working on are chiral metal centre catalysts.
But I think those guys are trying to use some kind of searcing algorithm to find reaction paths to find an optimum catalyst. For us I think we are not quite that level of automation, but just usual transition state reaction studies
It will be cool if we can get to such level, though. Imagine being able to scan through the potential energy surfaces with the tools of machine learning and find viable reaction pathways to further study without too much reliance on chemical intuition
and there are internal groups like Dial A Molecule have mentioned about how chemistry is in need to be able to search and handle reaction data digitally and urge synthetic labs to collect as much reaction pathway data as possible
16:26
@Secret I think "everyone" wants to get there. That's kinda the dream, right? Oh we have this drug we want to make, target we want to hit, reaction in the body we want to affect: "Computer, make me a catalyst to do just that."
Machine learning had already been incoporated in many science and business fields, but chemistry is still in need to catch up with this digital trend
It is nice how in recent years there are now many companies and universities have built microreactors to automate chemical synthesis thus allow simultaneous probing of many structural reactivity relationships in a small space with minimal waste
so I think chemistry will soon caught up with the others very soon
Quantum computers are also expected to be a big thing in both chemical and biomolecular researches because they have the promise to tackle very difficult reaction pathway calculations and complicated protein calculations
One of the issues frequently mentioned is the mess in the literature, false results, outright frauds, irreproducible results. Sorting through that to get legit data to feed into an algorithm seems to be the limiting step. So if you can figure out how to do that from raw data or computational results rather than relying on the literature, that would be an amazing breakthrough. Either that or find some way of sifting through those papers using some sort of algorithm...
... but that sounds far fetched at present.
17:21
Is argparse still the defacto standard for parsing cli?
Why wouldn't it be?
I remember there being other competing libs...been a while since I wrote a Python command line tool
17:50
@toonarmycaptain from master? Uh-oh! :P
I have a Numpy array of 2D coordinates. I'm using the following code to create an array of the squared distance between each pair of points. Is this ok, or is there a better way, eg some standard Numpy function?
np.sum((points[:, None] - points) ** 2, axis=-1)
scipy.spatial.distance.pdist or cdist
otherwise use .sum() and it'll be fine
ModuleNotFoundError: No module named 'scipy'
you should also try np.linalg.norm squared with an axis kwarg, might be faster
or even better: rewrite it to have a dot, in case that's possible
A = points[:, None] - points
A.dot(A.T) # <- is this not your answer?
@AndrasDeak Oh, I didn't realise there's a .sum method :oops:
@AndrasDeak Give me a sec...
18:04
sure
in case that works, .dot is probably fastest (unless the transpose messes with performance)
@AndrasDeak Was that wrong? I'm not real up on github. PR got accepted and merged though.
@toonarmycaptain well, using master on your local repo might mess with a few things, for instance if you pull the upstream master by mistake in the middle of your work. Some projects explicitly suggest deleting your local master branch :)
@AndrasDeak No, that doesn't work. I've reduced the number of points to 10. And I get this error: ValueError: shapes (10,10,2) and (2,10,10) not aligned: 2 (dim 2) != 10 (dim 1)
but congrats on the merge, that's what matters!
@PM2Ring ooh, 2d arrays! Yeah, that won't work
you could reshape temporarily
@AndrasDeak points.shape is (10, 2). Should I organize my data differently?
18:09
no, I'm probably being stupid
give me a sec :)
OK, at least np.linalg.norm**2 works
yeah, I can't dot this
It's only a minor concern at the moment. I'm working on a graphics thingy, and I thought I could do something useful by finding the nearest neighbours of each point in a set of random points, but it didn't pan out. So I'm now trying a radically different approach. But I figure I may have some use for this further down the track. So I'll try np.linalg.norm**2
might not actually be faster, but worth a try
there are also scipy libraries for building delaunay triangulations and whatnot...
DSM
DSM
Squaring the norm feels weird, because then you're just undoing the sqrt. Maybe in Python the whole thing doesn't matter because of overhead, but in C it would be weird.
18:16
scipy.spatial.distance.cdist(points,points,'sqeuclidean')
what I'd use ^
Yeah, I don't really need the squared distance, the proper distance is actually better. I was just using the squared distance to avoid calculating all those square roots, since I only need the actual distance to the nearest neighbour.
DSM
DSM
I'm lazy enough I'd use an off-the-shelf tree for that.
In [9]: %timeit np.sum((points[:, None] - points) ** 2, axis=-1)
27.3 ms ± 405 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [10]: %timeit ((points[:, None] - points) ** 2).sum(axis=-1)
27.2 ms ± 306 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [11]: %timeit np.linalg.norm(points[:, None] - points,axis=-1)**2
31.3 ms ± 535 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [12]: %timeit scipy.spatial.distance.cdist(points,points,'sqeuclidean')
2.82 ms ± 31.4 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
timings for (1000,2)-shaped points
and the scipy ones are correct too, I checked
On my machine with 500 points there's no significant speed difference, although np.linalg.norm(A, axis=-1) looks slightly slower, but that's just using the Bash time builtin, so there's the other overheads of creating the random array of coords. But I must admit that your scipy.spatial.distance.cdist speed is impressive.
@AndrasDeak You're saying I should have created a branch first and done the pull on my "pepedit" branch? I think I did that but merged it with my master before pulling.
18:25
@toonarmycaptain ah! You don't have to do that: if you push your feature branch to your remote github repo, it will automatically show you a banner that offers to submit a PR :)
DSM
DSM
But if you only need the nearest distances, I think we can do even better:
In [73]: %timeit scipy.spatial.distance.cdist(points,points,'sqeuclidean')
7.76 ms ± 251 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

In [74]: %timeit scipy.spatial.cKDTree(points).query(points, k=[2])
1.6 ms ± 40.7 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
yeah, that's partly what I had in mind with my Delaunay remark earlier, but mostly because this subject is a huge jumble in my head
I very briefly encountered KDTrees related to rbf interpolation in scipy
DSM
DSM
I spent a good bit of my graduate work dealing with trees and grid codes, so I'm getting flashbacks. :-)
:)
I didn't know you had green fingers
@AndrasDeak Thanks :)
18:30
@AndrasDeak Oh, I missed your previous remark about Delaunay triangulations! But yes, my project is related to Delaunay triangulations and Voronoi diagrams.
@AndrasDeak I don't remember seeing that, but then I was using github in the browser, not the desktop.
I do that too, always in the browser
I'm trying to plot a bunch of random non-overlapping discs with random radii. I figured out a crude slow algorithm for doing that, back in the days of the Amiga. But I can't remember exactly how I did it, and I'm sure there's a better way. :)
@PM2Ring in solid-state physics we call the Voronoi construction "Wigner--Seitz cells" which is cool because Wigner was my countryman
@AndrasDeak Ah. I didn't know Wigner did stuff with the Voronoi construction. I've never delved deeply into doing Voronoi constructions myself, but POV-Ray has a Voronoi function that I've used in some of my ray-tracings. Eg this floor:
18:37
neat :)
I don't know how much he did with the construction, but the construction pretty naturally emerges in condensed-matter physics
Thanks! The code that solved the polynomial tiling I wrote ages ago in C. Doing that kind of recursive backtracking is a lot easier in Python, although the C code is somewhat faster. ;)
faster shmaster
Hello, everyone! I was writing some recursive code at work today when my co-worker advised me against that.
well python's not particularly well-suited for that
Is there anything wrong in writing recursive functions in Python?
Oh my, that's new. If I may ask, why is that?
18:43
I just had a look at the source code. I wrote it in July 1998, on the Amiga. I guess I could update it to use more modern C features, but hey, it works. :)
there's no tail recursion optimization, all of the call frame is kept with each recursive call
so you can run out of stack
unless you use stackless Python maybe. Though I'm not sure about that
And Python frames are a lot chunkier than C's very lightweight call frames.
I hope they do fix the recursion thing in the upcoming versions
by default there's a limit of like 10k, I think it is. You can find it out:
> python3 -c "import sys; print(sys.getrecursionlimit())"
1000
18:45
So it's generally a Good Idea to avoid recursion in Python unless you're doing stuff that really benefits from recursive code, like processing recursive data structures.
Yeah, I am traversing a tree and it would be a pain to actually not use recursion
Polling the room: multi line, multiline, or multi-line?
shrugs whatever I feel like at the moment
@thatrockbottomprogrammer as long as your tree is less-than-1000-deep then you'll be fine
As a speaker of the german language I vote for "multiline" (we like long words)
18:46
though I would go with multi_line
@thatrockbottomprogrammer You can easily set the recursion to a higher limit if you really need it. 1000 is generally adequate, and it's useful if you accidentally run broken code that wants to recurse to some ridiculous depth.
I have often run broken code that tries to recurse too far. Usually of my own making.
I don't think the data structure is big enough to go 1000 in depth
If your trees are deeper than 1000, Python's recursion limit is probably the least of your worries.
It might consist of some 50k nodes in all, but 1000 in depth rarely occurs
18:48
I don't mean as a variable name, I meant by convention in written usage.
In writing, I'd go with multi line
@thatrockbottomprogrammer Guido has no intention of giving Python tail call optimization - it would stuff up the traceback, making broken recursive code harder to debug.
@toonarmycaptain multi-line
I also vote for multi-line.
Every variation seems to exist in the documentation - it's not even consistent in single PEPs
18:50
meh
what's the worst that could happen? run out of memory?
I mean, is that the impact of all this chit chat about frames in python vs C etc
>>> def foo(): return foo()
...
>>> foo()
  File "<stdin>", line 1, in foo
  File "<stdin>", line 1, in foo
  File "<stdin>", line 1, in foo
  File "<stdin>", line 1, in foo
  [...]
  File "<stdin>", line 1, in foo
  File "<stdin>", line 1, in foo
  File "<stdin>", line 1, in foo
  File "<stdin>", line 1, in foo
  File "<stdin>", line 1, in foo
  File "<stdin>", line 1, in foo
  File "<stdin>", line 1, in foo
RecursionError: maximum recursion depth exceeded
@user3431083 Yes, lack of TCO does mean that recursion in Python uses more RAM. But the other thing is that Python function calls are relatively slow, so if they can't be magically converted into while loops then a recursive version is measurably slower than equivalent code that does use a while loop.
strictly speaking a RecursionError is the worst :P
How about this ?
However, you could also follow the unconventional method of increasing the recursiondepth
18:59
or use lisp
@thatrockbottomprogrammer As the author says "I would not consider this a useful technique in itself, but I do think it’s a good example which shows off some of the power of decorators."
DSM
DSM
Which we should frankly be doing anyway.
@thatrockbottomprogrammer THere's nothing wrong with changing the recursion limit. But I've rarely needed to do that. FWIW, despite what I said about avoiding recursion I often do write recursive code in Python. I'm rather fond of recursive generators. ;)
A couple of months ago I was doing quite a bit with recursive backtracking. I never hit the recursion limit, but I did have to kill some of my runs due to them chewing up large amounts of virtual memory looking for a solution that probably doesn't exist.
Ah mine is going to run under a REST call, so hopefully the memory should be cleaned out by the gc
19:16
Can you implement the recursion in Python and see if memory or speed is a problem and then if and only if it is, tackle the issue
@AndrasDeak Why not both? github.com/hylang/hy/blob/master/docs/contrib/loop.rst @thatrockbottomprogrammer
So, in summary, there's no need to be paranoid about using recursion in Python when it's appropriate for the problem domain. Just don't use recursion when you can easily write a non-recursive version.
In many situations, you can give your recursive function a cache. That way it only recurses if it hasn't previously done that calculation.
@user3431083 if doing twice the work sounds fun to you, then by all means :P
but when you realize that you've shot yourself in the foot with recursion, you won't say "perhaps I should go to a hospital and take on golfing as a new hobby". You'll go "I need a better scope for my AK-47"
20:14
@AndrasDeak is this better?
looks great :)
I take it you found the banner
you have a typo in your comment: "apitalization"
when the PR gets merged, github will automatically offer you to delete your remote feature branch, as it's no longer needed
Fixed!
I don't think I understood what you meant by banner, but I saw where it said "create pull" when viewing that fork. :)
sorry, I probably wasn't clear enough
Nah, I'm just not familiar with some terminology - I was thinking banner like a banner ad, or a popup, something highlighted.
I meant it as a banner like a banner ad, something highlighted :)
that beige note stands out pretty well to my eyes
20:23
Fair enough
20:40
What a terrible day.
won't argue with that
Python didn't help either.
that might not be python's fault ;)
No but First I try to build a python extension. unrecognized compiler version So there I am first thing this morning modifying my python installation so it recognizes my C compiler version (I recently updated Python installation).
Not that I'm complaining but honestly. It does not recognize MinGW versions after 16 (its 19 now) when was that python last updated?
what is "that python"?
20:48
sorry I meant the file. Wait a second I'll get the name
one of Gohlke's wheels?
Oh no. The compiler for python extensions in C.
That's it cygwinccompiler.py yes but I use that for MinGW as well.
Actually it may be but I think it's included with the installation. (still need a c compiler though)
Yep I could go on. Searching for a good GUI. Looked at both GTK and Kivy -both were epic disasters
Is GTK+ even updated anymore?
01:00 - 21:0021:00 - 23:00

« first day (2566 days earlier)      last day (2607 days later) »