On 2011-11-25 14:52, Luca Beltrame wrote:
I've been looking through the code and I have a couple of questions on design.
I wonder if

- it is preferable to hack in a special case of "tlist" being a Matrix in the
DataFrame constructor, e.g. if isinstance(tlist, Matrix);
- it is preferable (like I suggested at first) to have a separate parameter to
construct an instance from a Matrix.
- it is preferable using a class/static method to create a DataFrame from a
matrix (e.g. DataFrame.from_matrix)

Opinions?

May be there is no perfect solution.
Python does not have typed parameters in function signatures (includes methods and constructors), which pushes boilerplate code to consider separate types to the developer. Duck-typing can alleviate some of this, but is not always possible (one cannot always have a full control over the possible classes for a given parameter in the function).

Currently, the constructor to DataFrame accepts a "tlist" ("tagged list") as a main parameter. The idea was to be relying on duck-typing, somehow, and anything that would exhibit the behaviour (relevant methods or properties) of a tagged-list will be accepted. The implementation is slightly more complex because of a mixture of reasons ranging from patching shortcoming in the design, to impossibility to apply duck typing all the way, to quirks in R's own design. Your questions are triggering some thoughts, and may be there is a better way to implement this than it currently is.

The second option in your list (separate parameter) is, I think, the least desirable of the options as it is pushing some of the complexity back to the user (longer function signature, which optional parameter to use given the input).

The third option can be considered anyway, and called from the main constructor (so your code is broken down into separate units.

L.



------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d


_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to