repo stringlengths 3 91 | file stringlengths 16 152 | code stringlengths 0 3.77M | file_length int64 0 3.77M | avg_line_length float64 0 16k | max_line_length int64 0 273k | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
robogym | robogym-master/robogym/worldgen/parser/normalize.py | import ast
import re
from collections import OrderedDict
from decimal import Decimal, getcontext
from typing import List, Union
import numpy as np
from robogym.worldgen.parser.const import float_arg_types, list_types
getcontext().prec = 10
"""
This methods are used internally by parser.py
Internal notes:
norma... | 7,538 | 33.741935 | 89 | py |
robogym | robogym-master/robogym/wrappers/parametric.py | import gym
class EnvParameterWrapper(gym.Wrapper):
""" Generic parameter that modifies environment parameters on each reset """
def __init__(self, env, parameter_name: str):
super().__init__(env)
self.parameter_name = parameter_name
self.original_value = getattr(self.unwrapped.parame... | 1,143 | 28.333333 | 85 | py |
robogym | robogym-master/robogym/wrappers/cube.py | from collections import OrderedDict
import gym
import numpy as np
from gym.spaces import Box, Dict
from robogym.wrappers import randomizations
from robogym.wrappers.randomizations import loguniform
from robogym.wrappers.util import update_obs_space
class RandomizedCubeSizeWrapper(randomizations.RandomizedBodyWrappe... | 6,697 | 35.601093 | 90 | py |
robogym | robogym-master/robogym/wrappers/randomizations.py | import copy
import math
from collections import OrderedDict, deque
import gym
import numpy as np
from gym.spaces import Box, Dict
from robogym.utils.dactyl_utils import actuated_joint_range
from robogym.utils.rotation import (
normalize_angles,
quat_average,
quat_from_angle_and_axis,
quat_mul,
qua... | 44,567 | 35.741962 | 99 | py |
robogym | robogym-master/robogym/wrappers/face.py | from robogym.wrappers import randomizations
class RandomizedFaceDampingWrapper(randomizations.RandomizedDampingWrapper):
def __init__(self, env=None, damping_range=[1 / 3.0, 3.0], object_name="cube"):
joint_names = [
object_name + ":" + name for name in env.unwrapped.face_joint_names
]... | 379 | 37 | 83 | py |
robogym | robogym-master/robogym/wrappers/named_wrappers.py | import logging
from gym.wrappers import * # noqa # type: ignore
from .cube import * # noqa # type: ignore
from .dactyl import * # noqa # type: ignore
from .face import * # noqa # type: ignore
from .parametric import * # noqa # type: ignore
from .randomizations import * # noqa # type: ignore
from .util import * ... | 3,536 | 36.62766 | 148 | py |
robogym | robogym-master/robogym/wrappers/util.py | import enum
from collections import OrderedDict
from copy import deepcopy
import gym
import numpy as np
from gym.spaces import Box, Dict
def update_obs_space(env, delta):
spaces = env.observation_space.spaces.copy()
for key, shape in delta.items():
spaces[key] = Box(-np.inf, np.inf, (np.prod(shape),)... | 11,436 | 32.247093 | 109 | py |
robogym | robogym-master/robogym/wrappers/dactyl.py | from collections import OrderedDict
import gym
import numpy as np
from robogym.robot.shadow_hand.hand_forward_kinematics import (
FINGERTIP_SITE_NAMES,
REFERENCE_SITE_NAMES,
)
from robogym.utils.sensor_utils import check_occlusion, occlusion_markers_exist
from robogym.wrappers import randomizations
class Ra... | 8,676 | 37.22467 | 89 | py |
robogym | robogym-master/robogym/wrappers/tests/test_randomizations.py | import numpy as np
import pytest
from mock import patch
from numpy.testing import assert_almost_equal
from robogym.envs.dactyl.full_perpendicular import make_simple_env
from robogym.envs.dactyl.locked import make_env as make_env_locked
from robogym.envs.dactyl.reach import make_simple_env as make_reach_env
from robogy... | 12,783 | 31.779487 | 97 | py |
robogym | robogym-master/robogym/wrappers/tests/test_dactyl.py | import numpy as np
from mock import patch
from robogym.envs.dactyl.locked import make_simple_env
from robogym.wrappers.dactyl import FingersOccludedPhasespaceMarkers
from robogym.wrappers.randomizations import RandomizeObservationWrapper
@patch("robogym.wrappers.dactyl.check_occlusion")
def test_fingers_occluded_pha... | 1,473 | 36.794872 | 88 | py |
robogym | robogym-master/robogym/wrappers/tests/test_action_wrappers.py | import numpy as np
from robogym.envs.rearrange.blocks import make_env
from robogym.wrappers.util import DiscretizeActionWrapper
class TestDiscretizeActionWrapper:
def test_linear_mapping(self):
n_bins = 11
env = make_env(apply_wrappers=False, constants=dict(n_action_bins=n_bins))
env = Di... | 1,105 | 33.5625 | 84 | py |
robogym | robogym-master/robogym/utils/icp.py | # Copy from https://github.com/ClayFlannigan/icp/blob/master/icp.py
# ICP: Iterative Closest Point which is an algorithm to find optimal rotation
# matrix between two set of point cloud. This file implements vanilla ICP using
# Kabsch algorithm with nearest neighbor matching.
# See https://en.wikipedia.org/wiki/Iterati... | 4,822 | 29.333333 | 113 | py |
robogym | robogym-master/robogym/utils/misc.py | from os.path import abspath, dirname, join
# This is the absolute path to the root directory for the robogym repo.
ROBOGYM_ROOT_PATH = abspath(join(dirname(__file__), ".."))
def robogym_path(*args):
"""
Returns an absolute path from a path relative to the robogym repository root directory.
"""
return... | 841 | 27.066667 | 91 | py |
robogym | robogym-master/robogym/utils/dactyl_utils.py | # This function can'be removed yet. There are two places that still need it: DactylReachEnv and
# RandomizedJointLimitWrapper. The latter can't be changed until the old environments are refactored. And the first
# one relies on it for initialization. An additional refactor is needed to remove this util.
def actuated_jo... | 888 | 58.266667 | 115 | py |
robogym | robogym-master/robogym/utils/testing.py | import numpy as np
def assert_dict_match(d1: dict, d2: dict, eps: float = 1e-6):
"""Assert if two dictionary variables are different.
:param eps: the threshold used when comparing two float values from dicts.
"""
assert sorted(d1.keys()) == sorted(d2.keys())
for k in d1:
assert isinstance... | 746 | 36.35 | 78 | py |
robogym | robogym-master/robogym/utils/parse_arguments.py | import glob
import os
from robogym.worldgen.parser.normalize import normalize_value
def parse_arguments(argv):
"""
Takes list of arguments and splits them
to argument that are of form key=value, and dictionary.
Furhter, cleans arguments (expands *, ~), and
makes sure that they refer to files, the... | 2,347 | 25.681818 | 96 | py |
robogym | robogym-master/robogym/utils/sensor_utils.py | OCCLUSION_MARKERS = [
"robot0:ffocclusion",
"robot0:mfocclusion",
"robot0:rfocclusion",
"robot0:lfocclusion",
"robot0:thocclusion",
]
OCCLUSION_DIST_CUTOFF = -0.0001 # neg; penetrated.
def occlusion_markers_exist(sim):
for marker in OCCLUSION_MARKERS:
if marker not in sim.model.geom_n... | 2,083 | 33.733333 | 94 | py |
robogym | robogym-master/robogym/utils/multi_goal_tracker.py | import logging
from typing import Any, Callable, Dict, List, Optional, Set, Tuple
from numpy.random import RandomState
from robogym.mujoco.simulation_interface import SimulationInterface
from robogym.utils.env_utils import InvalidSimulationError
logger = logging.getLogger(__name__)
def _sample_new_goal(goal_sample... | 10,623 | 37.215827 | 101 | py |
robogym | robogym-master/robogym/utils/rubik_utils.py | import kociemba
import pycuber
def solve_fast(cube, max_depth=24):
assert isinstance(cube, pycuber.Cube)
coloring = str(cube).replace("[", "").replace("]", "").replace(" ", " ")
coloring = coloring.split("\n")
seq = coloring[0].strip() + coloring[1].strip() + coloring[2].strip()
seq += coloring[... | 964 | 29.15625 | 78 | py |
robogym | robogym-master/robogym/utils/rotation.py | # Many methods borrow heavily or entirely from transforms3d https://github.com/matthew-brett/transforms3d
# eventually some of these may be upstreamed, but credit to transforms3d
# authors for implementing the many of the formulations we use here.
import itertools
import numpy as np
"""
Rotations
=========
Note: th... | 18,620 | 32.611913 | 105 | py |
robogym | robogym-master/robogym/utils/env_utils.py | import glob
import json
import os
from copy import deepcopy
from functools import partial
from runpy import run_path
import _jsonnet
import numpy as np
from gym.spaces import Box, Dict, Tuple
class InvalidSimulationError(Exception):
pass
def gym_space_from_arrays(arrays):
""" Define environment observation... | 5,116 | 29.640719 | 127 | py |
robogym | robogym-master/robogym/utils/mesh.py | from typing import Tuple
import numpy as np
import trimesh
def get_vertices_bounding_box(vertices: np.ndarray) -> Tuple[float, float, float]:
min_xyz = np.min(vertices, axis=0)
max_xyz = np.max(vertices, axis=0)
size = (max_xyz - min_xyz) / 2.0
assert np.all(size >= 0.0)
pos = min_xyz + size
... | 947 | 27.727273 | 82 | py |
robogym | robogym-master/robogym/utils/tests/test_rotation.py | import itertools as it
import unittest
import numpy as np
from mujoco_py import functions
from numpy.random import randint, uniform
from numpy.testing import assert_allclose
from scipy.linalg import inv, sqrtm
from transforms3d import euler, quaternions
from robogym.utils.rotation import (
any_orthogonal,
eul... | 9,198 | 32.089928 | 88 | py |
robogym | robogym-master/robogym/utils/tests/test_rubik_utils.py | import unittest
import pycuber
from robogym.utils.rubik_utils import solve_fast
class RubikTest(unittest.TestCase):
def test_solver(self):
cube = pycuber.Cube()
initial_cube = str(cube)
alg = pycuber.Formula()
random_alg = alg.random()
cube(random_alg)
assert init... | 583 | 26.809524 | 73 | py |
robogym | robogym-master/robogym/randomization/sim.py | import abc
import copy
from typing import List, Union
import numpy as np
from mujoco_py import MjSim
from numpy.random import RandomState
from robogym.mujoco.constants import OPT_FIELDS, PID_GAIN_PARAMS
from robogym.randomization.common import Randomizer
from robogym.randomization.parameters import (
FloatRandomi... | 20,619 | 33.949153 | 97 | py |
robogym | robogym-master/robogym/randomization/action.py | import abc
import numpy as np
from robogym.randomization.common import Randomizer
class ActionRandomizer(Randomizer[np.ndarray], abc.ABC):
"""
Randomizer which randomize action.
"""
pass
| 208 | 13.928571 | 56 | py |
robogym | robogym-master/robogym/randomization/observation.py | import abc
from typing import Dict
import numpy as np
from robogym.randomization.common import Randomizer
class ObservationRandomizer(Randomizer[Dict[str, np.ndarray]], abc.ABC):
"""
Randomizer which randomize randomization.
"""
pass
| 255 | 16.066667 | 72 | py |
robogym | robogym-master/robogym/randomization/common.py | import abc
from collections import OrderedDict
from enum import Enum
from typing import Dict, Generic, List, Optional, Tuple, TypeVar
import numpy as np
VType = TypeVar("VType", int, float)
class DType(Enum):
INT = (1,)
FLOAT = 2
class RandomizerParameter(Generic[VType], abc.ABC):
"""
Base interfa... | 6,630 | 26.17623 | 86 | py |
robogym | robogym-master/robogym/randomization/parameters.py | from typing import Optional, Tuple
import numpy as np
from robogym.randomization.common import RandomizerParameter
MAX_INT = int(1e9) # This is reasonably large enough for any integer parameter.
class IntRandomizerParameter(RandomizerParameter[int]):
"""
Randomizer parameter of scalar int data type.
"... | 1,292 | 22.944444 | 80 | py |
robogym | robogym-master/robogym/randomization/env.py | from typing import (
Any,
Dict,
Generic,
Iterable,
List,
NamedTuple,
Optional,
Tuple,
Type,
TypeVar,
Union,
)
import attr
import numpy as np
from robogym.randomization.action import ActionRandomizer
from robogym.randomization.common import (
ChainedRandomizer,
Rando... | 7,963 | 29.281369 | 96 | py |
robogym | robogym-master/robogym/randomization/tests/test_sim_randomization.py | import numpy as np
from robogym.envs.rearrange.blocks import BlockRearrangeEnv
from robogym.randomization.sim import (
GenericSimRandomizer,
GeomSolimpRandomizer,
GeomSolrefRandomizer,
GravityRandomizer,
JointMarginRandomizer,
PidRandomizer,
)
class TestEnv(BlockRearrangeEnv):
@classmetho... | 2,343 | 29.051282 | 83 | py |
robogym | robogym-master/robogym/randomization/tests/test_randomization.py | import unittest
import attr
import numpy as np
from robogym.randomization.env import (
EnvActionRandomizer,
EnvObservationRandomizer,
EnvParameterRandomizer,
EnvRandomization,
EnvSimulationRandomizer,
build_randomizable_param,
)
from robogym.randomization.observation import ObservationRandomiz... | 4,093 | 30.984375 | 87 | py |
cad.js | cad.js-master/scripts/tyson.py | # Copyright (C) 2011-2012 Alexander Shorin
# 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
# notice, th... | 25,604 | 37.046062 | 82 | py |
cad.js | cad.js-master/scripts/xmlToJson.py | #!/usr/bin/env python
# L. Howard Copyright @2014
# Convert a CAD model (per the STEPtools defined XML spec)
# into a JSON spec model
# Derived from Javascript version at
# https://github.com/ghemingway/cad.js/blob/master/scripts/xmlToJson.js
import argparse
from datetime import datetime
import json
import math
from ... | 20,459 | 34.957821 | 81 | py |
nat-acl2020 | nat-acl2020-master/main.py | from torch.optim.sgd import SGD
import os.path
import sys, csv, random, logging
import numpy as np
FIXED_RANDOM_SEEDS = False
if FIXED_RANDOM_SEEDS:
random.seed(0)
np.random.seed(0)
EXIT_SUCCESS=0
EXIT_FAILURE=-1
def evaluate(model_path, corpus, mini_batch_size=256, misspelling_rate=0.0,
cmx_f... | 22,210 | 44.144309 | 133 | py |
nat-acl2020 | nat-acl2020-master/robust_ner/enums.py | from enum import Enum
class TrainingMode(Enum):
"""
Training mode (one of: standard, stability, augmentation)
"""
Standard = 'standard'
Stability = 'stability'
Augmentation = 'augmentation'
def __str__(self):
return self.name
class EvalMode(Enum):
"""
Evaluation mode (on... | 686 | 17.078947 | 61 | py |
nat-acl2020 | nat-acl2020-master/robust_ner/embeddings.py | import logging
import torch
from typing import List
from flair.data import Sentence
log = logging.getLogger("flair")
def check_embeddings(sentList1: List[Sentence], sentList2: List[Sentence], embed1: torch.tensor, embed2: torch.tensor):
"""
Checks embeddings of the original and perturbed sentences.
Retu... | 1,019 | 33 | 119 | py |
nat-acl2020 | nat-acl2020-master/robust_ner/noise.py | import math
import logging
import random
import numpy as np
from robust_ner.confusion_matrix import noise_sentences_cmx
from robust_ner.vanilla_noise import noise_sentences_vanilla
from robust_ner.typos import noise_sentences_typos
from robust_ner.enums import MisspellingMode
def make_char_vocab(sentences):
"""
... | 1,346 | 27.659574 | 139 | py |
nat-acl2020 | nat-acl2020-master/robust_ner/confusion_matrix.py | import os.path
import csv
import math
import logging
import random
import numpy as np
def load_confusion_matrix(cmx_file_name, separator=' '):
"""
Loads a confusion matrix from a given file.
NULL - token that represents the epsilon character used to define.
the deletion and insertion operations.
... | 6,544 | 30.618357 | 127 | py |
nat-acl2020 | nat-acl2020-master/robust_ner/vanilla_noise.py | import math
import logging
import random
import numpy as np
from robust_ner.confusion_matrix import make_lut_from_vocab
def induce_noise_vanilla(input_text, char_vocab, noise_level):
"""
Induces noise into the input text using a vanilla noise model.
"""
log = logging.getLogger("flair")
vocab = ... | 5,584 | 33.90625 | 127 | py |
nat-acl2020 | nat-acl2020-master/robust_ner/spellcheck.py | import hunspell
def init_spellchecker(corpus):
"""
Initializes the spell checker.
It uses the corpus information to choose a proper language for spell checker.
Returns the initialied spell checker
"""
if corpus in ["conll03_en", "ontonotes"]:
spell_check = hunspell.HunSpell('/usr/share... | 1,441 | 29.041667 | 113 | py |
nat-acl2020 | nat-acl2020-master/robust_ner/typos.py | import os.path
import logging
import random
import numpy as np
def load_typos(file_name, char_vocab = {}, filter_OOA_chars = False):
"""
Loads typos from a given file.
Optionally, filters all entries that contain out-of-alphabet characters.
"""
_, ext = os.path.splitext(file_name)
if ext... | 3,257 | 25.487805 | 84 | py |
nat-acl2020 | nat-acl2020-master/flair_ext/nn.py | import warnings
from pathlib import Path
import torch.nn
from abc import abstractmethod
from typing import Union, List
import flair
from flair.data import Sentence
from flair.training_utils import Result
from flair.nn import Model
class ParameterizedModel(Model):
"""Abstract base class for all downstream task... | 711 | 28.666667 | 119 | py |
nat-acl2020 | nat-acl2020-master/flair_ext/models/nat_sequence_tagger_model.py | import logging
import sys
import numpy as np
from pathlib import Path
import torch.nn
import torch.nn.functional as F
from torch.utils.data.dataset import Dataset
import flair.nn
import torch
import flair.embeddings
from flair.data import Dictionary, Sentence, Token, Label
from flair.datasets import DataLoader
fro... | 21,916 | 39.362799 | 133 | py |
nat-acl2020 | nat-acl2020-master/flair_ext/models/__init__.py | from .nat_sequence_tagger_model import NATSequenceTagger
| 57 | 28 | 56 | py |
nat-acl2020 | nat-acl2020-master/flair_ext/visual/training_curves.py | import logging
from collections import defaultdict
from pathlib import Path
from typing import Union, List
import numpy as np
import csv
import matplotlib
import math
matplotlib.use("Agg")
import matplotlib.pyplot as plt
# header for 'weights.txt'
WEIGHT_NAME = 1
WEIGHT_NUMBER = 2
WEIGHT_VALUE = 3
log = logging.g... | 7,271 | 31.609865 | 112 | py |
nat-acl2020 | nat-acl2020-master/flair_ext/trainers/__init__.py | from .trainer import ParameterizedModelTrainer
| 47 | 23 | 46 | py |
nat-acl2020 | nat-acl2020-master/flair_ext/trainers/trainer.py | from pathlib import Path
from typing import List, Union
import datetime
from torch.optim.sgd import SGD
from torch.utils.data.dataset import ConcatDataset
import flair
import flair.nn
from flair.data import Sentence, MultiCorpus, Corpus
from flair.datasets import DataLoader
from flair.training_utils import (
ini... | 22,609 | 39.30303 | 173 | py |
KoG2P | KoG2P-master/g2p.py | # -*- coding: utf-8 -*-
'''
g2p.py
~~~~~~~~~~
This script converts Korean graphemes to romanized phones and then to pronunciation.
(1) graph2phone: convert Korean graphemes to romanized phones
(2) phone2prono: convert romanized phones to pronunciation
(3) graph2phone: convert Korean graphemes to pronuncia... | 9,320 | 26.658754 | 107 | py |
class_DMDR | class_DMDR-master/CLASS_rename.py | # Script to change the names of CLASS modules (by Nils Schöneberg & Julien Lesgourgues)
#
# Can be used to:
# - rename module files, module prefixes, module structures, module structure acronyms
# - undo renaming
# - clean the generated log and backup files
#
# usage: CLASS_rename.py [-h] --method {rename,undo,clean... | 19,182 | 43.611628 | 202 | py |
class_DMDR | class_DMDR-master/CPU.py | #!/usr/bin/env python
"""
.. module:: CPU
:synopsis: CPU, a CLASS Plotting Utility
.. moduleauthor:: Benjamin Audren <benjamin.audren@gmail.com>
.. credits:: Benjamin Audren, Jesus Torrado
.. version:: 2.0
This is a small python program aimed to gain time when comparing two spectra,
e.g. from CAMB and CLASS, or a ... | 22,565 | 35.221509 | 90 | py |
class_DMDR | class_DMDR-master/test_python.py | from classy import Class
| 25 | 12 | 24 | py |
class_DMDR | class_DMDR-master/external/external_Pk/generate_Pk_example_w_tensors.py | #!/usr/bin/python
from __future__ import print_function
import sys
from math import exp
# README:
#
# This is an example python script for the external_Pk mode of Class.
# It generates the primordial spectrum of LambdaCDM.
# It can be edited and used directly, though keeping a copy of it is recommended.
#
# Two (maybe... | 1,792 | 28.393443 | 84 | py |
class_DMDR | class_DMDR-master/external/external_Pk/generate_Pk_example.py | #!/usr/bin/python
from __future__ import print_function
import sys
from math import exp
# README:
#
# This is an example python script for the external_Pk mode of Class.
# It generates the primordial spectrum of LambdaCDM.
# It can be edited and used directly, though keeping a copy of it is recommended.
#
# Two (maybe... | 1,662 | 28.175439 | 84 | py |
class_DMDR | class_DMDR-master/external/distortions/generate_PCA_files.py | #!/usr/bin/env python
import numpy as np
import sys
import scipy.interpolate as sciint
from numpy.linalg import norm as vector_norm
from numpy.linalg import eigh as eigen_vals_vecs
import os
import matplotlib.pyplot as plt
# Read inputs
if(len(sys.argv)==14):
sd_detector_name = sys.argv[1]
sd_detector_nu_min = ev... | 10,312 | 36.638686 | 190 | py |
class_DMDR | class_DMDR-master/external/RealSpaceInterface/colormap_converter.py | import matplotlib.cm as cm
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
import os
OUTPUT_DIR = os.path.join("static", "images", "colormaps")
WIDTH = 512
def create_image(cmap, width):
values = np.linspace(0, 1, width)
colors = cmap(values).reshape((1, width, 4))
image = Image.f... | 1,042 | 28.8 | 75 | py |
class_DMDR | class_DMDR-master/external/RealSpaceInterface/config.py | import os
# Default port number to listen on. Can be overriden by passing a port number
# as the first command line argument, e.g. `python tornadoserver.py 1234`
PORT = 7777
# Directory to store previously computed transfer functions, spectra etc. in
DATABASE_DIR = "cache"
# Maximum number of thread pool workers (on... | 806 | 32.625 | 77 | py |
class_DMDR | class_DMDR-master/external/RealSpaceInterface/tornadoserver.py | from Calc2D.CalculationClass import Calculation
import time
import numpy as np
from concurrent.futures import ThreadPoolExecutor
from tornado.ioloop import IOLoop
from tornado import gen
import tornado.web
import tornado.websocket
import os
import os.path
import json
import unicodedata
import logging
import base64
imp... | 9,009 | 35.184739 | 119 | py |
class_DMDR | class_DMDR-master/external/RealSpaceInterface/Calc2D/TransferFunction.py | import os.path
import pickle
import uuid
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline, RectBivariateSpline
import sys
import logging
from classy import Class
import Calc2D.Database as Database
import config
TRANSFER_QUANTITIES = ["d_g", "d_ur", "d_cdm", "d_b", "d_g/4 + psi"]
def Com... | 2,263 | 33.830769 | 115 | py |
class_DMDR | class_DMDR-master/external/RealSpaceInterface/Calc2D/DataGeneration.py | import logging
import numpy as np
import cv2
from Calc2D.rFourier import realFourier, realInverseFourier
def GenerateGaussianData(sigma, size, points, A=1):
xr = np.linspace(-size / 2.0, size / 2.0, points)
yr = np.linspace(-size / 2.0, size / 2.0, points)
step = xr[1] - xr[0]
x, y = np.meshgrid(
... | 2,802 | 29.467391 | 82 | py |
class_DMDR | class_DMDR-master/external/RealSpaceInterface/Calc2D/CalculationClass.py | import os
import logging
import cv2
import numpy as np
from classy import Class
from Calc2D.TransferFunction import ComputeTransferFunctionList
from Calc2D.DataGeneration import GenerateGaussianData, GenerateSIData
from Calc2D.DataPropagation import PropagateDatawithList
from Calc2D.rFourier import *
from Calc2D.Dat... | 6,414 | 33.12234 | 148 | py |
class_DMDR | class_DMDR-master/external/RealSpaceInterface/Calc2D/DataPropagation.py | import numpy as np
#uses one dimensional interpolation
def PropagateDatawithListOld(k,FValue,zredindex,transferFunctionlist):
return (transferFunctionlist[zredindex](k.ravel()) * FValue.ravel()).reshape(FValue.shape)
def PropagateDatawithList(k, FValue, zredindex, transferFunctionlist):
result = {}
for field... | 1,256 | 32.078947 | 117 | py |
class_DMDR | class_DMDR-master/external/RealSpaceInterface/Calc2D/Database.py | import pickle
import os
import logging
import uuid
class Database:
def __init__(self, directory, db_file="database.dat"):
self.directory = directory
self.db_file = db_file
if not os.path.isdir(directory):
raise ValueError("'{}' is not a directory!".format(directory))
s... | 1,820 | 30.396552 | 87 | py |
class_DMDR | class_DMDR-master/external/RealSpaceInterface/Calc2D/__init__.py | 0 | 0 | 0 | py | |
class_DMDR | class_DMDR-master/external/RealSpaceInterface/Calc2D/rFourier.py | import numpy as np
import numpy.fft as fft
def realFourier(step, Value):
FValue = np.fft.fftshift(
np.fft.rfft2(Value), axes=(0)) #shifting only the x axes
kx = np.fft.fftshift(np.fft.fftfreq(Value.shape[0], d=step)) * 2 * np.pi
ky = np.fft.rfftfreq(Value.shape[0], d=step) * 2 * np.pi
return... | 633 | 27.818182 | 76 | py |
class_DMDR | class_DMDR-master/python/test_class.py | """
.. module:: test_class
:synopsis: python script for testing CLASS using nose
.. moduleauthor:: Benjamin Audren <benjamin.audren@gmail.com>
.. credits:: Benjamin Audren, Thomas Tram
.. version:: 1.0
This is a python script for testing CLASS and its wrapper Classy using nose.
To run the test suite, type
nosetest... | 24,909 | 39.702614 | 159 | py |
class_DMDR | class_DMDR-master/python/setup.py | from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as nm
import os
import subprocess as sbp
import os.path as osp
# Recover the gcc compiler
GCCPATH_STRING = sbp.Popen(
['gcc', '-print-libgcc-file-name'],
stdout=sbp.PIPE).communicate(... | 2,316 | 35.777778 | 118 | py |
class_DMDR | class_DMDR-master/python/extract_errors.py | # From the dumped stdout and stderr of a nosetests test_class.py, extract all
# the failed steps.
# Usage: python extract_errors.py output
from __future__ import print_function
import sys
import os
def main(path):
"""
Create a shorter file containing only the errors from nosetests
"""
assert os.path.... | 1,664 | 31.019231 | 77 | py |
class_DMDR | class_DMDR-master/python/interface_generator.py | """
Automatically reads header files to generate an interface
"""
from __future__ import division, print_function
import sys
import logging
try:
from collections import OrderedDict as od
except ImportError:
try:
from ordereddict import OrderedDict as od
except ImportError:
raise ImportError(... | 20,191 | 40.462012 | 88 | py |
class_DMDR | class_DMDR-master/scripts/thermo.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import necessary modules
# uncomment to get plots displayed in notebook
#get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from classy import Class
from scipy.optimize import fsolve
from scipy.int... | 2,008 | 22.091954 | 72 | py |
class_DMDR | class_DMDR-master/scripts/cltt_terms.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import necessary modules
from classy import Class
from math import pi
# In[ ]:
#############################################
#
# Cosmological parameters and other CLASS parameters
#
common_settings = {# LambdaCDM parameters
'h':0.67810,
... | 2,635 | 21.529915 | 73 | py |
class_DMDR | class_DMDR-master/scripts/varying_neff.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import necessary modules
# uncomment to get plots displayed in notebook
#get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from classy import Class
from scipy.optimize import fsolve
import math
... | 5,240 | 25.876923 | 106 | py |
class_DMDR | class_DMDR-master/scripts/Growth_with_w.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
#get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from classy import Class
from scipy import interpolate
# In[ ]:
w0vec = [-0.7, -1.0, -1.3]
wavec = [-0.2,0.0,0.2]
#w0vec = [-1.0]
#wavec = [0.0... | 8,550 | 26.944444 | 105 | py |
class_DMDR | class_DMDR-master/scripts/many_times.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import necessary modules
# uncomment to get plots displayed in notebook
#get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from classy import Class
from scipy.optimize import fsolve
from scipy.int... | 10,681 | 39.157895 | 179 | py |
class_DMDR | class_DMDR-master/scripts/distances.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import necessary modules
# uncomment to get plots displayed in notebook
#get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from classy import Class
# In[ ]:
font = {'size' : 20, 'family':'ST... | 1,670 | 17.566667 | 63 | py |
class_DMDR | class_DMDR-master/scripts/neutrinohierarchy.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import necessary modules
# uncomment to get plots displayed in notebook
#get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from classy import Class
from scipy.optimize import fsolve
# In[ ]:
#... | 4,339 | 34 | 191 | py |
class_DMDR | class_DMDR-master/scripts/check_PPF_approx.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
#get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from classy import Class
# In[ ]:
k_out = [5e-5, 5e-4, 5e-3]
models = ['PPF1','PPF2','FLD1','FLD1S']
w0 = {'PPF1':-0.7,'PPF2':-1.15,'FLD1':-0.7... | 7,163 | 28.240816 | 105 | py |
class_DMDR | class_DMDR-master/scripts/warmup.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import classy module
from classy import Class
# In[ ]:
# create instance of the class "Class"
LambdaCDM = Class()
# pass input parameters
LambdaCDM.set({'omega_b':0.0223828,'omega_cdm':0.1201075,'h':0.67810,'A_s':2.100549e-09,'n_s':0.9660499,'tau_reio':0.05430842}... | 1,742 | 16.088235 | 127 | py |
class_DMDR | class_DMDR-master/scripts/one_time.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import necessary modules
from classy import Class
from math import pi
# In[ ]:
#####################################################
#
# Cosmological parameters and other CLASS parameters
#
#####################################################
common_settings = {#... | 8,830 | 28.33887 | 165 | py |
class_DMDR | class_DMDR-master/scripts/one_k.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import necessary modules
# uncomment to get plots displayed in notebook
#get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from classy import Class
from scipy.optimize import fsolve
from scipy.int... | 6,113 | 33.542373 | 179 | py |
class_DMDR | class_DMDR-master/scripts/cl_ST.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import necessary modules
from classy import Class
from math import pi
# In[ ]:
#####################################################
#
# Cosmological parameters and other CLASS parameters
#
#####################################################
common_settings = {#... | 3,156 | 21.876812 | 114 | py |
class_DMDR | class_DMDR-master/scripts/varying_pann.py | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# import necessary modules
# uncomment to get plots displayed in notebook
#get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from classy import Class
from scipy.optimize import fsolve
from math impo... | 4,181 | 23.313953 | 97 | py |
3D-Deepbox | 3D-Deepbox-master/main.py | import tensorflow as tf
import tensorflow.contrib.slim as slim
import cv2, os
import numpy as np
import time
from random import shuffle
from data_processing import *
import sys
import argparse
from tqdm import tqdm
#####
#Training setting
BIN, OVERLAP = 2, 0.1
W = 1.
ALPHA = 1.
MAX_JIT = 3
NORM_H, NORM_W = 224, 224
V... | 11,431 | 38.557093 | 379 | py |
3D-Deepbox | 3D-Deepbox-master/data_processing.py | import tensorflow as tf
import cv2, os
import numpy as np
from random import shuffle
import copy
#####
#Training setting
BIN, OVERLAP = 2, 0.1
NORM_H, NORM_W = 224, 224
VEHICLES = ['Car', 'Truck', 'Van', 'Tram','Pedestrian','Cyclist']
def compute_anchors(angle):
anchors = []
wedge = 2.*np.pi/BIN
l_i... | 6,100 | 33.083799 | 106 | py |
Beholder-GAN | Beholder-GAN-master/tfutil.py | #Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
#
#Attribution-NonCommercial 4.0 International
#
#=======================================================================
#
#Creative Commons Corporation ("Creative Commons") is not a law firm and
#does not provide legal services or legal advice. Distribut... | 66,879 | 46.131783 | 226 | py |
Beholder-GAN | Beholder-GAN-master/legacy.py | #Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
#
#Attribution-NonCommercial 4.0 International
#
#=======================================================================
#
#Creative Commons Corporation ("Creative Commons") is not a law firm and
#does not provide legal services or legal advice. Distribut... | 24,724 | 46.275335 | 122 | py |
Beholder-GAN | Beholder-GAN-master/inference_cond.py | import os
import misc
import numpy as np
import pdb
from config import EasyDict
import tfutil
import argparse
# initialize parser arguments
parser = argparse.ArgumentParser()
parser.add_argument('--results_dir', '-results_dir', help='name of training experiment folder', default='dean_cond_batch16', type=str)
parser.ad... | 4,341 | 46.195652 | 160 | py |
Beholder-GAN | Beholder-GAN-master/beautify_image.py | import os
import misc
import numpy as np
import pdb
from config import EasyDict
import tfutil
import argparse
import csv
import tensorflow as tf
import tensorflow_hub as hub
import PIL
from PIL import Image
import matplotlib.pyplot as plt
# initialize parser arguments
parser = argparse.ArgumentParser()
parser.add_argu... | 3,112 | 44.115942 | 171 | py |
Beholder-GAN | Beholder-GAN-master/loss.py | #Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
#
#Attribution-NonCommercial 4.0 International
#
#=======================================================================
#
#Creative Commons Corporation ("Creative Commons") is not a law firm and
#does not provide legal services or legal advice. Distribut... | 24,514 | 48.325956 | 117 | py |
Beholder-GAN | Beholder-GAN-master/misc.py | #Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
#
#Attribution-NonCommercial 4.0 International
#
#=======================================================================
#
#Creative Commons Corporation ("Creative Commons") is not a law firm and
#does not provide legal services or legal advice. Distribut... | 32,539 | 42.386667 | 146 | py |
Beholder-GAN | Beholder-GAN-master/dataset.py | #Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
#
#Attribution-NonCommercial 4.0 International
#
#=======================================================================
#
#Creative Commons Corporation ("Creative Commons") is not a law firm and
#does not provide legal services or legal advice. Distribut... | 31,670 | 47.724615 | 134 | py |
Beholder-GAN | Beholder-GAN-master/networks.py | #Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
#
#Attribution-NonCommercial 4.0 International
#
#=======================================================================
#
#Creative Commons Corporation ("Creative Commons") is not a law firm and
#does not provide legal services or legal advice. Distribut... | 41,442 | 51.261034 | 167 | py |
Beholder-GAN | Beholder-GAN-master/config.py | #Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
#
#Attribution-NonCommercial 4.0 International
#
#=======================================================================
#
#Creative Commons Corporation ("Creative Commons") is not a law firm and
#does not provide legal services or legal advice. Distribut... | 33,334 | 59.389493 | 284 | py |
Beholder-GAN | Beholder-GAN-master/dataset_tool.py | #Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
#
#Attribution-NonCommercial 4.0 International
#
#=======================================================================
#
#Creative Commons Corporation ("Creative Commons") is not a law firm and
#does not provide legal services or legal advice. Distribut... | 77,822 | 47.038889 | 163 | py |
Beholder-GAN | Beholder-GAN-master/train.py | #Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
#
#Attribution-NonCommercial 4.0 International
#
#=======================================================================
#
#Creative Commons Corporation ("Creative Commons") is not a law firm and
#does not provide legal services or legal advice. Distribut... | 35,370 | 49.747489 | 190 | py |
Beholder-GAN | Beholder-GAN-master/util_scripts.py | #Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
#
#Attribution-NonCommercial 4.0 International
#
#=======================================================================
#
#Creative Commons Corporation ("Creative Commons") is not a law firm and
#does not provide legal services or legal advice. Distribut... | 31,455 | 47.768992 | 239 | py |
Beholder-GAN | Beholder-GAN-master/beauty_prediction/execute_beauty_prediction.py | from __future__ import print_function, division
import argparse
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
from torchvision import transforms, models
from torch.autograd import Variable
import os
import numpy as np
from PIL import Image
import csv
parser = argparse.ArgumentParser()
parser.... | 3,738 | 35.300971 | 142 | py |
Beholder-GAN | Beholder-GAN-master/beauty_prediction/train_beauty_prediction.py | from __future__ import print_function, division
import argparse
import os
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
from torchvision import transforms, models
from torch.autograd import Variable
import time
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot... | 8,255 | 35.052402 | 127 | py |
Beholder-GAN | Beholder-GAN-master/beauty_prediction/execute_beauty_prediction_single.py | from __future__ import print_function, division
import argparse
import torch
import torch.nn as nn
import torch.backends.cudnn as cudnn
from torchvision import transforms, models
from torch.autograd import Variable
import os
import numpy as np
from PIL import Image
import csv
parser = argparse.ArgumentParser()
parser.... | 2,908 | 34.47561 | 142 | py |
Beholder-GAN | Beholder-GAN-master/beauty_prediction/faces_dataset.py | import csv
import numpy as np
import torch
from torch.utils.data.dataset import Dataset
from PIL import Image
import matplotlib.pyplot as plt
##### Dataset for Face images with beauty rates #####
# Each entry will contain: #
# Face image #
# L... | 2,953 | 35.02439 | 100 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.