« first day (2160 days earlier)      last day (2803 days later) » 

1:04 PM
cbg all
I'm starting to find myself answering the question "What's the best IDE?" with Jupyter
 
I usually want to look cool and answer with Vim or Emacs
 
Do you people have cameras in your office? As in, cameras the employer can use to see what people are doing.
 
I only answer Vim or Emacs when I know the person is waiting for me to answer so he can be smarmy and say "VIM/EMACS IS BETTER!" - takes the wind out of his sails
 
@BenjaminGruenbaum hell no
 
there were some cameras for security and you could use those to see what people were doing but none directly looking at me (granted I've heard of it)
 
1:11 PM
@JGreenwell Jupyter is nice... but I'm too powerful with vim's keybindings. I'm like over 9000 or something ;)
 
There's only laptop webcams in here which I'm fairly certain aren't being monitored. Fairly certain.
... I'll bring in some duct tape tomorrow.
 
user559633
No post-it notes there? Duct and most gaffers tape will dry out and leave very hard to clean residue. The post-it note "sticky end" works well and you can make it into a little flap with scotch-tape
 
@JonClements mmmmmm, records (at least I'm guessing that, because of the pops)
 
(multiple-choice joke: is Kevin bringing in duct tape to cover up the webcam lens? Or to do unspeakable things left up to the imagination of the reader, in order to listen in for the faint screams of whoever's monitoring him?)
 
user559633
To cover up the webcam lens.
 
1:13 PM
@tristan A small post-it note (or cut up piece of the sticky part) covering someone's mouse laser is good for some office hijinks
 
@tristan Ooh, I've got duct tape on my home machine. Good thing I never intend to use it ever and so residue doesn't matter to me.
 
user559633
@WayneWerner Haha yeah, or replace their chair with a pile of venomous lizards!!! haha, interns hate getting poisoned
 
But I should treat office property with more care in case they want to bill me for damages.
 
user559633
@Kevin Never have online meetings/web conferences?
 
audio only
insist on it
 
1:14 PM
same.
 
@tristan TristanCo - where before you sit down you check that your chair hasn't been replaced by a pile of venomous lizards. Those wacky co-workers!
 
web camera staring at me freaks me out
 
Would you quit your job if your employer introduced cameras?
(cc @khajvah )
 
I always point it to the ceiling
 
If I become the kind of person that attends web conferences, I'll probably end up buying a new laptop to commemorate my grim transfiguration.
 
user559633
1:15 PM
@BenjaminGruenbaum Yes. If I was required to work under the watch of a camera, I'd quit immediately.
 
nobody needs their boss and users to see the rude gestures they are making and the rolling of eyes when they ask for the impossible in 2 weeks (well they say 6 months but you know it will end up "is the prototype done?" in 2 weeks)
 
@BenjaminGruenbaum Yes, unless it was the only job I could find
 
@tristan great, good to know I'm not crazy for feeling this way.
 
I absolutely would, it's indicative of a whole bunch of Bad Culture Stuffs
 
user559633
@BenjaminGruenbaum 100% fuck that.
 
1:16 PM
As well as an obvious shitfest in its own right.
 
Video can enhance some conversations, but that's a good point @JGreenwell
 
If they installed cameras, I think the resulting paranoia would make my productivity drop to fireable levels. The problem solves itself!
 
@BenjaminGruenbaum I would also quit but know the job market so might not until I have an actual offer somewhere else
 
If your employers are pointing video cameras at you, the more important question is why did they hire someone they don't trust??
7
 
I just installed PyCharm to give it a second chance. Any beginner recommendations?
 
1:17 PM
I think i'd probably spend more time dicking with the cameras than working.
 
@JGreenwell yeah, I have 15 other offers lined up - I'm not going to quit and they're not going to put the cameras up.
 
@Withnail Also true
 
Depends @Programmer what didn't you like the last time?
 
@Programmer Learn keyboard shortcuts
 
user559633
I technically reported to someone that floated the idea of me working with my face up on the screen so people could walk up and "talk to me" in the office and so people knew I was there all day and not just blowing off work. So many levels of "lol this place is terrible at gauging work and y'all need to learn how to delegate work appropriately"
 
1:18 PM
granted I used to work in a place where cameras were pointing directly at me and didn't mind but it wasn't a development job (and involved an armory)
 
@WayneWerner the cameras wouldn't be pointed directly at me, but there is a good chance they'll film me and my team.
 
user559633
@BenjaminGruenbaum If they're pointing at the lobby or doorways, I can understand that.
 
@JGreenwell which is (arguably) an entirely different thing
 
user559633
Or is it a "just watch over the general work area" camera?
 
@tristan there already are cameras pointing at the entrance - that's fine.
 
1:19 PM
@JonClements :D I have an hour's commute each way - usually on the phone with her for all of that
 
which is a complete different thing @WayneWerner - except if you're developing safety measures for nuclear systems then maybe you'll learn to live with cameras
 
@RobertGrant I'M ON A TRAIN!
 
@WayneWerner you're not there to be trustworthy, you're there to $output
@JonClements :D
 
devil's advocate and all that
 
@Withnail my laptop wasn't running it well, previously.
 
1:20 PM
@Programmer install vim plugin
 
yes, well, I would be totally fine with that, too. Actually, I would prefer that instead of recording me they just recorded my computer. And maybe that I was actually the one there.
 
@JGreenwell or you're developing software to monitor employees through cameras and your company believes in eating its own dogfood
 
user559633
If I had an employer that wanted to monitor my computer screen, I'd dedicate 1/4 of my screen to furry anime as a protest.
 
1:22 PM
@JonClements so good. I love their stuff
 
Anyone know any good machine learning sites? In particular, content aggregator (already got HN)
 
@tristan even eviler is to resurrect "Clippy" to talk to them whenever you leave your workstation
 
@tristan or hentai
 
@WayneWerner and one I agree with: youtube.com/watch?v=E4_Qp2BGrC4
 
1:31 PM
Nice. That's fantastic.
 
Did you hear about the Note 7?
Samsung is going to limit its charging capacity to 60% via a software update… this is just ridiculous… xD
 
@poke I am guessing before they fix the existing ones
 
user559633
Oh good, it will only 3/5 blow up
 
@poke errr... how does that even work?
 
delightful. So instead of burning ones pants on fire they'll just have to be constantly connected to the wall
 
1:34 PM
Haven't they done an official recall?
 
@JonClements Firmware flash I guess?
 
maybe... but if the fault is actually in the hardware... software ain't going to do anything
 
@JonClements Not quite true with modern charging - a lot is governed by the software
 
my bookmarks @Ffisegydd? Actually, that's a good question as everyone (even universities) has a blog for machine learning/AI but don't see many "Hey, check these links out!" pages - hence my massive bookmark folders....This Kaggle forum post has some
 
@JRichardSnape they officially said that the problem are in the batteries, as far as I know
 
1:38 PM
@JRichardSnape / @JonClements very true - especially with Lithium Ion batteries. They have a dreadful tendency to fail in spectacular ways: youtube.com/…
 
Yeah - but a workaround might be - this Li ion battery blows up when I work it (read charge it) to 100%, I'll just run it and 60% and none will hit that failure point
 
@JRichardSnape True enough... but if my hard drive is going wonky... the OS can operate "around" it noting bad sectors and compensate etc... However - it won't fix the actual disk.
 
I think they're probably just trying to keep from setting anyones crotch on fire
 
ture
 
Li-ion are incredibly fickle beasts - not like your old car battery where you just shove 15V at it and hope
@JonClements Oh yeah, it's a workaround no doubt at all.
 
1:39 PM
yeah yesterday on the plane... "and we kindly ask any passengers who have a Note 7 to contact the cabin crew"
 
Their real worry is if it's the design that's pushing the envelope too far, rather than "just" faulty manufacture.
 
... had I had one, I guess I'd have felt too ashamed to admit that and would just have stayed silent
 
@JonClements Rare I see a "new to me" XKCD quoted, but that one hits the spot
 
1:41 PM
Morning cabbage.
 
I am having a problem with /etc/hosts file... Even though I add 127.0.0.1 dev.corvid.com and ::1 dev.corvid.com, it appears to not go to that address and attempt to go to the real address. Already tried clearing the DNS cache
 
@AnttiHaapala And stowed it under the seat next to you :D
 
cbg
 
Wow... Netflix really are churning out "Netflix Original" stuff...
 
1:42 PM
For those who like their rock American and their guitar solos indulgent - now playing in Snapesville: youtube.com/watch?v=pb22MYqdugE&spfreload=1
 
@JonClements xkcd one-boxes, complete with alt text;)
 
like this v
 
@JRichardSnape I worked on a project earlier this year with a guy who claimed he had technology that would rejuvenate Li-Ion batteries through a 5v wall socket. I, uh, had my doubts.
 
what about 1.5V Li batteries?
 
Mmmm. He'll either be very rich, or shortly have no eyebrows or hair on his forearms.
 
1:48 PM
@Withnail RIP
 
or meat on his bones?
 
Hey guys! anybody here have some experience with Bokeh? I am plotting a stream, which works well. However, the toggle to show/hide lines doesn't work. Any lead?
 
there was something about HF and Li batteries?
 
Tbh, if he has the tech he claims to have a) he'll be ludicrously rich, and b) he would already have licensed it to someone for $$$$ instead of trying to manufacature it himself.
 
@AndrasDeak typically not a problem. They're not Li-ion, simply LIthium as anode.
 
1:48 PM
Hmm, my select * from ENORMOUS_TABLE_A where widget_id not in (select widget_id from ENORMOUS_TABLE_B) query is taking a long time...
 
iirc (not a battery expert, but I have to look into it a bit from time to time)
 
40 seconds and counting, now
 
@JRichardSnape oh I had no idea there were Li batteries and Li-ion, I assumed all of them are the latter
 
Lithium batteries are batteries that have lithium as an anode. They stand apart from other batteries in their high charge density (long life) and high cost per unit. Depending on the design and chemical compounds used, lithium cells can produce voltages from 1.5 V (comparable to a zinc–carbon or alkaline battery) to about 3.7 V. Disposable lithium batteries are contrasted with Lithium-ion and lithium polymer, which are rechargeable batteries, where ions move between the anode and the cathode, using an intercalated lithium compound or metallic lithium as the electrode material. Lithium batteries...
 
1:50 PM
My fallible memory proved not to have deteriorated too much this time.
 
@JRichardSnape ooooh, nice:) thanks
 
