« first day (2935 days earlier)      last day (2238 days later) » 
05:00 - 23:0023:00 - 00:00

05:10
hello
suppose, vec is a vector, what does vec[:,0] mean?
vec[:] is list slicing, but vec[:,0] really got me.
05:21
@ThirstyLearner I believe you are using numpy? this might be relevant I think
@Jerry I'm reading someone's code. Yes, he imported numpy. Here is the code:
class Normalizer(object):
def __init__(self):
    self.mask = [ 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 ]
def norm(self, number):
    data = map(lambda m: 0.9 if number & m else 0.1, self.mask)
def denorm(self, vec):
    binary = map(lambda i: 1 if i > 0.5 else 0, vec[:,0])
    for i in range(len(self.mask)):
        binary[i] = binary[i] * self.mask[i]
    return reduce(lambda x,y: x + y, binary)
I'm struggling to understand what he is doing: he wants to change a number (an integer) into a 8X1 array containg only 0.9 and 0.1, and offer function to decode such a vector back into a corresponding integer.
06:03
@Jerry thank you Jerry. I read the numpy manual. Still don't know what [:,0] means. Something similar is x[...,0]. It seems to decrease dimensions. Lack of descriptive and well-organized manuals is a difficulty for new ML students.
I went back to the homepage and found this: docs.scipy.org/doc/_static/numpybook.pdf
go to page 23 section 2.2
I think it's clearer
I haven't really used numpy myself before, so I kinda took that opportunity to read about it a bit
06:19
@Jerry I tested it out. [:,0] means to choose the first element of every vector in a matrix.
>>> x = np.array([[[1],[2],[3]], [[4],[5],[6]]])
>>> x[:,0]
array([[1],
[4]])
it's kind of dimension decreasing...
yea so it will really depend on what kind of vector the user is creating in the first place
I suspect it might be a (1,1) vector such as [[0],[1],...,[7]]
thus one won't need to bother with anything other than the 0th index
It has to be at least 2 dimensional:
>>> x=np.array([[1,2,3]])
>>> x[:,0]
array([1])
oh sorry, I actually meant (8,1)
the was thinking 'one column, one column' when I typed the above
should've been '8 rows, 1 row'
>>> x = np.array([[0],[1],[2],[3],[4],[5],[6],[7]])
>>> x[:,0]
array([0, 1, 2, 3, 4, 5, 6, 7])
you could say it's flattening the array
how I'm seeing this is that map(lambda i: 1 if i > 0.5 else 0, vec[:,0]) is roughly equivalent to map(lambda i: 1 if i[0] > 0.5 else 0, vec) if vec is of size (8,1)
*of shape
06:44
Yes, you are right. Thanks. You are very cool.
07:04
@Tanuj You can always check your recent conversations
cbg
 
