These are chat archives for data-8/datascience

30th
Nov 2015
Carl Boettiger
@cboettig
Nov 30 2015 19:05
@SamLau95 Any recommendation for a style guide for python? In particular, looking for clarification on when to use the notation x.method() vs the notation method(x)
Stefan van der Walt
@stefanv
Nov 30 2015 19:07
Is this specifically wrt numpy?
Carl Boettiger
@cboettig
Nov 30 2015 19:08
anything really, it's all pretty new to me. does style differ wrt different modules?
Stefan van der Walt
@stefanv
Nov 30 2015 19:09
I think numpy has both class and normal methods available due to history, but in most other packages you have only one or the other.
Most of the time, we try to use Python's rich containers in combination with functions. Only when there's a lot of state being dragged around the system do we start looking at objects even.
Carl Boettiger
@cboettig
Nov 30 2015 19:13
that seems like a good starting point. so just to be clear, you call method(object) function notation, and object.method to be object notation?
it seems that plotting starts off with method notation in the textbook, but switch later into object notation?
Sam Lau
@SamLau95
Nov 30 2015 21:32

@cboettig do you have an example? we use stuff like

foo_table.hist()

quite a bit, but when we needed plotting functionality that the table didn’t provide we switched to using matplotlib directly instead (the plots variable). for example, in http://data8.org/text/4_prediction.html#correlation we make a scatter plot using

plots.scatter(ht_pw['mat_ht'], ht_pw['mat_pw'], s=5, color='gold')
plots.xlabel('height (inches)')
plots.ylabel('pregnancy weight (pounds)’)

this is because the table class didn’t provide the functionality we wanted in order to make these plots; we typically try to use the Table class as much as possible