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
RoadDamageDetector
RoadDamageDetector-master/utils/dataset_util.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
2,617
29.091954
80
py
RoadDamageDetector
RoadDamageDetector-master/utils/object_detection_evaluation.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
26,696
42.269044
80
py
RoadDamageDetector
RoadDamageDetector-master/utils/np_box_list_test.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
5,183
37.117647
80
py
RoadDamageDetector
RoadDamageDetector-master/utils/np_box_ops.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
3,320
32.887755
80
py
RoadDamageDetector
RoadDamageDetector-master/utils/test_utils.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
4,576
31.692857
80
py
RoadDamageDetector
RoadDamageDetector-master/utils/config_util_test.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
18,834
45.853234
80
py
code-nerf
code-nerf-main/optimize.py
import sys, os ROOT_DIR = os.path.abspath(os.path.join('', 'src')) sys.path.insert(0, os.path.join(ROOT_DIR)) import argparse from utils import str2bool from optimizer import Optimizer if __name__ == '__main__': arg_parser = argparse.ArgumentParser(description="CodeNeRF") arg_parser.add_argument("--gpu",d...
1,624
39.625
105
py
code-nerf
code-nerf-main/train.py
import sys, os ROOT_DIR = os.path.abspath(os.path.join('', 'src')) sys.path.insert(0, os.path.join(ROOT_DIR)) import argparse from trainer import Trainer if __name__ == '__main__': arg_parser = argparse.ArgumentParser(description="CodeNeRF") arg_parser.add_argument("--gpu",dest="gpu",required=True) a...
1,201
34.352941
95
py
code-nerf
code-nerf-main/src/utils.py
import imageio import numpy as np import torch # import json # from torchvision import transforms import os def get_rays(H, W, focal, c2w): i, j = torch.meshgrid(torch.linspace(0, W - 1, W), torch.linspace(0, H - 1, H)) i = i.t() j = j.t() dirs = torch.stack([(i - W * .5) / focal, -(j - H * .5) / foc...
2,512
34.394366
94
py
code-nerf
code-nerf-main/src/model.py
import torch import torch.nn as nn def PE(x, degree): y = torch.cat([2.**i * x for i in range(degree)], -1) w = 1 return torch.cat([x] + [torch.sin(y) * w, torch.cos(y) * w], -1) class CodeNeRF(nn.Module): def __init__(self, shape_blocks = 2, texture_blocks = 1, W = 256, num_xyz_fre...
2,360
43.54717
83
py
code-nerf
code-nerf-main/src/data.py
import imageio import numpy as np import torch # import json # from torchvision import transforms import os def load_poses(pose_dir, idxs=[]): txtfiles = np.sort([os.path.join(pose_dir, f.name) for f in os.scandir(pose_dir)]) posefiles = np.array(txtfiles)[idxs] srn_coords_trans = np.diag(np.array([1, -1...
3,451
37.786517
92
py
code-nerf
code-nerf-main/src/trainer.py
import numpy as np import torch import torch.nn as nn import json from data import SRN from utils import get_rays, sample_from_rays, volume_rendering, image_float_to_uint8 from model import CodeNeRF from torch.utils.data import DataLoader from torch.utils.tensorboard import SummaryWriter import os import math import ...
8,307
46.204545
121
py
code-nerf
code-nerf-main/src/optimizer.py
import numpy as np import torch import torch.nn as nn import json from data import SRN from utils import get_rays, sample_from_rays, volume_rendering, image_float_to_uint8 from skimage.metrics import structural_similarity as compute_ssim from model import CodeNeRF from torch.utils.data import DataLoader from torch.ut...
11,915
47.636735
134
py
pynbody
pynbody-master/setup.py
import codecs import distutils import os import shutil import subprocess import sys import tempfile from os import path import numpy.distutils.misc_util from Cython.Build import build_ext from Cython.Compiler.Options import get_directive_defaults from setuptools import Extension, setup get_directive_defaults()['langu...
7,627
32.603524
98
py
pynbody
pynbody-master/tests/sph_image_test.py
import pickle from pathlib import Path import numpy as np import numpy.testing as npt import pylab as p import pytest import pynbody test_folder = Path(__file__).parent def setup_module(): global f f = pynbody.load("testdata/g15784.lr.01024") h = f.halos() # hard-code the centre so we're not implici...
4,603
32.362319
118
py
pynbody
pynbody-master/tests/array_test.py
import pynbody SA = pynbody.array.SimArray import numpy as np import pytest def test_pickle(): import pickle x = SA([1, 2, 3, 4], units='kpc') assert str(x.units) == 'kpc' y = pickle.loads(pickle.dumps(x)) assert y[3] == 4 assert str(y.units) == 'kpc' def test_issue255() : r = SA(0.5, 'a...
4,790
24.897297
107
py
pynbody
pynbody-master/tests/units_test.py
import numpy.testing as npt import pynbody from pynbody import units def numacc(a, b, tol=1.e-9): print(a, b) assert abs(a - b) < a * tol def test_units_conversion(): numacc(units.kpc.in_units(units.Mpc), 0.001) numacc(units.Mpc.in_units(units.kpc), 1000) numacc(units.yr.in_units(units.Myr), 1...
2,311
28.265823
79
py
pynbody
pynbody-master/tests/subfindhdf_gadget4_test.py
from os.path import isfile import h5py import numpy as np import pynbody def setup_module(): global snap, halos, subhalos, htest, snap_arepo, halos_arepo, subhalos_arepo, htest_arepo snap = pynbody.load('testdata/testL10N64/snapshot_000.hdf5') halos = pynbody.halo.Gadget4SubfindHDFCatalogue(snap) su...
13,096
38.095522
116
py
pynbody
pynbody-master/tests/test_profile.py
import numpy as np import numpy.testing as npt import pynbody np.random.seed(1) def make_fake_bar(npart=100000, max=1, min=-1, barlength=.8, barwidth=0.05, phi=0, fraction=0.2): x = np.random.sample(int(npart*fraction))*(max-min) + min y = np.random.sample(int(npart*fraction))*(max-min) + min xbar = np...
2,747
28.548387
97
py
pynbody
pynbody-master/tests/ramses_test.py
import os import numpy as np import pytest import pynbody def setup_module(): global f f = pynbody.load("testdata/ramses_partial_output_00250") def test_lengths(): assert len(f.gas) == 152667 assert len(f.star) == 2655 assert len(f.dm) == 51887 def test_properties(): np.testing.assert_alm...
17,652
40.438967
116
py
pynbody
pynbody-master/tests/subfind_test.py
import numpy as np from numpy.testing import assert_allclose import pynbody def setup_module(): global snap, halos, groups snap = pynbody.load("testdata/subfind/snapshot_019") halos = snap.halos(subs=True) groups = snap.halos() def teardown_module(): global snap, halos, groups del snap, hal...
2,947
42.352941
122
py
pynbody
pynbody-master/tests/filter_test.py
import numpy as np import numpy.testing as npt import pytest import pynbody def setup_module(): global f f = pynbody.new(1000) f['pos'] = np.random.normal(scale=1.0, size=f['pos'].shape) f['vel'] = np.random.normal(scale=1.0, size=f['vel'].shape) f['mass'] = np.random.uniform(1.0, 10.0, size=f['m...
2,736
26.37
80
py
pynbody
pynbody-master/tests/bridge_test.py
import numpy as np import pynbody def test_order_bridge(): f1 = pynbody.new(dm=1000) f2 = pynbody.new(dm=3000) f1['iord'] = np.arange(5, 2005, 2, dtype=int) f2['iord'] = np.arange(3000, dtype=int) b = pynbody.bridge.OrderBridge(f1, f2) h1 = f1[:50:2] assert b(h1).ancestor is f2 asse...
4,933
37.850394
164
py
pynbody
pynbody-master/tests/adaptahop_test.py
import numpy as np import pytest from scipy.io import FortranFile as FF import pynbody from pynbody.halo.adaptahop import AdaptaHOPCatalogue, NewAdaptaHOPCatalogue # Note: we do not use a module-wide fixture here to prevent caching of units @pytest.fixture def f(): yield pynbody.load("testdata/output_00080") @...
5,950
28.904523
95
py
pynbody
pynbody-master/tests/derived_arrays_test.py
import numpy as np import pynbody def setup_module(): global f, h f = pynbody.new(dm=1000, star=500, gas=500, order='gas,dm,star') f['pos'] = pynbody.array.SimArray(np.random.normal(scale=1.0, size=f['pos'].shape), units='kpc') f['vel'] = pynbody.array.SimArray(np.random.normal(scale=1.0, size=f['vel...
4,439
39
112
py
pynbody
pynbody-master/tests/import_test.py
def test_import_plot_module(): import pynbody pl_dir = dir(pynbody.plot) im = pynbody.plot.sph.image assert callable(im)
137
22
31
py
pynbody
pynbody-master/tests/partial_tipsy_test.py
import numpy as np import pytest import pynbody def test_indexing(): f1 = pynbody.load("testdata/g15784.lr.01024") np.random.seed(1) for test_len in [100, 10000, 20000]: for i in range(5): subindex = np.random.permutation(np.arange(0, len(f1)))[:test_len] subindex.sort() ...
1,131
25.325581
78
py
pynbody
pynbody-master/tests/ahf_halos_test.py
import glob import os.path import shutil import stat import subprocess import numpy as np import pynbody def test_load_ahf_catalogue(): f = pynbody.load("testdata/g15784.lr.01024") h = pynbody.halo.AHFCatalogue(f) assert len(h)==1411 def test_load_ahf_catalogue_non_gzipped(): subprocess.call(["gunz...
3,948
41.923913
150
py
pynbody
pynbody-master/tests/subarray_test.py
import gc import pickle import numpy as np import pynbody def test_pickle(): import pickle f = pynbody.new(10) f['blob'] = np.arange(10) s = f[[3, 6, 7]] assert (s['blob'] == [3, 6, 7]).all( ), "Preliminary check to testing pickle failed!" reloaded = pickle.loads(pickle.dumps(s['blob'])...
1,492
24.305085
74
py
pynbody
pynbody-master/tests/transformation_test.py
import copy import gc import numpy as np import numpy.testing as npt import pytest import pynbody def setup_module(): global f, original f = pynbody.new(dm=1000) f['pos'] = np.random.normal(scale=1.0, size=f['pos'].shape) f['vel'] = np.random.normal(scale=1.0, size=f['vel'].shape) f['mass'] = n...
3,328
26.512397
74
py
pynbody
pynbody-master/tests/tipsy_test.py
import glob import os import numpy as np import pytest import pynbody from pynbody.dependencytracker import DependencyError def setup_module(): X = glob.glob("testdata/test_out.*") for z in X: os.unlink(z) global f, h f = pynbody.load("testdata/g15784.lr.01024") h = f.halos() def tear...
15,081
36.056511
115
py
pynbody
pynbody-master/tests/rockstar_test.py
import numpy as np import numpy.testing as npt import pytest import pynbody def setup_module(): # create a dummy gadget file global f, h f = pynbody.new(dm=2097152) f['iord'] = np.arange(2097152) f.properties['z']=1.6591479493605812 f._filename = "testdata/rockstar/snapshot_015" h = f.hal...
1,401
32.380952
110
py
pynbody
pynbody-master/tests/utils_test.py
import time import numpy as np import numpy.testing as npt import pynbody def random_slice(max_pos=1000, max_step=10): import random a = random.randint(0, max_pos) b = random.randint(0, max_pos) return slice(min(a, b), max(a, b), random.randint(1, max_step)) def test_intersect_slices(): """Uni...
6,074
29.074257
86
py
pynbody
pynbody-master/tests/ramses_new_ptcl_format_test.py
import glob import os import warnings import numpy as np import pynbody sink_filename = "testdata/ramses_new_format_partial_output_00001/sink_00001.csv" sink_filename_moved = sink_filename+".temporarily_moved" import pytest def setup_module(): global f f = pynbody.load("testdata/ramses_new_format_partial_...
5,249
37.602941
125
py
pynbody
pynbody-master/tests/pyread_gadget_hdf5.py
"""Routine for reading Gadget3 HDF5 output files.""" import fnmatch import os import h5py import numpy import pandas as pd __author__ = 'Alan Duffy' __email__ = 'mail@alanrduffy.com' __version__ = '0.1.0' def pyread_gadget_hdf5(filename, ptype, var_name, sub_dir=None,\ smooth=None,cgsunits=None,physunits=None,...
18,632
40.778027
126
py
pynbody
pynbody-master/tests/gravity_test.py
import numpy as np import numpy.testing as npt import pynbody def test_gravity(): f = pynbody.load("testdata/g15784.lr.01024") h = f.halos() pynbody.analysis.angmom.faceon(h[1]) pro = pynbody.analysis.profile.Profile( h[1], type='equaln', nbins=50, rmin='100 pc', rmax='50 kpc') v_circ_co...
2,887
39.111111
90
py
pynbody
pynbody-master/tests/family_test.py
import numpy as np import pynbody def test_pickle(): # Regression test for issue 80 import pickle assert pickle.loads(pickle.dumps(pynbody.family.gas)) is pynbody.family.gas def test_family_array_dtype() : # test for issue #186 f = pynbody.load('testdata/g15784.lr.01024.gz') f.g['rho'] = np....
1,282
35.657143
120
py
pynbody
pynbody-master/tests/gadget_test.py
import numpy as np import pytest import pynbody def setup_module(): global snap snap = pynbody.load("testdata/test_g2_snap") def teardown_module(): global snap del snap def test_construct(): """Check the basic properties of the snapshot""" assert (np.size(snap._files) == 2) assert(sna...
7,056
31.671296
96
py
pynbody
pynbody-master/tests/halotools_test.py
import glob import os import time import numpy as np import pytest import pynbody def setup_module(): global f, h f = pynbody.load("testdata/g15784.lr.01024") h = f.halos() def teardown_module(): global f, h del f, h def test_center(): global f, h with pynbody.analysis.halo.center(h[...
2,825
34.772152
121
py
pynbody
pynbody-master/tests/snapshot_test.py
import weakref import numpy as np import pytest import pynbody def setup_module(): global f, h f = pynbody.new(dm=1000, star=500, gas=500, order='gas,dm,star') f['pos'] = np.random.normal(scale=1.0, size=f['pos'].shape) f['vel'] = np.random.normal(scale=1.0, size=f['vel'].shape) f['mass'] = np.r...
6,673
24.76834
103
py
pynbody
pynbody-master/tests/gadgethdf_test.py
import shutil from itertools import chain import h5py import numpy as np import pytest import pynbody def setup_module() : global snap,subfind snap = pynbody.load('testdata/Test_NOSN_NOZCOOL_L010N0128/data/snapshot_103/snap_103.hdf5') subfind = pynbody.load('testdata/Test_NOSN_NOZCOOL_L010N0128/data/sub...
8,441
39.782609
166
py
pynbody
pynbody-master/tests/grafic_test.py
import numpy as np import numpy.testing as npt import pytest import pynbody def setup_module(): global f f = pynbody.load("testdata/grafic_test/") def test_vel(): npt.assert_allclose(f['vel'][::10], [[-14.57081223, 25.25094223, -4.56839371], [ -7.05367327, -32.75279617, 22.61590385], ...
1,775
33.153846
107
py
pynbody
pynbody-master/tests/cosmology_test.py
import numpy as np import numpy.testing as npt import pynbody def test_a_to_t(): """Test scalefactor -> time conversion for accuracy. See also issue #479""" f = pynbody.new() # for default cosmology ipoints = pynbody.analysis.cosmology._interp_points interp_a = np.linspace(0.005, 1.0, ipoints+1) # en...
1,095
38.142857
119
py
pynbody
pynbody-master/tests/nchilada_test.py
import numpy as np import numpy.testing as npt import pynbody correct_pos_3000 = np.array([[4.80664825e+01, -8.99647751e+01, 3.74038162e+01], [-5.44153690e+00, 1.38918352e+00, -4.13906145e+00], ...
11,304
48.366812
84
py
pynbody
pynbody-master/tests/theoretical_profile.py
import numpy as np import numpy.testing as npt import pytest import pynbody from pynbody.array import SimArray def setup_module(): global halo_boundary, rs, rhos, mass, c, NFW1, NFW2 halo_boundary = SimArray(347., units="kpc") rs = SimArray(10, units="kpc") rhos = SimArray(1e8, units="Msol kpc**-3")...
4,717
42.284404
118
py
pynbody
pynbody-master/tests/sph_smooth_test.py
from pathlib import Path import numpy as np import numpy.testing as npt import pytest import pynbody def setup_module(): global f f = pynbody.load("testdata/g15784.lr.01024") # for compatibility with original results, pretend the box # is not periodic del f.properties['boxsize'] def teardown_m...
7,056
31.37156
134
py
pynbody
pynbody-master/docs/conf.py
# # pynbody documentation build configuration file, created by # sphinx-quickstart on Mon Oct 3 11:57:24 2011. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values ha...
8,294
31.027027
89
py
pynbody
pynbody-master/docs/tutorials/example_code/velocity_vectors.py
import matplotlib.pylab as plt import pynbody import pynbody.plot.sph as sph # load the snapshot and set to physical units s = pynbody.load('testdata/g15784.lr.01024.gz') s.physical_units() # load the halos h = s.halos() # center on the largest halo and align the disk pynbody.analysis.angmom.sideon(h[1]) # create ...
1,002
33.586207
92
py
pynbody
pynbody-master/docs/tutorials/example_code/do_pictures.py
diskgas=s.gas[diskf] ### Make pictures: try: pp.sph.image(h[i].gas,filename=simname+'.facegas.png',width=30) pp.sph.image(h[i].star,filename=simname+'.facestar.png',width=30) pp.sph.image(diskgas,qty='temp',filename=simname+'.tempgasdiskface.png', width=30,vmin=3,vmax=7) s.gas['hiden'] ...
2,045
48.902439
76
py
pynbody
pynbody-master/docs/tutorials/example_code/rotcurve.py
from os import environ import matplotlib.pylab as plt import pynbody # load the snapshot and set to physical units s = pynbody.load('testdata/g15784.lr.01024.gz') # load the halos h = s.halos() # center on the largest halo and align the disk pynbody.analysis.angmom.faceon(h[1]) # create a profile object for the s...
943
28.5
82
py
pynbody
pynbody-master/docs/tutorials/example_code/do_plots.py
### Make plots try: pp.sbprofile(h[i],filename=simname+'.sbprof.png',center=False) pp.sfh(h[i],filename=simname+'.sfh.png',nbins=500) pp.rotation_curve(h[i],filename=simname+'.rc.png',quick=True, rmax ='40 kpc',center=False) pp.rotation_curve(h[i],filename=simname+'.rcparts.png',quick=True, ...
948
46.45
79
py
pynbody
pynbody-master/docs/tutorials/example_code/density_slice.py
import matplotlib.pylab as plt import pynbody import pynbody.plot.sph as sph # load the snapshot and set to physical units s = pynbody.load('testdata/g15784.lr.01024.gz') s.physical_units() # load the halos h = s.halos() # center on the largest halo and align the disk pynbody.analysis.angmom.faceon(h[1]) #create a...
416
22.166667
66
py
pynbody
pynbody-master/docs/tutorials/example_code/do_images.py
diskgas=s.gas[diskf] ### Make pictures: try: pp.sph.image(h[i].gas,filename=simname+'.facegas.png',width=30) pp.sph.image(h[i].star,filename=simname+'.facestar.png',width=30) pp.sph.image(diskgas,qty='temp',filename=simname+'.tempgasdiskface.png', width=30,vmin=3,vmax=7) s.gas['hiden'] ...
2,005
50.435897
76
py
pynbody
pynbody-master/docs/tutorials/example_code/star_render.py
import matplotlib.pylab as plt import pynbody # load the snapshot and set to physical units s = pynbody.load('testdata/g15784.lr.01024.gz') s.physical_units() # load the halos h = s.halos() # center on the largest halo and align the disk pynbody.analysis.angmom.sideon(h[1]) #create an image using the default bands...
375
21.117647
50
py
pynbody
pynbody-master/docs/tutorials/example_code/density_profile.py
import matplotlib.pylab as plt import pynbody # load the snapshot and set to physical units s = pynbody.load('testdata/g15784.lr.01024.gz') # load the halos h = s.halos() # center on the largest halo and align the disk pynbody.analysis.angmom.faceon(h[1]) # convert all units to something reasonable (kpc, Msol etc)...
1,024
27.472222
82
py
pynbody
pynbody-master/docs/tutorials/example_code/rcs.py
import glob import pickle import sys import matplotlib.pyplot as plt import numpy as np import pynbody runs = ['c.1td.05rp.1','mugs','esn1.2','td.01c.1rp.1','rp.175','noradpres','2crasy'] labels = ['Fiducial','MUGS','120% SN energy','Low Diffusion','High Diffusion','No ESF', 'High ESF'] cs = ['r','k','c','...
1,046
29.794118
87
py
pynbody
pynbody-master/docs/tutorials/example_code/do_preamble.py
import glob import os import pickle import sys import numpy as np import pynbody import pynbody.analysis.profile as profile import pynbody.filt as filt import pynbody.plot as pp import pynbody.plot.sph import pynbody.units as units simname = sys.argv[1] # use first argument as simulation name to analyze pp.plt.ion...
1,443
34.219512
86
py
pynbody
pynbody-master/docs/tutorials/example_code/do_data.py
Jtot = np.sqrt(((np.multiply(h[i]['j'].transpose(),h[i]['mass']).sum(axis=1))**2).sum()) # calculate angular momentum W = np.sum(h[i]['phi']*h[i]['mass']) # halo potential energy K = np.sum(h[i]['ke']*h[i]['mass']) # halo kinetic energy absE = np.fabs(W+K) # total halo energy mvir=np.sum(h[i]['mass'].in_...
2,337
54.666667
128
py
pynbody
pynbody-master/docs/tutorials/example_code/temperature_slice.py
import matplotlib.pylab as plt import pynbody import pynbody.plot.sph as sph # load the snapshot and set to physical units s = pynbody.load('testdata/g15784.lr.01024.gz') s.physical_units() # load the halos h = s.halos() # center on the largest halo and align the disk pynbody.analysis.angmom.sideon(h[1]) #create a...
451
24.111111
88
py
pynbody
pynbody-master/docs/tutorials/example_code/density_integrated.py
import matplotlib.pylab as plt import pynbody import pynbody.plot.sph as sph # load the snapshot and set to physical units s = pynbody.load('testdata/g15784.lr.01024.gz') s.physical_units() # load the halos h = s.halos() # center on the largest halo and align the disk pynbody.analysis.angmom.faceon(h[1]) #create a...
452
24.166667
73
py
pynbody
pynbody-master/docs/sphinxext/docscrape_sphinx.py
import inspect import pydoc import re import textwrap from docscrape import ClassDoc, FunctionDoc, NumpyDocString class SphinxDocString(NumpyDocString): # string conversion routines def _str_header(self, name, symbol='`'): return ['.. rubric:: ' + name, ''] def _str_field_list(self, name): ...
4,237
29.056738
76
py
pynbody
pynbody-master/docs/sphinxext/ipython_directive.py
r"""Sphinx directive to support embedded IPython code. This directive allows pasting of entire interactive IPython sessions, prompts and all, and their code will actually get re-executed at doc build time, with all prompts renumbered sequentially. It also allows you to input code as a pure python input by giving the a...
27,656
31.807829
141
py
pynbody
pynbody-master/docs/sphinxext/apigen.py
"""Attempt to generate templates for module reference with Sphinx XXX - we exclude extension modules To include extension modules, first identify them as valid in the ``_uri2path`` method, then handle them in the ``_parse_module`` script. We get functions and classes by parsing the text of .py files. Alternatively w...
15,622
35.417249
79
py
pynbody
pynbody-master/docs/sphinxext/numpydoc.py
""" ======== numpydoc ======== Sphinx extension that handles docstrings in the Numpy standard format. [1] It will: - Convert Parameters etc. sections to field lists. - Convert See Also section to a See also entry. - Renumber references. - Extract the signature from the docstring, if it can't be determined otherwise....
4,068
32.628099
90
py
pynbody
pynbody-master/docs/sphinxext/docscrape.py
"""Extract reference documentation from the NumPy source tree. """ import inspect import pydoc import re import textwrap from warnings import warn from StringIO import StringIO 4 class Reader(object): """A line-based string reader. """ def __init__(self, data): """ Parameters --...
14,810
28.740964
80
py
pynbody
pynbody-master/docs/sphinxext/ipython_console_highlighting.py
"""reST directive for syntax-highlighting ipython interactive sessions. XXX - See what improvements can be made based on the new (as of Sept 2009) 'pycon' lexer for the python console. At the very least it will give better highlighted tracebacks. """ #-----------------------------------------------------------------...
4,144
35.681416
87
py
pynbody
pynbody-master/docs/sphinxext/inheritance_diagram.py
r""" Defines a docutils directive for inserting inheritance diagrams. Provide the directive with one or more classes or modules (separated by whitespace). For modules, all of the classes in that module will be used. Example:: Given the following classes: class A: pass class B(A): pass class C(A): pass ...
13,635
32.258537
103
py
pynbody
pynbody-master/pynbody/transformation.py
import weakref import numpy as np from . import snapshot class Transformation: def __init__(self, f, defer=False): if isinstance(f, snapshot.SimSnap): self.sim = f self.next_transformation = None elif isinstance(f, Transformation): self.sim = None ...
5,675
25.773585
118
py
pynbody
pynbody-master/pynbody/derived.py
""" derived ======= Holds procedures for creating new arrays from existing ones, e.g. for getting the radial position. For more information see :ref:`derived`. """ import functools import logging import time import numpy as np from . import analysis, array, config, units from .snapshot import SimSnap logger = log...
8,269
25.59164
109
py
pynbody
pynbody-master/pynbody/array.py
""" array ===== Defines a shallow wrapper around numpy.ndarray for extra functionality like unit-tracking. For most purposes, the differences between numpy.ndarray and array.SimArray are not important. However, when units are specified (by setting the ``units`` attribute), the behaviour is slightly different. In part...
37,590
30.50964
129
py
pynbody
pynbody-master/pynbody/family.py
""" family ====== This module defines the Family class which represents families of particles (e.g. dm, gas, star particles). New Family objects are automatically registered so that snapshots can use them in the normal syntax (snap.dm, snap.star, etc). In practice the easiest way to make use of the flexibility this ...
2,974
24.869565
80
py
pynbody
pynbody-master/pynbody/units.py
""" units ===== The pynbody units module consists of a set of classes for tracking units. It relates closely to the :mod:`~pynbody.array` module, which defines an extension to numpy arrays which carries unit information. Making units ------------ Units are generated and used at various points through the pynbody f...
24,362
27.494737
187
py
pynbody
pynbody-master/pynbody/filt.py
""" filt ==== Defines and implements 'filters' which allow abstract subsets of data to be specified. See the `filter tutorial <http://pynbody.github.io/pynbody/tutorials/filters.html>`_ for some sample usage. """ import pickle import numpy as np from . import _util, family, units class Filter: def __init...
10,427
25.738462
122
py
pynbody
pynbody-master/pynbody/configuration.py
import logging import multiprocessing import os import warnings def _get_config_parser_with_defaults(): # Create config dictionaries which will be required by subpackages import configparser config_parser = configparser.ConfigParser() config_parser.optionxform = str config_parser.read( os....
4,328
37.651786
200
py
pynbody
pynbody-master/pynbody/util.py
""" util ==== Various utility routines used internally by pynbody. """ import fractions import gzip import logging import math import os import struct import sys import threading import time import numpy as np from . import units from .array import SimArray logger = logging.getLogger('pynbody.util') from ._util ...
17,864
26.191781
105
py
pynbody
pynbody-master/pynbody/dependencytracker.py
import threading class DependencyError(RuntimeError): pass class DependencyContext: def __init__(self, tracker, name): self.tracker = tracker self.name = name def __enter__(self): self.tracker._calculation_lock.__enter__() if self.name in self.tracker._current_calculation...
1,736
28.948276
74
py
pynbody
pynbody-master/pynbody/__init__.py
""" pynbody ======= A light-weight, portable, format-transparent analysis framework for N-body and SPH astrophysical simulations. For more information, either build the latest documentation included in our git repository, or view the online version here: http://pynbody.github.io/pynbody/ """ import sys if sys.vers...
2,460
24.905263
95
py
pynbody
pynbody-master/pynbody/simdict.py
""" simdict ======= This submodule defines an augmented dictionary class (:class:`SimDict`) for :class:`~pynbody.snapshot.SimSnap` properties where entries need to be managed e.g. for defining default entries, or for ensuring consistency between equivalent properties like redshift and scalefactor. By default, a :cla...
2,417
22.705882
79
py
pynbody
pynbody-master/pynbody/bridge/__init__.py
""" bridge ====== The bridge module has tools for connecting different outputs. For instance, it's possible to take a subview (e.g. a halo) from one snapshot and 'push' it into the other. This is especially useful if the two snapshots are different time outputs of the same simulation. Once connected, bridge called o...
13,047
41.090323
230
py
pynbody
pynbody-master/pynbody/chunk/__init__.py
""" chunk ===== Methods for describing parts of files to load. This module provides generalized logic for getting parts of sequential data off disk. It is for internal use. If you want to write a loader that supports partial loading, it will make it a lot easier. The steps for loading particle data are as follows ...
16,235
36.238532
111
py
pynbody
pynbody-master/pynbody/extern/cython_fortran_utils.py
from . import _cython_fortran_utils FortranFile = _cython_fortran_utils.FortranFile
85
20.5
47
py
pynbody
pynbody-master/pynbody/extern/__init__.py
0
0
0
py
pynbody
pynbody-master/pynbody/bc_modules/__init__.py
# Dummy file
13
6
12
py
pynbody
pynbody-master/pynbody/gravity/tree.py
"""Gravity Tree. Builds tree based on pkdgrav2""" try: from .. import pkdgrav except ImportError: # pkdgrav2 never works at the moment, and the warning below # confuses/annoys people pass #import warnings #warnings.warn("Unable to import PKDGrav gravity solver. Most likely this means either tha...
1,595
30.92
350
py
pynbody
pynbody-master/pynbody/gravity/calc.py
import math import warnings import numpy as np from .. import array, config, units from ..util import eps_as_simarray, get_eps from . import tree from ._gravity import direct def all_direct(f, eps=None): phi, acc = direct(f, f['pos'].view(np.ndarray), eps) f['phi'] = phi f['acc'] = acc def all_pm(f, e...
5,075
28.005714
120
py
pynbody
pynbody-master/pynbody/gravity/__init__.py
from . import calc
19
9
18
py
pynbody
pynbody-master/pynbody/plot/sph.py
""" sph === routines for plotting smoothed quantities """ import matplotlib import numpy as np import pylab as p from .. import config, sph, units as _units def sideon_image(sim, *args, **kwargs): """ Rotate the simulation so that the disc of the passed halo is side-on, then make an SPH image by pas...
17,830
31.898524
136
py
pynbody
pynbody-master/pynbody/plot/gas.py
""" gas === Functions for plotting gas quantities """ import logging import matplotlib.pyplot as plt import numpy as np from ..analysis import angmom, halo, profile from ..units import Unit from .generic import hist2d logger = logging.getLogger('pynbody.plot.gas') def rho_T(sim, rho_units=None, rho_range=None,...
3,676
28.416
125
py
pynbody
pynbody-master/pynbody/plot/profile.py
""" profile ======= """ import logging import numpy as np import pylab as p from .. import config, filt, units from ..analysis import angmom, halo, profile logger = logging.getLogger('pynbody.plot.profile') def rotation_curve(sim, center=True, r_units='kpc', v_units='km s^-1', disk_height='10...
6,830
27.227273
91
py
pynbody
pynbody-master/pynbody/plot/stars.py
""" stars ===== """ import logging import warnings import matplotlib import matplotlib.pyplot as plt import numpy as np from .. import array, filt, units, units as _units from ..analysis import angmom, profile from ..sph import Kernel2D, render_spherical_image from .sph import image logger = logging.getLogger('py...
41,698
29.661029
199
py
pynbody
pynbody-master/pynbody/plot/generic.py
""" generic ======= Flexible and general plotting functions """ import numpy as np import pylab as plt import pynbody from .. import config from ..array import SimArray from ..units import NoUnit def qprof(sim, qty='metals', weights=None, q=(0.16, 0.5, 0.84), ax=False, ylabel=None, xlog=False, ylog=Fa...
19,317
28.137255
107
py
pynbody
pynbody-master/pynbody/plot/util.py
""" util ==== Utility functions for the plotting module """ import numpy as np import scipy as sp import scipy.signal import scipy.sparse def fast_kde(x, y, kern_nx=None, kern_ny=None, gridsize=(100, 100), extents=None, nocorrelation=False, weights=None, norm = False, **kwargs): """ A faster ...
6,364
30.509901
89
py
pynbody
pynbody-master/pynbody/plot/__init__.py
import imp from . import gas, generic, metals, profile, stars, util imp.reload(profile) imp.reload(generic) imp.reload(stars) imp.reload(gas) imp.reload(metals) imp.reload(util) from .gas import rho_T, temp_profile from .generic import fourier_map, gauss_kde, hist2d, qprof from .metals import mdf, ofefeh from .profi...
488
26.166667
69
py
pynbody
pynbody-master/pynbody/plot/metals.py
""" metals ====== """ import numpy as np from .generic import gauss_kde def mdf(sim, filename=None, clear=True, range=[-5, 0.3], axes=False, **kwargs): ''' Metallicity Distribution Function Plots a metallicity distribution function to the best of matplotlib's abilities. Unfortunately, the "nor...
1,882
22.835443
96
py
pynbody
pynbody-master/pynbody/snapshot/nchilada.py
""" nchilada ======== Implements classes and functions for handling nchilada files. You rarely need to access this module directly as it will be invoked automatically via pynbody.load. """ import os import struct import warnings import xml.dom.minidom import numpy as np from .. import chunk, family, units from ....
7,561
35.708738
131
py
pynbody
pynbody-master/pynbody/snapshot/gadgethdf.py
""" gadgethdf ========= Implementation of backend reader for GadgetHDF files by Andrew Pontzen. The gadget array names are mapped into pynbody array mes according to the mappings given by the config.ini section [gadgethdf-name-mapping]. The gadget particle groups are mapped into pynbody families according to the m...
38,390
35.183789
173
py
pynbody
pynbody-master/pynbody/snapshot/snapshot_util.py
""" util ==== Utility functions for the snapshot module. """ import logging from functools import reduce from .. import array, units logger = logging.getLogger('pynbody.snapshot') class ContainerWithPhysicalUnitsOption: """ Defines an abstract class that has properties and arrays that can be converte...
4,046
29.428571
117
py
pynbody
pynbody-master/pynbody/snapshot/gadget.py
""" gadget ====== Implements classes and functions for handling gadget files; you rarely need to access this module directly as it will be invoked automatically via pynbody.load. """ import configparser import copy import errno import itertools import struct import sys import warnings import numpy as np from .. ...
52,546
42.57131
149
py
pynbody
pynbody-master/pynbody/snapshot/tipsy.py
"""tipsy ===== Implements classes and functions for handling tipsy files. You rarely need to access this module directly as it will be invoked automatically via pynbody.load. **Input**: *filename*: file name string **Optional Keywords**: *paramfile*: string specifying the parameter file to load. If not specified,...
63,527
36.042566
145
py
pynbody
pynbody-master/pynbody/snapshot/namemapper.py
import configparser import sys from .. import config_parser def setup_name_maps(config_name, gadget_blocks=False, with_alternates=False): name_map = {} rev_name_map = {} alternates = {} try: for a, b in config_parser.items(config_name): if sys.version_info[0] == 2: ...
1,903
29.709677
111
py