« first day (3729 days earlier)      last day (1226 days later) » 

3:51 AM
@AndrasDeak Andras Deak and holdenweb, I did not mean to use this chat room as a code writing place, if my actions did come across like that I apologize for that, afaik I have always asked questions with something I tried and most of the time I had an MCVE for that
@MisterMiyagi melon :D
 
4:28 AM
@ReblochonMasque You don't need a general method, and you can ignore some of the letters, and there's not much to solve. First, look at the uniquely-determining letters: 'W' only occurs in 'TWO' (if we're not required to handle 'TWELVE', 'TWENTY'), 'Z' only occurs in 'ZERO', 'G' only occurs in 'EIGHT'. So that unambiguously gives you some digits; remove them and their letter-counts. Next, if we removed all the 'T's belonging to 'TWO', then the remaining T's uniquely determine the number of 'THREE's...
Also 'U' only occurs in 'FOUR' (if we exclude 'HUNDRED','THOUSAND'), 'V' in 'FIVE', and 'X' in 'SIX'. So in the first pass we can get a count of, and remove all letters belonging to, the digits 0,2,4,5,6,8. In the second pass we do 3 (remaining T's), 4 (remaining F's) and 7 (remaining S's). That just leaves 'ONE' for the third pass (count the remaining O's N's, and E's.) As an error check you shouldn't have any letters left over.
In this case we didn' need to set up or solve simultaneous equations, and in general English (and most other languages) don't have any numerals which all use each others' letters and no other letters, e.g. three numerals each using two of 'O','T','F'.
^^ CORRECTION: 'V' occurs in both FIVE and SEVEN. So yeah the second pass is likely to set up simultaneous eqns in 'V','E','N','O'. (And no we can't do a third pass for the letters of 'ONE'.)
@PaulMcG The default arg in which? Not filter or map? what?
@AndrasDeak Well, even if this one was non-unique, there would still be a finite (and probably small) set of solutions, since unlike general Diophantines this can't admit negative-integer solutions.
@PaulMcG What, you have green beans squatting on your lawn? This is terrible! Have you called Lieutenant Legume? Sergeant Squash?
 
4:55 AM
@smci min and max now take a default arg to be returned if given an empty sequence, instead of raising ValueError.
4
 
@PaulMcG Oh, thanks! I had forgotten that.
@python_user In general can you please use the Reply feature to specific messages rather than @-mentions, it makes it much easier for everyone else looking at the conversation, esp. afterwards. Even more so when there's 3+ people discussing. Also, if there's any time lag, e.g. you reply hours later or the next day.
^^^^^^^ Self-correction: so yeah I was wrong, you do need a general method, and will in general get a linear set of eqns. Let's hope I jump the gun less in 2021...
 
5:48 AM
@smci, thank you very much for your help, I do appreciate. As stated in my original question, I am looking for the name of this category of problems so I can conduct searches to find reading material, and learn a little bit something.
the discriminant is indeed:
{0: {'z'},
 2: {'w'},
 4: {'u'},
 6: {'x'},
 8: {'g'},
 1: {'o'},
 3: {'h', 'r', 't'},
 5: {'f'},
 7: {'s'},
 9: set()}
 
 
2 hours later…
7:45 AM
Hi guys, just found something, wanted to make sure if it was true. Assigning new values to a dict inside a function, to a dictionary that is defined outside function, does not need global dict_name inside the function ?
 
Nope. global is only required if you assign a value to a variable. Assigning to a key inside a dict or any other container is different
 
Thats cool
 
user13727121
is there a way to take the value from the input() function? Example: num = input("Enter a number: "), I want to retrieve the value that the user has entered
 
@CoreVisional print(num) ? num holds the value returned by the input(). Since we are talking about numbers, I would say num = int(input('Enter a number: ')) so that num will be a integer and not a string.
Talking about numbers, yesterday when I visited a mathematics chat group, I noticed they had a rule to not be sarcastic? or something, since the tone the person is trying to convey the message might be hard to interpret.
 
user13727121
i know, i forgot to mention that I'm working with function,
    def tenth_power(num):
        return num ** 10

    print(tenth_power(int(float(input("\nEnter a number: ")))))
 
user13727121
8:00 AM
say that the user entered 2, I want to print out a message saying 2 to the tenth power is, and then the answer
 
First store input in a variable and later do the power in it?
So something like this:
def tenth_power(num):
        return num ** 10

inp = input("\nEnter a number: ")
print(f'{inp} to the tenth power is {tenth_power(int(float(inp)))}')
 
user13727121
@CoolCloud thank you so much :D that worked
 
Watermelon!
 
Using Python >3.8 you can combine the two lines:
print(f'{inp:=int(float(input("\nEnter a number: "))} to the tenth power is {tenth_power(inp)}')
 
Formatting doesn't work in multi-line messages
 
8:14 AM
@Aran-Fey Figured that out the hard way lol
 
Also that doesn't work like that inside f-strings
 
@Tomerikoo I've actually never used the walrus operator before :p I still work with python 3.7. But it looks amazing
 
user13727121
@Tomerikoo it didn't work, it gave me ValueError: Invalid format specifier
 
user13727121
I just want to confirm something, did Python override the parameter num when you gave the argument inp?
 
@CoolCloud Don't listen to me... It doesn't work. That's what happens when you suggest code without trying it first... <face-palm>
@CoreVisional What do you mean override? The value of inp is passed to the function into the num name
 
8:18 AM
@Tomerikoo But it would be great it if worked, almost felt like exec() there
 
@CoreVisional Check this out: stackoverflow.com/questions/986006/… It explains it far better than we can here...
 
@CoreVisional inp is passed on to tenth_power and returned out as num ** 10. The value of inp however will remain unchanged(is my understanding).
 
user13727121
8:32 AM
@CoolCloud Even though I've written a bunch of notes about arguments and parameters, sometimes, I still get confused about how they work. Basically, num just acts like a variable within a function, right? And that we can replace it with variables outside of the function?
 
Yea I guess, it holds the value of any variable passed as argument.
 
user13727121
Nvm, it wasn't an error, but one long numbers 1267650600228229401496703205376, it should be 1024, instead, it printed the former
 
user13727121
8:47 AM
def tenth_power(num):
    return num * 2

x = tenth_power(1)
print(tenth_power(x))
 
user13727121
may I know why the output is 4 instead of 2, Im only storing it in a variable
 
x is 2 and you are passing that 2 onto tenth_power(print(tenth_power(2)) which makes the 2 become 4 and prints it out, but this 4 is not saved anywhere
 
user13727121
@CoolCloud hmm, that's weird, but I specify 1 for the function tenth_power in x, and then I printed out the function through the variable x
 
The function returns whatever the number multiplied by 2 is, the number you are passing is 2 because x becomes 2 after you pass 1.
Just think of it simply as, x = tenth_power(1), now 1 goes inside the function as num and now the value of num is 2 which is returned by the function and stored inside of x as you are saying x = tenth_power(1). THen print(tenth_power(x)) is same as print(tenth_power(2)) because the value of x is 2, just like the previous steps.
 
user13727121
ohh, wait, i think i just figured it out. Basically, the program ran twice, is that it? The first time it ran, it multiplies 1 to 2, so now that x holds the value 2, the second time it ran the function, it takes the value in x and again, multiply with 2?
 
8:54 AM
@CoreVisional Yep, thats my understanding.
 
Correct, but what you're calling "the program" is actually "the function"
 
Oh, and I was actually thinking of starting another chat group but for tkinter. I know tkinter belongs to python and its talk shall be here, but I think it deserves a separate chatroom as most of the questions related to it are basic and if people wanted to clear something they could just ask it out there. Thoughts?
 
user13727121
@CoolCloud I see where I got that huge numbers from now, it was 2 ^ 10 = 1024, and then it ran the second time, making it 1024 ^ 10. Thank you so much for the explanation :D
 
Watermelon!
 
@CoolCloud That room will probably be pretty dead
 
9:00 AM
@Aran-Fey That could be VERY true
But I think it would be good to have a place to get some opinion about tkinter too.
 
@ReblochonMasque I don't know, I never saw a problem like that before, I can't find a name for it. "Solving digit-letter-sums to infer the original digits" is what I'd call it, or "spelled-digit-sums", but those don't turn up anything useful.
...perhaps start hunting from WP: Verbal arithmetic. You could post in some of those forums, or write to the editors.
...might as well come up with some witty cryptarithm for the year 2020, although it would probably involve the name of the US leader, and a v!rus, which is verboten.
 
A numpy question: Is there a way to pack array of uint8 into array of uint32? (I figured out numpy.ndarray(buffer=..., dtype=..., shape=...) but it seems ugly)
@CoreVisional ... have you read the room rules? "Don't star posts to reward users for answering your question. " (assuming you starred them)
 
9:15 AM
@user202729 For what purpose? Are you talking about some generalized array of arbitrary number of uint32, or is it RGBa colors and you want to access each 8-bit component? (e.g. with bitmasks and &/|)
 
@smci Huh, yes, it's rgba, but it doesn't matter right?
 
@user202729 It does matter in the sense unless you're insisting this must be implemented purely in numpy, that there are several good python image-processing libraries, so don't reinvent the wheel. Search SO to see what people use. (I programmed a bit of RGBa manipulation a while ago, I'm looking to find my code for you...)
 
I did try to search with both numpy and opencv keyword...
Okay, this is the context. stackoverflow.com/questions/27882255/…
 
No, search by keywords, to get names of libraries, not the other way around. [python] rgba library gets tons of mentions of PIL (Python Imaging Library), plus some others
@user202729 Now you're confusing me. That OP wanted to play the videos from the OpenCV tutorials inside Jupyter Notebook instead of dedicated windows, as they default to. The question seems to have several answers. And you posted a comment onto someone else's answer, and referenced playing local video in (jupyter)/IPython notebook. But this is not starting with the RGBa array. I cant read your mind for your use case - are you trying to do the same thing as those Q&A, or something different? ...
... (if so, post a clear question with MCVE). Anyway I don't know about that area.
 
9:36 AM
sigh
 
@user202729 ... well what's your actual use-case?
@ReblochonMasque: ok here are some cryptarithms on themes from 2020, some are quite witty.
 
@smci (Didn't I say it in the comment?) I want to convert w*h*4 (uint8_t) rgba numpy array into w*h (uint32_t) array, also rgba but pack each pixel into one uint32_t.
I also said that numpy.ndarray(buffer=a, shape=a.shape[:2], dtype=numpy.uint32) works well and ask for an alternative way, if that given way isn't typical
 
@user202729 That's waaaaay too low-level, you didn't say for what: are you importing these OpenCV videos, if so what library did you use? And what's your ultimate purpose: to play the OpenCV videos under jupyter? And what are the issues? (frame rate? memory?) Trying to write some video converter in numpy is totally reinventing the wheel.
 
# I want to get a frame **with VideoCapture** and plot it **with bokeh**.
# this is not really practical, because IPython.display can plot it too

#read one frame for testing
video = cv2.VideoCapture(0)
_, frame0 = video.read()
video.release()

#now plot it with bokeh
from bokeh.plotting import figure
from bokeh.io import output_notebook, show, push_notebook
output_notebook()

assert frame0.shape == (720, 1280, 3)
frame=cv2.cvtColor(frame0, cv2.COLOR_BGR2RGBA) # because Bokeh expects a RGBA image
Surely I don't have to use these 2 libraries, but it's weird to solve a problem by "switching to another dictionary", isn't it...
 
9:54 AM
@user202729 Ok, it's good to state the problem. Best to post a Bokeh question in Bokeh Discourse (discourse.bokeh.org/search?q=rgba), or else here. I don't know the answer.
I don't understand your remark "this is not really practical, because IPython.display can plot it too" - do you mean you just want to do this in Bokeh as a learning exercise? or not rely on jupyter calls? or something else?
 
Hm... the other user said that it's faster, so I want to benchmark those..
Sounds pretty practical isn't it...
That having said, what's image-processing-specific at `numpy.ndarray(shape=frame.shape[:-1], dtype=numpy.uint32, buffer=frame)`? Surely numpy supports byte packing and stuff too, no?
cv have already done the bgr2rgba part.
 
@user202729 Then I still can't understand your remark "this is not really practical, because IPython.display can plot it too", it sounds like saying "this is not a serious question, I only want someone to show me how to do it in Bokeh, but I'm not going to use it", I would ignore a question that said that. I'd rewrite that to "I want to implement this in Bokeh (yes I'm aware IPython.display can plot it too)".
 
user13727121
@user202729 Yes, I've read the rules. Only thing is that I starred both because the answers were useful for a beginner. It also cleared my confusion.
 
10:32 AM
@Tomerikoo please don't try to do that and don't suggest that others do that. Life is not code golf and Python is not Perl.
@user202729 arr.view(dtype=np.uint32)
 
10:46 AM
@AndrasDeak Looks correct. (by the way is this a numpy basic thing? I tried to search raw data representation, convert uint8 to uint32 numpy and pack bytes and found nothing)
 
@user202729 yes, views can reinterpret memory. In contrast to .astype which converts values
 
What does that actually mean, though? Presumably it's a copy of some sort?
 
@roganjosh nope
It says "look at this chunk of memory as if it were uint32"
 
It's view (so modify it will modify the original)
(same with ndarray constructor.)
 
arr[:] is also a view. So is arr[::2]. They don't copy. Check their .base attribute. It's only None for copies.
 
10:52 AM
@AndrasDeak so that's purely a CPU instruction then?
 
@user202729 side note: you typically never have to use the ndarray constructor directly
@roganjosh I don't understand the question
 
What. Every instructions are CPU, no? Perhaps you mean pointer manipulation or something.
@AndrasDeak Yes, I knew that, ndarray constructor said that it's low-level.
 
Well, I'm confused about the "what" that is looking at the memory as though it were a different type than it is stored in memory as. If there's no copy, then I guess the only difference is how the CPU treats the data when it comes to manipulating it in some way
 
Yup
 
@AndrasDeak It doesn't work as I said shortly after and apologized for not testing...
 
10:55 AM
@roganjosh array as wrapper around a chunk of memory. Which it always is.
 
Ah ok, I had it framed incorrectly in my brain. Thanks
 
@Tomerikoo that's tangential. The problem is unreadable one-liners for absolutely no reason. Input handling, type conversion and formatted printing in one expression... great thing to read and debug.
 
 
3 hours later…
2:03 PM
@roganjosh Thank Travis Oliphant for the buffer protocol, introduced mostly due to his wish to support multiple interpretations of packed arrays of data docs.python.org/3/c-api/buffer.html
 
@holdenweb Perfect. That's exactly what I was missing, thanks!
 
2:34 PM
90 minutes to 2021 - Happy new year everyone - going to bed.
 
<-- genuinely didn't realise it was NYE. Happy New Year to you too. All the best!
 
mck
Happy 2021!
 
2:50 PM
I'm actually pretty shocked I didn't realise it was NYE. 2020 is just: wake up --> frobnicate broken bizbaz --> sleep. I might even turn the TV on for once tonight
 
 
2 hours later…
4:45 PM
Who won't be happy to see the back of 2020?
 
I don't care, does that count?
 
5:22 PM
Morning all. I have a very dumb question to ask but I feel I have to ask it anyway....
Is the only way to handle leap year days of Feb 29th to set the day to the 28th? Is that it? Python 3.7.
https://stackoverflow.com/questions/5319103/handling-leap-years-in-python

One of the many pages I've been looking at
 
You'll have to be more precise about what "handle" means here. What's happening and how do you intend to deal with it? The user inputs Feb 29th and you automatically change it to Feb 28th if it's not a leap year?
 
How would that "handle" them? The time and datetime modules have functions to convert textual date representations to Python objects. It would seem safest to use those for date comparisons.
 
user13925035
5:39 PM
hi gues
 
user13925035
first time here
 
5:50 PM
Welcome @AmineBradli
 
6:12 PM
Isn't it great when people ask a question and then disappear? At this rate I'm just gonna stop responding to people at all
 
I'm so sorry I didn't see the tab move.
I'm processing a lot of date times and the only ones I get the error "day is out of range for month" is on leap years for Feb 29th. It seems in 2016 this was fixed and a colleague has it working for them for leap years. So I have no idea why it isn't working on my machine.
 
@Aran-Fey snarky non-sequiturs are an acceptable alternative
 
Sorry. I'll just see my way out. Have a nice holiday.
 
@Pandasncode no need to be dramatic :) We just have a lot of lazy askers who hit and run. You're welcome to ask for help here. It's just been a long year.
but you'll probably have to provide a good MCVE for us to be able to help you
 
So what are you doing that causes this error? How are you creating your datetime object?
 
6:26 PM
it's probably a pandas question
 
That would make sense. Doesn't matter what python version you have if the problem is in an outdated library
 
pun intended, I hope :P
I think the "this was fixed" concerns their local code, not library code
 
@AndrasDeak haha, no. Took me a while to figure out what you were referring to
 
6:45 PM
I have a spare panda if it'll help with the maths?
 
7:08 PM
Happy New Year Python-istas !! May this year bring new happiness, new goals, new achievements, and a lot of new inspirations on our life. - From India
 
7:38 PM
Ugh, the documentation for setuptools is horrid.
 
sure is. best part is usually getting to learn whether the thing you want to know is 1) in the setuptools docs, 2) in the distutils docs, 3) in the very sparse pip docs, or the all time favorite 4) undocumented.
 
LOL
That said, with some teeth-gnashing, I finally managed to remove 3 no-longer-used files from my Python package.
New Year present from one of the maintainers... a New Minor Version! :D
 
Hey ya'll, quick question. Does python have a name for primitive types, like int, char, string, float or bool (as opposed to a complex class)
 
I don't think it does
 
Coo', thank you!
 
8:09 PM
also, ALSO ... pypy3 on FreeBSD is frankly driving me up the wall.
 
What's wrong with it?
 
 
1 hour later…
9:42 PM
cbg, everyone
Trying to think of something star-able so I can get the Happy New Year hat...
 
try chat.stackoverflow.com/rooms/info/226664/… so we don't have to star spam this room up
 
Of course there's a room for that. Thanks!
Not that I'll be leaving here, I like to lurk.
👀
 
9:57 PM
You know they'll all be gone in a few days, right? All that digital gudness will dissolve to nothing
 
This is the way.
 
10:12 PM
It is known.
 
10:26 PM
Morning cabbage from next year! :)
 
