repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
mikiec84/wagtail-filepreviews
wagtaildocs_previews/models.py
<filename>wagtaildocs_previews/models.py from __future__ import unicode_literals from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from filepreviews import FilePreview...
mikiec84/wagtail-filepreviews
wagtaildocs_previews/tests/test_views.py
<reponame>mikiec84/wagtail-filepreviews import json from django.test import TestCase from django.urls import reverse from wagtaildocs_previews.models import PreviewableDocument class TestWebhookView(TestCase): def setUp(self): self.url = reverse('filepreviews_webhook') self.document = Previewabl...
mikiec84/wagtail-filepreviews
wagtaildocs_previews/endpoints.py
from wagtail.documents.api.v2 import endpoints from .serializers import DocumentSerializer class DocumentsAPIEndpoint(endpoints.DocumentsAPIEndpoint): base_serializer_class = DocumentSerializer body_fields = endpoints.DocumentsAPIEndpoint.body_fields + ['preview_data']
mikiec84/wagtail-filepreviews
wagtaildocs_previews/serializers.py
from rest_framework.serializers import JSONField from wagtail.documents.api.v2 import serializers class DocumentSerializer(serializers.DocumentSerializer): preview_data = JSONField(read_only=True)
mikiec84/wagtail-filepreviews
wagtaildocs_previews/tests/urls.py
<gh_stars>10-100 from __future__ import absolute_import, unicode_literals from django.conf.urls import include, url from wagtail.admin import urls as wagtailadmin_urls from wagtail.core import urls as wagtail_urls from wagtaildocs_previews import urls as wagtaildocs_urls urlpatterns = [ url(r'^admin/', include(...
FordyceLab/RunPack-STAMMP
runpack-stammp/valvecontrol.py
<reponame>FordyceLab/RunPack-STAMMP # title : valvecontrol.py # description : Valve control for RunPack experimental acquisition # authors : <NAME> # credits : <NAME> # date : 20180520 # version update : 20200913 # version : 0.1.1 # python_version : 2.7...
FordyceLab/RunPack-STAMMP
runpack-stammp/tfMITOMIProtocols.py
# title : tfMITOMIprotocols.py # description : tf-MITOMI-specific protocols for experimental acquisition notebook # authors : <NAME>, <NAME>, <NAME> # credits : <NAME> # date : 201711015 # version update : 20200913 # version : v0.1 # python_version : 2....
FordyceLab/RunPack-STAMMP
runpack-stammp/io.py
<reponame>FordyceLab/RunPack-STAMMP # title : io.py # description : Top-level classes for Jupyter-based experimental # MicroManager imaging & WAGO valve control # authors : <NAME> # date : 20180520 # version update : 20200913 # version : 0.1....
FordyceLab/RunPack-STAMMP
runpack-stammp/imagingcontrol.py
<gh_stars>0 # title : imagingcontrol.py # description : Imaging and stage control for RunPack experiments # authors : <NAME>, <NAME> # credits : # date : 20180520 # version update : 20200913 # version : 0.1.1 # usage : With permission from DM ...
FordyceLab/RunPack-STAMMP
runpack-stammp/mitomiprotocols.py
# description : STAMMP protocols for experimental acquisition # authors : <NAME>, <NAME> # date : 20180520 # version update : 20200913 # version : 0.1.1 # python_version : 2.7 import time from Queue import Queue import numpy as np from apscheduler.schedulers.background im...
FordyceLab/RunPack-STAMMP
runpack-stammp/assays.py
# title : assays.py # description : Standard MITOMI Concurrent Imaging # authors : <NAME> # credits : <NAME> # date : 20180520 # version update : 20200913 # version : 0.1.1 # python_version : 2.7 import time from Queue import Queue from runpack.io im...
worleydl/solr-spatial-viz
indexer/fetcher.py
<reponame>worleydl/solr-spatial-viz<filename>indexer/fetcher.py<gh_stars>1-10 import urllib baseUrl = "http://www.hmdb.org/gpx/kml.asp?State=%s" with open('states.txt') as f: content = f.readlines(); for state in content: state = state.strip(); kml = urllib.URLopener() print "Retreiving %s" % state ...
worleydl/solr-spatial-viz
indexer/ingester.py
<reponame>worleydl/solr-spatial-viz<gh_stars>1-10 import urllib2 import xml.etree.ElementTree as ET with open('states.txt') as f: states = f.readlines(); for state in states: state = state.strip() print state tree = ET.parse('data/%s.kml' % state) root = tree.getroot() invalidIds = [None, '...
jack04060201/data-compression-practice
DC.py
import cv2 as cv,numpy as np, copy, time #from sklearn.cluster import KMeans from matplotlib import pyplot as plt import code_t as cd ############### blocksize =[8,8] Q_m=np.float32( [[ [16,11,10,16,24,40,51,61], [12,12,14,19,26,58,60,55], [14,13,16,24,40,57,69,56], [14,17,22,29,...
jack04060201/data-compression-practice
code_t.py
<filename>code_t.py import numpy as np,math,struct z_count=0 #DC:127 \ 7 #AC:+-64 / bits EOB=8 cb={ '0':1, '10':2, '110':3, '1110':4, '11110':5, '111110':6, #BLOCK為8*8,連續0長度最多63 '1111110':7, #DC最高127 '11111110':EOB #EOB } temp='' test='101011010101110100001001' fin='' bks=[] frame=[] ct=0 mv=[] ...
jack04060201/data-compression-practice
decoder.py
import code_t as cd import DC,numpy as np import cv2 as cv size=[int(288/8),int(512/8),2] frame=np.zeros((288,512,2)) preframe=np.zeros((288,512,2)) p=[0,0] def decode_bks(s): global frame,p,size,preframe bks_count=0 b=cd.read_file(s) #print(b[:64]) c = cd.split(b) #print(len(c)...
safariragoli2/python-print
print.py
string = "hi" print(string)
drewkerrigan/basho_bench
priv/results-browser.py
#!/usr/bin/env python import http.server import socketserver import logging import cgi import base64 import argparse import os class ServerHandler(http.server.SimpleHTTPRequestHandler): def do_GET(self): logging.warning("======= GET STARTED =======") logging.warning(self.headers) http.server.Si...
mparisi20/pragma_processor
pragma.py
# pragma.py # By mparisi20 # github.com/mparisi20/pragma_processor # #pragma regswap usage: # #pragma regswap start end regA regB startFile # start: absolute address of start of affected region (hex) # end: absolute address of end of affected region (hex) # regA: register to swap (r0-r31 or f0-f31) # regB:...
Massendefekt/ZLUDA
zluda_dump/src/replay.py
<reponame>Massendefekt/ZLUDA<filename>zluda_dump/src/replay.py import pycuda.autoinit import pycuda.driver as drv import pycuda.tools as py_tools from pathlib import PurePath import numpy as np from os import path import os import itertools import sys # It's impossible to discern what is the type of a buff...
zhaoy17/pyweb
pyweb/routing/router.py
<reponame>zhaoy17/pyweb<filename>pyweb/routing/router.py from ..http import httpRequest class Router: def __init__(self, root_object): self.root_object = root_object self.has_arg = None def _find_object(self, object_location): curr = self.root_object for i in range(len(object_...
zhaoy17/pyweb
pyweb/http/header.py
<reponame>zhaoy17/pyweb """ This module consists of functions that are used to parse multipart and discrete MIME header. """ from abc import ABC, abstractmethod import json __all__ = [ "ContentType", "Header", "HTTPBody" ] class Header(ABC): @abstractmethod def to_str(self) -> str: pass ...
zhaoy17/pyweb
pyweb/http/_url.py
<filename>pyweb/http/_url.py """ This module provides utilities for parsing url string. Most of the implementation is based on Python's urllib module with some slight modification. The incoming url is processed as str, while the url consists in the outgoing url request will be processed using ASCII bytearray """ import...
zhaoy17/pyweb
pyweb/http/httpRequest.py
<filename>pyweb/http/httpRequest.py from ._url import parse_query_string, parse_host, parse_path_info, decode from .header import ContentType, HTTPBody class BaseRequest: def __init__(self, environ): self._env = environ self._method = environ["REQUEST_METHOD"] try: self._pathin...
Niobiumkey/amazon-sagemaker-build-train-deploy
02_data_exploration_and_feature_eng/source_dir/preprocessor.py
import argparse import os import warnings import subprocess subprocess.call(['pip', 'install', 'sagemaker-experiments']) import pandas as pd import numpy as np import tarfile from smexperiments.tracker import Tracker from sklearn.externals import joblib from sklearn.model_selection import train_test_split from skle...
Niobiumkey/amazon-sagemaker-build-train-deploy
04_deploy_model/sklearn_source_dir/inference.py
from __future__ import print_function import sys from io import StringIO import os import csv import json import numpy as np import pandas as pd from sklearn.externals import joblib from sagemaker_containers.beta.framework import ( content_types, encoders, env, modules, transformer, worker) feature_columns_name...
Niobiumkey/amazon-sagemaker-build-train-deploy
08_projects/modelbuild/pipelines/endtoendmlsm/workflow.py
import os import time import boto3 import sagemaker from sagemaker.processing import ProcessingInput, ProcessingOutput from sagemaker.sklearn.processing import SKLearnProcessor from sagemaker.sklearn import SKLearnModel from sagemaker.inputs import TrainingInput from sagemaker.xgboost import XGBoost from sagemaker.xgb...
zaiweizhang/votenet
s3dis/model_util_s3dis.py
<gh_stars>1-10 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import sys import os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(BASE_DIR) ROOT_D...
zaiweizhang/votenet
models/ap_helper.py
<filename>models/ap_helper.py<gh_stars>1-10 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Helper functions and class to calculate Average Precisions for 3D object detection. """ impor...
zaiweizhang/votenet
s3dis/process_data.py
import numpy as np import os import sys sys.path.append('../utils') from pc_util import * from multiprocessing import Pool data_path = 'Path/to/Stanford3dDataset_v1.2_Aligned_Version' out_path = 'Path/to/output_dir' if not os.path.exists(out_path): os.makedirs(out_path) area_names = ['Area_1', 'Area_2', 'Are...
zaiweizhang/votenet
mp3d/process_matterport.py
import numpy as np import os from plyfile import PlyData, PlyElement import json import sys import csv from matplotlib import cm def read_mesh_vertices_rgb(filename): """ read XYZ RGB for each vertex. Note: RGB values are in 0-255 """ assert os.path.isfile(filename) with open(filename, 'rb') as f: ...
netlabcode/demo-2021
goose_attack.py
from scapy.all import * import os import binascii #targeting folder and file pcap THIS_FOLDER = os.path.dirname(os.path.abspath(__file__)) my_file = os.path.join(THIS_FOLDER, '9bus_trip.pcap') #MAC Address references #source = {'siemens1': "b4:b1:5a:05:30:6d",'siemens2':"b4:b1:5a:05:30:61",'alstom':"80:b3:2...
Zinnion/conan-libevent
build.py
<reponame>Zinnion/conan-libevent #!/usr/bin/env python # -*- coding: utf-8 -*- from bincrafters import build_template_default import platform if __name__ == "__main__": builder = build_template_default.get_builder(pure_c=True) if platform.system() == "Windows": for settings, options, env_vars, build_re...
Zinnion/conan-libevent
conanfile.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import shutil from conans import ConanFile, AutoToolsBuildEnvironment, RunEnvironment, tools from conans.errors import ConanInvalidConfiguration class LibeventConan(ConanFile): name = "libevent" version = "2.1.9" description = "libevent - an event n...
zhl017/omiyage
Documents/cancel_goal.py
<filename>Documents/cancel_goal.py<gh_stars>0 #!/usr/bin/env python import rospy from std_msgs.msg import String from actionlib_msgs.msg import GoalID class cancel_goal(): def __init__(self): self.is_cancel = False self.goal = GoalID() self.sub_yolo = rospy.Subscriber('/yolov...
zhl017/omiyage
Documents/turtlebot3_manipulator_demo.py
#!/usr/bin/env python3 import sys import rospy import moveit_commander class manipulator(): def __init__(self): moveit_commander.roscpp_initialize(sys.argv) self.group = moveit_commander.MoveGroupCommander("arm") self.group1 = moveit_commander.MoveGroupCommander("grip...
misantroop/jsonpickle
tests/stdlib_test.py
<reponame>misantroop/jsonpickle # -*- coding: utf-8 -*- """Test miscellaneous objects from the standard library""" import uuid import unittest import jsonpickle class UUIDTestCase(unittest.TestCase): def test_random_uuid(self): u = uuid.uuid4() encoded = jsonpickle.encode(u) decoded = j...
misantroop/jsonpickle
tests/helper.py
import unittest class SkippableTest(unittest.TestCase): def skip(self, msg): if hasattr(self, 'skipTest'): return self.skipTest(msg) return None
misantroop/jsonpickle
tests/datetime_test.py
# -*- coding: utf-8 -*- # # Copyright (C) 2013 <NAME> <<EMAIL>> # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. import unittest import datetime import time import jsonpickle from jsonpickle import tags class ObjWit...
kagarlickij/azuredevops-security-automation
onprem/create_group.py
<reponame>kagarlickij/azuredevops-security-automation """ This script creates group in projct via TFSSecurity cmd """ import subprocess import argparse PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectId", type=str, required=True) PARSER....
kagarlickij/azuredevops-security-automation
common/set_permissions.py
""" This script sets ACL """ import json import argparse import sys import os import time import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--namespaceId", type=str, required=True) PARSER.add_argument("--projectId", type=str, requir...
kagarlickij/azuredevops-security-automation
common/generate_pylint_badge.py
""" This script generates pylint badge that is used in README.md """ import subprocess import sys import json import argparse import os import requests import anybadge PARSER = argparse.ArgumentParser() PARSER.add_argument("--gistId", type=str, required=True) PARSER.add_argument("--gitHubPat", type=str, required=Tru...
kagarlickij/azuredevops-security-automation
cloud/export_project_info.py
""" This script gets and exports Project ID and projectScopeDescriptor of the Azure DevOps project """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectName", type=str, required=True)...
kagarlickij/azuredevops-security-automation
common/create_feed.py
""" This script creates new Artifact feed """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectName", type=str) PARSER.add_argument("--feedName", type=str, required=True) PARSER.add_a...
kagarlickij/azuredevops-security-automation
common/set_feed_permissions.py
<filename>common/set_feed_permissions.py """ This script sets ACL for Artifact feed """ import json import argparse import sys import os import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--feedId", type=str, required=True) PARSER.ad...
kagarlickij/azuredevops-security-automation
onprem/get_group_members.py
<filename>onprem/get_group_members.py """ This script gets current quantity of group members and compares it with desired """ import subprocess import argparse import sys PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectName", type=str, r...
kagarlickij/azuredevops-security-automation
common/create_tmp_release_pipeline.py
""" This script creates temporary Release pipeline """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectName", type=str, required=True) PARSER.add_argument("--pat", type=str, required...
kagarlickij/azuredevops-security-automation
common/delete_tmp_release_pipeline.py
<reponame>kagarlickij/azuredevops-security-automation """ This script deletes temporary Release pipeline """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectName", type=str, required...
kagarlickij/azuredevops-security-automation
onprem/get_groups.py
<gh_stars>1-10 """ This script gets list of current groups and compares it with list of desired groups """ import subprocess import argparse import sys PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectId", type=str, required=True) PARSER....
kagarlickij/azuredevops-security-automation
onprem/delete_group.py
<reponame>kagarlickij/azuredevops-security-automation<gh_stars>1-10 """ This script deletes group in projct via TFSSecurity cmd """ import subprocess import argparse PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectName", type=str, requir...
kagarlickij/azuredevops-security-automation
cloud/get_groups.py
<reponame>kagarlickij/azuredevops-security-automation<filename>cloud/get_groups.py """ This script gets list of current groups and compares it with list of desired groups """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, requ...
kagarlickij/azuredevops-security-automation
common/check_feed_permissions.py
<gh_stars>1-10 """ This script gets current ACL of the Artifact feed and compares it with desired """ import json import argparse import sys import os import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--feedId", type=str, required=T...
kagarlickij/azuredevops-security-automation
common/create_project.py
""" This script creates new Azure DevOps project """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectName", type=str, required=True) PARSER.add_argument("--projectDescription", type=...
kagarlickij/azuredevops-security-automation
common/set_git_policy.py
<filename>common/set_git_policy.py """ This script sets cross-repo Git policy """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectName", type=str, required=True) PARSER.add_argument(...
kagarlickij/azuredevops-security-automation
cloud/create_group.py
<gh_stars>1-10 """ This script creates group in projct via Azure DevOps API """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectScopeDescriptor", type=str, required=True) PARSER.add_...
kagarlickij/azuredevops-security-automation
cloud/export_group_info.py
""" This script gets and exports SID of the Azure DevOps group """ import json import argparse import sys import base64 import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectScopeDescriptor", type=str, required=True) PARSER.add...
kagarlickij/azuredevops-security-automation
cloud/delete_group.py
<gh_stars>1-10 """ This script deletes group in projct via Azure DevOps API """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectScopeDescriptor", type=str, required=True) PARSER.add_...
kagarlickij/azuredevops-security-automation
common/export_feed_info.py
<filename>common/export_feed_info.py<gh_stars>1-10 """ This script exports Feed ID """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--feedName", type=str, required=True) PARSER.add_argumen...
kagarlickij/azuredevops-security-automation
common/check_git_policy.py
""" This script checks if all git repos in project follow best practices """ import json import argparse import sys from datetime import date from datetime import datetime import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectN...
kagarlickij/azuredevops-security-automation
cloud/get_group_members.py
<filename>cloud/get_group_members.py """ This script gets current quantity of group members and compares it with desired """ import json import argparse import sys import requests PARSER = argparse.ArgumentParser() PARSER.add_argument("--organization", type=str, required=True) PARSER.add_argument("--projectScopeDesc...
yabhinav/FeedNotifier
updater.py
import wx import os import time import urllib import tempfile import util from settings import settings class CancelException(Exception): pass class DownloadDialog(wx.Dialog): def __init__(self, parent): super(DownloadDialog, self).__init__(parent, -1, 'Feed Notifier Update') ...
yabhinav/FeedNotifier
popups.py
import wx import webbrowser from settings import settings BLANK = 'about:blank' COMMAND_CLOSE = 'http://close/' COMMAND_NEXT = 'http://next/' COMMAND_PREVIOUS = 'http://previous/' COMMAND_FIRST = 'http://first/' COMMAND_LAST = 'http://last/' COMMAND_PLAY = 'http://play/' COMMAND_PAUSE = 'http://pause/' d...
yabhinav/FeedNotifier
controller.py
import wx import idle import feeds import popups import view import updater import util import winsound import socket from settings import settings class Controller(object): def __init__(self): socket.setdefaulttimeout(settings.SOCKET_TIMEOUT) self.icon = view.TaskBarIcon(self) ...
yabhinav/FeedNotifier
defaults.py
# Helper Functions def load_revision(): try: with open('revision.txt', 'r') as file: return int(file.read().strip()) except Exception: return -1 # Popup Settings POPUP_DURATION = 5 POPUP_AUTO_PLAY = True POPUP_WAIT_ON_HOVER = True POPUP_THEME = 'default' POPUP_W...
yabhinav/FeedNotifier
view.py
<gh_stars>1-10 import wx import util import feeds import filters from settings import settings INDEX_ENABLED = 0 INDEX_URL = 1 INDEX_TITLE = 2 INDEX_INTERVAL = 3 INDEX_ITEM_COUNT = 4 INDEX_CLICKS = 5 INDEX_RULES = 1 INDEX_FEEDS = 2 INDEX_IN = 3 INDEX_OUT = 4 class TaskBarIcon(wx.TaskBarIcon): ...
yabhinav/FeedNotifier
filters.py
<filename>filters.py # Keyword Filter Parser EXCLUDE = 0 INCLUDE = 1 ALL = 0xf TITLE = 1 LINK = 2 AUTHOR = 4 CONTENT = 8 TYPES = { None: INCLUDE, '+': INCLUDE, '-': EXCLUDE, } QUALIFIERS = { None: ALL, 'title:': TITLE, 'link:': LINK, 'author:': AUTHOR, 'content:...
yabhinav/FeedNotifier
parsetab.py
# parsetab.py # This file is automatically generated. Do not edit. _tabversion = '3.2' _lr_method = 'LALR' _lr_signature = '\x03\xd8\xc9Q1\x0e\x13W\xf5\xf7\xacu\x8b$z\xd4' _lr_action_items = {'AND':([2,8,16,17,20,21,22,23,],[-2,18,18,-5,-7,-6,-3,18,]),'WORD':([0,1,3,5,6,7,9,10,11,12,13,14,15,18,19,],[-...
yabhinav/FeedNotifier
idle.py
import sys if sys.platform == 'win32': from ctypes import * class LASTINPUTINFO(Structure): _fields_ = [ ('cbSize', c_uint), ('dwTime', c_int), ] def get_idle_duration(): lastInputInfo = LASTINPUTINFO() lastInputInfo.cbSize ...
yabhinav/FeedNotifier
dummy.py
<reponame>yabhinav/FeedNotifier # used for dummy.__file__ to setup path
ankurCES/bai-file-processor
bai_file_processor/constants.py
from collections import namedtuple from enum import Enum CONTINUATION_CODE = '88' class RecordCode(Enum): file_header = '01' group_header = '02' account_identifier = '03' transaction_detail = '16' account_trailer = '49' continuation = '88' group_trailer = '98' file_trailer = '99' cl...
everydaytimmy/data-structures-and-algorithms
python/tests/test_fizzbuzz_tree.py
<filename>python/tests/test_fizzbuzz_tree.py<gh_stars>0 from code_challenges.fizzbuzz_tree.fizzbuzz_tree import Ktree, Node, fizz_buzz # def test_node_has_value(): # node = Node("apple") # assert node.value == "apple" # def test_create_k_tree(): # tree = KTree() # assert tree # def test_fizz_buzz():...
everydaytimmy/data-structures-and-algorithms
python/tests/test_business_trip.py
from code_challenges.graph_business_trip.graph_business_trip import business_trip from code_challenges.graph.graph import Graph, Vertex def test_business_one(): graph = Graph('bidirectional') boston = graph.add_node('Boston') seattle = graph.add_node('Seattl') la = graph.add_node('LA') sf = graph.a...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/hashtable/hashtable.py
from code_challenges.linked_list.linked_list import LinkedList, Node class Hashtable: def __init__(self, size=1024): self.size = size self._bucket = [None] * size def add(self, key, value): index = self.hash(key) if not self._bucket[index]: self._bucket[index] = Lin...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/breadth_first/breadth_first.py
<reponame>everydaytimmy/data-structures-and-algorithms<filename>python/code_challenges/breadth_first/breadth_first.py<gh_stars>0 class Node: def __init__(self, value): self.value = value self.left = None self.right = None class BinaryTree: def __init__(self): self.root = None ...
everydaytimmy/data-structures-and-algorithms
python/tests/test_quick_sort.py
from code_challenges.quick_sort.quick_sort import partition, quick_sort def test_quick(): assert quick_sort def test_quick_sort(): array = [ 10, 7, 8, 9, 1, 5 ] actual = quick_sort(0, len(array) - 1, array) expected = [1,5,7,8,9,10] assert actual == expected def test_quick1(): array = [8,4,2...
everydaytimmy/data-structures-and-algorithms
python/tests/test_multi-bracket-validation.py
<gh_stars>0 from code_challenges.multi_bracket_validation.multi_bracket_validation import (multi_bracket_validation) def test_one(): string = "{}{Code}[Fellows](())" actual = multi_bracket_validation(string) expected = True assert actual == expected def test_two(): string = "{{}}}}" actual = multi_b...
everydaytimmy/data-structures-and-algorithms
python/tests/test_hashtable.py
from code_challenges.hashtable.hashtable import Hashtable def text_exists() : assert Hashtable def test_add(): ht = Hashtable() actual = ht.add('rum ham', 11) expected = None assert actual == expected def test_get_value(): ht = Hashtable() ht.add('rum ham', 6) actual = ht.get('rum h...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/merge_sort/merge_sort.py
def merge_sort(list): n = len(list) if n <= 1: return list if n > 1: mid = n//2 left = list[0:mid] right = list[mid:n] merge_sort(left) merge_sort(right) return merge(left,right,list) def merge(left, right, list): i = 0 j = 0 k = 0 w...
everydaytimmy/data-structures-and-algorithms
python/tests/test_breadth_first_graph.py
<filename>python/tests/test_breadth_first_graph.py<gh_stars>0 from code_challenges.depth_first_graph.depth_first_graph import depth_traversal, Stack, Node from code_challenges.graph.graph import Graph, Vertex def test_depth_traversal_exists(): assert depth_traversal def test_depth_traversal_one(): graph = Gr...
everydaytimmy/data-structures-and-algorithms
python/tests/test_hashmap_left_join.py
<reponame>everydaytimmy/data-structures-and-algorithms<gh_stars>0 from code_challenges.hashmap_left_join.hashmap_left_join import hashmap_left_join from code_challenges.hashtable.hashtable import Hashtable def test_exists(): assert hashmap_left_join def test_left_join(): ht1 = Hashtable() ht2 = Hashtable(...
everydaytimmy/data-structures-and-algorithms
python/tests/test_hash_repeat.py
<gh_stars>0 from code_challenges.hashmap_repeated.hashmap_repeated import word_repeat from code_challenges.hashtable.hashtable import Hashtable def test_word_repeat(): assert word_repeat def test_string(): actual = word_repeat("Once upon a time, there was a brave princess who...") expected = 'a' asser...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/queueWithStacks/queueWithStacks.py
class Stack: def __init__(self): self.top = None def push(self, value): self.top = Node (value, self.top) def pop(self): value = self.top.value self.top = self.top.next return value def enqueue(self, value): self.top = Node (value, self.top) def de...
everydaytimmy/data-structures-and-algorithms
python/tests/test_linked_list.py
<reponame>everydaytimmy/data-structures-and-algorithms from code_challenges.linked_list.linked_list import LinkedList, Node def test_import(): assert LinkedList def test_insert(): list = LinkedList(Node("Buddy")) assert list.head.data == "Buddy" list.insert('Guy') list.insert('Friend') assert...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/stacks_and_queues/stacks_and_queues.py
<gh_stars>0 from code_challenges.stacks_and_queues.invalid_error import InvalidOperationError class Stack: def __init__(self): self.top = None def push(self, value): self.top = Node (value, self.top) def pop(self): if not self.top: raise InvalidOperationError("Method ...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/graph/graph.py
<reponame>everydaytimmy/data-structures-and-algorithms class Vertex: def __init__(self, value): self.value = value class Graph: def __init__(self, kind='single direction'): self.adjacency_list = {} self.type= kind def add_node(self, value): vertex = Vertex(value) if...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/hashmap_left_join/hashmap_left_join.py
<reponame>everydaytimmy/data-structures-and-algorithms from code_challenges.hashtable.hashtable import Hashtable def hashmap_left_join(ht1, ht2): answer = [] for bucket in ht1._bucket: if bucket: current = bucket.head while current: current_key = current.data[0]...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/linked_list/linked_list.py
<filename>python/code_challenges/linked_list/linked_list.py class LinkedList: def __init__(self, head=None): self.head = head def __iter__(self): def value_generator(): current = self.head while current: yield current.value current...
everydaytimmy/data-structures-and-algorithms
python/tests/test_tree.py
<filename>python/tests/test_tree.py import pytest from code_challenges.tree.tree import Node, BinaryTree, BinarySearchTree def test_node_has_value(): node = Node("apple") assert node.value == "apple" def test_node_has_left_of_none(): node = Node("apple") assert node.left is None def test_node_has_...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/multi_bracket_validation/multi_bracket_validation.py
<gh_stars>0 def multi_bracket_validation(input): curly = 0 square = 0 parens = 0 lst1=[] lst1[:0]=input for i in lst1: if i == "{": curly += 1 if i == "}": curly -= 1 if curly < 0: return False if i == "[": square += 1 if i == "]": square -= 1 if...
everydaytimmy/data-structures-and-algorithms
python/tests/test_insertion_sort.py
<filename>python/tests/test_insertion_sort.py from code_challenges.insertion_sort.insertion_sort import insertion_sort def test_insertion_sort_one(): list = [1,6,3,8,66,23,] actual = [1,3,6,8,23,66] expected = insertion_sort(list) assert actual == expected def test_insertion_sorting1(): actual = i...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/fifo_animal_shelter/fifo_animal_shelter.py
<reponame>everydaytimmy/data-structures-and-algorithms<filename>python/code_challenges/fifo_animal_shelter/fifo_animal_shelter.py from collections import deque class Queue(deque): def enqueue(self, value): self.append(value) def dequeue(self): return self.popleft() def is_empty(self): ...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/fizzbuzz_tree/fizzbuzz_tree.py
class Node: def __init__(self, value): self.value = value self.children = [] class Ktree(): def __init__(self): self.root = None @staticmethod def breadth(tree = None): list = [] queue = Queue() queue.enqueue(tree.root) if not tree: ...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/hashmap_tree_intersection/hashmap_tree_intersection.py
from code_challenges.tree.tree import BinarySearchTree def tree_intersection(tree1, tree2): list1 = BinarySearchTree.pre_order(tree1) answer_key = [] for i in list1: if tree2.contains(i): answer_key.append(i) return answer_key
everydaytimmy/data-structures-and-algorithms
python/tests/test_queue_stack.py
from code_challenges.queueWithStacks.queueWithStacks import Stack, Node def test_is_stack(): assert Stack() def test_pop(): stack = Stack() stack.enqueue('Dwight') stack.enqueue('Michael') stack.enqueue('Pam') stack.enqueue('Jim') stack.enqueue('Andy') stack.dequeue() actual = stac...
everydaytimmy/data-structures-and-algorithms
python/tests/test_graphs.py
from code_challenges.graph.graph import Graph, Vertex def test_add_node(): graph = Graph() expected_value = 'noodle' actual = graph.add_node('noodle') assert actual.value == expected_value def test_get_nodes(): graph = Graph() graph.add_node("pizza") actual = graph.get_nodes() expe...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/graph_business_trip/graph_business_trip.py
from code_challenges.graph.graph import Graph, Vertex def business_trip(graph, arr_cities): if not graph.adjacency_list: return False, 0 cost = 0 for i,city in enumerate(arr_cities): neighbors = graph.get_neighbors(city) if i+1 >=len(arr_cities): return True, cost if arr_cities[i+1] in ne...
everydaytimmy/data-structures-and-algorithms
python/tests/test_max_binary_tree.py
from code_challenges.find_maximum_binary_tree.find_maximum_binary_tree import Node, BinaryTree, BinarySearchTree def test_node_has_value(): node = Node("apple") assert node.value == "apple" def test_create_binary_tree(): tree = BinaryTree() assert tree def test_max_value(): tree = BinarySearchTre...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/tree/tree.py
class Node: def __init__(self, value): self.value = value self.left = None self.right = None class BinaryTree: def __init__(self): self.root = None class BinarySearchTree(BinaryTree): def add(self, value): node = Node(value) def walk(root, new_node): ...
everydaytimmy/data-structures-and-algorithms
python/tests/test_stacks_queues.py
<reponame>everydaytimmy/data-structures-and-algorithms import pytest from code_challenges.stacks_and_queues.stacks_and_queues import Stack, Queue, Node from code_challenges.stacks_and_queues.invalid_error import InvalidOperationError def test_is_stack(): assert Stack() def test_push(): stack = Stack() st...
everydaytimmy/data-structures-and-algorithms
python/code_challenges/hashmap_repeated/hashmap_repeated.py
from code_challenges.hashtable.hashtable import Hashtable def word_repeat(string): words = string.replace(',', '').replace('.', '').split(" ") ht = Hashtable() for word in words: word = word.lower() if ht.contains(word): return word else: ht.add(word, word)