Well, as long as we all trust Wikipedia. In Wikipedia We Trust. My new motto.
 
no, sounds legit:D
So...don't drop those batteries in water, at least after smashing them to pieces, eh?
 
true that
 
Beautiful flame, eh? ignites phone even though it's not a Note 7
 
user6568562
1:55 PM
I still believe we should reverse back to cranks. There's something intimate to rotary motions
 
rolls eyes
 
"Storage at less than 2 V results in the slow degradation of LiCoO2 and LiMn2O4 cathodes, the release of oxygen and irreversible capacity loss.[74]"
 
user6568562
 
user6568562
Now we're talkin'
 
@Withnail what's that shape?
 
2:02 PM
Manager: "Our slow Internet got better yesterday after you left the office"
Me: _sweats profusely_
 
user6568562
@AndrasDeak How was your intro class, btw ?
 
thanks, not bad:)
the students were sort of responsive, at least the half of the class that were present
a student told me he heard rumours of the class being cancelled...:D
 
oh, so math classes being cancelled isn't just a problem over here? That makes me feel better
 
Flagged an answer for mods to investigate the 3 serial votes that weren't reversed. We'll see what happens. meta.stackoverflow.com/a/252271
 
user6568562
@AndrasDeak Was it Math for CS ?
 
2:07 PM
Manager is now playing "on hold" music via speakerphone, possibly as a psychological tactic to encourage us to use less Internet
 
