repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex8_gauss_int.py | <reponame>josephlewis42/personal_codebase<filename>python/Genetic Programming/Examples/pyevolve_ex8_gauss_int.py
from pyevolve import G1DList
from pyevolve import GSimpleGA
from pyevolve import Selectors
from pyevolve import Mutators
# This function is the evaluation function, we want
# to give high score to more zero... |
josephlewis42/personal_codebase | python/gamebot/ini_reader.py | <gh_stars>1-10
#!/usr/bin/env python
'''Provides NumberList and FrequencyDistribution, classes for statistics.
NumberList holds a sequence of numbers, and defines several statistical
operations (mean, stdev, etc.) FrequencyDistribution holds a mapping from
items (not necessarily numbers) to counts, and defines operati... |
josephlewis42/personal_codebase | python/timed_message.py | <reponame>josephlewis42/personal_codebase
#!/usr/bin/env python
import datetime
import re
import smtplib
import time
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
gmail_user = "<EMAIL>"
gmail_pwd = "password"
def mail(to, subject, body):
msg = MIMEMultipart(... |
josephlewis42/personal_codebase | python/randall/alife_randall_checkout/ai_webserver/actor_map.py | # actor_map.py -- Displays the internal map of an actor.
#
# Copyright 2011 <NAME> <<EMAIL>>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of t... |
josephlewis42/personal_codebase | python/reprap-franklin/display.py | #!/usr/bin/env python
'''Provides a main GUI for the RepRap Franklin.
Copyright 2011 <NAME> <<EMAIL>>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your opt... |
josephlewis42/personal_codebase | python/reprap-franklin/reprap.py | #!/usr/bin/env python
'''Provides a RepRap Object for the RepRap Franklin.
This is used as the abstract RepRap and has a set of toolheads, a
firmware, a printing bed and other small components, like fans.
Copyright 2011 <NAME> <<EMAIL>>
This program is free software; you can redistribute it and/or modify
it under th... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex18_gp.py | from pyevolve import Util
from pyevolve import GTree
from pyevolve import GSimpleGA
from pyevolve import Consts
import math
rmse_accum = Util.ErrorAccumulator()
def gp_add(a, b): return a+b
def gp_sub(a, b): return a-b
def gp_mul(a, b): return a*b
def gp_sqrt(a): return math.sqrt(abs(a))
def eval_func(chromosom... |
josephlewis42/personal_codebase | python/OpenCalc/Lib/Code/Functions/Log_Exp.py | '''
Holds Logarithmic and Exponential Functions
@Author = <NAME> <<EMAIL>>
@Date = 2010-03-03 (Originally)
@License = GPL
==Changelog==
2010-03-03 - Original of this document, so far it is a wrapper for the python log and exponential math functions, soon I hope it to be more
'''
#Import Statements
import math
#Define ... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex3_schaffer.py | from pyevolve import G1DList, GSimpleGA, Selectors
from pyevolve import Initializators, Mutators, Consts
import math
# This is the Schaffer F6 Function
# This function has been conceived by Schaffer, it's a
# multimodal function and it's hard for GAs due to the
# large number of local minima, the global minimum is
# ... |
josephlewis42/personal_codebase | Euler/pymath.py | <reponame>josephlewis42/personal_codebase
'''
A small, general-purpose math library for Python
- <NAME>
'''
import math
import random
def factor(n):
''' Finds the factors of the given number.'''
result = set()
for i in range(1, int(n ** 0.5) + 1):
div, mod = divmod(n, i)
if mod == 0:
result |= {i, div}
re... |
josephlewis42/personal_codebase | python/OpenCalc/Lib/Code/Frontend.py | #!/usr/bin/python
import wx.html as html
import Parser
import wx
import Graph
class events():
'''
This class holds all of the events for the main gui and their helper methods.
'''
def submit_function(self, event):
index = self.functions_list_box.GetSelection()
fx = Graph.function(s... |
josephlewis42/personal_codebase | python/randall/alife_randall_checkout/ai_webserver/actor_chooser.py | # actor_chooser.py
#
# Copyright 2011 <NAME> <<EMAIL>>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option... |
josephlewis42/personal_codebase | python/reprap-franklin/toolheads/__init__.py | import toolhead
#Include all other toolheads here
import basic |
josephlewis42/personal_codebase | python/OpenCalc/Main (copy).py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Sat Feb 27 13:35:04 2010
import wx
# begin wxGlade: extracode
import wx.html as html
from Lib.Code import Parser
import sys
# end wxGlade
class CalcWidget(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: CalcWidge... |
josephlewis42/personal_codebase | python/webkit_browser/simple_webkit_browser_with_tabs.py | <reponame>josephlewis42/personal_codebase<filename>python/webkit_browser/simple_webkit_browser_with_tabs.py
#!/usr/bin/env python
'''
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * ... |
josephlewis42/personal_codebase | python/randall/alife_randall_checkout/randallai/AI/body.py | <filename>python/randall/alife_randall_checkout/randallai/AI/body.py
#!/usr/bin/env python
'''
Copyright (c) 2011 <NAME> <<EMAIL>>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation... |
josephlewis42/personal_codebase | python/game_of_life/conway.py | #!/usr/bin/env python
''' Conway's game of life in python.
Copyright 2011-09-30 <NAME> <<EMAIL>> MIT License
1. Any live cell with fewer than two live neighbours dies.
2. Any live cell with two or three live neighbours lives.
3. Any live cell with more than three live neighbours dies.
4. Any dead cell wit... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex2_realgauss.py | <gh_stars>1-10
from pyevolve import GSimpleGA
from pyevolve import G1DList
from pyevolve import Selectors
from pyevolve import Initializators, Mutators
# Find negative element
def eval_func(genome):
score = 0.0
for element in genome:
if element < 0: score += 0.1
return score
def run_main():
# Geno... |
josephlewis42/personal_codebase | python/spellcheck/spell_checker.py | <filename>python/spellcheck/spell_checker.py
#!/usr/bin/env python
'''A simple spell checker for Python, modified version of <NAME>'s
http://norvig.com/spell-correct.html
Created by: <NAME> <joehms22 [at] gmail [dot] com> 2012-09-19
'''
import re
import collections
DICTIONARY_FILE = "american-english"
class Checker:... |
josephlewis42/personal_codebase | python/PersonalFileServer/Site/index.py | self.send_200()
self.wfile.write('''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Upload/Download</title>
<style TYPE="text/css">
body {
background-color:#ADD8E6;
text-align:center;
margin:0px;
padding:0px;
... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex1_simple.py | from pyevolve import G1DList
from pyevolve import GSimpleGA
from pyevolve import Selectors
from pyevolve import Statistics
from pyevolve import DBAdapters
# This function is the evaluation function, we want
# to give high score to more zero'ed chromosomes
def eval_func(genome):
score = 0.0
# iterate over the ch... |
josephlewis42/personal_codebase | Euler/008.py | #!/usr/bin/env python
'''
Find the greatest product of five consecutive digits in the 1000-digit number.
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
6689664895... |
josephlewis42/personal_codebase | Euler/003.py | <filename>Euler/003.py
#!/usr/bin/env python
'''
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
'''
import pymath
print max(pymath.prime(pymath.factor(600851475143)))
|
josephlewis42/personal_codebase | python/reprap-franklin/inputs/file_input.py | <gh_stars>1-10
#!/usr/bin/env python
import threading
import time
class FileInput( threading.Thread ):
def __init__(self, reprap, source, delay=None):
self.reprap = reprap
self.source = source
self.delay = delay
threading.Thread.__init__(self)
self.daemon = True
def ... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex4_sigmatrunc.py | from pyevolve import G1DList
from pyevolve import GSimpleGA
from pyevolve import Selectors
from pyevolve import Initializators, Mutators
from pyevolve import Scaling
from pyevolve import Consts
import math
def eval_func(ind):
score = 0.0
var_x = ind[0]
var_z = var_x**2+2*var_x+1*math.cos(var_x)
return var_... |
josephlewis42/personal_codebase | python/reprap-franklin/firmware/full.py | #!/usr/bin/env python
'''Provides a fullly implemented GCode parser for Franklin.
Commands can be passed in one at a time through the execute_gcode
function, returncodes will be returned.
Copyright 2011 <NAME> <<EMAIL>>
This program is free software; you can redistribute it and/or modify
it under the terms of the G... |
josephlewis42/personal_codebase | python/stpetersburg.py | <gh_stars>1-10
#!/usr/bin/python
'''stpetersburg.py -- A saint petersburg simulator.
2011/02/25 15:36:28
Copyright 2011 <NAME> <<EMAIL>>
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 r... |
josephlewis42/personal_codebase | python/OpenCalc/Lib/Code/Variables.py | <gh_stars>1-10
#!/usr/bin/python
#Define A-Z
a = 0
b = 0
c = 0
d = 0
e = 0
f = 0
g = 0
h = 0
i = 0
j = 0
k = 0
l = 0
m = 0
n = 0
o = 0
p = 0
q = 0
r = 0
s = 0
t = 0
u = 0
v = 0
w = 0
x = 0
y = 0
z = 0
|
josephlewis42/personal_codebase | python/apropos.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Fri Oct 29 10:43:01 2010
import wx
# begin wxGlade: extracode
# end wxGlade
class MainFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MainFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
... |
josephlewis42/personal_codebase | python/get_firefox_bookmarks.py | #!/usr/bin/python
# get_firefox_bookmarks.py
#
# Copyright 2010 <NAME> <<EMAIL>>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of... |
josephlewis42/personal_codebase | Euler/012.py | <gh_stars>1-10
#!/usr/bin/env python
u'''
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors of the first seven triangle numbers:... |
josephlewis42/personal_codebase | python/randall/alife_randall_checkout/ai_webserver/pavlov.py | # pavlov.py
#
# Copyright 2011 <NAME> <<EMAIL>>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any l... |
josephlewis42/personal_codebase | python/email_attachment_extractor.py | #!/usr/bin/env python3
import email.parser
import os
import sys
import base64
import binascii
import sys
def extract(rootdir):
fileList = []
for root, subFolders, files in os.walk(rootdir):
for file in files:
fileList.append(os.path.join(root,file))
for path in fileList:
if not path.endswith(".eml"):... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex6_dbadapter.py | <gh_stars>1-10
from pyevolve import G1DList
from pyevolve import GSimpleGA
from pyevolve import Selectors
from pyevolve import DBAdapters
from pyevolve import Statistics
# This function is the evaluation function, we want
# to give high score to more zero'ed chromosomes
def eval_func(chromosome):
score = 0.0
# ... |
josephlewis42/personal_codebase | python/OpenCalc/Lib/Code/Functions/OpenCalc.py | <gh_stars>1-10
'''
Description Of Module
@Author = <NAME><<EMAIL>>
@Date = 2010-2-24
@License = GPL
==Changelog==
2010-2-24 - First version made by <NAME>
'''
#Import Statements
#Define Constants
#Define Functions
def isNum(var):
if(type(var).__name__ == 'int' or type(var).__name__ == 'float'):
return True
else:
... |
josephlewis42/personal_codebase | python/markov.py | #!/usr/bin/env python3
'''
Provides common functions used through the similarity engines.
Copyright 2012 <NAME> <<EMAIL>> | <<EMAIL>>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must... |
josephlewis42/personal_codebase | wheel_of_fortune_ai/wheelmatch.py | <gh_stars>1-10
import re
class WheelMatch:
letters = set(['a','t','e'])
looking = ['a','.','e','.','.','.','a']
def matches(self, word):
if len(word) != len(self.looking):
return False
for i, letter in enumerate(self.looking):
if letter == '.':
if word[i] in self.letters:
return False
... |
josephlewis42/personal_codebase | Euler/015.py | <reponame>josephlewis42/personal_codebase
'''Starting in the top left corner of a 2x2 grid, and only being able to move to
the right and down, there are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20x20 grid?
'''
# there are a total of n * 2 steps you must take where n is le... |
josephlewis42/personal_codebase | python/randall/alife_randall_checkout/randallai/Randall.py | <reponame>josephlewis42/personal_codebase
#!/usr/bin/env python
'''
A simple AI mouse named Randall.
Copyright (c) 2011 <NAME> <<EMAIL>>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundatio... |
josephlewis42/personal_codebase | python/py_basic_ide/pyBASIC/__init__.py | from parser import tokenize_document, tokenize_from_file
from runner import run
def set_debug(bool):
print "DEBUG = ", bool
runner.debug = bool
|
josephlewis42/personal_codebase | wheel_of_fortune_ai/ngram.py | <reponame>josephlewis42/personal_codebase
#!/usr/bin/env python
import re
ngrams = {}
word_scores = {}
with open("w2_.txt") as ngram:
for line in ngram:
nwords, w1, w2 = line.split()
nwords = int(nwords)
try:
ngrams[w1].append((nwords, w2))
except:
ngrams[w1] = [(nwords, w2)]
start_words = ngram... |
josephlewis42/personal_codebase | python/email_grabber/email.pyw | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Wed Mar 24 11:22:54 2010
import wx
# begin wxGlade: extracode
# end wxGlade
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
... |
josephlewis42/personal_codebase | python/randall/alife_randall_checkout/randallai/AI/world.py | <reponame>josephlewis42/personal_codebase<filename>python/randall/alife_randall_checkout/randallai/AI/world.py<gh_stars>1-10
#!/usr/bin/env python
'''
The world provides a place for actors to interact. All Actors should
have some basic variables (cheifly location and hunger), these can
be accessed by the organs so the... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex9_g2dlist.py | from pyevolve import G2DList
from pyevolve import GSimpleGA
from pyevolve import Selectors
from pyevolve import Crossovers
from pyevolve import Mutators
# This function is the evaluation function, we want
# to give high score to more zero'ed chromosomes
def eval_func(chromosome):
score = 0.0
# iterate over the ... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex13_sphere.py | from pyevolve import G1DList
from pyevolve import Mutators, Initializators
from pyevolve import GSimpleGA, Consts
# This is the Sphere Function
def sphere(xlist):
total = 0
for i in xlist:
total += i**2
return total
def run_main():
genome = G1DList.G1DList(140)
genome.setParams(rangemin=-5.12, ra... |
josephlewis42/personal_codebase | Euler/006.py | <gh_stars>1-10
#!/usr/bin/env python
'''
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex22_monkey.py | #===============================================================================
# Pyevolve version of the Infinite Monkey Theorem
# See: http://en.wikipedia.org/wiki/Infinite_monkey_theorem
# By <NAME>
#===============================================================================
from pyevolve import G1DList
from p... |
josephlewis42/personal_codebase | wheel_of_fortune_ai/wheel.py | #!/usr/bin/env python
from __future__ import division
import common
import re
import ngram
# sort in to lengths
words = []
puzzle = []
guessed_letters = []
fullpuzzle = None
def setupPuzzle():
global puzzle
global guessed_letters
global fullpuzzle
print "To play, enter a full puzzle in lower case."
print ... |
josephlewis42/personal_codebase | python/webkit_browser/simple_webkit_browser.py | #!/usr/bin/env python
'''
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and... |
josephlewis42/personal_codebase | python/PersonalFileServer/Site/upload.py | import os
if POST_DICT:
try:
print POST_DICT.keys()
print POST_DICT['filename']
path = os.path.join("Downloads", POST_DICT['filename'])
print path
with open(path, 'wb') as f:
f.write(POST_DICT['myfile'])
except Exception, e:
print e
self.redirect("in... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex19_gp.py | from pyevolve import GSimpleGA
from pyevolve import GTree
from pyevolve import Consts
from pyevolve import Selectors
from pyevolve import Mutators
from math import sqrt
import pydot
import random
def gp_add(a, b):
assert len(a)==len(b)
new_list = [x+y for x,y in zip(a,b)]
return new_list
#def gp_sub(a, b)... |
josephlewis42/personal_codebase | python/pyWebserver/configure.py | """
This application starts the webserver.
@Author : <NAME> <<EMAIL>>
@Licence : Apache License
@Date : Fri 12 Feb 2010 05:00:22 PM MST
"""
#WX Stuff
import wx
from wx import xrc
#Config Parser, not needed in normal wx applications.
import ConfigParser
config = ConfigParser.RawConfigParser()
class ServerApp(wx.Ap... |
josephlewis42/personal_codebase | python/PersonalFileServer/Site/download.py | import os
import mimetypes
import urllib
if QUERY_DICT:
filename = urllib.unquote(QUERY_DICT['f'][0])
mime = mimetypes.guess_type(filename)
path = os.path.join("Downloads", filename)
head={'Content-Disposition':'attachment; filename="%s"' %(filename)}
self.send_200(mime_type=mime, headers=hea... |
josephlewis42/personal_codebase | python/advanced_find_replace/replace_over.py | <gh_stars>1-10
#!/usr/bin/env python
# -*- coding: latin-1 -*-
'''A handy little script that replaces files in a directory with
Copyright 2011 <NAME> <joehms22 [at] gmail com>
Originally Made: 2012-06-12
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that th... |
josephlewis42/personal_codebase | python/OpenCalc/Lib/Code/Graph.py | #!/usr/bin/python
'''
Graph provides an interface to matplotlib, as well as classes defining graph
objects, and function objects
@Author = <NAME>
@Date = 2010-03-12
@License = GPL
==Changelog==
2010-03-12 - Original Built by <NAME> <<EMAIL>>
2010-03-17 - Added functions to get the graph colors and style - JL
'''
#fro... |
josephlewis42/personal_codebase | python/randall/alife_randall_checkout/randallai/AI/limbic.py | <filename>python/randall/alife_randall_checkout/randallai/AI/limbic.py
#!/usr/bin/env python
'''
The limbic module is responsible for maintaining emotions.
Copyright (c) 2011 <NAME> <<EMAIL>>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General ... |
josephlewis42/personal_codebase | python/randall/alife_randall_checkout/randallai/AI/mapper.py | #!/usr/bin/env python
''' The mapper module is used to maintain a map of places.
Copyright (c) 2011 <NAME> <<EMAIL>>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 ... |
josephlewis42/personal_codebase | python/randall/alife_randall_checkout/randallai/AI/maslow.py | <reponame>josephlewis42/personal_codebase
#!/usr/bin/env python
'''
The maslow module provides a basic list of needs and the ability to
judge how well those needs are doing based off organs.
More Info: http://en.wikipedia.org/wiki/Maslow's_hierarchy_of_needs
Copyright (c) 2011 <NAME> <<EMAIL>>
This program i... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex16_g2dbinstr.py | <filename>python/Genetic Programming/Examples/pyevolve_ex16_g2dbinstr.py
from pyevolve import G2DBinaryString
from pyevolve import GSimpleGA
from pyevolve import Selectors
from pyevolve import Crossovers
from pyevolve import Mutators
# This function is the evaluation function, we want
# to give high score to more zero... |
josephlewis42/personal_codebase | python/xkcdfetch.py | <filename>python/xkcdfetch.py<gh_stars>1-10
#!/usr/bin/python
import urllib2
import time
import sys
WGET = False
try:
if sys.argv[1] == "-w":
WGET = True
except IndexError:
pass
for i in range(1,850):
if i == 404: #Skip the 404th comic which is an error 404 page.
continue
url = "http... |
josephlewis42/personal_codebase | python/reprap-franklin/firmware/repman.py | <filename>python/reprap-franklin/firmware/repman.py<gh_stars>1-10
#!/usr/bin/env python
'''An emulator for RepMan specific commands (not complete)
Copyright 2011 <NAME> <<EMAIL>>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
t... |
josephlewis42/personal_codebase | python/Genetic Programming/Finished Programs/2010-08-30 GP Vaccum .py | from pyevolve import *
import math
import pprint
NORTH = 0
SOUTH = 2
EAST = 1
WEST = 3
lowest_score_yet = 100 #Print out the lowest scores.
loc_x = 1
loc_y = 1
direction = 0
grid = []
def setup_map():
global grid
global loc_x
global loc_y
global direction
loc_x = 1
loc_y = ... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex11_allele.py | from pyevolve import G1DList
from pyevolve import GSimpleGA
from pyevolve import Mutators
from pyevolve import Initializators
from pyevolve import GAllele
# This function is the evaluation function, we want
# to give high score to more zero'ed chromosomes
def eval_func(chromosome):
score = 0.0
# iterate over th... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex15_rosenbrock.py | from pyevolve import G1DList, GSimpleGA, Selectors, Statistics
from pyevolve import Initializators, Mutators, Consts, DBAdapters
# This is the Rosenbrock Function
def rosenbrock(xlist):
sum_var = 0
for x in xrange(1, len(xlist)):
sum_var += 100.0 * (xlist[x] - xlist[x-1]**2)**2 + (1 - xlist[x-1])**2
ret... |
josephlewis42/personal_codebase | python/Genetic Programming/Examples/pyevolve_ex12_tsp.py | from pyevolve import G1DList, GAllele
from pyevolve import GSimpleGA
from pyevolve import Mutators
from pyevolve import Crossovers
from pyevolve import Consts
import sys, random
random.seed(1024)
from math import sqrt
PIL_SUPPORT = None
try:
from PIL import Image, ImageDraw, ImageFont
PIL_SUPPORT = True
except... |
josephlewis42/personal_codebase | python/OpenCalc/Lib/Code/Functions/Trig.py | '''
Basic Trig Stuff
@Author = <NAME>
@Date = Friday, Feb. 19, 2010
==Changelog==
2010-2-25 - Added the boolean that changes if you want radians or degrees
2010-02-27 - Fixed a problem with the basic trigonometric functions that was
causing improper numbers to be returned. Also added the functions that set the
want_de... |
josephlewis42/personal_codebase | python/randall/alife_randall_checkout/ai_webserver/organs.py | # organs.py
#
# Copyright 2011 <NAME> <<EMAIL>>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any l... |
josephlewis42/personal_codebase | python/gamebot/codescraper.py | #!/usr/bin/python
'''
Copyright (c) 2010 <NAME> <<EMAIL>>
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, ... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v2/rtt.py | <filename>covid19_forecaster/v2/rtt.py
import numpy as np
import pandas as pd
from .. import DATA_DIR
from ..core import RevenueForecast
from ..forecasters import NoBaselineForecasterBySector
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class RealtyTransfe... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v1/rtt.py | <filename>covid19_forecaster/v1/rtt.py
import numpy as np
from ..core import RevenueForecast
from ..forecasters import DefaultForecaster
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class RealtyTransferTaxForecast(DefaultForecaster, RevenueForecast):
"... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v2/__init__.py | # Forecast range
FORECAST_START = "2021-01-01"
FORECAST_STOP = "2022-06-30"
# Baseline range
BASELINE_START = "2013-07-01"
BASELINE_STOP = "2020-03-31"
# Forecast frequency
FREQ = "Q"
# Scenario names
SCENARIOS = ["moderate", "severe"]
from ..core import ScenarioComparison, ScenarioForecast
from .amusement import ... |
PhiladelphiaController/covid19-forecaster | setup.py | from setuptools import setup, find_packages
import re
from pathlib import Path
PACKAGE_NAME = "covid19_forecaster"
HERE = Path(__file__).parent.absolute()
def find_version(*paths: str) -> str:
with HERE.joinpath(*paths).open("tr") as fp:
version_file = fp.read()
version_match = re.search(
... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/baseline/sales.py | <filename>covid19_forecaster/baseline/sales.py
"""Transform sales data by splitting between City and School District"""
import pandas as pd
from ..utils import get_fiscal_year
# School district gets $120M
MAX_DISTRICT_AMOUNT = 120e6
def get_sales_fiscal_year(r: pd.Series) -> int:
"""
July/Aug are associated... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v1/npt.py | from ..core import RevenueForecast
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class NPTForecast(RevenueForecast):
"""Net profits tax revenue forecast."""
ASSUMPTIONS = {
"moderate": {2020: 0.05, 2021: 0.1},
"severe": {2020: 0.1, 2... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/io.py | <reponame>PhiladelphiaController/covid19-forecaster<filename>covid19_forecaster/io.py<gh_stars>1-10
import calendar
import pandas as pd
from phl_budget_data.clean import (
load_birt_collections_by_sector,
load_city_collections,
load_rtt_collections_by_sector,
load_sales_collections_by_sector,
load_... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v1/parking.py | <gh_stars>1-10
import numpy as np
from ..core import RevenueForecast
from ..forecasters import DefaultForecaster
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class ParkingTaxForecast(DefaultForecaster, RevenueForecast):
"""Parking tax revenue forecast.... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v2/sales.py | <reponame>PhiladelphiaController/covid19-forecaster
import numpy as np
from ..core import RevenueForecast
from ..forecasters import SectorForecaster
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class SalesTaxForecast(SectorForecaster, RevenueForecast):
... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v2/npt.py | from ..core import RevenueForecast
from ..forecasters import DefaultForecaster
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class NPTForecast(DefaultForecaster, RevenueForecast):
"""Net profits tax revenue forecast."""
ASSUMPTIONS = {
"mode... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/run.py | import argparse
import shutil
from pathlib import Path
from typing import List, Union
import click
import openpyxl
import pandas as pd
from loguru import logger
from matplotlib import pyplot as plt
from . import DATA_DIR, v1, v2
from .core import RevenueForecast, ScenarioComparison, ScenarioForecast
from .utils impor... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v2/soda.py | <reponame>PhiladelphiaController/covid19-forecaster
import numpy as np
from ..core import RevenueForecast
from ..forecasters import DefaultForecaster
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class SodaTaxForecast(DefaultForecaster, RevenueForecast):
... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v1/__init__.py | <reponame>PhiladelphiaController/covid19-forecaster
# Forecast range
FORECAST_START = "2020-04-01"
FORECAST_STOP = "2021-12-31"
# Baseline range
BASELINE_START = "2013-07-01"
BASELINE_STOP = "2020-03-31"
# Forecast frequency
FREQ = "M"
# Scenario names
SCENARIOS = ["moderate", "severe"]
from loguru import logger
... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/utils.py | <filename>covid19_forecaster/utils.py
import hashlib
import json
import numpy as np
import pandas as pd
def aggregate_to_quarters(df, cols=None, key=None):
"""Aggregate monthly data to quarters."""
grouped = df.groupby(pd.Grouper(freq="QS", key=key))
if cols is not None:
out = grouped[cols].sum()... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/baseline/transformers.py | import logging
logger = logging.getLogger("fbprophet.plot")
logger.setLevel(logging.CRITICAL)
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import pandas as pd
from fbprophet import Prophet
from sklearn.base import TransformerMixin
from .. import io
from ..utils import get... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/__init__.py | from pathlib import Path
# Version number
__version__ = "2.0.0"
# Data directory
DATA_DIR = Path(__file__).parent.absolute() / "data"
|
PhiladelphiaController/covid19-forecaster | covid19_forecaster/forecasters.py | import pandas as pd
def check_date_bounds(date, start_date, stop_date):
"""Check the bounds of a specific date."""
# Check min date
if date < pd.to_datetime(start_date):
date_str = date.strftime("%Y-%m-%d")
raise ValueError(
f"Date {date_str} before min forecast date ('{start_... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v2/wage.py | <reponame>PhiladelphiaController/covid19-forecaster<gh_stars>1-10
import numpy as np
import pandas as pd
from .. import DATA_DIR
from ..core import RevenueForecast
from ..forecasters import NoBaselineForecasterBySector
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FR... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v2/birt.py | from ..core import RevenueForecast
from ..utils import get_fiscal_year
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class BIRTForecast(RevenueForecast):
"""BIRT revenue forecast."""
ASSUMPTIONS = {
"moderate": {2020: 0.0, 2021: 0.075, 2022:... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/core.py | <filename>covid19_forecaster/core.py
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Dict, Optional, Union
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from phila_style import get_digital_standards
from phila_style.matplotlib import get_the... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v1/amusement.py | <gh_stars>1-10
import numpy as np
from ..core import RevenueForecast
from ..forecasters import DefaultForecaster
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class AmusementTaxForecast(DefaultForecaster, RevenueForecast):
"""Amusement tax revenue forec... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v1/sales.py | <gh_stars>1-10
import numpy as np
from ..core import RevenueForecast
from ..forecasters import SectorForecaster
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class SalesTaxForecast(SectorForecaster, RevenueForecast):
"""Sales tax revenue forecast."""
... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v1/wage.py | <gh_stars>1-10
import numpy as np
from ..core import RevenueForecast
from ..forecasters import check_date_bounds
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class WageTaxForecast(RevenueForecast):
"""Wage tax revenue forecast."""
RECOVERY_RATES =... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v1/soda.py | <reponame>PhiladelphiaController/covid19-forecaster<gh_stars>1-10
import numpy as np
from ..core import RevenueForecast
from ..forecasters import DefaultForecaster
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class SodaTaxForecast(DefaultForecaster, Revenu... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/baseline/core.py | <reponame>PhiladelphiaController/covid19-forecaster
from collections import OrderedDict
from dataclasses import dataclass, field
from functools import partial
from typing import Dict, List, Optional
import pandas as pd
from cached_property import cached_property
from sklearn.pipeline import Pipeline
from sklearn.prepr... |
PhiladelphiaController/covid19-forecaster | covid19_forecaster/baseline/__init__.py | from .core import TAX_NAMES, BaselineForecast
|
PhiladelphiaController/covid19-forecaster | covid19_forecaster/v2/parking.py | import numpy as np
from ..core import RevenueForecast
from ..forecasters import DefaultForecaster
from . import (
BASELINE_START,
BASELINE_STOP,
FORECAST_START,
FORECAST_STOP,
FREQ,
)
class ParkingTaxForecast(DefaultForecaster, RevenueForecast):
"""Parking tax revenue forecast."""
ASSUMP... |
Zapata/bitshares-explorer-api | config.py | <filename>config.py
import os
WEBSOCKET_URL = os.environ.get('WEBSOCKET_URL', "ws://localhost:8090/ws")
# Default connection to Elastic Search.
ELASTICSEARCH = {
'hosts': os.environ.get('ELASTICSEARCH_URL', 'https://es.bitshares.eu/').split(','),
'user': os.environ.get('ELASTICSEARCH_USER', 'BitShares'),
... |
seanmorris/dotsyntax-sublime | dotsyntax.py | <reponame>seanmorris/dotsyntax-sublime<gh_stars>1-10
import sublime_plugin
import sublime
import os.path
import fnmatch
import io
import re
class DotSyntaxCommand(sublime_plugin.EventListener):
mappings = {}
def on_load_async(self, view):
self.set_syntax(view)
def on_post_save_async(self, view):
self.set_... |
madpin/renthub | main/app/alembic/versions/ef3f101feb21_initial_9.py | <reponame>madpin/renthub
"""Initial 9
Revision ID: ef<PASSWORD>
Revises: <PASSWORD>
Create Date: 2021-11-14 06:45:24.012682
"""
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision = 'ef<PASSWORD>'
down_revision = '<PASSWORD>'
branch_labels = None
depends_... |
madpin/renthub | main/app/backgroud.py | import asyncio
class BackgroundRunner:
def __init__(self):
self.value = 0
self.is_running = False
async def run_main(self):
while True:
if(not self.is_running):
await asyncio.sleep(1)
continue
await asyncio.sleep(0.1)
... |
madpin/renthub | location/app/schemas.py | import os
from typing import List, Optional
# import datetime
from pydantic import BaseModel
class Point(BaseModel):
lat: float
long: float
class Location(BaseModel):
point: Point
name: str
tags: Optional[List[str]]
class RouteSummary(BaseModel):
waking_distance: int
total_distance: in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.