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
rlmeta
rlmeta-main/tests/data/segment_tree_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pickle import unittest from math import prod import numpy as np import torch from rlmeta.data import SumSegmentTree from tests.tes...
4,036
35.044643
77
py
rlmeta
rlmeta-main/tests/data/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
179
35
65
py
rlmeta
rlmeta-main/tests/ops/discounted_return_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from typing import Union import torch import rlmeta.ops as ops from tests.test_utils import TestCaseBase class Discoun...
2,278
29.797297
79
py
rlmeta
rlmeta-main/tests/ops/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
179
35
65
py
rlmeta
rlmeta-main/tests/ops/generalized_advantage_estimation_test.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from typing import Optional, Union import torch import rlmeta.ops as ops from tests.test_utils import TestCaseBase cla...
3,929
33.173913
74
py
rlmeta
rlmeta-main/docs/source/conf.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # ...
2,078
35.473684
79
py
rlmeta
rlmeta-main/rlmeta/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
179
35
65
py
rlmeta
rlmeta-main/rlmeta/core/callbacks.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Dict from rlmeta.core.types import Action, TimeStep # The EpisodeCallbacks class is adapted from RLLib's DefaultCa...
1,865
31.172414
116
py
rlmeta
rlmeta-main/rlmeta/core/loop.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import abc import asyncio import copy import logging import time from typing import Dict, List, NoRetur...
12,555
30.949109
113
py
rlmeta
rlmeta-main/rlmeta/core/launchable.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import abc class Launchable(abc.ABC): @abc.abstractmethod def init_launching(self) -> None: """ """ @abc.abs...
394
18.75
65
py
rlmeta
rlmeta-main/rlmeta/core/server.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import asyncio import logging from typing import Any, Callable, List, NoReturn, Optional, Sequence, Uni...
5,518
28.994565
78
py
rlmeta
rlmeta-main/rlmeta/core/model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import copy import functools import random from enum import IntEnum from typing import (Any, Awaitable, Callable, Dict, Optional, Sequence,...
11,670
35.358255
80
py
rlmeta
rlmeta-main/rlmeta/core/types.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from typing import Any, NamedTuple, Optional, Union Tensor = Union[np.ndarray, torch.Tensor] # NestedTens...
2,108
33.57377
109
py
rlmeta
rlmeta-main/rlmeta/core/controller.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from dataclasses import dataclass from enum import IntFlag from typing import Dict, Optional, Union import rlmeta.core.remote as remote fr...
2,275
27.098765
77
py
rlmeta
rlmeta-main/rlmeta/core/rescalers.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import abc from typing import Optional, Tuple, Union import torch import torch.nn as nn from rlmeta.utils.running_stats import RunningMom...
5,106
26.605405
78
py
rlmeta
rlmeta-main/rlmeta/core/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
179
35
65
py
rlmeta
rlmeta-main/rlmeta/core/replay_buffer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import collections import time import logging from typing import Callable, Optional, Sequence, Tuple, Union from rich.console import Conso...
8,167
33.464135
79
py
rlmeta
rlmeta-main/rlmeta/core/remote.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import abc import functools from typing import Any, Callable, List, Optional import moolib from rlmet...
4,865
29.993631
76
py
rlmeta
rlmeta-main/rlmeta/envs/gym_wrapper.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Optional import numpy as np import gym from gym.wrappers.frame_stack import LazyFrames from gym.wrappers.ste...
2,873
30.582418
79
py
rlmeta
rlmeta-main/rlmeta/envs/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
179
35
65
py
rlmeta
rlmeta-main/rlmeta/envs/atari_wrapper.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Optional import numpy as np import gym from gym.wrappers.atari_preprocessing import AtariPreprocessing from gym.wrappe...
4,344
35.822034
80
py
rlmeta
rlmeta-main/rlmeta/envs/env.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import abc from typing import Optional, Type from rlmeta.core.types import Action, TimeStep from rlmeta.core.types import NestedTensor c...
976
21.204545
77
py
rlmeta
rlmeta-main/rlmeta/models/actor_critic.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Sequence, Tuple import torch import torch.nn as nn import torch.nn.functional as F from rlmeta.models.utils import MLP ...
1,699
32.333333
76
py
rlmeta
rlmeta-main/rlmeta/models/utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Sequence import torch import torch.nn as nn # The MLP class is inspired from the MLP class in DeepMind's haiku lib. # h...
2,810
32.464286
111
py
rlmeta
rlmeta-main/rlmeta/models/dqn.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Sequence import torch import torch.nn as nn from rlmeta.models.utils import MLP class DQNHead(nn.Module): def __...
1,306
29.395349
68
py
rlmeta
rlmeta-main/rlmeta/models/atari.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn from rlmeta.models.utils import ResidualBlock class NatureCNNBackbone(nn.Module): def __init__(se...
1,990
28.716418
76
py
rlmeta
rlmeta-main/rlmeta/agents/agent.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import abc import asyncio import copy from concurrent.futures import Future from typing import Any, Optional, Type, Union import rlmeta.co...
3,867
28.30303
101
py
rlmeta
rlmeta-main/rlmeta/agents/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
179
35
65
py
rlmeta
rlmeta-main/rlmeta/agents/ppo/ppo_model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import abc from typing import Tuple import torch import torch.nn as nn from rlmeta.core.model import RemotableModel class PPOModel(Remo...
1,555
28.358491
79
py
rlmeta
rlmeta-main/rlmeta/agents/ppo/ppo_rnd_agent.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Dict, List, Optional, Sequence import torch import torch.nn as nn import rlmeta.utils.data_utils as data_util...
10,632
39.276515
80
py
rlmeta
rlmeta-main/rlmeta/agents/ppo/ppo_rnd_model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import abc from typing import Tuple import torch import torch.nn as nn from rlmeta.core.model import RemotableModel class PPORNDModel(R...
1,906
27.893939
78
py
rlmeta
rlmeta-main/rlmeta/agents/ppo/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from rlmeta.agents.ppo.ppo_agent import PPOAgent from rlmeta.agents.ppo.ppo_rnd_agent import PPORNDAgent from rlmeta.agents.ppo.ppo_model im...
475
27
65
py
rlmeta
rlmeta-main/rlmeta/agents/ppo/ppo_agent.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import time from concurrent.futures import Future, ThreadPoolExecutor from typing import Dict, Iterable, List, Optional, Sequence, Tuple, U...
13,953
36.210667
80
py
rlmeta
rlmeta-main/rlmeta/agents/dqn/dqn_model.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import abc from typing import Optional, Tuple import torch import torch.nn as nn from rlmeta.core.model import RemotableModel from rlmeta...
2,058
28
76
py
rlmeta
rlmeta-main/rlmeta/agents/dqn/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from rlmeta.agents.dqn.apex_dqn_agent import (ApexDQNAgent, ApexDQNAgentFactory, ConstantEpsFu...
514
29.294118
80
py
rlmeta
rlmeta-main/rlmeta/agents/dqn/apex_dqn_agent.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import time from concurrent.futures import Future, ThreadPoolExecutor from typing import Callable, Dict, List, Optional, Sequence, Union i...
17,509
36.255319
80
py
rlmeta
rlmeta-main/rlmeta/samplers/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from _rlmeta_extension import Sampler, UniformSampler, PrioritizedSampler __all__ = [ "Sampler", "UniformSampler", "Prioritized...
332
24.615385
73
py
rlmeta
rlmeta-main/rlmeta/storage/storage.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import abc from typing import Optional, Sequence, Tuple, Union import numpy as np from rlmeta.core.types import Tensor, NestedTensor cl...
1,262
19.704918
79
py
rlmeta
rlmeta-main/rlmeta/storage/tensor_circular_buffer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Optional, Sequence, Tuple, Union import numpy as np import _rlmeta_extension from rlmeta.core.types import N...
1,809
26.014925
73
py
rlmeta
rlmeta-main/rlmeta/storage/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from rlmeta.storage.storage import Storage from rlmeta.storage.circular_buffer import CircularBuffer from rlmeta.storage.tensor_circular_buf...
432
27.866667
70
py
rlmeta
rlmeta-main/rlmeta/storage/circular_buffer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Optional, Sequence, Tuple, Union import numpy as np import rlmeta.utils.nested_utils as nested_utils import r...
2,650
30.559524
73
py
rlmeta
rlmeta-main/rlmeta/utils/asyncio_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import asyncio from typing import Awaitable def handle_task_exception(task: asyncio.Task) -> None: try: task.result() exc...
585
23.416667
78
py
rlmeta
rlmeta-main/rlmeta/utils/loss_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Dict, Optional import torch import torch.nn as nn _NAME_TO_LOSS = { "huber": nn.HuberLoss, "huber_loss": n...
872
26.28125
77
py
rlmeta
rlmeta-main/rlmeta/utils/optimizer_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Any, Iterable, Dict, Optional, Union import torch _NAME_TO_OPTIMIZER = { "adadelta": torch.optim.Adadelta, "ada...
990
29.96875
69
py
rlmeta
rlmeta-main/rlmeta/utils/random_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import random import numpy as np import torch def manual_seed(seed: int) -> None: random.seed(seed) np.random.seed(seed) torc...
377
21.235294
65
py
rlmeta
rlmeta-main/rlmeta/utils/data_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import io import os from typing import Any, Dict, Sequence, Tuple, Union import numpy as np import torch import rlmeta.utils.nested_utils...
3,056
26.294643
76
py
rlmeta
rlmeta-main/rlmeta/utils/moolib_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import uuid def generate_random_name() -> str: return str(uuid.uuid4()) def expend_name_by_index(name: str, index: int) -> str: ...
346
22.133333
65
py
rlmeta
rlmeta-main/rlmeta/utils/hydra_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import json import hydra from omegaconf import DictConfig, OmegaConf def config_to_json(cfg: OmegaConf) -> str: return json.dumps(Ome...
346
23.785714
65
py
rlmeta
rlmeta-main/rlmeta/utils/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
179
35
65
py
rlmeta
rlmeta-main/rlmeta/utils/nested_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from _rlmeta_extension.nested_utils import *
225
31.285714
65
py
rlmeta
rlmeta-main/rlmeta/utils/running_stats.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Optional, Tuple, Union import torch import torch.nn as nn class RunningRMS(nn.Module): def __init__(self, ...
4,699
33.306569
79
py
rlmeta
rlmeta-main/rlmeta/utils/remote_utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Optional, Union from rlmeta.core.remote import Remotable, Remote from rlmeta.core.server import Server def make_remote...
521
29.705882
66
py
rlmeta
rlmeta-main/rlmeta/utils/stats_dict.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import json import math from typing import Dict, Optional from tabulate import tabulate class StatsI...
3,586
24.992754
79
py
rlmeta
rlmeta-main/rlmeta/data/segment_tree.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Optional, Union import numpy as np import torch from _rlmeta_extension import SumSegmentTreeFp32, SumSegmentTreeFp64 fr...
1,899
26.941176
72
py
rlmeta
rlmeta-main/rlmeta/data/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from rlmeta.data.segment_tree import SumSegmentTree __all__ = [ "SumSegmentTree", ]
269
23.545455
65
py
rlmeta
rlmeta-main/rlmeta/ops/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from _rlmeta_extension.ops import *
216
30
65
py
LDEAlgsComparison
LDEAlgsComparison-master/scripts/generate.py
import subprocess import sys res = subprocess.Popen("python3 stressTest.py %s" % ' '.join(sys.argv[1:]), shell=True) if res.wait() != 0: print("Error")
155
21.285714
87
py
LDEAlgsComparison
LDEAlgsComparison-master/scripts/stressTest.py
import time import os import subprocess import sys from random import randint, seed exes = ["./ldegraphmain", "./slopesV7i"] def checkSkip(n, m, mxVal): if len(sys.argv) > 1: mx1, mx2, n1, m1, n2, m2 = map(int, sys.argv[1:]) if mxVal < mx1 or mxVal > mx2: return True if n < n1 or n > n2: r...
5,592
34.624204
199
py
LDEAlgsComparison
LDEAlgsComparison-master/scripts/doComparison.py
from os import system import sys system("gcc -static slopesV7i.c -std=c11 -O3 -o slopesV7i") system("g++ -static -lm -s -x c++ -std=c++17 -O3 -o ldegraphmain ldegraphmain.cpp ../src/ldegraphalg.cpp ../src/ldealg.cpp") system("python3 generate.py %s" % ' '.join(sys.argv[1:]))
276
45.166667
124
py
JOLLE
JOLLE-main/label_embedding_python/run_nn_ce_lshtc1.py
import torch import numpy as np from time import time from sklearn.datasets import load_svmlight_files import math from nn_utils import * import sys seed = 20220510 # gonna use this integer to sample random seeds for different functions max_int = np.iinfo(np.int32).max rng = np.random.default_rng(seed) train_path =...
3,797
40.282609
170
py
JOLLE
JOLLE-main/label_embedding_python/run_nn_dmoz.py
import torch import numpy as np from time import time from sklearn.datasets import load_svmlight_files import math from nn_utils import * import sys seed = 20230508 max_int = np.iinfo(np.int32).max rng = np.random.default_rng(seed) train_path = # TODO: fill the data path val_path = # TODO: fill the data path test_p...
4,139
42.125
169
py
JOLLE
JOLLE-main/label_embedding_python/run_nn_odp.py
import torch import numpy as np from time import time from sklearn.datasets import load_svmlight_files import math from nn_utils import * import sys seed = 20230508 max_int = np.iinfo(np.int32).max rng = np.random.default_rng(seed) train_path = # TODO: fill the data path val_path = # TODO: fill the data path test_p...
4,345
42.029703
170
py
JOLLE
JOLLE-main/label_embedding_python/run_nn_lshtc1.py
import torch import numpy as np from time import time from sklearn.datasets import load_svmlight_files import math from nn_utils import * import sys seed = 20230508 max_int = np.iinfo(np.int32).max rng = np.random.default_rng(seed) train_path = # TODO: fill the data path val_path = # TODO: fill the data path test_p...
4,522
44.23
169
py
JOLLE
JOLLE-main/label_embedding_python/run_nn_sq_dmoz.py
import torch import numpy as np from time import time from sklearn.datasets import load_svmlight_files import math from nn_utils import * import sys seed = 20220510 # gonna use this integer to sample random seeds for different functions max_int = np.iinfo(np.int32).max rng = np.random.default_rng(seed) train_path =...
3,764
39.923913
169
py
JOLLE
JOLLE-main/label_embedding_python/run_nn_ce_dmoz.py
import torch import numpy as np from time import time from sklearn.datasets import load_svmlight_files import math from nn_utils import * import sys seed = 20220510 # gonna use this integer to sample random seeds for different functions max_int = np.iinfo(np.int32).max rng = np.random.default_rng(seed) train_path =...
3,793
40.23913
169
py
JOLLE
JOLLE-main/label_embedding_python/run_nn_sq_odp.py
import torch import numpy as np from time import time from sklearn.datasets import load_svmlight_files import math from nn_utils import * seed = 20230508 max_int = np.iinfo(np.int32).max rng = np.random.default_rng(seed) train_path = # TODO: fill the data path val_path = # TODO: fill the data path test_path = # TODO...
4,026
40.091837
170
py
JOLLE
JOLLE-main/label_embedding_python/run_nn_sq_lshtc1.py
import torch import numpy as np from time import time from sklearn.datasets import load_svmlight_files import math from nn_utils import * import sys seed = 20220510 # gonna use this integer to sample random seeds for different functions max_int = np.iinfo(np.int32).max rng = np.random.default_rng(seed) train_path =...
3,849
39.957447
169
py
JOLLE
JOLLE-main/label_embedding_python/run_nn_ce_odp.py
import torch import numpy as np from time import time from sklearn.datasets import load_svmlight_files import math from nn_utils import * seed = 20230508 max_int = np.iinfo(np.int32).max rng = np.random.default_rng(seed) train_path = # TODO: fill the data path val_path = # TODO: fill the data path test_path = # TODO...
3,972
40.385417
170
py
JOLLE
JOLLE-main/label_embedding_python/nn_utils.py
import torch from sklearn.metrics import pairwise_distances import numpy as np class sparse_dataset(torch.utils.data.Dataset): def __init__(self, x, y): self.x = x self.y = y self.n_features = x.shape[1] def __len__(self): return self.x.shape[0] def __getitem__(sel...
4,296
41.127451
145
py
graphlaxy
graphlaxy-master/GraphlaxyDataGen.py
#!/usr/bin/env python import argparse import sys class Graphlaxy(object): def __init__(self): parser = argparse.ArgumentParser( description='Tool used to create synthetic graph datasets using \'Nash Bargin Scheme\' optimization.', usage='''gdg <command> [<args>] The available com...
10,767
55.376963
213
py
graphlaxy
graphlaxy-master/processes/optimization.py
from pathlib import Path import numpy as np import pandas as pd from scipy.optimize import minimize from utils.filesystem import add_to_csv from .bargin import grid_bargin, gen_metric_grid, gen_param_grid def store_params(dataset_folder, name, params, i = None): if i is not None: name = "{}_{}".format(name,i) ...
1,536
28.557692
80
py
graphlaxy
graphlaxy-master/processes/baseline_dataset.py
import random import numpy as np from pathlib import Path from utils.rmat import rmat_to_file def generate_baseline( dataset_folder = "../baseline_dataset", dataset_size = 10000, edges_between = (1000,1000000), multiprocess = False): Path(dataset_folder,'graphs').mkdir(parents=True, exist_ok=True...
1,520
31.361702
121
py
graphlaxy
graphlaxy-master/processes/result_dataset.py
import random import numpy as np from pathlib import Path import pandas as pd from utils.rmat import rmat_to_file from utils.probability import beta_rvs_shifted, beta_rvs_discrete_shifted def generate_result_dataset( from_file = True, custom_weights = [1] *8, param_file = "../baseline_dataset/parameters.c...
2,200
30.898551
121
py
graphlaxy
graphlaxy-master/processes/bargin.py
import numpy as np import pandas as pd from utils.probability import beta_cdf_interval, beta_cdf_mean, beta_cdf_mean_2d def get_grid(m=10, limits = [(0,1),(-6,-1)]): block0 = np.linspace(limits[0][0], limits[0][1], m + 1) block1 = np.linspace(limits[1][0], limits[1][1], m + 1) return [block0,...
3,465
32.326923
156
py
graphlaxy
graphlaxy-master/processes/statistics.py
import pandas as pd from pathlib import Path def statistics( dataset_folder = "../baseline_dataset", samples = 1000 ): print("Loading Dataset...") df = pd.read_csv(Path(dataset_folder, "dataset_metrics.csv")).head(samples) print("correlation: ", df["density_log"].corr(df["clustering"]...
723
37.105263
79
py
graphlaxy
graphlaxy-master/processes/metrics.py
import pandas as pd import networkx as nx import numpy as np from pathlib import Path from utils.filesystem import read_graph, add_to_csv import multiprocessing as mp lock = mp.Lock() def _metrics(dataset_folder, row, trials): a = row['a'] b = row['b'] c = row['c'] d = 1 - a - b - c G = re...
1,723
30.345455
96
py
graphlaxy
graphlaxy-master/processes/plot.py
from argparse import ArgumentError import random from statistics import mean import pandas as pd import numpy as np from pathlib import Path from matplotlib import pyplot as plt from utils.probability import beta_rvs_shifted from scipy.stats import beta, uniform from .bargin import gen_param_grid, gen_weights, gen_me...
8,500
34.569038
94
py
graphlaxy
graphlaxy-master/processes/__init__.py
__all__ = ["baseline_dataset", "metrics", "optimization", "plot", "result_dataset"]
83
83
83
py
graphlaxy
graphlaxy-master/utils/probability.py
import numpy as np from scipy.stats import beta def beta_cdf_interval(interval, a, b, interval_shift): low = interval_shift[0] up = interval_shift[1] if up - low <= 0: return 0 return beta.cdf(interval.right, a, b, loc = low, scale = up - low) -\ beta.cdf(interval.left, a, b, loc = low, scale = up - lo...
1,558
34.431818
96
py
graphlaxy
graphlaxy-master/utils/rmat.py
from pathlib import Path import numpy as np import multiprocessing as mp import networkit as nk from utils.filesystem import add_to_csv lock = mp.Lock() def rmat_to_file(N, E, a, b, c, d, dataset_folder, s): scale = np.ceil(np.log2(N)) factor = E/N reduce = np.power(2, scale) - N Graph = nk.generators.RmatG...
1,080
37.607143
119
py
graphlaxy
graphlaxy-master/utils/filesystem.py
import os import csv import networkx as nx def add_to_csv(path, data): if os.path.exists(path): with open(path, 'a', newline='') as f: w = csv.DictWriter(f, data.keys()) w.writerow(data) else: with open(path, 'w', newline='') as f: w = csv.DictWriter(f, data.keys()) ...
483
23.2
49
py
graphlaxy
graphlaxy-master/utils/__init__.py
0
0
0
py
graphlaxy
graphlaxy-master/utils/multiprocess.py
def pebble_timeout_callback(future): try: future.result() # blocks until results are ready except TimeoutError as error: print("Function took longer than %d seconds" % error.args[1]) except Exception as error: print("Function raised %s" % error) if hasattr(error, "traceback"...
384
41.777778
69
py
apicarver
apicarver-main/restats/app.py
from pathlib import Path import sys import json import core.pairing as pairing import core.statistic as stat import utils.parsers as par def callOptionMethod(confDict): modules = confDict['modules'] # Extract data from specification (needed to parse pairs) specDict = par.extractSpecificationData(conf['specificat...
3,165
33.043011
127
py
apicarver
apicarver-main/restats/__init__.py
0
0
0
py
apicarver
apicarver-main/restats/core/statistic.py
from pathlib import Path import json import utils.parsers as parsers import utils.dbmanager as dbm # dest = None jsonTestedKey = 'documentedAndTested' jsonNotTestedKey = 'documentedAndNotTested' jsonNotExpectedKey = 'notDocumentedAndTested' jsonFoundKey = 'totalTested' jsonTotalKey = 'documented' def getPathCoverage...
14,042
29.728665
141
py
apicarver
apicarver-main/restats/core/__init__.py
0
0
0
py
apicarver
apicarver-main/restats/core/pairing.py
import os from pathlib import Path import re import json from ruamel import yaml import utils import utils.parsers as parsers import utils.dbmanager as dbm import ruamel.yaml def addSpecToDB(pair): ##################### #### POPULATE DB #### pathID = dbm.getPathID(pair['request']['path']) method = pair['reques...
23,948
27.612903
125
py
apicarver
apicarver-main/restats/utils/dbmanager.py
import sqlite3 from sqlite3 import Error conn = None def create_connection(dbfile): """ create a database connection to the SQLite database specified by db_file :param db_file: database file :return: Connection object or None """ global conn try: conn = sqlite3.connect(dbfile)...
6,221
22.044444
93
py
apicarver
apicarver-main/restats/utils/parsers.py
import traceback from urllib.parse import parse_qs, urlsplit import json import ruamel.yaml methodsWithRequestBody = {'post', 'put', 'patch'} def parsePostData(postData): params = {} if postData is None: print("Cannot parse None") return None if type(postData) is dict and "string" in postData.keys(): postDa...
17,544
26.982456
113
py
apicarver
apicarver-main/restats/utils/__init__.py
0
0
0
py
apicarver
apicarver-main/testCarver/pythonCode/runEvoMaster.py
import glob import os import shutil from datetime import datetime import constants from constants import RUN_SCHEMATHESIS_COMMAND, APPS, STATUS_SUCCESSFUL, STATUS_SKIPPED, STATUS_ERRORED, CASETTE_YAML, \ SCHEMATHESIS_OUTPUT from utilsRun import monitorProcess, cleanup, startProcess, restartDocker, MODE def runAl...
6,598
35.865922
160
py
apicarver
apicarver-main/testCarver/pythonCode/constants.py
import os.path # APPS = ['medical'] APPS = ['petclinic', 'parabank', 'realworld', 'booker', 'jawa', 'medical', 'ecomm'] DOCKER_LOCATION = os.path.abspath('../src/main/resources/webapps') RUN_CARVER_COMMAND = ['java', '-Xmx8G', '-Xss1G', '-cp', 'target/testCarver-0.0.1-SNAPSHOT-jar-with-dependencies.jar', ...
2,633
29.627907
118
py
apicarver
apicarver-main/testCarver/pythonCode/runGeneratedTests.py
import glob import os from datetime import datetime, timedelta import constants from constants import APPS, STATUS_SUCCESSFUL, STATUS_ERRORED from utilsRun import restartDocker, startProcess, monitorProcess, getDockerName, cleanup, MODE, exportJson # BASE_COMMAND_HYBRID = ['sh', 'runTests.sh'] BASE_COMMAND = ['sh', '...
6,899
29
137
py
apicarver
apicarver-main/testCarver/pythonCode/utilsRun.py
import csv import json import os import subprocess from datetime import datetime from enum import Enum from subprocess import check_call, CalledProcessError, Popen from time import sleep import psutil from constants import DOCKER_LOCATION, STATUS_SUCCESSFUL def getDockerName(appName): return appName def restartD...
4,316
22.983333
113
py
apicarver
apicarver-main/testCarver/pythonCode/runSchemathesis.py
import glob import os import shutil from datetime import datetime import constants from constants import RUN_SCHEMATHESIS_COMMAND, APPS, STATUS_SUCCESSFUL, STATUS_SKIPPED, STATUS_ERRORED, CASETTE_YAML, \ SCHEMATHESIS_OUTPUT from utilsRun import monitorProcess, cleanup, startProcess, restartDocker, MODE def runAl...
6,970
39.063218
134
py
apicarver
apicarver-main/testCarver/pythonCode/rq1_executionTime.py
import glob import os.path from datetime import datetime import utilsRun from constants import APPS from coverageStats import getCovFiles from runCarver import getExistingCarverRun from runGeneratedTests import getCrawlsToAnalyze, getExistingCrawl from utilsRun import importJson def findAllOutputs(ALL_CRAWLS="../cra...
3,289
37.255814
142
py
apicarver
apicarver-main/testCarver/pythonCode/parseRestatsOutput.py
import os from datetime import datetime import constants import runRestats import utilsRun def fetchRestatsOutputDir(appName): returnDict = {} toolOutputs = runRestats.getExistingOutput(appName) if toolOutputs is None: print("No restats results found {}".format(appName)) return None f...
12,307
45.621212
156
py
apicarver
apicarver-main/testCarver/pythonCode/runRestats.py
import glob import os.path from datetime import datetime from enum import Enum import constants import utilsRun from constants import APPS, STATUS_ERRORED, STATUS_SUCCESSFUL, STATUS_SKIPPED, RUN_RESTATS_COMMAND, \ RESULT_RESPONSES_JSON, SCHEMATHESIS_OUTPUT, CASETTE_YAML, PROBER_RESPONSES_JSON, INFERRED_YAML, PROBE...
24,223
42.963702
185
py
apicarver
apicarver-main/testCarver/pythonCode/scratch_1.py
import glob import os # print(os.path.splitext("../a/b/c.json")[0]) # carverRecords = "../a/c.json" # # dir = os.path.pathsep.join(os.path.split(carverRecords)[0:len(os.path.split(carverRecords))-1]) # print(dir) import constants import coverageStats from constants import RESULT_RESPONSES_JSON # print(glob.glob( "/Te...
450
27.1875
100
py