« first day (3284 days earlier)      last day (1647 days later) » 

12:06 AM
Quick Survey, which ML framework do you use? I use Tensorflow
 
 
7 hours later…
7:18 AM
@roganjosh yes, and yes
14 hours ago, by roganjosh
@ReblochonMasque Does it have the same meaning? Are there multiple variances like clemence/clemency
 
8:05 AM
@smci that's the one and same close reason. An MCVE is mostly mandatory for debugging questions.
 
Guess the output...
def func(arg):
    print(arg)

p1 = functools.partial(func, arg=1)
p2 = functools.partial(p1, arg=2)
p2()
 
8:35 AM
@AndrasDeak IIRC, smci's objection to debugging questions is that they're too localised and therefore unlikely to help others, unless it's a common bug that most users of that language or framework are likely to encounter. However, "Too Localized" hasn't been an official close reason for several years. And if the bug can be isolated to a MCVE then there's a good chance that the answers can be educational to a wider readership than just the OP.
@Aran-Fey :tosses an imaginary coin: 2, but 1 wouldn't surprise me. Or SyntaxError: keyword argument repeated
 
that's a lucky coin you've got there. I honestly expected it to throw an exception
 
I've never been a fan of functools.partial, and I'm not that familiar with its quirks. If I want currying, I'll learn Haskell. :)
 
I'll tell you another reason to dislike it: it checks if the callable you passed is a partial object by doing if hasattr(func, 'func'): rather than if isinstance(func, partial):
fortunately the C implementation from _functools is a bit better than that though
 
@Aran-Fey Well, 2 looks like the least surprising & most useful result. And you never get SyntaxError at runtime, except from eval'd or exec'd code, when it's essentially a compile-time error that occurs during runtime.
 
repeated keyword args usually throw TypeError though AFAIK
 
8:44 AM
@Aran-Fey Hmmm. That's not very duck-type-ish, but I suppose that's tolerable when you need to do the things that partial has to do.
@Aran-Fey Oh, ok.
 
Well, a proper implementation would check for func and args and kwargs attributes rather than checking only for func and then crashing with an AttributeError if args and kwargs aren't also present (:
 
@Aran-Fey I'd have expected 2
If I have def foo(kwarg=42) I want partial to be able to overwrite that
 
Hmmm, I guess if you look at it like that...
 
The doctrine of Least Surprise implies that if an ambiguous interpretations is possible, then the convention should implement the more useful interpretation.
Similarly, the convention in algebra is that a^b^c means a^(b^c) not a^(bc), because if you want the latter you can easily write it.
 
@PM2Ring .. and imports of modules with syntax errors in them.
that was the most horrifying real-life bug I ever encountered in a project as of yet
 
8:53 AM
@Arne Yeah, ok.
And that's a good reason to put your imports at the top of the script so all that stuff gets resolved before your local function & class definitions get executed.
 
a module with pre processing functions got loaded not at the top but within the main preprocessing function. Some chucklehead put a bare try..except around it, with the reasoning "if preprocessing fails, we will just use the raw input". And I was tasked with finding out why no preprocessing took place. You guys should have seen my face when I debugged the section and saw the the excption that got caught ignored was a syntax error in one of the prerpocessing funcs
 
@Arne I think you're legally permitted to punch people who do stuff like that. :D
 
he was my boss =/
@PM2Ring word
 
@Arne That does make the situation delicate. ;) What was in the bare except block. Please don't say pass...
 
@PM2Ring ok, I won't say it
 
9:02 AM
:D
 
🙈 🙉 🙊
 
9:23 AM
morning cbg
anyone got any thoughts on switching from idle to pycharm (community)
 
switching away from idle is definitely a good idea
 
welp
thats that then
 
 
3 hours later…
 
2 hours later…
2:30 PM
hi, is it possible to decrease to number of digits in calculation?
I am writing an abaqus script. the values have over 12 decimals.
this causes my model not to be precise and nodes are not in the same position when needed. they have inclination.
I need all numbers to be in 2 digits precision, like: 0.12 instead of 0.1200012522652
 
decreasing the number of digits usually decreases the precision
 
my input is like this: 750.1
 
do you know about floating point arithmetic?
 
but i have calculation over the input values, and this imposes huge decimals
 
@EnthusiasticEngineer for computing or printing? Huge difference.
 
2:32 PM
@AndrasDeak for computing
and my python is version 3.7 and abaqus 6.14, if it matters
 
make sure you familiarize yourself with Arne's link
 
Does Abaqus use standard python floats?
 
This one might be easier to digest: docs.python.org/3/tutorial/floatingpoint.html
 
Hmm, abaqus seems like a computer-aided design program. I have no idea why someone would want to reduce precision.
 
im willing to bet this is actually currencies again
 
2:37 PM
but I only know how to print fewer digits reliably, so I'll defer to the others
 
@ParitoshSingh i have lots of values... should i format them separately? I think in fortran we can decrease significant precision in the whole document
since we define parameters in the beginning of the program.
 
