Skip to content

Instantly share code, notes, and snippets.

@llimllib
llimllib / jenks2.py
Last active April 3, 2023 19:26
The jenks algorithm in python. Since replaced with: https://github.com/llimllib/jenks-python which has tests and stuff
import json
from pprint import pprint as pp
def jenks_matrices_init(data, n_classes):
#fill the matrices with data+1 arrays of n_classes 0s
lower_class_limits = []
variance_combinations = []
for i in xrange(0, len(data)+1):
temp1 = []
temp2 = []
$ python -mtopaz -e "a"
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.3/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/local/Cellar/python/2.7.3/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/bill/code/topaz/topaz/__main__.py", line 9, in <module>
sys.exit(entry_point(sys.argv))
File "topaz/main.py", line 19, in entry_point
space = getspace()
$ ../mspec/bin/mspec -t bin/topaz_untranslated.py ../rubyspec/core/range/each_spec.rb
topaz (ruby-1.9.3p125) [x86_64-darwin]
EE.EF
1)
Range#each passes each element to the given block by using #succ ERROR
NoMethodError: undefined method `succ' for MockObject
/Users/bill/code/mspec/lib/mspec/mocks/proxy.rb:8:in `method_missing'
/Users/bill/code/mspec/lib/mspec/mocks/proxy.rb:8:in `method_missing'
topaz/objects/rangeobject.pyc:29:in `each'
$ ../mspec/bin/mspec -t bin/topaz ../rubyspec/core/range/begin_spec.rb
topaz (ruby-1.9.3p125) [x86_64-darwin]
.
Finished in 0.002603 seconds
1 file, 1 example, 6 expectations, 0 failures, 0 errors
$ cd ..
$ python -mtopaz -e "a=[]; (:a..:b).each {|x| a<<x; a<<x.class}; puts a"
[a, Symbol, b, Symbol]
$ py.test tests/objects/test_rangeobject.py
============================================ test session starts =============================================
platform darwin -- Python 2.7.3 -- pytest-2.2.4.dev2
collected 10 items
tests/objects/test_rangeobject.py .........F
classdef.app_method("""
def each
unless self.begin.is_a? Integer
raise TypeError, "can't iterate from Float"
end
i = self.begin
lim = self.end
lim += 0.1 unless self.exclude_end?
while i < lim
yield i
require 'json'
require 'open-uri'
class Hubstat < Linkbot::Plugin
@@config = Linkbot::Config["plugins"]["hubstatus"]
if @@config
Linkbot::Plugin.register('hubstat', self, {
:message => {:regex => /\A!hubstat/, :handler => :on_message, :help => :help}
:periodic => {:handler => :periodic}
require 'json'
require 'open-uri'
class Hubstat < Linkbot::Plugin
@@hipchat = Linkbot::Config["plugins"]["hipchat"]
Linkbot::Plugin.register('hubstat', self, {
:message => { :regex => /\A!hubstat/, :handler => :on_message, :help => :help }
})
[vagrant@precise32:/vagrant (master)]$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.
[vagrant@precise32:/vagrant (master)]$ gem install bundler
Successfully installed bundler-1.2.3
1 gem installed
[vagrant@precise32:/vagrant (master)]$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.
redis elapsed: 0.00105381011963
1234567890
pg elapsed: 0.00156402587891
1234567890