@ReblochonMasque How is it over there? I'm still 6½ hours away.
 
@roganjosh Thank you, all the best to you too. :)
it is 6:30 am, and a gorgeous day is pointing at the horizon.
 
10:46 PM
Slightly early/late(depending on your TZ) - but happy new year folks... paws crossed that 2021 isn't quite so "interesting"... and my fellow RO's - thanks for all you do.
 
@Sidney try "built-in types" or possibly "scalar types" if you want to exclude list, tuple and dicts.
 
Oh man, I've been so isolated from any of the usual end-of-year stuff that I totally forgot there'd be fireworks today
My sleep rhythm's been all over the place in the last week, let's see if this'll make it better or worse
 
don't think I'll be about tomorrow so, and have some home stuff to do over the weekend so will be trying to avoid the computer, so see you all for some catch up on the 4th :)
 
Yes, Happy 2021 rhubarb to everyone.
 
happy cabbages
 
10:55 PM
Happy cabbages indeed
 
ugh, midnight
 
Thanks to firework noises in the middle of the night, every year is off to a bad start :D
 
there's an illegal party at my upstairs neighbour
leave it to reinforced concrete to be as thin as paper when it comes to noise filtering
 
Happy New Year - Don't drink and sudo
16
 
11:21 PM
@AndrasDeak Are you in Ireland?
 