1 hour later…
08:27
cbg
If you guys clean up a question or answer, do you delete "thanks", "you're welcome" and the like, or do you leave it in there?
Human beings show gratitude. It's never too polite.
I usually remove it, unless the question is so awfully short that "Any help is appreciated" makes up 20% of the text
@Arne usually clean it up
(unless you think it might offend OP in some way, if unsure, just leave it be)
Clean up unless contextwise unwise, got it.
@ThirstyLearner I also like to say thanks, but only in comments. I think it makes the Q-A pair more readable, but I wanted some opinions if that's just me.
08:54
I also remove social fluff
@ThirstyLearner for a 3d numpy array you can fetch an element with arr[i,j,k]. What a colon does is slice along a dimension, just like a slice in a list. So arr[i,:,k] is a 1d array whose elements are [arr[i,0,k], arr[i,1,k], ..., arr[i,arr.shape[1]-1,k]. You can have multiple slices, like arr[:,j,:], and for "slice all the remaining dimensions" can be written as ... short-hand: arr[...,k] for arr[:,:,k].
And there's an entire section of the docs about indexing. Perhaps ML students should spend more time perusing the documentation
09:24
@AndrasDeak social fluff omitted. point taken. By the way, can python operator * multiply array? I saw this code snippet. sum() can be used only on iterables:
return 0.5 * ((label - output) * (label - output)).sum()
where label and ouput both are 8X1 array
It can multiply a numpy array, but not list.
people tend to call lists arrays, hence my phrasing
.sum() can only be used on numpy arrays or similar. Built-in sequences don't have a sum attribute I think
09:40
sum() is a python built-in function but it can't operate its own data types. It works only for numpy arrays. The logic of ML world is entertaining.
What? no.
>>> sum([1, 2,3 ])
6
>>> [1, 2, 3].sum()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'sum'
If you read the documentation with as much attention as when reading my messages, no wonder you think numpy is at fault
if you want to do machine learning in python, go in this order: learn python -> learn numpy -> learn ML using numpy
If you skip any of the steps you'll be frustrated, come here, and make us frustrated too for no reason. Walk before you can run.
10:15
too broad (requirement dump), 1 vote needed stackoverflow.com/questions/53042823/…
10:38
Cabbage
Could someone with pyqt try running this? stackoverflow.com/questions/53032259/… I don't know pyqt, but I made a guess of the cause of the problem, and proposed a dupe target, but didn't hammer it, since I wasn't sure. But it got closed, and the OP changed his code to a MCVE (I think), and claims my suggestion & the dupe target don't solve his problem.
The problem is definitely that lambda.
I'm happy to un-hammer it, if the problem really is different. I suspect that the OP simply needs a little help to apply the solution. And if that can be done in a brief comment, I'd rather not re-open.
I want to help the OP because they made the effort to reduce the original huge code dump to a MCVE.
12:00
cbg
12:15
@malan I'm way late, but: If you're confident that your program will only be executed by Python 3.7 or later, than you should feel free to rely upon dict insertion order. Now that insertion-order-preservation is part of the Python language specification, you can assume that all modern implementations of Python will abide by it, and that it won't change in the foreseeable future. Such a change would be as tumultuous as the 2.7-3.X schism, and nobody is in a hurry to experience that again.
It was weird that they made it part of the language spec
(ok, if insertion-order-preservation was the only change that they undid, then it wouldn't be that tumultuous. It would be more like "we're not mad, just disappointed". Reneging on language spec changes is a violation of trust even if it doesn't have that much practical impact)
(but if 2.7-3.X is any indication, then if the devs do want to renege on specifications again, they'll save up a whole lot of them and unleash them all at once, in which case it would be tumultuous)
12:30
Any opinions on the closure of this question? Neither the question nor its answer strike me as very useful, but I can't really explain what makes the new question more useful than the older one...
I guess the difference is that the child class __init__ has a different signature, but is that reason enough to reopen?
I wish Windows had a global "don't prompt me with update notifications, maintenance scan results, or anything else that may obstruct the active window" setting. I'm trying to write an automation project that clicks a button every fifteen minutes with no human oversight, and a "reboot now? y/n" prompt in the wrong place could be disastrous.
@Kevin It seems that in the past I've used a package called ptfb, in which you could target a button in a specific window, regardless of any popups that might overlay it.
It has been a while though, so I'm not sure of its current status
Hmm, interesting
jpp
jpp
I flagged this answer to have it moved to one of the duplicate posts. But a mod said the questions were different. I struggle to see why :S. Can anyone enlighten me?
How do I, using regex find and replace, place a comma in between the digits in the following:

y_test = np.array([[0 0 1 0 0 0 0 1 0 0 1 1],
 [1 0 0 1 1 0 0 0 0 0 1 1 0 0 1 1 0 1 0 0 1 0 1 0 0 1
  0 0 0 0 1 0 1 1 0 1 0 0 0],
 [0 1 0 0 0 1 0 1 1 0 0 0 1 1 0 1 1 0
  0 1 0 1 0 0  0]])
12:36
@SebastianNielsen I think you'd be better off just converting that object into a list of lists, at which point it will have commas between elements without you having to insert them.
jpp
jpp
@SebastianNielsen, That's not valid Python to begin with.
Rule of thumb: parsing the repr() of an object so you can turn it into another object, is almost never the best way to do something
Well, I want to do it just as much for the regex challenge
@Kevin that's a medley of str and repr
@SebastianNielsen it's your challenge
Learn regex for your regex challenge
Hint: You're gonna need lookarounds
12:39
I'm assuming by "challenge" you mean "interesting thing I want to do", not "a contest that I found online and which I shouldn't be asking for help for, but which I'm asking help for anyway", in which case I have no problem helping you.
>>> s = """np.array([[0 0 1 0 0 0 0 1 0 0 1 1],
...  [1 0 0 1 1 0 0 0 0 0 1 1 0 0 1 1 0 1 0 0 1 0 1 0 0 1
...   0 0 0 0 1 0 1 1 0 1 0 0 0],
...  [0 1 0 0 0 1 0 1 1 0 0 0 1 1 0 1 1 0
...   0 1 0 1 0 0  0]])"""
>>> import re
>>> print(re.sub(r"(\d) ", r"\1, ", s))
np.array([[0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1],
 [1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1
  0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0],
 [0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0
  0, 1, 0, 1, 0, 0,  0]])
Hmm, but, oh no, the 1 and 0 at the ends of lines 2 and 4 don't have commas.
Hmm, yours is better.
There we go
>>> print(re.sub(r"(\d)(\W)", r"\1,\2", s))
np.array([[0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1,],
 [1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1,
  0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0,],
 [0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0,
  0, 1, 0, 1, 0, 0,  0,]])
12:41
OK
However there is a leading comma though.
Kevin
I'd remove the brackets, pass it through np.fromstring and reshape
Not sure why there's a comma before each right bracket. I think I'm misunderstanding what \W does.
Well, that is a lot harder Andras if you are not that familiar working with np arrays
Everything that is not a "space"
Like a bracket ]
\t and \n is considered a space I think
The lazy solution is to say "actually, list literals are allowed to have a trailing comma after their last element, so this is already fine". [1,2,3,] == [1,2,3].
12:43
@Kevin \W matches non-word characters, which includes brackets ]. You can match whitespace with \s instead.
No, \w is word character, \W should be non-word
uh okay, \s is the space thingy
>>> re.sub(r'(?<=\d)(\s+)(?=\d)', r',\1', '[0 0 1 0 0 0 0 1 0 0 1 1]')
'[0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1]'
Darn these false friends! Whitespace starts with W, not S.
Regex is never a true friend
12:45
Ok, so the logic I actually intended would be print(re.sub(r"(\d)(\s)", r"\1,\2", s))
Although that still incorrectly inserts an extra comma when the input has a newline followed by a bracket, e.g. s = "[1,2\n]"
There should be a newline meddling flag
Oh, nevermind
Aran-Fey's strategy of matching digit-whitespace-digit would neatly avoid the wacky newline+bracket problem
I like Kevin's original suggestion to fix it upstream so you don't have to futz around trying to read data back in from a Numpy repr. Even if you do find an efficient regex solution it will be of limited usefulness, since when Numpy prints big arrays it makes the output compact by using ... notation.
I think this is a single-use thing
Yeah, I still 100% endorse the strategy of avoiding strings altogether, despite the vigor with which I am playing with these footguns
12:50
Oh, ok.
2Ring It is just as much for the sake of revising regex
@Kevin I approve of this joke, my true ami
If only my ignorance could be this fruitful every day.
FWIW, I've sometimes done this kind of thing when answering Numpy questions where the input data is given as a Numpy repr. It's annoying, and I tend to use a combination of regex & manual editing.
DSM once showed me a magical method that could turn array reprs into arrays. I forgot the name of it almost immediately.
12:54
@SebastianNielsen Fair enough.
Or... Was it dataframe reprs into dataframes? It was one of those cool third-party types that I never use.
@PM2Ring str? I think repr has commas
import pyparsing as pp
print(pp.OneOrMore(pp.pyparsing_common.integer).addParseAction(lambda t: str(t.asList())).transformString(s))

np.array([[[0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1]],
 [[1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0]],
 [[0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0]]])
Neat.
repr should repr into what it takes to create that very same instance
13:01
And I think it does
Unless the array is big
Nobody wants a 50 MB repr
In other news, for two weeks I thought that something got messed up and that's why ethernet stopped working for me. Turns out my "wired connection" profile changed to a crosslink UTP setup I made a few years ago.....
Ooops, that has one too many levels of bracket nesting. Well, its just a minor tweak to the parse action, left as an exercise for the reader
Just arr.squeeze() ;)
13:21
OS-specific behavior poll: if you do import time; time.sleep(5) in the REPL, and type "hello world" during the sleep duration, does "hello world" appear at the next ">>>" prompt?
On Windows, it does appear. I'm trying to figure out if Linux and friends have input buffering too.
@AndrasDeak Ah, right. I was mostly using repr in a general sense. :)
Or perhaps I should say, "shell-specific behavior poll". Maybe the behavior varies even on the same OS. Compare Windows' cmd to Windows' powershell, for example.
>>> import time; time.sleep(5)
"hello world"
>>> "hello world"
'hello world'
Ubuntu 18, python 3.6
Interesting. So it appears twice. This is not so in cmd:
>>> time.sleep(5)
>>> "hello world"
'hello world'
I guess it's also worthwhile checking what IDLE does.
13:27
This is related to How to reject input until needed in Python?. I was considering telling OP to just accept the fact that input buffering exists, but his follow-up comment makes it sound like he's seeing un-Windows-like behavior, where typed input can intersperse itself inside printed output.
I consider it reasonable to want to disallow that
This is quite close to the threshold of complexity where I typically suggest switching to a GUI. Command line is not for fanciness.
\o cbg
@Kevin Related, with both Windows & *nix solutions stackoverflow.com/questions/2520893/…
Nice. I thought it would be a lot harder than that. Something involving ctypes and HWNDs and, idk, interrupts.
13:56
Hello!
Need to parse jobs posting in Linked in. Use python3-linkedin
when trying to run jobsearch get error
LinkedInForbiddenError: 403 Client Error: Forbidden for url: api.linkedin.com/v1/…: Access to people search denied.
are you paying for the api access or are you using their free api ?
Linked In has no payed api
at least i use free
how many questions times have you tried their api? also there are some already posted questions on this topic on SO, have you tried any of those solutions?
4 or 5 times
nothing worked
If you are looking for jobs, why are you searching for people?
14:02
mistake copy while searching
In order to solve a coding challenge this weekend I learned about "bit twiddling" and I'm here to tell you that it's not as inappropriate as it sounds
@БеляковаАнастасия Now that you've fixed your mistake, are you getting any further?
this have not fixed anything
was wringly copied error message
has your program been vetted approved by linkedin ?
1
Q: LinkedIn JavaScript API - Access to people denied