@JGreenwell that never happens, so I have no idea where they got that notion from
@randomhopeful nope, intro**2 math for physics freshmen
specifically, limits in practice
 
undergraduate rumor mills are a breeding ground for fear
 
The over/under on how long it will take for a Comcast representative to pick up is two hours
 
next time it'll be derivation, Taylor series, maybe even integration
 
@Kevin Use Less Internet - we don't want to run out of Internet prematurely.
 
2:08 PM
@Kevin elevator music ftw
 
user6568562
@AndrasDeak It sounds very fulfilling [ :
 
if you look awkwardly at your feet, you can't waste bandwidth
@randomhopeful heh:P
 
I'm downloading all of the Internet right now so I can cache it all locally. I'm up to "J".
 
user6568562
P is gonna be a headache
 
@JGreenwell it's funny because we met last week on another course, and they already knew me and my e-mail address (the latter would be easily found on the department website, anyway.....)
 
2:10 PM
The speed benefits are definitely going to be worth it, though.
 
fear is illogical? (that's it I have no more guesses after this)
 
or some students are dummies:P
 
@AndrasDeak The cynic in me says it is sometimes bliss to live in (deliberate) ignorance. Is it a nice day where you are today? Time for beer / ice-cream / pizza?
"What's that, class is cancelled, you say? Well damn, I guess it's time to meet some girls on the park and awkwardly try to talk to them"
Oh, mind you, I forgot. Physics.
;D
 
I love writing quick and terrible code knowing that I will toss it away after the deadline
 
DSM
9 AM meetings are generally forbidden at NumberFirm, but a scheduling conflict meant we had to have one. Guess who didn't say a single thing during the entire meeting and so could have slept in instead?
 
2:13 PM
@AndrasDeak well, by no more guesses I kinda meant no more nice guesses ;)
 
DSM
Annoyed morning cabbage for all.
 
user6568562
Cbg
 
@DSM Gah, I hate it when that happens (especially at 9am). Morning!
 
I have a little mantra when I'm about to enter a situation that I know will only waste my time: "I offer this part of my day to the God of Bullshit". It makes meetings / traffic jams / etc feel more tolerable because of the illusion that I'm participating voluntarily.
 
@Kevin is that a sacrificial sham?
 
2:17 PM
And if it turns out that G.o.B. is an actual real being, then maybe he'll be temporarily mollified by my offering, and not make it rain on the weekend when I have outsidey plans.
It's like Pascal's wager except instead of hell you're mildly inconvenienced
 
user6568562
Yeah a half-ass job of torture, I can relate to that
 
Being left with only half of one would be pretty bad
 
user6568562
More like when sound volume is irritating. If it only could increase by some tiny degree, but it doesn't. So evidently, you'll turn back to life thinking I know what you're doing, dick
 
@JRichardSnape haha, tell me about it;D
now it's raining and it's gloomy, but yesterday during the class there was perfect hang-in-the-park(-looking-at-your-phone) weather
@DSM cabbage
How was your meeting? Shall I ask to begin with?
oops, you answered already, sorry:)
 
