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 |
|---|---|---|---|---|---|---|
esp-idf | esp-idf-master/components/protocomm/python/sec1_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: sec1.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
fro... | 2,240 | 59.567568 | 1,054 | py |
esp-idf | esp-idf-master/components/protocomm/python/sec0_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: sec0.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
fro... | 1,568 | 46.545455 | 526 | py |
esp-idf | esp-idf-master/components/protocomm/python/sec2_pb2.py | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: sec2.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
fro... | 2,374 | 63.189189 | 1,172 | py |
esp-idf | esp-idf-master/components/esp_system/check_system_init_priorities.py | #!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
# This file is used to check the order of execution of ESP_SYSTEM_INIT_FN functions.
# It compares the priorities found in .c source files to the contents of system_init_fn.txt
# In case of... | 3,922 | 36.009434 | 123 | py |
esp-idf | esp-idf-master/components/esp_system/test_apps/esp_system_unity_tests/pytest_esp_system_unity_tests.py | # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.generic
@pytest.mark.parametrize(
'config',
[
pytest.param('default', marks=[pytest.mark.supported_targets]),
pytest.param('pd_... | 1,023 | 29.117647 | 99 | py |
esp-idf | esp-idf-master/components/esp_system/test_apps/rtc_8md256/pytest_rtc_8md256.py | # SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
def deepsleep_test(dut: Dut, case_name: str) -> None:
dut.expect_exact('Press ENTER to see the list of tests')
dut.write(case_name)
reset_reason = 'DEEP... | 2,106 | 30.924242 | 97 | py |
esp-idf | esp-idf-master/components/esp_system/test_apps/linux_apis/pytest_esp_system_linux.py | # SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.linux
@pytest.mark.host_test
def test_esp_system_linux(dut: Dut) -> None:
dut.expect_exact('Press ENTER to see the list of tests.')
dut.... | 376 | 28 | 66 | py |
esp-idf | esp-idf-master/components/efuse/efuse_table_gen.py | #!/usr/bin/env python
#
# ESP32 efuse table generation tool
#
# Converts efuse table to header file efuse_table.h.
#
# SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import division, print_function
import argparse
import hashlib
import os
i... | 21,744 | 38.109712 | 140 | py |
esp-idf | esp-idf-master/components/efuse/test_apps/pytest_efuse.py | # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.esp32
@pytest.mark.esp32c2
@pytest.mark.esp32c3
@pytest.mark.esp32c6
@pytest.mark.esp32h2
@pytest.mark.generic
def test_efuse(dut: Dut) ->... | 502 | 20.869565 | 71 | py |
esp-idf | esp-idf-master/components/efuse/test_efuse_host/efuse_tests.py | #!/usr/bin/env python
# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
from __future__ import division, print_function
import sys
import unittest
try:
import efuse_table_gen
except ImportError:
sys.path.append('..')
import efuse_table_gen
'''
To ru... | 26,294 | 48.895636 | 121 | py |
esp-idf | esp-idf-master/components/app_update/otatool.py | #!/usr/bin/env python
#
# otatool is used to perform ota-level operations - flashing ota partition
# erasing ota partition and switching ota partition
#
# SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
from __future__ import division, print_function
import a... | 13,621 | 35.42246 | 154 | py |
esp-idf | esp-idf-master/components/app_update/test_apps/pytest_app_update_ut.py | # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import re
import pytest
from pytest_embedded import Dut
DEFAULT_TIMEOUT = 20
TEST_SUBMENU_PATTERN_PYTEST = re.compile(rb'\s+\((\d+)\)\s+"([^"]+)"\r?\n')
def run_multiple_stages(dut: Dut, test_case... | 1,180 | 34.787879 | 85 | py |
esp-idf | esp-idf-master/components/freertos/test_apps/freertos/pytest_freertos.py | # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytest_embedded import Dut
CONFIGS = [
pytest.param('default', marks=[pytest.mark.supported_targets, pytest.mark.temp_skip_ci(targets=['esp32h2'], reason='test failed')]),
pytest.pa... | 1,831 | 41.604651 | 145 | py |
esp-idf | esp-idf-master/components/esp_mm/test_apps/mmap_hw/pytest_mmap_hw.py | # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.supported_targets
@pytest.mark.generic
@pytest.mark.parametrize(
'config',
[
'release',
],
indirect=True,
)
def test_mmap_hw(du... | 398 | 20 | 71 | py |
esp-idf | esp-idf-master/components/esp_mm/test_apps/mm/pytest_mmap.py | # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
# normal mmu tests
@pytest.mark.supported_targets
@pytest.mark.generic
@pytest.mark.parametrize(
'config',
[
'release',
],
indirect=True,
)
... | 1,897 | 24.306667 | 72 | py |
esp-idf | esp-idf-master/components/heap/test_apps/heap_tests/pytest_heap.py | # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.generic
@pytest.mark.supported_targets
@pytest.mark.nightly_run
@pytest.mark.parametrize(
'config',
[
'no_poisoning',
'light_po... | 3,465 | 21.953642 | 94 | py |
esp-idf | esp-idf-master/components/heap/test_apps/host_test_linux/pytest_heap_linux.py | # SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.linux
@pytest.mark.host_test
def test_heap_linux(dut: Dut) -> None:
dut.expect_exact('Press ENTER to see the list of tests.')
dut.write(... | 370 | 27.538462 | 66 | py |
esp-idf | esp-idf-master/components/esp_netif/test_apps/test_app_esp_netif/pytest_esp_netif.py | # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32c3
@pytest.mark.generic
def test_esp_netif(dut: Dut) -> None:
dut.expect_unity_test_output()
| 287 | 21.153846 | 66 | py |
esp-idf | esp-idf-master/components/esp_netif/test_apps/test_app_vfs_l2tap/pytest_esp_vfs_l2tap.py | # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.esp32
@pytest.mark.ethernet
def test_esp_netif(dut: Dut) -> None:
dut.expect_exact('Press ENTER to see the list of tests')
dut.write('\n')
dut.e... | 413 | 24.875 | 66 | py |
esp-idf | esp-idf-master/docs/conf_common.py | # -*- coding: utf-8 -*-
#
# Common (non-language-specific) configuration for Sphinx
#
# This file is imported from a language-specific conf.py (ie en/conf.py or
# zh_CN/conf.py)
# type: ignore
# pylint: disable=wildcard-import
# pylint: disable=undefined-variable
from __future__ import print_function, unicode_literal... | 13,754 | 45.313131 | 158 | py |
esp-idf | esp-idf-master/docs/en/conf.py | # -*- coding: utf-8 -*-
#
# English Language RTD & Sphinx config file
#
# Uses ../conf_common.py for most non-language-specific settings.
# Importing conf_common adds all the non-language-specific
# parts to this conf module
try:
from conf_common import * # noqa: F403,F401
except ImportError:
import os
im... | 782 | 26.964286 | 84 | py |
esp-idf | esp-idf-master/docs/zh_CN/conf.py | # -*- coding: utf-8 -*-
#
# English Language RTD & Sphinx config file
#
# Uses ../conf_common.py for most non-language-specific settings.
# Importing conf_common adds all the non-language-specific
# parts to this conf module
try:
from conf_common import * # noqa: F403,F401
except ImportError:
import os
im... | 749 | 25.785714 | 74 | py |
destest | destest-master/run_y1.py | import numpy as np
import os
import fitsio as fio
import healpy as hp
import src.catalog as catalog
import src.config as config
import src.fig as fig
import src.lin as lin
import src.sys_split as sys_split
import src.corr as corr
import src.field as field
import src.pz as pz
import src.cosmo as cosmo
import src.y1shear... | 5,641 | 39.589928 | 200 | py |
destest | destest-master/testsuite.py | import numpy as np
import src.catalog as catalog
import src.config as config
import src.fig as fig
import src.lin as lin
import src.sys_split as sys_split
import src.corr as corr
import src.field as field
import src.pz as pz
import src.cosmo as cosmo
# Select columns to read from catalog (no cols option indicates to r... | 4,771 | 44.018868 | 327 | py |
destest | destest-master/src/lin.py | import numpy as np
from scipy.optimize import curve_fit
#import dill
import multiprocessing
import ctypes
import os
import catalog
import config
import fig
import txt
class UseError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
# class single_arg_wra... | 33,803 | 30.770677 | 290 | py |
destest | destest-master/src/field.py | import numpy as np
import fitsio as fio
import catalog
import config
import fig
import txt
import lin
import corr
class field(object):
@staticmethod
def loop_epoch(nbc,val='e',key='e',scale=0.01,catdir='/share/des/disc2/y1/im3shape/single_band/r/y1v1/complete/epoch/',catname='i3',cattype='i3epoch'):
"""
... | 24,943 | 35.682353 | 363 | py |
destest | destest-master/src/setup.py | from distutils.core import setup
from Cython.Distutils import Extension
from Cython.Distutils import build_ext
import cython_gsl
setup(
include_dirs = [cython_gsl.get_include()],
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("a_int_cython",
["a_int_cython.pyx"],... | 550 | 35.733333 | 81 | py |
destest | destest-master/src/txt.py | import numpy as np
import catalog
class write_methods(object):
@staticmethod
def write_append(line,cat,label='',create=False,newline=True):
"""
Text output routine used in many functions to standardise output.
"""
if newline:
n='\n'
print line
else:
n=''
print line,
... | 1,197 | 22.96 | 82 | py |
destest | destest-master/src/sys_split.py | import numpy as np
import fitsio as fio
import healpy as hp
import multiprocessing
import os
import numpy.random as ran
import time
import pickle
import catalog
import config
import fig
import txt
import lin
import corr
import mock
def save_obj(obj, name ):
with open(name, 'wb') as f:
pickle.dump(obj, f, p... | 24,060 | 39.920068 | 315 | py |
destest | destest-master/src/fig.py |
import numpy as np
import matplotlib
matplotlib.use ('agg')
import matplotlib.pyplot as plt
import os
import inspect
# if "NERSC_HOST" in os.environ:
# os.environ['PATH']+=':/usr/common/software/latex/2015/2015/bin/x86_64-linux'
# os.environ['LATEX_DIR']='/usr/common/software/latex/2015/2015'
dirname=os.path.spl... | 50,525 | 39.681159 | 255 | py |
destest | destest-master/src/corr.py | import numpy as np
try:
import treecorr
except:
print "No treecorr"
treecorr=None
import os
if "NERSC_HOST" not in os.environ:
try:
from mpi4py import MPI
except ImportError:
print 'No mpi4py'
else:
print 'No mpi4py'
import scipy
import math
import catalog
import cosmo
import config
import fig
im... | 63,103 | 37.905055 | 578 | py |
destest | destest-master/src/utils.py | import numpy as np
def lowercase_array(x):
if x.dtype.names:
x.dtype.names = tuple(d.lower() for d in x.dtype.names)
| 130 | 20.833333 | 63 | py |
destest | destest-master/src/cosmo.py | import numpy as np
import os
import scipy
import fitsio as fio
import catalog
import config
import fig
import txt
vary = {
'omega_m' : False,
'h0' : False,
'omega_b' : False,
'sigma8_input' : False,
'tau' : False,
'n_s' : False,
'A_s' : False,
'omega_k' : False,
'w' : False,
'wa' : False,
'om... | 40,338 | 37.454719 | 1,133 | py |
destest | destest-master/src/config.py | import numpy as np
# Path definitions
mockdir = '/share/des/sv/BCC-SVA1-WL-v3.0/'
golddir = '/share/des/disc2/y1/gold_v102/'
pzdir = '/share/des/disc2/y1/photo_z/'
pztestdir = '/home/troxel/cosmosis/cosmosis-des-library/photoztests/y1/'
cosmosiscosmodir = '/home/troxel/cosmosis/cosmosis-des-library/wl/y1prep/'
cosmos... | 16,243 | 20.601064 | 116 | py |
destest | destest-master/src/mock.py | import numpy as np
import healpy as hp
import fitsio as fio
import sys_split
import catalog
import config
import lin
try:
import treecorr
except:
print "No treecorr"
treecorr=None
import time
import pickle
import glob
import twopoint as tp
import scipy.optimize as opt
'''
Modified code by Oliver to turn flask ca... | 24,535 | 34.55942 | 247 | py |
destest | destest-master/src/__init__.py | 2 | 0.5 | 1 | py | |
destest | destest-master/src/catalog.py | import numpy as np
import glob
import os
import fitsio as fio
try:
import pandas as pd
except:
print "No Pandas"
pd=None
import time
import config
import pickle
import multiprocessing
import ctypes
noval=999999
t0=time.time()
class CatalogStore(object):
"""
A flexible class that reads and stores shear catal... | 61,953 | 34.46308 | 346 | py |
destest | destest-master/src/y1shearcat.py | import os
import numpy as np
import pickle
import glob
import healpy as hp
import matplotlib
matplotlib.use ('agg')
import matplotlib.pyplot as plt
dirname=os.path.split(__file__)[0]
style_file=os.path.join(dirname, "SVA1StyleSheet.mplstyle")
plt.style.use(style_file)
import matplotlib.cm as cm
from matplotlib.colors i... | 44,385 | 38.17564 | 379 | py |
destest | destest-master/src/pz.py | import numpy as np
import os
import catalog
import lin
import fig
import txt
import cosmo
import config
class pz_methods(object):
@staticmethod
def build_nofz_bins(pz0,label=None,pzref=None,pzlow=0.0,pzhigh=2.5,cat=None,bins=3,split='mean',nztype='pdf',pzmask=None,catmask=None,spec=False,boot=None):
"""
... | 18,887 | 34.437148 | 321 | py |
OPT | OPT-main/src/main.py | import numpy as np
import os
import collections
from os.path import dirname, abspath
from copy import deepcopy
from sacred import Experiment, SETTINGS
from sacred.observers import FileStorageObserver
from sacred.utils import apply_backspaces_and_linefeeds
import sys
import torch as th
from utils.logging import get_logg... | 3,318 | 29.731481 | 121 | py |
OPT | OPT-main/src/run.py | import datetime
import os
import pprint
import time
import threading
import torch as th
from types import SimpleNamespace as SN
from utils.logging import Logger
from utils.timehelper import time_left, time_str
from os.path import dirname, abspath
from learners import REGISTRY as le_REGISTRY
from runners import REGISTR... | 9,273 | 34.945736 | 116 | py |
OPT | OPT-main/src/__init__.py | 0 | 0 | 0 | py | |
OPT | OPT-main/src/modules/__init__.py | 0 | 0 | 0 | py | |
OPT | OPT-main/src/modules/mixers/token_opt_qmix.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from modules.layers import OPTTransformer
class TokenOPTQMixer(nn.Module):
def __init__(self, args):
super(TokenOPTQMixer, self).__init__()
self.args = args
self.state_shape = None
self.token_embedding = nn.Linear... | 2,185 | 33.15625 | 118 | py |
OPT | OPT-main/src/modules/mixers/entity_opt_qmix.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from modules.layers import OPTTransformer
class EntityOPTQMixer(nn.Module):
def __init__(self, args):
super(EntityOPTQMixer, self).__init__()
self.args = args
input_shape = args.entity_shape
if self.args.entity_la... | 2,747 | 36.643836 | 118 | py |
OPT | OPT-main/src/modules/mixers/__init__.py | 0 | 0 | 0 | py | |
OPT | OPT-main/src/modules/agents/entity_opt_agent.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from modules.layers import EntityOPTTransformer
class EntityOPTAgent(nn.Module):
def __init__(self, input_shape, args):
super(EntityOPTAgent, self).__init__()
self.args = args
self.entity_shape = None
self.entity_e... | 3,074 | 37.4375 | 146 | py |
OPT | OPT-main/src/modules/agents/token_opt_agent.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from modules.layers import TokenOPTTransformer
class TokenOPTAgent(nn.Module):
def __init__(self, input_shape, args):
super(TokenOPTAgent, self).__init__()
self.args = args
self.x_shape = None
self.token_embedding ... | 2,410 | 32.957746 | 128 | py |
OPT | OPT-main/src/modules/agents/__init__.py | REGISTRY = {}
from .entity_opt_agent import EntityOPTAgent
REGISTRY["entity_opt_agent"] = EntityOPTAgent
from .token_opt_agent import TokenOPTAgent
REGISTRY["token_opt_agent"] = TokenOPTAgent
| 194 | 23.375 | 45 | py |
OPT | OPT-main/src/modules/layers/entity_opt_attention.py | import torch
import torch.nn as nn
from entmax import sparsemax
import torch.nn.functional as F
from torch.distributions import kl_divergence
from torch.distributions import Categorical
class ScaledDotProductEntityOPTAttention(nn.Module):
def __init__(self, temperature, dropout_attn=0.0):
super().__init__... | 6,584 | 32.426396 | 127 | py |
OPT | OPT-main/src/modules/layers/__init__.py | from .entity_opt_attention import EntityOPTTransformer
from .token_opt_attention import TokenOPTTransformer
from .opt_attention import OPTTransformer
| 150 | 36.75 | 54 | py |
OPT | OPT-main/src/modules/layers/token_opt_attention.py | import torch
import torch.nn as nn
from entmax import sparsemax
import torch.nn.functional as F
from torch.distributions import kl_divergence
from torch.distributions import Categorical
class ScaledDotProductTokenOPTAttention(nn.Module):
def __init__(self, temperature, dropout_attn=0.0):
super().__init__(... | 6,357 | 32.287958 | 126 | py |
OPT | OPT-main/src/modules/layers/opt_attention.py | import torch
import torch.nn as nn
from entmax import sparsemax
import torch.nn.functional as F
class ScaledDotProductOPTAttention(nn.Module):
def __init__(self, temperature, dropout_attn=0.0):
super().__init__()
self.temperature = temperature
self.dropout_attn = nn.Dropout(dropout_attn)
... | 4,856 | 29.54717 | 109 | py |
OPT | OPT-main/src/envs/multiagentenv.py | class MultiAgentEnv(object):
def step(self, actions):
""" Returns reward, terminated, info """
raise NotImplementedError
def get_obs(self):
""" Returns all agent observations in a list """
raise NotImplementedError
def get_obs_agent(self, agent_id):
""" Returns obs... | 1,787 | 28.311475 | 94 | py |
OPT | OPT-main/src/envs/__init__.py | from functools import partial
from .multiagentenv import MultiAgentEnv
from .starcraft2 import StarCraft2Env, StarCraft2MTEnv
from .prey import PreyEnv
import sys
import os
def env_fn(env, **kwargs) -> MultiAgentEnv:
return env(**kwargs)
REGISTRY = {}
REGISTRY["sc2"] = partial(env_fn, env=StarCraft2Env)
REGISTRY[... | 416 | 26.8 | 56 | py |
OPT | OPT-main/src/envs/prey/__init__.py | from .prey import PreyEnv | 25 | 25 | 25 | py |
OPT | OPT-main/src/envs/prey/prey.py | import numpy as np
from numpy.random import RandomState
from ..multiagentenv import MultiAgentEnv
class PreyEnv(MultiAgentEnv):
def __init__(self, map_name="various_all", entity_scheme=True, map_size=12, sight_range=4,
episode_limit=50, seed=None):
super(PreyEnv, self).__init__()
... | 24,093 | 52.542222 | 212 | py |
OPT | OPT-main/src/envs/starcraft2/render.py | import numpy as np
import re
import subprocess
import platform
from absl import logging
import math
import time
import collections
import os
import pygame
import queue
from pysc2.lib import colors
from pysc2.lib import point
from pysc2.lib.renderer_human import _Surface
from pysc2.lib import transform
from pysc2.lib i... | 11,442 | 31.882184 | 79 | py |
OPT | OPT-main/src/envs/starcraft2/starcraft2.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from ..multiagentenv import MultiAgentEnv
from .maps import get_map_params
import atexit
from warnings import warn
from operator import attrgetter
from copy import deepcopy
import numpy as np
import enum
impor... | 70,849 | 36.486772 | 109 | py |
OPT | OPT-main/src/envs/starcraft2/starcraft2mt.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from ..multiagentenv import MultiAgentEnv
from .maps import get_mt_scenario_params
import atexit
import sys
from operator import attrgetter
from copy import deepcopy
import numpy as np
from numpy.random import... | 75,993 | 37.092231 | 133 | py |
OPT | OPT-main/src/envs/starcraft2/__init__.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from .starcraft2 import StarCraft2Env
from .starcraft2mt import StarCraft2MTEnv
from absl import flags
FLAGS = flags.FLAGS
FLAGS(["main.py"])
| 254 | 20.25 | 41 | py |
OPT | OPT-main/src/envs/starcraft2/maps/smac_maps.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from pysc2.maps import lib
class SMACMap(lib.Map):
directory = "SMAC_Maps"
download = "https://github.com/oxwhirl/smac#smac-maps"
players = 2
step_mul = 8
game_steps_per_episode = 0
map_... | 5,162 | 21.158798 | 65 | py |
OPT | OPT-main/src/envs/starcraft2/maps/mt_maps.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from pysc2.maps import lib
from functools import partial
from itertools import combinations_with_replacement, product
class SMACMap(lib.Map):
directory = "SMAC_Maps"
download = "https://github.com/ox... | 6,296 | 41.836735 | 146 | py |
OPT | OPT-main/src/envs/starcraft2/maps/__init__.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from . import smac_maps
from . import mt_maps
def get_map_params(map_name):
map_param_registry = smac_maps.get_smac_map_registry()
return map_param_registry[map_name]
def get_mt_scenario_params(scen... | 455 | 25.823529 | 67 | py |
OPT | OPT-main/src/components/episode_buffer.py | import torch as th
import numpy as np
from types import SimpleNamespace as SN
class EpisodeBatch:
def __init__(self,
scheme,
groups,
batch_size,
max_seq_length,
data=None,
preprocess=None,
device... | 10,894 | 42.75502 | 134 | py |
OPT | OPT-main/src/components/__init__.py | 0 | 0 | 0 | py | |
OPT | OPT-main/src/components/epsilon_schedules.py | import numpy as np
class DecayThenFlatSchedule():
def __init__(self,
start,
finish,
time_length,
decay="exp"):
self.start = start
self.finish = finish
self.time_length = time_length
self.delta = (self.start - sel... | 770 | 27.555556 | 102 | py |
OPT | OPT-main/src/components/action_selectors.py | import torch as th
from torch.distributions import Categorical
from .epsilon_schedules import DecayThenFlatSchedule
REGISTRY = {}
class MultinomialActionSelector():
def __init__(self, args):
self.args = args
self.schedule = DecayThenFlatSchedule(args.epsilon_start, args.epsilon_finish, args.eps... | 2,225 | 32.727273 | 112 | py |
OPT | OPT-main/src/components/transforms.py | import torch as th
class Transform:
def transform(self, tensor):
raise NotImplementedError
def infer_output_info(self, vshape_in, dtype_in):
raise NotImplementedError
class OneHot(Transform):
def __init__(self, out_dim):
self.out_dim = out_dim
def transform(self, tensor):
... | 568 | 24.863636 | 71 | py |
OPT | OPT-main/src/runners/episode_runner.py | from envs import REGISTRY as env_REGISTRY
from functools import partial
from components.episode_buffer import EpisodeBatch
import numpy as np
import time
class EpisodeRunner:
def __init__(self, args, logger):
self.args = args
self.logger = logger
self.batch_size = self.args.batch_size_run... | 4,762 | 34.544776 | 111 | py |
OPT | OPT-main/src/runners/parallel_runner.py | from envs import REGISTRY as env_REGISTRY
from functools import partial
from components.episode_buffer import EpisodeBatch
from multiprocessing import Pipe, Process
import numpy as np
import torch as th
# Based (very) heavily on SubprocVecEnv from OpenAI Baselines
# https://github.com/openai/baselines/blob/master/bas... | 10,322 | 37.518657 | 133 | py |
OPT | OPT-main/src/runners/__init__.py | REGISTRY = {}
from .episode_runner import EpisodeRunner
REGISTRY["episode"] = EpisodeRunner
from .parallel_runner import ParallelRunner
REGISTRY["parallel"] = ParallelRunner
| 176 | 21.125 | 43 | py |
OPT | OPT-main/src/controllers/basic_controller.py | from modules.agents import REGISTRY as agent_REGISTRY
from components.action_selectors import REGISTRY as action_REGISTRY
import torch as th
# This multi-agent controller shares parameters between agents
class BasicMAC:
def __init__(self, scheme, groups, args):
self.n_agents = args.n_agents
self.a... | 4,552 | 40.018018 | 125 | py |
OPT | OPT-main/src/controllers/entity_controller.py | from .basic_controller import BasicMAC
import torch as th
# This multi-agent controller shares parameters between agents
# takes entities + observation masks as input
class EntityMAC(BasicMAC):
def __init__(self, scheme, groups, args):
super(EntityMAC, self).__init__(scheme, groups, args)
def forward... | 2,021 | 38.647059 | 115 | py |
OPT | OPT-main/src/controllers/token_controller.py | from .basic_controller import BasicMAC
import torch as th
# This multi-agent controller shares parameters between agents
class TokenMAC(BasicMAC):
def __init__(self, scheme, groups, args):
super(TokenMAC, self).__init__(scheme, groups, args)
def forward(self, ep_batch, t, test_mode=False):
ag... | 1,697 | 39.428571 | 128 | py |
OPT | OPT-main/src/controllers/__init__.py | REGISTRY = {}
from .basic_controller import BasicMAC
from .token_controller import TokenMAC
from .entity_controller import EntityMAC
REGISTRY["basic_mac"] = BasicMAC
REGISTRY["token_mac"] = TokenMAC
REGISTRY["entity_mac"] = EntityMAC
| 236 | 22.7 | 40 | py |
OPT | OPT-main/src/utils/timehelper.py | import time
import numpy as np
def print_time(start_time, T, t_max, episode, episode_rewards):
time_elapsed = time.time() - start_time
T = max(1, T)
time_left = time_elapsed * (t_max - T) / T
# Just in case its over 100 days
time_left = min(time_left, 60 * 60 * 24 * 100)
last_reward = "N\A"
... | 1,550 | 34.25 | 202 | py |
OPT | OPT-main/src/utils/logging.py | from collections import defaultdict
import logging
import numpy as np
class Logger:
def __init__(self, console_logger):
self.console_logger = console_logger
self.use_tb = False
self.use_sacred = False
self.use_hdf = False
self.stats = defaultdict(lambda: [])
def setup... | 2,097 | 30.787879 | 102 | py |
OPT | OPT-main/src/utils/dict2namedtuple.py | from collections import namedtuple
def convert(dictionary):
return namedtuple('GenericDict', dictionary.keys())(**dictionary)
| 132 | 21.166667 | 69 | py |
OPT | OPT-main/src/utils/rl_utils.py | import torch as th
def build_td_lambda_targets(rewards, terminated, mask, target_qs, n_agents, gamma, td_lambda):
# Assumes <target_qs > in B*T*A and <reward >, <terminated >, <mask > in (at least) B*T-1*1
# Initialise last lambda -return for not terminated episodes
ret = target_qs.new_zeros(*targe... | 774 | 47.4375 | 110 | py |
OPT | OPT-main/src/learners/entity_opt_q_learner.py | import copy
from components.episode_buffer import EpisodeBatch
from modules.mixers.entity_opt_qmix import EntityOPTQMixer
import torch as th
from torch.optim import RMSprop, Adam
class QLearner:
def __init__(self, mac, scheme, logger, args):
self.args = args
self.mac = mac
self.logger = lo... | 8,046 | 43.214286 | 138 | py |
OPT | OPT-main/src/learners/token_opt_q_learner.py | import copy
from components.episode_buffer import EpisodeBatch
from modules.mixers.token_opt_qmix import TokenOPTQMixer
import torch as th
from torch.optim import RMSprop, Adam
class QLearner:
def __init__(self, mac, scheme, logger, args):
self.args = args
self.mac = mac
self.logger = logg... | 8,202 | 45.607955 | 138 | py |
OPT | OPT-main/src/learners/__init__.py | from .entity_opt_q_learner import QLearner as EntityOPTQLearner
from .token_opt_q_learner import QLearner as TokenOPTQLearner
REGISTRY = {}
REGISTRY["entity_opt_q_learner"] = EntityOPTQLearner
REGISTRY["token_opt_q_learner"] = TokenOPTQLearner
| 246 | 29.875 | 63 | py |
fairness-comparison | fairness-comparison-master/setup.py | #!/usr/bin/env python
from setuptools import setup, find_packages
VERSION = '0.1.8'
LICENSE='Apache 2.0'
INSTALL_REQUIRES = [
'cycler==0.10.0',
'decorator==4.0.11',
'matplotlib==2.0.0',
'networkx==1.11',
'numpy==1.14.0',
'pandas==0.21.1',
'scikit-learn==0.18.1',
'scipy==0.19.0',
... | 2,313 | 29.447368 | 96 | py |
fairness-comparison | fairness-comparison-master/__init__.py | name = "fairness"
| 18 | 8.5 | 17 | py |
fairness-comparison | fairness-comparison-master/fairness/benchmark.py | import fire
import os
import pandas as pd
import pathlib
import statistics
import sys
from fairness import results
from fairness.data.objects.list import DATASETS, get_dataset_names
from fairness.data.objects.ProcessedData import ProcessedData
from fairness.algorithms.list import ALGORITHMS
from fairness.metrics.list... | 9,321 | 43.817308 | 122 | py |
fairness-comparison | fairness-comparison-master/fairness/analysis.py | import fire
import pandas as pd
import pathlib
import sys
import subprocess
# The following two lines are needed to resolve an issue with ggplot
import matplotlib
matplotlib.use('TkAgg')
from ggplot import *
from fairness.data.objects.list import DATASETS, get_dataset_names
from fairness.data.objects.ProcessedData i... | 3,982 | 34.247788 | 98 | py |
fairness-comparison | fairness-comparison-master/fairness/get_best_split.py | import fire
import math
import pandas as pd
from fairness.data.objects.Adult import Adult
from fairness.data.objects.ProcessedData import TAGS
def run(algname, data = Adult(), measure = 'accuracy'):
for filename in make_filenames(algname, measure, data):
outfile = filename + '.correctedbest.csv'
o... | 2,451 | 34.028571 | 98 | py |
fairness-comparison | fairness-comparison-master/fairness/results.py | import pathlib
import os
import tempfile
import shutil
from fairness.metrics.list import get_metrics
# FIXME: this could probably be handled better on Windows
def local_results_path():
home = pathlib.Path.home()
path = home / '.fairness'
ensure_dir(path)
print(f'local_results_path: {path}')
return... | 3,628 | 35.656566 | 103 | py |
fairness-comparison | fairness-comparison-master/fairness/__init__.py | from fairness.metrics.list import add_metric
from fairness.data.objects.list import add_dataset, get_dataset_by_name
from fairness.algorithms.list import add_algorithm
| 168 | 41.25 | 71 | py |
fairness-comparison | fairness-comparison-master/fairness/preprocess.py | import sys
import os
import pandas as pd
import fire
from fairness.data.objects.list import DATASETS, get_dataset_names
def prepare_data(dataset_names = get_dataset_names()):
for dataset in DATASETS:
if not dataset.get_dataset_name() in dataset_names:
continue
print("--- Processing dat... | 5,376 | 44.184874 | 100 | py |
fairness-comparison | fairness-comparison-master/fairness/algorithms/ParamGridSearch.py | import math
from fairness.algorithms.Algorithm import Algorithm
class ParamGridSearch(Algorithm):
def __init__(self, algorithm, metric):
Algorithm.__init__(self)
self.algorithm = algorithm
self.name = algorithm.get_name() + "-" + metric.get_name()
# The single metric that will be o... | 3,735 | 45.7 | 96 | py |
fairness-comparison | fairness-comparison-master/fairness/algorithms/Algorithm.py |
class Algorithm():
"""
This is the base class for all implemented algorithms. New algorithms should extend this
class, implement run below, and set self.name in the init method. Other optional methods to
implement are described below.
"""
def __init__(self):
pass
def run(self, t... | 2,788 | 43.983871 | 101 | py |
fairness-comparison | fairness-comparison-master/fairness/algorithms/__init__.py | 0 | 0 | 0 | py | |
fairness-comparison | fairness-comparison-master/fairness/algorithms/list.py | from fairness.algorithms.zafar.ZafarAlgorithm import ZafarAlgorithmBaseline, ZafarAlgorithmAccuracy, ZafarAlgorithmFairness
from fairness.algorithms.kamishima.KamishimaAlgorithm import KamishimaAlgorithm
from fairness.algorithms.kamishima.CaldersAlgorithm import CaldersAlgorithm
from fairness.algorithms.feldman.Feldman... | 2,287 | 46.666667 | 123 | py |
fairness-comparison | fairness-comparison-master/fairness/algorithms/baseline/Random.py | import numpy as np
from fairness.algorithms.baseline.Generic import Generic
class Random(Generic):
"""
Randomly predicts positive or negative class with probability equal to the
positi. If it's predicting a negative, it samples from the non-positive class
values with equal probability.
"""
de... | 1,279 | 33.594595 | 85 | py |
fairness-comparison | fairness-comparison-master/fairness/algorithms/baseline/GaussianNB.py | from sklearn.naive_bayes import GaussianNB as SKLearn_NB
from fairness.algorithms.baseline.Generic import Generic
class GaussianNB(Generic):
def __init__(self):
Generic.__init__(self)
self.classifier = SKLearn_NB()
self.name = "GaussianNB"
| 269 | 29 | 56 | py |
fairness-comparison | fairness-comparison-master/fairness/algorithms/baseline/DecisionTree.py | from sklearn.tree import DecisionTreeClassifier as SKLearn_DT
from fairness.algorithms.baseline.Generic import Generic
class DecisionTree(Generic):
def __init__(self):
Generic.__init__(self)
self.classifier = SKLearn_DT()
self.name = "DecisionTree"
| 278 | 30 | 61 | py |
fairness-comparison | fairness-comparison-master/fairness/algorithms/baseline/LogisticRegression.py | from sklearn.linear_model import LogisticRegression as SKLearn_LR
from fairness.algorithms.baseline.Generic import Generic
class LogisticRegression(Generic):
def __init__(self):
Generic.__init__(self)
self.classifier = SKLearn_LR()
self.name = "LR"
| 278 | 30 | 65 | py |
fairness-comparison | fairness-comparison-master/fairness/algorithms/baseline/SVM.py | from sklearn.svm import SVC as SKLearn_SVM
from fairness.algorithms.baseline.Generic import Generic
class SVM(Generic):
def __init__(self):
Generic.__init__(self)
self.classifier = SKLearn_SVM()
self.name = "SVM"
| 242 | 26 | 56 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.