repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
mfasDa/MadGraph5
MadSpin/decay.py
#!/usr/bin/env python from __future__ import division from __future__ import absolute_import from __future__ import print_function from madgraph.interface import reweight_interface from six.moves import map from six.moves import range from six.moves import zip #########################################################...
mfasDa/MadGraph5
tests/parallel_tests/test_madweight.py
################################################################################ # # Copyright (c) 2009 The MadGraph Development team and Contributors # # This file is a part of the MadGraph 5 project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # high-energy proce...
mfasDa/MadGraph5
tests/unit_tests/various/test_cmd.py
################################################################################ # # Copyright (c) 2012 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # h...
mfasDa/MadGraph5
madgraph/interface/amcatnlo_interface.py
<reponame>mfasDa/MadGraph5 ################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix...
mfasDa/MadGraph5
models/write_param_card.py
############################################################################### # # Copyright (c) 2010 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # hi...
mfasDa/MadGraph5
models/usermod.py
################################################################################ # # Copyright (c) 2011 The MadGraph Development team and Contributors # # This file is a part of the MadGraph 5 project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # high-energy proce...
mfasDa/MadGraph5
madgraph/iolibs/helas_call_writers.py
################################################################################ # # Copyright (c) 2010 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # h...
mfasDa/MadGraph5
tests/unit_tests/core/test_helas_objects.py
################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # h...
mfasDa/MadGraph5
tests/unit_tests/core/test_base_objects.py
################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # h...
mfasDa/MadGraph5
models/MSSM_SLHA2/coupling_orders.py
# This file was automatically created by FeynRules 1.7.53 # Mathematica version: 8.0 for Linux x86 (64-bit) (February 23, 2011) # Date: Tue 31 Jul 2012 19:55:22 from __future__ import absolute_import from .object_library import all_orders, CouplingOrder QCD = CouplingOrder(name = 'QCD', expansio...
mfasDa/MadGraph5
tests/unit_tests/fks/test_fks_helas_objects.py
<filename>tests/unit_tests/fks/test_fks_helas_objects.py ################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generat...
mfasDa/MadGraph5
tests/unit_tests/loop/test_import_LoopUFOModel.py
################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # h...
mfasDa/MadGraph5
madgraph/interface/extended_cmd.py
################################################################################ # # Copyright (c) 2011 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # h...
mfasDa/MadGraph5
tests/unit_tests/__init__.py
<reponame>mfasDa/MadGraph5<gh_stars>1-10 ################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagr...
mfasDa/MadGraph5
madgraph/loop/loop_diagram_generation.py
# ################################################################################ # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # h...
mfasDa/MadGraph5
tests/unit_tests/loop/test_loop_diagram_generation.py
<filename>tests/unit_tests/loop/test_loop_diagram_generation.py ################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically ...
mfasDa/MadGraph5
tests/acceptance_tests/test_madspin.py
from __future__ import division from __future__ import absolute_import import subprocess import unittest import os import re import shutil import sys import logging import time import tempfile import math logger = logging.getLogger('test_cmd') import tests.unit_tests.iolibs.test_file_writers as test_file_writers imp...
mfasDa/MadGraph5
tests/input_files/DM_pion/CT_couplings.py
# This file was automatically created by FeynRules 2.3.2 # Mathematica version: 9.0 for Linux x86 (64-bit) (November 20, 2012) # Date: Thu 11 Jun 2015 17:39:54 from __future__ import absolute_import from .object_library import all_couplings, Coupling from .function_library import complexconjugate, re, im, csc, sec, ...
mfasDa/MadGraph5
tests/input_files/mssm/interactions.py
<filename>tests/input_files/mssm/interactions.py interactions = [ { 'id': 1, 'particles': [21,21,21], 'color': ['1 f(0,1,2)'], 'lorentz': ['VVV1'], 'couplings': {(0, 0): 'GC_6'}, 'orders': {'QCD': 1} },{ 'id': 2, 'particles': [21,21,21,21], 'color': ['1 f(1,2,-1) f(-1,0,3)', '1 f(1,3...
mfasDa/MadGraph5
tests/input_files/DM_pion/parameters.py
# This file was automatically created by FeynRules 2.3.2 # Mathematica version: 9.0 for Linux x86 (64-bit) (November 20, 2012) # Date: Thu 11 Jun 2015 17:39:54 from __future__ import absolute_import from .object_library import all_parameters, Parameter from .function_library import complexconjugate, re, im, csc, s...
mfasDa/MadGraph5
madgraph/core/color_algebra.py
################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # h...
mfasDa/MadGraph5
tests/parallel_tests/test_ML5MSSMQCD.py
from __future__ import absolute_import import logging.config import logging import pydoc import os import unittest import sys import shutil import re #Look for MG5/MG4 path _mg5_path = os.sep.join(os.path.realpath(__file__).split(os.sep)[:-3]) sys.path.append(_mg5_path) _file_path = os.path.dirname(os.path.realpath(__f...
mfasDa/MadGraph5
tests/acceptance_tests/test_cmd_madevent.py
<gh_stars>0 ################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for a...
mfasDa/MadGraph5
models/MSSM_SLHA2/vertices.py
# This file was automatically created by FeynRules 1.7.53 # Mathematica version: 8.0 for Linux x86 (64-bit) (February 23, 2011) # Date: Tue 31 Jul 2012 19:55:14 from __future__ import absolute_import from .object_library import all_vertices, Vertex from . import particles as P from . import couplings as C from . impo...
mfasDa/MadGraph5
tests/parallel_tests/test_ML5EW.py
<filename>tests/parallel_tests/test_ML5EW.py from __future__ import absolute_import from __future__ import print_function import logging.config import logging import pydoc import os import unittest import sys import re #Look for MG5/MG4 path _mg5_path = os.sep.join(os.path.realpath(__file__).split(os.sep)[:-3]) sys.pat...
mfasDa/MadGraph5
tests/parallel_tests/compare_with_old_mg5_version.py
################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix elements for arbitrary # h...
mfasDa/MadGraph5
models/MSSM_SLHA2/build_restrict.py
<reponame>mfasDa/MadGraph5 ################################################################################ # # Copyright (c) 2012 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feynman diagrams and matrix...
mfasDa/MadGraph5
tests/unit_tests/fks/test_fks_common.py
<filename>tests/unit_tests/fks/test_fks_common.py ################################################################################ # # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors # # This file is a part of the MadGraph5_aMC@NLO project, an application which # automatically generates Feyn...
mfasDa/MadGraph5
vendor/IREGI/src/oneloop/src/avh_pc_olo.py
from __future__ import absolute_import import re import avh_pc def xprec(srcdir,rctype,prec,xkind,xkindmod): lines = [] if rctype == '': return elif rctype == 'intrinsic': if xkind == '': return else: lines = open(srcdir+'avh_olo_kinds.f90').readlines() ...
mfasDa/MadGraph5
models/MSSM_SLHA2/__init__.py
<gh_stars>0 from __future__ import absolute_import from . import particles from . import couplings from . import lorentz from . import parameters from . import vertices from . import coupling_orders from . import write_param_card from . import function_library all_particles = particles.all_particles all_vertices = ve...
ForumViriumHelsinki/SenseHel
backend/core/utils/elsys.py
import binascii TYPE_TEMP = 0x01 # temp 2 bytes -3276.8°C -->3276.7°C TYPE_RH = 0x02 # Humidity 1 byte 0-100% TYPE_ACC = 0x03 # acceleration 3 bytes X,Y,Z -128 --> 127 +/-63=1G TYPE_LIGHT = 0x04 # Light 2 bytes 0-->65535 Lux TYPE_MOTION = 0x05 # No of motion 1 byte 0-255 TYPE_CO2 = 0x06 # Co2 2 bytes 0-65535 p...
microsoft/WindowsProtocolTestSuites
TestSuites/RDP/RDPSUTControlAgent/Python/RDPSUTControlAgent.py
#!/usr/bin/env python import binascii import datetime import logging import socket import subprocess import sys import threading from struct import Struct, unpack try: from configparser import ConfigParser except ImportError: from ConfigParser import ConfigParser # ver. < 3.0 logging.basicConfig( format...
kiprotect/go-helpers
.scripts/make_copyright_headers.py
<reponame>kiprotect/go-helpers<filename>.scripts/make_copyright_headers.py import datetime import os script_dir = os.path.dirname(os.path.abspath(__file__)) source_dir = os.path.dirname(script_dir) context = {} def read_copyright(): with open(os.path.join(script_dir,'copyright_text.txt')) as input_file: r...
andyljones/simple-transformer-xl
transformer/transformer.py
<filename>transformer/transformer.py # coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this fi...
andyljones/simple-transformer-xl
transformer/__init__.py
<reponame>andyljones/simple-transformer-xl<filename>transformer/__init__.py from .transformer import TransformerXL
andyljones/simple-transformer-xl
transformer/demo.py
import torch from torch import nn from torch.nn import functional as F from . import nets from tqdm.auto import tqdm class Problem(nn.Module): """A simple, synthetic memory problem for demonstrating that the TransformerXL works. Each time you call `sample`, you get an `x, y` pair. The `x` is a random (T, ...
EnginKosure/web_scraping
main.py
import requests from bs4 import BeautifulSoup import pandas as pd link = "https://www.ebay.com/e/fashion/bo7-omega-021720" my_content = requests.get(link) soup = BeautifulSoup(my_content.text, 'html.parser') ul = soup.find( 'ul', attrs={'class': 'b-list__items_nofooter srp-results srp-grid'}) titles = [] pric...
enurinm/LearnPython
src/rain.py
import pygame, sys, random from pygame.locals import* pygame.init() pygame.display.set_caption("rain") screen=pygame.display.set_mode((1000,600)) clock=pygame.time.Clock() raindrop_spawn_time=0 camerlyn_default=pygame.image.load("./img/Camerlyn_umbrella.png").convert() camerlyn_right=pygame.image.load("./img/Camerlyn...
enurinm/LearnPython
src/firstprogram.py
import pygame, sys from pygame.locals import* pygame.init() pygame.display.set_caption("First Program") screen=pygame.display.set_mode((640,480)) xpos=50 clock=pygame.time.Clock() while 1: clock.tick(60) for event in pygame.event.get(): if event.type==pygame.QUIT: sys.exit() p...
fwtan/tensorflow
tensorflow/python/ops/bincount.py
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
fwtan/tensorflow
tensorflow/python/autograph/operators/control_flow_test.py
# Lint as: python3 # Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
fwtan/tensorflow
tensorflow/python/keras/layers/preprocessing/string_lookup.py
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
shivangibithel/Python
divide_and_conquer/bitonic_sequence.py
""" Given an array A[1..n], which is a bitonic sequence. Also this sequence can be rotated left or right. I have to find the smallest element in this bitonic sequence. In this implementation, I provide a divide-and-conquer algorithm. """ def bitonic(nums): if(len(nums)==1): return nums[0] if(len(nums...
opusdeits/json-datetime
jsondatetime/__init__.py
<filename>jsondatetime/__init__.py<gh_stars>1-10 from jsondatetime import loads
opusdeits/json-datetime
jsondatetime/tests/tests.py
from unittest import TestCase import jsondatetime as json import datetime class TestBase(TestCase): def setUp(self): self.test = '{"name": "<NAME>", "born": "Thu, 1 Mar 2012 10:00:49 UTC"}' self.expected = datetime.datetime(2012, 3, 1, 10, 0 ,49) self.datetime_format = '%a, %d %b %Y %H:%M...
net-auto/automation-tools
hpe_networking/comware_7_netconf/comware_netconf.py
<reponame>net-auto/automation-tools """ netconf functions for use with comware 7 devices """ # imports: import xmltodict def get_irf_members(ncclient_manager_ref): """ :param ncclient_manager_ref: ncclient manager reference: :return: Current IRF members """ filter_criteria = ''' ...
net-auto/automation-tools
WLAN_ruckus_smartzone/vSZ_5_single_zone_upgrade_tool.py
<gh_stars>0 import click from modules.common_functions import * from modules.ruckus import * # from functions.api.RUCKUS_API_calls import SZ_API_calls # global vars: host = "<WLC_FQDN>" requiredSoftware = '5.2.2.0.1026' # # rollback to the previous version only works, # if the AP zone was at this release before: rol...
net-auto/automation-tools
hpe_networking/imc/IMC_ruckus_ap_finder.py
""" describe script/app """ from ipaddress import IPv4Network from pathlib import Path import click import keyring from xlwt import Workbook from classes import Switch from modules import imc from modules.common_functions import get_current_date_filename # variables: http_url = "https://" imc_url = "<IMC_FQDN>:8443"...
net-auto/automation-tools
hpe_networking/imc/IMC_ntp_compliance.py
""" ### Description ### Script grabs the running config of the devices from IMC and checks the compliance against the variable: ntp_default_ip If a different imc_server/syntax is found, then the corresponding undo syntax is created and pushed to the device via IMC """ import os from ipaddress import IPv4Address from ...
net-auto/automation-tools
hpe_networking/imc/IMC_PRTG_auto_alarm_ack.py
<gh_stars>0 """ tool for syncing the acknowledged alarms at PRTG """ # Standard library imports import sys # Third party imports import click # Local application imports from modules.common_functions import \ get_imc_keyring_credentials, \ get_prtg_keyring_credentials from modules.imc import \ get_confir...
net-auto/automation-tools
hpe_networking/comware_7_onbox/irf_autoconfig/irf_auto_configurator.py
<reponame>net-auto/automation-tools # -*- coding: utf-8 -*- """On-Box Module for IRF configuration based on the autoconfiguration of the comware OS. for member ID: 1 there is also a baseline config applied. This baseline config is based on the IMC auto deployment requirements That means, that the device/switch can be...
net-auto/automation-tools
hpe_networking/imc/IMC_software_inventory_creator.py
""" ### Description ### gets the current devices at IMC and creates a sofware inventory / pie chart svg file """ import os import pygal from pyhpeimc.auth import * from modules import common_functions as api # variables: http_url = "http://" imc_url = "<IMC_FQDN>" imc_port = "8080" api_url = "/imcrs/plat/res/device...
net-auto/automation-tools
config/prtg_params.py
<gh_stars>0 """ set here the corresponding PRTG connection parameters """ prtg_host = '<PRTG_FQDN>' prtg_port = '443' prtg_protocol = 'https'
net-auto/automation-tools
config/imc_params.py
""" set here the corresponding IMC connection parameters """ http_url = "https://" imc_url = "<IMC_FQDN>:8443"
net-auto/automation-tools
classes/Switch.py
""" IMC RestAPI availability needed! functions to be used with: - netmiko - textfsm - ntc-templates device_type is set to: 'hp_comware' please get the ntc-templates in a different folder via git clone and set the environment variable: "NET_TEXTFSM" to the templates folder (where the index file is located) """ from co...
net-auto/automation-tools
hpe_networking/imc/IMC_device_creator.py
from ipaddress import IPv4Address import PySimpleGUI as sg import click import keyring from pyhpeimc.auth import * from modules import imc # variables: http_url = "https://" imc_url = "<IMC_FQDN>" imc_port = "8443" api_url = "/imcrs/plat/res/device?start=0&size=1000" api_dev_url = "/imcrs/plat/res/device/" HEADERS_J...
net-auto/automation-tools
modules/config_generator.py
<gh_stars>0 import csv import datetime import logging import shutil from ipaddress import IPv4Address from pathlib import Path import PySimpleGUI as SimpleGui import PySimpleGUI as sg import jinja2 from PySimpleGUI import popup_get_file from classes.Switch import Switch def get_last_octet_as_int(ip): try: ...
net-auto/automation-tools
hpe_networking/imc/IMC_switch_STP_config_remediation.py
# imports: import csv import json import os from ipaddress import IPv4Address from time import sleep import PySimpleGUI as SimpleGui from modules import imc # variables: imcUsername = os.environ.get('IMC_USER') imcPassword = os.environ.get('imc_pass') csv_data = SimpleGui.popup_get_file('CSV file to open') csv_filen...
net-auto/automation-tools
modules/ruckus.py
<reponame>net-auto/automation-tools<gh_stars>0 # -*- coding: utf-8 -*- """Module to interact with the Ruckus SmartZone API. inspired from source: https://github.com/commscope-ruckus/The-Kennel """ import json import warnings # Maybe using a dataclass?: from dataclasses import dataclass # imports: import requests #...
net-auto/automation-tools
hpe_networking/imc/IMC_loghost_compliance.py
<reponame>net-auto/automation-tools """ ### Description ### Script grabs the running config of the devices from IMC and checks the compliance against the variable: LOGHOST_DEFAULT_ADDRESS If a different imc_server/syntax is found, then the corresponding to undo syntax is created and pushed to the device via IMC """ i...
net-auto/automation-tools
hpe_networking/config_generator/5130_Switch_Config_Generator.py
import os from pathlib import Path import click # using corresponding keychain for the credentials: import keyring from modules import config_generator # variables: CSV_DIR = 'templates/csv/NEW_SITE/' CSV_PATH = Path.cwd() / CSV_DIR TEMPLATE_DIR = 'templates/' TEMPLATE_PATH = Path.cwd() / TEMPLATE_DIR TEMPLATE_FILE...
net-auto/automation-tools
modules/common_functions.py
import logging # Import smtplib for the actual sending function: import smtplib import sys from datetime import datetime # Import the email modules: from email.message import EmailMessage from pathlib import Path import keyring from pyhpeimc.plat.groups import * from requests.packages.urllib3.exceptions import Insecur...
net-auto/automation-tools
WLAN_ruckus_smartzone/ap_hostname_renamer.py
""" WLAN access point hostname renaming script """ import click from modules import ruckus from modules.common_functions import get_imc_keyring_credentials # custom variables: affected_ap_zone_name = "<INSERT_GROUP_NAME" # example: "AP_GROUP_LAB" host = "<WLC_FQDN>" @click.command() @click.option('--smartzone-use...
net-auto/automation-tools
modules/prtg.py
# --------------------------------PRTG functions:------------------------------------------------------- # import logging from ipaddress import IPv4Address, IPv4Network, AddressValueError import requests from requests import Response from classes.prtg import prtg from classes.prtg.prtg import prtg_api, prtg_device fr...
net-auto/automation-tools
classes/prtg/prtg.py
import csv from datetime import datetime import requests from bs4 import BeautifulSoup from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) # class used by prtg_api and children to manage global arrays of all objects class global_...
net-auto/automation-tools
modules/imc.py
import sys from collections import defaultdict from dataclasses import dataclass from ipaddress import IPv4Address, AddressValueError, IPv4Interface, IPv4Network from time import sleep import keyring import progressbar import requests.packages.urllib3 from pyhpeimc.auth import * from pyhpeimc.objects import * from pyh...
net-auto/automation-tools
prtg_monitoring/PRTG_auto_switch_remover.py
<filename>prtg_monitoring/PRTG_auto_switch_remover.py import logging import os import sys from ipaddress import IPv4Address from pathlib import Path from modules import common_functions as api from modules import imc from modules import prtg # variables: http_url = "https://" imc_url = "<IMC_FQDN" imc_port = ":8443" ...
net-auto/automation-tools
config/ruckus_params.py
""" set here the corresponding Ruckus WLC connection parameters """ host = "<WLC_SMARTZONE_FQDN>" http_port = "8443"
ElizavetaBugrova/basic-backend
project/lib/db_pool.py
<gh_stars>0 import sqlite3 from cuttlepool import CuttlePool class DbConnectionPool(CuttlePool): """https://pypi.org/project/cuttlepool/""" def __init__(self, database, capacity, **kwargs): super().__init__(factory=sqlite3.connect, database=database, capacity=capacity, **kwargs) def normalize_r...
ElizavetaBugrova/basic-backend
main.py
import sys from pathlib import Path from bottle import Bottle from project.app.app import App allowed_hosts = {'localhost', '127.0.0.1', '0.0.0.0'} def main(): host = 'localhost' port = '8080' arg_len = len(sys.argv) if arg_len == 2: port = sys.argv[1] if arg_len > 2: host = sys...
ElizavetaBugrova/basic-backend
project/adapter/query.py
from typing import List from project.domain.model import User from project.domain.query import UserQueries from project.lib.db_pool import DbConnectionPool class DbUserQueries(UserQueries): def __init__(self, connection_pool: DbConnectionPool): self.connection_pool = connection_pool def find_all(sel...
ElizavetaBugrova/basic-backend
project/app/app.py
from pathlib import Path from bottle import Bottle, run from project.adapter.command import DbCommandFactory from project.app.handler import SayHello, GetUsers, CreateUser from project.adapter.query import DbUserQueries from project.lib.db_pool import DbConnectionPool class App(object): def __init__(self, serv...
ElizavetaBugrova/basic-backend
project/domain/query.py
from typing import List from project.domain.model import User class UserQueries(object): def find_all(self) -> List[User]: pass
ElizavetaBugrova/basic-backend
script/db_init.py
from project.lib.db_pool import DbConnectionPool connectionPool = DbConnectionPool(database='../db/main.db', capacity=1) with connectionPool.get_resource() as connection: cursor = connection.cursor() cursor.execute('CREATE TABLE users (first_name text, last_name text, phone text)') cursor.execute("INSERT I...
ElizavetaBugrova/basic-backend
project/app/handler.py
<reponame>ElizavetaBugrova/basic-backend import json from bottle import BaseResponse, request from project.domain.command import CommandFactory from project.domain.query import UserQueries class Handler: def handle(self) -> BaseResponse: pass class SayHello(Handler): def handle(self) -> BaseResp...
ElizavetaBugrova/basic-backend
project/adapter/command.py
from project.domain.command import Command, CommandFactory from project.lib.db_pool import DbConnectionPool class DbCreateUserCommand(Command): def __init__(self, connection_pool: DbConnectionPool, first_name: str, last_name: str, phone: str): self.connection_pool = connection_pool self.first_nam...
ElizavetaBugrova/basic-backend
project/domain/model.py
<gh_stars>0 class User(object): def __init__(self, first_name: str, last_name: str, phone: str): self.first_name = first_name self.last_name = last_name self.phone = phone def as_dict(self): return { "first_name": self.first_name, "last_name": self.last_n...
ElizavetaBugrova/basic-backend
project/domain/command.py
<filename>project/domain/command.py class Command(object): def execute(self): pass class CommandFactory(object): def create_user_command(self, first_name: str, last_name: str, phone: str) -> Command: pass
ElizavetaBugrova/basic-backend
test_project/domain/test_model.py
<gh_stars>0 from unittest import TestCase from project.domain.model import User class TestUser(TestCase): def test_as_dict(self): user = User('john', 'doe', '+79109700102') self.assertEqual(user.as_dict(), {'first_name': 'john', 'last_name': 'doe', 'phone': '+79109700102'})
granatumx/gbox-scimpute
greet.py
#!/usr/bin/env python3 print(""" Hello, welcome to Cedric's scImpute docker image. Available commands: scImpute - docker run -i cedric-scimpute python3 ./main.py stdin format: { assay: [matrix] (required), drop_thre: [number between 0 and 1] (default:0.5) ...
granatumx/gbox-scimpute
main.py
#!/usr/bin/env python3 from sys import stdin,stdout,exit import matplotlib as mpl mpl.use('Agg') import seaborn as sns import matplotlib.pyplot as plt import numpy as np import json import rpy2 import rpy2.robjects as robjects import rpy2.robjects.numpy2ri as numpy2ri from base64 import b64encode from glob import glob...
centre-for-humanities-computing/danish-foundation-models
src/dfm/about.py
<reponame>centre-for-humanities-computing/danish-foundation-models __version__ = "0.0.3" # only source of version ID __title__ = "dfm" __download_url__ = ( "https://github.com/centre-for-humanities-computing/danish-foundation-models" )
centre-for-humanities-computing/danish-foundation-models
tests/description/match_counter_test.py
import pytest import spacy from dfm.description import MatchCounter class TestMatchCounter: @pytest.fixture(scope="class") def texts(self): texts = [ "Der kom en soldat marcherende hen ad landevejen: én, to! én, to! Han havde sit tornyster på ryggen og en sabel ved siden, for han havde vær...
centre-for-humanities-computing/danish-foundation-models
src/applications/danews/add_metadata.py
""" Add description to dataset and generate an outline to a datasheet describing the dataset. Dependent on: src/applications/danews/dedupe.py Authors: <NAME> """ from datasets import load_from_disk from pathlib import Path import spacy def word_count(batch): nlp = spacy.blank("da") batch["n_tokens"]...
centre-for-humanities-computing/danish-foundation-models
src/applications/dagw_reddit/add_metadata.py
<filename>src/applications/dagw_reddit/add_metadata.py """ Add initial metadata to the DFM compositite dataset consisting of dagw and reddit-da dataset. """ import os from datasets import load_from_disk from wasabi import msg import spacy path = os.path.join("/work", "dagw-clean", "dfm_dagw_reddit.arrow") write_pat...
centre-for-humanities-computing/danish-foundation-models
src/applications/danews/quality_filter.py
<filename>src/applications/danews/quality_filter.py """ Applies quality filters to DaNews Dependent on: isn't dependent Authors: <NAME> """ import glob import os import sys from pathlib import Path import multiprocessing from wasabi import msg from datasets import load_dataset dfm_path = os.path.join("dan...
centre-for-humanities-computing/danish-foundation-models
src/dfm/modelling/model_types.py
<gh_stars>1-10 MODEL_TYPES = ["autoencoding", "seq-to-seq"]
centre-for-humanities-computing/danish-foundation-models
tests/dfm_tokenizers/tokenizer_config_test.py
"""Tests for the tokenizer configuration""" import pytest from pathlib import Path from pydantic import ValidationError import os from dfm.dfm_tokenizers import TokenizerConfig # Disable tokenizer parallelization os.environ["TOKENIZERS_PARALLELISM"] = "false" @pytest.fixture(scope="module") def valid_config_dict():...
centre-for-humanities-computing/danish-foundation-models
setup.py
from setuptools import setup from setuptools import find_packages import subprocess import sys import os path = os.path.join("src", "dfm", "about.py") with open(path) as f: v = f.read() for l in v.split("\n"): if l.startswith("__version__"): __version__ = l.split('"')[-2] def install_no...
centre-for-humanities-computing/danish-foundation-models
src/applications/hopetwitter/apply_filter.py
""" Apply filters to the Twitter dataset. Dependent on: src/applications/hopetwitter/add_metadata.py Authors: <NAME> """ import os from wasabi import msg from datasets import load_from_disk if __name__ == "__main__": path = os.path.join( "/work", "twitter_cleaned", "twitter_da_stopwords_2019-01...
centre-for-humanities-computing/danish-foundation-models
tests/data/load_test.py
<filename>tests/data/load_test.py<gh_stars>1-10 """Tests for the dataset loading scripts""" import pytest from dfm.data.load import ( load_tweets, load_news, load_dagw, load_reddit, load_lexdk, load_tokenizer_ds, ) from datasets import IterableDataset, Dataset @pytest.mark.skip(reason="Datase...
centre-for-humanities-computing/danish-foundation-models
src/dfm/description/match_counter.py
<reponame>centre-for-humanities-computing/danish-foundation-models from collections import defaultdict from soupsieve import match from spacy.language import Language from spacy.matcher import Matcher from spacy.tokens import Doc from typing import Dict, Iterable, List, Optional class MatchCounter: """Class for ...
centre-for-humanities-computing/danish-foundation-models
src/dfm/cleaning/deduper_utils.py
"""Utility functions for the deduplicator. Author: <NAME> (<EMAIL>) """ from datasketch import MinHash, LeanMinHash from typing import List, Callable from unicodedata import normalize import re def get_shingles( doc: str, normalization_func: Callable, split_method: str, ngram_size: int, ngra...
centre-for-humanities-computing/danish-foundation-models
tests/cleaning/deduper_test.py
"""Tests for the deduplication module""" from dfm.cleaning import Deduper from dfm.cleaning.deduper_utils import get_minhash, get_shingles, default_normalization import tempfile from pathlib import Path import json import re import pytest def word_shape(doc: str) -> str: """Aggressive normalization function used...
centre-for-humanities-computing/danish-foundation-models
src/applications/dagw_reddit/preprocess.py
""" Preprocess (quality filter and deduplicate) the DFM compositite dataset consisting of dagw and reddit-da dataset. """ import os from pathlib import Path from functools import partial from datasets import load_dataset, concatenate_datasets from wasabi import msg from dfm.cleaning import Deduper, QualityFilter de...
centre-for-humanities-computing/danish-foundation-models
src/dfm/description/generate_description.py
import os import time from typing import List import spacy from datasets import load_dataset from dfm.description.description_patterns import ( danish_adult_words, get_female_gendered_patterns, get_gender_name_patterns, get_male_gendered_patterns, get_muslim_name_patterns, get_negative_word_pat...
centre-for-humanities-computing/danish-foundation-models
src/dfm/cleaning/__init__.py
from .quality_filter import QualityFilter from .deduper import Deduper
centre-for-humanities-computing/danish-foundation-models
src/applications/hopetwitter/quality_filter.py
<filename>src/applications/hopetwitter/quality_filter.py """ Applies quality filters to tweets filtering on language tag. Dependent on: src/applications/hopetwitter/flatten_ndjson.py Authors: <NAME> """ import glob import os from pathlib import Path import multiprocessing from wasabi import msg from dataset...
centre-for-humanities-computing/danish-foundation-models
src/dfm/description/description_patterns.py
<gh_stars>1-10 from typing import Dict, List from dfm.description import MatchCounter # Terms for religions are: # * The person-noun singular (e.g. "kristen") and conjugated # * The adjective (e.g. kristent) # * The religion-noun singular (e.g. "kristendom") and conjugated religion_labelled_match_patterns = [ {"m...
centre-for-humanities-computing/danish-foundation-models
src/applications/danews/dedupe.py
""" Applies quality filters to tweets filtering on language tag. Dependent on: src/applications/nopenews/quality_filter.py Authors: <NAME> """ import os from functools import partial from wasabi import msg from datasets import load_from_disk from dfm.cleaning import Deduper def filter_batch(batch, i): ...