that would mean I still have half an hour to midnight, so no ;)
 
Isn't Ireland UTC-0600?
I mean UTC-0100
 
How many drinks have you had already? :D
keep going
UK/Ireland are UTC+0 in winter, we're UTC+1
 
Right. Time zones confuse me more than they should...
And no, I haven't started drinking yet. Thanks for reminding me!
 
At least they'll stop moving around now (maybe. Probably. Maybe not.)
 
11:27 PM
A while ago I was surprised to find out I'm UTC+1. I thought "Isn't Greenwich right above us though??". Turns out it's quite a bit to the west
 
Wat?
Are you no longer in Austria?
/were
 
Another victim of geography! :P
Still in Vienna :P
 
Or did you just not know that Greenwich is in the UK? Or that the UK is not to the North? Something's off here :D
 
Yeah, I thought the UK was straight north from here
 
ah
That's a new one to me
 
11:29 PM
Or at least not that far to the west
 
Perhaps it's different for me because we're more to the east compared to you, so most of Europe is obviously to the west. To me the surprising bit is that Italy's heel is to the south of us
 
Interesting insight to people's perspectives from their viewpoint! :)
 
That makes sense to me, since Italy is right below us (*goes off to double-check if it really is*)
 
Italians: "what heel?"
@Aran-Fey is you country's shape "obviously what a country is shaped like"? Because that's how I feel about our country's shape, and others, like yours, look weird to me.
 
I was very surprised to find out that where I lived in Mandchuria was at a lat equivalent to France/Spain... Bloody cold there!
 
11:35 PM
turns out there's at least two dimensions to consider ;)
 
@AndrasDeak Nah, I think most countries are more... convex. Ours is definitely shaped weird
Alright, time to go to bed so I can get up in time for my 3AM appointment "be awake for no good reason". Rbrb
 
11:58 PM
rhubarb
 

« first day (3729 days earlier)      last day (1226 days later) »