Almost forgot ... I also added a minimal *.Rd file for the S4-class definition:
https://github.com/lianos/datatable/blob/master/pkg/man/data.table-class.Rd -steve On Tue, Nov 30, 2010 at 12:03 AM, Steve Lianoglou <[email protected]> wrote: > Hi, > > I think running the tests by invoking the test.data.table from inside > an "Examples" section of an .Rd file are causing some pain. > > There are complaints of locked environments: > > Error in assign(mname, def, where) : > cannot add bindings to a locked environment > > when defining S4 classes and methods inside the test.data.table function. > > Defining the class outside of the function works and lets the tests > pass. Defining functions out there doesn't help, so those tests are > commented out (see lines 552 - 556): > > https://github.com/lianos/datatable/blob/master/pkg/R/test.data.table.R > > I'm not sure how you feel about this approach, but these work. > > IMHO it would be better to use something like testthat or RUnit and > run the test harness for the package with those. I have a feeling we'd > avoid these problems that way. If the devs are willing to consider > that, I'd volunteer to port the tests over. > > At any rate, let me know if you're OK with these S4 modifications and > I can commit back to the svn repo. > > In summary, I've: > > * Added an AllS4.R file to add the setOldClass stuff to include > data.table's in S4 "slots" and defined as(...) methods to convert > data.table to data.frame, and vice versa. > > * Modified the namespace to export the data.table class for other > packages to use it. > > * Bumped version number in DESCRIPTION to 1.5.2, and added an Imports: > methods to it. > > * Made changes to the NEWS file > > * Added some tests to test.data.table() function. > > I've used this updated package as an import to another package I'm > dev'ing and things seem to work as expected ... > > Thanks, > -steve > > > On Wed, Nov 24, 2010 at 6:01 PM, Matthew Dowle <[email protected]> wrote: >> >> For the setClass call itself that would be ok, and then use the class >> somehow, to test it worked? >> >> setClass("DTS4", representation(info="data.table")) >> test(228, is.data.table(new("DTS4"))) >> >> >> On Wed, 2010-11-24 at 14:26 -0500, Steve Lianoglou wrote: >>> Hi, >>> >>> On Wed, Nov 24, 2010 at 2:13 PM, Matthew Dowle <[email protected]> >>> wrote: >>> > Try >>> > >>> > test(228, setClass("DTS4", representation(info="data.table")), "DTS4") >>> >>> I tried that at first, but you get an error from (I think) defining a >>> new class in the wrong place, specifically: >>> >>> Test 228 Error in assign(mname, def, where) : >>> cannot add bindings to a locked environment >>> >>> > In test.data.table we only use try() for when the correct result is an >>> > error and the test is that we get the right error message with a grep in >>> > another test just afterwards. Otherwise we can leave test() to try(). >>> > >>> > Code that shouldn't fail can just be written (and would cause >>> > test.data.table to stop then and there on error) or inside a test(). >>> >>> So, in light of the above problem, would you rather I just write the >>> code that defines the new S4 class and not test that "it worked" since >>> we assume implicitly it works if no error stops test.data.table() form >>> completing? >>> >>> -steve >>> >> >> >> > > > > -- > Steve Lianoglou > Graduate Student: Computational Systems Biology > | Memorial Sloan-Kettering Cancer Center > | Weill Medical College of Cornell University > Contact Info: http://cbio.mskcc.org/~lianos/contact > -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact _______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
