abscondment / statistics2

Shin-ichiro Hara's library, updated for Ruby 1.9 & packaged as a gem.
http://github.com/abscondment/statistics2
59 stars 13 forks source link

Modernize gem structure #3

Closed sj26 closed 12 years ago

sj26 commented 12 years ago

Fixes a few non-ruby-isms present in the gem. See 4a46be1 for more details.

Mainly, don't touch the load path, and uncomplicate method definition/overriding.

sj26 commented 12 years ago

Worth noting that all tests still pass:

[~/Projects/statistics2:modernize⚡]% ruby -I lib -I ext -r test/unit -e 'Test::Unit::AutoRunner.run' test
Run options: 

# Running tests:

........

Finished tests in 3.063680s, 2.6112 tests/s, 1769.7671 assertions/s.

8 tests, 5422 assertions, 0 failures, 0 errors, 0 skips
abscondment commented 12 years ago

Thanks for the patch!

No need for hoe, this is a fairly simple gem. Also hoe is awful in most cases.

I have no love for hoe, but I'd for like there to be an easy way to build the extension and run tests via a single command. Do you have any suggestions?

Also no need to kill methods before overriding—Ruby just lets us do it.

Yeah, it does let you -- but it generates warnings, and I'd prefer to quell the warnings.

brendan@flask:~/code/statistics2$ ruby -w -I lib -I ext -r test/unit -e 'Test::Unit::AutoRunner.run' test
/home/brendan/code/statistics2/lib/statistics2.rb:123: warning: method redefined; discarding old normaldist
/home/brendan/code/statistics2/lib/statistics2.rb:128: warning: method redefined; discarding old pnormaldist
/home/brendan/code/statistics2/lib/statistics2.rb:198: warning: method redefined; discarding old chi2dist
[...]

Revert the overriding bits and I'll apply the rest happily.

sj26 commented 12 years ago

Overriding that way is still a ruby code smell. I've refactored into two modules which makes the tests cleaner, too.

Included is a rakefile to make compiling the extension and running the tests easy, too:

$ rake
creating Makefile
linking shared-object _statistics2.bundle
malloc_limit=1000000000 (8000000)
heap_min_slots=1000000 (10000)
Run options: 

# Running tests:

........

Finished tests in 0.627370s, 12.7516 tests/s, 8642.4279 assertions/s.

8 tests, 5422 assertions, 0 failures, 0 errors, 0 skips
abscondment commented 12 years ago

I like that solution. Thanks!

sj26 commented 12 years ago

Yay! :-)