@EnthusiasticEngineer have you taken a moment to read the link? Just go through it, really.
 
but regardless, i think you can benefit from how currencies should ideally be handled in systems. Once you learn about the issues with storing floats, you should realise that the ideal solution here, if you only want 2 decimal precision, is actually to get rid of floats for calculations entirely. Just work with a smaller "unit" of ints, and keep track of only using int perhaps.
 
I guess one might be able to use mpmath with mp.dps = 2?
 
2:40 PM
@AndrasDeak see... when precision accumulate, sum together, they cause insignificance in the program.
@ParitoshSingh i am reading it.
 
That way, you bypass the floating limitations by just working with whole numbers.
 
@EnthusiasticEngineer but unless we're only talking about addition and subtraction the truncation during calculations will introduce more errors, but they will be hidden.
 
Yeah, rounding off during calculations, and then using that intermediate result for further calculations should definitely have bigger errors
 
I think I should simplify my input values to get rid of these calculations which cause such insignificance
 
it's not like bigger values can be represented more precisely by floats
so it'll probably change nothing
 
2:44 PM
Just to be clear: does rounding the end results to 2 decimal places not solve your issue?
 
@AndrasDeak I have continuous calculation steps. how may I round the results in each step?...
@ParitoshSingh "...to get rid of floats for calculations entirely" how?
 
if you have full control about the calculations that lead to your results, you can use decimals instead of floats docs.python.org/3.7/library/decimal.html
but doing math with them is a lot slower, so i hope it isn't anything intensive
 
@EnthusiasticEngineer im scared to continue my line of thought because im afraid of giving you ill advice. Im having a hard time figuring out what exactly you're trying to calculate, and whether your calculations, when given a whole number as a starting point, ever generate floats or not.
 
@EnthusiasticEngineer when I said "end results" I meant end results. The step where your things don't align
 
@ParitoshSingh it generates floats...
 
2:48 PM
Arne's decimal.Decimal suggestion is a good one, that will rid you of imprecision and either work for you or prove some fundamental flaw in your requirements.
I'd try that.
 
@AndrasDeak It may work... I should round end values in each step.
 
just watch out:
In [19]: Decimal(750.1) == Decimal('750.1')
Out[19]: False
@EnthusiasticEngineer I doubt it, but I'll take your word for it
 
@AndrasDeak that's evil, I had no clue. So it's both slower as well as a little insane
 
@Arne you're reading it wrong. It's floats that are insane.
In [20]: f'{750.1:.50f}'
Out[20]: '750.10000000000002273736754432320594787597656250000000'
 
@Arne the lhs is forced to coerce a float. it's already too late by then
definitely won't count that one against Decimal.
 
2:51 PM
@AndrasDeak this is exactly what i face!!!! how those decimals are produced, by changing binary values causes this harm to my code!
 
you really haven't read the link. :P
or taken the time to grasp what it's saying in any case
computers work in binary. you just cant accurately store all floats (that are base 10)
 
@ParitoshSingh my programming knowledge is not as well as programmers here... I am a civil engineer... sorry if I have little understanding of the whole discussion.
 
It's okay. that's not an issue.
My recommendation still is to just read that link, go through it slowly, at your own pace. You have an issue you need solved, so get digging. Im sure you'd do the same if you had an issue when working on a project related to civil engineering.
 
@EnthusiasticEngineer another link for you: Is floating-point math broken?
 
@ParitoshSingh :) I am working on a research structural engineering modeling in abaqus, and I am trying to make it parametric by python scripting. this will really help me for my future modelings.
 
2:55 PM
you don't have to be a good programmer, but if you use computers to do work with numbers it's essential that you understand the limitations of floating-point arithmetic
 
That one might be the simplest to read, the link that Andras sent
 
The reason why we're beating about the bush is that you often can't "just fix" the problem.
your requirement might be fundamentally flawed to an extent
 
^ and you have to be the one to tell us that.
 
I promise I will read all the links :))... thanks all
@ParitoshSingh of course, I will tell you what I do.
 
no problem, good luck
 
2:58 PM
for what it's worth, i thought it was some kind of sorcery when i first ran into this issue.
it makes a lot more sense once you read about it though.
 
I was finished with my model, but when I zoomed to assign my loads to the points in my model, I realized that the points are misplaced due to this precision issue.
 
@AndrasDeak ohhh, now I see the missing quotes
 
i also realise ive forgotten what should the right term be for that kind of type conversion. I use the term coerce/typecast but vaguely recall that those terms are technically not correct here
 
@Arne :P
@ParitoshSingh coerce maybe, typecast probably not
 
I see. is there any different term that you would use here by any chance also?
 
3:09 PM
Coerce is probably right. It typically means when a variable's value is changed to fit another type. Like adding 0.0 to an int will coerce it to be a float. What's happening here is that the real number 750.1 can't be represented exactly as a float, so it gets converted to the nearest valid float. Which I think is the same thing.
 