@Kevin someone needs to post cute kitten/puppy pictures - I hear they cure all life doubts (or something)
 
2:34 PM
rabbits > kittens / puppies
 
awwwwww
 
this was a close runner-up
 
bad Andras, bad
 
That... wow.. I don't want to know where to start with that
 
2:36 PM
rofl
 
@AndrasDeak Monty Python and the Holy Grail - the killer bunny
 
Death awaits you!
 
go ahead and shout "mod abuse" - but I've saved your soul there @Andras :p
 
lol. Or everyone else anyway ;)
 
@AndrasDeak I'm being repressed!
 
2:40 PM
of course you are :)
 
Need help on following:
I am trying to convert time string into UTC in 24 hour format from EST time.
For example:
for 11:15am converts to 15:15 and 11:15pm to 3:15
 
@thefourtheye that's nonsense. I should know, I can spot Joel's handwriting a mile away.
 
sorry I posted here.
I am getting 90 minutes warning all the time.
 
@beginner_yaml_user you're more than welcome to ask for help - please read the room rules: sopython.com/chatroom
 
@beginner_yaml_user Try uploading your code to pastebin.com
 
2:43 PM
done.
 
If i'm writing information to a CSV file on a network and someone opens this file it breaks the program. My immediate thought was to just make the name "DO NOT OPEN" until the CSV file is done building. Also, I'd rather not store the whole thing in memory until it's complete. Better solution?
 
whaddup snakes
 
build a temp file which you write to then combine them or overwrite the old file
 
Write to a temp directory then copy the file. But your approach isn't bad.
 
@beginner_yaml_user Ok, now give us a link to the code you uploaded on pastebin :-P
 
2:45 PM
I've seen some virus checkers do that. They download the file but name it as incomprehensible gibber, then rename it correctly once done scanning.
 
@beginner_yaml_user dat username
 
thats the only link O am seegin after creating paste code
 
@clickhere granted, my suggestion assumes that people are just reading to the file - if there is a need for read/write access for multiple individuals - it might be time to switch to a table on a database
 
Ok so your question is "how do I get the UTC version of a string that looks like a date/time and is implicitly EST?"? I... Actually have no idea how you do that.
Other than adding/subtracting hours manually but that's not fun
 
2:52 PM
@RobertGrant Really?
 