nick gowdyI am trying to use the LinkedIn JavaScript API from this webpage JSAPI Tutorial: People Search but when I try it the json response I receive is this: { "errorCode": 0, "message": "Access to people search denied.", "requestId": "JEDHDU95PC", "status": 403, "timestamp": 1354094114382 } ...

14:17
Sounds like you need to get special permission from LinkedIn before you can access that data.
This is all assuming that "Access to people search denied" is really the error message you're getting. I'm not sure what error you are getting since you said you made a mistake when copying the error message, but haven't showed us any other error message.
LinkedInForbiddenError: 403 Client Error: Forbidden for url: api.linkedin.com/v1/…: Access to job search denied.
I guess it does not makes much difference
Yes, I think it is likely that you still need to get permission from LinkedIn
Pretty much the same issue then, LinkedIn does not want to make it easy to scrape their system without permission
Kevin'd!!!
14:21
any way aroud this?
This is urgent work
I suspect not. LinkedIn most likely works very hard to prevent unauthorized access.
oh no
why to complicate humans lifes
In order to simplify the lives of a million LinkedIn users that don't want their contact information placed on spam lists :-)
it was not there anyway
15:14
When a question's title contains the phrase "Let's debate", I feel like the OP has not completely grasped the mission of the site
Objective demonstrable truth does not usually require debate, if you demonstrated it right
LOL. Newbie edits Bryan Oakley answer, changing "serifed" to "certified"
Extra bold of them to edit the contents of a quote
And two people (one of which is Bryan Oakley himself) approved that edit...
Changing "think" to "thing" was correct, so maybe the approvers only saw that part of the proposed change
@Aran-Fey Double LOL. I guess Bryan wasn't looking closely.
15:26
Interesting that numpy's random number generation is faster than the random module's: stackoverflow.com/a/53048588/953482
50 quatloos says that the benchmarking doesn't take into account the time it takes to import numpy
Which, on my machine, is upwards of one second
Very strange. I thought it was mostly just a wrapper around the stdlib random, but I guess it's calling the C components directly.
I suppose I should actually look at the linked answer before making further comments...
numpy.random.randint takes a dtype parameter, so it's not just a straight-up alias for random.randint
Numpy takes a while to load the first time on my machine, but after that it's pretty fast to load, since it's in the file cache... unless something else bumps it out of the cache. Linux uses most of your RAM for caching, unless some other program actually needs the RAM. You can set a couple of parameters to control that, but the default settings work ok, most of the time.
I believe randomkit.c is responsible for the actual generation. So it's distinct from Python's random implementation.
15:42
Is my question really too broad? It has a precise definition and specific examples stackoverflow.com/questions/24017363/…
No, no it's most certainly not too broad
@Kevin Ok. It could still be calling the C version of randint (really randrange) and then doing type coercion. IIRC, while randrange can take a huge start param, it really only generates numbers within a range the size of a machine int, and adds the start param as an offset. At least, that's what it did in Py2. And I'm pretty sure it chucks an error if the range is too wide. But I could be mistaken: it may call getrandbits.
@ColonelPanic Looks OK to me. There's an O(N) solution, and there probably isn't an O(1) solution, so it's not as if there are a million distinct and equally good ways to do this. Voting to reopen.
@ColonelPanic You should really update the accepted answer though. Popping from the left of a list like your answer is doing is... well... suboptimal.
@Kevin Ok. In that case, I'll shut up. :)
15:48
I'm only 75% confident that randint actually calls randomkit. There are some pyx files involved, and I have no idea what those are or how they work.
beyond "these are pyrex files", because that's what it calls itself in the comments
@ColonelPanic Weird. I tried to cast a re-open vote, but it tells me I've already voted to re-open it. I have visited that page before, but not recently... unless my memory is getting really bad. :)
I got that message too. I don't know whether I visited this page before or not, but I definitely haven't voted to reopen anything in the recent past. Maybe it's a server hiccup.
Both of you already cast reopen votes back in '16
We must be in a very slow reopen/re-close war
Each side takes turns, lasting about one year
But what Aran-Fey said. Try to get rid of that left pop. If you don't want to use an iterator, you could use a deque, which can do left pop efficiently.
16:02
If you don't want to use an iterator, reconsider (:
3
wim
wim
I would humbly suggest to dupe it the other way: Finding substring (nonconsecutive) [duplicate]
the question is better written, and the answers are higher quality
Is it really? I think Colonel's question does a better of job of explaining the "subsequence" concept
I'm not horribly opposed to turning the closure around, but I do think I made the right call
wim
wim
too much explaining and the use of uppercase letters confuses matters
@Aran-Fey The problem with changing his code to use an iterator is that it'd become a clone of an existing answer...
Deleting is always an option :D
wim
wim
16:09
the other one has 1 good answer and a lot of garbage answers, and OP accepted suboptimal answer
*shrug* if we can get it reopened, do what you want
wim
wim
ok
I cast a re-open vote there needs 1 more though
it's certainly not "too broad"!
Probably good to delete that non-Python answer stackoverflow.com/a/42883960/4014959
@wim I don't find the capital letters confusing, I think they're helpful.
wim
wim
gone
wim
wim
16:24
^ classy hammering from martijn
@wim did requests have .json() in 2013 though?
wim
wim
irrelevant.
Why?... It seems:
0.12.1 (2012-05-08)¶
New Response.json property.
wim
wim
property? it's a method now..
yeah changed 2012-12-17 it appears... Make Response.json() callable, not property.
wim
wim
16:49
@JonClements I say "irrelevant" because we should not judge an answer based on what was available at the time, we should judge it based on what is available now.
cruft is harmful to SO.
Nothing wrong with the answer though - it works... and will work on versions of requests prior to when it was introduced.... it's just not as convenient as it could be...
wim
wim
I can easily create a situation in which it will not work, when response.json() does work.
That'd be like blasting answers that don't use pathlib before it was part of the stdlib because using os.path just isn't the newest thang :)
Sure... I just don't get why you're so passionate in this case regarding the tick mark...
wim
wim
because on popular questions like this, I think many people just copy-paste code from the accepted answer. since it gets pinned to the top.
and I wouldn't neg on os.path answers that are correct and working, FWIW.
17:26
@wim Neither question is a dupe of the other now?
wim
wim
fixed
A recent question uses textwrap.wrap in order to split a string into a collection of equal-sized substrings. I admire their creative thinking, if nothing else.
wim
wim
...I must be missing something because that's basically what textwrap is designed for, isn't it?
Yeah, but it does more than just regular old slicing. For example, it strips trailing whitespace: textwrap.wrap("foob baz", 3) returns ['foo', 'b', 'baz']. This may be undesirable.
17:42
Doesn't it also break on word boundaries where it can?
It seems I've used it to tabulate multi-line cells of a table.
I thought so, but I couldn't get it to do so with the couple of test cases I tried.
(Literally a couple, I gave up after 2)
>>> textwrap.wrap("Now is the winter of our discontent made glorious summmer by this sun of York", 10)
['Now is the', 'winter of', 'our', 'discontent', 'made', 'glorious', 'summmer by', 'this sun', 'of York']
>>> print('\n'.join(_))
Now is the
winter of
our
discontent
made
glorious
summmer by
this sun
of York
I award you five quatloos for succeeding where I failed.
But the real treasure is the friends you made along the way.
18:04
If we have a canonical question whose answer is "because file.readline() doesn't strip out the trailing newline", then this question could use it: Wrong boolean result in the main program (python)
18:27
@PM2Ring I'm positive numpy random is standalone. There's been discussion about how stable the implementation has to be. Turns out people rely on deterministic results with a given seed in their tests, so it's not that easy to fiddle with the RNG
I think the outcome of the last discussion was something like "fork a stable generator that should be used in such cases, otherwise don't worry about backwards-compatibility of the random stream"
I want to say "if your simulation only produces favorable results with one specific seed, then it shouldn't be considered reproducible anyway, and numpy devs should not be trying to cater to you" but in the time it took me to type that out I thought of two additional justifications for long-term backwards compatibility
as I understand the legit concerns are about testing
"We need to be able to exactly reproduce the simulations of old experiments in order to verify that the original authors aren't simply lying about the results it produced" is one
it's easier to assert x.mean()==9.481593 than x.mean()==9.5 with a 95% confidence bounds of ...
@Kevin I don't think that's a thing
I recall reading about this happening at least once, and I'm 80% sure it wasn't a science-based piece of fiction
18:41
You'll never get the exact same thing even with deterministic problems. I don't think anybody would try to backtrack a random stream to see what comes out. As you said, no relevant result should depend on the exact numbers used
after all, it's enough not to tell anyone the seed and there, no reproducibility
In a perfect world, omitting your program's seed would be considered Suspicious with a capital S
meh
then again I only see random numbers for physics simulations, and there nobody cares as long as they're "good enough"
perhaps CS people with random-oriented things are picky
You can either have complete reproducibility, or you can extract true random numbers from the rate of decay of radioactive particles. No half measures. (except for measuring half-lives)
19:48
somebody online ?
Hi :)
i try to run this function but i get "must be real number, not NoneType
anu thoughts ?
You have indentation errors. Please see sopython.com/wiki/… for formatting multiline code in chat.
Your function doesn't return anything.
19:52
@Richard edit your post, and use Ctrl-k to format it properly.
@AaronHall for some reason it won't indent it properly
@Richard you have to indent the whole thing
def foo(x):
    # >>>>> YOUR CODE HERE
    for x in X:
        y = max(0, x) + np.log(1 + np.exp(-np.abs(x)))
        print('foo(%11.4f) = %foo'%(x,y))
    # <<<<< END YOUR CODE
