repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
sprenge/energywizard | degreeday/apps.py | <gh_stars>0
from django.apps import AppConfig
class DegreedayConfig(AppConfig):
name = 'degreeday'
|
sprenge/energywizard | degreeday/migrations/0001_initial.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-11-27 17:09
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.Creat... |
sprenge/energywizard | meter/urls.py | from django.conf.urls import url
from . import views
urlpatterns = [
url(
r'^save_meter$',
views.save_meter,
name='save_meter'),
url(
r'^get_meter_types$',
views.get_meter_types,
name='get_meter_types'),
url(
r'^get_meter_readings$',
... |
sprenge/energywizard | degreeday/models.py | <filename>degreeday/models.py
from django.db import models
class DegreedaySource(models.Model):
name = models.CharField('name source degree day', max_length=512, unique=True)
api_key = models.CharField('api key', max_length=512, blank=True)
api_secret = models.CharField('api key', max_length=512, blank=Tr... |
sprenge/energywizard | household/migrations/0002_auto_20161127_1809.py | <filename>household/migrations/0002_auto_20161127_1809.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-11-27 17:09
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependenc... |
sprenge/energywizard | household/urls.py | from django.conf.urls import url
from . import views
urlpatterns = [
url(
r'^getall$',
views.get_all_households,
name='get_all_households'),
url(
r'^save_household_user$',
views.save_household_user,
name='save_household_user'),
]
|
sprenge/energywizard | energywizard/urls.py | """energywizard URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Clas... |
sprenge/energywizard | meter/models.py | <gh_stars>0
from django.db import models
from household.models import Household
from django.contrib.auth.models import User, Group
class EnergieType(models.Model):
name = models.CharField("energie type", max_length=256, help_text="e.g. Gas, Water", unique=True)
e_unit = models.CharField("energy unit", max_len... |
sprenge/energywizard | main/urls.py | from django.conf.urls import url
from . import views
urlpatterns = [
url(
r'^$',
views.homepage,
name='homepage'),
]
|
sprenge/energywizard | household/views.py | <reponame>sprenge/energywizard<filename>household/views.py
import json
from django.shortcuts import render
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.http import JsonResponse... |
sprenge/energywizard | meter/admin.py | <reponame>sprenge/energywizard
from django.contrib import admin
from import_export import resources
from .models import EnergieType
from .models import MeterType
from .models import MeterReading
from import_export.admin import ImportExportModelAdmin
class ReadingResource(resources.ModelResource):
class Meta:
... |
sprenge/energywizard | household/admin.py | from django.contrib import admin
from .models import Household
from .models import MetertypeHousehold
from .models import UserHousehold
admin.site.register(Household)
admin.site.register(MetertypeHousehold)
admin.site.register(UserHousehold)
|
sprenge/energywizard | household/migrations/0001_initial.py | <filename>household/migrations/0001_initial.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-11-27 17:09
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django_countries.fields
class Migration(migr... |
sprenge/energywizard | meter/views.py | import json
import datetime
import time
from django.shortcuts import render
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import JsonResponse
from django.contrib.auth.models import User, Group
from household.models import MetertypeHousehold
from meter.models... |
sprenge/energywizard | household/models.py | from django.db import models
from django.contrib.auth.models import User, Group
from django_countries.fields import CountryField
from degreeday.models import DegreedaySource
class Household(models.Model):
name = models.CharField('name household', max_length=128, blank=True)
nbr_members = models.IntegerField("... |
sprenge/energywizard | graphs/views.py | import time
from django.shortcuts import render
from django.http import JsonResponse
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.template import RequestContext
from household.models import Household
from meter.models import MeterType
from meter.models import ... |
sprenge/energywizard | main/views.py | <filename>main/views.py
from django.shortcuts import render
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.http import JsonResponse
from django.template import RequestContext
fro... |
sprenge/energywizard | main/management/commands/import_graaddagen_archive.py | from django.core.management.base import BaseCommand, CommandError
import requests
import pandas
import datetime
from degreeday.models import DegreedaySource
from degreeday.models import Degreeday
ilist = [
'http://www.aardgas.be/sites/default/files/sites/default/files/imce/DJE01new-1.xls',
]
class C... |
sprenge/energywizard | degreeday/admin.py | <reponame>sprenge/energywizard
from django.contrib import admin
from .models import DegreedaySource
from .models import Degreeday
class DegreedayAdmin(admin.ModelAdmin):
list_display = ['source', 'date_day', 'value']
admin.site.register(DegreedaySource)
admin.site.register(Degreeday, DegreedayAdmin)
|
sprenge/energywizard | main/management/commands/import_graaddagen_dagelijks.py | <gh_stars>0
import datetime
from django.core.management.base import BaseCommand, CommandError
import requests
import pandas
from lxml import html
from degreeday.models import DegreedaySource
from degreeday.models import Degreeday
base_link = "http://www.aardgas.be"
class Command(BaseCommand):
help = 'Import dag... |
sprenge/energywizard | meter/migrations/0001_initial.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-11-27 17:09
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migration... |
tolbot/trail | trail/trail.py | # -*- coding: utf-8 -*-
"""trail.trail: provides entry point main()."""
import sys # for proper exit.
import os # for OS path checking.
import datetime
import calendar
__version__ = "0.1.0"
py3 = sys.version_info[0] > 2 # creates boolean value for test that Python major version > 2
global_flag_used = F... |
tolbot/trail | trail/__init__.py | # This file makes the "trail" directory a package. |
tolbot/trail | trail-runner.py | <filename>trail-runner.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# could probably work with Python2.x but never tested ...
"""Convenience wrapper, for running trail.py (package form), directly from source tree.
Example usage:
./trail-runner enter some text here ... # Save new trail, in current directo... |
tolbot/trail | setup.py | # -*- coding: utf-8 -*-
"""setup.py: setuptools control."""
import re
from setuptools import setup
import os
version = re.search(
'^__version__\s*=\s*"(.*)"',
open('trail/trail.py').read(),
re.M
).group(1)
print("Got version: {}".format(version))
with open("README.md", "rb") as f:
long_descr = f.r... |
uehara1414/django-spa-template | {{cookiecutter.project_name}}/{{cookiecutter.app_name}}/apps.py | from django.apps import AppConfig
class AppNameConfig(AppConfig):
name = '{{cookiecutter.app_name}}'
|
uehara1414/django-spa-template | rename.py | <reponame>uehara1414/django-spa-template
import os
RENAME_PATTERNS = [
('__project_name__', '{{cookiecutter.project_name}}'),
('__app_name__', '{{cookiecutter.app_name}}'),
]
IGNORE_FILES = ['rename.py', 'README.md']
IGNORE_DIRS = ['.git']
def replace(text):
output = text
for pattern in RENAME_PATTE... |
UMCUGenetics/mips | mips_log_table.py | #!/usr/bin/env python
from __future__ import print_function
import sys
import os
if __name__ == "__main__":
# Parse arguments
if len(sys.argv) != 2:
print("python mips_log_table.py /path/to/log/files_dir")
sys.exit()
log_dir = os.path.abspath(sys.argv[1])
mips_data = {}
samples... |
UMCUGenetics/mips | mips_trim_dedup.py | <gh_stars>1-10
#!/usr/bin/env python
import sys
import re
import argparse
from itertools import izip_longest, izip
import gzip
import contextlib
def reverse_complement(seq):
"""Return reverse complement of a dna sequence."""
bases_dict = {
'A': 'T', 'a': 't',
'C': 'G', 'g': 'c',
'G':... |
UMCUGenetics/mips | qsub_mips_trim_dedup.py | #!/usr/bin/env python
import sys
import os
import fnmatch
import subprocess
def find_fastq(fastq_pattern, raw_data_dir):
for file in os.listdir(raw_data_dir):
if fnmatch.fnmatch(file, fastq_pattern):
return os.path.abspath('{0}/{1}'.format(raw_data_dir, file))
if __name__ == "__main__":
... |
UMCUGenetics/mips | mips_uuid_table.py | #!/usr/bin/env python
from __future__ import print_function
import sys
import os
if __name__ == "__main__":
# Parse arguments
if len(sys.argv) != 2:
print("python mips_uuid_table.py /path/to/log/files_dir")
sys.exit()
log_dir = os.path.abspath(sys.argv[1])
uuid_data = {}
# Ope... |
UMCUGenetics/mips | qsub_sample_dirs_mips_trim_dedup.py | #!/usr/bin/env python
import sys
import os
import subprocess
import glob
if __name__ == "__main__":
# Parse arguments
if len(sys.argv) != 6:
print "python qsub_sample_dirs_mips_trim_dedup.py /path/to/design.txt uuid_length uuid_read(R1,R2) /path/to/raw_data/sequencer/run/Unaligned/project /path/to/ou... |
yosemiteyss/lru_cache | 20514332.py | <filename>20514332.py<gh_stars>0
import sys
import time
OUTPUT_FILE = '20514332-output.txt'
# Query
QUERY_CHECK = 'Check'
QUERY_ADD = 'Add'
QUERY_DELETE = 'Delete'
class Cache:
def __init__(self, size):
self.size = size
self.queue = []
def __reorder_queue(self):
self.queue = sorted(s... |
yosemiteyss/lru_cache | cache_test.py | import unittest
import time
from cache import Cache
from cache_entry import CacheEntry
class CacheTest(unittest.TestCase):
def test_is_full(self):
cache = Cache(2)
cache.add(CacheEntry('A'))
self.assertFalse(cache.is_full())
cache.add(CacheEntry('B'))
self.assertTrue(cach... |
yosemiteyss/lru_cache | cache_entry.py | import time
class CacheEntry:
def __init__(self, data):
self.data = data
self.accessed_at = time.time() |
yosemiteyss/lru_cache | lru.py | <reponame>yosemiteyss/lru_cache
import sys
import time
from cache import Cache
from cache_entry import CacheEntry
OUTPUT_FILE = '20514332-output.txt'
# Query
QUERY_CHECK = 'Check'
QUERY_ADD = 'Add'
QUERY_DELETE = 'Delete'
# Caches
l1_cache = Cache(8)
l2_cache = Cache(16)
l3_cache = Cache(32)
storage = []
def cache_... |
yosemiteyss/lru_cache | cache.py | <reponame>yosemiteyss/lru_cache
import time
from cache_entry import CacheEntry
class Cache:
def __init__(self, size):
self.size = size
self.queue = []
def __reorder_queue(self):
self.queue = sorted(self.queue, key=lambda entry: entry.accessed_at, reverse=True)
def is_full(self):
... |
robbierobinette/rcv-tensorflow | DistrictData.py | import csv
from typing import List
from CombinedPopulation import CombinedPopulation
from PopulationGroup import PopulationGroup, Democrats, Republicans, Independents
class DistrictVotingRecord:
def __init__(self,
district: str,
incumbent: str,
expected_lean: flo... |
robbierobinette/rcv-tensorflow | HeadToHeadElection.py | from typing import List, Set, Tuple
import numpy as np
from Candidate import Candidate
from Election import Election, BallotIter
from ElectionResult import ElectionResult
class HeadToHeadResult(ElectionResult):
def __init__(self, oc, rm):
super().__init__(oc)
self.rm = rm
# def __init__(self... |
robbierobinette/rcv-tensorflow | DefaultConfigOptions.py | <filename>DefaultConfigOptions.py
from PopulationGroup import *
from CombinedPopulation import *
unit_election_config = ElectionConfig(
partisanship=0,
stddev=1,
skew_factor=0,
primary_skew=0,
party_loyalty=0,
independent_bonus=0,
wasted_vote_factor=0,
uncertainty=.20
)
dw_nominate_el... |
robbierobinette/rcv-tensorflow | Ballot.py | <reponame>robbierobinette/rcv-tensorflow
from typing import List, Set
from CandidateScore import CandidateScore
from Candidate import Candidate
from Voter import Voter
from ElectionConfig import ElectionConfig
class Ballot:
def __init__(self, voter: Voter, candidates: List[Candidate], config: ElectionConfig):
... |
robbierobinette/rcv-tensorflow | Tensor.py | import tensorflow as tf
Tensor = tf.types.experimental.TensorLike
|
robbierobinette/rcv-tensorflow | CandidateModel.py | <filename>CandidateModel.py
from CandidateNetwork import CandidateNetwork
from Candidate import Candidate
import numpy as np
import tensorflow as tf
from typing import List
from ActionMemory import ActionMemory
from Ideology import Ideology
import random
import datetime as datetime
from Timings import Timings
from Ten... |
robbierobinette/rcv-tensorflow | CandidateScore.py | from Candidate import Candidate
class CandidateScore:
def __init__(self, candidate: Candidate, score: float):
self.candidate = candidate
self.score = score
|
robbierobinette/rcv-tensorflow | Ideology.py | from typing import List
import math
import numpy as np
class IdeologyBase:
def __init__(self, ideology_vec: np.ndarray):
self.vec: np.ndarray = ideology_vec
class Ideology(IdeologyBase):
def __init__(self, ideology_vec: np.ndarray):
super().__init__(ideology_vec)
self.dim = ideology_... |
robbierobinette/rcv-tensorflow | CandidateNetwork.py | <reponame>robbierobinette/rcv-tensorflow<gh_stars>0
import tensorflow as tf
import numpy as np
from typing import List
from Tensor import Tensor
class CandidateNetwork(tf.keras.Model):
def __init__(self, ideology_bins: int, ideology_dim: int, n_latent: int, width: int):
super().__init__()
self.ide... |
robbierobinette/rcv-tensorflow | Population.py | <reponame>robbierobinette/rcv-tensorflow
from Voter import Voter
from Party import Party
from typing import List
class Population:
def __init__(self, party: Party):
super().__init__()
self.party = party
def partisan_sample_voter(self) -> Voter:
pass
def unit_sample_voter(self) ->... |
robbierobinette/rcv-tensorflow | Party.py | class Party:
def __init__(self, name: str, short_name: str):
self.name = name
self.short_name = short_name
Republicans = Party("Republican", "rep")
Democrats = Party("Democrat", "dem")
Independents = Party("Independent", "ind")
|
robbierobinette/rcv-tensorflow | NDSimulation.py | import matplotlib.pyplot as plt
from Ballot import Ballot
from DefaultConfigOptions import *
from ElectionResult import ElectionResult
from InstantRunoffElection import InstantRunoffElection
from HeadToHeadElection import HeadToHeadElection
from Population import Population
from NDPopulation import NDPopulation
from t... |
robbierobinette/rcv-tensorflow | NDPopulation.py | <reponame>robbierobinette/rcv-tensorflow
from Population import Population
from Voter import Voter, UnitVoter
from Ideology import Ideology
from Party import Party
import numpy as np
from PopulationGroup import Independents
class NDPopulation(Population):
def __init__(self, location: np.array, scale: np.array):
... |
robbierobinette/rcv-tensorflow | Timings.py | import time
from contextlib import contextmanager
class Timings(object):
def __init__(self):
self.timings = {}
self.counts = {}
def add(self, label: str, delta: float):
self.timings[label] = self.timings.get(label, 0.0) + delta
self.counts[label] = self.counts.get(label, 0.0) ... |
robbierobinette/rcv-tensorflow | Candidate.py | <reponame>robbierobinette/rcv-tensorflow<filename>Candidate.py
from Party import Party
from Ideology import Ideology
class Candidate:
def __init__(self, name: str, party: Party, ideology: Ideology, quality: float):
self.ideology = ideology
self.name = name
self.party = party
self.q... |
robbierobinette/rcv-tensorflow | main.py | from PopulationGroup import PopulationGroup
from Party import *
from Voter import Voter
from CombinedPopulation import CombinedPopulation
import matplotlib.pyplot as plt
import numpy as np
from typing import List
def main():
population_groups = [
PopulationGroup(Republicans, 30, 30, .4, 12),
Popul... |
robbierobinette/rcv-tensorflow | FullSimulation.py | import matplotlib.pyplot as plt
from Ballot import Ballot
from DefaultConfigOptions import *
from PartyPrimaryElection import PartyPrimaryElection
from ElectionResult import ElectionResult
from DistrictData import DistrictVotingRecord, DistrictData
from InstantRunoffElection import InstantRunoffResult, InstantRunoffEl... |
robbierobinette/rcv-tensorflow | Election.py | <gh_stars>0
from ElectionResult import ElectionResult
from Ballot import Ballot
from typing import List, Iterable, Union, Set
from Candidate import Candidate
BallotIter = Union[Iterable[Ballot], List[Ballot]]
class Election:
def __init__(self, ballots: List[Ballot], candidates: Set[Candidate]):
self.ball... |
robbierobinette/rcv-tensorflow | ProcessResult.py | from ElectionConstructor import ElectionConstructor
from ModelStats import ModelStats
import pickle
from Candidate import Candidate
from typing import List
class ProcessResult:
def __init__(self, process: ElectionConstructor, bins: int, dim: int, stats: ModelStats, step: int):
self.process = process
... |
robbierobinette/rcv-tensorflow | InstantRunoffElection.py | <filename>InstantRunoffElection.py
from Election import ElectionResult, Election, BallotIter, Ballot
from typing import List, Iterable, Union, Set
from Candidate import Candidate
from PluralityElection import PluralityElection, PluralityResult
class InstantRunoffResult(ElectionResult):
def __init__(self, ordered_... |
robbierobinette/rcv-tensorflow | ElectionConstructor.py | <filename>ElectionConstructor.py
from typing import Set, Callable
from Ballot import Ballot
from DefaultConfigOptions import *
from Election import Election
from ElectionResult import ElectionResult
from HeadToHeadElection import HeadToHeadElection
from InstantRunoffElection import InstantRunoffElection
class Electio... |
robbierobinette/rcv-tensorflow | train_model.py | import argparse
import os.path
import pickle
from concurrent.futures import ThreadPoolExecutor
from typing import Tuple
import matplotlib.pyplot as plt
from Ballot import Ballot
from CandidateModel import CandidateModel
from DefaultConfigOptions import *
from NDPopulation import NDPopulation
from Timings import Timin... |
robbierobinette/rcv-tensorflow | PartyPrimaryElection.py | from CombinedPopulation import Democrats, Republicans, CombinedPopulation
from Election import *
from Party import Party
from PluralityElection import PluralityElection
from PopulationGroup import PopulationGroup
from ElectionConfig import ElectionConfig
class PartyPrimaryElection(Election):
def __init__(self, ba... |
robbierobinette/rcv-tensorflow | BallotTest.py | <reponame>robbierobinette/rcv-tensorflow
import matplotlib.pyplot as plt
from Ballot import Ballot
from DefaultConfigOptions import *
from PartyPrimaryElection import PartyPrimaryElection
def main():
ideology = []
for i in range(1000):
print(".")
if (i + 1) % 100 == 0:
print("")
... |
robbierobinette/rcv-tensorflow | ppo_model.py | import datetime as datetime
import os.path
import pickle
import tensorflow as tf
from ActionMemory import ActionMemory
from Ballot import Ballot
from DefaultConfigOptions import *
from ElectionConstructor import ElectionConstructor, construct_irv, construct_h2h
from ModelStats import ModelStats
from NDPopulation impo... |
robbierobinette/rcv-tensorflow | PopulationGroup.py | from Party import *
from Voter import *
import random
import numpy as np
class PopulationGroup:
def __init__(self, party: Party, mean: float, stddev: float, weight: float, primary_shift: float):
self.party = party
self.mean = mean
self.stddev = stddev
self.weight = weight
s... |
robbierobinette/rcv-tensorflow | CombinedPopulation.py | from Voter import *
from PopulationGroup import *
from typing import List
from random import uniform
from Population import Population
class CombinedPopulation(Population):
def __init__(self, population_groups: List[PopulationGroup]):
super().__init__(Independents)
self.population_groups = populat... |
robbierobinette/rcv-tensorflow | Voter.py | <filename>Voter.py
from Party import Party, Independents
from Ideology import Ideology
from Candidate import Candidate
from ElectionConfig import ElectionConfig
import random
class Voter:
def __init__(self, ideology: Ideology):
self.ideology = ideology
def score(self, candidate: Candidate, config: El... |
robbierobinette/rcv-tensorflow | ElectionConfig.py | class ElectionConfig:
def __init__(self,
partisanship: float,
stddev: float,
skew_factor: float,
primary_skew: float,
party_loyalty: float,
independent_bonus: float,
wasted_vote_factor: float,
... |
robbierobinette/rcv-tensorflow | PluralityElection.py | <reponame>robbierobinette/rcv-tensorflow
from Election import *
from ElectionResult import ElectionResult
from Ballot import Ballot
from typing import List, Union, Iterable, Set
from Candidate import Candidate
class PluralityResult(ElectionResult):
def __init__(self, ordered_candidates: List[Candidate], vote_tota... |
robbierobinette/rcv-tensorflow | ActionMemory.py | <filename>ActionMemory.py
from CandidateNetwork import CandidateNetwork
from Candidate import Candidate
import numpy as np
import tensorflow as tf
from typing import List
import random
from Tensor import Tensor
from Timings import Timings
class ActionMemory:
def __init__(self, max_size: int, state_width: int, act... |
robbierobinette/rcv-tensorflow | ModelStats.py | from typing import List
from Candidate import Candidate
class ModelStats:
def __init__(self):
self.model_count = 1e-5
self.model_winners = 1e-5
self.random_count = 1e-5
self.random_winners = 1e-5
self.model_winner_distance = 0
self.random_winner_distance = 0
... |
robbierobinette/rcv-tensorflow | ElectionResult.py | from typing import List
from Candidate import Candidate
class ElectionResult:
def __init__(self, ordered_candidates: List[Candidate]):
self.ordered_candidates = ordered_candidates
def winner(self) -> Candidate:
return self.ordered_candidates[0]
|
freshchen/dev-tools | script/office/excel/mysql_update.py | <reponame>freshchen/dev-tools
import os
import pandas as pd
SQL = ""
def write_file(s, file_name):
fh = open(file_name, 'w', encoding='utf-8')
fh.write(s)
fh.close()
def parse(data):
global SQL
for row in data.values:
SQL += "INSERT IGNORE INTO zfhis.source_code_mapping (source_id, biz_... |
freshchen/dev-tools | script/office/excel/source.py | import os
import xlrd
import time
import requests
import json
def parse(sheet, row_begin, url, token):
sheet_rows = sheet.nrows
temp = ''
for row_num in range(row_begin, sheet_rows):
row = sheet.row_values(row_num)
first = str(row[0])
second = str(row[1])
if first != '':
... |
freshchen/dev-tools | script/office/excel/create_oracle_table.py | <filename>script/office/excel/create_oracle_table.py
import os
import xlrd
SQL = ""
TYPE_DICT = {"字符串": "VARCHAR", "字符": "CHAR", "数字": "DECIMAL", "DATE": "DATE", "Datetime": "TIMESTAMP",
"日期时间": "TIMESTAMP", "DATETIME": "TIMESTAMP", "数值": "DECIMAL", "整数": "DECIMAL"}
NEED_DICT = {"必填": "NOT NULL", "应填": "N... |
freshchen/dev-tools | script/office/csv/mysql_update.py | <filename>script/office/csv/mysql_update.py
import os
import pandas as pd
SQL = ""
def write_file(s, file_name):
fh = open(file_name, 'w', encoding='utf-8')
fh.write(s)
fh.close()
def parse(data):
global SQL
for row in data.values:
SQL += "update zf_customer set qie_id=" + str(row[1]) +... |
freshchen/dev-tools | script/openstack/openstack-python-client-api.py | <reponame>freshchen/dev-tools<gh_stars>1-10
from keystoneauth1.identity import v3
from keystoneauth1 import session
from keystoneauth1 import loading
from keystoneclient.v3 import client as keyclient
from glanceclient import Client
from novaclient import client
from neutronclient.v2_0 import client as ntclient
from hea... |
darienmt/gcp-ads-b-collector | aircraft-json-to-bucket/main.py | <filename>aircraft-json-to-bucket/main.py
import sys
import os
import json
import time
import requests
from google.cloud import storage
from google.cloud.storage import Blob
device_id = os.getenv('DEVICE_ID')
if not device_id:
raise ValueError('DEVICE_ID env variable is not set')
receiver_url = os.getenv('RECEIVE... |
darienmt/gcp-ads-b-collector | topic-cloud-function/simulation/send_data.py | <gh_stars>0
import sys
import os
import time
import json
import random
from google.cloud import pubsub_v1
with open('./sample_data.json') as json_file:
data = json.load(json_file)
device_id = 'simulated_device'
message = {
'device_id' : device_id,
'aircraft_data' : data
}
project_id = os.getenv('... |
darienmt/gcp-ads-b-collector | topic-cloud-function/main.py | <reponame>darienmt/gcp-ads-b-collector
import base64
import json
import os
import hashlib
from google.cloud import bigquery
from google.api_core.exceptions import NotFound
from datetime import datetime
def get_table_and_bq_client(dataset_id, table_name):
"""
Returns the table instance and the BigQuery client `(... |
darienmt/gcp-ads-b-collector | topic-cloud-function/test_main.py | import os
import json
from google.cloud import bigquery
from google.api_core.exceptions import NotFound
from main import get_table_and_bq_client
from main import map_aircraft_to_record
from main import create_records
from main import insert_records
from main import handler
class TestMain(object):
@classmetho... |
darienmt/gcp-ads-b-collector | aircraft-json-collector/main.py | import sys
import os
import time
import json
import random
from google.cloud import pubsub_v1
import requests
project_id = os.getenv('PROJECT_ID')
if not project_id:
raise ValueError('PROJECT_ID env variable is not set')
topic = os.getenv('INPUT_TOPIC')
if not topic:
raise ValueError('INPUT_PUBSUB env variable i... |
dansuh17/deep-supervised-hashing | train.py | <reponame>dansuh17/deep-supervised-hashing
"""
Liu et al., "Deep Supervised Hashing for Fast Image Retrieval"
"""
from collections import defaultdict
import random
import torch
from torch import nn
from torch import optim
from torchvision.datasets.mnist import MNIST
from torch.utils.data import DataLoader, Dataset
impo... |
dansuh17/deep-supervised-hashing | model.py | <reponame>dansuh17/deep-supervised-hashing<filename>model.py
import torch
from torch import nn
import torch.nn.functional as F
class ResBlock(nn.Module):
def __init__(self, in_channels: int, out_channels: int, stride=1):
super().__init__()
self.net = nn.Sequential(
nn.Conv2d(
... |
monkey-cli/monkey-playground | union_find_maze/maze.py | import math
import numpy as np
from random import randrange
from union_find import union, find, connected
from utils import get_possible_next_steps, get_non_connected_next_steps
from mock import get_maze
"""
Task: Try to find the route in the provided maze from origin (0,0) to destination (N-1,M-1).
N-number of rows, ... |
monkey-cli/monkey-playground | union_find_maze/mock.py | maze = [
[0, 0, 1, 1, 0, 0, 1, 1],
[1, 0, 1, 0, 0, 1, 1, 0],
[0, 0, 0, 0, 1, 0, 1, 1],
[1, 1, 1, 0, 1, 1, 0, 0],
[0, 0, 1, 0, 0, 1, 1, 1],
[1, 0, 1, 1, 0, 0, 0, 1],
[0, 0, 0, 1, 1, 1, 0, 1],
[1, 1, 1, 1, 0, 0, 0, 1],
[0, 1, 1, 1, 0, 1, 1, 0],
[1, 0, 0, 1, 0, 0, 0, 1],
[0, 1, ... |
monkey-cli/monkey-playground | union_find_maze/union_find.py | # union find equipped with "path compression"
def find(data, i):
root = i
# Find the root of the dataset
while root != data[root]:
root = data[root]
# Compress the path leading back to the root.
# this operation is called "path compression"
while i != root:
next = data[i]
... |
monkey-cli/monkey-playground | union_find_maze/main.py | <reponame>monkey-cli/monkey-playground<filename>union_find_maze/main.py
from visualizer.maze_visualizer import create_matrix, on_step_reached
from maze import run_union_find
def on_step_update(data):
"""
Callback method to be called on every next step update from the union find runtime.
Example:
1. ne... |
monkey-cli/monkey-playground | union_find_maze/visualizer/maze_visualizer.py | import numpy as np
from turtle import Screen, Turtle
from visualizer import utils
import mock
draw_graph, fill_matrix, fill_coordinate, is_matrix_edge = (
utils.draw_graph,
utils.fill_matrix,
utils.fill_coordinate,
utils.is_matrix_edge,
)
# ------------------------------------------------------------... |
monkey-cli/monkey-playground | union_find_maze/visualizer/utils.py | from turtle import Screen, Turtle
import numpy as np
turtle = Turtle(visible=False) # hide the cursor completely
turtle.speed(0)
def draw_graph(num_rows, num_columns, space_from_edge=10):
columns = num_columns + 1
rows = num_rows + 1
screen = Screen()
width, height = screen.window_width(), screen.wi... |
monkey-cli/monkey-playground | union_find_maze/utils.py | import numpy as np
from union_find import union, find, connected
def get_surroundings(matrix, coord):
"""
Get surrounding coordinates only if their indexes are part of the matrix
"""
width = np.shape(matrix)[0]
height = np.shape(matrix)[1]
coordinates = []
# top
(
coordinates.... |
Paul-Verardi/nipyapi | tests/test_versioning.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for `nipyapi` package."""
from __future__ import absolute_import
import pytest
from deepdiff import DeepDiff
from tests import conftest
from nipyapi import registry, nifi, versioning, canvas, utils, config
def test_create_registry_client(regress_flow_reg):
... |
Paul-Verardi/nipyapi | nipyapi/nifi/models/variable_registry_dto.py | <reponame>Paul-Verardi/nipyapi<filename>nipyapi/nifi/models/variable_registry_dto.py
# coding: utf-8
"""
NiFi Rest Api
The Rest Api provides programmatic access to command and control a NiFi instance in real time. Start and stop processors, monitor queues, query pr... |
Paul-Verardi/nipyapi | nipyapi/nifi/models/version_control_information_dto.py | <reponame>Paul-Verardi/nipyapi<gh_stars>0
# coding: utf-8
"""
NiFi Rest Api
The Rest Api provides programmatic access to command and control a NiFi instance in real time. Start and stop processors, monitor queues, query provenance data, and more. Each endpoint belo... |
Paul-Verardi/nipyapi | nipyapi/nifi/models/link.py | # coding: utf-8
"""
NiFi Rest Api
The Rest Api provides programmatic access to command and control a NiFi instance in real time. Start and stop processors, monitor queues, query provenance data, and more. Each endpoint below includes a description, ... |
Paul-Verardi/nipyapi | nipyapi/nifi/models/processor_config_dto.py | <filename>nipyapi/nifi/models/processor_config_dto.py
# coding: utf-8
"""
NiFi Rest Api
The Rest Api provides programmatic access to command and control a NiFi instance in real time. Start and stop processors, monitor queues, query provenance data, and more. Each e... |
Paul-Verardi/nipyapi | nipyapi/demo/fdlc.py | <reponame>Paul-Verardi/nipyapi<filename>nipyapi/demo/fdlc.py
# -*- coding: utf-8 -*-
"""
A self-paced walkthrough of version control using NiFi-Registry.
See initial print statement for detailed explanation.
"""
from __future__ import absolute_import
import logging
from time import sleep
import nipyapi
from nipyapi.u... |
Paul-Verardi/nipyapi | nipyapi/nifi/models/controller_status_dto.py | # coding: utf-8
"""
NiFi Rest Api
The Rest Api provides programmatic access to command and control a NiFi instance in real time. Start and stop processors, monitor queues, query provenance data, and more. Each endpoint below includes a description, ... |
Paul-Verardi/nipyapi | nipyapi/registry/models/bucket_item.py | # coding: utf-8
"""
NiFi Registry REST API
The REST API provides an interface to a registry with operations for saving, versioning, reading NiFi flows and components.
OpenAPI spec version: 0.2.0
Contact: <EMAIL>
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from pprint im... |
Paul-Verardi/nipyapi | tests/test_canvas.py | <filename>tests/test_canvas.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for `nipyapi` package."""
import pytest
from tests import conftest
from nipyapi import canvas, nifi
from nipyapi.nifi import ProcessGroupFlowEntity, ProcessGroupEntity
from nipyapi.nifi import ProcessorTypesEntity, DocumentedTypeDTO... |
Paul-Verardi/nipyapi | nipyapi/nifi/models/flow_snippet_dto.py | <filename>nipyapi/nifi/models/flow_snippet_dto.py
# coding: utf-8
"""
NiFi Rest Api
The Rest Api provides programmatic access to command and control a NiFi instance in real time. Start and stop processors, monitor queues, query provenance data, and more. Each endpo... |
Paul-Verardi/nipyapi | nipyapi/nifi/models/status_descriptor_dto.py | <reponame>Paul-Verardi/nipyapi<filename>nipyapi/nifi/models/status_descriptor_dto.py<gh_stars>0
# coding: utf-8
"""
NiFi Rest Api
The Rest Api provides programmatic access to command and control a NiFi instance in real time. Start and stop processors, monitor queue... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.