I have a string "11:15am" and wants to convert into "15:15" in UTC in 24 hour format
 
I'd check the datetime docs but right now I'm throttled to less than 1 kbps because Comcast is an asshat
 
Stripe is cool
 
yes they are --------------------------^
 
recbg from dinner
 
2:54 PM
@khajvah their API is beautifully designed
 
I think you can break this down into two problems: how do I convert from EST to UTC? And how can I display a datetime in 24 hour format?
 
got into a bit of an argument with the missus, one about positive definite symmetric bilinear forms
 
@idjaw docs are good too
 
(she's a good one)
 
@khajvah Yeah, I implied that too. They did a great job.
 
2:55 PM
Googling each one separately will probably give better results than googling "how do I convert EST into 24 hour UTC?"
 
I'm pretty sure that's unique in teh history of couplez argumentz @AndrasDeak
 
turns out we just misunderstood each other:P
 
"Oh, bi_linear_? I thought you said bilateral"
Wacky misunderstanding level rating: three camera sitcom
 
DSM
I'm a quadratic form man myself. #clifford
 
2:58 PM
I don't understand meetings, you guys.
 
Or 37 centi-asked-two-dates-to-prom, if you're using metric.
 
@beginner_yaml_user have you tried the 'time' module?
In particular 'strptime'?
 
@corvid There's different kinds of meetings. Some are good, some are bad.
 
my wife and I got in to a minor argument about insertion and shell sorts recently, the argument was fairly one sided as she didn't care and I just ignored the fact that she didn't care
 
Hello guys.
 
3:00 PM
Cheese bread
 
The good ones all provide either (or both) good coffee or food
 
ah, meetings, not wives
 
The worst meeting I ever had was where the VP of R&D at our acquiring company decided to pull in all stakeholders (including VPs of both companies) so we could as a group decide how to measure distance from a golf ball to the pin. It was mostly a discussion about geometry.
 
@AndrasDeak yes, well......no, yes
 
It took hours and could have been done in 5 emails.
 
3:03 PM
And what colour did the bike shed turn out to be?
 
trigonometry, white board = done in 2 min
 
I've been reading this http://miriamposner.com/classes/medimages/3-use-opencv-to-find-the-average-color-of-an-image/

The author explains how to get the average color of an image. First he gets the average colors per row. He just takes an image and does it with np.average(image, axis=0).
While the author writes that he is getting the average values for each row, I am not sure. Might it be that in reality this just gets the average values per column?
Oh and it's a 'she'
 
axis=0 willl probably do it columnwise, yes
but what's np.average? Isn't it mean?
ah, average can do weighted average
 
I'm sorry, we weren't measuring distance from the ball, we were measuring 'break distance'. It's traditionally expressed in distance although it's really an angle.
 
@Käsebrot oh, your question is "rows vs columns"
that might be non-trivial, it might also matter how it's being plotted later
 
3:06 PM
@AndrasDeak yes it is. What did you think it was about?
I see
 
yeah, people use average and mean interchangeably with numpy but there is a major difference when you need it (or just enough of one to screw up all your calculations)
 
It wasn't even a trig problem, it was a notational thing. That was the meeting that made me start putting price tags on wastes of time.
 
@Käsebrot for first read I thought it was full average vs columnwise:)
 
VP2 of 2 companies, head of R&D, like 5 other people (including our one Senior Dev who was basically a company founder), sitting in a meeting until 7.
 
you should have turned it into a travelling salesmen problem (yes it can be done) and just screwed with him all day @QuestionC
 
3:09 PM
@AndrasDeak Nopes. She actually just does the same with the result in order to get the global average. with np.average(average_per_row)
 
@Käsebrot just try it out yourself. Import something non-square with opencv, run that mean, and see how many elements it contains
it probably doesn't really matter
 
oh, there was a question in that? I thought this was just a "look at this neat example I found" thing
 
>>> np.average(np.random.rand(10,20),axis=0).shape
(20,)
so unless the image is transposed by opencv (for which there is 50% chance), it takes columnwise average
 
if your asking about the axis: check out its definition in the glossary
> the first running vertically downwards across rows (axis 0)
 
Nobody (except the VP of R&D who organized this farce) wanted to get too technical because we didn't want to talk over the very important business people that wrote our checks. We let VP of the acquiring company re-explain the problem to everyone in the room for like half an hour.
 