y = foo(x)
print('foo(%11.4f) = %11.4f'%(x,y))
Try print(y) and see if it has the value it should have
19:56
@Aran-Fey yes it does
Strange, that code doesn't give me must be real number, not NoneType, it gives me NameError: name 'x' is not defined
I mean outside of the function, after the y = foo(x)
Where does X come from - presumably it's global if you're not getting a NameError? Also - are you meant to be using numpy here? It's a bit of a mishmash between you should either be doing that all in numpy or not using it at all @Richard
@JonClements X = [-10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000]
sounds like a coding challenge, so whatever works, works :P
19:58
@Aran-Fey outside the function print(y) delivers 0.0 --> not what I want
Even adding X = [-10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000] to the code, I still get NameError: name 'x' is not defined
@Richard That's strange, because the code you posted should set y to None...
nice 3 silver badges already for the False/True question
We'll need a Minimal, Complete, and Verifiable Example if we want to make some progress here
thanks @AndrasDeak for bringing that one into my attention
20:01
@Kevin maybe there's really y = foo(X)... but shrugs...
meh :P
    def bar(z): return numpy.log(1+numpy.exp(z))

    Y = bar(X)

X = [-10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000]

def foo(x):
    # >>>>> YOUR CODE HERE
    for x in X:
        y = max(0, x) + np.log(1 + np.exp(-np.abs(x)))
        print('foo(%11.4f) = %foo'%(x,y))
    # <<<<< END YOUR CODE
