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 |
|---|---|---|---|---|---|---|
flowseq | flowseq-master/flownmt/modules/priors/length_predictors/predictor.py | from typing import Dict, Tuple
import torch
import torch.nn as nn
class LengthPredictor(nn.Module):
"""
Length Predictor
"""
_registry = dict()
def __init__(self):
super(LengthPredictor, self).__init__()
self.length_unit = None
def set_length_unit(self, length_unit):
... | 1,712 | 26.629032 | 120 | py |
flowseq | flowseq-master/flownmt/modules/priors/length_predictors/utils.py | from typing import Tuple
import numpy as np
import torch
import torch.nn.functional as F
def discretized_mix_logistic_loss(x, means, logscales, logit_probs,
bin_size, lower, upper) -> torch.Tensor:
"""
loss for discretized mixture logistic distribution
Args:
x: [b... | 3,823 | 29.592 | 114 | py |
flowseq | flowseq-master/flownmt/modules/priors/length_predictors/diff_discretized_mix_logistic.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.modules.priors.length_predictors.predictor import LengthPredictor
from flownmt.modules.priors.length_predictors.utils import discretized_mix_logistic_loss, discretized_mix_logi... | 4,046 | 39.069307 | 120 | py |
flowseq | flowseq-master/flownmt/modules/priors/length_predictors/__init__.py | from flownmt.modules.priors.length_predictors.predictor import LengthPredictor
from flownmt.modules.priors.length_predictors.diff_discretized_mix_logistic import DiffDiscreteMixLogisticLengthPredictor
from flownmt.modules.priors.length_predictors.diff_softmax import DiffSoftMaxLengthPredictor
| 294 | 72.75 | 121 | py |
flowseq | flowseq-master/flownmt/modules/encoders/encoder.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
class Encoder(nn.Module):
"""
Src Encoder to encode source sentence
"""
_registry = dict()
def __init__(self, vocab_size, embed_dim, padding_idx):
super(Encoder, self).__init__()
self... | 1,549 | 28.245283 | 82 | py |
flowseq | flowseq-master/flownmt/modules/encoders/transformer.py | from overrides import overrides
from typing import Dict, Tuple
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.modules.encoders.encoder import Encoder
from flownmt.nnet.transformer import TransformerEncoderLayer
from flownmt.nnet.positional_encoding import PositionalEncoding... | 2,782 | 34.227848 | 132 | py |
flowseq | flowseq-master/flownmt/modules/encoders/__init__.py | from flownmt.modules.encoders.encoder import Encoder
from flownmt.modules.encoders.rnn import RecurrentEncoder
from flownmt.modules.encoders.transformer import TransformerEncoder
| 179 | 44 | 67 | py |
flowseq | flowseq-master/flownmt/modules/encoders/rnn.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.modules.encoders.encoder import Encoder
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
class RecurrentCore(nn.Module):
def __init__(self, embed,... | 2,897 | 36.153846 | 119 | py |
flowseq | flowseq-master/flownmt/modules/posteriors/shift_rnn.py | from overrides import overrides
from typing import Tuple, Dict
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
from flownmt.nnet.weightnorm import LinearWeightNorm
from flownmt.modules.posteriors.posterior import Posterior
from... | 7,669 | 49.460526 | 143 | py |
flowseq | flowseq-master/flownmt/modules/posteriors/transformer.py | from overrides import overrides
from typing import Tuple, Dict
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from flownmt.nnet.weightnorm import LinearWeightNorm
from flownmt.nnet.transformer import TransformerDecoderLayer
from flownmt.nnet.positional_encoding import PositionalEncoding... | 5,026 | 42.713043 | 143 | py |
flowseq | flowseq-master/flownmt/modules/posteriors/__init__.py | from flownmt.modules.posteriors.posterior import Posterior
from flownmt.modules.posteriors.rnn import RecurrentPosterior
from flownmt.modules.posteriors.shift_rnn import ShiftRecurrentPosterior
from flownmt.modules.posteriors.transformer import TransformerPosterior
| 266 | 52.4 | 72 | py |
flowseq | flowseq-master/flownmt/modules/posteriors/rnn.py | from overrides import overrides
from typing import Tuple, Dict
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
from flownmt.nnet.weightnorm import LinearWeightNorm
from flownmt.modules.posteriors.posterior import Posterior
from... | 6,032 | 47.264 | 143 | py |
flowseq | flowseq-master/flownmt/modules/posteriors/posterior.py | import math
from typing import Dict, Tuple
import torch
import torch.nn as nn
class Posterior(nn.Module):
"""
posterior class
"""
_registry = dict()
def __init__(self, vocab_size, embed_dim, padding_idx, _shared_embed=None):
super(Posterior, self).__init__()
if _shared_embed is No... | 3,375 | 33.10101 | 143 | py |
flowseq | flowseq-master/flownmt/flows/nmt.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
from flownmt.flows.flow import Flow
from flownmt.flows.actnorm import ActNormFlow
from flownmt.flows.linear import InvertibleMultiHeadFlow
from flownmt.flows.couplings.coupling import NICE
from flownmt.utils import squeez... | 24,648 | 44.815985 | 144 | py |
flowseq | flowseq-master/flownmt/flows/flow.py | from typing import Dict, Tuple
import torch
import torch.nn as nn
class Flow(nn.Module):
"""
Normalizing Flow base class
"""
_registry = dict()
def __init__(self, inverse):
super(Flow, self).__init__()
self.inverse = inverse
def forward(self, *inputs, **kwargs) -> Tuple[torch... | 3,608 | 30.657895 | 118 | py |
flowseq | flowseq-master/flownmt/flows/actnorm.py | from overrides import overrides
from typing import Dict, Tuple
import numpy as np
import torch
import torch.nn as nn
from torch.nn import Parameter
from flownmt.flows.flow import Flow
class ActNormFlow(Flow):
def __init__(self, in_features, inverse=False):
super(ActNormFlow, self).__init__(inverse)
... | 3,655 | 32.851852 | 112 | py |
flowseq | flowseq-master/flownmt/flows/linear.py | from overrides import overrides
from typing import Dict, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import Parameter
from flownmt.flows.flow import Flow
class InvertibleLinearFlow(Flow):
def __init__(self, in_features, inverse=False):
super(InvertibleLinearFlow... | 7,141 | 34.356436 | 124 | py |
flowseq | flowseq-master/flownmt/flows/__init__.py | from flownmt.flows.flow import Flow
from flownmt.flows.actnorm import ActNormFlow
from flownmt.flows.parallel import *
from flownmt.flows.linear import InvertibleMultiHeadFlow, InvertibleLinearFlow
from flownmt.flows.couplings import *
from flownmt.flows.nmt import NMTFlow
| 274 | 38.285714 | 78 | py |
flowseq | flowseq-master/flownmt/flows/parallel/data_parallel.py | from overrides import overrides
from typing import Tuple
import torch
from torch.nn.parallel.replicate import replicate
from flownmt.flows.parallel.parallel_apply import parallel_apply
from torch.nn.parallel.scatter_gather import scatter_kwargs, gather
from torch.nn.parallel.data_parallel import _check_balance
from fl... | 2,891 | 37.56 | 107 | py |
flowseq | flowseq-master/flownmt/flows/parallel/__init__.py | from flownmt.flows.parallel.data_parallel import DataParallelFlow
| 66 | 32.5 | 65 | py |
flowseq | flowseq-master/flownmt/flows/parallel/parallel_apply.py | import threading
import torch
def get_a_var(obj):
if isinstance(obj, torch.Tensor):
return obj
if isinstance(obj, list) or isinstance(obj, tuple):
for result in map(get_a_var, obj):
if isinstance(result, torch.Tensor):
return result
if isinstance(obj, dict):
... | 2,756 | 33.4625 | 100 | py |
flowseq | flowseq-master/flownmt/flows/couplings/transform.py | import math
from overrides import overrides
from typing import Tuple
import torch
class Transform():
@staticmethod
def fwd(z: torch.Tensor, mask: torch.Tensor, params) -> Tuple[torch.Tensor, torch.Tensor]:
raise NotImplementedError
@staticmethod
def bwd(z: torch.Tensor, mask: torch.Tensor, pa... | 4,619 | 32.478261 | 101 | py |
flowseq | flowseq-master/flownmt/flows/couplings/__init__.py | from flownmt.flows.couplings.coupling import NICE
| 50 | 24.5 | 49 | py |
flowseq | flowseq-master/flownmt/flows/couplings/coupling.py | from overrides import overrides
from typing import Tuple, Dict
import torch
from flownmt.flows.couplings.blocks import NICEConvBlock, NICERecurrentBlock, NICESelfAttnBlock
from flownmt.flows.flow import Flow
from flownmt.flows.couplings.transform import Transform, Additive, Affine, NLSQ
class NICE(Flow):
"""
... | 7,316 | 40.573864 | 155 | py |
flowseq | flowseq-master/flownmt/flows/couplings/blocks.py | import torch
import torch.nn as nn
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
from flownmt.nnet.weightnorm import Conv1dWeightNorm, LinearWeightNorm
from flownmt.nnet.attention import GlobalAttention, MultiHeadAttention
from flownmt.nnet.positional_encoding import PositionalEncoding
from ... | 5,809 | 44.748031 | 133 | py |
flowseq | flowseq-master/flownmt/optim/lr_scheduler.py | from torch.optim.optimizer import Optimizer
class _LRScheduler(object):
def __init__(self, optimizer, last_epoch=-1):
if not isinstance(optimizer, Optimizer):
raise TypeError('{} is not an Optimizer'.format(
type(optimizer).__name__))
self.optimizer = optimizer
... | 4,603 | 40.477477 | 94 | py |
flowseq | flowseq-master/flownmt/optim/adamw.py | import math
import torch
from torch.optim.optimizer import Optimizer
class AdamW(Optimizer):
r"""Implements AdamW algorithm.
This implementation is modified from torch.optim.Adam based on:
`Fixed Weight Decay Regularization in Adam`
(see https://arxiv.org/abs/1711.05101)
Adam has been proposed in... | 4,811 | 41.584071 | 116 | py |
flowseq | flowseq-master/flownmt/optim/__init__.py | from flownmt.optim.adamw import AdamW
from flownmt.optim.lr_scheduler import InverseSquareRootScheduler, ExponentialScheduler
| 126 | 41.333333 | 87 | py |
flowseq | flowseq-master/flownmt/nnet/weightnorm.py | from overrides import overrides
import torch
import torch.nn as nn
class LinearWeightNorm(nn.Module):
"""
Linear with weight normalization
"""
def __init__(self, in_features, out_features, bias=True):
super(LinearWeightNorm, self).__init__()
self.linear = nn.Linear(in_features, out_fea... | 2,806 | 32.819277 | 91 | py |
flowseq | flowseq-master/flownmt/nnet/transformer.py | import torch.nn as nn
from flownmt.nnet.attention import MultiHeadAttention, PositionwiseFeedForward
class TransformerEncoderLayer(nn.Module):
def __init__(self, model_dim, hidden_dim, heads, dropout=0.0, mask_diag=False):
super(TransformerEncoderLayer, self).__init__()
self.slf_attn = MultiHeadA... | 1,784 | 42.536585 | 98 | py |
flowseq | flowseq-master/flownmt/nnet/positional_encoding.py | import math
import torch
import torch.nn as nn
from flownmt.utils import make_positions
class PositionalEncoding(nn.Module):
"""This module produces sinusoidal positional embeddings of any length.
Padding symbols are ignored.
"""
def __init__(self, encoding_dim, padding_idx, init_size=1024):
... | 2,348 | 36.285714 | 99 | py |
flowseq | flowseq-master/flownmt/nnet/__init__.py | from flownmt.nnet.weightnorm import LinearWeightNorm, Conv1dWeightNorm
from flownmt.nnet.attention import GlobalAttention, MultiHeadAttention, PositionwiseFeedForward
from flownmt.nnet.transformer import TransformerEncoderLayer, TransformerDecoderLayer
from flownmt.nnet.layer_norm import LayerNorm
from flownmt.nnet.pos... | 428 | 60.285714 | 95 | py |
flowseq | flowseq-master/flownmt/nnet/layer_norm.py | import torch
import torch.nn as nn
def LayerNorm(normalized_shape, eps=1e-5, elementwise_affine=True, export=False):
if not export and torch.cuda.is_available():
try:
from apex.normalization import FusedLayerNorm
return FusedLayerNorm(normalized_shape, eps, elementwise_affine)
... | 428 | 32 | 81 | py |
flowseq | flowseq-master/flownmt/nnet/criterion.py | import torch.nn.functional as F
import torch.nn as nn
class LabelSmoothedCrossEntropyLoss(nn.Module):
"""
Cross Entropy loss with label smoothing.
For training, the loss is smoothed with parameter eps, while for evaluation, the smoothing is disabled.
"""
def __init__(self, label_smoothing):
... | 1,029 | 35.785714 | 107 | py |
flowseq | flowseq-master/flownmt/nnet/attention.py | from overrides import overrides
import torch
from torch.nn import Parameter
import torch.nn as nn
import torch.nn.functional as F
from flownmt.nnet.layer_norm import LayerNorm
class GlobalAttention(nn.Module):
"""
Global Attention between encoder and decoder
"""
def __init__(self, key_features, quer... | 9,245 | 35.401575 | 116 | py |
flowseq | flowseq-master/flownmt/data/dataloader.py | import codecs
import math
import random
from collections import defaultdict
import numpy as np
import torch
import os
def get_sorted_wordlist(path):
freqs = defaultdict(lambda: 0)
with codecs.open(path, "r", encoding="utf-8") as fin:
for line in fin:
words = line.strip().split()
... | 21,852 | 39.097248 | 149 | py |
flowseq | flowseq-master/flownmt/data/__init__.py | __author__ = 'violet-zct'
from flownmt.data.dataloader import NMTDataSet, DataIterator
| 88 | 21.25 | 60 | py |
flowseq | flowseq-master/experiments/nmt.py | import os
import sys
current_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(root_path)
import time
import json
import random
import math
import numpy as np
import torch
from torch.nn.utils import clip_grad_norm_
import torch... | 34,259 | 41.559006 | 151 | py |
flowseq | flowseq-master/experiments/slurm.py | import sys
import os
current_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(root_path)
import torch.multiprocessing as mp
import experiments.options as options
from experiments.nmt import main as single_process_main
def ma... | 1,374 | 27.645833 | 117 | py |
flowseq | flowseq-master/experiments/translate.py | import os
import sys
current_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(root_path)
import time
import json
import random
import numpy as np
import torch
from flownmt.data import NMTDataSet, DataIterator
from flownmt imp... | 8,142 | 39.311881 | 131 | py |
flowseq | flowseq-master/experiments/options.py | import os, sys
from argparse import ArgumentParser
def parse_args():
parser = ArgumentParser(description='FlowNMT')
parser.add_argument('--rank', type=int, default=-1, metavar='N', help='rank of the process in all distributed processes')
parser.add_argument("--local_rank", type=int, default=0, metavar='N'... | 9,967 | 72.837037 | 143 | py |
flowseq | flowseq-master/experiments/distributed.py | import sys
import os
current_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(root_path)
import json
import signal
import threading
import torch
from flownmt.data import NMTDataSet
import experiments.options as options
from ex... | 4,220 | 30.736842 | 107 | py |
DataCovVac | DataCovVac-main/covvac-code/run_make_adj.py | #!/usr/bin/env python
"""Load and save and adjacency matrix.
Load adjacency matrix and define partitions.
Compute:
-------
- adjacency matrix
- community structure
Todo:
----
- country discovery
"""
import csv
import json
import pathlib
import networkx as nx
import numpy as np
from scipy import sparse
import cov
... | 2,280 | 27.873418 | 87 | py |
DataCovVac | DataCovVac-main/covvac-code/run_stats_url_media.py | #!/usr/bin/env python3
"""
File: run_stats_url_media.py
Author: Mauro Faccin
Email: mauro@gmail.com
Description: Fraction of tweets and retweets with urls from the critics and media sets.
"""
import json
from dataclasses import dataclass, field
import numpy as np
import tqdm
from scipy import sparse
import cov
impor... | 7,113 | 27.918699 | 87 | py |
DataCovVac | DataCovVac-main/covvac-code/run_community_outreach.py | #!/usr/bin/env python3
"""Compute the probability of finding a critic or media tweet in communities.
And they outreach probabilities.
"""
import json
from collections import Counter
import numpy as np
from scipy import sparse
import cov
import cov_utils
def read_communities(tau):
"""Read community structure."... | 3,656 | 26.496241 | 77 | py |
DataCovVac | DataCovVac-main/covvac-code/run_engagement.py | #!/usr/bin/env pyhton
"""Compute users engagement as an SIS model."""
from datetime import date, timedelta
import cov
import cov_utils as utils
from tqdm import tqdm
# classes
class Engaged:
"""Collect user engagement."""
def __init__(self, window=3):
self.__data__ = []
self.__cache__ = {
... | 4,681 | 25.754286 | 98 | py |
DataCovVac | DataCovVac-main/covvac-code/cov_utils.py | #!/usr/bin/env python3
"""Utilities.
File: cov_utils.py
Author: Mauro
Github: https://github.com/maurofaccin
Description: Utility functions for analysis
"""
import csv
import gzip
import pathlib
from datetime import date, timedelta
import networkx as nx
import numpy as np
from community import best_partition
BASENA... | 15,188 | 22.957413 | 99 | py |
DataCovVac | DataCovVac-main/covvac-code/cov.py | #!/usr/bin/env python
"""Utility functions."""
import csv
import gzip
import pathlib
import subprocess as sp
import tempfile
from collections import Counter
from dataclasses import dataclass, field
from datetime import date
import networkx as nx
import numpy as np
import pycountry
import pygenstability as stability
f... | 28,239 | 27.296593 | 100 | py |
DataCovVac | DataCovVac-main/covvac-code/run_community_temporal.py | #!/usr/bin/env python3
"""Compute the probability of finding a critic or media tweet in communities.
And they outreach probabilities.
"""
import json
from collections import Counter
from datetime import date, timedelta
import numpy as np
from scipy import sparse
import cov
import cov_utils
def read_communities(ta... | 4,643 | 30.167785 | 88 | py |
DataCovVac | DataCovVac-main/covvac-plots/plot_engagement.py | #!/usr/bin/env python
"""Plots engagement for a given window."""
import csv
from datetime import date, timedelta
import numpy as np
from matplotlib import dates as mdates
from matplotlib import pyplot, ticker
import cov
import cov_utils
from conf import WIN
pyplot.style.use("mplrc")
grey = "#999999"
keywords = []
... | 4,737 | 26.229885 | 90 | py |
DataCovVac | DataCovVac-main/covvac-plots/plot_community_periods.py | #!/usr/bin/env python3
"""Plot the temporal behaviour of the communities on the three periods."""
import json
from collections import Counter
from datetime import date, timedelta
import numpy as np
from matplotlib import pyplot
import cov_utils
pyplot.style.use("mplrc")
grey = "#999999"
class NumpyEncoder(json.JS... | 3,513 | 28.283333 | 93 | py |
DataCovVac | DataCovVac-main/covvac-plots/plot_hashtag_periods.py | #!/usr/bin/env python
"""Most important hashtags per period."""
import json
from collections import Counter
from datetime import date
import numpy as np
import squarify
from matplotlib import colors, pyplot
from matplotlib.transforms import Bbox
import cov
import cov_text
import cov_utils
pyplot.style.use("mplrc")... | 8,878 | 27.827922 | 88 | py |
DataCovVac | DataCovVac-main/covvac-plots/plot_community_reach_onlyprob.py | #!/usr/bin/env python3
"""Plot community reach.
depends on:
- ../run_10_make_adj.py
- ../
"""
import json
from collections import Counter
import numpy as np
from adjustText import adjust_text
from matplotlib import pyplot
import cov_utils
from conf import TAU
pyplot.style.use("mplrc")
grey = "#999999"
def load_... | 4,151 | 24.95 | 90 | py |
DataCovVac | DataCovVac-main/covvac-plots/plot_simple_stats.py | #!/usr/bin/env python3
"""Plot tweets and retweets fraction of critic and media content."""
from datetime import date
import numpy as np
from matplotlib import pyplot
import cov_utils
pyplot.style.use("mplrc")
grey = "#999999"
def main():
"""Do your stuff."""
data = cov_utils.load_csv("../data/daily_stats... | 1,658 | 25.758065 | 72 | py |
DataCovVac | DataCovVac-main/covvac-plots/plot_urls_comms_adj.py | #!/usr/bin/env python
"""Draw a plot of the community-urls usage."""
import json
import networkx as nx
import numpy as np
from matplotlib import colors, pyplot
from scipy import sparse
from sklearn import cluster
from conf import TAU
pyplot.style.use("mplrc")
def get_keywords(topic):
"""Load filtering words.
... | 7,814 | 26.421053 | 100 | py |
erics | erics-main/erics.py | import numpy as np
from scipy.stats import norm
from warnings import warn
import copy
import time
class ERICS:
def __init__(self, n_param, window_mvg_average=50, window_drift_detect=50, beta=0.0001, base_model='probit',
init_mu=0, init_sigma=1, epochs=10, lr_mu=0.01, lr_sigma=0.01):
"""
... | 13,134 | 47.468635 | 145 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/Satellite Map Generation/main.py | from create_map import create_map
def take_screenshot(lat: float, long: float, row: int, col: int, number: int, file_name: str):
"""
Args:
lat: Latitude of the left corner
long: Longitude of the left corner
row: Row count
col: Column count
number: Numbering to output fi... | 1,202 | 25.152174 | 94 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/Satellite Map Generation/create_map.py | import os
import time
import tkinter
import numpy as np
from PIL import Image
import pyscreenshot
from selenium import webdriver
# Removing fields from Google Maps
remove_from_view = [
"var element = document.getElementById(\"omnibox-container\");element.remove();",
"var element = document.getElementById(\"wa... | 7,084 | 39.953757 | 113 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/test.py | from pathlib import Path
import os
import gc
import argparse
import cv2
from PIL import Image
Image.MAX_IMAGE_PIXELS = 933120000
import numpy as np
import matplotlib.cm as cm
from pyqtree import Index
import pickle
import torch
import time
from models.matching import Matching
from models.utils.utils import AverageTime... | 14,274 | 45.347403 | 182 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/Feature_extractor.py | from pathlib import Path
import argparse
import numpy as np
import torch
import json
import os
from models.matching import Matching
from models.utils.utils import (AverageTimer, VideoStreamer, load_encoder_img, frame2tensor)
torch.set_grad_enabled(False)
if __name__ == '__main__':
parser = argparse.ArgumentPars... | 5,454 | 38.528986 | 103 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/models/matching.py | # %BANNER_BEGIN%
# ---------------------------------------------------------------------
# %COPYRIGHT_BEGIN%
#
# Magic Leap, Inc. ("COMPANY") CONFIDENTIAL
#
# Unpublished Copyright (c) 2020
# Magic Leap, Inc., All Rights Reserved.
#
# NOTICE: All information contained herein is, and remains the property
# of COMPAN... | 3,417 | 39.211765 | 77 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/models/superglue.py | # %BANNER_BEGIN%
# ---------------------------------------------------------------------
# %COPYRIGHT_BEGIN%
#
# Magic Leap, Inc. ("COMPANY") CONFIDENTIAL
#
# Unpublished Copyright (c) 2020
# Magic Leap, Inc., All Rights Reserved.
#
# NOTICE: All information contained herein is, and remains the property
# of COMPAN... | 11,316 | 38.848592 | 86 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/models/superpoint.py | # %BANNER_BEGIN%
# ---------------------------------------------------------------------
# %COPYRIGHT_BEGIN%
#
# Magic Leap, Inc. ("COMPANY") CONFIDENTIAL
#
# Unpublished Copyright (c) 2020
# Magic Leap, Inc., All Rights Reserved.
#
# NOTICE: All information contained herein is, and remains the property
# of COMPAN... | 8,145 | 39.128079 | 80 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/models/utils/utils.py | from pathlib import Path
import time
from collections import OrderedDict
from threading import Thread
import numpy as np
import math
from vidgear.gears import CamGear
import cv2
import torch
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('Agg')
class AverageTimer:
""" Class to help manage printi... | 14,700 | 38.732432 | 157 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/models/utils/utils_plot.py | import numpy as np
import cv2
import math
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('Agg')
# --- VISUALIZATION ---
def make_localization_plot(GeoLoc, image0, image1, kpts0, kpts1, mkpts0, mkpts1, color, size, center, points, img_box,
text, path=None, show_keypoints=... | 7,417 | 37.237113 | 118 | py |
PCVLabDrone2021 | PCVLabDrone2021-main/UAV Geolocalization/models/utils/utils_loc.py | import pyproj
import simplekml
import numpy as np
import cv2
import math
# extended libraries for extracting GPS ground truth from drone taken images
import re
import os
import simplekml
def update_current_GPS(sat_gps, pix_c):
GSD = [0.1493, -0.1492] # m/pix
# convert initial GPS to projective distance in me... | 8,311 | 41.192893 | 160 | py |
d3py | d3py-master/setup.py | #!/usr/bin/env python
from distutils.core import setup
from setuptools import setup
setup(
name='d3py',
version='0.2.3',
description='d3py',
author='Mike Dewar, Micha Gorelick and Adam Laiacano',
author_email='md@bit.ly',
url='https://github.com/mikedewar/D3py',
packages=['d3py', 'd3py.geo... | 424 | 24 | 58 | py |
d3py | d3py-master/examples/d3py_vega_line.py | import d3py
import pandas as pd
import random
x = range(0, 101, 1)
y = [random.randint(10, 100) for num in range(0, 101, 1)]
df = pd.DataFrame({'x': x, 'y': y})
#Create Pandas figure
fig = d3py.PandasFigure(df, 'd3py_area', port=8000, columns=['x', 'y'])
#Add Vega Area plot
fig += d3py.vega.Line()
#Show figure
fig... | 329 | 16.368421 | 71 | py |
d3py | d3py-master/examples/d3py_multiline.py | import numpy as np
import d3py
import pandas
T = 5*np.pi
x = np.linspace(-T,T,100)
a = 0.05
y = np.exp(-a*x) * np.sin(x)
z = np.exp(-a*x) * np.sin(0.5*x)
df = pandas.DataFrame({
'x' : x,
'y' : y,
'z' : z,
})
with d3py.PandasFigure(df, 'd3py_line', width=600, height=200) as fig:
fig += d3py.geoms.Line... | 477 | 19.782609 | 70 | py |
d3py | d3py-master/examples/d3py_area.py | import numpy as np
import d3py
import pandas
N = 500
T = 5*np.pi
x = np.linspace(-T,T,N)
y = np.sin(x)
y0 = np.cos(x)
df = pandas.DataFrame({
'x' : x,
'y' : y,
'y0' : y0,
})
with d3py.PandasFigure(df, 'd3py_area', width=500, height=250) as fig:
fig += d3py.geoms.Area('x', 'y', 'y0')
fig += d3py.g... | 384 | 16.5 | 70 | py |
d3py | d3py-master/examples/d3py_scatter.py | import numpy as np
import pandas
import d3py
n = 400
df = pandas.DataFrame({
'd1': np.arange(0,n),
'd2': np.random.normal(0, 1, n)
})
with d3py.PandasFigure(df, "example scatter plot using d3py", width=400, height=400) as fig:
fig += d3py.Point("d1", "d2", fill="DodgerBlue")
fig += d3py.xAxis('d1', la... | 398 | 23.9375 | 92 | py |
d3py | d3py-master/examples/d3py_vega_area.py | import d3py
import pandas as pd
import random
x = range(0, 21, 1)
y = [random.randint(25, 100) for num in range(0, 21, 1)]
df = pd.DataFrame({'x': x, 'y': y})
#Create Pandas figure
fig = d3py.PandasFigure(df, 'd3py_area', port=8080, columns=['x', 'y'])
#Add Vega Area plot
fig += d3py.vega.Area()
#Add interpolation... | 441 | 22.263158 | 71 | py |
d3py | d3py-master/examples/d3py_vega_scatter.py | import d3py
import pandas as pd
import random
n = 400
df = pd.DataFrame({'d1': np.arange(0,n),'d2': np.random.normal(0, 1, n)})
#Create Pandas figure
fig = d3py.PandasFigure(df, 'd3py_area', port=8000, columns=['d1', 'd2'])
#Add Vega Area plot
fig += d3py.vega.Scatter()
#Show figure
fig.show()
| 300 | 16.705882 | 73 | py |
d3py | d3py-master/examples/d3py_vega_bar.py | import d3py
import pandas as pd
import random
x = ['apples', 'oranges', 'grapes', 'bananas', 'plums', 'blackberries']
y = [10, 17, 43, 23, 31, 18]
df = pd.DataFrame({'x': x, 'y': y})
#Create Pandas figure
fig = d3py.PandasFigure(df, 'd3py_area', port=8000, columns=['x', 'y'])
#Add Vega Area plot
fig += d3py.vega.Ba... | 348 | 19.529412 | 71 | py |
d3py | d3py-master/examples/d3py_line.py | import numpy as np
import d3py
import pandas
T = 5*np.pi
x = np.linspace(-T,T,100)
a = 0.05
y = np.exp(-a*x) * np.sin(x)
df = pandas.DataFrame({
'x' : x,
'y' : y
})
with d3py.PandasFigure(df, 'd3py_line', width=600, height=200) as fig:
fig += d3py.geoms.Line('x', 'y', stroke='BlueViolet')
fig += d3py... | 374 | 17.75 | 70 | py |
d3py | d3py-master/examples/d3py_bar.py | import pandas
import d3py
import logging
logging.basicConfig(level=logging.DEBUG)
df = pandas.DataFrame(
{
"count" : [1,4,7,3,2,9],
"apple_type": ["a", "b", "c", "d", "e", "f"],
}
)
# use 'with' if you are writing a script and want to serve this up forever
with d3py.PandasFigure(df) as p:
... | 692 | 22.896552 | 78 | py |
d3py | d3py-master/examples/d3py_graph.py | import d3py
import networkx as nx
import logging
logging.basicConfig(level=logging.DEBUG)
G=nx.Graph()
G.add_edge(1,2)
G.add_edge(1,3)
G.add_edge(3,2)
G.add_edge(3,4)
G.add_edge(4,2)
# use 'with' if you are writing a script and want to serve this up forever
with d3py.NetworkXFigure(G, width=500, height=500) as p:
... | 359 | 19 | 74 | py |
d3py | d3py-master/tests/test_javascript.py | #!/usr/bin/python
from d3py import javascript as JS
def test_JavaScript_object_lookup():
g = JS.Selection("g").attr("color", "red")
j = JS.JavaScript() + g
assert(j.get_object("g", JS.Selection) == g)
g.attr("test", "test")
assert(j.get_object("g", JS.Selection) == g)
f = JS.Function("test"... | 558 | 20.5 | 50 | py |
d3py | d3py-master/tests/test_figure.py | # -*- coding: utf-8 -*-
'''
Figure Test
-------
Test figure object with nose package:
https://nose.readthedocs.org/en/latest/
'''
import d3py
import nose.tools as nt
class TestFigure():
def setup(self):
'''Setup Figure object for testing'''
self.Figure = d3py.Figure('test figure', 1024, 768... | 1,179 | 29.25641 | 79 | py |
d3py | d3py-master/d3py/test.py | import unittest
import css
import pandas
import d3py
import javascript
class TestCSS(unittest.TestCase):
def setUp(self):
self.css = css.CSS()
def test_init(self):
out = css.CSS({"#test":{"fill":"red"}})
self.assertTrue(out["#test"] == {"fill":"red"})
def test_get(se... | 2,503 | 29.168675 | 81 | py |
d3py | d3py-master/d3py/networkx_figure.py | import logging
import json
from networkx.readwrite import json_graph
import javascript as JS
from figure import Figure
class NetworkXFigure(Figure):
def __init__(self, graph, name="figure", width=400, height=100,
interactive=True, font="Asap", logging=False, template=None,
host="localhost", port... | 1,876 | 35.096154 | 84 | py |
d3py | d3py-master/d3py/figure.py | # -*- coding: utf-8 -*-
'''
Figure
-------
Abstract Base Class for all figures. Currently subclassed by pandas_figure,
can be subclassed for other figure types.
'''
import logging
import webbrowser
from HTTPHandler import CustomHTTPRequestHandler, ThreadedHTTPServer
import IPython.core.display
import threading
fr... | 12,067 | 34.390029 | 119 | py |
d3py | d3py-master/d3py/javascript.py | #!/usr/bin/python
import logging
class JavaScript(object):
# TODO: Add a lookup function so you can easily find/edit functions/objects
# defined within the JavaScript object
def __init__(self, statements=None):
self.statements = []
self.objects_lookup = {}
if statements is not... | 6,796 | 32.482759 | 107 | py |
d3py | d3py-master/d3py/HTTPHandler.py | import SimpleHTTPServer
import SocketServer
from cStringIO import StringIO
import sys
class ThreadedHTTPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
allow_reuse_address = True
class CustomHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def log_message(self, format, *args):
... | 2,383 | 32.111111 | 97 | py |
d3py | d3py-master/d3py/templates.py | d3py_template = '''<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://{{ host }}:{{ port }}/{{ name }}.js"></script>
<link type="text/css" rel="stylesheet" href="http://{{ host }}:{{ port }}/{{ name }}.css">
<link href='http... | 586 | 28.35 | 100 | py |
d3py | d3py-master/d3py/pandas_figure.py | import numpy as np
import logging
import json
import javascript as JS
from figure import Figure
class PandasFigure(Figure):
def __init__(self, data, name="figure", width=800, height=400,
columns = None, use_index=False, interactive=True, font="Asap",
logging=False, template=None, host="localhos... | 6,134 | 37.34375 | 91 | py |
d3py | d3py-master/d3py/__init__.py | from pandas_figure import *
from networkx_figure import *
from geoms import *
import javascript
| 96 | 18.4 | 29 | py |
d3py | d3py-master/d3py/css.py | #!/usr/bin/python
class CSS:
"""
a CSS object is a dictionary whose keys are CSS selectors and whose values
are dictionaries of CSS declarations. This object is named according to the
definition of CSS on wikipedia:
A style sheet consists of a list of rules.
Each rule or rule-set consi... | 2,020 | 35.745455 | 79 | py |
d3py | d3py-master/d3py/vega.py | '''
Vega/Vincent
-------
The d3py port of the Vincent project:
https://github.com/wrobstory/vincent
'''
from __future__ import print_function
import os
import json
from pkg_resources import resource_string
import pandas as pd
import pdb
class Vega(object):
'''Vega abstract base class'''
def __init__(self... | 14,109 | 35.086957 | 79 | py |
d3py | d3py-master/d3py/geoms/area.py | from geom import Geom, JavaScript, Selection, Function
class Area(Geom):
def __init__(self,x,yupper,ylower,**kwargs):
Geom.__init__(self,**kwargs)
self.x = x
self.yupper = yupper
self.ylower = ylower
self.params = [x, yupper, ylower]
self.debug = True
self.na... | 1,844 | 30.810345 | 88 | py |
d3py | d3py-master/d3py/geoms/geom.py | from ..css import CSS
from ..javascript import JavaScript, Selection, Function
class Geom:
def __init__(self, **kwargs):
self.styles = kwargs
self.js = JavaScript()
self.css = CSS()
def _build_js(self):
raise NotImplementedError
def _build_css(self):
raise ... | 340 | 21.733333 | 56 | py |
d3py | d3py-master/d3py/geoms/point.py | from geom import Geom, JavaScript, Selection, Function
class Point(Geom):
def __init__(self,x,y,c=None,**kwargs):
Geom.__init__(self, **kwargs)
self.x = x
self.y = y
self.c = c
self._id = 'point_%s_%s_%s'%(self.x,self.y,self.c)
self.params = [x,y,c]
self.name... | 1,968 | 34.160714 | 69 | py |
d3py | d3py-master/d3py/geoms/xaxis.py | from geom import Geom, JavaScript, Selection, Function
class xAxis(Geom):
def __init__(self,x, label=None, **kwargs):
"""
x : string
name of the column you want to use to define the x-axis
"""
Geom.__init__(self, **kwargs)
self.x = x
self.label = label if... | 1,650 | 29.574074 | 69 | py |
d3py | d3py-master/d3py/geoms/graph.py | from geom import Geom, JavaScript, Selection, Function
class ForceLayout(Geom):
def __init__(self,**kwargs):
Geom.__init__(self,**kwargs)
self.name = "forceLayout"
self._id = 'forceLayout'
self._build_js()
self._build_css()
self.styles = dict([(k[0].replace('_','-'),... | 2,376 | 32.478873 | 90 | py |
d3py | d3py-master/d3py/geoms/bar.py | from geom import Geom, JavaScript, Selection, Function
class Bar(Geom):
def __init__(self,x,y,**kwargs):
"""
This is a vertical bar chart - the height of each bar represents the
magnitude of each class
x : string
name of the column that contains the class label... | 2,313 | 29.853333 | 83 | py |
d3py | d3py-master/d3py/geoms/yaxis.py | from geom import Geom, JavaScript, Selection, Function
class yAxis(Geom):
def __init__(self,y, label=None, **kwargs):
"""
y : string
name of the column you want to use to define the y-axis
"""
Geom.__init__(self, **kwargs)
self.y = y
self.label = label if... | 1,677 | 30.074074 | 70 | py |
d3py | d3py-master/d3py/geoms/__init__.py | #!/usr/local/bin/python
from xaxis import xAxis
from yaxis import yAxis
from point import Point
from bar import Bar
from line import Line
from area import Area
from geom import Geom
from graph import ForceLayout
| 213 | 18.454545 | 29 | py |
d3py | d3py-master/d3py/geoms/line.py | from geom import Geom, JavaScript, Selection, Function
class Line(Geom):
def __init__(self,x,y,**kwargs):
Geom.__init__(self,**kwargs)
self.x = x
self.y = y
self.params = [x,y]
self.debug = True
self.name = "line"
self._build_js()
self._build_css()
... | 1,624 | 32.163265 | 82 | py |
z2n-periodogram | z2n-periodogram-master/setup.py | #! /usr/bin/python
# -*- coding: utf-8 -*-
# Generic/Built-in
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name='z2n-periodogram',
version='2.0.6',
license='MIT',
python_requires='>=3.6.9',
install_requires=[
... | 1,886 | 28.030769 | 74 | py |
z2n-periodogram | z2n-periodogram-master/z2n/main.py | #! /usr/bin/python
# -*- coding: utf-8 -*-
# Other Libraries
import click
import matplotlib
def cli() -> None:
"""Entry point to the Z2n Software."""
try:
matplotlib.use('tkagg')
except (ImportError, ModuleNotFoundError):
click.secho("Failed to use interactive backend.", fg='red')
... | 549 | 21 | 87 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.