ok, just wasn't sure if it would be implying something different to other people in a manner that would make it wrong
i'll stick to coerce then!
 
not that I'm an authority on the matter :P
 
1 external opinion is infinitely/undefined-ly times better than none!
i dont even think that's a word!
 
3:40 PM
@Arne Ah. Yes, initializing Decimal or mpmath numbers with floats is almost always a bad idea. You can only do it safely if the number is an integer, or an exact binary fraction (i.e, as a rational number its denominator is a whole power of 2). So the decimal & mpmath docs urge you to do such initialization using a string, not a float.
There's even been suggestions that it should raise a TypeError to initialize a Decimal with a float, but people objected that would be inconvenient, and bewildering to newbies who haven't read the docs properly, or misunderstood them. My opinion is that it should be a TypeError.
 
i generally like it when things complain rather than silently breaking expectations. At the same time, i think things should be able to accept and convert datatypes that i expect them to be able to consume. This would put Decimal module specifically in a tough spot.
 
3:59 PM
That would leave the real gimmicky magic of cutting off float decimals after two or so zeroes, thus leading to fulfilled expectations everywhere, plus one bug out there that is going to drive everyone who tries to fix it literally insane.
 
 
2 hours later…
wim
5:36 PM
Stack Experiment Off - Turns off the voting experiment <--- shows true vote totals on pageload and after voting
 
First time to use assignment expressions, in update to this answer: stackoverflow.com/questions/2554185/match-groups-in-python/…
I find myself reading the walrus operator as "which equals". "if m, which equals re.match( etc....):"
 
wim
@PM2Ring not exactly true...
raise SyntaxError # syntactically valid code that raises a syntax error 😏
 
6:11 PM
cbg
anyone got any idea why my k means implementation is being weird?
http://dpaste.com/2NE8WNF
any help appreciated
 
side note: that's a weird way to initialize your data
are you intentionally avoiding ready-made kmeans implementations?
 
how did you guess
how else would i initialise data?
 
unfortunately that's too much random code for me to crawl through to find a bug where the only thing I know is "being weird" and the only thing I see is "I have a point in between the two clusters"
 
tbh i dont really know what its doing exactly either
the 2 centroids seem to move towards eachother into a point between the 2 clusters
 
@3141 a = (np.random.normal(0, 0.1, size=(2, size, k)) + np.arange(k)).reshape(2, -1)
total = total/len(arr) <- you have a division by zero here
perhaps from return temp[w,:int(count[w])]
the rest is left as an exercise to the reader
 
6:44 PM
I just chased a bug where a link on a page didn't work for an hour or so an was going mad wondering why none of my fixes was working. You're welcome to guess what the issue was, but you can probably just reuse the answer from the last time something like this went wrong.
 
cache? :P i always blame the cache now
 
that's a bingo. A lesson I will some day hopefully learn
 
oh haha, that url is awesome. i'll have to use it from now on!
 
I think I saw it posted in this chat the first time I saw it
 
7:07 PM
The fine print makes it even funnier
 
7:40 PM
sorry andras i was afk, but thanks for the help :)
 
7:56 PM
no problem
 
8:17 PM
@3141 I was fun of pycharm until I tried VS code which is brilliant. Give it a try.
 
whats better about vscode?
 
VS code is simpler and the interface is arguably more attractive but I prefer pycharm for its builtin python console and easy interpreter management with python virtual environments
Another benefit of VS code is that the free version (it might only be produced as a free version) integrates well with remote server development while pycharm forces you to buy the propriety version to enable server dev features, it is worth expense I'd say
 
8:56 PM
VS stands for Visual Studio stands for MS so you bet it's not typically free
 
" Free and built on open source. Integrated Git, debugging and extensions." It is, this is from the site
Which is surprising coming from them
The other thing that microsoft does that is free and awesome is Microsoft ICE. This is what we used to stitch our drone imagery early on until we discovered open drone map
 
9:17 PM
VS Code is nothing to do with VS the product, and is certainly free (though I hadn't realised it's open source).
 
@holdenweb really?
> Developer(s): Microsoft
OK, at least not that much
 
I believe so. You do realise that MS employs Python core developers nowadays?
 
you mean MS is seeping into python development? :PP
 
Its the old microsoft embrace, extend, extinguish strategy
 
user6568562
9:32 PM
Microsoft is the new Google, Google is the new Microsoft
 
user6568562
And Apple is the same old Oracle
 
10:09 PM
haha
 
11:03 PM
Hi, guys! I'm developing a web application using Django that has to deal with slow HTTP queries to some API, and due to synchronous nature of Django, it freezes all the back end... Is it possible to overcome this problem?
Maybe it's possible to simply run multiple instances of Django simultaneously? So, while some ones waits for IO, others handle other website users.
I know that the problem can be easily solved using such tools ascasyncio, but Django doesn't support it, and I need Django to validate that user is authorised correctly before using that API.
Also, I cannot query the API in background (e.g Celery) because the user needs the API query results.
 

« first day (3284 days earlier)      last day (1647 days later) »