rsokl / Learning_Python

Source material for Python Like You Mean it
https://www.pythonlikeyoumeanit.com/
Other
166 stars 54 forks source link

New Module: Odds & Ends #15

Closed rsokl closed 5 years ago

rsokl commented 6 years ago

Precise content to be included here is up for debate

Matplotlib

File I/O

String Formatting (??)

Basic of modules (??)

davidmascharka commented 6 years ago

I'm up for taking matplotlib and I could do basic file I/O. With mpl are you also wanting to talk about loading and saving images, or should that be covered elsewhere or not covered for this?

davidmascharka commented 6 years ago

I like the idea of having string formatting (including f-strings) in here. They're so genuinely useful and make code way cleaner in my opinion.

rsokl commented 6 years ago

Including image loading and saving would be good. There isn't too much to cover towards that end. Here is a decent matplotlib reference (although I dislike the guy's formatting and writing style). I do think we should teach all matplotlib stuff based off the fig & axis objects.

rsokl commented 6 years ago

That seals it - string formatting should be included. I guess we should be wary of being too complete, which is what bogs the official docs down, and focus on the most practical aspects. f-strings for sure, specifying number of decimal places, the .format method.

Would you agree that it should be its own sections? It seems like it should, to me.

davidmascharka commented 6 years ago

The only reason I'd be slightly wary of talking about image saving/loading is that there are a lot of ways to save and load images. I think it's worth talking about matplotlib's imsave and imread because they're really useful. I'm not sure whether mentioning PIL or any other projects would be valuable too -- maybe as a comment at the end of talking about matplotlib's functionality for images?

davidmascharka commented 6 years ago

I would agree that string formatting should have its own section. I agree with not talking about too much functionality. A simple primer and a link to the documentation should be great.

rsokl commented 6 years ago

Yeah, I'd only point the reader to PIL in passing, at most. I think imread/imsave and fig.save/fig.load is all that really needs mentioning

davidmascharka commented 6 years ago

@rsokl #21 adds matplotlib functionality. It probably needs a bit of reorganization to better fit with the rest of the content, but it should cover everything a new user needs to get running. PIL doesn't really seem natural to fit in there and I'm not sure it's necessary. If you want to get into image processing in Python then of course it might be useful. That seems like a topic for a different source or a different module though.

AFederici commented 6 years ago

I decided to add my comments to the already open issues as to not clutter it up more than it needs to be.

Odds and Ends

Overall I thought these were very very useful sections and I will most likely find myself referencing this section more than the rest.

In the opening section pyplot.subplots is colorized red due to the formatting which I thought looked weird because everything else surrounding it is blue.

Matplotlib

In the first code snippet in the third comment it should say "we create both a figure and axis object" not "we figure and axis object"

Under plotting and saving a figure it is mentioned that nrows and ncols are keyword arguments yet they got passed without keywords which I thought was a little bit confusing but this might just be me not remembering that exact details of how arguments need to be specified in python.

Working with files

"On such occasions you can simply" not "On such occasions you can simple"

Additionally, I am curious as to when pickle would be used over numpy's load and save functions? From what I understand, np.save has an argument allow_pickle= True that will automatically pickle the object if it isn't of a numerical type. But when possible this function will also avoid pickling as pickling has security and portability issues making it seem like np.save / np.load is always the way to go.

davidmascharka commented 6 years ago

In the opening section pyplot.subplots is colorized red due to the formatting which I thought looked weird because everything else surrounding it is blue.

:thinking: :confused: where is this? I'm staring at that section going crazy trying to find red things....

AFederici commented 6 years ago

image

Not a big deal or anything I just thought it looked a little strange

rsokl commented 6 years ago

I had been using the stylization so that it would be obvious that the reader is seeing code and not a typo

davidmascharka commented 6 years ago

Is adding a numba primer still in the works? If not, this can be closed.

davidmascharka commented 5 years ago

This is inactive and the format function is already covered; f-strings could fit in there but they're (relatively) minor so I'm going to close this. An f-string-specific issue could be opened if that's a real need.