repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
nsarang/backpack | backpack/library/__init__.py | import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__)))
from . import tianshou
__all__ = ["tianshou"] |
nsarang/backpack | backpack/library/tianshou/utils/__init__.py | <reponame>nsarang/backpack
from tianshou.utils.config import tqdm_config
from tianshou.utils.statistics import MovAvg, RunningMeanStd
from tianshou.utils.log_tools import BasicLogger, LazyLogger, BaseLogger
from tianshou.utils import net as networks
__all__ = [
"networks",
"MovAvg",
"RunningMeanStd",
"... |
ramonpeter/UnbinnedMeasurements | density-based/train.py | import tensorflow as tf
import pandas as pd
import numpy as np
import sys
import time
from cflow import ConditionalFlow
from MoINN.modules.subnetworks import DenseSubNet
from utils import train_density_estimation, plot_loss, plot_tau_ratio
# import data
tau1_gen = np.reshape(np.load("../data/tau1s_Pythia_gen.npy"), ... |
ramonpeter/UnbinnedMeasurements | density-based/MoINN/modules/base.py | """Base Invertible Module Class"""
from typing import Tuple, Iterable
import tensorflow as tf
class InvertibleModule(tf.keras.layers.Layer):
"""
Generic invertible layer for invertible
neural network structures.
Used to implement `Nice`, `Glow`, `RNVP` etc.
"""
def __init__(self, dims_in: T... |
ramonpeter/UnbinnedMeasurements | density-based/MoINN/modules/subnetworks.py | <reponame>ramonpeter/UnbinnedMeasurements
""" Subnetworks """
from typing import Dict
import tensorflow as tf
# pylint: disable=C0103
class _SubNet(tf.keras.layers.Layer):
"""Base class to implement various subnetworks. It takes care of
checking the dimensions. Each child class only has
to implement th... |
ramonpeter/UnbinnedMeasurements | classifier-based/omnifold.py | import numpy as np
import tensorflow as tf
import tensorflow.keras.backend as K
from sklearn.model_selection import train_test_split
def reweight(events,model,batch_size=10000):
f = model.predict(events, batch_size=batch_size)
weights = f / (1. - f)
return np.squeeze(np.nan_to_num(weights))
# Binary cross... |
ramonpeter/UnbinnedMeasurements | density-based/MoINN/modules/coupling_layers.py | """ Coupling Blocks """
from typing import Dict, Callable, Union
import tensorflow as tf
from MoINN.modules.base import InvertibleModule
# pylint: disable=C0103, R1729, E1120, E1124, W0221
class _BaseCouplingBlock(InvertibleModule):
"""Base class to implement various coupling schemes. It takes care of
chec... |
ramonpeter/UnbinnedMeasurements | classifier-based/train.py | import tensorflow as tf
import pandas as pd
import numpy as np
import sys
import matplotlib.pyplot as plt
import omnifold as of
from tensorflow.keras.layers import Dense, Input
from tensorflow.keras.models import Model
# import data
tau1_gen = np.reshape(np.load("../data/tau1s_Pythia_gen.npy"), (-1,1))
tau2_gen = np.... |
ramonpeter/UnbinnedMeasurements | density-based/MoINN/modules/fixed_permutation.py | """ Random Permutation """
from typing import Union
import numpy as np
import tensorflow as tf
from MoINN.modules.base import InvertibleModule
# pylint: disable=C0103
class PermuteRandom(InvertibleModule):
"""Constructs a random permutation, that stays fixed during training.
Permutes along the first (channe... |
ramonpeter/UnbinnedMeasurements | density-based/MoINN/modules/__init__.py | <filename>density-based/MoINN/modules/__init__.py
# Import the base class first
from MoINN.modules.base import *
# Then all inheriting modules
from MoINN.modules.coupling_layers import *
from MoINN.modules.fixed_permutation import *
from MoINN.modules.subnetworks import *
from MoINN.modules.all_in_one_block import *
|
ramonpeter/UnbinnedMeasurements | density-based/utils.py | <filename>density-based/utils.py
'''
Implementation of functions that are important for training.
'''
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
@tf.function
def train_density_estimation(flow, optimizer, batch_gen, batch_sim):
"""
Train function for density estimation normali... |
ramonpeter/UnbinnedMeasurements | density-based/MoINN/__init__.py | """Modules for Invertible Neural Networks"""
from MoINN import modules
|
ramonpeter/UnbinnedMeasurements | density-based/train_herwig.py | <filename>density-based/train_herwig.py
import tensorflow as tf
import pandas as pd
import numpy as np
import sys
import time
from cflow import ConditionalFlow
from MoINN.modules.subnetworks import DenseSubNet
from utils import train_density_estimation, plot_loss, plot_tau_ratio
# import data
tau1_gen = np.reshape(n... |
ramonpeter/UnbinnedMeasurements | density-based/cflow.py | <gh_stars>0
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
import importlib
import math
import numpy as np
import sys
import tensorflow as tf
import time
from matplotlib.backends.backend_pdf import PdfPages
from typing import Dict, Union
# Import Model blocks
from MoINN.modules.all_in_one_block import AllInOneBl... |
seii-saintway/hexo-ipynb | convert.py | <gh_stars>1-10
from __future__ import print_function
import sys
import os
from nbconvert import HTMLExporter
class MyExporter(HTMLExporter):
@property
def template_path(self):
"""
We want to inherit from HTML template, and have template under
`./templates/` so append it to the search pa... |
robocorp/jupytext | tests/test_formats.py | <filename>tests/test_formats.py
import pytest
from jupytext.compare import compare
from nbformat.v4.nbbase import new_notebook
import jupytext
from jupytext.formats import (
guess_format,
divine_format,
read_format_from_metadata,
rearrange_jupytext_metadata,
)
from jupytext.formats import (
long_for... |
robocorp/jupytext | tests/test_cells.py | <reponame>robocorp/jupytext
import pytest
from nbformat.v4.nbbase import new_markdown_cell
from jupytext.cell_reader import (
RMarkdownCellReader,
LightScriptCellReader,
uncomment,
paragraph_is_fully_commented,
)
from jupytext.cell_to_text import RMarkdownCellExporter
@pytest.mark.parametrize(
"li... |
robocorp/jupytext | tests/test_cm_config.py | import os
try:
import unittest.mock as mock
except ImportError:
import mock
from nbformat.v4.nbbase import new_notebook, new_markdown_cell, new_code_cell
from nbformat import read
import pytest
from tornado.web import HTTPError
import jupytext
from .utils import notebook_model
SAMPLE_NOTEBOOK = new_notebook(
... |
robocorp/jupytext | jupytext/config.py | <filename>jupytext/config.py
"""Find and read Jupytext configuration files"""
import os
import yaml
import json
from traitlets import Unicode, Float, Bool, Enum
from traitlets.config import Configurable
from traitlets.config.loader import PyFileConfigLoader
from traitlets.traitlets import TraitError
from .formats impor... |
robocorp/jupytext | tests/test_unicode.py | # coding: utf-8
import pytest
import jupytext
from jupytext.compare import compare
from .utils import list_notebooks
from nbformat.v4.nbbase import new_notebook, new_markdown_cell
try:
unicode # Python 2
except NameError:
unicode = str # Python 3
@pytest.mark.parametrize("nb_file", list_notebooks() + list_... |
robocorp/jupytext | tests/test_read_simple_python.py | <filename>tests/test_read_simple_python.py
# -*- coding: utf-8 -*-
from nbformat.v4.nbbase import (
new_markdown_cell,
new_code_cell,
new_raw_cell,
new_notebook,
)
from jupytext.compare import compare
import jupytext
from jupytext.compare import compare_notebooks
from .utils import skip_if_dict_is_not_... |
robocorp/jupytext | tests/test_doxygen.py | import pytest
import nbformat
import jupytext
from jupytext.cli import jupytext as jupytext_cli
from jupytext.doxygen import doxygen_to_markdown, markdown_to_doxygen
from jupytext.compare import compare, compare_notebooks
SAMPLE_MARKDOWN = """A latex formula $$1+1$$, another one $$2+2
$$
An inline formula $3+3$
"""
... |
robocorp/jupytext | tests/test_read_simple_nomarker.py | <gh_stars>1-10
import os
import pytest
from nbformat.v4.nbbase import new_notebook, new_code_cell, new_markdown_cell
from jupytext.compare import compare
from jupytext import reads, writes, write
from jupytext.combine import combine_inputs_with_outputs
from jupytext.cli import jupytext as jupytext_cli
def test_write_... |
robocorp/jupytext | tests/test_metadata_filters_from_config.py | import nbformat
from nbformat.v4.nbbase import new_notebook, new_markdown_cell
from jupytext.cli import jupytext as jupytext_cli
from jupytext.compare import compare, compare_notebooks
def test_metadata_filters_from_config(tmpdir):
cfg_file = tmpdir.join("jupytext.toml")
nb_file = tmpdir.join("notebook.ipynb"... |
robocorp/jupytext | jupytext/metadata_filter.py | """Notebook and cell metadata filtering"""
from copy import copy
from .cell_metadata import _JUPYTEXT_CELL_METADATA
_DEFAULT_NOTEBOOK_METADATA = ",".join(
[
# Preserve Jupytext section
"jupytext",
# Preserve kernel specs
"kernelspec",
# Kernel_info found in Nteract notebook... |
robocorp/jupytext | tests/test_read_simple_rmd.py | import re
import pytest
import nbformat
from nbformat.v4.nbbase import (
new_notebook,
new_markdown_cell,
new_raw_cell,
new_code_cell,
)
from jupytext.compare import compare, compare_notebooks
import jupytext
from jupytext.cli import jupytext as jupytext_cli
from .utils import skip_if_dict_is_not_ordere... |
robocorp/jupytext | tests/test_metadata_filter.py | <filename>tests/test_metadata_filter.py<gh_stars>1-10
import pytest
from nbformat.v4.nbbase import new_notebook, new_code_cell
from jupytext import reads, writes
from jupytext.cli import jupytext as jupytext_cli
from jupytext.metadata_filter import filter_metadata, metadata_filter_as_dict
def to_dict(keys):
retur... |
robocorp/jupytext | tests/test_paired_paths.py | <filename>tests/test_paired_paths.py<gh_stars>1-10
import os
import pytest
try:
import unittest.mock as mock
except ImportError:
import mock
from jupytext.compare import compare
from jupytext.contentsmanager import TextFileContentsManager
from jupytext.paired_paths import InconsistentPath, paired_paths, base_p... |
robocorp/jupytext | tests/test_escape_magics.py | import pytest
from nbformat.v4.nbbase import new_code_cell, new_notebook
from jupytext.compare import compare
from jupytext.magics import comment_magic, uncomment_magic, unesc, is_magic
from jupytext.compare import compare_notebooks
import jupytext
from .utils import notebook_model
def test_unesc():
assert unesc(... |
JasonXu12/gym_torcs | snakeoil3_gym.py | <filename>snakeoil3_gym.py
#!/usr/bin/python
# snakeoil.py
# <NAME> <<EMAIL>>
# Snake Oil is a Python library for interfacing with a TORCS
# race car simulator which has been patched with the server
# extentions used in the Simulated Car Racing competitions.
# http://scr.geccocompetitions.com/
#
# To use it, you must i... |
JasonXu12/gym_torcs | example_experiment.py | from gym_torcs import TorcsEnv
from sample_agent import Agent
import numpy as np
vision = True
episode_count = 10
max_steps = 50
reward = 0
done = False
step = 0
# Generate a Torcs environment
env = TorcsEnv(vision=vision, throttle=False)
agent = Agent(1) # steering only
print("TORCS Experiment Start.")
for i in ... |
JasonXu12/gym_torcs | ddpg.py | from gym_torcs import TorcsEnv
import matplotlib.pyplot as plt
import numpy as np
import random
import argparse
from keras.models import model_from_json, Model
from keras.models import load_model
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.optimizers ... |
Setheck/s3yum-lambda-updater | vendor/yum/updateinfo.py |
import os.path
import re
from yum.i18n import _, P_
from yum.constants import *
from yum.logginglevels import INFO_1
import rpmUtils.miscutils
import misc
import fnmatch
# newpackages is weird, in that we'll never display that because we filter to
# things relevant to installed pkgs...
_update_info_types_ = ("s... |
Setheck/s3yum-lambda-updater | vendor/yum/igroups.py | <filename>vendor/yum/igroups.py
#! /usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program ... |
Setheck/s3yum-lambda-updater | vendor/yum/mdparser.py | <reponame>Setheck/s3yum-lambda-updater
#! /usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This ... |
Setheck/s3yum-lambda-updater | vendor/rpmUtils/miscutils.py | <reponame>Setheck/s3yum-lambda-updater
#!/usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This p... |
Setheck/s3yum-lambda-updater | vendor/yum/Errors.py | #!/usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that i... |
Setheck/s3yum-lambda-updater | vendor/rpmUtils/oldUtils.py | #!/usr/bin/python -tt
import rpm
import types
import os
import gzip
import sys
from gzip import write32u, FNAME
from urlgrabber.grabber import URLGrabError
from zlib import error as zlibError
def log(num, msg):
print >>sys.stderr, msg
errorlog = log
def _(msg):
return msg
# pylint: disable-msg=E0602
d... |
Setheck/s3yum-lambda-updater | vendor/rpmUtils/__init__.py | <reponame>Setheck/s3yum-lambda-updater
#!/usr/bin/python -tt
class RpmUtilsError(Exception):
""" Exception thrown for anything rpmUtils related. """
def __init__(self, args=None):
Exception.__init__(self, args)
|
Setheck/s3yum-lambda-updater | vendor/yum/config.py | <filename>vendor/yum/config.py
#!/usr/bin/python -t
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is... |
Setheck/s3yum-lambda-updater | vendor/yum/update_md.py | #!/usr/bin/python -t
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it... |
Setheck/s3yum-lambda-updater | lambda_s3updater.py | import ssl
import string
import urlparse
import logging
#import sys # For StreamHandler
import tempfile
import createrepo
import yum
import boto
import os
import shutil
from rpmUtils.miscutils import splitFilename
# Logger
logger = logging.getLogger()
level = os.getenv('LOG_LEVEL', 'INFO')
logger.setLevel(level)
# H... |
Setheck/s3yum-lambda-updater | vendor/yum/comps.py | <gh_stars>0
#! /usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in th... |
Setheck/s3yum-lambda-updater | vendor/yum/depsolve.py | <reponame>Setheck/s3yum-lambda-updater<gh_stars>0
#!/usr/bin/python -t
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#... |
Setheck/s3yum-lambda-updater | vendor/yum/failover.py | <gh_stars>0
#!/usr/bin/python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hop... |
Setheck/s3yum-lambda-updater | vendor/yum/constants.py | <reponame>Setheck/s3yum-lambda-updater<gh_stars>0
#! /usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.... |
Setheck/s3yum-lambda-updater | vendor/yum/pkgtag_db.py | #!/usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that i... |
Setheck/s3yum-lambda-updater | vendor/yum/sqlutils.py | <filename>vendor/yum/sqlutils.py
#!/usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License
# as published by the Free Software Foundation
#
# This program is distributed in the hope that it will be useful,
# but WITHO... |
Setheck/s3yum-lambda-updater | vendor/yum/fssnapshots.py |
import os
import fnmatch
import time
from datetime import datetime
import subprocess
from yum import _
try:
import lvm
# Check that lvm2 is at least 2.2.99... In theory hacked versions of
# .98 work, but meh.
_ver = lvm.getVersion()
# Looks liks: 2.02.84(2) (2011-02-09)
_ver = _ver.split(... |
Setheck/s3yum-lambda-updater | vendor/yum/plugins.py | <filename>vendor/yum/plugins.py
#! /usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program ... |
Setheck/s3yum-lambda-updater | vendor/yum/callbacks.py | <filename>vendor/yum/callbacks.py
#!/usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program... |
Setheck/s3yum-lambda-updater | vendor/yum/metalink.py | #!/usr/bin/python -t
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it... |
Setheck/s3yum-lambda-updater | vendor/yum/rpmtrans.py | #!/usr/bin/python -t
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it... |
Setheck/s3yum-lambda-updater | vendor/yum/history.py | #!/usr/bin/python -t
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it... |
Setheck/s3yum-lambda-updater | vendor/yum/drpm.py | <filename>vendor/yum/drpm.py
# Integrated delta rpm support
# Copyright 2013 <NAME>
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at ... |
Setheck/s3yum-lambda-updater | vendor/yum/parser.py | <reponame>Setheck/s3yum-lambda-updater
#! /usr/bin/python -tt
import re
import urlparse
import urlgrabber
import os.path
import Errors
_KEYCRE = re.compile(r"\$(\w+)")
def varReplace(raw, vars):
'''Perform variable replacement
@param raw: String to perform substitution on.
@param vars: Dictionary of ... |
Setheck/s3yum-lambda-updater | vendor/createrepo/merge.py | #!/usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that i... |
Setheck/s3yum-lambda-updater | vendor/yum/logginglevels.py | <gh_stars>0
#! /usr/bin/python -tt
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in th... |
Setheck/s3yum-lambda-updater | vendor/createrepo/utils.py | #!/usr/bin/python
# util functions for createrepo
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is di... |
showerbugs/showerbasket | api/coinone.py | <reponame>showerbugs/showerbasket
import time
import requests
from api import API
class Account(API):
def __init__(self):
super().__init__()
self.base = f'{self.base}/account'
def balance(self):
url = f'{self.base}/balance'
payload = {
'access_token': self.access... |
showerbugs/showerbasket | marketcap/__init__.py | <reponame>showerbugs/showerbasket
import requests
from bs4 import BeautifulSoup
class MarketCap:
def get(self, limit=50):
ticker_cap = {}
html = requests.get('https://www.coingecko.com/en').text
soup = BeautifulSoup(html, 'html.parser')
table = soup.find(id='gecko-table').tbody
... |
showerbugs/showerbasket | api/conftest.py | <reponame>showerbugs/showerbasket<gh_stars>1-10
import pytest
from api.coinone import Account
@pytest.fixture(scope='session')
def account():
return Account()
|
showerbugs/showerbasket | api/test_coinone.py | <gh_stars>1-10
class TestAccount:
def test_balance(self, account):
result = account.balance()
assert result['result'] == 'success'
assert 'krw' in result
assert 'btc' in result
assert 'bch' in result
assert 'btg' in result
assert 'eth' in result
asser... |
showerbugs/showerbasket | marketcap/test_marketcap.py | <filename>marketcap/test_marketcap.py
class TestMarketCap:
def test_get(self, marketcap):
ticker_cap = marketcap.get()
assert(len(ticker_cap) == 100) # top 100 coins
|
showerbugs/showerbasket | marketcap/conftest.py | import pytest
from marketcap import MarketCap
@pytest.fixture(scope='session')
def marketcap():
return MarketCap()
|
showerbugs/showerbasket | config/__init__.py | import os
import yaml
from easydict import EasyDict
def create_config():
result = None
base_path = os.path.dirname(__file__)
file_path = os.path.join(base_path, 'config.yml')
try:
with open(file_path, 'r') as f:
result = yaml.load(f)
except FileNotFoundError:
raise F... |
showerbugs/showerbasket | api/__init__.py | import json
import hmac
import hashlib
import base64
from config import config
class API:
def __init__(self):
self.root = config.coinone.root
self.version = config.coinone.version
self.base = f'{self.root}/{self.version}'
self.access_token = config.coinone.access_token
se... |
showerbugs/showerbasket | basket.py | <gh_stars>1-10
import pprint
from api.coinone import Account
from marketcap import MarketCap
account = Account()
pprint.pprint(account.balance())
marketcap = MarketCap()
pprint.pprint(marketcap.get())
|
nizebelami/command-line-chess | src/Knight.py | from src.Coordinate import Coordinate as C
from src.Move import Move
from src.Piece import Piece
WHITE = True
BLACK = False
class Knight(Piece):
stringRep = '♞'
value = 3
def __init__(self, board, side, position, movesMade=0):
super(Knight, self).__init__(board, side, position)
self.mo... |
perpetualCreations/deargodpleaseno | src/usr/share/deargodpleaseno/main.py | <filename>src/usr/share/deargodpleaseno/main.py<gh_stars>0
"""
deargodpleaseno, revision 1.0
main.py, does the following:
- run install
- if not already existing, creates deargodpleaseno directory in webroot
- edits or generates robots.txt to disable obeying user-agents from viewing deargodpleaseno's directory
- run... |
Chen-Yifan/DEM_building_segmentation | data_loader_manual.py | <reponame>Chen-Yifan/DEM_building_segmentation
from PIL import Image
import numpy as np
import os
import re
import scipy.misc
import random
import sys
import csv
def is_feature_present(input_array):
return (np.sum(input_array!=0)>10) # select the image with more than 50 pixel label
def load_feature_d... |
Chen-Yifan/DEM_building_segmentation | util/summarize.py | import matplotlib.pyplot as plt
import os
def summarize_performance(history, Model_path):
print(history.history.keys())
if('lr' in history.history.keys()):
plt.plot(history.history['lr'])
plt.title('Model lr')
plt.ylabel('lr')
plt.xlabel('Epoch')
plt.savefig(os.path... |
Chen-Yifan/DEM_building_segmentation | options/train_options.py | <reponame>Chen-Yifan/DEM_building_segmentation
# -*- coding: utf-8 -*-
from .base_options import BaseOptions
import os
class TrainOptions(BaseOptions):
"""This class includes training options.
It also includes shared options defined in BaseOptions.
"""
def initialize(self, parser):
parser = B... |
Chen-Yifan/DEM_building_segmentation | options/test_options.py | from .base_options import BaseOptions
import os
class TestOptions(BaseOptions):
"""This class includes training options.
It also includes shared options defined in BaseOptions.
"""
def initialize(self, parser):
parser = BaseOptions.initialize(self, parser)
parser.add_argument('--frame... |
Chen-Yifan/DEM_building_segmentation | filter_files.py | <gh_stars>0
import numpy as np
from PIL import Image
import os
def filter_DEM():
path = '/home/shared/dem/building_data/512_50p_over/DEM_retile_all/'
frame_list = os.listdir(path)
a = frame_list.index('mclean_fillnodata_107_015.tif')
frame_list = frame_list[a:]
new_path = '/home/shared/dem/buildin... |
Chen-Yifan/DEM_building_segmentation | options/base_options.py | import argparse
import os
from util import util
class BaseOptions():
"""This class defines options used during both training and test time.
It also implements several helper functions such as parsing, printing, and saving the options.
"""
def __init__(self):
"""Reset the class; indicates the cl... |
Chen-Yifan/DEM_building_segmentation | visualize.py | import numpy as np
from matplotlib import pyplot as plt
from PIL import Image
def process_comp(gt, pred):
"""
Process groundtruth label and predicted label to 3 class map,
where TP=1, FP=2, FN=3, TN=0.
Arugments:
gt: binary numpy array (n, dim,dim,#channel)
pred: binary numpy array... |
Chen-Yifan/DEM_building_segmentation | models/models.py | <reponame>Chen-Yifan/DEM_building_segmentation
import os
import numpy as np
from keras import backend as K
from skimage.io import imsave
from keras.models import *
from keras.layers import *
from keras.optimizers import *
from metrics import *
from losses import *
from keras.regularizers import l2
import tensorflow as ... |
Chen-Yifan/DEM_building_segmentation | generator.py | <filename>generator.py
from keras.preprocessing.image import ImageDataGenerator
import numpy as np
import cv2
#from scipy.misc import imresize
import os
import random
# def trainvalGenerator(train_frame_path, train_mask_path, val_frame_path, val_mask_path, BATCH_SIZE):
# train_datagen = ImageDataGenerator(
# ... |
Chen-Yifan/DEM_building_segmentation | dataGenerator.py | <reponame>Chen-Yifan/DEM_building_segmentation
import numpy as np
import math
from keras.preprocessing.image import ImageDataGenerator
def squeeze(batches): # change to enable x and y together
while True:
batch_x, batch_y = next(batches)
# batch_y = batch_y[:,:,:,0]
print(batch_x.shape, bat... |
Chen-Yifan/DEM_building_segmentation | metrics.py | import keras.backend as K
import numpy as np
import os
import glob
import skimage.io as io
import tensorflow as tf
import cv2
from itertools import product
from skimage.morphology import skeletonize
def centerline_acc(y_true, y_pred):
"""
acc = (#( y_true_center & y_pred ) / #y_true_center + #( y_pred_center &... |
Chen-Yifan/DEM_building_segmentation | main.py | <reponame>Chen-Yifan/DEM_building_segmentation
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 20 16:38:59 2019
@author: <NAME>
"""
import os
import numpy as np
from options.train_options import TrainOptions
# from data_loader import load_data
from data_loader_manual import load_data
from define_model import train_mod... |
Chen-Yifan/DEM_building_segmentation | define_model.py | import os
import numpy as np
from keras.callbacks import ModelCheckpoint,TensorBoard,CSVLogger,EarlyStopping,ReduceLROnPlateau
from keras.models import model_from_json
from dataGenerator import custom_image_generator, val_datagenerator, no_aug_generator
from keras.optimizers import Adadelta, Adam, SGD
from metrics impo... |
Chen-Yifan/DEM_building_segmentation | data_loader.py | <reponame>Chen-Yifan/DEM_building_segmentation
from PIL import Image
import numpy as np
import os
import re
import scipy.misc
import random
import sys
import csv
# part 1/2
# def train_test_val_split(frame_data,mask_data, name_list, result_path):
# n = len(frame_data)
# a = int(n*0.75)
# b = int(n*0.85)
# ... |
Chen-Yifan/DEM_building_segmentation | losses.py | import keras.backend as K
import numpy as np
import os
import glob
import skimage.io as io
import tensorflow as tf
from keras.utils import to_categorical
from itertools import product
from scipy.spatial.distance import cdist
def wbce( y_true, y_pred, weight1=0.7, weight0=0.3) :
y_true = K.clip(y_true, K.epsilon()... |
YetAnotherKeyboard/rust-firmware | tools/runners/nrf.py | #!/usr/bin/env python3
import os
import sys
import tempfile
from pathlib import Path
from subprocess import run
def kill_open_ocd():
r = run(["killall", "openocd"])
def delete_flash():
result = run(["nrfjprog", "--eraseall", "-f", "nrf52"])
if result.returncode != 0:
raise Exception("Could no... |
bloom42/research | rust_gui_ecosystem/electron_addon/addon-rs/node/binding.gyp | <filename>rust_gui_ecosystem/electron_addon/addon-rs/node/binding.gyp
{
"targets": [{
"target_name": "addon",
"sources": [ "addon.cpp" ],
"libraries": [
"../../target/release/libaddon.dylib"
]
}]
}
|
narfman0/abbot | abbot/galaxy/chunk.py | import random
import arcade
from abbot.galaxy.celestial_body import CelestialBody
class Chunk:
"""A chunk within the game. A chunk has coordinates, defined as a
chunk_x, chunk_y pair.
Note: coordinates shall always be absolute coordinates. Chunk
coordinates do not exist and we will not do math rela... |
narfman0/abbot | abbot/ui/gameplay_window.py | <filename>abbot/ui/gameplay_window.py
import random
from typing import Optional
import arcade
import pymunk
from abbot.math import distance
from abbot.npc import NPC, ATTACK_DISTANCE
from abbot.driver import Driver
SCREEN_TITLE = "Abbot"
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 1024
class GameplayWindow(arcade.Window):... |
narfman0/abbot | abbot/driver.py | import random
from typing import Optional
import arcade
import pymunk
from abbot.math import distance
from abbot.npc import Collision, NPC, ATTACK_DISTANCE
from abbot.galaxy import Chunk, Galaxy
# Movement speed of player, in pixels per frame
MOVEMENT_SPEED = 2
GRAVITY = 1
PLAYER_JUMP_SPEED = 25
PLAYER_MOVE_FORCE_ON... |
narfman0/abbot | tests/galaxy/test_chunk.py | <reponame>narfman0/abbot<filename>tests/galaxy/test_chunk.py
import unittest
import pytest
from abbot.galaxy import Chunk
def test_chunk_seed_create_is_equivalent():
chunk_1 = Chunk(seed=0, chunk_x=0, chunk_y=1, chunk_width=2 ** 10)
chunk_2 = Chunk(seed=0, chunk_x=0, chunk_y=1, chunk_width=2 ** 10)
asse... |
narfman0/abbot | abbot/galaxy/galaxy.py | <filename>abbot/galaxy/galaxy.py<gh_stars>0
import random
from functools import lru_cache
from abbot.galaxy.chunk import Chunk
from abbot.math import distance
class Galaxy:
"""Identify and control the environment. Chunks are viewed like a grid,
and themselves have coordinates. Coordinates originate at 0,0 an... |
narfman0/abbot | abbot/main.py | <filename>abbot/main.py
import arcade
from abbot.ui.gameplay_window import GameplayWindow
def main():
""" Main method """
window = GameplayWindow()
window.setup()
arcade.run()
if __name__ == "__main__":
main()
|
narfman0/abbot | abbot/galaxy/celestial_body.py | import pymunk
class CelestialBody:
def __init__(self, x, y, radius):
""" x, y in absolute coordinates """
self.radius = radius
mass = 1
moment = pymunk.moment_for_circle(mass, 0, radius)
self.body = pymunk.Body(mass, moment, body_type=pymunk.body.Body.STATIC)
self.... |
narfman0/abbot | tests/test_npc.py | import unittest
import pytest
from abbot.npc import NPC
def test_npc_attack():
attacker = NPC("kingkrool")
defender = NPC("kingkrool")
attacker.attack([defender])
assert defender.current_hp < defender.hp
def test_npc_fainted():
npc = NPC("kingkrool")
npc.current_hp -= npc.current_hp
as... |
narfman0/abbot | abbot/galaxy/__init__.py | <gh_stars>0
from abbot.galaxy.celestial_body import CelestialBody
from abbot.galaxy.chunk import Chunk
from abbot.galaxy.galaxy import Galaxy
|
narfman0/abbot | tests/galaxy/test_galaxy.py | <reponame>narfman0/abbot
import unittest
import pytest
from abbot.galaxy import Chunk, Galaxy
@pytest.fixture
def galaxy():
return Galaxy(seed=0)
def test_position_to_chunk_coordinates(galaxy):
assert galaxy.position_to_chunk_coordinates(0, 0) == (0, 0)
assert galaxy.position_to_chunk_coordinates(gala... |
narfman0/abbot | abbot/settings.py | <filename>abbot/settings.py
import os
USE_SIMPLE_JUMP_PHYSICS = bool(os.environ.get("USE_SIMPLE_JUMP_PHYSICS", "True"))
|
narfman0/abbot | abbot/npc.py | <reponame>narfman0/abbot
import math
import random
import time
from dataclasses import dataclass
import arcade
import pymunk
from abbot import settings
from abbot.ui.animated_sprite import AnimatedSprite
from abbot.math import distance
ATTACK_DISTANCE = 100
PLAYER_JUMP_IMPULSE = 1000
PLAYER_GRAVITY_IMPULSE = 20
cl... |
JeandsGomes/pacotes_pypi | src/Face_Recognition/Face_Recognition.py | import numpy as np
import cv2
import skimage
from keras.models import Model, Sequential
from keras.layers import Input, Convolution2D, ZeroPadding2D, MaxPooling2D, Flatten, Dense, Dropout, Activation
from PIL import Image
from keras.preprocessing.image import load_img, save_img, img_to_array
from keras.applications.i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.