3:13 PM
@JGreenwell the question is probably whether it's column-wise with respect to an image
But @Käsebrot, cv2.imshow will plot a (10,20)-shape array as a rectangle of 10 height, 20 width.
 
That project is my most memorable experience with the company, and definitely contributed to me finding a new job.
 
which means that yes, it's probably a column-wise average rather than row-wise, as numpy's conventions would suggest
 
well, the image is now represented as a matrix (multidimensional one) or arrays of arrays so it still the same defintion
 
and my suspicion is that it doesn't really matter for the opencv example
@JGreenwell not if the image is plotted transposed for some obscure reason...
if arr[i,j] is pixel [j,i]
there are some image plot orientation oddities in matlab at least, so I urged a bit of caution;)
 
yes, but he asked what that author was doing so I'm just explaining that (and adding a link to the glossary cause its a good resource)
 
3:15 PM
I meant by opencv itself...
@Käsebrot it just computes the average of a 3-index quantity by averaging the first two indices
 
yes, with general image processing one would have to watch out for transposition - true enough :)
 
the order is irrelevant
I'd just do np.mean(img.reshape(-1,img.shape[-1]),axis=0) in one step
>>> img = np.random.rand(10,20,3)*256
>>> np.mean(img.reshape(-1,3),axis=0)
array([ 122.94362467,  133.19503317,  130.57567559])
I hope that does what I think it does, let me check:D
 
lol, now your just showing off :P ;)
 
I think it does
 
actually, I like explaining sorts as I also get to explain why things are typically not sorted and those instances where order doesn't matter......oh! new idea for an experiment in my lecture
 
3:20 PM
I created an example and checked it. It does store the values columns vise. Thank you guys.
 
>>> np.allclose(np.mean(img.reshape(-1,3),axis=0),np.average(np.average(img,axis=0),axis=0))
True
phew
@Käsebrot you should also consider casting with .astype(np.uint8)
the next line is also bad practice:
average_color_img = numpy.array([[average_color]*100]*100, numpy.uint8)
if you edited that list, you could end up with surprises
 
Ok thanks a lot
 
stupid 3d arrays
 
re-cbg
 
average_color*np.ones((100,100,3),dtype=np.uint8))
that assumes that average_color is a 1d array, and uses array broadcasting to construct a constant image
adding a zero matrix might be more fun:D
 
3:28 PM
arrrrgh - too many brackets. Brain parse objection
 
oops, the dtype is ruined there
 
trying time and strptime but still not getting
 
sorry, good version: (average_color*np.ones((100,100,3))).astype(np.uint8), probably
sorry JRS:P
 
