text stringlengths 0 1.05M | meta dict |
|---|---|
__author__ = 'thor'
print('''
Remember to use these useful utils:
igrab, QuickStore, set_obj, get_obj, doctest_string_print
heatmap, vlines
print_progress, ppr, pickle_dump, pickle_load, numof_trues
''')
import sys
if sys.platform == 'darwin':
from IPython.display import set_matplotlib_formats
s... | {
"repo_name": "thorwhalen/ut",
"path": "util/imports/ipython_utils.py",
"copies": "1",
"size": "3037",
"license": "mit",
"hash": 6843440704640013000,
"line_mean": 22.5426356589,
"line_max": 114,
"alpha_frac": 0.6147513994,
"autogenerated": false,
"ratio": 3.2691065662002154,
"config_test": fals... |
__author__ = 'thorsteinn'
from db_to_file_helpers.jsonDicts_to_file import file_to_db
from db_format_helpers.list_all_field_values import list_all_field_values
import json
import os
def new_imo_list(wishlist, old_db_file, newer_db_file):
db_files = [old_db_file, newer_db_file]
imo_list = []
for file in d... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "MarineConnectionSoups/mc_prepare_run.py",
"copies": "1",
"size": "1722",
"license": "apache-2.0",
"hash": -7262538843571403000,
"line_mean": 29.2105263158,
"line_max": 103,
"alpha_frac": 0.5464576074,
"autogenerated": fals... |
__author__ = 'thorsteinn'
from is_number import is_number
from is_int import is_int
def strings_in_fields_to_numbers(db_key, db):
"""
A method for converting typed numbers to actual numbers
u'123.22' should be turned into a floating point number
u'123' should be turned into an integer number
:param... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "db_format_helpers/strings_in_fields_to_numbers.py",
"copies": "1",
"size": "1440",
"license": "apache-2.0",
"hash": -4203768026334260000,
"line_mean": 37.9189189189,
"line_max": 119,
"alpha_frac": 0.5326388889,
"autogenera... |
__author__ = 'thorsteinn'
import urllib2
from bs4 import BeautifulSoup
import re
import sys
def mc_soup(imoNumber):
'''
Soup module that grabs information from MarineConnection
'''
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
# define the proper web address
... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "MarineConnectionSoups/mc_soup.py",
"copies": "1",
"size": "1996",
"license": "apache-2.0",
"hash": -6334358173644247000,
"line_mean": 29.2424242424,
"line_max": 104,
"alpha_frac": 0.5856713427,
"autogenerated": false,
"r... |
__author__ = 'thorsteinn'
def check_field_values(key_id, db, **kwargs):
if len(kwargs) > 1:
raise KeyError("Only one keyword is allowed to be used at a time. Received {length!s} arguments."
"\n {kwargs}".format(length=len(kwargs), kwargs=kwargs))
has_all_numbers = kwargs.pop('has... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "db_format_helpers/check_field_values.py",
"copies": "1",
"size": "2150",
"license": "apache-2.0",
"hash": -8771751137936458000,
"line_mean": 34.262295082,
"line_max": 105,
"alpha_frac": 0.4869767442,
"autogenerated": false... |
__author__ = 'thorsteinn'
def get_all_ship_fields(db):
ships = db.keys()
fields = []
for ship in ships:
shipDB = db[ship]
shipKeys = shipDB.keys()
for oneKey in shipKeys:
if oneKey not in fields:
fields.append(oneKey)
return fields
def rename_ship_... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "db_format_helpers/ship_fields.py",
"copies": "1",
"size": "2991",
"license": "apache-2.0",
"hash": -7482989258805156000,
"line_mean": 25.2456140351,
"line_max": 119,
"alpha_frac": 0.55667001,
"autogenerated": false,
"rat... |
__author__ = 'thorsteinn'
def line_in_file(aLine,file_name):
'''
a method for finding if a line in a json.dumps file exits
:param aLine: a full line of text, not including \m
:param file_name: the name of a text file, not a reference object
:return: boolean true if found, false if not found
'''... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "db_to_file_helpers/textLines_to_file.py",
"copies": "1",
"size": "1349",
"license": "apache-2.0",
"hash": 5685705812369315000,
"line_mean": 28.9777777778,
"line_max": 71,
"alpha_frac": 0.5974796145,
"autogenerated": false,... |
__author__ = 'thorsteinn'
from db_to_file_helpers.jsonDicts_to_file import file_to_db, db_to_file
from db_format_helpers.strings_in_fields_to_numbers import strings_in_fields_to_numbers
import os
from db_format_helpers.set_blanks_to_None import set_blanks_to_None
def dnv_process_1(db_input_file, **kwargs):
###### s... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "dnv_exchange/dnv_process_db_master.py",
"copies": "1",
"size": "1329",
"license": "apache-2.0",
"hash": -3479389537620816000,
"line_mean": 31.4146341463,
"line_max": 132,
"alpha_frac": 0.662151994,
"autogenerated": false,
... |
__author__ = 'thorsteinn'
from db_to_file_helpers.jsonDicts_to_file import file_to_db
def mc_db_extract_subtable_db(db, **kwargs):
"""
A method for extracting a sub-table information from a mc-db object.
:param db: a database object of the type {ship1:{ship database},ship2:{ship database}
one of the ... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "MarineConnectionSoups/mc_db_to_csv.py",
"copies": "1",
"size": "3375",
"license": "apache-2.0",
"hash": -2264729837541806300,
"line_mean": 34.1666666667,
"line_max": 106,
"alpha_frac": 0.5863703704,
"autogenerated": false,... |
__author__ = 'thorsteinn'
from db_to_file_helpers.jsonDicts_to_file import file_to_db
def parse_component_name(s):
"""
A script for parsing dnv-engine information. Possible engine components were extracted by visual inspection
of all fields seen in the dnv-machinery database
:param s: the dnv name of... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "dnv_exchange/dnv_db_to_csv.py",
"copies": "1",
"size": "8418",
"license": "apache-2.0",
"hash": 6352210219739423000,
"line_mean": 42.621761658,
"line_max": 111,
"alpha_frac": 0.5508434307,
"autogenerated": false,
"ratio"... |
__author__ = 'thorsteinn'
from mc_soup import mc_soup
from db_to_file_helpers.jsonDicts_to_file import append_db_to_file
from db_format_helpers.is_number import is_number
import json
import os
def mc_soup_processor(requested_runs=40, wishlist_filename='wishlist.txt', **kwargs):
"""
A script used for mining ma... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "MarineConnectionSoups/mc_soup_processor.py",
"copies": "1",
"size": "8043",
"license": "apache-2.0",
"hash": 8454318191110889000,
"line_mean": 45.4913294798,
"line_max": 140,
"alpha_frac": 0.622155912,
"autogenerated": fal... |
__author__ = 'thorsteinn'
import csv
import json
from db_to_file_helpers.jsonDicts_to_file import db_to_file
from db_format_helpers.ship_fields import rename_ship_field, stringnumbers_to_numbers, list_all_field_values
# ABS catalogue is a csv file that I copied from the abs website. The catalogue has all the publicly... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "ABS_files/abs_libary_from_catalogue.py",
"copies": "1",
"size": "1927",
"license": "apache-2.0",
"hash": 5164090158635185000,
"line_mean": 43.8139534884,
"line_max": 133,
"alpha_frac": 0.7368967307,
"autogenerated": false,... |
__author__ = 'thorsteinn'
import csv
import urllib2
import re
import json
from bs4 import BeautifulSoup
def bwi_page(country, port):
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
url = 'http://www.bunkerworld.com/prices/port/{c}/{p}/'.format(c = country, p = port)
... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "bwi_fuels/bwi_page.py",
"copies": "1",
"size": "2171",
"license": "apache-2.0",
"hash": -4755442605046606000,
"line_mean": 39.9622641509,
"line_max": 111,
"alpha_frac": 0.5453707969,
"autogenerated": false,
"ratio": 2.98... |
__author__ = 'thorsteinn'
import json
from db_to_file_helpers.jsonDicts_to_file import file_to_db
# first pick up the db from the maritime connection
db = file_to_db('../output_files/mc_db_get_1_fixed.txt')
# find the ships in that db which are in DNV, or Germanische Lloyds
ships = db.keys()
classification_societie... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "maritime_connection/collect_imo_numbers_for_dnv_get_2.py",
"copies": "1",
"size": "1695",
"license": "apache-2.0",
"hash": 632134700971148300,
"line_mean": 36.6888888889,
"line_max": 126,
"alpha_frac": 0.6949852507,
"autog... |
__author__ = 'thorsteinn'
import json
def file_to_db(file_name):
with open(file_name, 'r') as f:
lines = f.readlines()
db = {}
for line in lines:
oneDict = json.loads(line.strip())
db.update(oneDict) # here duplicate entries will be thrown out
return db
... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "db_to_file_helpers/jsonDicts_to_file.py",
"copies": "1",
"size": "1881",
"license": "apache-2.0",
"hash": -8060901922040670000,
"line_mean": 25.125,
"line_max": 106,
"alpha_frac": 0.5741626794,
"autogenerated": false,
"r... |
__author__ = 'thorsteinn'
import urllib2
from bs4 import BeautifulSoup
def setup_items_to_find(sub_view):
return_db = {}
if sub_view == 'record_vesseldetailsprinparticular':
return_db['Designation'] = {'table_type': 'two_column_table', }
'Designation', 'Categories', 'Anchor Equipment', 'Other Inf... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "ABS_files/abs_soup.py",
"copies": "1",
"size": "4364",
"license": "apache-2.0",
"hash": 7324193878364541000,
"line_mean": 34.7786885246,
"line_max": 133,
"alpha_frac": 0.596700275,
"autogenerated": false,
"ratio": 3.6066... |
__author__ = 'thorsteinn'
import urllib2
import re
from bs4 import BeautifulSoup
from db_format_helpers.is_number import is_number
def set_up(item_dict='summary'): # fields ['summary', 'dimensions', 'hullsummary', 'machinerysummary']
"""
a setup call to adjust the various fields and names that exist on the dn... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "dnv_exchange/dnv_exchange_soup_dnv.py",
"copies": "1",
"size": "18186",
"license": "apache-2.0",
"hash": -3078177333221817300,
"line_mean": 48.8246575342,
"line_max": 152,
"alpha_frac": 0.6106895414,
"autogenerated": false... |
__author__ = 'thorsteinn'
def mc_unify_get_documents(folder, file_base, **kwargs):
from glob import glob
import os
from db_to_file_helpers.jsonDicts_to_file import file_to_db, db_to_file
output_file = kwargs.pop('output_file', 'mc_db_master.txt')
foot = os.path.dirname(folder)
ff = os.path.jo... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "MarineConnectionSoups/mc_unify_get_documents.py",
"copies": "1",
"size": "1079",
"license": "apache-2.0",
"hash": 4339078396448506400,
"line_mean": 31.7272727273,
"line_max": 153,
"alpha_frac": 0.6107506951,
"autogenerated... |
__author__ = 'thorsteinn'
from db_to_file_helpers.jsonDicts_to_file import file_to_db, db_to_file
from db_format_helpers.strings_in_fields_to_numbers import strings_in_fields_to_numbers
import os
from db_format_helpers.set_blanks_to_None import set_blanks_to_None
from db_format_helpers.drop_ship_by_key import drop_sh... | {
"repo_name": "ThorsteinnAdal/webcrawls_in_singapore_shippinglane",
"path": "MarineConnectionSoups/mc_process_db_master.py",
"copies": "1",
"size": "2515",
"license": "apache-2.0",
"hash": 2721125759142545000,
"line_mean": 37.6923076923,
"line_max": 132,
"alpha_frac": 0.662027833,
"autogenerated": ... |
__author__ = 'thorwhalen'
# -*- coding: utf-8 -*-
import pandas as pd
import numpy as np
df9_for_dedup = pd.DataFrame(
{'keyword': ['rome hotel','Rome Hotel', 'rome hôtel', ' rome * ** hotel $ ', 'hotel rome', 'rome hotel', 'hotel rome', 'hôtel rome', 'rome hotel', 'rome hotel', 'matt monkey'],
'match_type'... | {
"repo_name": "thorwhalen/ut",
"path": "aw_test/fake_data.py",
"copies": "1",
"size": "1810",
"license": "mit",
"hash": 4779460374596240000,
"line_mean": 85.1428571429,
"line_max": 181,
"alpha_frac": 0.3860619469,
"autogenerated": false,
"ratio": 3.0083194675540765,
"config_test": false,
"has... |
__author__ = 'thorwhalen'
fc = dict(
reset="\033[0m", # alias for reset_all
reset_all="\033[0m",
bold="\033[1m",
dim="\033[2m",
underlined="\033[4m",
blink="\033[5m",
reverse="\033[7m",
hidden="\033[8m",
reset_bold="\033[21m",
reset_dim="\033[22m",
reset_underlined="\033[2... | {
"repo_name": "thorwhalen/ut",
"path": "pstr/to.py",
"copies": "1",
"size": "5680",
"license": "mit",
"hash": 3156997455879804000,
"line_mean": 28.2783505155,
"line_max": 111,
"alpha_frac": 0.6065140845,
"autogenerated": false,
"ratio": 3.2927536231884056,
"config_test": false,
"has_no_keywor... |
__author__ = 'thorwhalen'
from boto.s3.connection import Location
from boto.s3.key import Key
import boto.s3
import tempfile
import pickle
import os
from ut.util.importing import get_environment_variable
class S3(object):
"""
Storage to Amazon S3.
"""
def __init__(self, bucket_name):
"""
... | {
"repo_name": "thorwhalen/ut",
"path": "ams3/s3io_old.py",
"copies": "1",
"size": "3041",
"license": "mit",
"hash": 2727413762462673000,
"line_mean": 32.7888888889,
"line_max": 113,
"alpha_frac": 0.5817165406,
"autogenerated": false,
"ratio": 3.964797913950456,
"config_test": false,
"has_no_k... |
__author__ = 'thorwhalen'
from boto.s3.connection import Location
from boto.s3.key import Key
import boto.s3
import tempfile
import pickle
import os
import sys
from ut.util.importing import get_environment_variable
S3_DEFAULT_REGION = 'eu-west-1'
class S3(object):
"""
Storage to Amazon S3.
"""
def ... | {
"repo_name": "thorwhalen/ut",
"path": "ams3/s3io.py",
"copies": "1",
"size": "3609",
"license": "mit",
"hash": 253034986342997340,
"line_mean": 32.1100917431,
"line_max": 113,
"alpha_frac": 0.57439734,
"autogenerated": false,
"ratio": 3.9529025191675795,
"config_test": false,
"has_no_keyword... |
__author__ = 'thorwhalen'
from datapath import datapath
import pickle
import os
import pandas as pd
import pfile.to as file_to
import pfile.name as file_name
import pstr.to as str_to
from khan_utils.encoding import to_unicode_or_bust
class DataAccessor(object):
def __init__(self, data_root_location=None, extensi... | {
"repo_name": "thorwhalen/ut",
"path": "serialize/data_accessor_bak.py",
"copies": "1",
"size": "2792",
"license": "mit",
"hash": -5606072243611732000,
"line_mean": 30.3820224719,
"line_max": 105,
"alpha_frac": 0.5913323782,
"autogenerated": false,
"ratio": 4.179640718562874,
"config_test": fal... |
__author__ = 'thorwhalen'
from unidecode import unidecode
import os
import re
from bs4 import BeautifulSoup
from io import StringIO
#import ut.pfile
import subprocess
import tempfile
from html.parser import HTMLParser
from bs4.element import Tag
import ut.util.ulist as util_ulist
import ut.pstr.trans as pstr_trans
... | {
"repo_name": "thorwhalen/ut",
"path": "parse/util.py",
"copies": "1",
"size": "6757",
"license": "mit",
"hash": 5351665928585822000,
"line_mean": 29.5791855204,
"line_max": 115,
"alpha_frac": 0.6001183957,
"autogenerated": false,
"ratio": 3.5922381711855396,
"config_test": false,
"has_no_key... |
__author__ = 'thorwhalen'
from unidecode import unidecode
import re
import pandas as pd
########### Partial and incremental formatting #########################################################################
from string import Formatter
# TODO: Make .vformat (therefore .format) work with args and kwargs
# TODO: Ma... | {
"repo_name": "thorwhalen/ut",
"path": "pstr/trans.py",
"copies": "1",
"size": "9314",
"license": "mit",
"hash": -452314797882338700,
"line_mean": 32.6245487365,
"line_max": 120,
"alpha_frac": 0.5740820271,
"autogenerated": false,
"ratio": 3.5347248576850094,
"config_test": false,
"has_no_key... |
__author__ = 'thorwhalen'
from ut.datapath import datapath
import pickle
import os
from ut.util.importing import get_environment_variable
import pandas as pd
import ut.pfile.to as file_to
import ut.pfile.name as pfile_name
import ut.pstr.to as str_to
from ut.pstr.trans import str_to_unicode_or_bust
#from os import env... | {
"repo_name": "thorwhalen/ut",
"path": "serialize/local.py",
"copies": "1",
"size": "4132",
"license": "mit",
"hash": 600162662135535700,
"line_mean": 31.5433070866,
"line_max": 119,
"alpha_frac": 0.6243949661,
"autogenerated": false,
"ratio": 4.011650485436893,
"config_test": false,
"has_no_... |
__author__ = 'thorwhalen'
from ut.pcoll.ordered_set import OrderedSet
def unique_list(x):
return list(dict.fromkeys(x))
def unique_from_iter(it):
d = dict()
for item in it:
d.update(dict.fromkeys(item))
return list(d)
def unique_for_non_hashables(X):
seen = set()
seen_add = seen.a... | {
"repo_name": "thorwhalen/ut",
"path": "pcoll/order_conserving.py",
"copies": "1",
"size": "1320",
"license": "mit",
"hash": 4221897662587286000,
"line_mean": 21.7586206897,
"line_max": 102,
"alpha_frac": 0.6068181818,
"autogenerated": false,
"ratio": 3.291770573566085,
"config_test": false,
... |
__author__ = 'thorwhalen'
from warnings import warn
from collections import Counter, defaultdict
from datetime import datetime
from pprint import PrettyPrinter
import json
from contextlib import suppress as _suppress
# class ModuleNotFoundIgnore:
# def __enter__(self):
# return self
#
# def __exit__(... | {
"repo_name": "thorwhalen/ut",
"path": "my.py",
"copies": "1",
"size": "3626",
"license": "mit",
"hash": 3752651190077896700,
"line_mean": 25.0863309353,
"line_max": 77,
"alpha_frac": 0.7159404302,
"autogenerated": false,
"ratio": 3.7151639344262297,
"config_test": false,
"has_no_keywords": f... |
__author__ = 'thorwhalen'
"""
functions that work on soup, soup tags, etc.
"""
import bs4
from ut.pgenerator.get import last_element
from tempfile import mkdtemp
import os
import ut.pstr.to as strto
import ut.parse.util as parse_util
import ut.pstr.trans as pstr_trans
def root_parent(s):
return last_element(s.p... | {
"repo_name": "thorwhalen/ut",
"path": "parse/bsoup.py",
"copies": "1",
"size": "2106",
"license": "mit",
"hash": 1739490398230975000,
"line_mean": 27.8493150685,
"line_max": 114,
"alpha_frac": 0.5959164292,
"autogenerated": false,
"ratio": 3.463815789473684,
"config_test": false,
"has_no_key... |
__author__ = 'thorwhalen'
import datetime
from . import reporting as rp
import pandas
#settings
save_folder = '/D/Dropbox/dev/py/data/query_data/'
account_list = rp.get_account_id('dict')
account_list = list(account_list.keys())
numOfDays = 60
report_query_str = rp.mk_report_query_str(
varList='q_iipic',
sta... | {
"repo_name": "thorwhalen/ut",
"path": "aw/SCRAP_fetching_queries.py",
"copies": "1",
"size": "1111",
"license": "mit",
"hash": 4562080899991298600,
"line_mean": 26.1219512195,
"line_max": 75,
"alpha_frac": 0.6237623762,
"autogenerated": false,
"ratio": 3.2676470588235293,
"config_test": false,... |
__author__ = 'thorwhalen'
import functools
class ParseSearchTerms(object):
def __init__(self,
html_pull=None,
html_pull_failure_action=None,
parser=None,
parser_failure_action=None,
parse_diagnosis=None,
parse_d... | {
"repo_name": "thorwhalen/ut",
"path": "parse/bak/bak_parse_search_terms.py",
"copies": "1",
"size": "3342",
"license": "mit",
"hash": 3231757948347330600,
"line_mean": 41.3037974684,
"line_max": 177,
"alpha_frac": 0.5867743866,
"autogenerated": false,
"ratio": 4.050909090909091,
"config_test":... |
__author__ = 'thorwhalen'
import logging
import traceback
import json
from datetime import datetime
import pandas as pd
from pandas import DataFrame
import os
from ut.util.importing import get_environment_variable
import numpy as np
from serialize.amazon_sender import AmazonSender
from collections import OrderedDict
... | {
"repo_name": "thorwhalen/ut",
"path": "serialize/ms_logger.py",
"copies": "1",
"size": "10093",
"license": "mit",
"hash": -9076478460782712000,
"line_mean": 35.8394160584,
"line_max": 118,
"alpha_frac": 0.5843654018,
"autogenerated": false,
"ratio": 3.774495138369484,
"config_test": false,
"... |
__author__ = 'thorwhalen'
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
def force_axis_to_contain(axis=None, num=0):
"""
changes axis limits so that it will contain num
"""
fun = _axis_fun('lim', axis)
lim = fun()
if num < lim:
fun([num,... | {
"repo_name": "thorwhalen/ut",
"path": "pplot/ch.py",
"copies": "1",
"size": "2059",
"license": "mit",
"hash": -3992115835628241400,
"line_mean": 25.3974358974,
"line_max": 96,
"alpha_frac": 0.5823215153,
"autogenerated": false,
"ratio": 3.2630744849445326,
"config_test": false,
"has_no_keywo... |
__author__ = 'thorwhalen'
import matplotlib.pyplot as plt
import tempfile
from PIL import Image
import os
import fnmatch
import numpy as np
from matplotlib import animation
def mk_2d_sequence_gif(x_seq, y_seq, filename='make_2d_sequence_gif.gif', plot_kwargs={},
edit_funs={}, writeGif_kwargs={... | {
"repo_name": "thorwhalen/ut",
"path": "pplot/anim.py",
"copies": "1",
"size": "3560",
"license": "mit",
"hash": -6212187018210805000,
"line_mean": 32.5849056604,
"line_max": 123,
"alpha_frac": 0.5646067416,
"autogenerated": false,
"ratio": 3.423076923076923,
"config_test": false,
"has_no_key... |
__author__ = 'thorwhalen'
import numpy as np
import ut.daf.ch as daf_ch
import ut.semantics.math as semantics_math
import nltk
import pandas as pd
class TermWeightGetter(object):
def __init__(self, term_gweight_selector):
self.term_gweight_selector = term_gweight_selector
def termcount_to_termweigh... | {
"repo_name": "thorwhalen/ut",
"path": "semantics/term_stats.py",
"copies": "1",
"size": "6044",
"license": "mit",
"hash": -5303177466726613000,
"line_mean": 36.0858895706,
"line_max": 123,
"alpha_frac": 0.6437789543,
"autogenerated": false,
"ratio": 3.0295739348370927,
"config_test": false,
... |
__author__ = 'thorwhalen'
import os
import glob
from ut.pcoll.op import ismember
import re
def recursive_file_walk_iterator(directory, pattern=''):
if isinstance(pattern, str):
pattern = re.compile(pattern)
# return pattern
for name in os.listdir(directory):
full_path = os.path.join(direc... | {
"repo_name": "thorwhalen/ut",
"path": "pfile/name.py",
"copies": "1",
"size": "6976",
"license": "mit",
"hash": -172932865988940030,
"line_mean": 31.2962962963,
"line_max": 129,
"alpha_frac": 0.6293004587,
"autogenerated": false,
"ratio": 3.671578947368421,
"config_test": false,
"has_no_keyw... |
__author__ = 'thorwhalen'
import pandas as pd
import numpy as np
import semantics.term_stats as ts
class IntentTargetAnalysis(object):
def __init__(self,
get_intent_termstats=None,
get_target_termstats=None,
similarity_measure=ts.cosine,
**kwargs... | {
"repo_name": "thorwhalen/ut",
"path": "semantics/intent_target_analysis.py",
"copies": "1",
"size": "1172",
"license": "mit",
"hash": 7674224546567022000,
"line_mean": 32.4857142857,
"line_max": 69,
"alpha_frac": 0.5964163823,
"autogenerated": false,
"ratio": 3.867986798679868,
"config_test": ... |
__author__ = 'thorwhalen'
import pandas as pd
import numpy as np
import string
import random
from ut.pfile.name import fileparts, data_file, delim_file
from ut.util import log
import pickle
import zipfile
import gzip
import re
def lidx_of_rows_whose_col_values_match_pattern(df, col, pattern):
if isinstance(patte... | {
"repo_name": "thorwhalen/ut",
"path": "daf/get.py",
"copies": "1",
"size": "8158",
"license": "mit",
"hash": 4104852877797835300,
"line_mean": 33.7191489362,
"line_max": 116,
"alpha_frac": 0.6087276293,
"autogenerated": false,
"ratio": 3.4774083546462062,
"config_test": false,
"has_no_keywor... |
__author__ = 'thorwhalen'
import pandas as pd
import ut.daf.get as daf_get
import ut.pstr.trans as pstr_trans
import numpy as np
import re
non_w_letter_re = re.compile('[^\w]+')
def empty_index(df):
df.index = [''] * len(df)
return df
def sr_set_values(sr, values):
sr_name = sr.name
index_names = ... | {
"repo_name": "thorwhalen/ut",
"path": "daf/ch.py",
"copies": "1",
"size": "6275",
"license": "mit",
"hash": -5450994289010498000,
"line_mean": 31.1846153846,
"line_max": 98,
"alpha_frac": 0.588685259,
"autogenerated": false,
"ratio": 3.3324482209240576,
"config_test": false,
"has_no_keywords... |
__author__ = 'thorwhalen'
import pandas as pd
import ut.util.ulist as ulist
import ut.pstr.trans as pstr_trans
import ut.aw.manip as aw_manip
_Broad = 'BROAD'
_Phrase = 'PHRASE'
_Exact = 'EXACT'
_match_type_list = [_Broad,_Phrase,_Exact]
_match_type_tag = {_Broad:'B', _Phrase:'P', _Exact:'X'}
_no_match_tag = '_'
_bp... | {
"repo_name": "thorwhalen/ut",
"path": "aw/russian_dolls_CAPS.py",
"copies": "1",
"size": "3305",
"license": "mit",
"hash": -5132360480815901000,
"line_mean": 34.9239130435,
"line_max": 112,
"alpha_frac": 0.6202723147,
"autogenerated": false,
"ratio": 2.7359271523178808,
"config_test": false,
... |
__author__ = 'thorwhalen'
import pfile.accessor as pfile_accessor
from analyzer.pstore import MyStore
from analyzer.pstore import StoreAccessor
local_facc = pfile_accessor.for_local('hdf5/')
def for_local(
store_path_dict=None
):
if store_path_dict is None:
store_path_dict = {
'ad_el... | {
"repo_name": "thorwhalen/ut",
"path": "aw/store_accessor.py",
"copies": "1",
"size": "1643",
"license": "mit",
"hash": -6394831768170740000,
"line_mean": 33.25,
"line_max": 128,
"alpha_frac": 0.5952525867,
"autogenerated": false,
"ratio": 3.014678899082569,
"config_test": false,
"has_no_keyw... |
__author__ = 'thorwhalen'
import ut.parse.google as google
import pandas as pd
import re
from bs4.element import Tag
import ut.semantics.text_processors as semantics_text_processors
import ut.util.ulist as util_ulist
import ut.daf.manip as daf_manip
import ut.coll.order_conserving as colloc
#### Utilsxw
LOCATION_LOC... | {
"repo_name": "thorwhalen/ut",
"path": "semantics/term_stats_maker.py",
"copies": "1",
"size": "7764",
"license": "mit",
"hash": -897353993439477800,
"line_mean": 37.0588235294,
"line_max": 144,
"alpha_frac": 0.6335651726,
"autogenerated": false,
"ratio": 3.406757349714787,
"config_test": false... |
__author__ = 'thorwhalen'
"""
Includes functions to diagnose duplicates in adwords elements
"""
from ut.aw.manip import add_col
from ut.daf.dup_diag import get_duplicates
import ut.coll.order_conserving as oc
from ut.aw.manip import assert_dependencies
import pandas as pd
import ut.daf.ch as daf_ch
import ut.daf.dup_d... | {
"repo_name": "thorwhalen/ut",
"path": "aw/dup_diag.py",
"copies": "1",
"size": "9120",
"license": "mit",
"hash": 7733054169356004000,
"line_mean": 41.8169014085,
"line_max": 125,
"alpha_frac": 0.614254386,
"autogenerated": false,
"ratio": 3.065546218487395,
"config_test": false,
"has_no_keyw... |
__author__ = 'thorwhalen'
"""
Includes various adwords elements diagnosis functions
"""
#from daf.manip import lower_series
# from numpy.lib import arraysetops
# import pandas as pd
def ad_group_ids_are_unique(df):
"""
This function returns True iff ad_group_ids are unique (only show up once in the rows of d... | {
"repo_name": "thorwhalen/ut",
"path": "aw/diagnosis.py",
"copies": "1",
"size": "1310",
"license": "mit",
"hash": 8832774249669086000,
"line_mean": 31.75,
"line_max": 114,
"alpha_frac": 0.6580152672,
"autogenerated": false,
"ratio": 3.2029339853300733,
"config_test": false,
"has_no_keywords"... |
__author__ = 'thorwhalen'
def show(d,nlines=None,cols=None):
if nlines is None: nlines=len(d)
if cols is None: cols = d.columns
if isinstance(cols,str): cols = [cols]
print(d[:nlines][cols].to_string())
def sw(df, up_rows=10, down_rows=5, left_cols=4, right_cols=3, return_df=False):
''' display ... | {
"repo_name": "thorwhalen/ut",
"path": "daf/disp.py",
"copies": "1",
"size": "1799",
"license": "mit",
"hash": 1135919591125324400,
"line_mean": 39.8863636364,
"line_max": 121,
"alpha_frac": 0.5658699277,
"autogenerated": false,
"ratio": 2.896940418679549,
"config_test": false,
"has_no_keywor... |
__author__ = 'thorwhalen'
from bs4 import BeautifulSoup
import re
# import os.path
# from urllib2 import urlopen
# from ut.pfile import to
from lxml import etree
import tldextract
import ut.parse.util as util
from urllib.parse import urlparse, parse_qs
from ut.util import extract_section
# RE_HAS_NEW_LINE = re.compi... | {
"repo_name": "thorwhalen/ut",
"path": "bak/google_bak01.py",
"copies": "1",
"size": "25339",
"license": "mit",
"hash": -3757860287990393300,
"line_mean": 37.3343419062,
"line_max": 189,
"alpha_frac": 0.5264217215,
"autogenerated": false,
"ratio": 3.297202342225114,
"config_test": false,
"has... |
__author__ = 'thorwhalen'
import pandas as pd
import ut.pdict.ot as pdict_ot
import ut.util.ulist as util_ulist
from collections import OrderedDict
import re
import ut.pstr.trans as pstr_trans
# import ut.parse.html2text_formated as html2text_formated
from pattern.web import plaintext
# import venere.data_source as... | {
"repo_name": "thorwhalen/ut",
"path": "semantics/text_processors.py",
"copies": "1",
"size": "4005",
"license": "mit",
"hash": 4675517583501558000,
"line_mean": 43.010989011,
"line_max": 120,
"alpha_frac": 0.6277153558,
"autogenerated": false,
"ratio": 3.449612403100775,
"config_test": false,
... |
__author__ = 'thorwhalen'
import pymongo as mg
import pandas as pd
from ut.util.imports.ipython_utils import PPR
from ut.daf.to import dict_list_of_rows
from ut.daf.manip import rm_cols_if_present
from ut.daf.ch import to_utf8
def mdb_info(mg_element=None):
if mdb_info is None:
return mdb_info(mg.MongoC... | {
"repo_name": "thorwhalen/ut",
"path": "dacc/mong/com.py",
"copies": "1",
"size": "4599",
"license": "mit",
"hash": -6366190786834566000,
"line_mean": 37.325,
"line_max": 117,
"alpha_frac": 0.6149162861,
"autogenerated": false,
"ratio": 3.8229426433915212,
"config_test": false,
"has_no_keywor... |
__author__ = 'thorwhalen'
import ut.aw
from numpy.lib import arraysetops
import pandas as pd
import ut.daf
import ut.util
def get_unique(d,cols):
d = d.reindex(index=list(range(len(d))))
grouped = d.groupby(cols)
index = [gp_keys[0] for gp_keys in list(grouped.groups.values())]
return d.reindex(ind... | {
"repo_name": "thorwhalen/ut",
"path": "aw/bull_shit_hack_because_imports_dont_work_WTF.py",
"copies": "1",
"size": "2980",
"license": "mit",
"hash": 5543270433176772000,
"line_mean": 29.1111111111,
"line_max": 122,
"alpha_frac": 0.6496644295,
"autogenerated": false,
"ratio": 3.322185061315496,
... |
__author__ = 'thorwhalen'
#import ut.util as putil
#import re
import ut.parse.google as parse_google
from ut.semantics.term_stats_maker import TermStatsMaker
import ut.semantics.term_stats_maker as term_stats_maker
from collections import OrderedDict
LOCATION_LOCAL = 'LOCAL'
LOCATION_S3 = 'S3'
class GResultInfoRetr... | {
"repo_name": "thorwhalen/ut",
"path": "parse/gresult_info_retriever.py",
"copies": "1",
"size": "4182",
"license": "mit",
"hash": -2721667699934692400,
"line_mean": 50,
"line_max": 129,
"alpha_frac": 0.6984696318,
"autogenerated": false,
"ratio": 3.5113350125944582,
"config_test": false,
"ha... |
__author__ = 'thorwhalen'
# utils to get from a pfile to... something else
from ut.pfile.name import replace_extension
import os
import gzip
def string(filename):
"""
returns the string contents of a pfile
"""
fid = file(filename)
s = fid.read()
fid.close()
return s
def zip_file(source_... | {
"repo_name": "thorwhalen/ut",
"path": "pfile/to.py",
"copies": "1",
"size": "2804",
"license": "mit",
"hash": 190210946878588830,
"line_mean": 32,
"line_max": 115,
"alpha_frac": 0.6080599144,
"autogenerated": false,
"ratio": 3.5810983397190292,
"config_test": false,
"has_no_keywords": false,... |
from org.gluu.service.cdi.util import CdiUtil
from org.gluu.oxauth.security import Identity
from org.gluu.model.custom.script.type.auth import PersonAuthenticationType
from org.gluu.oxauth.service import AuthenticationService
from org.gluu.util import StringHelper
from org.gluu.oxauth.util import ServerUtil
from com.p... | {
"repo_name": "GluuFederation/oxAuth",
"path": "Server/integrations/ThumbSignIn/ThumbSignInExternalAuthenticator.py",
"copies": "2",
"size": "14838",
"license": "mit",
"hash": 6053286807783154000,
"line_mean": 45.5141065831,
"line_max": 158,
"alpha_frac": 0.6794716269,
"autogenerated": false,
"ra... |
# Imports
#########
# from datetime import datetime as dt
import subprocess
import re
import os
import sys
IS_PY2 = sys.version_info < (3, 0)
if IS_PY2:
from Queue import Queue
else:
from queue import Queue
from threading import Thread
from datetime import datetime
import time
from influxdb import InfluxDB... | {
"repo_name": "SurrealTiggi/mess",
"path": "python/Work stuff/GomezPoolMonitor.py",
"copies": "1",
"size": "7338",
"license": "mit",
"hash": 9123326177903269000,
"line_mean": 30.4935622318,
"line_max": 108,
"alpha_frac": 0.5372035977,
"autogenerated": false,
"ratio": 3.4777251184834124,
"config... |
__author__ = 'Tiago'
__documentation__ = 'https://pythonhosted.org/RPIO/rpio_py.html#ref-rpio-py-additions'
from FakeRPi.GPIO import *
RPI_REVISION = 1
RPI_REVISION_HEX = 0x0002
def gpio_function(channel):
"""
returns the current setup of a gpio (IN, OUT, ALT0)
:param channel:
:return:
"""
... | {
"repo_name": "jpnos26/thermostat_V3",
"path": "FakeRPi/RPIO.py",
"copies": "5",
"size": "3730",
"license": "mit",
"hash": -6159177153586751000,
"line_mean": 30.5847457627,
"line_max": 235,
"alpha_frac": 0.6969940955,
"autogenerated": false,
"ratio": 3.8098159509202456,
"config_test": false,
... |
__author__ = 'Tiago'
"""
Board pin constants
Pi B REV 2 & B+ J8
"""
#PIN_3v = 1 # DC Power 3.3v
#PIN_5v = 2 # DC Power 5v
PIN_GPIO_02 = 3 # GPIO02 (SDA1, I2C)
PIN_GPIO_02_SDA1_I2C = PIN_GPIO_02 # GPIO02 (SDA1, I2C)
#PIN_5v = 4 ... | {
"repo_name": "jpnos26/thermostat",
"path": "FakeRPi/Utilities.py",
"copies": "5",
"size": "7007",
"license": "mit",
"hash": -8116798458724096000,
"line_mean": 34.5736040609,
"line_max": 63,
"alpha_frac": 0.4867989154,
"autogenerated": false,
"ratio": 2.593264248704663,
"config_test": false,
... |
__author__ = 'tianchen'
from utils.helper import *
from utils.db_handlers.roles import *
from taskflow import task
import taskflow.engines
from taskflow.patterns import unordered_flow as uf
LOG = logging.getLogger(__name__)
def delete_role(role, target):
"""
delete a role from the target cloud
:param ro... | {
"repo_name": "Phoenix1708/OpenAcademy_OpenStack_Flyway",
"path": "flyway/flow/roletask.py",
"copies": "1",
"size": "4760",
"license": "apache-2.0",
"hash": 7123967147043842000,
"line_mean": 29.9090909091,
"line_max": 82,
"alpha_frac": 0.5733193277,
"autogenerated": false,
"ratio": 4.121212121212... |
__author__ = 'tianchen'
import logging
from utils.db_base import *
from common import config
TABLE_NAME = 'roles'
LOG = logging.getLogger(__name__)
def update_complete(role_name):
update_table(TABLE_NAME,
{'state': 'completed'},
{'roleName': role_name,
'src_c... | {
"repo_name": "Phoenix1708/OpenAcademy_OpenStack_Flyway",
"path": "flyway/utils/db_handlers/roles.py",
"copies": "1",
"size": "3016",
"license": "apache-2.0",
"hash": 6287642138665458000,
"line_mean": 30.4166666667,
"line_max": 78,
"alpha_frac": 0.5361405836,
"autogenerated": false,
"ratio": 3.70... |
__author__ = 'Tian Gan'
## unit test for get_user_info() from users.py
## Notes:
# According to the API requirement. The User ID is used to get the user info such as profile and group
# The current get_user_info() can get the user info using the user instance but can't get the user info using the User ID
# The obta... | {
"repo_name": "hydroshare/hydroshare_temp",
"path": "hs_core/tests/api/native/test_get_user_info.py",
"copies": "1",
"size": "3608",
"license": "bsd-3-clause",
"hash": 5937369392545954000,
"line_mean": 28.8181818182,
"line_max": 121,
"alpha_frac": 0.5310421286,
"autogenerated": false,
"ratio": 4.... |
import ctypes
import os
# optinally have scipy sparse, though not necessary
import numpy
import sys
import numpy.ctypeslib
import scipy.sparse as scp
# set this line correctly
XGBOOST_PATH = os.path.dirname(__file__)+'/libxgboostwrapper.so'
# load in xgboost library
xglib = ctypes.cdll.LoadLibrary(XGBOOST_PATH)
xgli... | {
"repo_name": "tanayz/Kaggle",
"path": "HB_ML_Challenge/xgboostR/wrapper/xgboost.py",
"copies": "1",
"size": "11490",
"license": "apache-2.0",
"hash": 2710964634103212000,
"line_mean": 40.7818181818,
"line_max": 113,
"alpha_frac": 0.584073107,
"autogenerated": false,
"ratio": 3.49346305868045,
... |
__author__ = 'Tian'
import csv
import json
from itertools import chain
import os
from glob import glob
import mysql.connector
filename = ""
def process_dir(dir):
result = (chain.from_iterable(glob(os.path.join(x[0], '*.*')) for x in os.walk(dir)))
for s in result:
convertToCSVFile(s... | {
"repo_name": "anivk/riceai-traffic",
"path": "archive/JSONToCSV.py",
"copies": "1",
"size": "3980",
"license": "mit",
"hash": 6441991062923909000,
"line_mean": 40.3617021277,
"line_max": 274,
"alpha_frac": 0.466080402,
"autogenerated": false,
"ratio": 3.826923076923077,
"config_test": false,
... |
__author__ = 'Tian'
import json
from itertools import chain
import os
from glob import glob
import mysql.connector
buffer = []
def process_dir(dir):
result = (chain.from_iterable(glob(os.path.join(x[0], '*.*')) for x in os.walk(dir)))
for s in result:
addFileToDB(s)
print("P... | {
"repo_name": "anivk/riceai-traffic",
"path": "archive/DirToMySQL.py",
"copies": "1",
"size": "4849",
"license": "mit",
"hash": 2364996385498790000,
"line_mean": 36.792,
"line_max": 115,
"alpha_frac": 0.3450195917,
"autogenerated": false,
"ratio": 4.666987487969201,
"config_test": false,
"has... |
__author__ = 'tieni'
from datetime import datetime
from django.utils.timezone import utc
from django.utils.translation import ugettext_lazy as _
from forms import *
from serializers import *
def writeAuthHistory(history, user, type, message=""):
"""
write messages to the user management history.
If his... | {
"repo_name": "floatec/ProsDataBase",
"path": "ProsDataBase/database/historyfactory.py",
"copies": "1",
"size": "5787",
"license": "bsd-2-clause",
"hash": 789418186617867100,
"line_mean": 31.8863636364,
"line_max": 114,
"alpha_frac": 0.5403490582,
"autogenerated": false,
"ratio": 4.40746382330540... |
__author__ = 'tieni'
import csv
import json
import sys
from django.http import HttpResponse
from models import *
from forms import *
import historyfactory
from response import *
from django.utils.translation import ugettext_lazy as _
def modifyCategories(request):
"""
modifies the existing category names.
... | {
"repo_name": "floatec/ProsDataBase",
"path": "ProsDataBase/database/tablefactory.py",
"copies": "1",
"size": "60374",
"license": "bsd-2-clause",
"hash": -912622159229898400,
"line_mean": 47.7673667205,
"line_max": 304,
"alpha_frac": 0.5653095703,
"autogenerated": false,
"ratio": 4.26580936903836... |
__author__ = 'tieni'
import json
from django.utils.translation import ugettext_lazy as _
from django.http import HttpResponse
from models import *
from forms import *
from response import Error
import historyfactory
def register(request):
jsonRequest = json.loads(request.raw_post_data)
try:
DBUser.o... | {
"repo_name": "floatec/ProsDataBase",
"path": "ProsDataBase/database/userfactory.py",
"copies": "1",
"size": "10242",
"license": "bsd-2-clause",
"hash": 7351258709894667000,
"line_mean": 43.150862069,
"line_max": 233,
"alpha_frac": 0.6248779535,
"autogenerated": false,
"ratio": 4.2907415165479685... |
__author__ = 'Ties'
import Statement as S
import copy
class Statement:
def __init__(self,statement):
self.statement = statement
self.children = []
self.compile()
def compile(self):
#Remove whitespaces at front
while self.statement[0] == ' ':
self.statement... | {
"repo_name": "Sipondo/python-false-interpreter",
"path": "Statement.py",
"copies": "1",
"size": "25901",
"license": "mit",
"hash": -4155011604341841000,
"line_mean": 56.56,
"line_max": 319,
"alpha_frac": 0.5077796224,
"autogenerated": false,
"ratio": 3.49023042716615,
"config_test": false,
"... |
__author__ = "Tihamer Levendovszky, Subhav Pradhan"
# Base class for solvers computing new configuration
from z3 import *
from configuration_solver import ConfigurationSolver
from logger import get_logger
logger = get_logger("new_configuration_solver")
class NewConfigurationSolver(ConfigurationSolver):
def __in... | {
"repo_name": "dcpssc/chariot",
"path": "Runtime/chariot_runtime_libs/new_configuration_solver.py",
"copies": "2",
"size": "6818",
"license": "mit",
"hash": 7537673437433406000,
"line_mean": 40.0722891566,
"line_max": 129,
"alpha_frac": 0.5252273394,
"autogenerated": false,
"ratio": 4.52422030524... |
__author__ = "Tihamer Levendovszky, Subhav Pradhan"
from new_configuration_solver import NewConfigurationSolver
# Backend-aware new configuration solver
class NewConfigurationSolverBound(NewConfigurationSolver):
def __init__(self, backend):
#super(NewConfigurationSolverBound, self).__init__(len(backend... | {
"repo_name": "visor-vu/chariot",
"path": "Runtime/chariot_runtime_libs/new_configuration_solver_bound.py",
"copies": "2",
"size": "2801",
"license": "mit",
"hash": 3972144147080600600,
"line_mean": 43.4603174603,
"line_max": 127,
"alpha_frac": 0.5215994288,
"autogenerated": false,
"ratio": 5.872... |
__author__ = 'Tillsten'
from nose.tools import raises, assert_raises
from qtdataflow.model import Schema, Node
def test_schema():
schema = Schema()
n1 = Node()
n2 = Node()
n3 = Node()
schema.add_node(n1)
schema.add_node(n2)
schema.add_node(n3)
assert(n1 in schema.nodes)
assert(n2 i... | {
"repo_name": "Tillsten/qt-dataflow",
"path": "qtdataflow/tests/test.py",
"copies": "1",
"size": "1550",
"license": "bsd-3-clause",
"hash": -129230223711491500,
"line_mean": 22.1343283582,
"line_max": 62,
"alpha_frac": 0.6103225806,
"autogenerated": false,
"ratio": 2.83363802559415,
"config_tes... |
__author__ = 'Tillsten'
from qtdataflow.Qt import QtGui
from qtdataflow.Qt import QtCore
from view import SchemaView, NodeView, PixmapNodeView
from model import Schema
class ToolBar(QtGui.QGraphicsView):
"""
Toolbar which show the availeble nodes.
"""
node_clicked = QtCore.Signal(object)
def ... | {
"repo_name": "Tillsten/qt-dataflow",
"path": "qtdataflow/gui.py",
"copies": "1",
"size": "2789",
"license": "bsd-3-clause",
"hash": 2935471373054193700,
"line_mean": 29.6483516484,
"line_max": 79,
"alpha_frac": 0.6249551811,
"autogenerated": false,
"ratio": 3.6842800528401587,
"config_test": f... |
__author__ = 'Tillsten'
from qtdataflow.view import WidgetNodeView, SchemaView
from qtdataflow.model import Node, Schema
from qtdataflow.Qt import QtGui
QSpinBox = QtGui.QSpinBox
QApplication = QtGui.QApplication
QGraphicsView = QtGui.QGraphicsView
class SpinBoxNode(Node):
def __init__(self):
super(SpinBo... | {
"repo_name": "Tillsten/qt-dataflow",
"path": "qtdataflow/examples/example_widget.py",
"copies": "1",
"size": "1492",
"license": "bsd-3-clause",
"hash": 57994663819667170,
"line_mean": 22.6984126984,
"line_max": 56,
"alpha_frac": 0.6065683646,
"autogenerated": false,
"ratio": 3.352808988764045,
... |
__author__ = 'tilmannbruckhaus'
# Even Fibonacci numbers
# Problem 2
# Each new term in the Fibonacci sequence is generated by adding the previous two terms.
# By starting with 1 and 2, the first 10 terms will be:
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
# By considering the terms in the Fibonacci sequence whose value... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p002_even_fibonacci.py",
"copies": "1",
"size": "1367",
"license": "mit",
"hash": -2107489658923146000,
"line_mean": 30.7906976744,
"line_max": 117,
"alpha_frac": 0.5844915874,
"autogenerated": false,
"ratio": 3.408977... |
__author__ = 'tilmannbruckhaus'
import os
import sys
current_path = os.path.dirname(os.path.abspath(__file__))
lib_path = os.path.join(current_path, '..')
sys.path.append(lib_path)
from lib.pandigital import Pandigital
class LexicographicPermutations:
# Lexicographic permutations
# Problem 24
# A permu... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p024_lexicographic_permutations.py",
"copies": "1",
"size": "1147",
"license": "mit",
"hash": -7787080489054365000,
"line_mean": 30,
"line_max": 106,
"alpha_frac": 0.6425457716,
"autogenerated": false,
"ratio": 3.24011... |
__author__ = 'tilmannbruckhaus'
# Largest product in a series
# Problem 8
# The four adjacent digits in the 1000-digit number that have the greatest product are 9 x 9 x 8 x 9 = 5832.
#
# 73167176531330624919225119674426574742355349194934
# 96983520312774506326239578318016984801869478851843
# 85861560789112949495459501... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p008_largest_product_in_series.py",
"copies": "1",
"size": "3487",
"license": "mit",
"hash": 8432845297069011000,
"line_mean": 44.2857142857,
"line_max": 108,
"alpha_frac": 0.7608259249,
"autogenerated": false,
"ratio"... |
__author__ = 'tilmannbruckhaus'
class AmicableNumbers:
# Amicable numbers
# Problem 21
# Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
# If d(a) = b and d(b) = a, where a != b, then a and b are an amicable pair and each of a and b are called
... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p021_amicable_numbers.py",
"copies": "1",
"size": "1526",
"license": "mit",
"hash": 4150649653494365000,
"line_mean": 31.4680851064,
"line_max": 117,
"alpha_frac": 0.5701179554,
"autogenerated": false,
"ratio": 3.09533... |
__author__ = 'tilmannbruckhaus'
class CountingSundays:
# Counting Sundays
# Problem 19
# You are given the following information, but you may prefer to do some research for yourself.
#
# 1 Jan 1900 was a Monday.
# Thirty days has September,
# April, June and November.
# All the rest ha... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p019_counting_sundays.py",
"copies": "1",
"size": "1914",
"license": "mit",
"hash": -1588416615727974400,
"line_mean": 30.9,
"line_max": 111,
"alpha_frac": 0.5543364681,
"autogenerated": false,
"ratio": 3.5909943714821... |
__author__ = 'tilmannbruckhaus'
class DoubleBasePalindrome:
"""
Double-base palindromes
Problem 36
The decimal number, 585 = 1001001001 (base 2 binary), is palindromic in both bases.
Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.
(Please note... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p036_double_base_palindromes.py",
"copies": "1",
"size": "1497",
"license": "mit",
"hash": -5805593211825031000,
"line_mean": 25.2631578947,
"line_max": 107,
"alpha_frac": 0.5564462258,
"autogenerated": false,
"ratio":... |
__author__ = 'tilmann.bruckhaus'
class Hanoi:
def __init__(self, disks):
print "Playing \"Towers of Hanoi\" for ", disks, " disks:"
self.disks = disks
self.source_peg = []
self.helper_peg = []
self.target_peg = []
self.set_up_pegs()
self.show()
def sol... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/hanoi.py",
"copies": "1",
"size": "1078",
"license": "mit",
"hash": 6909502216494593000,
"line_mean": 28.9722222222,
"line_max": 80,
"alpha_frac": 0.5565862709,
"autogenerated": false,
"ratio": 3.2083333333333335,
"config_test": f... |
__author__ = 'tilmannbruckhaus'
class LargestPalindrome:
# Largest palindrome product
# Problem 4
# A palindromic number reads the same both ways.
# The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99.
# Find the largest palindrome made from the product of two 3-... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p004_largest_palindrome.py",
"copies": "1",
"size": "1217",
"license": "mit",
"hash": 8101248992547010000,
"line_mean": 30.2051282051,
"line_max": 102,
"alpha_frac": 0.5414954807,
"autogenerated": false,
"ratio": 3.888... |
__author__ = 'tilmannbruckhaus'
class LargestProductInAGrid:
# Largest product in a grid
# Problem 11
# In the 20x20 grid below, four numbers along a diagonal line have been marked (in parentheses).
#
# 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
# 49 49 99 40 17 81 18 57 60 8... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p011_largest_product_in_a_grid.py",
"copies": "1",
"size": "6269",
"license": "mit",
"hash": 1610746815755154700,
"line_mean": 46.4924242424,
"line_max": 100,
"alpha_frac": 0.5185835061,
"autogenerated": false,
"ratio"... |
__author__ = 'tilmannbruckhaus'
class LargeSum:
# Large sum
# Problem 13
# Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.
#
# 37107287533902102798797998220837590246510135740250
# 46376937677490009712648124896970078050417018260538
# 74324986199524741... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p013_large_sum.py",
"copies": "1",
"size": "12009",
"license": "mit",
"hash": 2861339592046434000,
"line_mean": 47.6194331984,
"line_max": 96,
"alpha_frac": 0.8852527271,
"autogenerated": false,
"ratio": 2.456330537942... |
__author__ = 'tilmannbruckhaus'
class LongestCollatzSequence:
# Longest Collatz sequence
# Problem 14
# The following iterative sequence is defined for the set of positive integers:
#
# n -> n/2 (n is even)
# n -> 3n + 1 (n is odd)
#
# Using the rule above and starting with 13, we gen... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p014_longest_collatz_sequence.py",
"copies": "1",
"size": "1596",
"license": "mit",
"hash": -8602532815398440000,
"line_mean": 28.0181818182,
"line_max": 94,
"alpha_frac": 0.5413533835,
"autogenerated": false,
"ratio":... |
__author__ = 'tilmann.bruckhaus'
class Matrix:
def __init__(self, values):
self.values = values
def traverse(self):
self.compute_paths()
return self.values[-1][-1]
def compute_paths(self):
for row in range(len(self.values)):
for column in range(len(self.values... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/matrix.py",
"copies": "1",
"size": "1710",
"license": "mit",
"hash": 7793885077998098000,
"line_mean": 34.625,
"line_max": 110,
"alpha_frac": 0.4526315789,
"autogenerated": false,
"ratio": 3.9310344827586206,
"config_test": false,... |
__author__ = 'tilmannbruckhaus'
class MaximumPathSum:
# Maximum path sum I
# Problem 18
# By starting at the top of the triangle below and moving to adjacent numbers on the row below,
# the maximum total from top to bottom is 23.
#
# 3
# 7 4
# 2 4 6
# 8 5 9 3
#
# That... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p018_maximum_path_sum.py",
"copies": "1",
"size": "2412",
"license": "mit",
"hash": 2241163818491496400,
"line_mean": 34.4705882353,
"line_max": 103,
"alpha_frac": 0.4850746269,
"autogenerated": false,
"ratio": 3.17368... |
__author__ = 'tilmannbruckhaus'
class NumberSpiralDiagonals:
"""
Number spiral diagonals
Problem 28
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 1... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p028_number_spiral_diagonals.py",
"copies": "1",
"size": "2213",
"license": "mit",
"hash": -8682052480057607000,
"line_mean": 27.7402597403,
"line_max": 117,
"alpha_frac": 0.5237234523,
"autogenerated": false,
"ratio":... |
__author__ = 'tilmannbruckhaus'
class Pandigital:
def __init__(self, digits):
self.p = digits
self.N = len(self.p)
def find(self, n):
for i in range(n - 1):
self.step()
return self.get()
def step(self):
# The algorithm is described in E. W. Dijkstra, A... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/lib/pandigital.py",
"copies": "1",
"size": "1190",
"license": "mit",
"hash": 669476225807984000,
"line_mean": 23.7916666667,
"line_max": 111,
"alpha_frac": 0.4571428571,
"autogenerated": false,
"ratio": 3.1481481481481484,
"config... |
__author__ = 'tilmannbruckhaus'
class SumSquareDifference:
# Sum square difference
# Problem 6
# 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 ... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p006_sum_square_difference.py",
"copies": "1",
"size": "1180",
"license": "mit",
"hash": -6924793132690020000,
"line_mean": 27.0952380952,
"line_max": 99,
"alpha_frac": 0.6016949153,
"autogenerated": false,
"ratio": 3.... |
__author__ = 'tilmannbruckhaus'
# Smallest multiple
# Problem 5
# 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
# What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
# Answer: 232792560
class SmallestMultiple:
... | {
"repo_name": "bruckhaus/challenges",
"path": "python_challenges/project_euler/p005_smallest_multiple.py",
"copies": "1",
"size": "1123",
"license": "mit",
"hash": -5405374038019572000,
"line_mean": 33.0303030303,
"line_max": 113,
"alpha_frac": 0.625111309,
"autogenerated": false,
"ratio": 3.8993... |
__author__ = 'timaeudg'
import pandas as pd
user_columns = ['id', 'gender', 'age', 'occupation', 'zip']
users = pd.read_table('users.dat', sep='::', header=None, names=user_columns)
ratings_columns = ['id', 'movie_id', 'rating', 'timestamp']
ratings = pd.read_table('ratings.dat', sep='::', header=None, names=ratings... | {
"repo_name": "timaeudg/CSSE490-DataMining",
"path": "In-ClassFirst/DataLoader.py",
"copies": "1",
"size": "1084",
"license": "bsd-2-clause",
"hash": -4505390997558083600,
"line_mean": 36.4137931034,
"line_max": 87,
"alpha_frac": 0.7066420664,
"autogenerated": false,
"ratio": 2.8906666666666667,
... |
"""A module for representing and fitting piecewise polynomial functions
with and without regularity constraints.
"""
import numpy as np
lna = np.linalg
poly1d = np.poly1d
import matplotlib.pyplot as plt
#Legendre = np.polynomial.legendre.Legendre
class Centered_Scaled_Polynomial:
"represents polynomials P(y) in... | {
"repo_name": "quidditymaster/piecewise_polynomial",
"path": "piecewise_polynomial.py",
"copies": "1",
"size": "17338",
"license": "apache-2.0",
"hash": -7519530306191680000,
"line_mean": 44.5065616798,
"line_max": 460,
"alpha_frac": 0.5876110278,
"autogenerated": false,
"ratio": 3.57927332782824... |
__author__ = 'TimeWz667'
__all__ = ['Event']
class Event:
NullEvent = None
def __init__(self, td, ti, msg=None):
"""
To do something at a certain time
:param td: a thing to do
:param ti: a certain time for the event
:param msg: message to report
"""
sel... | {
"repo_name": "TimeWz667/Kamanian",
"path": "complexism/element/event.py",
"copies": "1",
"size": "1050",
"license": "mit",
"hash": 4710518939338686000,
"line_mean": 20.875,
"line_max": 64,
"alpha_frac": 0.5342857143,
"autogenerated": false,
"ratio": 3.559322033898305,
"config_test": false,
"... |
__author__ = 'TimeWz667'
__all__ = ['Trigger', 'EventTrigger',
'AttributeTrigger', 'AttributeEnterTrigger', 'AttributeExitTrigger']
class Trigger:
NullTrigger = None
def check_event(self, ag, evt):
return False
def check_pre_change(self, ag):
return False
def check_post... | {
"repo_name": "TimeWz667/Kamanian",
"path": "complexism/agentbased/be/trigger.py",
"copies": "1",
"size": "2628",
"license": "mit",
"hash": -3169182131216931000,
"line_mean": 21.0840336134,
"line_max": 79,
"alpha_frac": 0.5547945205,
"autogenerated": false,
"ratio": 4.030674846625767,
"config_t... |
# could possibly add in threading and the ability to send actual data
import sys, getopt, httplib, urlparse #, urllib
#from threading import Thread as T
#from Queue import Queue as Q
def usage():
print "Usage: python testclient.py [--help] [--number number_of_terations] http://www.example.com"
def send_a_reques... | {
"repo_name": "timkang/CloudDatabases",
"path": "old/client/testclient.py",
"copies": "1",
"size": "1690",
"license": "mit",
"hash": 5133504775640467000,
"line_mean": 29.1785714286,
"line_max": 102,
"alpha_frac": 0.5834319527,
"autogenerated": false,
"ratio": 3.6739130434782608,
"config_test": ... |
__author__ = 'Tim Martin'
from unittest import skipUnless
from cqlengine.management import sync_table, drop_table
from cqlengine.tests.base import BaseCassEngTestCase
from cqlengine.tests.base import CASSANDRA_VERSION
from cqlengine.models import Model
from cqlengine.exceptions import LWTException
from uuid import uui... | {
"repo_name": "cqlengine/cqlengine",
"path": "cqlengine/tests/test_transaction.py",
"copies": "2",
"size": "3527",
"license": "bsd-3-clause",
"hash": 605201057596117400,
"line_mean": 34.27,
"line_max": 96,
"alpha_frac": 0.664303941,
"autogenerated": false,
"ratio": 3.6701352757544226,
"config_t... |
__author__ = 'timmattison'
import sys # For command-line argument processing
import os # For checking to see if a file exists
import urllib # For URL encoding POST parameters
import urllib2 # For creating URL openers
import cookielib # For cookie processing
# Public functions
def get_url_opener(coo... | {
"repo_name": "timmattison/pyuda",
"path": "pyuda/__init__.py",
"copies": "1",
"size": "7702",
"license": "unlicense",
"hash": -1463010043144732700,
"line_mean": 38.4974358974,
"line_max": 145,
"alpha_frac": 0.6672292911,
"autogenerated": false,
"ratio": 4.1565029681597405,
"config_test": false... |
__author__ = 'tim mcguire'
import datetime
import math
import Tkinter
import sys,os
def to_binary(dec, width):
x = width - 1
answer = ""
while x >= 0:
current_power = math.pow(2, x)
# how many powers of two fit into dec?
how_many = int(dec / current_power)
answer += str(how... | {
"repo_name": "mcgyver5/python_binary_clock",
"path": "binary_clock.py",
"copies": "1",
"size": "1763",
"license": "apache-2.0",
"hash": -5604078933119914000,
"line_mean": 23.1506849315,
"line_max": 106,
"alpha_frac": 0.5847986387,
"autogenerated": false,
"ratio": 3.1823104693140793,
"config_te... |
__author__ = 'timmer'
import csv
import os
from las import LASReader
import numpy as np
import glob
class LogUtilities:
"""
Class for generating text files of each LAS file (easier to use than LAS). Also used for generating a list
of all acronyms in the files.
"""
def __init__(self, prompt, las_... | {
"repo_name": "Eric-Timmer/Useful_PhD_scripts",
"path": "bakken_resistivity/bakken_rw.py",
"copies": "1",
"size": "11012",
"license": "mit",
"hash": -5642246975880765000,
"line_mean": 38.3285714286,
"line_max": 120,
"alpha_frac": 0.4566836179,
"autogenerated": false,
"ratio": 3.6572567253404187,
... |
__author__ = 'tim'
import powerapi
from getpass import getpass
import sys
ps = powerapi.core('https://stafford.powerschool.com')
#Print basic header information
print('pyPowerSchool')
print('A POWERSCHOOL COMMAND LINE APP WRITTEN IN PYTHON')
print('BY: TIMOTHY NOTO (n3tn0)')
print('VERSION: ALPHA')
print('\n\n')
#G... | {
"repo_name": "n3tn0/pyPS",
"path": "powerschool.py",
"copies": "1",
"size": "1388",
"license": "mit",
"hash": 2864211650416525300,
"line_mean": 23.350877193,
"line_max": 60,
"alpha_frac": 0.6527377522,
"autogenerated": false,
"ratio": 3.2735849056603774,
"config_test": false,
"has_no_keyword... |
__author__ = 'Timo Boldt'
import sys
import logging
class Logger:
def __init__(self, log_facility="info", log_file="/dev/null", log_print=True, log_syslog=False, app="ctrl"):
# loglevels we support
self.LOG_FACILITIES = {
'debug': logging.DEBUG,
'info': logging.INFO,
... | {
"repo_name": "vibe-x/robotic",
"path": "libraries/Logger.py",
"copies": "1",
"size": "1793",
"license": "apache-2.0",
"hash": -4686247046644725000,
"line_mean": 31.6,
"line_max": 112,
"alpha_frac": 0.5856107083,
"autogenerated": false,
"ratio": 3.8559139784946237,
"config_test": false,
"has_... |
__author__ = 'timo merlin zint'
import sys, getopt
import gtk
import Xlib.display
class Direction:
NONE = -1
UP = 0
RIGHT = 1
DOWN = 2
LEFT = 3
UP_RIGHT = 4
DOWN_RIGHT = 5
DOWN_LEFT = 6
UP_LEFT = 7
ALL = 8
def usage():
print "see -h or --help"
def help():
print "-a or... | {
"repo_name": "tmzint/pysnap",
"path": "pysnap.py",
"copies": "1",
"size": "5474",
"license": "mit",
"hash": 5229140727723310000,
"line_mean": 29.7528089888,
"line_max": 135,
"alpha_frac": 0.5915235659,
"autogenerated": false,
"ratio": 3.3035606517803258,
"config_test": false,
"has_no_keyword... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.