repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
rancher | rancher-master/tests/validation/tests/v3_api/test_bkp_restore_s3_recover.py | import pytest
from .common import * # NOQA
from .test_rke_cluster_provisioning import HOST_NAME
from .test_rke_cluster_provisioning import create_and_validate_custom_host
from .test_rke_cluster_provisioning import rke_config
namespace = {"p_client": None, "ns": None, "cluster": None, "project": None,
"no... | 7,295 | 36.22449 | 79 | py |
rancher | rancher-master/tests/validation/tests/v3_api/test_rbac_2.py | import pytest
import os
from .common import create_kubeconfig
from .common import DATA_SUBDIR
from .common import get_user_client_and_cluster
from .common import rbac_test_file_reader
from .common import validate_cluster_role_rbac
from .common import if_test_rbac_v2
@pytest.fixture(scope='module', autouse="True")
def... | 2,032 | 38.862745 | 74 | py |
rancher | rancher-master/tests/validation/tests/v3_api/test_cluster_templates.py | import copy
import os
import pytest
import requests
from rancher import ApiError
from .common import * # NOQA
from .test_monitoring import cluster_query_template
from .test_monitoring import validate_cluster_graph
from .test_monitoring import C_MONITORING_ANSWERS
from .test_monitoring import CLUSTER_MONITORING_APP
fro... | 45,280 | 39.32146 | 79 | py |
rancher | rancher-master/tests/validation/tests/v3_api/cli_common.py | import os
import logging
import sys
import time
from .common import run_command, run_command_with_stderr
logging.basicConfig(stream=sys.stdout,
level=os.environ.get("LOGLEVEL", "INFO"),
format='%(asctime)s - %(filename)s:%(funcName)s'
':%(lineno)d - [... | 3,552 | 34.178218 | 87 | py |
rancher | rancher-master/tests/validation/tests/v3_api/test_ebs_volume_backed_instance.py | import os
import pytest
import time
from lib.aws import AmazonWebServices
from rancher import ApiError
from .common import (
AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY,
AWS_REGION,
AWS_SG,
AWS_SUBNET,
AWS_VPC,
AWS_ZONE,
DEFAULT_TIMEOUT,
cluster_cleanup,
get_user_client,
random... | 4,698 | 30.965986 | 89 | py |
rancher | rancher-master/tests/validation/tests/v3_api/test_node_template.py | import os
import pytest
from rancher import ApiError
from .common import * # NOQA
from .test_rke_cluster_provisioning import rke_config
from .test_rke_cluster_provisioning import random_node_name
from .test_rke_cluster_provisioning import create_and_validate_cluster
DO_ACCESSKEY = os.environ.get('DO_ACCESSKEY', "None... | 12,187 | 44.140741 | 78 | py |
rancher | rancher-master/tests/validation/tests/v3_api/test_websocket.py | import base64
import pytest
import time
import urllib
from .common import CATTLE_TEST_URL
from .common import USER_TOKEN
from .common import TEST_IMAGE
from .common import create_kubeconfig
from .common import create_connection
from .common import create_project_and_ns
from .common import get_user_client_and_cluster
fr... | 5,369 | 34.098039 | 77 | py |
rancher | rancher-master/tests/validation/tests/v3_api/test_project_quota.py | import os
import pytest
from .common import * # NOQA
namespace = {"p_client": None, "ns": None, "cluster": None, "project": None}
CLUSTER_NAME = os.environ.get("CLUSTER_NAME", "")
RANCHER_CLEANUP_PROJECT = os.environ.get("RANCHER_CLEANUP_PROJECT", "True")
@pytest.fixture
def ns_default_quota():
return {"limit"... | 7,019 | 33.07767 | 79 | py |
rancher | rancher-master/tests/validation/tests/v3_api/test_oke_cluster.py | import pytest
from .common import * # NOQA
OCI_TENANCY_OCID = os.environ.get('RANCHER_OCI_TENANCY_OCID', "")
OCI_COMPARTMENT_OCID = os.environ.get('RANCHER_OCI_COMPARTMENT_OCID', "")
OCI_USER_OCID = os.environ.get('RANCHER_OCI_USER_OCID', "")
OCI_FINGERPRINT = os.environ.get('RANCHER_OCI_FINGERPRINT', "")
OCI_PRIVATE... | 7,633 | 36.239024 | 114 | py |
rancher | rancher-master/tests/validation/tests/v3_api/test_proxy.py | import os
import time
from lib.aws import AWS_USER
from .common import (
AmazonWebServices, run_command
)
from .test_airgap import get_bastion_node
from .test_custom_host_reg import (
random_test_name, RANCHER_SERVER_VERSION, HOST_NAME, AGENT_REG_CMD
)
BASTION_ID = os.environ.get("RANCHER_BASTION_ID", "")
NUMBE... | 12,636 | 41.837288 | 79 | py |
rancher | rancher-master/tests/validation/lib/digital_ocean.py | import digitalocean
import os
import time
from .cloud_provider import CloudProviderBase
from .node import Node
PRIVATE_IMAGES = {
"ubuntu-16.04-docker-1.12.6": {
'image': 30447985, 'ssh_user': 'ubuntu'},
"ubuntu-16.04-docker-17.03": {
'image': 30473722, 'ssh_user': 'ubuntu'},
"ubuntu-16.0... | 5,305 | 31.956522 | 78 | py |
rancher | rancher-master/tests/validation/lib/aws.py | import base64
import boto3
import logging
import os
import rsa
import time
from boto3.exceptions import Boto3Error
from botocore.exceptions import ClientError
from .cloud_provider import CloudProviderBase
from .node import Node
logging.getLogger('boto3').setLevel(logging.CRITICAL)
logging.getLogger('botocore').setLeve... | 26,266 | 37.856509 | 79 | py |
rancher | rancher-master/tests/validation/lib/node.py | import json
import logging
import paramiko
import time
logging.getLogger("paramiko").setLevel(logging.CRITICAL)
DOCKER_INSTALL_CMD = (
"curl https://releases.rancher.com/install-docker/{0}.sh | sh")
class Node(object):
def __init__(self, provider_node_id=None, host_name=None, node_name=None,
... | 6,138 | 35.981928 | 78 | py |
rancher | rancher-master/tests/validation/lib/kubectl_client.py | import os
import json
import time
import subprocess
DEBUG = os.environ.get('DEBUG', 'false')
CONFORMANCE_YAML = ("tests/kubernetes_conformance/resources/k8s_ymls/"
"sonobuoy-conformance.yaml")
class KubectlClient(object):
def __init__(self):
self._kube_config_path = None
self... | 8,702 | 36.351931 | 78 | py |
rancher | rancher-master/tests/validation/lib/__init__.py | 0 | 0 | 0 | py | |
rancher | rancher-master/tests/validation/lib/cloud_provider.py | import abc
import os
from invoke import run
class CloudProviderBase(object, metaclass=abc.ABCMeta):
DOCKER_VERSION = os.environ.get("DOCKER_VERSION", '20.10')
DOCKER_INSTALLED = os.environ.get("DOCKER_INSTALLED", "false")
@abc.abstractmethod
def create_node(self, node_name, wait_for_ready=False):
... | 2,074 | 34.169492 | 75 | py |
rancher | rancher-master/tests/validation/lib/rke_client.py | import os
import jinja2
import logging
import tempfile
import time
import subprocess
from yaml import load
logging.getLogger('invoke').setLevel(logging.WARNING)
DEBUG = os.environ.get('DEBUG', 'false')
DEFAULT_CONFIG_NAME = 'cluster.yml'
DEFAULT_NETWORK_PLUGIN = os.environ.get('DEFAULT_NETWORK_PLUGIN', 'canal')
K8S_... | 5,848 | 38.52027 | 78 | py |
rancher | rancher-master/tests/validation/images/container-utils/app.py | from flask import Flask, request
import os
import random
import requests
import socket
from string import ascii_letters, digits
from subprocess import call
TEMP_DIR = os.path.dirname(os.path.realpath(__file__)) + '/temp'
app = Flask(__name__)
def generate_random_file_name():
name = ''.join(random.choice(ascii_l... | 3,284 | 28.070796 | 82 | py |
semanticilp-aaai | semanticilp-aaai/other/generateHashForEachQuestion.py | ## I used this because I need to convert each question to a hash value
import csv
import hashlib
fourth = True
if fourth:
questions_file = "/Users/daniel/ideaProjects/TextILP/other/questionSets/Public-Feb2016-Elementary-NDMC-Test.tsv"
lucene_predictions = "/Users/daniel/ideaProjects/TextILP/other/lucene-publ... | 5,448 | 37.373239 | 128 | py |
prifi-experiments | prifi-experiments-master/remove-prefix.py | import sys
import re
def processFile(inFile, outFile):
linesOut = []
with open(inFile) as file:
rawData = file.read()
lines = rawData.split("\n")
for line in lines:
line2 = ""
if re.search("1 : time_statistics.go:87 \\(log.\\(\\*TimeStatistics\\)\\.ReportWithInfo... | 2,040 | 46.465116 | 153 | py |
prifi-experiments | prifi-experiments-master/pcap-individuals.py | import sys
import re
import json
import collections
regex1str = "{\"pcap_time_diff\": \"([-\d]+)\""
regex1 = re.compile(regex1str)
json = []
pcapsNames = []
nClientsVals = []
nActiveClientsVals = []
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
def pars... | 2,517 | 27.942529 | 149 | py |
prifi-experiments | prifi-experiments-master/fetch-info-dual.py | #!/usr/bin/python2
import os
import sys
import json
data = []
if len(sys.argv) < 2:
print "Argument 1 must be the features to extract"
sys.exit(1)
feature = sys.argv[1]
outLines = []
def processFile(inFile):
global logFolder
data = []
with open(logFolder + inFile) as file:
rawData = fi... | 1,462 | 22.596774 | 76 | py |
prifi-experiments | prifi-experiments-master/remove-prefix-old-format.py | import sys
def processFile(inFile, outFile):
linesOut = []
with open(inFile) as file:
rawData = file.read()
lines = rawData.split("\n")
for line in lines:
line2 = ""
if "ReportWithInfo: 78) - " in line:
line2 = line[line.find("ReportWithInfo: 78... | 1,492 | 38.289474 | 153 | py |
prifi-experiments | prifi-experiments-master/convert-json.py | import sys
import re
import json
regex1str = "\[([\d]+)\] ([\d\.]+) round\/sec, ([\d\.]+) kB\/s up, ([\d\.]+) kB\/s down, ([\d\.]+) kB\/s down\(udp\), ([\d\.]+) kB\/s down\(re-udp\)"
regex1 = re.compile(regex1str)
regex2str = "\[([-\d]+)\] ([-\d\.]+) ms \+- ([-\d\.]+) \(over ([-\d\.]+), happened ([-\d\.]+)\)\. Info: (... | 3,530 | 35.402062 | 149 | py |
prifi-experiments | prifi-experiments-master/fetch-info.py | #!/usr/bin/python2
import os
import sys
import json
data = []
if len(sys.argv) < 2:
print "Argument 1 must be the features to extract"
sys.exit(1)
feature = sys.argv[1]
outLines = []
def processFile(inFile):
global logFolder
data = []
with open(logFolder + inFile) as file:
rawData = fi... | 1,425 | 22 | 76 | py |
prifi-experiments | prifi-experiments-master/fig7b-churn-anonymity-set/anon_set_size_relative.py | #!/usr/bin/python3
import sys
import csv
import math
import numpy
MIN_DIFF = 0.1
assoc = []
disassoc = []
with open('cafe_association.csv', 'r') as csvfile:
f = csv.reader(csvfile, delimiter=',', quotechar='"')
for row in f:
assoc.append(row)
with open('cafe_disassociation.csv', 'r') as csvfile:
... | 5,821 | 27.125604 | 99 | py |
prifi-experiments | prifi-experiments-master/fig7b-churn-anonymity-set/anon_set_size.py | #!/usr/bin/python3
import sys
import csv
import math
import numpy
MIN_DIFF = 0.1
assoc = []
disassoc = []
with open('cafe_association.csv', 'r') as csvfile:
f = csv.reader(csvfile, delimiter=',', quotechar='"')
for row in f:
assoc.append(row)
with open('cafe_disassociation.csv', 'r') as csvfile:
... | 5,020 | 26.587912 | 99 | py |
prifi-experiments | prifi-experiments-master/fig5a-hangouts-pcap-replay/bitratestats.py | import sys
import re
import json
import collections
import os
regex1str = "{\"pcap_time_diff\": \"([-\d]+)\""
regex1 = re.compile(regex1str)
json = []
pcapsNames = []
nClientsVals = []
nActiveClientsVals = []
def is_number(s):
try:
float(s)
return True
except ValueError:
return False... | 2,706 | 27.797872 | 149 | py |
prifi-experiments | prifi-experiments-master/fig5a-hangouts-pcap-replay/pcap-individuals.py | import sys
import re
import json
import collections
regex1str = "{\"pcap_time_diff\": \"([-\d]+)\""
regex1 = re.compile(regex1str)
json = []
pcapsNames = []
nClientsVals = []
nActiveClientsVals = []
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
def pars... | 2,539 | 28.195402 | 171 | py |
prifi-experiments | prifi-experiments-master/fig5a-hangouts-pcap-replay/data_explore.py | #!/usr/bin/python3
# usage: cat individualpcaps_.gnudata | ./stats.py
import fileinput
from pprint import pprint
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import sys
def try_parse_int(s, base=10):
try:
return int(s, base)
except ValueError:
return None
if len(sys.argv) < 2... | 658 | 17.828571 | 55 | py |
prifi-experiments | prifi-experiments-master/fig5a-hangouts-pcap-replay/data_explore2.py | #!/usr/bin/python3
# usage: cat individualpcaps_.gnudata | ./stats.py
from pathlib import Path
import sys
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
def try_parse_int(s, base=10):
try:
return int(s, base)
except ValueError:
return None
def processPoint(fileScheme):
plot... | 1,550 | 29.411765 | 109 | py |
prifi-experiments | prifi-experiments-master/fig8-others-pcap-replay/bitratestats.py | import sys
import re
import json
import collections
import os
regex1str = "{\"pcap_time_diff\": \"([-\d]+)\""
regex1 = re.compile(regex1str)
json = []
pcapsNames = []
nClientsVals = []
nActiveClientsVals = []
def is_number(s):
try:
float(s)
return True
except ValueError:
return False... | 2,706 | 27.797872 | 149 | py |
prifi-experiments | prifi-experiments-master/fig8-others-pcap-replay/pcap-individuals.py | import sys
import re
import json
import collections
regex1str = "{\"pcap_time_diff\": \"([-\d]+)\""
regex1 = re.compile(regex1str)
json = []
pcapsNames = []
nClientsVals = []
nActiveClientsVals = []
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
def pars... | 2,539 | 28.195402 | 171 | py |
prifi-experiments | prifi-experiments-master/fig8-others-pcap-replay/data_explore.py | #!/usr/bin/python3
# usage: cat individualpcaps_.gnudata | ./stats.py
import fileinput
from pprint import pprint
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import sys
def try_parse_int(s, base=10):
try:
return int(s, base)
except ValueError:
return None
if len(sys.argv) < 2... | 658 | 17.828571 | 55 | py |
prifi-experiments | prifi-experiments-master/fig8-others-pcap-replay/data_explore2.py | #!/usr/bin/python3
# usage: cat individualpcaps_.gnudata | ./stats.py
from pathlib import Path
import sys
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
def try_parse_int(s, base=10):
try:
return int(s, base)
except ValueError:
return None
def processPoint(fileScheme):
plot... | 1,550 | 29.411765 | 109 | py |
prifi-experiments | prifi-experiments-master/fig4-skype/bitratestats.py | import sys
import re
import json
import collections
import os
import numpy as np
import math
regex1str = "{\"pcap_time_diff\": \"([-\d]+)\""
regex1 = re.compile(regex1str)
json = []
pcapsNames = []
nClientsVals = []
nActiveClientsVals = []
def is_number(s):
try:
float(s)
return True
except V... | 3,074 | 29.147059 | 196 | py |
prifi-experiments | prifi-experiments-master/fig4-skype/pcap-individuals.py | import sys
import re
import json
import collections
regex1str = "{\"pcap_time_diff\": \"([-\d]+)\""
regex1 = re.compile(regex1str)
json = []
pcapsNames = []
nClientsVals = []
nActiveClientsVals = []
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
def pars... | 2,539 | 28.195402 | 171 | py |
prifi-experiments | prifi-experiments-master/fig4-skype/data_explore.py | #!/usr/bin/python3
# usage: cat individualpcaps_.gnudata | ./stats.py
import fileinput
from pprint import pprint
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import sys
def try_parse_int(s, base=10):
try:
return int(s, base)
except ValueError:
return None
if len(sys.argv) < 2... | 658 | 17.828571 | 55 | py |
prifi-experiments | prifi-experiments-master/fig4-skype/data_explore2.py | #!/usr/bin/python3
# usage: cat individualpcaps_.gnudata | ./stats.py
from pathlib import Path
import sys
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
def try_parse_int(s, base=10):
try:
return int(s, base)
except ValueError:
return None
def processPoint(fileScheme):
plot... | 1,550 | 29.411765 | 109 | py |
prifi-experiments | prifi-experiments-master/fig5b-icrc/pcap-individuals.py | import sys
import re
import json
import collections
regex1str = "{\"pcap_time_diff\": \"([-\d]+)\""
regex1 = re.compile(regex1str)
json = []
pcapsNames = []
payloads = []
def is_number(s):
try:
float(s)
if float(s) > 10:
return True
return False
except ValueError:
... | 2,280 | 25.835294 | 171 | py |
prifi-experiments | prifi-experiments-master/fig5b-icrc/script.py |
out = []
with open('bkp') as f:
for line in f:
number = int(line.strip().replace(',',''))
if number > 10:
out.append(number)
with open('individualpcaps_experiment_10.gnudata', 'w') as f:
for val in out:
f.write(str(val)+",\n") | 273 | 21.833333 | 61 | py |
prifi-experiments | prifi-experiments-master/fig3b-relatedwork/riffle-data/stats.py | import os
import sys
from os import listdir
import numpy as np
from os.path import isfile, join
files = [f for f in listdir('.') if isfile(f) and '.txt' in f and 'out_' in f]
files.sort()
stats = dict()
for file in files:
with open(file) as f:
content = f.read()
lines = content.split('\n')
... | 1,447 | 29.166667 | 83 | py |
nu_coincidence | nu_coincidence-main/setup.py | from setuptools import setup
import versioneer
import os
def find_config_files(directory):
paths = []
for (path, directories, filenames) in os.walk(directory):
for filename in filenames:
paths.append(os.path.join("..", path, filename))
return paths
config_files = find_config_fil... | 504 | 17.703704 | 61 | py |
nu_coincidence | nu_coincidence-main/versioneer.py |
# Version: 0.19
"""The Versioneer - like a rocketeer, but for versions.
The Versioneer
==============
* like a rocketeer, but for versions!
* https://github.com/python-versioneer/python-versioneer
* Brian Warner
* License: Public Domain
* Compatible with: Python 3.6, 3.7, 3.8, 3.9 and pypy3
* [![Latest Version][pyp... | 70,144 | 36.793642 | 87 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/coincidence.py | from abc import ABCMeta
import numpy as np
class CoincidenceCheck(object, metaclass=ABCMeta):
"""
Abstract base class for coincidence checks.
"""
def __init__(self):
pass
def check_spatial(self):
pass
def check_temporal(self):
pass
def check_spatial_coincidence(... | 5,821 | 24.761062 | 87 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/_version.py | # This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# feature). Distribution tarballs (built by setup.py sdist) and build
# directories (produced by setup.py build) will contain a much shorter file
# that just contains th... | 18,700 | 32.275801 | 88 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/simulation.py | import h5py
import numpy as np
from abc import abstractmethod, ABCMeta
from typing import List
class Simulation(object, metaclass=ABCMeta):
"""
Generic simulation base class.
"""
def __init__(self, file_name="output/test_sim", group_base_name="survey", N=1):
self._N = N
self._file_n... | 1,706 | 18.848837 | 83 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/__init__.py | from nu_coincidence.populations.aux_samplers import (
SpectralIndexAuxSampler,
VariabilityAuxSampler,
FlareRateAuxSampler,
FlareTimeAuxSampler,
FlareDurationAuxSampler,
FlareAmplitudeAuxSampler,
CombinedFluxIndexSampler,
)
from nu_coincidence.populations.selection import CombinedFluxIndexSe... | 422 | 23.882353 | 75 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/distributions/cosmological_distribution.py | import numpy as np
from popsynth.distribution import DistributionParameter
from popsynth.distributions.cosmological_distribution import CosmologicalDistribution
class ZPowExpCosmoDistribution(CosmologicalDistribution):
r0 = DistributionParameter(default=1, vmin=0)
k = DistributionParameter()
xi = Distri... | 753 | 26.925926 | 85 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/distributions/__init__.py | 0 | 0 | 0 | py | |
nu_coincidence | nu_coincidence-main/nu_coincidence/config/__init__.py | 0 | 0 | 0 | py | |
nu_coincidence | nu_coincidence-main/nu_coincidence/populations/spatial_populations.py | from popsynth.population_synth import PopulationSynth
from nu_coincidence.distributions.cosmological_distribution import (
ZPowExpCosmoDistribution,
)
class ZPowExpCosmoPopulation(PopulationSynth):
def __init__(
self,
r0,
k,
xi,
r_max=5.0,
seed=1234,
lu... | 937 | 23.051282 | 68 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/populations/popsynth_wrapper.py | import yaml
from typing import Dict, Any
from popsynth.population_synth import PopulationSynth
from nu_coincidence.utils.parameter_server import ParameterServer
class PopsynthParams(ParameterServer):
"""
Class to pass necessary params to create
a popsynth population.
"""
def __init__(self, confi... | 1,361 | 19.328358 | 81 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/populations/aux_samplers.py | import numpy as np
from scipy import stats
import h5py
from popsynth.auxiliary_sampler import AuxiliarySampler, AuxiliaryParameter
from popsynth.aux_samplers.normal_aux_sampler import NormalAuxSampler
from popsynth.aux_samplers.plaw_aux_sampler import PowerLawAuxSampler, _sample_power_law
from popsynth.utils.cosmology... | 7,979 | 25.778523 | 88 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/populations/selection.py | from popsynth.selection_probability.generic_selectors import LowerBound, SoftSelection
from popsynth.selection_probability.selection_probability import SelectionParameter
class CombinedFluxIndexSelection(LowerBound):
"""
Selection on :class:`CombinedFluxIndexSampler`,
with the form:
index = ``slope``... | 1,992 | 26.30137 | 86 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/populations/__init__.py | 0 | 0 | 0 | py | |
nu_coincidence | nu_coincidence-main/nu_coincidence/blazar_nu/base.py | from abc import ABCMeta, abstractmethod
from joblib import (
parallel_backend,
register_parallel_backend,
Parallel,
delayed,
)
from nu_coincidence.populations.popsynth_wrapper import (
PopsynthParams,
PopsynthWrapper,
)
from nu_coincidence.simulation import Simulation
from nu_coincidence.utils.... | 6,053 | 25.669604 | 83 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/blazar_nu/coincidence.py | import numpy as np
import h5py
from typing import List
from collections import OrderedDict
from nu_coincidence.simulation import Results
from nu_coincidence.populations.popsynth_wrapper import PopsynthWrapper
from nu_coincidence.neutrinos.icecube import IceCubeObsWrapper
from nu_coincidence.coincidence import (
ch... | 13,877 | 30.39819 | 87 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/blazar_nu/connected.py | import os
import h5py
import numpy as np
from collections import OrderedDict
from typing import List
from astropy import units as u
from icecube_tools.neutrino_calculator import NeutrinoCalculator
from nu_coincidence.populations.popsynth_wrapper import PopsynthWrapper
from nu_coincidence.neutrinos.icecube import (
... | 25,219 | 30.251549 | 87 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/blazar_nu/__init__.py | 0 | 0 | 0 | py | |
nu_coincidence | nu_coincidence-main/nu_coincidence/neutrinos/icecube.py | import numpy as np
import h5py
import yaml
from abc import ABCMeta, abstractmethod
from dataclasses import dataclass
from typing import Any, Dict, Optional
from icecube_tools.detector.effective_area import EffectiveArea
from icecube_tools.detector.energy_resolution import EnergyResolution
from icecube_tools.detector.a... | 15,879 | 24.99018 | 88 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/neutrinos/__init__.py | 0 | 0 | 0 | py | |
nu_coincidence | nu_coincidence-main/nu_coincidence/utils/plotting.py | import numpy as np
from astropy.visualization.wcsaxes.patches import _rotate_polygon
from matplotlib.patches import PathPatch
from matplotlib.path import Path
import astropy.units as u
class SphericalCircle(PathPatch):
# created from the astropy.visualization.wcsaxes.patches.SphericalCircle class
# changed to... | 4,272 | 36.156522 | 87 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/utils/fluxes.py | import numpy as np
def flux_conv(index, E_min, E_max):
"""
Convert from energy flux [erg cm^-2 s^-1]
to number flux [cm^-2 s^-1] assuming
a bounded power law spectrum.
:param index: Spectral index
:param E_min: Minimum energy
:param E_max: Maximum energy
"""
if index == 1.0:
... | 696 | 18.361111 | 67 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/utils/parameter_server.py | from abc import ABCMeta
class ParameterServer(object, metaclass=ABCMeta):
"""
Abstract base class for parameter servers.
"""
def __init__(self):
self._file_name = None
self._group_name = None
self._seed = None
self._parameters = None
@property
def seed(sel... | 838 | 14.830189 | 49 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/utils/package_data.py | from pathlib import Path
from pkg_resources import resource_filename
def get_path_to_config(file_name: str) -> Path:
file_path = resource_filename("nu_coincidence", "config/%s" % file_name)
return Path(file_path)
def get_available_config():
config_path = resource_filename("nu_coincidence", "config")
... | 427 | 19.380952 | 76 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/utils/__init__.py | 0 | 0 | 0 | py | |
nu_coincidence | nu_coincidence-main/nu_coincidence/utils/parallel.py | from abc import abstractmethod, ABCMeta
from joblib._parallel_backends import LokyBackend
class MultiCallback:
"""
Allow for multiple async callbacks
in your custom parallel backend.
"""
def __init__(self, *callbacks):
self.callbacks = [cb for cb in callbacks if cb]
def __call__(sel... | 1,524 | 20.180556 | 61 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/pop_nu/base.py | from abc import ABCMeta, abstractmethod
from joblib import (
parallel_backend,
register_parallel_backend,
Parallel,
delayed,
)
from nu_coincidence.populations.popsynth_wrapper import (
PopsynthParams,
PopsynthWrapper,
)
from nu_coincidence.simulation import Simulation
from nu_coincidence.utils.... | 4,965 | 23.706468 | 80 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/pop_nu/coincidence.py | import numpy as np
import h5py
from typing import List
from collections import OrderedDict
from nu_coincidence.simulation import Results
from nu_coincidence.populations.popsynth_wrapper import PopsynthWrapper
from nu_coincidence.neutrinos.icecube import IceCubeObsWrapper
from nu_coincidence.coincidence import (
co... | 5,653 | 26.852217 | 82 | py |
nu_coincidence | nu_coincidence-main/nu_coincidence/pop_nu/__init__.py | 0 | 0 | 0 | py | |
nu_coincidence | nu_coincidence-main/tests/conftest.py | import pytest
@pytest.fixture(scope="session")
def output_directory(tmpdir_factory):
directory = tmpdir_factory.mktemp("output")
return directory
| 158 | 14.9 | 47 | py |
nu_coincidence | nu_coincidence-main/tests/__init__.py | 0 | 0 | 0 | py | |
nu_coincidence | nu_coincidence-main/tests/test_blazar_sim.py | from popsynth.population_synth import PopulationSynth
from nu_coincidence.utils.package_data import (
get_available_config,
get_path_to_config,
)
config_files = get_available_config()
def test_blazar_sim():
blazar_config_files = [f for f in config_files if ("bllac" in f or "fsrq" in f)]
for blazar... | 674 | 21.5 | 84 | py |
nu_coincidence | nu_coincidence-main/tests/test_blazar_nu.py | import time
from nu_coincidence.blazar_nu.coincidence import BlazarNuCoincidenceSim
from nu_coincidence.blazar_nu.coincidence import BlazarNuCoincidenceResults
from nu_coincidence.blazar_nu.connected import BlazarNuConnectedSim
from nu_coincidence.blazar_nu.connected import BlazarNuConnectedResults
coincidence_sim_p... | 4,776 | 32.405594 | 81 | py |
nu_coincidence | nu_coincidence-main/tests/test_nu_sim.py | from icecube_tools.detector.effective_area import EffectiveArea
from icecube_tools.detector.energy_resolution import EnergyResolution
from icecube_tools.detector.angular_resolution import AngularResolution
from nu_coincidence.utils.package_data import (
get_available_config,
get_path_to_config,
)
from nu_coinc... | 2,022 | 27.9 | 88 | py |
nu_coincidence | nu_coincidence-main/docs/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 1,979 | 33.736842 | 79 | py |
spring-security | spring-security-main/itest/context/src/integration-test/resources/someMethod.py | print authentication.name;
for authority in authentication.authorities:
print authority
print "Granting access"
allow = 1
| 129 | 13.444444 | 44 | py |
rewalt | rewalt-main/tests/test_diagrams.py | from pytest import raises
from rewalt import utils, diagrams
from rewalt.ogposets import El
from rewalt.shapes import Shape
from rewalt.diagrams import (DiagSet, Diagram)
""" Tests for DiagSet """
def test_DiagSet_init():
X = DiagSet()
assert X == X
Y = DiagSet()
assert not X == Y
assert len(X)... | 17,213 | 24.240469 | 71 | py |
rewalt | rewalt-main/tests/test_shapes.py | from pytest import raises
from rewalt import utils, shapes
from rewalt.ogposets import (El, OgPoset, OgMap, OgMapPair)
from rewalt.shapes import (Shape, ShapeMap)
""" Tests for Shape """
def test_Shape_init():
assert Shape() == Shape()
assert Shape().dim == -1
def test_Shape_isatom():
empty = Shape.e... | 15,171 | 27.358879 | 71 | py |
rewalt | rewalt-main/tests/test_ogposets.py | import numpy as np
from pytest import raises
from rewalt import utils
from rewalt.ogposets import (El, OgPoset, GrSet, GrSubset, Closed,
OgMap, OgMapPair)
""" Tests for El """
def test_El_init():
assert El(2, 3) == El(2, 3)
assert El(2, 3) != El(1, 3)
assert El(2, 3) != El(2... | 18,931 | 25.968661 | 77 | py |
rewalt | rewalt-main/tests/__init__.py | 0 | 0 | 0 | py | |
rewalt | rewalt-main/docs/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 2,221 | 30.295775 | 79 | py |
rewalt | rewalt-main/rewalt/strdiags.py | """
Implements string diagram visualisations.
"""
import networkx as nx
from rewalt import (utils, ogposets, shapes, diagrams, drawing)
DEFAULT = {
'tikz': False,
'scale': 3,
'show': True,
'depth': True,
'bgcolor': 'white',
'fgcolor': 'black',
'infocolor': 'ma... | 25,559 | 36.151163 | 79 | py |
rewalt | rewalt-main/rewalt/diagrams.py | """
Implements diagrammatic sets and diagrams.
"""
from rewalt import utils, shapes
from rewalt.ogposets import (El, GrSet, GrSubset)
from rewalt.shapes import (Shape, ShapeMap)
class DiagSet:
"""
Class for diagrammatic sets, a model of higher-dimensional rewrite
systems and/or directed cell complexes.
... | 71,763 | 31.137931 | 77 | py |
rewalt | rewalt-main/rewalt/ogposets.py | """
Implements oriented graded posets, their elements, subsets, and maps.
"""
import numpy as np
from rewalt import utils
class El(tuple):
"""
Class for elements of an oriented graded poset.
An element is encoded as a pair of non-negative integers:
the dimension of the element, and its position in ... | 85,707 | 29.210786 | 78 | py |
rewalt | rewalt-main/rewalt/utils.py | """
Utility functions for rewalt.
"""
def typecheck(x, constraint, *more_constraints):
"""
Type and constraint checking function.
"""
if not isinstance(x, constraint['type']):
raise TypeError(type_err(constraint['type'], x))
if 'st' in constraint:
if not constraint['st'](x):
... | 1,471 | 25.763636 | 61 | py |
rewalt | rewalt-main/rewalt/hasse.py | """
Implements oriented Hasse diagram visualisation.
"""
import networkx as nx
from rewalt import utils, ogposets, diagrams, drawing
DEFAULT = {
'tikz': False,
'show': True,
'bgcolor': 'white',
'fgcolor': 'black',
'labels': True,
'inputcolor': 'magenta',
'outp... | 9,695 | 32.09215 | 75 | py |
rewalt | rewalt-main/rewalt/shapes.py | """
Implements shapes of cells and diagrams.
"""
import networkx as nx
from rewalt import utils
from rewalt.ogposets import (El, OgPoset, GrSet, GrSubset, Closed,
OgMap, OgMapPair)
class Shape(OgPoset):
"""
Inductive subclass of :class:`ogposets.OgPoset` for shapes of
cells ... | 73,090 | 31.1845 | 78 | py |
rewalt | rewalt-main/rewalt/__init__.py | from rewalt import (
ogposets, shapes, diagrams, hasse, strdiags)
from rewalt.ogposets import (El, OgPoset, OgMap, GrSet, GrSubset)
from rewalt.shapes import (Shape, ShapeMap)
from rewalt.diagrams import (DiagSet, Diagram)
from rewalt.strdiags import StrDiag
__version__ = '0.1.0'
| 290 | 31.333333 | 65 | py |
rewalt | rewalt-main/rewalt/drawing.py | """
Drawing backends.
"""
from abc import ABC
import matplotlib.pyplot as plt
from matplotlib.path import Path
from matplotlib.patches import PathPatch
DEFAULT = {
'bgcolor': 'white',
'fgcolor': 'black',
'orientation': 'bt',
}
class DrawBackend(ABC):
"""
Abs... | 14,403 | 30.937916 | 75 | py |
MERL-LB | MERL-LB-main/mp_test_fixed_ns.py | import os
import numpy as np
import random
from itertools import count
from multiprocessing import Pool, cpu_count
from copy import deepcopy
from config.test import *
from envs.datacenter_env.env import DatacenterEnv
from utils import *
class NSG:
def __init__(self, machine_num) -> None:
self.machine_num... | 9,860 | 34.092527 | 100 | py |
MERL-LB | MERL-LB-main/mp_test_nn_load.py | import os
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import pandas as pd
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEnv
from utils import *
class Actor(nn.Module):
def _... | 11,123 | 32.506024 | 131 | py |
MERL-LB | MERL-LB-main/mp.py | import torch
from torchvision import datasets, transforms
from tqdm import tqdm
device_ids = [0, 1, 2, 3] # 可用GPU
BATCH_SIZE = 64
transform = transforms.Compose([transforms.ToTensor()])
data_train = datasets.MNIST(root="./data/", transform=transform, train=True, download=True)
data_test = datasets.MNIST(root="./data... | 2,903 | 30.225806 | 91 | py |
MERL-LB | MERL-LB-main/mp_train_nn_nsga2_one.py | import os
import torch
import random
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
from multiprocessing import Pool, cpu_count
from config.ga import *
from typing import List
from envs.datacenter_env.env import DatacenterEnv
from torch.utils.tensorboard impor... | 21,461 | 34.299342 | 96 | py |
MERL-LB | MERL-LB-main/mp_train_nn_nsga2.py | import os
import torch
import random
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
from multiprocessing import Pool, cpu_count
from config.ga import *
from typing import List
from envs.datacenter_env.env import DatacenterEnv
from torch.utils.tensorboard impor... | 21,419 | 34.346535 | 96 | py |
MERL-LB | MERL-LB-main/mp_test_fixed_lg.py | import os
import numpy as np
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEnv
from utils import *
class LG:
def select_action(self, obs):
_, job_run_time, _, machines_run_time, _, action_mask = obs
... | 4,714 | 31.07483 | 100 | py |
MERL-LB | MERL-LB-main/mp_test_nn_nsga.py | import os
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import pandas as pd
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEnv
from utils import *
class Actor(nn.Module):
def _... | 11,135 | 32.643505 | 131 | py |
MERL-LB | MERL-LB-main/mp_test_sigma.py | import os
import random
import torch
import numpy as np
import pandas as pd
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Categorical
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEn... | 13,433 | 31.686131 | 97 | py |
MERL-LB | MERL-LB-main/mp_test_load.py | import os
import random
import torch
import numpy as np
import pandas as pd
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions import Categorical
from itertools import count
from multiprocessing import Pool, cpu_count
from config.test import *
from envs.datacenter_env.env import DatacenterEn... | 13,101 | 31.59204 | 97 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.