(I won't hold it against you
 
3:32 PM
@beginner_yaml_user have you tried the solutions from this question? As this will cover the first question (if you have to use standard lib and no localtime you just have to add 4 to hours)
 
where's a message-editing mod when you need one
 
missing parens drive me crazy
 
consider it overnumerous rather than missing
 
I've just been playing with colour interpolation in PIL, trying to find a good PIL solution for this question. And I just learned that PIL's Image.resize method is pretty bad when enlarging a 2x2 image, no matter which interpolation method you choose (apart from nearest neighbour).
 
what doesn't do bad when enlarging a 2x2 image?
 
3:34 PM
guys....I just used my own SO answer without realizing it was my SO answer
 
lol:D
an odd combination of cool and lame
 
You can't vote for your own post
then it hit me :P
obv
 
non-matching parens drive me crazy then :P
 
@beginner_yaml_user strptime is the correct path
 
stackoverflow.com/q/39493026 doh, removed the flask tag before reopening
still needs to be reduced to an mcve, but definitely not that dupe anymore
 
3:38 PM
did I just prove that past me is more knowledgeable than present me? What's happening here....
 
@AndrasDeak Whatever they use in police procedural media where "zoom, now enhance" produces useful evidence.
 
@idjaw ageing
 
@JRichardSnape legitimate explanation
 
@AndrasDeak I was hoping that it'd be able to smoothly interpolate to a 256x256 image. The source colours I tested with are pure red, green, blue & yellow, so it's possible to get a pretty smooth transition. Here's the code that didn't work:
 
@idjaw I've done that a few times. "Wow, this answer is really easy to understand, it's exactly like I would... oh."
 
3:39 PM
from PIL import Image

def color_square(colors, size):
    data = bytes(x for c in colors for x in c)
    img = Image.frombytes('RGB', (2, 2), data)
    return img.resize((size, size), Image.BILINEAR)

tl = (255, 0, 0)
tr = (255, 255, 0)
bl = (0, 0, 255)
br = (0, 255, 0)
img = color_square((tl, tr, bl, br), 256)
img.show()
 
[Insert obligatory link to that scene from Red Dwarf where they reconstruct a 3d scene from a photograph and bounce off of seven reflective surfaces to view a letter in someone's pocket]
 
@PM2Ring if kNN works then other clustering methods might improve the quality some (indeed I assume this would be based on pixel density so determining clustering would be a good start) might look at other methods which are more based on density over centroid and see if that helps
 
@davidism heheh...so does it still count as us figuring out how to do it on our own if it ends up being our own answer? :P
 
granted I've never used PIL
 
Here's what I ended up doing:
def color_square0(colors, size):
    #Make an Image of each corner color
    tl, tr, bl, br = [Image.new('RGB', (size, size), color=c) for c in colors]

    #Make the composition mask
    mask = Image.new('L', (size, size))
    m = 255.0 / (size - 1)
    mask.putdata([int(m * x) for x in range(size)] * size)

    imgt = Image.composite(tr, tl, mask)
    imgb = Image.composite(br, bl, mask)
    return Image.composite(imgb, imgt, mask.transpose(Image.TRANSPOSE))
I get identical results to the last code with this:
def interp_2D(tl, tr, bl, br, x, y):
    u0 = x / mx
    v0 = y / my
    u1 = 1 - u0
    v1 = 1 - v0
    return floor(0.5 + u1*v1*tl + u0*v1*tr + u1*v0*bl + u0*v0*br)

width = height = 256
mx = width - 1
my = height - 1
data = [interp_2D(tl[i], tr[i], bl[i], br[i], x, y)
    for y in range(height)
        for x in range(width)
            for i in (0, 1, 2)]

img = Image.frombytes('RGB', (width, height), bytes(data))
img.show()
 
3:44 PM
you're doing list generation with a treble for? Impressive
@PM2Ring
 
I guess there might be some way to build that data faster (and nicer) using Numpy. PIL can load image data from a Numpy array.
 
I'd numpy the hell out of that
scipy even
 
@AndyK The .frombytes method needs a 1D byte sequence.
@AndrasDeak The accepted answer uses scipy, but I was hoping that plain Numpy could do the job. But I hardly know any Numpy, and I got sick of randomly looking through the docs after about 10 minutes. :)
 
scipy definitely...might be interesting what sklearn could do
 
Today I discovered that nine people sharing one 3 mbps internet connection might experience speed issues regardless of whether Comcast is an asshat.
 
3:52 PM
@AndyK The reason I posted that code with the triple-nested for loop was just to show that simple bilinear interpolation does produce a smooth result. So I don't know what the hell PIL is doing.
 
You can't put fifteen pounds of funny cat pictures in a five pound bag.
 
You can if you squeeze the pounds.
That's Science.
 
I'm keeping that in mind
 
> 2 + 2 = 5 for very large values of 2.
 
or very small values of 5
 
DSM
3:56 PM
Or approximate values of =.
 
rhubarb everyone
 
Or for operators represented by the plus sign but which are not, in fact, addition
 
Sounds like a Q for math.SE, but is there any mathematical system where 2+2 really does equal 5?
I doubt it.
 
@Kevin Nah, it's probably Comcast. We used to have 4 computers connected to one DSL - and it was probably like 700k or whatever the speed was at the time
@Ffisegydd Well, assuming that you hold 2 and 5 to mean what we mean in the typical Real Number system using arabic numerals
 
There was a bit in a Lewis Carrol book where the protagonist is doing math that seems to make no sense whatsoever and it turns out that all the equations are only consistent in base 13 and it took a hundred and fifty years for anyone to notice this. Or at least I think there was a bit, but maybe I dreamed it because I couldn't find a trace of evidence the last time I googled it.
 
3:59 PM
Well yes that's one easy way out of it.
 
But at the very least it's a plausible dream because Carrol was a mathematician and sort of liked absurd situations a bit
 
"I'm redefining the symbol 5 to represent the number that you pagans think of as 4"
 

« first day (2160 days earlier)      last day (2803 days later) »