code
stringlengths
114
1.05M
path
stringlengths
3
312
quality_prob
float64
0.5
0.99
learning_prob
float64
0.2
1
filename
stringlengths
3
168
kind
stringclasses
1 value
"""Classes that define a user's choice behavior over a slate of documents.""" import abc from typing import Sequence, Text import edward2 as ed # type: ignore from gym import spaces import numpy as np from recsim_ng.core import value from recsim_ng.lib.tensorflow import entity from recsim_ng.lib.tensorflow import fie...
/recsim_ng-0.1.2-py3-none-any.whl/recsim_ng/entities/choice_models/selectors.py
0.981753
0.802517
selectors.py
pypi
from typing import Optional, Sequence, Text from gym import spaces import numpy as np from recsim_ng.core import value from recsim_ng.lib.tensorflow import entity from recsim_ng.lib.tensorflow import field_spec import tensorflow as tf Value = value.Value ValueSpec = value.ValueSpec Space = field_spec.Space class Ta...
/recsim_ng-0.1.2-py3-none-any.whl/recsim_ng/entities/choice_models/affinities.py
0.969628
0.585042
affinities.py
pypi
from typing import Callable, Optional, Sequence, Text from gym import spaces import numpy as np from recsim_ng.core import value from recsim_ng.entities.state_models import state from recsim_ng.lib.tensorflow import field_spec import tensorflow as tf import tensorflow_probability as tfp tfd = tfp.distributions Value ...
/recsim_ng-0.1.2-py3-none-any.whl/recsim_ng/entities/state_models/estimation.py
0.970282
0.890342
estimation.py
pypi
import abc from typing import Optional, Text import edward2 as ed # type: ignore from recsim_ng.core import value from recsim_ng.lib.tensorflow import entity as entity_lib from recsim_ng.lib.tensorflow import field_spec import tensorflow_probability as tfp tfd = tfp.distributions Entity = entity_lib.Entity Value = ...
/recsim_ng-0.1.2-py3-none-any.whl/recsim_ng/entities/state_models/state.py
0.900157
0.222521
state.py
pypi
"""Metrics entity for bandit simulation.""" from typing import Text from recsim_ng.core import value from recsim_ng.entities.state_models import state import tensorflow as tf FieldSpec = value.FieldSpec Value = value.Value ValueSpec = value.ValueSpec class BanditMetrics(state.StateModel): """The base entity for ...
/recsim_ng-0.1.2-py3-none-any.whl/recsim_ng/entities/bandits/metrics.py
0.937261
0.37319
metrics.py
pypi
"""Abstract classes that encode a user's state and dynamics.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import abc import numpy as np import six from typing import List, Optional def softmax(vector): """Computes the softmax of a vector.""" no...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/choice_model.py
0.970562
0.568236
choice_model.py
pypi
r"""An example of main function for training in RecSim. Use the interest evolution environment and a slateQ agent for illustration. To run locally: python main.py --base_dir=/tmp/interest_evolution \ --gin_bindings=simulator.runner_lib.Runner.max_steps_per_episode=50 """ from __future__ import absolute_import fro...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/main.py
0.765067
0.449695
main.py
pypi
"""Abstract interface for recommender system agents.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import abc from absl import logging import six @six.add_metaclass(abc.ABCMeta) class AbstractRecommenderAgent(object): """Abstract class to model a r...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agent.py
0.966718
0.595257
agent.py
pypi
"""Abstract classes that encode a user's state and dynamics.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import abc from gym import spaces import numpy as np import six @six.add_metaclass(abc.ABCMeta) class AbstractResponse(object): """Abstract c...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/user.py
0.963083
0.532729
user.py
pypi
from __future__ import absolute_import from __future__ import division from __future__ import print_function from absl import flags from absl import logging import gin from gym import spaces import numpy as np from recsim import choice_model from recsim import document from recsim import user from recsim import utils ...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/environments/interest_exploration.py
0.923545
0.352759
interest_exploration.py
pypi
"""Agent that picks items with highest pCTR given the true user choice model.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from absl import logging import numpy as np from recsim import agent from recsim import choice_model as cm class GreedyPCTRA...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/greedy_pctr_agent.py
0.962918
0.643133
greedy_pctr_agent.py
pypi
"""A Tabular Q-learning implementation.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import itertools from absl import logging from gym import spaces import numpy as np from recsim import agent from recsim.agents import agent_utils class TabularQAg...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/tabular_q_agent.py
0.91086
0.673853
tabular_q_agent.py
pypi
"""Agent that picks topics based on the UCB1 algorithm given past responses.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import functools import gin import numpy as np from recsim import agent from recsim.agents.bandits import algorithms from recsim....
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/cluster_bandit_agent.py
0.885712
0.482551
cluster_bandit_agent.py
pypi
"""Convenience primitives relating to the implementation of agents.""" from gym import spaces import numpy as np class GymSpaceWalker(object): """Class for recursively applying a given function to a gym space. Gym spaces have nested structure in terms of container spaces (e.g. Dict and Tuple) containing basic ...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/agent_utils.py
0.925255
0.855066
agent_utils.py
pypi
"""Classes for Bandit Algorithms.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np class MABAlgorithm(object): """Base class for Multi-armed bandit (MAB) algorithms. We implement multi-armed bandit algorithms with confidence width ...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/bandits/algorithms.py
0.955465
0.639708
algorithms.py
pypi
"""Classes for Bandit Algorithms for Generalized Linear Models.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import abc import numpy as np from scipy import special import six @six.add_metaclass(abc.ABCMeta) class GLMAlgorithm(object): """Base class...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/bandits/glm_algorithms.py
0.958693
0.628179
glm_algorithms.py
pypi
"""Helper class to collect cluster click and impression counts.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from gym import spaces import numpy as np from recsim.agents.layers import sufficient_statistics class ClusterClickStatsLayer(sufficient_sta...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/layers/cluster_click_statistics.py
0.882225
0.476214
cluster_click_statistics.py
pypi
"""Temporally aggregated reinforcement learning agent.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from gym import spaces import numpy as np from recsim import agent from recsim.agents import agent_utils class TemporalAggregationLayer(agent.Abstra...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/layers/temporal_aggregation.py
0.945336
0.602442
temporal_aggregation.py
pypi
"""Agent that picks topics based on the UCB1 algorithm given past responses.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import gin import numpy as np from recsim import agent from recsim.agents.bandits import algorithms @gin.configurable class Ab...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/layers/abstract_click_bandit.py
0.934731
0.548129
abstract_click_bandit.py
pypi
"""Helper classe to record fixed length history of observations.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from gym import spaces from recsim.agents.layers import sufficient_statistics class FixedLengthHistoryLayer(sufficient_statistics.Sufficien...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/layers/fixed_length_history.py
0.955392
0.519887
fixed_length_history.py
pypi
"""Helper classes to record user response history on recommendations.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import abc from gym import spaces from recsim import agent class SufficientStatisticsLayer(agent.AbstractHierarchicalAgentLayer): ""...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/agents/layers/sufficient_statistics.py
0.953966
0.619673
sufficient_statistics.py
pypi
r"""An executable class to run agents in the simulator.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import time from absl import flags, logging import gin from gym import spaces import numpy as np from recsim.simulator import environment ...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/simulator/runner_lib.py
0.917478
0.328206
runner_lib.py
pypi
"""A wrapper for using Gym environment.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections import gym from gym import spaces import numpy as np from recsim.simulator import environment def _dummy_metrics_aggregator(responses, metrics, in...
/recsim_no_tf-0.2.3-py3-none-any.whl/recsim/simulator/recsim_gym.py
0.964296
0.466238
recsim_gym.py
pypi
import theano, numpy import theano.tensor as T import time import sys from collections import defaultdict class BPR(object): def __init__(self, rank, n_users, n_items, lambda_u = 0.0025, lambda_i = 0.0025, lambda_j = 0.00025, lambda_bias = 0.0, learning_rate = 0.05): """ Creates a new object for...
/recsys_bpr-0.1.1-py3-none-any.whl/recsys_bpr/bpr.py
0.68215
0.670622
bpr.py
pypi
from collections import defaultdict import urllib, csv def load_data_from_csv(csv_file, users_to_i = {}, items_to_i = {}): """ Loads data from a CSV file located at `csv_file` where each line is of the form: user_id_1, item_id_1 ... user_id_n, item_id_n Initial mappings...
/recsys_bpr-0.1.1-py3-none-any.whl/recsys_bpr/utils.py
0.783326
0.449876
utils.py
pypi
from typing import Optional, Tuple import torch from torch import Tensor def _check_topk_validity(preds: Tensor, k: Optional[int] = None) -> int: _max_k = preds.shape[-1] if k is None: k = _max_k if not (isinstance(k, int) and k > 0): raise ValueError(f'`k` has to be a positive integer o...
/recsys_metrics-0.0.4-py3-none-any.whl/recsys_metrics/utils.py
0.943152
0.62019
utils.py
pypi
from typing import Optional import torch from torch import Tensor from recsys_metrics.utils import _check_ranking_inputs, _check_preds_unexpectedness_inputs, _reduce_tensor # Ref: https://eugeneyan.com/writing/serendipity-and-accuracy-in-recommender-systems/#serendipity def serendipity(preds: Tensor, target: Tensor...
/recsys_metrics-0.0.4-py3-none-any.whl/recsys_metrics/serendipity.py
0.878001
0.559711
serendipity.py
pypi
import torch from recsys_metrics.mean_average_precision import mean_average_precision from torchmetrics.functional import retrieval_average_precision from benchmark.benchmark import benchmark, benchmark_batch, sanity_check # ns = [128, 256, 512, 1024, 2048, 4096] # ks = [1, 50, 100] def bench_map_single(ns, ks, num...
/recsys_metrics-0.0.4-py3-none-any.whl/benchmark/mean_average_precision.py
0.792946
0.280019
mean_average_precision.py
pypi
import torch from recsys_metrics.normalized_dcg import normalized_dcg from torchmetrics.functional import retrieval_normalized_dcg from benchmark.benchmark import benchmark, benchmark_batch, sanity_check # ns = [128, 256, 512, 1024, 2048, 4096] # ks = [1, 50, 100] def bench_ndcg_single(ns, ks, number=10_000, seed=4...
/recsys_metrics-0.0.4-py3-none-any.whl/benchmark/normalized_dcg.py
0.753376
0.22718
normalized_dcg.py
pypi
import torch from recsys_metrics.hit_rate import hit_rate from torchmetrics.functional import retrieval_hit_rate from benchmark.benchmark import benchmark, benchmark_batch, sanity_check # ns = [128, 256, 512, 1024, 2048, 4096] # ks = [1, 50, 100] def bench_hr_single(ns, ks, number=10_000, seed=42): def init_cal...
/recsys_metrics-0.0.4-py3-none-any.whl/benchmark/hit_rate.py
0.741019
0.215888
hit_rate.py
pypi
import torch from recsys_metrics.recall import recall from torchmetrics.functional import retrieval_recall from benchmark.benchmark import benchmark, benchmark_batch, sanity_check # ns = [128, 256, 512, 1024, 2048, 4096] # ks = [1, 50, 100] def bench_recall_single(ns, ks, number=10_000, seed=42): def init_callb...
/recsys_metrics-0.0.4-py3-none-any.whl/benchmark/recall.py
0.735547
0.192577
recall.py
pypi
import torch from recsys_metrics.precision import precision from torchmetrics.functional import retrieval_precision from benchmark.benchmark import benchmark, benchmark_batch, sanity_check # ns = [128, 256, 512, 1024, 2048, 4096] # ks = [1, 50, 100] def bench_precision_single(ns, ks, number=10_000, seed=42): de...
/recsys_metrics-0.0.4-py3-none-any.whl/benchmark/precision.py
0.768038
0.247441
precision.py
pypi
import torch from recsys_metrics.mean_reciprocal_rank import mean_reciprocal_rank from torchmetrics.functional import retrieval_reciprocal_rank from benchmark.benchmark import benchmark, benchmark_batch, sanity_check # ns = [128, 256, 512, 1024, 2048, 4096] # ks = [1, 50, 100] def bench_mrr_single(ns, ks, number=10...
/recsys_metrics-0.0.4-py3-none-any.whl/benchmark/mean_reciprocal_rank.py
0.785555
0.235493
mean_reciprocal_rank.py
pypi
import tensorflow as tf from datetime import datetime from recsys_models.data.sampling import uniform_sample_from_df def train_model(session, model, train_df, validation_mat, test_mat, n_iterations=2500, batch_size=512, min_epochs=10, max_epochs=200, stopping_threshold=1e-5, ...
/recsys_models-0.1.3.tar.gz/recsys_models-0.1.3/recsys_models/pipeline.py
0.85564
0.591664
pipeline.py
pypi
import os import gc import pandas as pd import numpy as np from datetime import datetime import random def sample_unobserved(df, user_interactions_dict, n_items, size=500000, use_original_actions=False): ''' Samples unobserved items for each (user, item) interaction pair. Creates <size> pairwise comparison...
/recsys_models-0.1.3.tar.gz/recsys_models-0.1.3/recsys_models/data/sampling.py
0.827445
0.458652
sampling.py
pypi
import os import gc import pandas as pd import numpy as np from datetime import datetime USER_ITEM_COLS = { 'allrecipes': ['user_id', 'recipe_id'], 'movielens': ['user_id', 'item_id'] } def print_basic_stats(df, user_col, item_col): ''' Prints basic summary stats for a DF: # users # it...
/recsys_models-0.1.3.tar.gz/recsys_models-0.1.3/recsys_models/data/__init__.py
0.565779
0.292823
__init__.py
pypi
from torch import nn import torch.nn.functional as F def _reduce(x, reduction='elementwise_mean'): if reduction is 'none': return x elif reduction is 'elementwise_mean': return x.mean() elif reduction is 'sum': return x.sum() else: raise ValueError('No such reduction {} defined'.format(reducti...
/recsys-recoder-0.4.0.tar.gz/recsys-recoder-0.4.0/recoder/losses.py
0.968672
0.583856
losses.py
pypi
import numpy as np import recoder.utils as utils from recoder.data import RecommendationDataLoader from multiprocessing import Process, Queue def average_precision(x, y, k, normalize=True): x = x[:k] x_in_y = np.isin(x, y, assume_unique=True).astype(np.int) tp = x_in_y.cumsum() # true positives at every pos...
/recsys-recoder-0.4.0.tar.gz/recsys-recoder-0.4.0/recoder/metrics.py
0.859649
0.46393
metrics.py
pypi
import annoy as an import pickle import glog as log class EmbeddingsIndex(object): """ An abstract Embeddings Index from which to fetch embeddings and execute nearest neighbor search on the items represented by the embeddings All ``EmbeddingsIndex`` should implement this interface. """ def get_embeddi...
/recsys-recoder-0.4.0.tar.gz/recsys-recoder-0.4.0/recoder/embedding.py
0.852107
0.507629
embedding.py
pypi
import torch from torch import nn import torch.nn.functional as F def activation(x, act): if act == 'none': return x func = getattr(torch, act) return func(x) class FactorizationModel(nn.Module): """ Base class for factorization models. All subclasses should implement the following methods. """ def...
/recsys-recoder-0.4.0.tar.gz/recsys-recoder-0.4.0/recoder/nn.py
0.947684
0.69125
nn.py
pypi
import numpy as np from scipy.sparse import coo_matrix def unzip(l): """ Returns the inverse operation of `zip` on `list`. Args: l (list): the list to unzip """ return list(map(list, zip(*l))) def normalize(x, axis=None): """ Returns the normalization of `x` along `axis`. Args: x (np.array...
/recsys-recoder-0.4.0.tar.gz/recsys-recoder-0.4.0/recoder/utils.py
0.865934
0.703282
utils.py
pypi
from recoder.embedding import EmbeddingsIndex import numpy as np import recoder.utils as utils class Recommender(object): """ Base Recommender that provide recommendations given users history of interactions. All Recommenders should implement the ``recommend`` function. """ def recommend(self, users_hist...
/recsys-recoder-0.4.0.tar.gz/recsys-recoder-0.4.0/recoder/recommender.py
0.936995
0.515254
recommender.py
pypi
# %% auto 0 __all__ = ['SequentialDataset', 'load_dataloaders'] # %% ../dataset_torch.ipynb 2 import torch import recsys_slates_dataset.data_helper as data_helper from torch.utils.data import Dataset, DataLoader import torch import json import numpy as np import logging logging.basicConfig(format='%(asctime)s %(messa...
/recsys_slates_dataset-1.0.3-py3-none-any.whl/recsys_slates_dataset/dataset_torch.py
0.729038
0.676793
dataset_torch.py
pypi
# %% auto 0 __all__ = ['SlateDataModule', 'CallbackPrintRecommendedCategory', 'Hitrate'] # %% ../lightning_helper.ipynb 3 import recsys_slates_dataset.dataset_torch as dataset_torch import recsys_slates_dataset.data_helper as data_helper import pytorch_lightning as pl import logging class SlateDataModule(pl.Lightning...
/recsys_slates_dataset-1.0.3-py3-none-any.whl/recsys_slates_dataset/lightning_helper.py
0.562898
0.385693
lightning_helper.py
pypi
d = { 'settings': { 'branch': 'main', 'doc_baseurl': '/recsys_slates_dataset/', 'doc_host': 'http://opensource.finn.no', 'git_url': 'https://github.com/finn-no/recsys_slates_dataset/tree/main/', 'lib_path': 'recsys_slates_dataset'}, 'syms': { 'recsys_sl...
/recsys_slates_dataset-1.0.3-py3-none-any.whl/recsys_slates_dataset/_modidx.py
0.433022
0.178884
_modidx.py
pypi
__author__ = 'Daniel Andersson' __maintainer__ = __author__ __email__ = 'daniel.4ndersson@gmail.com' __contact__ = __email__ __copyright__ = 'Copyright (c) 2017 Daniel Andersson' __license__ = 'MIT' __url__ = 'https://github.com/Penlect/rectangle-packer' __version__ = '2.0.1' # Built-in from typing import Iterable, Tu...
/rectangle_packer-2.0.1-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl/rpack/__init__.py
0.924351
0.306806
__init__.py
pypi
from typing import Tuple import matplotlib.patches as patches from matplotlib import pylab as plt from .solution import Solution class Visualizer: """ A floorplan visualizer. """ def __init__(self) -> None: # Default font size is 12 plt.rcParams["font.size"] = 14 def visualize...
/rectangle_packing_solver-0.0.5-py3-none-any.whl/rectangle_packing_solver/visualizer.py
0.946708
0.452415
visualizer.py
pypi
import random import signal import sys from typing import Any, List, Optional, Tuple import simanneal from tqdm.auto import tqdm from .problem import Problem from .sequence_pair import SequencePair from .solution import Solution def exit_handler(signum, frame) -> None: # type: ignore """ Since `simaaneal`...
/rectangle_packing_solver-0.0.5-py3-none-any.whl/rectangle_packing_solver/solver.py
0.765944
0.353721
solver.py
pypi
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from rectifai.models.posenet.settings import * def traverse_to_targ_keypoint( edge_id, source_keypoint, target_keypoint_id, scores, offsets, output_stride, displacements ): height = scores.shape[1] width = scores.sh...
/rectif-ai-0.1.tar.gz/rectif-ai-0.1/rectifai/models/posenet/decode.py
0.69035
0.386706
decode.py
pypi
import torch import torch.nn as nn import torch.nn.functional as F from collections import OrderedDict def _get_padding(kernel_size, stride, dilation): padding = ((stride - 1) + dilation * (kernel_size - 1)) // 2 return padding class InputConv(nn.Module): def __init__(self, inp, outp, k=3, stride=1, dil...
/rectif-ai-0.1.tar.gz/rectif-ai-0.1/rectifai/models/posenet/network.py
0.932731
0.540196
network.py
pypi
import torch import torch.nn as nn from torch.utils.data import DataLoader from torchsummary import summary from rectifai.models.posturenet import PostureNetwork from rectifai.settings import * from rectifai.models.posturenet.config import * from rectifai.data.dataset.posturenet import PostureDataset # Fully connect...
/rectif-ai-0.1.tar.gz/rectif-ai-0.1/rectifai/train/posturenet.py
0.824956
0.461502
posturenet.py
pypi
import torch import cv2 import time import argparse import subprocess from rectifai.models import posenet, posturenet from rectifai.models.posenet.decode import * from rectifai.tools.utils.posenet import * from rectifai.models.posturenet.config import input_size parser = argparse.ArgumentParser() parser.add_argument(...
/rectif-ai-0.1.tar.gz/rectif-ai-0.1/rectifai/predictors/demo_webcam.py
0.47926
0.192027
demo_webcam.py
pypi
import cv2 import numpy as np import math import subprocess import time from rectifai.models.posenet.settings import * def valid_resolution(width, height, output_stride=16): target_width = (int(width) // output_stride) * output_stride + 1 target_height = (int(height) // output_stride) * output_stride + 1 ...
/rectif-ai-0.1.tar.gz/rectif-ai-0.1/rectifai/tools/utils/posenet.py
0.498291
0.272377
posenet.py
pypi
# rectpack [![Build Status](https://travis-ci.org/secnot/rectpack.svg?branch=master)](https://travis-ci.org/secnot/rectpack) Rectpack is a collection of heuristic algorithms for solving the 2D knapsack problem, also known as the bin packing problem. In essence packing a set of rectangles into the smallest number of ...
/rectpack-0.2.2.tar.gz/rectpack-0.2.2/README.md
0.731634
0.962321
README.md
pypi
from __future__ import annotations import argparse import itertools import logging import random import subprocess as sp import sys import time import traceback from dataclasses import dataclass from typing import Callable, Literal from simpleeval import EvalWithCompoundTypes MAX_DELAY = 366 * 24 * 60 * 60 VERSION ...
/recur_command-0.2.0.tar.gz/recur_command-0.2.0/recur.py
0.715722
0.151906
recur.py
pypi
# RecurrentJS in Python Following in the footsteps of [Andrej Kaparthy](http://cs.stanford.edu/people/karpathy/), here is a Python implementation of [recurrentJS](http://cs.stanford.edu/people/karpathy/recurrentjs/) ([Github](https://github.com/karpathy/recurrentjs)). ### Why ? While Python has great automatic diff...
/recurrent-js-python-0.0.1.tar.gz/recurrent-js-python-0.0.1/README.md
0.557364
0.85446
README.md
pypi
from collections import namedtuple from functools import wraps from packaging import version import torch from torch import nn, einsum import torch.nn.functional as F from einops import rearrange # constants Config = namedtuple('EfficientAttentionConfig', ['enable_flash', 'enable_math', 'enable_mem_efficient']) # ...
/recurrent_memory_transformer_pytorch-0.5.5-py3-none-any.whl/recurrent_memory_transformer_pytorch/attend.py
0.924338
0.272775
attend.py
pypi
import sched import functools from datetime import datetime, timedelta __all__ = ("RecurringScheduler",) class RecurringJob: def __init__(self, interval, rsched): self.interval = interval self.unit = None self._rsched = rsched self._at_time = None self._prev_run = None ...
/recurring_sched-0.0.1.tar.gz/recurring_sched-0.0.1/recurring_sched.py
0.778313
0.251906
recurring_sched.py
pypi
import typing import re from abc import ABC, abstractmethod from pathlib import Path import gzip import io import pickle import pdb import requests class Corpus(ABC): """ Class to get a corpus """ name = '' url = '' decode=True """decode the raw bytes from the request in download_corpus""...
/recurse-words-0.2.1.tar.gz/recurse-words-0.2.1/recurse_words/corpi.py
0.651687
0.201479
corpi.py
pypi
import multiprocessing as mp from itertools import repeat import pickle from pathlib import Path import typing from tqdm import tqdm import pygraphviz as pgv import networkx as nx from recurse_words.corpi import get_corpus from recurse_words.recursers.recurser import Recurser class Graph_Recurser(Recurser): """ ...
/recurse-words-0.2.1.tar.gz/recurse-words-0.2.1/recurse_words/recursers/graph.py
0.643217
0.200479
graph.py
pypi
# %% auto 0 __all__ = ['get_preorder_traversal', 'get_graph_edges', 'get_graph'] # %% ../01_graph.ipynb 4 from .node import Node # %% ../01_graph.ipynb 5 import networkx as nx from typing import List, Dict # %% ../01_graph.ipynb 6 def get_preorder_traversal( history: List[int] # list of node ids recording when ea...
/recursion_visualizer-0.0.1-py3-none-any.whl/recursion_visualizer/graph.py
0.900549
0.628379
graph.py
pypi
from abc import ABC, abstractmethod from enum import Enum from collections.abc import Callable, Iterator # Possible iteration orders. Order = Enum('Order', 'PRE POST') Direction = Enum('Direction', 'FORWARD REVERSE') class Recursive(ABC): """Abstract base class for classes that provide the __recur__() method"""...
/recursive-abc-0.2.0.tar.gz/recursive-abc-0.2.0/recur/abc.py
0.89177
0.248124
abc.py
pypi
from types import CodeType, FunctionType, MethodType import sys DECORATOR_LIST_FIELD_NAME = "__wraped_with_" def mount_to_module(module_to_mount, object_to_mount, name_in_module): """Mount Given function to given module. Args: module_to_mount(module): module to mount function. object_to_mou...
/recursive_decorator-1.0.7.tar.gz/recursive_decorator-1.0.7/recursive_decorator/utils.py
0.606265
0.274718
utils.py
pypi
from __future__ import annotations import argparse import glob import logging import os import sys import xarray from recursive_diff.recursive_diff import recursive_diff LOGFORMAT = "%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] %(message)s" def argparser() -> argparse.ArgumentParser: """Return precompi...
/recursive_diff-1.1.0.tar.gz/recursive_diff-1.1.0/recursive_diff/ncdiff.py
0.683736
0.209126
ncdiff.py
pypi
import uuid from recursive_parse import recursive_parse """ data schema: GameID: uuid Map: str Duration: float (minutes) PlayerName: str IsWinner: bool Race: str ('Protoss', 'Terran', 'Zerg') UnitName: str BirthTime: float (minutes) DeathTime: float (minutes) """ def parse_data(players, timeline, stats, metadata, ...
/recursive-parse-0.0.2.tar.gz/recursive-parse-0.0.2/recursive_parse/hsc_analysis.py
0.526586
0.258303
hsc_analysis.py
pypi
# recurtx [![Python version](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9-blue.svg)](https://pypi.org/project/recurtx/) [![PyPI version](https://badge.fury.io/py/recurtx.svg)](https://badge.fury.io/py/recurtx) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.co...
/recurtx-0.0.9.tar.gz/recurtx-0.0.9/README.md
0.595963
0.804329
README.md
pypi
import functools from typing import AnyStr, Generator, Tuple from redis import Redis from redis.lock import Lock from ._base import _BaseMapping from .typing import TTL, KeyType __author__ = 'Memory_Leak<irealing@163.com>' class RedCache(_BaseMapping): def __init__(self, redis: Redis): super().__init_...
/red_cache-0.2.5-py3-none-any.whl/red_cache/objects.py
0.828592
0.19789
objects.py
pypi
import os import sys import ftputil import ftputil.session from functools import wraps from urllib.parse import urlparse import jsonschema def parse_ftp(url): """ Parses the given FTP URL and extracts the FTP host and path. :param url: The FTP URL to parse. :return: A tuple containing the FTP host an...
/red_connector_ftp-1.2-py3-none-any.whl/red_connector_ftp/commons/helpers.py
0.547101
0.208985
helpers.py
pypi
import json import os import stat import subprocess from tempfile import NamedTemporaryFile from argparse import ArgumentParser import jsonschema import pexpect from red_connector_ssh.helpers import DEFAULT_PORT, graceful_error, check_remote_dir_available, \ InvalidAuthenticationError, find_executable, create_ssh...
/red_connector_ssh-1.3-py3-none-any.whl/red_connector_ssh/mount_dir.py
0.559531
0.173183
mount_dir.py
pypi
import os from fabric.api import env from config import CustomConfig from functions import gather_remotes # Import all tasks import local from deploy import deploy, migrate GIT_REPO_NAME = 'project-git' GIT_WORKING_DIR = '/srv/active' def setup_env(project_path): """ Sets up the env settings for the fabric...
/red-fab-deploy-0.0.8.tar.gz/red-fab-deploy-0.0.8/fab_deploy/__init__.py
0.458591
0.167491
__init__.py
pypi
from fabric.api import env from fabric.tasks import Task from utils import get_security_group from api import get_ec2_connection class FirewallSync(Task): """ Update security group policies of AWS based on info read from server.ini Under each section defining a type of server, you will find 'open-ports...
/red-fab-deploy-0.0.8.tar.gz/red-fab-deploy-0.0.8/fab_deploy/amazon/manage.py
0.499756
0.190762
manage.py
pypi
from fabric.api import local, env, execute, run from fabric.tasks import Task from fabric.context_managers import cd class AddGitRemote(Task): """ Adds a remote to your git repo. Requires two arguments: * **remote_name**: The name this remote should have in your repo. * **user_and_host**: The co...
/red-fab-deploy-0.0.8.tar.gz/red-fab-deploy-0.0.8/fab_deploy/local/git.py
0.563738
0.169234
git.py
pypi
import sys import inspect import types from functools import wraps from fabric.tasks import Task, WrappedCallableTask from fabric.api import env, settings from . import functions class PlatformCallableTask(WrappedCallableTask): def __init__(self, callable, platform, *args, **kwargs): self.env_kwargs = {...
/red-fab-deploy2-0.2.5.tar.gz/red-fab-deploy2-0.2.5/fab_deploy2/tasks.py
0.539469
0.252638
tasks.py
pypi
import abc import json import pickle from datetime import timedelta from typing import AnyStr, AsyncGenerator, Tuple, Callable, Union, TypeVar, Any from aredis import StrictRedis _Ret = TypeVar('_Ret') TTL = Union[int, timedelta] Encoder = Callable[[Any], AnyStr] Decoder = Callable[[bytes], Any] KeyType = Union[AnySt...
/red_helper-0.1.1-py3-none-any.whl/red_helper/types.py
0.670932
0.162015
types.py
pypi
from typing import AnyStr, AsyncGenerator, Tuple, Optional from aredis import StrictRedis from ._base import _BaseMapping from .types import RedCollection, TTL from ._exc import UnsupportedOperation class RedHelper(_BaseMapping): def __init__(self, redis: StrictRedis): super().__init__(redis, "") ...
/red_helper-0.1.1-py3-none-any.whl/red_helper/objects.py
0.851073
0.207014
objects.py
pypi
import numpy as np import scipy.optimize as op import matplotlib.pyplot as plt from .psd import psd, psd_from_fft2 def chi2_simple(data_1, data_2, err): """ Simplest chi2 function comparing two sets of datas. Parameters ========== data_1, data_2 : array_like Set of data to be compared. e...
/red_magic-0.0.11-py3-none-any.whl/red_magic/chi2.py
0.81409
0.812904
chi2.py
pypi
import numpy as np from matplotlib.widgets import ( LassoSelector, RectangleSelector, Button, RadioButtons ) from matplotlib.path import Path class Data_Selector(object): def __init__(self, ax, line, proceed_func=None, alpha_other=0.3): self.canvas = ax.figure.canvas self.line = l...
/red_magic-0.0.11-py3-none-any.whl/red_magic/graphic_selection.py
0.637144
0.248691
graphic_selection.py
pypi
import matplotlib.pyplot as plt from matplotlib.widgets import TextBox, Button from scipy.optimize import minimize from tqdm import tqdm class Manual_fitting(): # induce a bug with the text_boxes list not restarting at each call of # a new instance of Manual_fitting # to be fix later i guess :/ t...
/red_magic-0.0.11-py3-none-any.whl/red_magic/manual_fitting.py
0.479016
0.327991
manual_fitting.py
pypi
import json import requests from datetime import timedelta from .models.enum_user_role import EnumUserRole from .models.enum_user_type import EnumUserType from .exceptions import RedOctoberDecryptException from .exceptions import RedOctoberRemoteException class RedOctober(object): """ It provides Python bindi...
/red-october-0.2.1b173.tar.gz/red-october-0.2.1b173/red_october/red_october.py
0.863536
0.312311
red_october.py
pypi
import warnings from collections import OrderedDict from textwrap import dedent from typing import Union, Optional, List import logging import pandas as pd from red_panda.pandas import PANDAS_TOCSV_KWARGS from red_panda.aws import ( REDSHIFT_RESERVED_WORDS, REDSHIFT_COPY_KWARGS, ) from red_panda.utils import ...
/red-panda-1.0.2.tar.gz/red-panda-1.0.2/red_panda/red_panda.py
0.791821
0.231495
red_panda.py
pypi
import logging from typing import Union, Optional, List import pandas as pd import psycopg2 from red_panda.typing import QueryResult, TemplateQueryResult from red_panda.pandas import PANDAS_TOCSV_KWARGS from red_panda.aws.templates.redshift import ( SQL_NUM_SLICES, SQL_TABLE_INFO, SQL_TABLE_INFO_SIMPLIFIE...
/red-panda-1.0.2.tar.gz/red-panda-1.0.2/red_panda/aws/redshift.py
0.859251
0.16502
redshift.py
pypi
REDSHIFT_RESERVED_WORDS = [ "aes128", "aes256", "all", "allowoverwrite", "analyse", "analyze", "and", "any", "array", "as", "asc", "authorization", "backup", "between", "binary", "blanksasnull", "both", "bytedict", "bzip2", "case", "cas...
/red-panda-1.0.2.tar.gz/red-panda-1.0.2/red_panda/aws/__init__.py
0.430626
0.463323
__init__.py
pypi
# red-postgres Piccolo Postgres integration for Red-DiscordBot, although it could be used with any dpy bot as an easy wrapper for making postgres with cogs more modular. ![Postgres 15](https://img.shields.io/badge/postgres%2015-%23316192.svg?style=for-the-badge&logo=postgresql&logoColor=white) ![Red-DiscordBot](https...
/red-postgres-0.1.10.tar.gz/red-postgres-0.1.10/README.md
0.435781
0.68589
README.md
pypi
from typing import Optional from .signature import FIELD_PRIME, pedersen_hash def get_msg( instruction_type: int, vault0: int, vault1: int, amount0: int, amount1: int, token0: int, token1_or_pub_key: int, nonce: int, expiration_timestamp: int, hash=pedersen_hash, condition: Optional[int] = No...
/red_py_sdk-0.1.10-py3-none-any.whl/redpysdk/starkex_message.py
0.915968
0.57087
starkex_message.py
pypi
from web3 import Web3 import web3 from .signature import private_to_stark_key, sign from .starkex_message import get_limit_order_msg_with_fee, get_transfer_msg def get_asset_info(type, address): if type.lower() == "eth": return '0x8322fff2' elif type == 'ERC20': return '0xf47261b0' + address[2...
/red_py_sdk-0.1.10-py3-none-any.whl/redpysdk/starkex_utils.py
0.49707
0.164047
starkex_utils.py
pypi
from typing import Tuple import mpmath import sympy from sympy.core.numbers import igcdex # A type that represents a point (x,y) on an elliptic curve. ECPoint = Tuple[int, int] def pi_as_string(digits: int) -> str: """ Returns pi as a string of decimal digits without the decimal point ("314..."). """ ...
/red_py_sdk-0.1.10-py3-none-any.whl/redpysdk/math_utils.py
0.950995
0.644169
math_utils.py
pypi
from typing import List, Union from dataclasses import dataclass, field import hodgepodge.helpers import itertools @dataclass(frozen=True) class Tactic: external_id: str name: str @property def id(self): return self.external_id @dataclass(frozen=True) class Technique: external_id: str ...
/red_raccoon-0.0.0.tar.gz/red_raccoon-0.0.0/red_raccoon/integrations/mitre_attack_evaluations/types.py
0.944009
0.512205
types.py
pypi
from red_raccoon.integrations.mitre_attack_evaluations.types import Tactic, Technique, Evaluation, Step, Test, \ Observation, Screenshot import hodgepodge.helpers import logging import re import os logger = logging.getLogger(__name__) _RE_VENDOR_AND_GROUP = re.compile(r'([\w_-]+)\.1\.([\w_-]+)\..+') def parse_...
/red_raccoon-0.0.0.tar.gz/red_raccoon-0.0.0/red_raccoon/integrations/mitre_attack_evaluations/parsers.py
0.5144
0.435301
parsers.py
pypi
from typing import List, Dict, Union from dataclasses import dataclass, field from red_raccoon.integrations.mitre_attack import MITRE_ATTACK_ENTERPRISE, MITRE_ATTACK_MOBILE, \ MITRE_ATTACK_PRE_ATTACK, MITRE_CAPEC, MITRE_CWE, NIST_MOBILE_THREAT_CATALOGUE import red_raccoon.integrations.stix.parsers import red_racco...
/red_raccoon-0.0.0.tar.gz/red_raccoon-0.0.0/red_raccoon/integrations/mitre_attack/types.py
0.879438
0.205276
types.py
pypi
import logging import hodgepodge.helpers import red_raccoon.helpers import red_raccoon.integrations.stix.parsers from hodgepodge.helpers import ensure_type from red_raccoon.integrations.mitre_attack import MITRE_ATTACK_ENTERPRISE, MITRE_ATTACK_PRE_ATTACK, \ MITRE_ATTACK_MOBILE, MATRIX, TACTIC from red_raccoon.i...
/red_raccoon-0.0.0.tar.gz/red_raccoon-0.0.0/red_raccoon/integrations/mitre_attack/parsers.py
0.417746
0.168651
parsers.py
pypi
from typing import List, Union from dataclasses import dataclass, field from red_raccoon.integrations.atomic_red_team import DEFAULT_COMMAND_TIMEOUT, \ DEFAULT_COMMAND_TIMEOUT_FOR_DEPENDENCY_RESOLUTION from red_raccoon.platforms import WINDOWS, LINUX, MACOS, CURRENT_OS_TYPE from red_raccoon.commands import DEFAULT...
/red_raccoon-0.0.0.tar.gz/red_raccoon-0.0.0/red_raccoon/integrations/atomic_red_team/types.py
0.867696
0.177152
types.py
pypi
import logging import yaml import os import hodgepodge.helpers import hodgepodge.files import hodgepodge.path import red_raccoon.integrations.atomic_red_team.parsers as parsers from hodgepodge import UTF8 from hodgepodge.helpers import ensure_type from hodgepodge.toolkits.filesystem.search.api import FilesystemSearch...
/red_raccoon-0.0.0.tar.gz/red_raccoon-0.0.0/red_raccoon/integrations/atomic_red_team/api.py
0.443841
0.159381
api.py
pypi
from typing import List, Union from dataclasses import dataclass, field from hodgepodge.helpers import ensure_type from red_raccoon.integrations.mitre_attack_navigator import DEFAULT_LAYER_NAME, DEFAULT_LAYER_DESCRIPTION, \ DEFAULT_LAYER_DOMAIN, DEFAULT_LAYER_VERSION, DEFAULT_COLOR import hodgepodge.helpers impor...
/red_raccoon-0.0.0.tar.gz/red_raccoon-0.0.0/red_raccoon/integrations/mitre_attack_navigator/types.py
0.838018
0.270757
types.py
pypi
from __future__ import annotations import argparse import re import json import discord.ui from discord import ButtonStyle from red_star.rs_errors import CommandSyntaxError from urllib.parse import urlparse from typing import TYPE_CHECKING if TYPE_CHECKING: import discord from red_star.config_manager import Js...
/red_star-3.0.2-py3-none-any.whl/red_star/rs_utils.py
0.803097
0.181444
rs_utils.py
pypi
from __future__ import annotations import datetime import json import discord.utils from discord.ext import tasks from random import choice from red_star.plugin_manager import BasePlugin from red_star.rs_errors import CommandSyntaxError, ChannelNotFoundError, DataCarrier from red_star.rs_utils import respond, RSArgumen...
/red_star-3.0.2-py3-none-any.whl/red_star/plugins/motd.py
0.591605
0.159577
motd.py
pypi
import shlex import discord from string import capwords from red_star.plugin_manager import BasePlugin from red_star.rs_errors import CommandSyntaxError from red_star.rs_utils import respond, is_positive, find_role, group_items, RSArgumentParser from red_star.command_dispatcher import Command class RoleCommands(BaseP...
/red_star-3.0.2-py3-none-any.whl/red_star/plugins/roles.py
0.467332
0.279862
roles.py
pypi
import discord from red_star.plugin_manager import BasePlugin from red_star.rs_utils import respond from red_star.command_dispatcher import Command from red_star.rs_errors import CommandSyntaxError from random import randint from collections import defaultdict from enum import Enum import re roll_tokens = re.compile...
/red_star-3.0.2-py3-none-any.whl/red_star/plugins/diceroll.py
0.481941
0.322619
diceroll.py
pypi
import discord from asyncio import sleep from string import capwords from red_star.plugin_manager import BasePlugin from red_star.rs_errors import UserPermissionError from red_star.rs_utils import respond from red_star.rs_version import version from red_star.command_dispatcher import Command # Yes, I know about multil...
/red_star-3.0.2-py3-none-any.whl/red_star/plugins/info.py
0.707506
0.456591
info.py
pypi
from red_star.plugin_manager import BasePlugin from red_star.rs_errors import CommandSyntaxError, UserPermissionError from red_star.rs_utils import respond, RSArgumentParser from red_star.command_dispatcher import Command import shlex import discord class Voting(BasePlugin): name = "voting" version = "1.0" ...
/red_star-3.0.2-py3-none-any.whl/red_star/plugins/voting.py
0.544075
0.157817
voting.py
pypi
from red_star.plugin_manager import BasePlugin from red_star.rs_utils import respond from red_star.command_dispatcher import Command from red_star.rs_errors import ChannelNotFoundError, CommandSyntaxError import discord import shlex class ChannelManagerCommands(BasePlugin): name = "channel_manager_commands" v...
/red_star-3.0.2-py3-none-any.whl/red_star/plugins/channel_manager_commands.py
0.645567
0.274838
channel_manager_commands.py
pypi