code
stringlengths
1
1.72M
language
stringclasses
1 value
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
# -*- coding: utf-8 -*- # # jQuery File Upload Plugin GAE Python Example 2.0 # https://github.com/blueimp/jQuery-File-Upload # # Copyright 2011, Sebastian Tschan # https://blueimp.net # # Licensed under the MIT license: # http://www.opensource.org/licenses/MIT # from __future__ import with_statement from google.appeng...
Python
# ================================================ # amboy.py - CheckNerds Labs. # http://www.checknerds.com # Backup all your items in CheckNerds. # Original Author: CNBorn, http://cnborn.net, 2009 # # # ================================================ ''' Usage: Create your .checknerds file in your home directory...
Python
# ================================================ # trigo.py - CheckNerds Labs API testing script. # http://www.checknerds.com # # Original Author: CNBorn, http://cnborn.net, 2009 # # # ================================================ ''' Usage: Create your .checknerds file in your home directory(for example, /ho...
Python
# ================================================ # # http://www.checknerds.com # # Original Author: CNBorn, http://cnborn.net, 2009 # # # ================================================ import sys from ConfigParser import ConfigParser import os import datetime import hashlib import urllib import httplib class ...
Python
#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fishes.settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
Python
from django.conf.urls import patterns, include, url # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Examples: # url(r'^$', 'fishes.views.home', name='home'), # url(r'^fishes/', include('fishes.foo.urls')), # Uncomm...
Python
# Django settings for fishes project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': '/home/c...
Python
""" WSGI config for fishes project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` s...
Python
# coding=utf-8 from django.db import models class Image(models.Model): url = models.CharField(max_length=1000) description = models.CharField(max_length=2000) def __unicode__(self): return self.url class ImageWelcome(Image): pass class Question(models.Model): question = models.CharField(max_length=1000) an...
Python
""" This file demonstrates writing tests using the unittest module. These will pass when you run "manage.py test". Replace this with more appropriate tests for your application. """ from django.test import TestCase class SimpleTest(TestCase): def test_basic_addition(self): """ Tests that 1 + 1 a...
Python
from django.conf.urls import patterns, url from model import views urlpatterns = patterns('', url(r'^$', views.index, name='index') )
Python
from django.contrib import admin from model.models import * admin.site.register(ImageWelcome) admin.site.register(Question) admin.site.register(Group) admin.site.register(SubGroup) admin.site.register(Item)
Python
from django.shortcuts import render from model.models import * def index(request): #latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] welcomeImages = ImageWelcome.objects.all() groups = Group.objects.all() questions = Question.objects.all() context = {'welcomeImages': welcomeImages, 'groups': g...
Python
#!/usr/bin/env python # -*- encoding:utf8 -*- # protoc-gen-erl # Google's Protocol Buffers project, ported to lua. # https://code.google.com/p/protoc-gen-lua/ # # Copyright (c) 2010 , 林卓毅 (Zhuoyi Lin) netsnail@gmail.com # All rights reserved. # # Use, modification and distribution are subject to the "New BSD License" #...
Python
import csv import operator def calculateTotalMark(emmark,epcmark,qpmark,qpmaxmark,qcmark,qcmaxmark,qmmark,qmmaxmark,sno): #print emmark,epcmark,qpmark,qpmaxmark,qcmark,qcmaxmark,qmmark,qmmaxmark status="" reason="" emmark=float(emmark) epcmark=float(epcmark) qpmark=float(qpmark) qpmaxmark=float(qpmaxmark) qc...
Python
import httplib, urllib import csv apprange=3000 def send_to_server(rankdtl,cmd): if cmd=='E': print rankdtl params = urllib.urlencode({'cmd':cmd,'rank':rankdtl[0],'score': rankdtl[1],'pcm':rankdtl[2],'entmark':rankdtl[3],'sno':rankdtl[4],'erollno':rankdtl[5][5:],'name':rankdtl[6],'qualboard':rankdtl[7]}) eli...
Python
import sys import os from google.appengine.ext.webapp import template import cgi import csv from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from defaults import * from models import * import re import time from datetime import d...
Python
import httplib, urllib import csv apprange=3000 def send_to_server(rankdtl,cmd): if cmd=='E': print rankdtl params = urllib.urlencode({'cmd':cmd,'rank':rankdtl[0],'score': rankdtl[1],'pcm':rankdtl[2],'entmark':rankdtl[3],'sno':rankdtl[4],'erollno':rankdtl[5][5:],'name':rankdtl[6],'qualboard':rankdtl[7]}) eli...
Python
"""Models""" from google.appengine.ext import db class serialNoMap(db.Model): sno=db.StringProperty() erollno=db.StringProperty() class rankList(db.Model): rank=db.StringProperty() score=db.StringProperty() erollno=db.StringProperty() qualboard=db.StringProperty() pcm=db.StringProperty() entmark=db.StringPr...
Python
import os from google.appengine.dist import use_library use_library('django', '0.96') from google.appengine.api import mail from google.appengine.ext.webapp import template import cgi import csv from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util impor...
Python
import os from google.appengine.dist import use_library use_library('django', '0.96') from google.appengine.api import mail from google.appengine.ext.webapp import template import cgi import csv from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util impor...
Python
import sys import os from google.appengine.dist import use_library use_library('django', '0.96') sys.path.insert(0, 'reportlab.zip') from google.appengine.api import mail from google.appengine.ext.webapp import template import cgi import csv from google.appengine.api import users from google.appengine.ext import we...
Python
import urllib from google.appengine.api import urlfetch """ Adapted from http://pypi.python.org/pypi/recaptcha-client to use with Google App Engine by Joscha Feth <joscha@feth.com> Version 0.1 """ API_SSL_SERVER ="https://api-secure.recaptcha.net" API_SERVER ="http://api.recaptcha.net" VERIFY_SE...
Python
import sys import os from google.appengine.dist import use_library use_library('django', '0.96') from google.appengine.ext.webapp import template import cgi import csv from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from defaul...
Python
publish_rank=1 lock_rank=0 disablesubmit=1 dsno=9999 max_apps=5000 address_length=10 phoneno_length=9 nation_length=1 fboaes_length=2 erollno_length=3 qualexamno_length=2 qualexam_length=2 qualboard_length=2 ddno_length=3 ddbranch_length=3 dddate_length=9 ddbank_length=2 chop_length=25 appstatus_null="""<tr><td>%s</td>...
Python
import sys import os os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from google.appengine.dist import use_library use_library('django', '0.96') from google.appengine.api import mail from google.appengine.ext.webapp import template import cgi import csv from google.appengine.api import users from google.appengine....
Python
import sys import os from google.appengine.dist import use_library use_library('django', '0.96') from google.appengine.ext.webapp import template import cgi import csv from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from defaul...
Python
capthalist={
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- __author__ = "shinysky" __license__ = "Apache License 2.0" __version__ = "2.0" '''Dr. Weather, a Google Wave robot. Gives the weather of a city. Usage: @city @city,country @city#language-code @city,country#language-code E.g.: @beijing @beijing,china @...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- #Copyright (c) 2009 Eugene Kaznacheev <qetzal@gmail.com> #Permission is hereby granted, free of charge, to any person #obtaining a copy of this software and associated documentation #files (the "Software"), to deal in the Software without #restriction, including without l...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- import logging import re import urllib2 import gwapi def OnBlipSubmit(): """Invoked when new blip submitted. hl = zh-cn: chinese zh-tw: tranditional chinese en: english de: fr: """ while True: ...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- __author__ = "shinysky" __license__ = "Apache License 2.0" __version__ = "2.0" '''Dr. Weather, a Google Wave robot. Gives the weather of a city. Intro: http://code.google.com/p/firstwave/wiki/DrWeather ''' import logging import re import urllib2 from w...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- __author__ = "shinysky" __license__ = "Apache License 2.0" __version__ = "2.0" '''Dr. Weather, a Google Wave robot. Gives the weather of a city. Usage: @city @city,country @city#language-code @city,country#language-code E.g.: @beijing @beijing,china @...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- __author__ = "shinysky" __license__ = "Apache License 2.0" __version__ = "2.0" '''Dr. Weather, a Google Wave robot. Gives the weather of a city. Intro: http://code.google.com/p/firstwave/wiki/DrWeather ''' import logging import re import urllib2 from w...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- #Copyright (c) 2009 Eugene Kaznacheev <qetzal@gmail.com> #Permission is hereby granted, free of charge, to any person #obtaining a copy of this software and associated documentation #files (the "Software"), to deal in the Software without #restriction, including without l...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- import logging import re import urllib2, urlparse from waveapi import simplejson URL_TINYURL_PREVIEW = 'http://tinyurl.com/preview.php?num=%s' URL_TINYURL_HOST = 'tinyurl.com' URL_BITLY_EXPAND = 'http://api.bit.ly/expand?version=2.0.1&shortUrl=%s&login=bitly...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- __author__ = "shinysky" __license__ = "Apache License 2.0" __version__ = "1.0" '''BotURL, a Google Wave robot. Replace URLs with hyperlinks. Usage: Just add me as a participant, I will take care of the rest ''' import logging import re import urllib2...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- __author__ = "shinysky" __license__ = "Apache License 2.0" __version__ = "1.0" '''BotURL, a Google Wave robot. Replace URLs with hyperlinks. Usage: Just add me as a participant, I will take care of the rest ''' import logging import re import urllib2...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- __author__ = "shinysky" __license__ = "Apache License 2.0" __version__ = "1.0" '''TiHistory, a Google Wave robot. Usage: Just add me as a participant, I will take care of the rest ''' import logging import re import urllib2, urlparse from waveapi i...
Python
#!/usr/bin/env python # -*- coding: UTF-8 -*- __author__ = "shinysky" __license__ = "Apache License 2.0" __version__ = "1.0" '''TiHistory, a Google Wave robot. Usage: Just add me as a participant, I will take care of the rest ''' import logging import re import urllib2, urlparse from waveapi i...
Python
#!/usr/bin/python # Copyright 2011 Muthu Kannan. All Rights Reserved. # # Script that searches for a string in a Blogger export XML file. import getopt import re import sys from xml.dom import minidom BLOGGER_HOST = 'draft.blogger.com' def FindPostsWithString(xml_doc, search_string): ids = [] for entry in xml_...
Python
#!/usr/bin/env python # Copyright 2010 Muthu Kannan. All Rights Reserved. # # Sets up an SSH tunnel and starts Synergy Client. import errno import os import signal import socket import subprocess import time SSH = '/usr/bin/ssh' SYNERGYC = '/usr/bin/synergyc' LOCAL_HOST = 'localhost' SERVER = 'SERVER_HOST_NAME' SYNER...
Python
from google.appengine.ext import db from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app import sys import os from google.appengine.ext.webapp import template from models import * class MainPage(webapp.RequestHandler): def get(self)...
Python
import sys import os from google.appengine.ext.webapp import template from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext import db from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library use_library('django', '0.96') ...
Python
"""Models""" from google.appengine.ext import db class userDetails(db.Model): #To store individual student details username=db.StringProperty() #Student name email=db.EmailProperty() #Email of student mobilenumber=db.StringProperty() #Mobile phone number admissionnumber=db.StringProperty() #Admissio...
Python
import sys import os from google.appengine.ext.webapp import template from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext import db from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library use_library('django', '0.96') f...
Python
import sys import os from google.appengine.ext.webapp import template from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext import db from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library use_library('django', '0.96') f...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import sys import os from google.appengine.ext.webapp import template from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext import db from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library use_library('django', '0.96') f...
Python
from google.appengine.ext import db from google.appengine.api import users from models import * cat=db.GqlQuery("SELECT * FROM projectCategory") for i in cat: i.delete() cat=db.GqlQuery("SELECT * FROM projectDetails") for i in cat: i.delete() u1=projectCategory(categoryid="CSHPC",maxmembers=100,categorytype="HPC ...
Python
import sys import os from google.appengine.ext.webapp import template from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext import db from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library use_library('django', '0.96')...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
from google.appengine.ext import db from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app import sys import os from google.appengine.ext.webapp import template from models import * global pcategory class MainPage(webapp.RequestHandler)...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
from google.appengine.ext import db from google.appengine.api import users from models import * u1=userDetails(username="kev",email="kev@gmail.com",userid="221",mobilenumber="111",admissionnumber="1",branch="CSE",projecteamids="",privilege="stud",timestamp="") u1.put() u2=userDetails(username="jozf",email="jozf@gma...
Python
from google.appengine.ext import db from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app import sys import os from google.appengine.ext.webapp import template from models import * class MainPage(webapp.RequestHandler): def verifyLo...
Python
import sys import os from google.appengine.ext.webapp import template from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext import db from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library use_library('django', '0.96')...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import cgi from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app import os from google.appengine.ext.webapp import template from models import * class MainPage(webapp.RequestHandler): def verifyLog...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import sys import os from google.appengine.ext.webapp import template from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext import db from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library use_library('django', '0.96') f...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
import sys import os from google.appengine.ext.webapp import template from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext import db from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library use_library('django', '0.96')...
Python
import datetime,cgi import sys import os from google.appengine.ext.webapp import template from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.dist import use_library from os imp...
Python
# This is Python example on how to use Mongoose embeddable web server, # http://code.google.com/p/mongoose # # Before using the mongoose module, make sure that Mongoose shared library is # built and present in the current (or system library) directory import mongoose import sys # Handle /show and /form URIs. def Even...
Python
# Copyright (c) 2004-2009 Sergey Lyubka # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publ...
Python
#!/usr/bin/env python import itertools import numpy import baker from fitpy.utils import iterables from fitpy.optimize import optimize import benchmarks as bm import fitpy.algorithms.algorithm_names def decode_names(names, module): iterable_names = iterables.make_iterable(names) return [getattr(module, na...
Python
import math def schaffer_f6(a, b): t1 = math.sin(math.sqrt(a*a + b*b)) t2 = 1 + 0.001*(a*a + b*b) score = 0.5 + (t1*t1 - 0.5)/(t2*t2) return score
Python
import schaffer_f6_standard all_benchmarks = [schaffer_f6_standard]
Python
from .functions import schaffer_f6 cost_function = schaffer_f6.schaffer_f6 kwargs = {'parameter_constraints': [[-10.0, 10.0], [-10.0, 10.0]], 'target_cost': 0.001, 'max_evaluations': None, 'num_points':10000}
Python
#!/usr/bin/env python import itertools import numpy import baker from fitpy.utils import iterables from fitpy.optimize import optimize import benchmarks as bm import fitpy.algorithms.algorithm_names def decode_names(names, module): iterable_names = iterables.make_iterable(names) return [getattr(module, na...
Python
import numpy import random import fitpy # Here's the functional form we will fit def functional_form(x, a, b, c): """ par is a sequence of parameters (a chromosome in the fitting algorithm) x is where to evaluate the function """ return a * numpy.exp(b * x) + c # Generate some noisy data to fit ...
Python
import numpy import fitpy from fitpy.helpers import chi_squared, count_zero_crossings # Here's the functional form we will fit def functional_form(par, x): """ par is a sequence of parameters (a chromosome in the fitting algorithm) x is where to evaluate the function """ return par[0] * numpy.exp...
Python
from itertools import izip import numpy import fitpy # Here's the functional form we will fit def functional_form(par, x): """ par is a sequence of parameters (a chromosome in the fitting algorithm) x is where to evaluate the function """ return par[0] * numpy.exp(par[1] * x) + par[2] # Generat...
Python
import datetime RESIDUAL_NAME = 'chi_squared' MAX_EVALUATIONS = 10000 MAX_RUNTIME = datetime.timedelta(minutes=5) ALGORITHM_NAME = 'continuous_genetic'
Python
DEFAULT_INITIAL_POPULATION_SIZE=500 DEFAULT_CROSSOVER_RATE = 0.1 DEFAULT_MUTATION_RATE = 0.3 DEFAULT_PERTURBATION_RATE = 0.4 DEFAULT_NUMBER_SAMPLE_POINTS = 1000
Python
import math from . import strategies from . import reproduction from ..common.parameter_queue import MultiObjectiveParameterQueue, SingleObjectiveParameterQueue from .settings import * from fitpy.utils import meshes, iterables __all__ = ['make_algorithm'] def make_algorithm(cost_func, parameter_constraint_list, en...
Python
from fitpy.utils import logutils from ..common.evaluation_cache import EvaluationCache from .settings import DEFAULT_INITIAL_POPULATION_SIZE logger = logutils.getLogger(__file__) __all__ = ['GeneticAlgorithm'] class GeneticAlgorithm(object): def __init__(self, cost_func, population, reproduce, end, **kwargs): ...
Python
from . import factories from . import strategies
Python
import copy import random from fitpy.utils import logutils from ..common import choice logger = logutils.getLogger(__file__) class DiscreteStandard(object): def __init__(self, allowed_parameter_values, crossover_rate, mutation_rate, perturbation_rate): self.allowed_para...
Python
import os from . import common # Generate list of legal algorithm names. _ignored_strings = ['.', 'common'] _dirname = os.path.dirname(__file__) algorithm_names = [] for file in os.listdir(_dirname): if not any(s in file for s in _ignored_strings): algorithm_names.append(file) del _ignored_strings del _d...
Python
from . import common from .algorithm_names import algorithm_names from fitpy.utils.cost_function_wrapper import CostFunctionWrapper from fitpy.utils.funcutils import get_parameter_names def make_residual_cost_function(target_function, x_values, y_values, y_errors, ...
Python
DEFAULT_MAX_RANKING_LENGTH=500
Python
try: from collections import OrderedDict except ImportError: try: from ordereddict import OrderedDict except ImportError: raise ImportError("Couldn't find an ordered dictionary class to import, either install ordereddict from pypi or upgrade to Python 2.7 or newer.") class EvaluationCache(...
Python
from itertools import izip __all__ = ['chi_squared', 'residual_functions'] def chi_squared(x_values, y_values, y_stds, y_calculated, **kwargs): if y_stds: return sum([((y1-y2)/ys)**2 for y1, y2, ys in izip(y_values, y_calculated, y_stds)]) else: return sum([(y1-y2)**2 for y...
Python
import datetime import time import unittest from fitpy.algorithms.common import end_conditions class TestCounter(unittest.TestCase): def testNormal(self): c = end_conditions.Counter(50) self.assertFalse(any(c(None) for i in xrange(49))) self.assertTrue(c(None)) self.assertTrue(c(No...
Python
import datetime from fitpy.utils import logutils logger = logutils.getLogger(__file__) __all__ = ['MaxIterations', 'MaxRuntime', 'StoppedImproving', 'FitTolerance'] class EndCondition(object): def __call__(self, variables): check_result = self.check(variables) if check_result: logger....
Python
from . import residuals from . import end_conditions from . import choice
Python
import bisect from itertools import izip from collections import namedtuple from .settings import * MORankingProperties = namedtuple('MORankingProperties', 'trails trumps age cost parameters') SORankingProperties = namedtuple('SORankingProperties', 'c...
Python
import random def choose_two(sequence, select_function): """ Picks 2 unique items from the sequence. """ p1 = select_function(sequence) p2 = p1 while p1 == p2: p2 = select_function(sequence) return p1, p2 def weighted_choice(sequence, width=None): """ Choose a random el...
Python
import inspect import itertools import collections import logging from .utils import logutils from .utils.parameters import format_as_list from .utils import funcutils from .algorithms import factories import default_settings as ds logger = logutils.getLogger(__file__) def optimize(cost_function, para...
Python