id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2,289,200 | 中文git.py | DuckDuckStudio_Chinese_git/zh-tw/中文git.py | import subprocess
import sys
import os
script_path = os.path.dirname(__file__)
full_path = os.path.join(script_path, "中文git.py")
def git_command(command, *args):
git_command_mapping = {
"拉取": "pull",
"推送": "push",
"提交": "commit",
"新建分支": "checkout -b",
"切換分支": "checkout",
... | 8,878 | Python | .py | 175 | 29.4 | 120 | 0.475082 | DuckDuckStudio/Chinese_git | 8 | 1 | 6 | GPL-2.0 | 9/5/2024, 10:48:34 PM (Europe/Amsterdam) |
2,289,201 | 中文git-pack.py | DuckDuckStudio_Chinese_git/zh-tw/中文git-pack.py | import subprocess
import sys
import os
script_path = os.path.dirname(__file__)
full_path = os.path.join(script_path, "中文git.exe")
def git_command(command, *args):
git_command_mapping = {
"拉取": "pull",
"推送": "push",
"提交": "commit",
"新建分支": "checkout -b",
"切換分支": "checkout",
... | 8,857 | Python | .py | 175 | 29.377143 | 120 | 0.47311 | DuckDuckStudio/Chinese_git | 8 | 1 | 6 | GPL-2.0 | 9/5/2024, 10:48:34 PM (Europe/Amsterdam) |
2,289,202 | 中文git-pypi.py | DuckDuckStudio_Chinese_git/中文git-pypi.py | import os
import sys
import json
import requests
import subprocess
from colorama import init, Fore
# ----------- 此代码为PyPi专用,非函数代码请写在main()函数中! -----------
# --- 读取配置文件 ---
def fetch_json():
global exit_code
config_url = "https://duckduckstudio.github.io/yazicbs.github.io/Tools/chinese_git/files/json/config.js... | 29,537 | Python | .pyp | 596 | 30.67953 | 252 | 0.501433 | DuckDuckStudio/Chinese_git | 8 | 1 | 6 | GPL-2.0 | 9/5/2024, 10:48:34 PM (Europe/Amsterdam) |
2,289,203 | 中文git_pypi.py | DuckDuckStudio_Chinese_git/ChineseGit/中文git/中文git_pypi.py | import os
import sys
import json
import requests
import subprocess
from colorama import init, Fore
# ----------- 此代码为PyPi专用,非函数代码请写在main()函数中! -----------
# --- 读取配置文件 ---
def fetch_json():
global exit_code
config_url = "https://duckduckstudio.github.io/yazicbs.github.io/Tools/chinese_git/files/json/config.js... | 29,537 | Python | .pyp | 596 | 30.67953 | 252 | 0.501433 | DuckDuckStudio/Chinese_git | 8 | 1 | 6 | GPL-2.0 | 9/5/2024, 10:48:34 PM (Europe/Amsterdam) |
2,289,204 | setup.py | 15525730080_pc_perf/setup.py |
# coding=utf-8
from setuptools import setup, find_packages
setup(
# 包的名称,通常与包的目录名称相同
name='pc-perf',
# 版本号,遵循语义化版本控制规则
version='1.3.2',
# 项目简短描述
description='pc 进程性能测试平台,支持 windows / mac / linux 平台进程cpu、memory、fps(仅支持windows下OpenGL DirectX 引擎应用)、gpu、thread_num、handle_num 等指标的实时监控和可视化展示',
... | 2,371 | Python | .py | 64 | 23.71875 | 148 | 0.580214 | 15525730080/pc_perf | 8 | 1 | 1 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,205 | pc_perf.py | 15525730080_pc_perf/pc_perf.py | import ctypes
import multiprocessing
import os
import platform
import subprocess
import sys
import threading
import time
import webbrowser
def open_url():
time.sleep(2)
webbrowser.open("http://127.0.0.1:20223")
def is_admin():
"""检查是否有管理员权限(仅适用于 Windows)。"""
try:
return ctypes.windll.shell32... | 1,310 | Python | .py | 40 | 25.45 | 140 | 0.667238 | 15525730080/pc_perf | 8 | 1 | 1 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,206 | util.py | 15525730080_pc_perf/app/util.py | import asyncio
import json
from pathlib import Path
import numpy as np
import pandas as pd
from app.log import log as logger
from concurrent.futures import ProcessPoolExecutor, wait
class DataCollect(object):
def __init__(self, save_dir):
self.save_dir = save_dir
self.csv_files: list[Path] = self... | 3,872 | Python | .py | 74 | 39.283784 | 119 | 0.582838 | 15525730080/pc_perf | 8 | 1 | 1 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,207 | task_handle.py | 15525730080_pc_perf/app/task_handle.py | # coding=utf-8
import asyncio
import os
import traceback
from builtins import *
from multiprocessing.context import Process
import psutil
from app.database import TaskCollection
from app.log import log as logger
from app.core.pc_tools import perf as pc_perf
class TaskHandle(Process):
def __init__(self, serialn... | 1,588 | Python | .py | 43 | 29.186047 | 99 | 0.644951 | 15525730080/pc_perf | 8 | 1 | 1 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,208 | log.py | 15525730080_pc_perf/app/log.py | from logging import getLogger, INFO, StreamHandler, Formatter
from concurrent_log_handler import ConcurrentRotatingFileHandler
import os
log = getLogger(__name__)
# Use an absolute path to prevent file rotation trouble.
logfile = os.path.abspath("log.log")
# Rotate log after reaching 512K, keep 5 old copies.
rotateHan... | 648 | Python | .py | 16 | 38.75 | 81 | 0.793269 | 15525730080/pc_perf | 8 | 1 | 1 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,209 | database.py | 15525730080_pc_perf/app/database.py | import asyncio
import datetime
import os
import platform
from sqlalchemy import Column, String, Integer, DateTime, select, or_
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker
from contextlib import asynccontextmanager
from sqlalchemy_serializer import Seriali... | 7,119 | Python | .py | 147 | 36.782313 | 116 | 0.614009 | 15525730080/pc_perf | 8 | 1 | 1 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,210 | view.py | 15525730080_pc_perf/app/view.py | import pyximport
pyximport.install(language_level=3)
import asyncio
import base64
import os
import platform
import shutil
import time
import traceback
from pathlib import Path
from fastapi import FastAPI
from starlette.requests import Request
from starlette.responses import JSONResponse, RedirectResponse
from starlette... | 4,543 | Python | .py | 109 | 35.706422 | 113 | 0.707965 | 15525730080/pc_perf | 8 | 1 | 1 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,211 | monitor.py | 15525730080_pc_perf/app/core/monitor.py | import asyncio
import csv
import inspect
import json
import time
import traceback
from pathlib import Path
from app.log import log as logger
def print_json(data, *args, **kwargs):
data_json = json.dumps(data)
logger.info(data_json, *args, **kwargs)
class MonitorIter(object):
def __init__(self, stop_ev... | 2,513 | Python | .py | 63 | 29.666667 | 89 | 0.567501 | 15525730080/pc_perf | 8 | 1 | 1 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,212 | pc_tools.py | 15525730080_pc_perf/app/core/pc_tools.py | import asyncio
import json
import platform
import subprocess
import threading
import time
import traceback
from io import BytesIO
import psutil
import pynvml
from pathlib import Path
from app.log import log
from app.core.monitor import Monitor
SUPPORT_GPU = True
try:
pynvml.nvmlInit()
except:
log.error(traceba... | 9,888 | Python | .py | 239 | 29.531381 | 119 | 0.556323 | 15525730080/pc_perf | 8 | 1 | 1 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,213 | ensemble.py | huchenlei_sd-webui-controlnet-marigold/marigold/util/ensemble.py | # Test align depth images
# Author: Bingxin Ke
# Last modified: 2023-12-11
import numpy as np
import torch
from scipy.optimize import minimize
def inter_distances(tensors):
"""
To calculate the distance between each two depth maps.
"""
distances = []
for i, j in torch.combinations(torch.arange(te... | 3,688 | Python | .py | 87 | 34.942529 | 144 | 0.62156 | huchenlei/sd-webui-controlnet-marigold | 8 | 0 | 2 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,214 | image_util.py | huchenlei_sd-webui-controlnet-marigold/marigold/util/image_util.py |
import matplotlib
import numpy as np
import torch
from PIL import Image
def colorize_depth_maps(depth_map, min_depth, max_depth, cmap='Spectral', valid_mask=None):
"""
Colorize depth maps.
"""
assert len(depth_map.shape) >= 2, "Invalid dimension"
if isinstance(depth_map, torch.Tensor):
... | 2,149 | Python | .py | 50 | 35.92 | 103 | 0.642857 | huchenlei/sd-webui-controlnet-marigold | 8 | 0 | 2 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,215 | batchsize.py | huchenlei_sd-webui-controlnet-marigold/marigold/util/batchsize.py | # Author: Bingxin Ke
# Last modified: 2023-12-11
import torch
import math
# Search table for suggested max. inference batch size
bs_search_table = [
# tested on A100-PCIE-80GB
{"res": 768, "total_vram": 79, "bs": 35},
{"res": 1024, "total_vram": 79, "bs": 20},
# tested on A100-PCIE-40GB
{"res": 7... | 1,205 | Python | .py | 31 | 32.548387 | 88 | 0.558419 | huchenlei/sd-webui-controlnet-marigold | 8 | 0 | 2 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,216 | seed_all.py | huchenlei_sd-webui-controlnet-marigold/marigold/util/seed_all.py |
import numpy as np
import random
import torch
def seed_all(seed: int = 0):
"""
Set random seeds of all components.
"""
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed) | 245 | Python | .py | 11 | 18.545455 | 39 | 0.689655 | huchenlei/sd-webui-controlnet-marigold | 8 | 0 | 2 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,217 | stacked_depth_AE.py | huchenlei_sd-webui-controlnet-marigold/marigold/model/stacked_depth_AE.py | # Author: Bingxin Ke
# Last modified: 2023-12-05
import torch
import torch.nn as nn
import logging
from diffusers import AutoencoderKL
class StackedDepthAE(nn.Module):
"""
Tailored pretrained image VAE for depth map.
Encode: Depth images are repeated into 3 channels.
Decode: The average of 3 ... | 1,640 | Python | .py | 42 | 31.833333 | 101 | 0.646948 | huchenlei/sd-webui-controlnet-marigold | 8 | 0 | 2 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,218 | rgb_encoder.py | huchenlei_sd-webui-controlnet-marigold/marigold/model/rgb_encoder.py | # Author: Bingxin Ke
# Last modified: 2023-12-05
import torch
import torch.nn as nn
import logging
from diffusers import AutoencoderKL
class RGBEncoder(nn.Module):
"""
The encoder of pretrained Stable Diffusion VAE
"""
def __init__(self, pretrained_path, subfolder=None) -> None:
super().... | 994 | Python | .py | 27 | 29 | 96 | 0.64617 | huchenlei/sd-webui-controlnet-marigold | 8 | 0 | 2 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,219 | marigold_pipeline.py | huchenlei_sd-webui-controlnet-marigold/marigold/model/marigold_pipeline.py | # Author: Bingxin Ke
# Last modified: 2023-12-11
import logging
from typing import Dict
import numpy as np
import torch
from diffusers import (
DDIMScheduler,
DDPMScheduler,
PNDMScheduler,
DEISMultistepScheduler,
SchedulerMixin,
UNet2DConditionModel,
)
from torch import nn
from torch.nn import... | 11,755 | Python | .py | 282 | 30.907801 | 104 | 0.595626 | huchenlei/sd-webui-controlnet-marigold | 8 | 0 | 2 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,220 | preprocessor_marigold.py | huchenlei_sd-webui-controlnet-marigold/scripts/preprocessor_marigold.py | import torch
import numpy as np
from marigold.model.marigold_pipeline import MarigoldPipeline
# sd-webui-controlnet
from internal_controlnet.external_code import Preprocessor, PreprocessorParameter
from scripts.utils import resize_image_with_pad
# A1111
from modules import devices
@torch.no_grad()
@torch.inference... | 2,725 | Python | .py | 79 | 25.443038 | 87 | 0.591635 | huchenlei/sd-webui-controlnet-marigold | 8 | 0 | 2 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,221 | stacked_depth_AE.py | huchenlei_sd-webui-controlnet-marigold/marigold/model/stacked_depth_AE.py | # Author: Bingxin Ke
# Last modified: 2023-12-05
import torch
import torch.nn as nn
import logging
from diffusers import AutoencoderKL
class StackedDepthAE(nn.Module):
"""
Tailored pretrained image VAE for depth map.
Encode: Depth images are repeated into 3 channels.
Decode: The average of 3 ... | 1,640 | Python | .tac | 42 | 31.833333 | 101 | 0.646948 | huchenlei/sd-webui-controlnet-marigold | 8 | 0 | 2 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,222 | sunoise.py | bvhari_ComfyUI_SUNoise/sunoise.py | import comfy.samplers
import comfy.model_patcher
from comfy.k_diffusion.sampling import get_ancestral_step, to_d, BrownianTreeNoiseSampler
import torch
import numpy as np
from tqdm.auto import trange
def su_noise_sampler(x, _seed, noise_type):
def scaled_uniform_noise_multires(sigma_down):
ran... | 25,830 | Python | .py | 455 | 45.641758 | 181 | 0.573585 | bvhari/ComfyUI_SUNoise | 8 | 3 | 0 | GPL-3.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,223 | setup.py | WindyLab_Gym-PPS/setup.py | import os.path
import sys
from setuptools import find_packages, setup
# Don't import gym module here, since deps may not be installed
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "gym"))
from version import VERSION
# Environment-specific dependencies.
extras = {
"atari": ["atari-py==0.2.6", "openc... | 2,239 | Python | .py | 68 | 26.352941 | 83 | 0.583179 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,224 | custom_env.py | WindyLab_Gym-PPS/NJP_algorithm/custom_env.py | import gym
from gym import spaces
import numpy as np
"""Define your own Observation and Reward in this script:
You may use the following properties to define your observation/reward functions:
self.env.p, dp, ddp, theta, heading, d_b2b_center, is_collide_b2b, energy
"""
class MyObs(gym.ObservationWrapper):
def ... | 3,491 | Python | .py | 61 | 46.131148 | 160 | 0.564148 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,225 | arguments.py | WindyLab_Gym-PPS/NJP_algorithm/arguments.py | '''
Specify parameters of the env
'''
from typing import Union
import numpy as np
import argparse
parser = argparse.ArgumentParser("Gym-PredatorPreySwarm Arguments")
## ==================== User settings ===================='''
parser.add_argument("--n-p", type=int, default=0, help='number of predators')
parser.add_... | 3,412 | Python | .py | 48 | 69.020833 | 136 | 0.688637 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,226 | custom_param.py | WindyLab_Gym-PPS/NJP_algorithm/custom_param.py | '''
Specify parameters of the PredatorPreySwarm environment
'''
from typing import Union
import numpy as np
import argparse
parser = argparse.ArgumentParser("Gym-PredatorPreySwarm Arguments")
parser.add_argument("--n-p", type=int, default=3, help='number of predators')
parser.add_argument("--n-e", type=int, default=... | 884 | Python | .py | 14 | 61.428571 | 136 | 0.737875 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,227 | testmodel .py | WindyLab_Gym-PPS/NJP_algorithm/testmodel .py | import argparse
import torch
import time
import os
import numpy as np
import gym
from gym.wrappers import NJP
from arguments import gpsargs as args
from gym.wrappers import PredatorPreySwarmCustomizer
from gym.spaces import Box, Discrete
from torch.autograd import Variable
from algorithms.maddpg import MADDPG
from path... | 5,478 | Python | .py | 114 | 39.131579 | 161 | 0.633358 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,228 | main.py | WindyLab_Gym-PPS/NJP_algorithm/main.py | import argparse
import torch
import time
import os
import numpy as np
import gym
from gym.wrappers import NJP
from arguments import gpsargs as args
from gym.spaces import Box, Discrete
from torch.autograd import Variable
from algorithms.maddpg import MADDPG
from pathlib import Path
from utils.buffer import ReplayBuffer... | 7,986 | Python | .py | 148 | 42.445946 | 169 | 0.60121 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,229 | maddpg.py | WindyLab_Gym-PPS/NJP_algorithm/algorithms/maddpg.py | import torch
import torch.nn.functional as F
from gym.spaces import Box, Discrete
from utils.networks import MLPNetwork
from utils.misc import soft_update, average_gradients, onehot_from_logits, gumbel_softmax
from utils.agents import DDPGAgent
MSELoss = torch.nn.MSELoss()
class MADDPG(object):
"""
Wrapper cl... | 9,862 | Python | .py | 211 | 33.407583 | 157 | 0.561178 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,230 | networks.py | WindyLab_Gym-PPS/NJP_algorithm/utils/networks.py | import torch.nn as nn
import torch.nn.functional as F
class MLPNetwork(nn.Module):
"""
MLP network (can be used as value or policy)
"""
def __init__(self, input_dim, out_dim, hidden_dim=64, nonlin=F.relu,
constrain_out=False, norm_in=False, discrete_action=False):
"""
I... | 1,535 | Python | .py | 39 | 30.25641 | 77 | 0.593039 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,231 | buffer.py | WindyLab_Gym-PPS/NJP_algorithm/utils/buffer.py | import numpy as np
from torch import Tensor
from torch.autograd import Variable
class ReplayBuffer(object):
"""
Replay Buffer for multi-agent RL with parallel rollouts
"""
def __init__(self, max_steps, num_agents, start_stop_index, state_dim, action_dim):
"""
Inputs:
max_ste... | 5,453 | Python | .py | 101 | 39.742574 | 125 | 0.562906 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,232 | noise.py | WindyLab_Gym-PPS/NJP_algorithm/utils/noise.py | import numpy as np
# from https://github.com/songrotek/DDPG/blob/master/ou_noise.py
class OUNoise:
def __init__(self, action_dimension, scale=0.1, mu=0, theta=0.15, sigma=0.2):
self.action_dimension = action_dimension
self.scale = scale
self.mu = mu
self.theta = theta
self.... | 979 | Python | .py | 26 | 29.923077 | 81 | 0.629153 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,233 | agents.py | WindyLab_Gym-PPS/NJP_algorithm/utils/agents.py | from torch import Tensor
from torch.autograd import Variable
from torch.optim import Adam
from .networks import MLPNetwork
from .misc import hard_update, gumbel_softmax, onehot_from_logits
from .noise import OUNoise, GaussianNoise
import numpy as np
class DDPGAgent(object):
"""
General class for DD... | 4,700 | Python | .py | 93 | 36.645161 | 159 | 0.584568 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,234 | misc.py | WindyLab_Gym-PPS/NJP_algorithm/utils/misc.py | import os
import torch
import torch.nn.functional as F
import torch.distributed as dist
from torch.autograd import Variable
import numpy as np
# https://github.com/ikostrikov/pytorch-ddpg-naf/blob/master/ddpg.py#L11
def soft_update(target, source, tau):
"""
Perform DDPG soft update (move target params toward s... | 4,208 | Python | .py | 84 | 43.833333 | 109 | 0.705326 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,235 | lint_python.yml | WindyLab_Gym-PPS/.github/workflows/lint_python.yml | name: lint_python
on: [pull_request, push]
jobs:
lint_python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install isort mypy pytest pyupgrade safety
- run: isort --check-only --profile black . || true
- run: pip install -e ... | 544 | Python | .py | 15 | 31 | 71 | 0.620038 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,236 | test_manipulate.py | WindyLab_Gym-PPS/tests/gym/envs/robotics/hand/test_manipulate.py | import pickle
import unittest
import pytest
from gym import envs
from gym.envs.tests.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE
ENVIRONMENT_IDS = (
"HandManipulateEgg-v0",
"HandManipulatePen-v0",
"HandManipulateBlock-v0",
)
@pytest.mark.skipif(skip_mujoco, reason=SKIP_MUJOCO_WARNING_MES... | 683 | Python | .py | 20 | 30.4 | 77 | 0.757622 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,237 | test_reach.py | WindyLab_Gym-PPS/tests/gym/envs/robotics/hand/test_reach.py | import pickle
import pytest
from gym import envs
from gym.envs.tests.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE
@pytest.mark.skipif(skip_mujoco, reason=SKIP_MUJOCO_WARNING_MESSAGE)
def test_serialize_deserialize():
env1 = envs.make("HandReach-v0", distance_threshold=1e-6)
env1.reset()
env... | 495 | Python | .py | 13 | 33.923077 | 77 | 0.754717 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,238 | test_manipulate_touch_sensors.py | WindyLab_Gym-PPS/tests/gym/envs/robotics/hand/test_manipulate_touch_sensors.py | import pickle
import pytest
from gym import envs
from gym.envs.tests.spec_list import skip_mujoco, SKIP_MUJOCO_WARNING_MESSAGE
ENVIRONMENT_IDS = (
"HandManipulateEggTouchSensors-v1",
"HandManipulatePenTouchSensors-v0",
"HandManipulateBlockTouchSensors-v0",
)
@pytest.mark.skipif(skip_mujoco, reason=SKI... | 703 | Python | .py | 19 | 33.105263 | 77 | 0.766617 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,239 | nested_dict_test.py | WindyLab_Gym-PPS/tests/gym/wrappers/nested_dict_test.py | """Tests for the filter observation wrapper."""
import pytest
import numpy as np
import gym
from gym.spaces import Dict, Box, Discrete, Tuple
from gym.wrappers import FilterObservation, FlattenObservation
class FakeEnvironment(gym.Env):
def __init__(self, observation_space):
self.observation_space = ob... | 3,924 | Python | .py | 103 | 27.504854 | 88 | 0.538502 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,240 | flatten_test.py | WindyLab_Gym-PPS/tests/gym/wrappers/flatten_test.py | """Tests for the flatten observation wrapper."""
from collections import OrderedDict
import numpy as np
import pytest
import gym
from gym.spaces import Box, Dict, unflatten, flatten
from gym.wrappers import FlattenObservation
class FakeEnvironment(gym.Env):
def __init__(self, observation_space):
self.o... | 3,188 | Python | .py | 79 | 30.78481 | 88 | 0.603816 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,241 | error.py | WindyLab_Gym-PPS/gym/error.py | import sys
class Error(Exception):
pass
# Local errors
class Unregistered(Error):
"""Raised when the user requests an item from the registry that does
not actually exist.
"""
pass
class UnregisteredEnv(Unregistered):
"""Raised when the user requests an env from the registry that does
... | 4,565 | Python | .py | 149 | 24.208054 | 75 | 0.651302 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,242 | __init__.py | WindyLab_Gym-PPS/gym/__init__.py | import distutils.version
import os
import sys
import warnings
from gym import error
from gym.version import VERSION as __version__
from gym.core import (
Env,
GoalEnv,
Wrapper,
ObservationWrapper,
ActionWrapper,
RewardWrapper,
)
from gym.spaces import Space
from gym.envs import make, spec, reg... | 464 | Python | .py | 20 | 20.85 | 65 | 0.759637 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,243 | logger.py | WindyLab_Gym-PPS/gym/logger.py | import warnings
from gym.utils import colorize
DEBUG = 10
INFO = 20
WARN = 30
ERROR = 40
DISABLED = 50
MIN_LEVEL = 30
def set_level(level):
"""
Set logging threshold on current logger.
"""
global MIN_LEVEL
MIN_LEVEL = level
def debug(msg, *args):
if MIN_LEVEL <= DEBUG:
print("%s: ... | 725 | Python | .py | 28 | 21.928571 | 74 | 0.602639 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,244 | core.py | WindyLab_Gym-PPS/gym/core.py | from abc import abstractmethod
import gym
from gym import error
# from gym.utils import closer
class Env(object):
"""The main OpenAI Gym class. It encapsulates an environment with
arbitrary behind-the-scenes dynamics. An environment can be
partially or fully observed.
The main API methods that users... | 10,904 | Python | .py | 241 | 36.224066 | 120 | 0.650983 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,245 | play.py | WindyLab_Gym-PPS/gym/utils/play.py | import gym
import pygame
import matplotlib
import argparse
from gym import logger
try:
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
except ImportError as e:
logger.warn("failed to set matplotlib backend, plotting will not work: %s" % str(e))
plt = None
from collections import deque
from pyg... | 6,639 | Python | .py | 163 | 31.576687 | 88 | 0.606239 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,246 | json_utils.py | WindyLab_Gym-PPS/gym/utils/json_utils.py | import numpy as np
def json_encode_np(obj):
"""
JSON can't serialize numpy types, so convert to pure python
"""
if isinstance(obj, np.ndarray):
return list(obj)
elif isinstance(obj, np.float32):
return float(obj)
elif isinstance(obj, np.float64):
return float(obj)
e... | 583 | Python | .py | 21 | 21.52381 | 63 | 0.632143 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,247 | colorize.py | WindyLab_Gym-PPS/gym/utils/colorize.py | """A set of common utilities used within the environments. These are
not intended as API functions, and will not remain stable over time.
"""
color2num = dict(
gray=30,
red=31,
green=32,
yellow=33,
blue=34,
magenta=35,
cyan=36,
white=37,
crimson=38,
)
def colorize(string, color, b... | 753 | Python | .py | 28 | 22.321429 | 70 | 0.651872 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,248 | seeding.py | WindyLab_Gym-PPS/gym/utils/seeding.py | import hashlib
import numpy as np
import os
import random as _random
import struct
import sys
from gym import error
def np_random(seed=None):
if seed is not None and not (isinstance(seed, int) and 0 <= seed):
raise error.Error(
"Seed must be a non-negative integer or omitted, not {}".format(s... | 3,120 | Python | .py | 78 | 34.397436 | 95 | 0.67218 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,249 | atomic_write.py | WindyLab_Gym-PPS/gym/utils/atomic_write.py | # Based on http://stackoverflow.com/questions/2333872/atomic-writing-to-file-with-python
import os
from contextlib import contextmanager
# We would ideally atomically replace any existing file with the new
# version. However, on Windows there's no Python-only solution prior
# to Python 3.3. (This library includes a C... | 1,955 | Python | .py | 50 | 32.94 | 199 | 0.675462 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,250 | ezpickle.py | WindyLab_Gym-PPS/gym/utils/ezpickle.py | class EzPickle(object):
"""Objects that are pickled and unpickled via their constructor
arguments.
Example usage:
class Dog(Animal, EzPickle):
def __init__(self, furcolor, tailkind="bushy"):
Animal.__init__()
EzPickle.__init__(furcolor, tailkind)
... | 1,088 | Python | .py | 26 | 33.346154 | 88 | 0.61327 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,251 | closer.py | WindyLab_Gym-PPS/gym/utils/closer.py | import atexit
import threading
import weakref
class Closer(object):
"""A registry that ensures your objects get closed, whether manually,
upon garbage collection, or upon exit. To work properly, your
objects need to cooperate and do something like the following:
```
closer = Closer()
class Ex... | 2,020 | Python | .py | 53 | 29.886792 | 131 | 0.630123 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,252 | __init__.py | WindyLab_Gym-PPS/gym/utils/__init__.py | """A set of common utilities used within the environments. These are
not intended as API functions, and will not remain stable over time.
"""
# These submodules should not have any import-time dependencies.
# We want this since we use `utils` during our import-time sanity checks
# that verify that our dependencies are... | 421 | Python | .py | 9 | 45.555556 | 72 | 0.804878 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,253 | env_checker.py | WindyLab_Gym-PPS/gym/utils/env_checker.py | """
This file is originally from the Stable Baselines3 repository hosted on GitHub
(https://github.com/DLR-RM/stable-baselines3/)
Original Author: Antonin Raffin
It also uses some warnings/assertions from the PettingZoo repository hosted on GitHub
(https://github.com/PettingZoo-Team/PettingZoo)
Original Author: Justin... | 13,259 | Python | .py | 284 | 39.257042 | 118 | 0.661509 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,254 | test_seeding.py | WindyLab_Gym-PPS/gym/utils/tests/test_seeding.py | from gym import error
from gym.utils import seeding
def test_invalid_seeds():
for seed in [-1, "test"]:
try:
seeding.np_random(seed)
except error.Error:
pass
else:
assert False, "Invalid seed {} passed validation".format(seed)
def test_valid_seeds():
... | 420 | Python | .py | 14 | 22.714286 | 74 | 0.604478 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,255 | test_atexit.py | WindyLab_Gym-PPS/gym/utils/tests/test_atexit.py | from gym.utils.closer import Closer
class Closeable(object):
close_called = False
def close(self):
self.close_called = True
def test_register_unregister():
registry = Closer(atexit_register=False)
c1 = Closeable()
c2 = Closeable()
assert not c1.close_called
assert not c2.close_... | 494 | Python | .py | 17 | 24.117647 | 44 | 0.712766 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,256 | test_env_checker.py | WindyLab_Gym-PPS/gym/utils/tests/test_env_checker.py | import gym
import numpy as np
import pytest
from gym.spaces import Box, Dict, Discrete
from gym.utils.env_checker import check_env
class ActionDictTestEnv(gym.Env):
action_space = Dict({"position": Discrete(1), "velocity": Discrete(1)})
observation_space = Box(low=-1.0, high=2.0, shape=(3,), dtype=np.float32... | 983 | Python | .py | 26 | 31.538462 | 85 | 0.648734 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,257 | test_core.py | WindyLab_Gym-PPS/gym/tests/test_core.py | from gym import core
class ArgumentEnv(core.Env):
calls = 0
def __init__(self, arg):
self.calls += 1
self.arg = arg
def test_env_instantiation():
# This looks like a pretty trivial, but given our usage of
# __new__, it's worth having.
env = ArgumentEnv("arg")
assert env.arg ... | 355 | Python | .py | 12 | 24.5 | 62 | 0.627219 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,258 | registration.py | WindyLab_Gym-PPS/gym/envs/registration.py | import re
import copy
import importlib
from gym import error, logger
# This format is true today, but it's *not* an official spec.
# [username/](env-name)-v(version) env-name is group 1, version is group 2
#
# 2016-10-31: We're experimentally expanding the environment ID format
# to include an optional username.
e... | 6,475 | Python | .py | 159 | 30.194969 | 189 | 0.581543 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,259 | __init__.py | WindyLab_Gym-PPS/gym/envs/__init__.py | from gym.envs.registration import registry, register, make, spec
# Classic
# ----------------------------------------
register(
id="CartPole-v0",
entry_point="gym.envs.classic_control:CartPoleEnv",
max_episode_steps=200,
reward_threshold=195.0,
)
register(
id="CartPole-v1",
entry_point="gym.e... | 21,354 | Python | .py | 737 | 21.537313 | 90 | 0.589279 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,260 | fetch_env.py | WindyLab_Gym-PPS/gym/envs/robotics/fetch_env.py | import numpy as np
from gym.envs.robotics import rotations, robot_env, utils
def goal_distance(goal_a, goal_b):
assert goal_a.shape == goal_b.shape
return np.linalg.norm(goal_a - goal_b, axis=-1)
class FetchEnv(robot_env.RobotEnv):
"""Superclass for all Fetch environments."""
def __init__(
... | 8,927 | Python | .py | 201 | 33.895522 | 127 | 0.592043 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,261 | hand_env.py | WindyLab_Gym-PPS/gym/envs/robotics/hand_env.py | import os
import copy
import numpy as np
import gym
from gym import error, spaces
from gym.utils import seeding
from gym.envs.robotics import robot_env
class HandEnv(robot_env.RobotEnv):
def __init__(self, model_path, n_substeps, initial_qpos, relative_control):
self.relative_control = relative_control
... | 2,153 | Python | .py | 51 | 32.333333 | 79 | 0.576206 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,262 | robot_env.py | WindyLab_Gym-PPS/gym/envs/robotics/robot_env.py | import os
import copy
import numpy as np
import gym
from gym import error, spaces
from gym.utils import seeding
try:
import mujoco_py
except ImportError as e:
raise error.DependencyNotInstalled(
"{}. (HINT: you need to install mujoco_py, and also perform the setup instructions here: https://github.com... | 6,244 | Python | .py | 151 | 32.086093 | 144 | 0.60033 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,263 | utils.py | WindyLab_Gym-PPS/gym/envs/robotics/utils.py | import numpy as np
from gym import error
try:
import mujoco_py
except ImportError as e:
raise error.DependencyNotInstalled(
"{}. (HINT: you need to install mujoco_py, and also perform the setup instructions here: https://github.com/openai/mujoco-py/.)".format(
e
)
)
def robot... | 3,653 | Python | .py | 84 | 35.714286 | 144 | 0.630912 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,264 | __init__.py | WindyLab_Gym-PPS/gym/envs/robotics/__init__.py | from gym.envs.robotics.fetch_env import FetchEnv
from gym.envs.robotics.fetch.slide import FetchSlideEnv
from gym.envs.robotics.fetch.pick_and_place import FetchPickAndPlaceEnv
from gym.envs.robotics.fetch.push import FetchPushEnv
from gym.envs.robotics.fetch.reach import FetchReachEnv
from gym.envs.robotics.hand.reac... | 767 | Python | .py | 12 | 62.75 | 84 | 0.877822 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,265 | rotations.py | WindyLab_Gym-PPS/gym/envs/robotics/rotations.py | # Copyright (c) 2009-2017, Matthew Brett and Christoph Gohlke
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright... | 13,271 | Python | .py | 320 | 36.425 | 85 | 0.597252 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,266 | manipulate.py | WindyLab_Gym-PPS/gym/envs/robotics/hand/manipulate.py | import os
import numpy as np
from gym import utils, error
from gym.envs.robotics import rotations, hand_env
from gym.envs.robotics.utils import robot_get_obs
try:
import mujoco_py
except ImportError as e:
raise error.DependencyNotInstalled(
"{}. (HINT: you need to install mujoco_py, and also perform t... | 15,503 | Python | .py | 313 | 38.750799 | 144 | 0.606113 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,267 | reach.py | WindyLab_Gym-PPS/gym/envs/robotics/hand/reach.py | import os
import numpy as np
from gym import utils
from gym.envs.robotics import hand_env
from gym.envs.robotics.utils import robot_get_obs
FINGERTIP_SITE_NAMES = [
"robot0:S_fftip",
"robot0:S_mftip",
"robot0:S_rftip",
"robot0:S_lftip",
"robot0:S_thtip",
]
DEFAULT_INITIAL_QPOS = {
"robot0:W... | 5,635 | Python | .py | 134 | 34.134328 | 89 | 0.632079 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,268 | manipulate_touch_sensors.py | WindyLab_Gym-PPS/gym/envs/robotics/hand/manipulate_touch_sensors.py | import os
import numpy as np
from gym import utils, error, spaces
from gym.envs.robotics.hand import manipulate
# Ensure we get the path separator correct on windows
MANIPULATE_BLOCK_XML = os.path.join("hand", "manipulate_block_touch_sensors.xml")
MANIPULATE_EGG_XML = os.path.join("hand", "manipulate_egg_touch_sensor... | 7,929 | Python | .py | 188 | 30.904255 | 104 | 0.580808 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,269 | slide.py | WindyLab_Gym-PPS/gym/envs/robotics/fetch/slide.py | import os
import numpy as np
from gym import utils
from gym.envs.robotics import fetch_env
# Ensure we get the path separator correct on windows
MODEL_XML_PATH = os.path.join("fetch", "slide.xml")
class FetchSlideEnv(fetch_env.FetchEnv, utils.EzPickle):
def __init__(self, reward_type="sparse"):
initial... | 1,055 | Python | .py | 30 | 25.733333 | 66 | 0.563725 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,270 | push.py | WindyLab_Gym-PPS/gym/envs/robotics/fetch/push.py | import os
from gym import utils
from gym.envs.robotics import fetch_env
# Ensure we get the path separator correct on windows
MODEL_XML_PATH = os.path.join("fetch", "push.xml")
class FetchPushEnv(fetch_env.FetchEnv, utils.EzPickle):
def __init__(self, reward_type="sparse"):
initial_qpos = {
... | 1,013 | Python | .py | 29 | 25.241379 | 67 | 0.561224 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,271 | pick_and_place.py | WindyLab_Gym-PPS/gym/envs/robotics/fetch/pick_and_place.py | import os
from gym import utils
from gym.envs.robotics import fetch_env
# Ensure we get the path separator correct on windows
MODEL_XML_PATH = os.path.join("fetch", "pick_and_place.xml")
class FetchPickAndPlaceEnv(fetch_env.FetchEnv, utils.EzPickle):
def __init__(self, reward_type="sparse"):
initial_qpo... | 1,031 | Python | .py | 29 | 25.862069 | 67 | 0.567134 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,272 | reach.py | WindyLab_Gym-PPS/gym/envs/robotics/fetch/reach.py | import os
from gym import utils
from gym.envs.robotics import fetch_env
# Ensure we get the path separator correct on windows
MODEL_XML_PATH = os.path.join("fetch", "reach.xml")
class FetchReachEnv(fetch_env.FetchEnv, utils.EzPickle):
def __init__(self, reward_type="sparse"):
initial_qpos = {
... | 948 | Python | .py | 28 | 24.285714 | 62 | 0.573144 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,273 | humanoidstandup.py | WindyLab_Gym-PPS/gym/envs/mujoco/humanoidstandup.py | from gym.envs.mujoco import mujoco_env
from gym import utils
import numpy as np
class HumanoidStandupEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
mujoco_env.MujocoEnv.__init__(self, "humanoidstandup.xml", 5)
utils.EzPickle.__init__(self)
def _get_obs(self):
data = se... | 1,931 | Python | .py | 56 | 23.767857 | 88 | 0.534547 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,274 | ant.py | WindyLab_Gym-PPS/gym/envs/mujoco/ant.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
class AntEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
mujoco_env.MujocoEnv.__init__(self, "ant.xml", 5)
utils.EzPickle.__init__(self)
def step(self, a):
xposbefore = self.get_body_com("to... | 1,842 | Python | .py | 50 | 26.92 | 82 | 0.550952 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,275 | thrower.py | WindyLab_Gym-PPS/gym/envs/mujoco/thrower.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
class ThrowerEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
utils.EzPickle.__init__(self)
self._ball_hit_ground = False
self._ball_hit_location = None
mujoco_env.MujocoEnv.__init__(self,... | 2,151 | Python | .py | 56 | 28.428571 | 87 | 0.554702 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,276 | hopper_v3.py | WindyLab_Gym-PPS/gym/envs/mujoco/hopper_v3.py | import numpy as np
from gym.envs.mujoco import mujoco_env
from gym import utils
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 2,
"distance": 3.0,
"lookat": np.array((0.0, 0.0, 1.15)),
"elevation": -20.0,
}
class HopperEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(
self,
xml_... | 4,190 | Python | .py | 104 | 31.548077 | 84 | 0.619541 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,277 | walker2d_v3.py | WindyLab_Gym-PPS/gym/envs/mujoco/walker2d_v3.py | import numpy as np
from gym.envs.mujoco import mujoco_env
from gym import utils
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 2,
"distance": 4.0,
"lookat": np.array((0.0, 0.0, 1.15)),
"elevation": -20.0,
}
class Walker2dEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(
self,
xm... | 3,881 | Python | .py | 99 | 30.494949 | 79 | 0.618768 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,278 | humanoid_v3.py | WindyLab_Gym-PPS/gym/envs/mujoco/humanoid_v3.py | import numpy as np
from gym.envs.mujoco import mujoco_env
from gym import utils
DEFAULT_CAMERA_CONFIG = {
"trackbodyid": 1,
"distance": 4.0,
"lookat": np.array((0.0, 0.0, 2.0)),
"elevation": -20.0,
}
def mass_center(model, sim):
mass = np.expand_dims(model.body_mass, axis=1)
xpos = sim.data.... | 5,206 | Python | .py | 130 | 30.8 | 85 | 0.610825 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,279 | swimmer.py | WindyLab_Gym-PPS/gym/envs/mujoco/swimmer.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
class SwimmerEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
mujoco_env.MujocoEnv.__init__(self, "swimmer.xml", 4)
utils.EzPickle.__init__(self)
def step(self, a):
ctrl_cost_coeff = 0.0001
... | 1,179 | Python | .py | 29 | 32.586207 | 86 | 0.614847 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,280 | mujoco_env.py | WindyLab_Gym-PPS/gym/envs/mujoco/mujoco_env.py | from collections import OrderedDict
import os
from gym import error, spaces
from gym.utils import seeding
import numpy as np
from os import path
import gym
try:
import mujoco_py
except ImportError as e:
raise error.DependencyNotInstalled(
"{}. (HINT: you need to install mujoco_py, and also perform th... | 6,358 | Python | .py | 159 | 30.528302 | 144 | 0.592827 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,281 | striker.py | WindyLab_Gym-PPS/gym/envs/mujoco/striker.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
class StrikerEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
utils.EzPickle.__init__(self)
self._striked = False
self._min_strike_dist = np.inf
self.strike_threshold = 0.1
mujoco_... | 2,723 | Python | .py | 68 | 29.676471 | 87 | 0.546177 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,282 | reacher.py | WindyLab_Gym-PPS/gym/envs/mujoco/reacher.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
class ReacherEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
utils.EzPickle.__init__(self)
mujoco_env.MujocoEnv.__init__(self, "reacher.xml", 2)
def step(self, a):
vec = self.get_body_com("f... | 1,674 | Python | .py | 45 | 27.533333 | 87 | 0.558226 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,283 | half_cheetah.py | WindyLab_Gym-PPS/gym/envs/mujoco/half_cheetah.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
class HalfCheetahEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
mujoco_env.MujocoEnv.__init__(self, "half_cheetah.xml", 5)
utils.EzPickle.__init__(self)
def step(self, action):
xposbefore =... | 1,282 | Python | .py | 33 | 30.393939 | 85 | 0.604183 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,284 | inverted_double_pendulum.py | WindyLab_Gym-PPS/gym/envs/mujoco/inverted_double_pendulum.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
class InvertedDoublePendulumEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
mujoco_env.MujocoEnv.__init__(self, "inverted_double_pendulum.xml", 5)
utils.EzPickle.__init__(self)
def step(self, action... | 1,598 | Python | .py | 40 | 30.6 | 78 | 0.55799 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,285 | ant_v3.py | WindyLab_Gym-PPS/gym/envs/mujoco/ant_v3.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
DEFAULT_CAMERA_CONFIG = {
"distance": 4.0,
}
class AntEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(
self,
xml_file="ant.xml",
ctrl_cost_weight=0.5,
contact_cost_weight=5e-4,
hea... | 4,621 | Python | .py | 116 | 30.801724 | 79 | 0.616588 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,286 | pusher.py | WindyLab_Gym-PPS/gym/envs/mujoco/pusher.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
import mujoco_py
class PusherEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
utils.EzPickle.__init__(self)
mujoco_env.MujocoEnv.__init__(self, "pusher.xml", 5)
def step(self, a):
vec_1 = se... | 2,007 | Python | .py | 52 | 28.384615 | 87 | 0.549383 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,287 | humanoid.py | WindyLab_Gym-PPS/gym/envs/mujoco/humanoid.py | import numpy as np
from gym.envs.mujoco import mujoco_env
from gym import utils
def mass_center(model, sim):
mass = np.expand_dims(model.body_mass, 1)
xpos = sim.data.xipos
return (np.sum(mass * xpos, 0) / np.sum(mass))[0]
class HumanoidEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
... | 2,290 | Python | .py | 64 | 25.46875 | 88 | 0.54193 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,288 | hopper.py | WindyLab_Gym-PPS/gym/envs/mujoco/hopper.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
class HopperEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
mujoco_env.MujocoEnv.__init__(self, "hopper.xml", 4)
utils.EzPickle.__init__(self)
def step(self, a):
posbefore = self.sim.data.qp... | 1,550 | Python | .py | 42 | 28.333333 | 84 | 0.571904 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,289 | swimmer_v3.py | WindyLab_Gym-PPS/gym/envs/mujoco/swimmer_v3.py | import numpy as np
from gym.envs.mujoco import mujoco_env
from gym import utils
DEFAULT_CAMERA_CONFIG = {}
class SwimmerEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(
self,
xml_file="swimmer.xml",
forward_reward_weight=1.0,
ctrl_cost_weight=1e-4,
reset_noise_sca... | 2,970 | Python | .py | 71 | 32.450704 | 77 | 0.616481 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,290 | __init__.py | WindyLab_Gym-PPS/gym/envs/mujoco/__init__.py | from gym.envs.mujoco.mujoco_env import MujocoEnv
# ^^^^^ so that user gets the correct error
# message if mujoco is not installed correctly
from gym.envs.mujoco.ant import AntEnv
from gym.envs.mujoco.half_cheetah import HalfCheetahEnv
from gym.envs.mujoco.hopper import HopperEnv
from gym.envs.mujoco.walker2d import Wa... | 820 | Python | .py | 16 | 50.1875 | 78 | 0.861768 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,291 | walker2d.py | WindyLab_Gym-PPS/gym/envs/mujoco/walker2d.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
class Walker2dEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
mujoco_env.MujocoEnv.__init__(self, "walker2d.xml", 4)
utils.EzPickle.__init__(self)
def step(self, a):
posbefore = self.sim.dat... | 1,420 | Python | .py | 35 | 32.428571 | 81 | 0.598985 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,292 | half_cheetah_v3.py | WindyLab_Gym-PPS/gym/envs/mujoco/half_cheetah_v3.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
DEFAULT_CAMERA_CONFIG = {
"distance": 4.0,
}
class HalfCheetahEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(
self,
xml_file="half_cheetah.xml",
forward_reward_weight=1.0,
ctrl_cost_weigh... | 2,705 | Python | .py | 68 | 30.794118 | 79 | 0.61821 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,293 | inverted_pendulum.py | WindyLab_Gym-PPS/gym/envs/mujoco/inverted_pendulum.py | import numpy as np
from gym import utils
from gym.envs.mujoco import mujoco_env
class InvertedPendulumEnv(mujoco_env.MujocoEnv, utils.EzPickle):
def __init__(self):
utils.EzPickle.__init__(self)
mujoco_env.MujocoEnv.__init__(self, "inverted_pendulum.xml", 2)
def step(self, a):
reward ... | 1,100 | Python | .py | 29 | 30.241379 | 79 | 0.60939 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,294 | pps.py | WindyLab_Gym-PPS/gym/envs/pps/pps.py | __credits__ = ["lijianan@westlake.edu.cn"]
import gym
from gym import error, spaces, utils
from .putils import *
from gym.utils import *
import numpy as np
import torch
import random
class PredatorPreySwarmEnv(PredatorPreySwarmEnvProp):
"""
Description:
Multiple predators and prey interact with e... | 25,915 | Python | .py | 413 | 48.779661 | 181 | 0.541777 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,295 | param.py | WindyLab_Gym-PPS/gym/envs/pps/putils/param.py | import gym
class PredatorPreySwarmEnvParam(gym.Env):
metadata = {"render.modes": ["human", "rgb_array"], "video.frames_per_second": 30}
# Agent numbers
_n_p = 3
_n_e = 10
_n_o = 0
# Environment
_is_periodic = True
# Control Strategy
_pursuer_strategy = 'input'
_escaper_s... | 2,346 | Python | .py | 74 | 25.945946 | 96 | 0.59545 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,296 | putils.py | WindyLab_Gym-PPS/gym/envs/pps/putils/putils.py | import numpy as np
def make_periodic(x:np.array, L:float) -> np.array:
x[x > L] -= 2 * L
x[x < -L] += 2 * L
return x
def normalize_angle(x:np.array) -> np.array:
return ((x + np.pi) % (2 * np.pi)) - np.pi
def get_sizes(size_p, size_e, size_o, n_p, n_e, n_o):
n_peo = n_p + n_e + n_o
size ... | 1,474 | Python | .py | 42 | 28.714286 | 62 | 0.546414 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,297 | __init__.py | WindyLab_Gym-PPS/gym/envs/pps/putils/__init__.py | def check_python_version():
import sys
if sys.version_info[0] == 3 and (sys.version_info[1] == 8 or 10):
pass
else:
raise ValueError('Python 3.8 or 3.10 REQUIRED !')
check_python_version()
from .param import *
from .prop import *
from .putils import *
| 286 | Python | .py | 10 | 24.2 | 69 | 0.659259 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,298 | prop.py | WindyLab_Gym-PPS/gym/envs/pps/putils/prop.py | import gym
from .param import *
import numpy as np
class PredatorPreySwarmEnvProp(PredatorPreySwarmEnvParam):
## Useful parameters to customize observations and reward functions
@property
def p(self):
return self._p
@p.setter
def p(self, value):
self._assert_2X_ndarray('p', v... | 10,007 | Python | .py | 323 | 23.839009 | 118 | 0.622636 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |
2,289,299 | atari_env.py | WindyLab_Gym-PPS/gym/envs/atari/atari_env.py | import numpy as np
import os
import gym
from gym import error, spaces
from gym import utils
from gym.utils import seeding
try:
import atari_py
except ImportError as e:
raise error.DependencyNotInstalled(
"{}. (HINT: you can install Atari dependencies by running "
"'pip install gym[atari]'.)".fo... | 7,842 | Python | .py | 211 | 27.985782 | 91 | 0.587166 | WindyLab/Gym-PPS | 8 | 2 | 1 | GPL-2.0 | 9/5/2024, 10:48:35 PM (Europe/Amsterdam) |