y = foo(x)
print('foo(%11.4f) = %11.4f'%(x,y))
is this fine ?
try and see
bar and Y are never used? And foo(x) still throws a NameError?
I want to return the value of y inside foo
20:11
"is this fine?" is a subjective question, sorry I don't compute.
ok nvm, thanks anyway
I found my mistake and fixed it
@Andras of course it is... I happen to like sitting near a natural fire in a coffee shop/pub and having a beverage... the only issue with that one is that it's not a big comfy arm chair :p
Wowsers... stackoverflow.com/questions/53053255/… - a counting sort... that took a few moments to remember what the heck that is :)
20:30
Should this be duped to this?
rbrb all
wim
wim
crikey, imagine getting 1682 upvotes for a question like that!
20:51
@PaulMcG rbrb
Umm... has anyone here had a play with elastic canvas?
@Aran-Fey i would think so ...
but then again it's asking if you can slice a string directly... on top of how to do it.
It's probably a bad idea, actually. It looks like a suitable dupe because the OP already knows about slicing, but the average visitor who's reading that question probably has no idea that slicing a string returns a string
exactly. anyways why dwelling around older questions
Was looking for bounty-worthy answers
Oh wow, what a responsible user :D
21:02
It's surprisingly difficult to find answers that need a bounty (i.e. good answers that don't already have 500+ upvotes). I'm thinking of investing my rep into a mug instead
wim
wim
@Aran-Fey Oh, I've got a couple of suggestions, if you're interested.
gimme
wim
wim
maybe this
or are you specifically looking for good answers that aren't upvoted way more than the accepted answer?
I'm not specifically looking for answers that are better than other answers, no. Just good answers that are underrated for whatever reason (because the question is easy, for example)
wim
wim
@Aran-Fey This one
21:15
I'll pass on the pip question because I don't know enough about those things, but np8 has earned a bounty
wim
wim
yeah actually on second thought the pip question doesn't really have any particularly bounty-worthy answer.
the long tail of crap there could do with a few delvotes though! starting here and scrolling down
@wim thoon
Making solid progress, Andras!
if I had a therapist they wouldn't be happy about it
wim
wim
what's thoon?
well... good thing is you'll be there soon
wim
wim
why do rep 1 users do this? (answer questions that are several years old, and poorly)
I guess they come across a question while googling, and think they can/should contribute since SO is such a great place and everything
wim
wim
In all 4 of those cases, it's their only answer on the site
suppose they assume it's a forum not Q&A site
and they're never back to see the feedback, so these answers just hang around until 3 people could be bothered to delete them
Those people don't actively participate on SO. They found a question that's relevant to their problem but didn't have the answer they were looking for, so they thought they'd share their knowledge. I'd be surprised if they had more than 1 answer
 
1 hour later…
22:59
I answered an already answered question a few days ago. My solution had an stupid performance error. Got downvoted. Lesson learned. But I answered becuase I thought my approach was simpler and potentially useful. Not sure why folks do it on years old questions, however.
05:00 - 23:0023:00 - 00:00

« first day (2935 days earlier)      last day (2238 days later) »