« first day (4326 days earlier)      last day (614 days later) » 

1:28 AM
Where can I find the implementation of the type class? I've tried looking here to no avail.
 
Thanks @vaultah. Are we allowed to ask for clarification to answers posted on the main site here?
 
1:50 AM
In general, I would say yes. Here are the rules of this room though, just in case sopython.com/chatroom
 
 
2 hours later…
3:30 AM
Cabbage
Justed editing an answer and found myself typing "increasing pythonicity" as the reason. Thoughts on the use of "pythonicity"?
 
 
4 hours later…
7:30 AM
Hi guys!
@SargeATM prob something about being more pythonic (like "describes a coding style that leverages Python's unique features to write code that is readable and beautiful")
 
@SargeATM Made more pythonic
 
 
5 hours later…
12:24 PM
Why is (0, 0) the top left of an image?! Aaaarghhh
In any sane geometry module, increasing y means going up. Why do images have to be backwards? You want to represent an area of the image as a Rectangle? Screw you, the coordinates are upside down
I want to go into cryo-sleep until the world is less stupid.
 
1:12 PM
Isn't that super common in graphics systems
 
Dunno. Is there a difference between images and graphics?
 
1:47 PM
@Aran-Fey This history lesson is here and it looks like convention might have carried over into some image formats and not others
 
Wow, that's from way back when
 
2:07 PM
What's harder to find is what image format uses which convention in a list somewhere. Seems like it would be nice to have some list to crossref against if you were making an app to deal with e.g. jpeg and .png
 
2:21 PM
It's nothing quite that low-level, I'm just dealing with PIL
Well, that and I have to decide if I want to go along with the y-is-down convention or not
 
 
2 hours later…
4:15 PM
Half-serious proposal: define the constants UP = -1; DOWN = 1 and incorporate them into every expression in your program that does arithmetic on y coordinates. e.g. rewrite sprite.move(23, 42) as sprite.move(DOWN*23, 42)
Then, if it turns out that PIL disagrees with you about what direction "up" is, you only need to move one hyphen in your code
 
As for the geometry side of things, I decided to make my own Rectangle plus UpsideDownRectangle. Still unsure about the API design though. I want to add a switch like library.get_some_rectangles(upside_down=True), but I can't decide on a name and default value for the parameter
 
A super-generalized approach could be: define a method transform(self, matrix) on all of your geometry types, which makes it easy to apply any affine transformation to them. Then flipping the entire scene is as easy as scene = scene.transform([[1,0],[0,-1]])
 
Oh, I'm not planning to implement something as fancy as transforms. I have 3 classes Point, Vector, and Rectangle that support +, - and in and that's pretty much it
Plus the UpsideDownRectangle which swaps the meaning of rect.top and rect.bottom
 
Valid. I was just about to say it's likely overkill. And you'd have to figure out what to do if a transformation turns a rectangle into a non-rectangle. It could be easily skewed into a parallelogram, for instance.
 
4:39 PM
On the bright side, it's impossible for an affine transformation to turn a parallelogram into a non-parallelogram. So you wouldn't need to worry about implementing __contains__ for arbitrary quadrilaterals. Just parallelograms, which I reckon is considerably easier
 
Definitely, because parallelograms are guaranteed to be convex
 
4:58 PM
fun fact, the BMP format considers the bottom left corner of the image to be the "first" pixel. It gets stored in the first slot of the pixel array. Compare to, say, png, where the top left corner gets the first slot.
 
Honestly, it makes sense to store the top of the image at the start of the file. Gives it more time to load, since we always scroll from top to bottom
 
I was about to say "... Unless it's an interlaced png", but upon closer inspection, the top left corner is still the first pixel in the array, even though everything else gets jumbled around. Top left is getting preferential treatment, no fair
 
 
2 hours later…
7:10 PM
@KarlKnechtel Java marketed itself on this?
 
7:52 PM
I finally got bored enough to answer a pandas question on SO. But in my wanderings from that through other questions, I think I've found the most impressive pandas one-liner in existence
intermediate_df = df.groupby(by=['country','grade','category','id'], as_index=False).agg(int_totals=pd.NamedAgg(column='amount',aggfunc='sum'),int_counts=pd.NamedAgg(column='id',aggfunc='count')).groupby(by=['country','grade','category'], as_index=False).agg(mean_totals=pd.NamedAgg(column='int_totals',aggfunc='mean'),mean_counts=pd.NamedAgg(column='int_counts',aggfunc='mean'))
... How does someone conceive of this?
Sorry, it's syntactically invalid at the end, actually, because it overspills the chat char limit. Wow
huh, or not. I didn't realise the code formatting gave a scroll bar in chat until just now (or I just forgot)
 

« first day (4326 days earlier)      last day (614 days later) »