uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c03e949c4fbb1533e402acb8 | train | class | class SelectMultiple(Select):
allow_multiple_selected = True
def _format_value(self, value):
if len(value) == 1 and value[0] is None:
value = []
return [force_text(v) for v in value]
def value_from_datadict(self, data, files, name):
if isinstance(data, (MultiValueDict, ... | class SelectMultiple(Select):
| allow_multiple_selected = True
def _format_value(self, value):
if len(value) == 1 and value[0] is None:
value = []
return [force_text(v) for v in value]
def value_from_datadict(self, data, files, name):
if isinstance(data, (MultiValueDict, MergeDict)):
retur... | (value, None)
if django.VERSION < (1, 6):
def _has_changed(self, initial, data):
if initial is not None:
initial = bool(initial)
if data is not None:
data = bool(data)
return initial != data
class SelectMultiple(Select):
| 64 | 64 | 190 | 6 | 57 | greyside/django-floppyforms | floppyforms/widgets.py | Python | SelectMultiple | SelectMultiple | 541 | 564 | 541 | 541 | c5f60f1e20aaa2605842dfeaa89a8fe468265e8a | bigcode/the-stack | train |
373e701949a4294d26f58c22 | train | class | class LookupTagger(BaseTagger):
"""Lookup tagger
Example:
>>> from reason.tag import LookupTagger
>>> lookup_data = {'cat': 'animal', 'black': 'color'}
>>> tagger = LookupTagger(lookup_data)
>>> tagger.tag('a black cat')
[('a', ''), ('black', 'color'), ('cat', 'animal')]... | class LookupTagger(BaseTagger):
| """Lookup tagger
Example:
>>> from reason.tag import LookupTagger
>>> lookup_data = {'cat': 'animal', 'black': 'color'}
>>> tagger = LookupTagger(lookup_data)
>>> tagger.tag('a black cat')
[('a', ''), ('black', 'color'), ('cat', 'animal')]
"""
def __init__(self... | from ._tagger import BaseTagger
class LookupTagger(BaseTagger):
| 18 | 67 | 225 | 8 | 9 | alisoltanirad/Reason | reason/tag/_lookup.py | Python | LookupTagger | LookupTagger | 4 | 40 | 4 | 4 | d7bb1caa96711c2b6476db8dc7fc5d0dd00f00c8 | bigcode/the-stack | train |
4de71381474ff198dee3f9ee | train | class | class ClusterPrincipalAssignment(pulumi.CustomResource):
def __init__(__self__,
resource_name: str,
opts: Optional[pulumi.ResourceOptions] = None,
cluster_name: Optional[pulumi.Input[str]] = None,
principal_assignment_name: Optional[pulumi.Input[st... | class ClusterPrincipalAssignment(pulumi.CustomResource):
| def __init__(__self__,
resource_name: str,
opts: Optional[pulumi.ResourceOptions] = None,
cluster_name: Optional[pulumi.Input[str]] = None,
principal_assignment_name: Optional[pulumi.Input[str]] = None,
principal_id: Optional[pulum... | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union
from .. import _utilities, _tables
from ... | 101 | 256 | 1,662 | 10 | 91 | pulumi/pulumi-azure-nextgen | sdk/python/pulumi_azure_nextgen/kusto/cluster_principal_assignment.py | Python | ClusterPrincipalAssignment | ClusterPrincipalAssignment | 15 | 184 | 15 | 15 | 27edf4115e0d78fc400607643c60f050417d0d5d | bigcode/the-stack | train |
bd42a7ff83546b04ad6355e3 | train | function | def filt(airfoil, circles):
centers = circles[:,:2]
radii = circles[:,2]
# The center should be inside the airfoil
head = np.argmin(airfoil[:,0])
ubs = np.interp(centers[:,0], airfoil[range(head,-1,-1),0], airfoil[range(head,-1,-1),1])
lbs = np.interp(centers[:,0], airfoil[head:,0], airfoil[head... | def filt(airfoil, circles):
| centers = circles[:,:2]
radii = circles[:,2]
# The center should be inside the airfoil
head = np.argmin(airfoil[:,0])
ubs = np.interp(centers[:,0], airfoil[range(head,-1,-1),0], airfoil[range(head,-1,-1),1])
lbs = np.interp(centers[:,0], airfoil[head:,0], airfoil[head:,1])
ind1 = np.logical_... | r = circle[2]
C = [(x + math.cos(2*np.pi/(n-1)*i)*r, y + math.sin(2*np.pi/(n-1)*i)*r) for i in xrange(n)]
return np.array(C)
def filt(airfoil, circles):
| 64 | 64 | 195 | 8 | 56 | wchen459/hgan_jmd_2019 | AH/build_data.py | Python | filt | filt | 22 | 33 | 22 | 22 | 7187678bf75b8022f9ba5094c1ae2328484ab0cd | bigcode/the-stack | train |
dd502fd3c6f445fc67db9e5e | train | function | def build_data(a_points=64, h_points=16):
# Airfoils
try:
A = np.load('airfoil.npy')
except IOError:
A = np.load('./AH/airfoil.npy')
# Holes
lb = np.min(A.reshape((-1,2)),0)
ub = np.max(A.reshape((-1,2)),0)
r_min = 0.03
r_max = (ub[1]-lb[1])*.5
low = np.appe... | def build_data(a_points=64, h_points=16):
# Airfoils
| try:
A = np.load('airfoil.npy')
except IOError:
A = np.load('./AH/airfoil.npy')
# Holes
lb = np.min(A.reshape((-1,2)),0)
ub = np.max(A.reshape((-1,2)),0)
r_min = 0.03
r_max = (ub[1]-lb[1])*.5
low = np.append(lb+r_min, r_min)
high = np.append(ub-r_min, r_max)
... | 1])
ind1 = np.logical_and(centers[:,1]<ubs, centers[:,1]>lbs)
# All points on the airfoil contour should be outside the circle
distances = pairwise_distances(airfoil, centers)
ind2 = np.all(distances-radii.reshape((1,-1))>0.01, axis=0)
return np.logical_and(ind1, ind2)
def build_data(a_points=64, h_... | 107 | 107 | 357 | 20 | 87 | wchen459/hgan_jmd_2019 | AH/build_data.py | Python | build_data | build_data | 35 | 77 | 35 | 37 | 45ad34fca66f96daa30400141027d9a9f42c71d0 | bigcode/the-stack | train |
b972281766869882b8004dab | train | function | def points_on_circle(circle, n=100):
x = circle[0]
y = circle[1]
r = circle[2]
C = [(x + math.cos(2*np.pi/(n-1)*i)*r, y + math.sin(2*np.pi/(n-1)*i)*r) for i in xrange(n)]
return np.array(C)
| def points_on_circle(circle, n=100):
| x = circle[0]
y = circle[1]
r = circle[2]
C = [(x + math.cos(2*np.pi/(n-1)*i)*r, y + math.sin(2*np.pi/(n-1)*i)*r) for i in xrange(n)]
return np.array(C)
|
Author(s): Wei Chen (wchen459@umd.edu)
"""
import os
import numpy as np
from sklearn.metrics.pairwise import pairwise_distances
from matplotlib import pyplot as plt
#plt.switch_backend('Qt5Agg')
import math
def points_on_circle(circle, n=100):
| 64 | 64 | 81 | 10 | 53 | wchen459/hgan_jmd_2019 | AH/build_data.py | Python | points_on_circle | points_on_circle | 15 | 20 | 15 | 15 | ad120ab9078eddd1cafd090e45bec852a51103f8 | bigcode/the-stack | train |
37aafb96dd8e56fcf225fe8d | train | function | def transform(augmented_file_path: str, transformed_file_path: str):
df=pd.read_json(f"{augmented_file_path}", orient='records')
df.columns=[df.values[0:1:][0][i] for i in range(len(df.values[0:1:][0]))]
df=df.drop(index=0)
df['added_datetime']=pd.to_datetime(df['added'], unit='s').dt.date
df['adde... | def transform(augmented_file_path: str, transformed_file_path: str):
| df=pd.read_json(f"{augmented_file_path}", orient='records')
df.columns=[df.values[0:1:][0][i] for i in range(len(df.values[0:1:][0]))]
df=df.drop(index=0)
df['added_datetime']=pd.to_datetime(df['added'], unit='s').dt.date
df['added_weekday']=pd.to_datetime(df['added'], unit='s').dt.day_name()
d... | import pandas as pd
def transform(augmented_file_path: str, transformed_file_path: str):
| 21 | 64 | 203 | 16 | 4 | martmagi/data-engineering | dags/transformation.py | Python | transform | transform | 4 | 17 | 4 | 4 | ca51899c5205315a2549c16526110aa4aa321e85 | bigcode/the-stack | train |
d7231fbaae678464b1a55d69 | train | function | @cronjobs.register
def mkt_gc(**kw):
"""Site-wide garbage collections."""
days_ago = lambda days: datetime.today() - timedelta(days=days)
log.debug('Collecting data to delete')
logs = (ActivityLog.objects.filter(created__lt=days_ago(90))
.exclude(action__in=amo.LOG_KEEP).values_list('id', f... | @cronjobs.register
def mkt_gc(**kw):
| """Site-wide garbage collections."""
days_ago = lambda days: datetime.today() - timedelta(days=days)
log.debug('Collecting data to delete')
logs = (ActivityLog.objects.filter(created__lt=days_ago(90))
.exclude(action__in=amo.LOG_KEEP).values_list('id', flat=True))
for chunk in chunked(... |
import os
import time
from django.conf import settings
import commonware.log
import cronjobs
import amo
from amo.utils import chunked
from devhub.models import ActivityLog
log = commonware.log.getLogger('z.cron')
@cronjobs.register
def mkt_gc(**kw):
| 64 | 64 | 209 | 12 | 52 | Joergen/zamboni | apps/market/cron.py | Python | mkt_gc | mkt_gc | 17 | 37 | 17 | 18 | 030005e2f7223bbaed9469daa90d50bdbe99399c | bigcode/the-stack | train |
cccc4979c77e850de9ead1cc | train | class | class TestSupplierPerformanceEvaluationTemplate(unittest.TestCase):
pass
| class TestSupplierPerformanceEvaluationTemplate(unittest.TestCase):
| pass
| # -*- coding: utf-8 -*-
# Copyright (c) 2019, ATD and Contributors
# See license.txt
from __future__ import unicode_literals
import frappe
import unittest
class TestSupplierPerformanceEvaluationTemplate(unittest.TestCase):
| 51 | 64 | 12 | 10 | 40 | dufani1/Supplier-Registration | supplier_registration/supplier_registration/doctype/supplier_performance_evaluation_template/test_supplier_performance_evaluation_template.py | Python | TestSupplierPerformanceEvaluationTemplate | TestSupplierPerformanceEvaluationTemplate | 9 | 10 | 9 | 9 | 6d3b76847e2c4ba6fbd4bf93d3e1025a15d8bfb5 | bigcode/the-stack | train |
51dae75660aa194056d8a48e | train | function | def objective_func(config):
x1, x2, x3, x4 = config['x1'], config['x2'], config['x3'], config['x4']
x3 = 1
x4 = int(x4)
y1 = (x1 + x2 + x3 + 10) ** 2
y2 = (x1 - x2 - x4 - 10) ** 2
return dict(objs=[y1, y2])
| def objective_func(config):
| x1, x2, x3, x4 = config['x1'], config['x2'], config['x3'], config['x4']
x3 = 1
x4 = int(x4)
y1 = (x1 + x2 + x3 + 10) ** 2
y2 = (x1 - x2 - x4 - 10) ** 2
return dict(objs=[y1, y2])
| sp.Categorical('x3', ['a', 'b', 'c'])
x4 = sp.Ordinal('x4', ['10', '20', '30', '40', '50', '60'])
space.add_variables([x1, x2, x3, x4])
def objective_func(config):
| 64 | 64 | 107 | 5 | 59 | Dee-Why/lite-bo | test/optimizer/test_nsga.py | Python | objective_func | objective_func | 12 | 20 | 12 | 12 | 34492f03ff29653766c8a6dcb4160ccfa0ee62b7 | bigcode/the-stack | train |
c8a5ab911c33b0a21332eb0d | train | class | class prodmc(Scenario):
def __init__(self):
Scenario.__init__(self)
"""
_prodmc_
Implement configuration building for MC production
"""
def dqmHarvesting(self, datasetName, runNumber, globalTag, **args):
"""
_dqmHarvesting_
DQM Harvesting for MC production
... | class prodmc(Scenario):
| def __init__(self):
Scenario.__init__(self)
"""
_prodmc_
Implement configuration building for MC production
"""
def dqmHarvesting(self, datasetName, runNumber, globalTag, **args):
"""
_dqmHarvesting_
DQM Harvesting for MC production
"""
optio... | #!/usr/bin/env python
"""
_prodmc_
Scenario supporting MC production
"""
import os
import sys
from Configuration.DataProcessing.Scenario import *
import FWCore.ParameterSet.Config as cms
class prodmc(Scenario):
| 45 | 94 | 316 | 6 | 38 | ckamtsikis/cmssw | Configuration/DataProcessing/python/Impl/prodmc.py | Python | prodmc | prodmc | 15 | 61 | 15 | 15 | 90ed0eeb429c55448dda70d9b90d5890897c8c2e | bigcode/the-stack | train |
21279506754ad9572ce1c507 | train | class | class Migration(migrations.Migration):
dependencies = [
('system', '0007_auto_20200313_1433'),
]
operations = [
migrations.AddField(
model_name='setting',
name='vat_rate',
field=models.DecimalField(decimal_places=2, default=0.05, max_digits=2),
)... | class Migration(migrations.Migration):
| dependencies = [
('system', '0007_auto_20200313_1433'),
]
operations = [
migrations.AddField(
model_name='setting',
name='vat_rate',
field=models.DecimalField(decimal_places=2, default=0.05, max_digits=2),
),
]
| # Generated by Django 2.2.10 on 2020-03-14 14:10
from django.db import migrations, models
class Migration(migrations.Migration):
| 38 | 64 | 75 | 7 | 30 | hanztura/hrsalespipes | hrsalespipes/system/migrations/0008_setting_vat_rate.py | Python | Migration | Migration | 6 | 18 | 6 | 7 | 0251a27621f6d43460c65416187babc2f0958a41 | bigcode/the-stack | train |
1788e3a84d0c88862be03eee | train | class | class Migration(migrations.Migration):
dependencies = [
('railways', '0002_auto_20200612_1241'),
]
operations = [
migrations.AddField(
model_name='train',
name='time',
field=models.TimeField(default=datetime.datetime(2020, 6, 12, 12, 42, 39, 677918, tzin... | class Migration(migrations.Migration):
| dependencies = [
('railways', '0002_auto_20200612_1241'),
]
operations = [
migrations.AddField(
model_name='train',
name='time',
field=models.TimeField(default=datetime.datetime(2020, 6, 12, 12, 42, 39, 677918, tzinfo=utc)),
preserve_default=F... | # Generated by Django 3.0.7 on 2020-06-12 12:42
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
| 49 | 64 | 95 | 7 | 41 | SnehaKBankolli/RAILWAY_RESERVATION | mysite/railways/migrations/0003_train_time.py | Python | Migration | Migration | 8 | 21 | 8 | 9 | 5e2e3c12edb734a02ffb0d26c54f4f4d1f6d0e32 | bigcode/the-stack | train |
1c0f8b08a7ebd18400f37efb | train | class | class VeneerScriptGenerators(object):
def __init__(self, ironpython):
self._ironpy = ironpython
def find_feature_by_name(self):
script = self._ironpy._init_script()
script += "def find_feature_by_name(searchTerm,exact=False):\n"
script += " for n in scenario.Network.Nodes:\n"
... | class VeneerScriptGenerators(object):
| def __init__(self, ironpython):
self._ironpy = ironpython
def find_feature_by_name(self):
script = self._ironpy._init_script()
script += "def find_feature_by_name(searchTerm,exact=False):\n"
script += " for n in scenario.Network.Nodes:\n"
script += " if n.Name == sea... | Structure.Project = scenario.Project
ph.ProjectMetaStructure.OutputFile = ''
ph.ProjectMetaStructure.SaveProjectToFile = True
ph.SaveProject()
finally:
ph.CallBackHandler = saved_cb
''' % fn
ret... | 64 | 64 | 206 | 7 | 57 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerScriptGenerators | VeneerScriptGenerators | 649 | 667 | 649 | 649 | 1b7d6a835961d6037e0b095698e8bb329d88997e | bigcode/the-stack | train |
6d502c4d4329497ba8cd5ae6 | train | class | class VeneerNetworkElementConstituentActions(VeneerNetworkElementActions):
def __init__(self, ironpy):
super(VeneerNetworkElementConstituentActions, self).__init__(ironpy)
self._aspect_pre_modifer = {
'': '',
'played': 'Data.ConstituentPlayedValues',
'model': 'Dat... | class VeneerNetworkElementConstituentActions(VeneerNetworkElementActions):
| def __init__(self, ironpy):
super(VeneerNetworkElementConstituentActions, self).__init__(ironpy)
self._aspect_pre_modifer = {
'': '',
'played': 'Data.ConstituentPlayedValues',
'model': 'Data.ProcessingModels',
'initial': 'InitialConcentrations.Concentr... | )
class VeneerLinkActions(object):
def __init__(self, ironpython):
self._ironpy = ironpython
self.constituents = VeneerLinkConstituentActions(self)
self.routing = VeneerLinkRoutingActions(self)
self._name_accessor = '.DisplayName'
def create(self, from_node, to_node, name=None... | 256 | 256 | 870 | 16 | 240 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerNetworkElementConstituentActions | VeneerNetworkElementConstituentActions | 1,344 | 1,427 | 1,344 | 1,344 | d3db653fc8d63cdf6289558447db3decfc9a21a3 | bigcode/the-stack | train |
02a562fd0bdc873e1cd33b51 | train | class | class VeneerSubcatchmentActions(VeneerNetworkElementActions):
'''
Helpers for querying/modifying the subcatchment-level models
Query options:
* catchments - the name(s) of catchments to match when querying/configuring.
'''
def __init__(self, catchment):
self._catchment = catchment
... | class VeneerSubcatchmentActions(VeneerNetworkElementActions):
| '''
Helpers for querying/modifying the subcatchment-level models
Query options:
* catchments - the name(s) of catchments to match when querying/configuring.
'''
def __init__(self, catchment):
self._catchment = catchment
self._name_accessor = 'Catchment.DisplayName'
sup... | self._catchment._ironpy.get(cname_accessor)
return zip(fu_names, catchment_names)
accessor = self._build_accessor(None, **kwargs)
names = self._ironpy.get(accessor,
self._ns,
names=['cat', 'fu', 'con', 'src'],
... | 111 | 111 | 371 | 14 | 97 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerSubcatchmentActions | VeneerSubcatchmentActions | 1,277 | 1,319 | 1,277 | 1,277 | f482c2aa5b694834bf5e93e7bf0392aaf1f102d0 | bigcode/the-stack | train |
b0aab0011ca791527b4ac18c | train | class | class VeneerNetworkElementActions(object):
def __init__(self, ironpython):
self._ironpy = ironpython
self._ns = None
self._pvr_element_name = ''
self._build_pvr_accessor = self._build_accessor
self._pvr_attribute_prefix = ''
self._aliases = {}
self.name_column... | class VeneerNetworkElementActions(object):
| def __init__(self, ironpython):
self._ironpy = ironpython
self._ns = None
self._pvr_element_name = ''
self._build_pvr_accessor = self._build_accessor
self._pvr_attribute_prefix = ''
self._aliases = {}
self.name_columns = ['NetworkElement']
self.query_p... | \n"
script += " return l\n"
script += " return None\n\n"
return script
class VeneerSourceUIHelpers(object):
def __init__(self, ironpython):
self._ironpy = ironpython
def open_editor(self, name_of_element):
script = self._ironpy._init_script(
namespace... | 255 | 256 | 2,913 | 8 | 246 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerNetworkElementActions | VeneerNetworkElementActions | 695 | 1,008 | 695 | 695 | d263b76f0fb5399a8c8f14c5fe041b01c651b04d | bigcode/the-stack | train |
da0545a31ef77884c95dda9c | train | class | class VeneerSourceUIHelpers(object):
def __init__(self, ironpython):
self._ironpy = ironpython
def open_editor(self, name_of_element):
script = self._ironpy._init_script(
namespace="RiverSystem.Controls.Controllers.FeatureEditorController as FeatureEditorController")
script ... | class VeneerSourceUIHelpers(object):
| def __init__(self, ironpython):
self._ironpy = ironpython
def open_editor(self, name_of_element):
script = self._ironpy._init_script(
namespace="RiverSystem.Controls.Controllers.FeatureEditorController as FeatureEditorController")
script += self._ironpy._generator.find_featu... | l.Name == searchTerm:\n"
script += " return l\n"
script += " if not exact and l.Name.startswith(searchTerm):\n"
script += " return l\n"
script += " return None\n\n"
return script
class VeneerSourceUIHelpers(object):
| 66 | 66 | 222 | 8 | 57 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerSourceUIHelpers | VeneerSourceUIHelpers | 670 | 693 | 670 | 670 | 8d0fed0f1757ff33146b0a7fc49ba0d9b4e6c945 | bigcode/the-stack | train |
f9d250462a1d3c0d145f541c | train | function | def build_dynamic_methods():
def add_node_creator(name, klass):
def creator(self, node_name, location=None, schematic_location=None):
return self.create(node_name, klass, location, schematic_location)
creator.__name__ = "new_%s" % name
setattr(VeneerNodeActions, creator.__name__,... | def build_dynamic_methods():
| def add_node_creator(name, klass):
def creator(self, node_name, location=None, schematic_location=None):
return self.create(node_name, klass, location, schematic_location)
creator.__name__ = "new_%s" % name
setattr(VeneerNodeActions, creator.__name__, creator)
for name, klas... | 1.2)",var_names)
# function_names=v.model.name_subst("metals_%s_%s",all_names)
# v.model.functions.create_function(function_names,function_codes)
# v.model.catchment.generation.apply_function("ObservedLoad",function_names,constituents="metals")
def build_dynamic_methods():
| 64 | 64 | 89 | 5 | 59 | flowmatters/veneer-py | veneer/server_side.py | Python | build_dynamic_methods | build_dynamic_methods | 1,857 | 1,865 | 1,857 | 1,857 | 5265d24c9c4c29d1d3afad55a676ad38a45b2241 | bigcode/the-stack | train |
a4d35b1bb47f3947c0857e9d | train | class | class VeneerRunoffActions(VeneerFunctionalUnitActions):
'''
Helpers for querying/modifying the rainfall runoff model setup
Query options:
* catchments - the name(s) of catchments to match when querying/configuring.
* fus - the type(s) of functional units to match when querying/configuring
'''... | class VeneerRunoffActions(VeneerFunctionalUnitActions):
| '''
Helpers for querying/modifying the rainfall runoff model setup
Query options:
* catchments - the name(s) of catchments to match when querying/configuring.
* fus - the type(s) of functional units to match when querying/configuring
'''
def __init__(self, catchment):
super(Venee... | ._ironpy._init_script('RiverSystem')
script += self._ironpy._generator.find_feature_by_name()
script += 'network = scenario.Network\n'
script += 'catchment = network.CatchmentWithName("%s")\n' % name
script += 'if catchment:\n'
script += ' network.Remove.Overloads[RiverSystem.... | 112 | 112 | 375 | 13 | 99 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerRunoffActions | VeneerRunoffActions | 1,163 | 1,204 | 1,163 | 1,163 | 2b1a65b17e2f429546ff6d90080e62ec4c46d3d5 | bigcode/the-stack | train |
9734fe4481735f43d348c4b7 | train | class | class VeneerLinkRoutingActions(VeneerNetworkElementActions):
'''
Queries and actions relating to streamflow routing models.
Query options:
* links - the name(s) of links to match when querying/configuring.
For example:
v.model.links.routing.get_models(links=['Link #1','Link #2'])
'''
... | class VeneerLinkRoutingActions(VeneerNetworkElementActions):
| '''
Queries and actions relating to streamflow routing models.
Query options:
* links - the name(s) of links to match when querying/configuring.
For example:
v.model.links.routing.get_models(links=['Link #1','Link #2'])
'''
def __init__(self, link):
self._link = link
... | .Constituents.ConstituentPlayedValue import ConstituentPlayedType as ConstituentPlayedType\n'
self._default_aspect = 'model'
def _filter_constituent_data_types(self):
return '.OfType[LinkElementConstituentData]()'
def _filter_by_query(self, links=None):
if links is None:
re... | 119 | 119 | 397 | 13 | 105 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerLinkRoutingActions | VeneerLinkRoutingActions | 1,452 | 1,500 | 1,452 | 1,452 | 237e69b606a0bcdf42b5b625ba6287d32cc3fcd5 | bigcode/the-stack | train |
3045b49169d3fa40454e5641 | train | class | class VeneerCatchmentGenerationActions(VeneerFunctionalUnitActions):
'''
Helpers for querying/modifying the constituent generation model setup
Query options:
* catchments - the name(s) of catchments to match when querying/configuring.
* fus - the type(s) of functional units to match when querying... | class VeneerCatchmentGenerationActions(VeneerFunctionalUnitActions):
| '''
Helpers for querying/modifying the constituent generation model setup
Query options:
* catchments - the name(s) of catchments to match when querying/configuring.
* fus - the type(s) of functional units to match when querying/configuring.
* constituents - the name(s) of the constituents t... | ,fus=None):
# return self.get_param_values('GetType().FullName',catchments,fus)
# def get_param_values(self,parameter,catchments=None,fus=None):
# accessor = self._build_accessor(parameter,catchments,fus)
# return self._ironpy.get(accessor)
def assign_time_series(self, parameter, values, d... | 184 | 184 | 615 | 14 | 170 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerCatchmentGenerationActions | VeneerCatchmentGenerationActions | 1,206 | 1,274 | 1,206 | 1,206 | 6be25bae33c6462fa9cd3e801e3f7fca03361c74 | bigcode/the-stack | train |
7cf6fe59777c4caf5eaca729 | train | function | def _transform_node_type_name(n):
n = n[0].upper() + n[1:]
splits = n.split('_')
if len(splits) > 1:
n = ''.join([comp.capitalize() for comp in splits])
if n.endswith('NodeModel'):
return n
if n.endswith('Node'):
return n + 'Model'
if n=='InjectedFlow':
return n
... | def _transform_node_type_name(n):
| n = n[0].upper() + n[1:]
splits = n.split('_')
if len(splits) > 1:
n = ''.join([comp.capitalize() for comp in splits])
if n.endswith('NodeModel'):
return n
if n.endswith('Node'):
return n + 'Model'
if n=='InjectedFlow':
return n
return n + 'NodeModel'
| 'transfer_ownership': 'RiverSystem.Nodes.TransferOwnership.TransferOwnershipNodeModel',
'off_allocation': 'RiverSystem.Nodes.OffAllocation.OffAllocationNodeModel',
'environmental_demand': 'RiverSystem.Nodes.EnvironmentalDemand.EnvironmentalDemandNodeModel'
}
def _transform_node_type_name(n):
| 64 | 64 | 98 | 8 | 56 | flowmatters/veneer-py | veneer/server_side.py | Python | _transform_node_type_name | _transform_node_type_name | 24 | 35 | 24 | 24 | 59c2ebfa06078fe24c9ed73ca875e85c73e772b3 | bigcode/the-stack | train |
3f609c5703333193a5e85701 | train | class | class VeneerFunctionActions():
'''
Routines for managing Source functions.
'''
def __init__(self, ironpython):
self._ironpy = ironpython
def _accessor(self, option, functions=None):
accessor = 'scenario.Network.FunctionManager.Functions'
if functions is not None:
... | class VeneerFunctionActions():
| '''
Routines for managing Source functions.
'''
def __init__(self, ironpython):
self._ironpy = ironpython
def _accessor(self, option, functions=None):
accessor = 'scenario.Network.FunctionManager.Functions'
if functions is not None:
functions = _stringToList(fun... | .
* node_types - the type(s) of nodes to match when querying/configuring
For example:
v.model.nodes.constituents.get_models(nodes='Fish River')
'''
def __init__(self, node):
self._node = node
self._name_accessor = 'Element.Name'
super(VeneerNodeConstituentActions, self)._... | 256 | 256 | 1,687 | 6 | 250 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerFunctionActions | VeneerFunctionActions | 1,629 | 1,803 | 1,629 | 1,629 | 91a7fb047d2f0c08f3fb57614625f35d896a98ce | bigcode/the-stack | train |
20db907a5e6c34e87792061b | train | class | class VeneerLinkConstituentActions(VeneerNetworkElementConstituentActions):
def __init__(self, link):
self._link = link
self._name_accessor = 'Link.DisplayName'
super(VeneerLinkConstituentActions, self).__init__(link._ironpy)
self.name_columns =['Link','Constituent']
self.que... | class VeneerLinkConstituentActions(VeneerNetworkElementConstituentActions):
| def __init__(self, link):
self._link = link
self._name_accessor = 'Link.DisplayName'
super(VeneerLinkConstituentActions, self).__init__(link._ironpy)
self.name_columns =['Link','Constituent']
self.query_params=['links','constituents']
self._ns = 'RiverSystem.Constitue... | )
names = self._ironpy.get(accessor,
self._ns,
names=['ne', 'con'],
alt_expression='(ne.DisplayName,con.Constituent.Name)')
return [tuple(n) for n in names]
class VeneerLinkConstituentActions(VeneerNetwork... | 69 | 69 | 230 | 18 | 51 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerLinkConstituentActions | VeneerLinkConstituentActions | 1,430 | 1,449 | 1,430 | 1,430 | a74bcac49a46133624176d693a25c35ac0b57884 | bigcode/the-stack | train |
0a335818adf62329b023399c | train | class | class VeneerNodeActions(VeneerNetworkElementActions):
'''
Queries and actions relating to nodes (incuding node models).
Query options:
* nodes - the name(s) of nodes to match when querying/configuring.
* node_types - the type(s) of nodes to match when querying/configuring
For example:
v... | class VeneerNodeActions(VeneerNetworkElementActions):
| '''
Queries and actions relating to nodes (incuding node models).
Query options:
* nodes - the name(s) of nodes to match when querying/configuring.
* node_types - the type(s) of nodes to match when querying/configuring
For example:
v.model.nodes.get_models(nodes='Fish River')
'''
... | None:
links = _stringToList(links)
accessor += '.Where(lambda l:l.DisplayName in %s)' % links
accessor += '.*FlowRouting'
if not parameter is None:
accessor += '.%s' % parameter
return accessor
# def set_model(self,theThing,theValue,namespace=None,liter... | 256 | 256 | 951 | 12 | 244 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerNodeActions | VeneerNodeActions | 1,503 | 1,592 | 1,503 | 1,503 | 70620902481018ecc21e3986d728490a60e462c9 | bigcode/the-stack | train |
0e03457e1f1a8c210b18fbac | train | class | class VeneerLinkActions(object):
def __init__(self, ironpython):
self._ironpy = ironpython
self.constituents = VeneerLinkConstituentActions(self)
self.routing = VeneerLinkRoutingActions(self)
self._name_accessor = '.DisplayName'
def create(self, from_node, to_node, name=None, al... | class VeneerLinkActions(object):
| def __init__(self, ironpython):
self._ironpy = ironpython
self.constituents = VeneerLinkConstituentActions(self)
self.routing = VeneerLinkRoutingActions(self)
self._name_accessor = '.DisplayName'
def create(self, from_node, to_node, name=None, allow_duplicates=False):
sc... | =catchments)
return self._ironpy.add_to_list(accessor, model_type, model_type,
instantiate=True, allow_duplicates=allow_duplicates)
def reset(self, namespace=None, **kwargs):
self._call(self._build_accessor(
'reset()', models=False, **kwargs), nam... | 71 | 71 | 239 | 7 | 64 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerLinkActions | VeneerLinkActions | 1,322 | 1,341 | 1,322 | 1,322 | 16662c07b6d4b83ca2fe504a25cd2bf6d4a16361 | bigcode/the-stack | train |
1317ba273d2ea2300c61f054 | train | class | class VeneerCatchmentActions(VeneerNetworkElementActions):
'''
Helpers for querying/modifying the catchment model setup
Specific helpers exist under:
* .runoff (rainfall runoff in functional units)
* .generation (constituent generation in functional units)
* .subcatchment (subcatchment... | class VeneerCatchmentActions(VeneerNetworkElementActions):
| '''
Helpers for querying/modifying the catchment model setup
Specific helpers exist under:
* .runoff (rainfall runoff in functional units)
* .generation (constituent generation in functional units)
* .subcatchment (subcatchment level models)
'''
def __init__(self, ironpython):... | = _stringToList(fus)
accessor += '.Where(lambda fu: fu.definition.Name in %s)' % fus
if not parameter is None:
accessor += '.*%s' % parameter
return accessor
def names(self, **kwargs):
accessor = self._build_fu_accessor(self._name_accessor, **kwargs)
retur... | 256 | 256 | 921 | 13 | 243 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerCatchmentActions | VeneerCatchmentActions | 1,061 | 1,160 | 1,061 | 1,061 | a9f1733b174f42d4adcce80eac9a48a3d9888113 | bigcode/the-stack | train |
b70a7e57b6576c3600fa3349 | train | class | class VeneerIronPython(object):
"""
Helper functions for manipulating the internals of the Source model itself.
These features rely on 'Allow Scripting' being enabled in Veneer in order
to post custom IronPython scripts to Source.
Specific helpers for querying and modifying the catchment component... | class VeneerIronPython(object):
| """
Helper functions for manipulating the internals of the Source model itself.
These features rely on 'Allow Scripting' being enabled in Veneer in order
to post custom IronPython scripts to Source.
Specific helpers for querying and modifying the catchment components and
instream components ex... | .Nodes.Gauge.GaugeNodeModel',
'confluence': 'RiverSystem.Nodes.Confluence.ConfluenceNodeModel',
'loss': 'RiverSystem.Nodes.Loss.LossNodeModel',
'water_user': 'RiverSystem.Nodes.WaterUser.WaterUserNodeModel',
'storage': 'RiverSystem.Nodes.StorageNodeModel',
'scenario_transfer': 'RiverSystem.Nodes.Sce... | 256 | 256 | 5,506 | 7 | 248 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerIronPython | VeneerIronPython | 39 | 646 | 39 | 39 | d8e72552b62d52faeaf192e51498167f41755d0f | bigcode/the-stack | train |
784f9dd48b6b3af8d1c33796 | train | class | class VeneerFunctionalUnitActions(VeneerNetworkElementActions):
def __init__(self, catchment):
self._catchment = catchment
self._name_accessor = "definition.Name"
super(VeneerFunctionalUnitActions, self).__init__(catchment._ironpy)
self._build_pvr_accessor = self._build_fu_accessor
... | class VeneerFunctionalUnitActions(VeneerNetworkElementActions):
| def __init__(self, catchment):
self._catchment = catchment
self._name_accessor = "definition.Name"
super(VeneerFunctionalUnitActions, self).__init__(catchment._ironpy)
self._build_pvr_accessor = self._build_fu_accessor
self.name_columns = ['Catchment', 'Functional Unit']
... | literal=False, fromList=False, **kwargs):
accessor = self._build_accessor(method, **kwargs)
return self._ironpy.call(accessor, parameter_tuple, literal=literal, from_list=fromList)
def apply(self, code, name='target', init=None, namespace=None, **kwargs):
accessor = self._build_accessor('_... | 137 | 137 | 457 | 13 | 124 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerFunctionalUnitActions | VeneerFunctionalUnitActions | 1,011 | 1,059 | 1,011 | 1,011 | 0e60aa38037e0a8e99e4c12765d60778d9ef7063 | bigcode/the-stack | train |
8bfe111ccaaf613a34d9f0c9 | train | class | class VeneerSimulationActions():
def __init__(self, ironpython):
self._ironpy = ironpython
def get_configuration(self):
script = self._ironpy._init_script()
script += 'result = scenario.RunManager.CurrentConfiguration.GetType().FullName'
result = self._ironpy.run_script(script)... | class VeneerSimulationActions():
| def __init__(self, ironpython):
self._ironpy = ironpython
def get_configuration(self):
script = self._ironpy._init_script()
script += 'result = scenario.RunManager.CurrentConfiguration.GetType().FullName'
result = self._ironpy.run_script(script)
if not result['Exception... | s in toe]
return self.set_options('EvaluationTimes', toe, fromList=True, functions=functions)
def get_known_time_periods(self):
script = self._ironpy._init_script() + GET_TIME_PERIODS
return self._ironpy.simplify_response(self._ironpy._safe_run(script)['Response'])
def set_modelled_va... | 126 | 126 | 423 | 6 | 120 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerSimulationActions | VeneerSimulationActions | 1,805 | 1,846 | 1,805 | 1,805 | 87391d99eb95174f5ce2a7bd8de42979de8d4ca0 | bigcode/the-stack | train |
6090d190c4c1bf33072a2eaa | train | class | class VeneerNodeConstituentActions(VeneerNetworkElementConstituentActions):
'''
Queries and actions relating to nodes (incuding node models).
Query options:
* nodes - the name(s) of nodes to match when querying/configuring.
* node_types - the type(s) of nodes to match when querying/configuring
... | class VeneerNodeConstituentActions(VeneerNetworkElementConstituentActions):
| '''
Queries and actions relating to nodes (incuding node models).
Query options:
* nodes - the name(s) of nodes to match when querying/configuring.
* node_types - the type(s) of nodes to match when querying/configuring
For example:
v.model.nodes.constituents.get_models(nodes='Fish River... | += 'node = find_feature_by_name("%s",exact=True)\n' % name
script += 'if node:\n'
script += ' network.Delete.Overloads[RiverSystem.Node](node)\n'
return self._ironpy._safe_run(script)
class VeneerNodeConstituentActions(VeneerNetworkElementConstituentActions):
| 76 | 76 | 256 | 18 | 58 | flowmatters/veneer-py | veneer/server_side.py | Python | VeneerNodeConstituentActions | VeneerNodeConstituentActions | 1,595 | 1,622 | 1,595 | 1,595 | 0a11933b989085d3d91003ee61620e98d521dc21 | bigcode/the-stack | train |
eb1e5b1987d4a1ed6b58cd13 | train | function | def check_proxy_bypass_tor_control(*args, **kwargs) -> bool:
"""
This function returns True when called by stem.socket.ControlPort to prevent
the Tor control connection going through a proxied socket.
"""
stack = inspect.stack()
if stack and len(stack) >= 4:
# [0] is this function, [1] i... | def check_proxy_bypass_tor_control(*args, **kwargs) -> bool:
| """
This function returns True when called by stem.socket.ControlPort to prevent
the Tor control connection going through a proxied socket.
"""
stack = inspect.stack()
if stack and len(stack) >= 4:
# [0] is this function, [1] is the genexpr in _socksocket_filtered,
# [2] is _sock... | collections.abc.Iterable
_TOR_ENABLED_KEY = 'tor_enabled'
_TOR_ENABLED_DEFAULT = False
_TOR_SOCKS_PORT_KEY = 'tor_socks_port'
_TOR_SOCKS_PORT_DEFAULT = 0
def check_proxy_bypass_tor_control(*args, **kwargs) -> bool:
| 64 | 64 | 173 | 17 | 46 | PiRK/Electron-Cash | electroncash/tor/controller.py | Python | check_proxy_bypass_tor_control | check_proxy_bypass_tor_control | 61 | 75 | 61 | 61 | aa34de4c3f98585dcc26af04c74e8e3b710477ab | bigcode/the-stack | train |
37b0ebf25e43bd4b9d2386f8 | train | class | class TorController(PrintError):
@unique
class Status(IntEnum):
STOPPING = 0
STOPPED = 1
STARTED = 2
READY = 3
ERRORED = 4
@unique
class BinaryType(IntEnum):
MISSING = 0
INTEGRATED = 1
SYSTEM = 2
_config: SimpleConfig = None
_tor_... | class TorController(PrintError):
@unique
| class Status(IntEnum):
STOPPING = 0
STOPPED = 1
STARTED = 2
READY = 3
ERRORED = 4
@unique
class BinaryType(IntEnum):
MISSING = 0
INTEGRATED = 1
SYSTEM = 2
_config: SimpleConfig = None
_tor_process: subprocess.Popen = None
_tor_rea... |
# monkey-patch collections.Iterable back since stem.control expects to see this name
stem.control.collections.Iterable = collections.abc.Iterable
_TOR_ENABLED_KEY = 'tor_enabled'
_TOR_ENABLED_DEFAULT = False
_TOR_SOCKS_PORT_KEY = 'tor_socks_port'
_TOR_SOCKS_PORT_DEFAULT = 0
def check_proxy_bypass_... | 256 | 256 | 2,352 | 10 | 245 | PiRK/Electron-Cash | electroncash/tor/controller.py | Python | TorController | TorController | 78 | 362 | 78 | 79 | 0b0ba03662616762e88277f820883203b3b8e367 | bigcode/the-stack | train |
88a7ea613e16bdff41e24dd0 | train | class | class CodeNetworkView(wx.lib.imagebrowser.ImageView):
def __init__(self,parent,winId,fileName = 'codenetwork'):
wx.lib.imagebrowser.ImageView.__init__(self,parent,winId)
self.parent = parent
b = Borg()
self.theImageFile = b.tmpDir + '/' + fileName + '.png'
def onRightDown(self,evt):
self.PopupM... | class CodeNetworkView(wx.lib.imagebrowser.ImageView):
| def __init__(self,parent,winId,fileName = 'codenetwork'):
wx.lib.imagebrowser.ImageView.__init__(self,parent,winId)
self.parent = parent
b = Borg()
self.theImageFile = b.tmpDir + '/' + fileName + '.png'
def onRightDown(self,evt):
self.PopupMenu(self.parent.theViewMenu)
def reloadImage(self):... | either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from cairis.core.Borg import Borg
import wx.lib.imagebrowser
import os
from cairis.core.armid import *
class CodeNetworkView(wx.lib.imagebrowser.ImageView):
| 64 | 64 | 118 | 11 | 53 | RachelLar/cairis_update | cairis/gui/CodeNetworkView.py | Python | CodeNetworkView | CodeNetworkView | 23 | 35 | 23 | 23 | cbd7b093364dd74ba218acccddfaa248ce0951ea | bigcode/the-stack | train |
845ac9add9796ac04d0ed734 | train | function | def save_data(data):
np.save('dataset/ref/actions', data['actions'])
np.save('dataset/ref/states', data['states'])
print('Saved data')
| def save_data(data):
| np.save('dataset/ref/actions', data['actions'])
np.save('dataset/ref/states', data['states'])
print('Saved data')
| import argparse
from collections import defaultdict
import numpy as np
from sklearn.neighbors import KNeighborsRegressor
from sklearn.linear_model import LinearRegression
from softlearning.environments.gym.locobot import LocobotGraspingEnv, ImageLocobotGraspingEnv
def save_data(data):
| 61 | 64 | 36 | 5 | 55 | Neo-X/mobilemanipulation-tf2 | dataset/generate_grasp_data.py | Python | save_data | save_data | 10 | 13 | 10 | 10 | ad8ea63067d7a36ae3bffe98af44225df080e4b8 | bigcode/the-stack | train |
e6c868b43b89214756941d80 | train | function | def main(args):
env = LocobotGraspingEnv(renders=True, step_duration=1/60 * 0.1, mode="grasp")
data = defaultdict(list)
i = 0
while len(data['actions']) < args.samples:
_ = env.reset()
obj_pos, _ = env._interface.get_object(env.block_id, relative=True)
pos = (np.array(obj_pos)... | def main(args):
| env = LocobotGraspingEnv(renders=True, step_duration=1/60 * 0.1, mode="grasp")
data = defaultdict(list)
i = 0
while len(data['actions']) < args.samples:
_ = env.reset()
obj_pos, _ = env._interface.get_object(env.block_id, relative=True)
pos = (np.array(obj_pos) - env._interfac... | import KNeighborsRegressor
from sklearn.linear_model import LinearRegression
from softlearning.environments.gym.locobot import LocobotGraspingEnv, ImageLocobotGraspingEnv
def save_data(data):
np.save('dataset/ref/actions', data['actions'])
np.save('dataset/ref/states', data['states'])
print('Saved data')... | 79 | 79 | 266 | 4 | 75 | Neo-X/mobilemanipulation-tf2 | dataset/generate_grasp_data.py | Python | main | main | 15 | 43 | 15 | 15 | e8be66b3f28b0969307595b0ccd1704a9d9c6be3 | bigcode/the-stack | train |
d5eb9fbd012c1a965b5a1bd6 | train | class | class VideoFile(object):
"""A videofile which can either be imported or exported from."""
def __init__(self, filepath, **kwargs):
self.filepath = filepath
self._probe()
def _probe(self):
probe = ffmpeg.probe(self.filepath)
vid_stream = next(stream for stream in probe['stream... | class VideoFile(object):
| """A videofile which can either be imported or exported from."""
def __init__(self, filepath, **kwargs):
self.filepath = filepath
self._probe()
def _probe(self):
probe = ffmpeg.probe(self.filepath)
vid_stream = next(stream for stream in probe['streams'] if
... | """Video output tools for turnovertools."""
import ffmpeg
from timecode import Timecode
class VideoFile(object):
| 24 | 135 | 451 | 5 | 18 | morganwl/turnovertools | turnovertools/video/output.py | Python | VideoFile | VideoFile | 6 | 55 | 6 | 6 | 0b0cb5708d195f69c9edf00227e24e2b7e272a15 | bigcode/the-stack | train |
9fcb5f829a02d5d168c69b4c | train | function | def range_to_real_offset(start_tc, end_tc, framerate):
frames = (end_tc - start_tc).frames
framerate = framerate_to_float(framerate)
return frames / framerate
| def range_to_real_offset(start_tc, end_tc, framerate):
| frames = (end_tc - start_tc).frames
framerate = framerate_to_float(framerate)
return frames / framerate
| ):
return self.input.output(self.filepath, **self.kwargs)
class JPEG(OutputPreset):
kwargs = {'format': 'image2pipe', 'vcodec': 'mjpeg', 'q':1, 'vsync':0}
def range_to_real_offset(start_tc, end_tc, framerate):
| 64 | 64 | 45 | 14 | 50 | morganwl/turnovertools | turnovertools/video/output.py | Python | range_to_real_offset | range_to_real_offset | 71 | 74 | 71 | 71 | 6da82d7a7f784a2cd93bd6f173acddc1f61434ea | bigcode/the-stack | train |
0b6df8b6aa72c765d25ddae7 | train | class | class OutputPreset(object):
kwargs = {}
def __init__(self, input, filepath='pipe:', **kwargs):
self.input = input
self.filepath = filepath
def output(self):
return self.input.output(self.filepath, **self.kwargs)
| class OutputPreset(object):
| kwargs = {}
def __init__(self, input, filepath='pipe:', **kwargs):
self.input = input
self.filepath = filepath
def output(self):
return self.input.output(self.filepath, **self.kwargs)
| mpeg.input(self.filepath, **kwargs)
def ss_at(self, tc):
return range_to_real_offset(self.src_start_tc, tc,
self.framerate)
def frames_to_seconds(self, frames):
return frames / framerate_to_float(self.framerate)
class OutputPreset(object):
| 64 | 64 | 57 | 5 | 59 | morganwl/turnovertools | turnovertools/video/output.py | Python | OutputPreset | OutputPreset | 58 | 66 | 58 | 58 | 772e8bd241b99d400b3a0dc9bdb6b0aa9e2772f2 | bigcode/the-stack | train |
f609e5d2574cde3bb904204f | train | function | def capture_out(stream):
vid, _ = ffmpeg.run(stream, capture_stdout=True, capture_stderr=False)
return vid
| def capture_out(stream):
| vid, _ = ffmpeg.run(stream, capture_stdout=True, capture_stderr=False)
return vid
| float(framerate)
except ValueError:
dividend, divisor = framerate.split('/')
framerate = int(dividend) / int(divisor)
else:
if framerate == 23.98:
framerate = 23.976
return framerate
def capture_out(stream):
| 64 | 64 | 28 | 5 | 58 | morganwl/turnovertools | turnovertools/video/output.py | Python | capture_out | capture_out | 87 | 89 | 87 | 87 | d640e70469c9fd8396db5a5cf4255754dc9907e2 | bigcode/the-stack | train |
519669fc8fd464fb628d2d69 | train | function | def framerate_to_float(framerate):
try:
framerate = float(framerate)
except ValueError:
dividend, divisor = framerate.split('/')
framerate = int(dividend) / int(divisor)
else:
if framerate == 23.98:
framerate = 23.976
return framerate
| def framerate_to_float(framerate):
| try:
framerate = float(framerate)
except ValueError:
dividend, divisor = framerate.split('/')
framerate = int(dividend) / int(divisor)
else:
if framerate == 23.98:
framerate = 23.976
return framerate
| q':1, 'vsync':0}
def range_to_real_offset(start_tc, end_tc, framerate):
frames = (end_tc - start_tc).frames
framerate = framerate_to_float(framerate)
return frames / framerate
def framerate_to_float(framerate):
| 64 | 64 | 75 | 9 | 54 | morganwl/turnovertools | turnovertools/video/output.py | Python | framerate_to_float | framerate_to_float | 76 | 85 | 76 | 76 | 003ef81c48f66a6d5ce5f6b6fa4d4f8a59919beb | bigcode/the-stack | train |
0b29d11071f75186f762302e | train | class | class JPEG(OutputPreset):
kwargs = {'format': 'image2pipe', 'vcodec': 'mjpeg', 'q':1, 'vsync':0}
| class JPEG(OutputPreset):
| kwargs = {'format': 'image2pipe', 'vcodec': 'mjpeg', 'q':1, 'vsync':0}
| ate)
class OutputPreset(object):
kwargs = {}
def __init__(self, input, filepath='pipe:', **kwargs):
self.input = input
self.filepath = filepath
def output(self):
return self.input.output(self.filepath, **self.kwargs)
class JPEG(OutputPreset):
| 64 | 64 | 35 | 5 | 59 | morganwl/turnovertools | turnovertools/video/output.py | Python | JPEG | JPEG | 68 | 69 | 68 | 68 | 30c7ced41ccfdeff500d0307cb36e2e5f13f4a2b | bigcode/the-stack | train |
4453f38e70483b1632ec61a3 | train | function | def main4():
#g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MB_O305\O305_E2H_84.bus")
g=DebuggerView("Debugger")
#g.loadBus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MB_O305\O305_E2H_84.bus")
g.mainloop()
| def main4():
#g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MB_O305\O305_E2H_84.bus")
| g=DebuggerView("Debugger")
#g.loadBus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MB_O305\O305_E2H_84.bus")
g.mainloop()
| .bus")
for i in g.scripts.init:
i:Instruction
print(i.reverse)
def main4():
#g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MB_O305\O305_E2H_84.bus")
| 64 | 64 | 92 | 42 | 22 | dmitrol205/oscDebugger | oscTest.py | Python | main4 | main4 | 134 | 138 | 134 | 135 | b01ef76922548f7915c7d7ced8627116f4ef2a96 | bigcode/the-stack | train |
c17a2bcb4a6aca6e948c762f | train | function | def main2():
#g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\Trabant\Trabant.ovh")
#g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MAN Lions City Euro 6\A21_206.bus")
#g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MAN_NL_NG\MAN_GN92_main.bus")
g=Bus(r"D:\Program Files (x86)\OMSI 2.2.0... | def main2():
#g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\Trabant\Trabant.ovh")
#g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MAN Lions City Euro 6\A21_206.bus")
#g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MAN_NL_NG\MAN_GN92_main.bus")
| g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MB_O305\O305_E2H_84.bus")
#g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\VW_Golf_2\debug_golf.bus")
root=Tk()
j=CodeView(root,width=50,height=30)
j.grid(column=1,row=0)
#j.pack(fill="x",expand=True)
sv=LoopStack8View(root,"Float Sta... | import traceback
def main():
g=Program()
g.loadScript(r'D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MAN Lions City Euro 6\Script\churakrueger\VMatrix.osc')
#g.loadScript(r'D:\Program Files (x86)\OMSI 2.2.027\Vehicles\Trabant\script\Trabant_AI.osc')
e=Executor(g)
e.execute(next(iter(g.macros.items(... | 254 | 255 | 851 | 113 | 141 | dmitrol205/oscDebugger | oscTest.py | Python | main2 | main2 | 27 | 125 | 27 | 30 | 03585ec3f6c86e076a715a1e71d9a35135aa32a0 | bigcode/the-stack | train |
d7e3e8cc0d8b2b308505b379 | train | function | def main():
g=Program()
g.loadScript(r'D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MAN Lions City Euro 6\Script\churakrueger\VMatrix.osc')
#g.loadScript(r'D:\Program Files (x86)\OMSI 2.2.027\Vehicles\Trabant\script\Trabant_AI.osc')
e=Executor(g)
e.execute(next(iter(g.macros.items()))[1])
'''pri... | def main():
| g=Program()
g.loadScript(r'D:\Program Files (x86)\OMSI 2.2.027\Vehicles\MAN Lions City Euro 6\Script\churakrueger\VMatrix.osc')
#g.loadScript(r'D:\Program Files (x86)\OMSI 2.2.027\Vehicles\Trabant\script\Trabant_AI.osc')
e=Executor(g)
e.execute(next(iter(g.macros.items()))[1])
'''print(g.macros)... | View import LoopStack8View
from oscInstruction import Instruction
import time
from tkinter import Event, Misc, Tk
from oscProgram import Program
from oscExecutor import Executor
from datParser import parse
from bus import Bus
from codeView import CodeView
import threading
import traceback
def main():
| 64 | 64 | 138 | 3 | 60 | dmitrol205/oscDebugger | oscTest.py | Python | main | main | 14 | 25 | 14 | 14 | b6ac70879a4a74c85adfe54b11373b430d2c0737 | bigcode/the-stack | train |
222cde0ce79d24a5c0ab08ee | train | function | def main3():
g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\VW_Golf_2\debug_golf.bus")
for i in g.scripts.init:
i:Instruction
print(i.reverse)
| def main3():
| g=Bus(r"D:\Program Files (x86)\OMSI 2.2.027\Vehicles\VW_Golf_2\debug_golf.bus")
for i in g.scripts.init:
i:Instruction
print(i.reverse)
| : kv[0]))
del collections
for k,v in g.scripts.constants.items():
print(k,v)
'''g=g.script
print(g.macros)
print(g.triggers)
print(g.init)
print(g.frame)
print(g.ai_frame)'''
def main3():
| 64 | 64 | 59 | 4 | 60 | dmitrol205/oscDebugger | oscTest.py | Python | main3 | main3 | 127 | 132 | 127 | 127 | 84f7652ea4c6f3443da0bccb94dea5b84d6a3335 | bigcode/the-stack | train |
79a36718f91ce1086ccd787d | train | class | class Exception_Hook(QObject, Logger):
_report_exception = QtCore.pyqtSignal(object, object, object, object)
_INSTANCE = None # type: Optional[Exception_Hook] # singleton
def __init__(self, *, config: 'SimpleConfig'):
QObject.__init__(self)
Logger.__init__(self)
assert self._INST... | class Exception_Hook(QObject, Logger):
| _report_exception = QtCore.pyqtSignal(object, object, object, object)
_INSTANCE = None # type: Optional[Exception_Hook] # singleton
def __init__(self, *, config: 'SimpleConfig'):
QObject.__init__(self)
Logger.__init__(self)
assert self._INSTANCE is None, "Exception_Hook is suppos... | e.g. '<',
# they need to be escaped to avoid formatting issues.
traceback_str = super()._get_traceback_str()
return html.escape(traceback_str)
def _show_window(*args):
if not Exception_Window._active_window:
Exception_Window._active_window = Exception_Window(*args)
class Exception... | 73 | 73 | 246 | 8 | 65 | aguycalled/electrum | electrum/gui/qt/exception_window.py | Python | Exception_Hook | Exception_Hook | 162 | 187 | 162 | 162 | 82122ac104c1be4c27699ee37c48d8062960411b | bigcode/the-stack | train |
327b3ddf9cf7b71c782be44a | train | class | class Exception_Window(BaseCrashReporter, QWidget, MessageBoxMixin, Logger):
_active_window = None
def __init__(self, config: 'SimpleConfig', exctype, value, tb):
BaseCrashReporter.__init__(self, exctype, value, tb)
self.network = Network.get_instance()
self.config = config
QWi... | class Exception_Window(BaseCrashReporter, QWidget, MessageBoxMixin, Logger):
| _active_window = None
def __init__(self, config: 'SimpleConfig', exctype, value, tb):
BaseCrashReporter.__init__(self, exctype, value, tb)
self.network = Network.get_instance()
self.config = config
QWidget.__init__(self)
self.setWindowTitle('NavCash - ' + _('An Error Oc... | WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TOR... | 256 | 256 | 863 | 15 | 240 | aguycalled/electrum | electrum/gui/qt/exception_window.py | Python | Exception_Window | Exception_Window | 46 | 154 | 46 | 46 | ab1b518579c2154c6c8c26ef583a55e48a858465 | bigcode/the-stack | train |
0543df006f44da475df91c2d | train | function | def _show_window(*args):
if not Exception_Window._active_window:
Exception_Window._active_window = Exception_Window(*args)
| def _show_window(*args):
| if not Exception_Window._active_window:
Exception_Window._active_window = Exception_Window(*args)
| that shows the report uses rich_text=True, so
# if traceback contains special HTML characters, e.g. '<',
# they need to be escaped to avoid formatting issues.
traceback_str = super()._get_traceback_str()
return html.escape(traceback_str)
def _show_window(*args):
| 64 | 64 | 28 | 7 | 57 | aguycalled/electrum | electrum/gui/qt/exception_window.py | Python | _show_window | _show_window | 157 | 159 | 157 | 157 | bd390f864f9649895971537eb4eeb80546bd36d8 | bigcode/the-stack | train |
c3283e170fb96f3f3afd6186 | train | function | def _preprocess(init_state, weights, s_wires, d_wires):
"""Validate and pre-process inputs as follows:
* Check that not both wire sets are empty.
* Check that d_wires contains wire pairs.
* Check shaoe of the weights tensor.
* Cast initial state to numpy array.
* Check that initial state contai... | def _preprocess(init_state, weights, s_wires, d_wires):
| """Validate and pre-process inputs as follows:
* Check that not both wire sets are empty.
* Check that d_wires contains wire pairs.
* Check shaoe of the weights tensor.
* Cast initial state to numpy array.
* Check that initial state contains only zeros and ones.
* Flip bits in initial state... | either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
r"""
Contains the ``UCCSD`` template.
"""
import numpy as np
import pennylane as qml
# pylint: disable-msg=too-many-branches,too-many-arguments,protected-access
from pennylane.templates.d... | 125 | 125 | 417 | 17 | 107 | aglitoiu/pennylane | pennylane/templates/subroutines/uccsd.py | Python | _preprocess | _preprocess | 27 | 75 | 27 | 27 | 184157a9f9d337110e3d88b5346e2f5b18688f77 | bigcode/the-stack | train |
37c02a5da95a4ce9ac4c4fc2 | train | function | @template
def UCCSD(weights, wires, s_wires=None, d_wires=None, init_state=None):
r"""Implements the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz.
The UCCSD ansatz calls the
:func:`~.SingleExcitationUnitary` and :func:`~.DoubleExcitationUnitary`
templates to exponentiate the coupled-clust... | @template
def UCCSD(weights, wires, s_wires=None, d_wires=None, init_state=None):
| r"""Implements the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz.
The UCCSD ansatz calls the
:func:`~.SingleExcitationUnitary` and :func:`~.DoubleExcitationUnitary`
templates to exponentiate the coupled-cluster excitation operator. UCCSD is a VQE ansatz
commonly used to run quantum che... | and d_wires lists can not be both empty; got ph={}, pphh={}".format(
s_wires, d_wires
)
)
for d_wires_ in d_wires:
if len(d_wires_) != 2:
raise ValueError(
"expected entries of d_wires to be of size 2; got {} of length {}".format(
... | 256 | 256 | 1,834 | 25 | 231 | aglitoiu/pennylane | pennylane/templates/subroutines/uccsd.py | Python | UCCSD | UCCSD | 78 | 215 | 78 | 79 | 970ff688776072b3adec046762785b852c4df3b2 | bigcode/the-stack | train |
6ffed756ed4eef75ae880b83 | train | function | def setup_random_seed():
"""
Sets up Python's and numpy's random seed.
Fixture for the tests to assure globally controllable seeding of random
number generators in both Python (:func:`random.seed`) and ``numpy``
(:func:`numpy.random.seed`). The seed is taken either from ``FATF_SEED``
system var... | def setup_random_seed():
| """
Sets up Python's and numpy's random seed.
Fixture for the tests to assure globally controllable seeding of random
number generators in both Python (:func:`random.seed`) and ``numpy``
(:func:`numpy.random.seed`). The seed is taken either from ``FATF_SEED``
system variable; if not given it's ... | .')
if 'PYTEST_IN_PROGRESS' not in os.environ:
setup_warning_filters() # pragma: no cover
# Set the current package version
__version__ = '0.0.0'
# This function is tested in fatf.tests.test_rngs_seeding
def setup_random_seed():
| 64 | 64 | 201 | 5 | 58 | mattclifford1/fat-forensics-1 | fatf/__init__.py | Python | setup_random_seed | setup_random_seed | 75 | 95 | 75 | 75 | 9cf68c2be9a3858fe620e6cdac778df592883f1f | bigcode/the-stack | train |
e0548db18bf54c83a363ec61 | train | function | def setup_warning_filters():
"""
Sets up desired warning filters.
If the warning filters are not specified on the command line or via
the system variable make sure that :class:`DeprecationWarning` and
:class:`ImportWarning` raised by this this package always get printed.
The warning settings u... | def setup_warning_filters():
| """
Sets up desired warning filters.
If the warning filters are not specified on the command line or via
the system variable make sure that :class:`DeprecationWarning` and
:class:`ImportWarning` raised by this this package always get printed.
The warning settings used by pytest can be found in... | _formatter)
logger.addHandler(_logger_handler)
logger.setLevel(logging.INFO)
# Redirect warnings to the logger module
# logging.captureWarnings(True)
# py_warnings = logging.getLogger('py.warnings')
# py_warnings.addHandler(_logger_handler)
# py_warnings.setLevel(logging.INFO)
def setup_warning_filters():
| 66 | 66 | 221 | 5 | 61 | mattclifford1/fat-forensics-1 | fatf/__init__.py | Python | setup_warning_filters | setup_warning_filters | 38 | 64 | 38 | 38 | 59aaa37355088fa639e62fbbcf7d17f7662f218d | bigcode/the-stack | train |
bddeca55e2a39eb3dd02be42 | train | function | @auth.route('/logout')
@login_required
def logout():
logout_user()
flash('You have been logged out.')
return redirect(url_for('talks.index'))
| @auth.route('/logout')
@login_required
def logout():
| logout_user()
flash('You have been logged out.')
return redirect(url_for('talks.index'))
| email or password.')
return redirect(url_for('.login'))
login_user(user, form.remember_me.data)
return redirect(request.args.get('next') or url_for('talks.index'))
return render_template('auth/login.html', form=form)
@auth.route('/logout')
@login_required
def logout():
| 64 | 64 | 35 | 12 | 52 | darksigma/flask-pycon2014 | app/auth/routes.py | Python | logout | logout | 25 | 30 | 25 | 27 | a6a9c5369ef4be162eeb37c682b26de3c0a0e316 | bigcode/the-stack | train |
85def0aca95d499b1f4b28f1 | train | function | @auth.route('/login', methods=['GET', 'POST'])
def login():
if not current_app.config['DEBUG'] and not current_app.config['TESTING'] \
and not request.is_secure:
return redirect(url_for('.login', _external=True, _scheme='https'))
form = LoginForm()
if form.validate_on_submit():
u... | @auth.route('/login', methods=['GET', 'POST'])
def login():
| if not current_app.config['DEBUG'] and not current_app.config['TESTING'] \
and not request.is_secure:
return redirect(url_for('.login', _external=True, _scheme='https'))
form = LoginForm()
if form.validate_on_submit():
user = User.query.filter_by(email=form.email.data).first()
... | _template, current_app, request, redirect, url_for, \
flash
from flask.ext.login import login_user, logout_user, login_required
from ..models import User
from . import auth
from .forms import LoginForm
@auth.route('/login', methods=['GET', 'POST'])
def login():
| 64 | 64 | 156 | 16 | 47 | darksigma/flask-pycon2014 | app/auth/routes.py | Python | login | login | 9 | 22 | 9 | 10 | e0a1ead9a105fd0d9d0fb8de139d42ca9d66095e | bigcode/the-stack | train |
e5ed8b91d64eb34b4afdc3fa | train | class | class User(BaseModel):
username: str
full_name: str
password: str
email: str
@validator('username')
def username_is_valid(cls, v):
if ' ' in v or len(v) > 60:
raise ValueError('entered a non valide username')
return v
@validator('full_name')
def full_name_is... | class User(BaseModel):
| username: str
full_name: str
password: str
email: str
@validator('username')
def username_is_valid(cls, v):
if ' ' in v or len(v) > 60:
raise ValueError('entered a non valide username')
return v
@validator('full_name')
def full_name_is_valid(cls, v):
... | # pylint: disable=no-self-argument
from pydantic import BaseModel, ValidationError, validator
import re
class User(BaseModel):
| 30 | 73 | 244 | 5 | 24 | MatthewSaintBull/songure-api | songure-api/app/models/user.py | Python | User | User | 5 | 35 | 5 | 5 | dfc6cf5bc9bcd1c58589fa4fd7644bf927d04150 | bigcode/the-stack | train |
fa9d21103cac4105b0c2238d | train | class | class OauthUser(BaseModel):
username: str
full_name: str
email: str | class OauthUser(BaseModel):
| username: str
full_name: str
email: str | (cls, v):
pattern = re.compile(r"\"?([-a-zA-Z0-9.`?{}]+@\w+\.\w+)\"?")
if not re.match(pattern, v):
raise ValueError('entered a non valid email')
return v
class OauthUser(BaseModel):
| 64 | 64 | 22 | 7 | 56 | MatthewSaintBull/songure-api | songure-api/app/models/user.py | Python | OauthUser | OauthUser | 38 | 41 | 38 | 38 | 9a60909c38703a222eededb0f94612e6bfd156bd | bigcode/the-stack | train |
8a7cf8b506160b0b84f55668 | train | class | class banking:
_accounts = {}
_name = "PyBank Inc"
def Name(self):
return self._name
def GenerateAccountNumber(self):
return random.randint(10000, 99999)
def CreateAccount(self):
acct_num = self.GenerateAccountNumber()
user_name = self.GetUserName(se... | class banking:
| _accounts = {}
_name = "PyBank Inc"
def Name(self):
return self._name
def GenerateAccountNumber(self):
return random.randint(10000, 99999)
def CreateAccount(self):
acct_num = self.GenerateAccountNumber()
user_name = self.GetUserName(self.username.text... | .setGeometry(615,312,690,405)
self.lineEdit.setGeometry(180,100,301,41)
self.lineEdit_2.setGeometry(180,150,301,41)
self.label.setGeometry(140,200,401,31)
self.pushButton.setGeometry(240,240,161,51)
self.label_credits.setGeometry(-210,350,621,21)
k... | 256 | 256 | 1,147 | 3 | 253 | keroo-adel/Binking_System_management. | banking.py | Python | banking | banking | 95 | 213 | 95 | 96 | b1191541bfb0c6cca2a5af98f9688f57996b3c38 | bigcode/the-stack | train |
efe8eec6e5736a0d18b6983c | train | class | class Account(banking):
def __init__(self, name, acct_num, deposit):
self._name = name
self._account_number = acct_num
self._balance = deposit
@property
def Balance(self):
#balance is read only
... | class Account(banking):
| def __init__(self, name, acct_num, deposit):
self._name = name
self._account_number = acct_num
self._balance = deposit
@property
def Balance(self):
#balance is read only
return self._balanc... | (account.AccountNumber))
self.textBrowser_2.setPlainText(self.textBrowser_2.toPlainText()+"\n"+str(account.Name))
self.textBrowser.setPlainText(self.textBrowser.toPlainText()+"\n"+"$ "+str(account.Balance))
############ Accounts handle ############
class Account(banking):
| 64 | 64 | 185 | 5 | 58 | keroo-adel/Binking_System_management. | banking.py | Python | Account | Account | 216 | 249 | 216 | 216 | 7050f8b40d6da48f07bb3d980afc81ff30e3d1e8 | bigcode/the-stack | train |
9bcf208955e21d1a54b750ee | train | function | def main():
app2 = QApplication(sys.argv)
window=splashscreen()
sys.exit(app2.exec_())
| def main():
| app2 = QApplication(sys.argv)
window=splashscreen()
sys.exit(app2.exec_())
| Login()
self.main.show()
# CLOSE SPLASH SCREEN
self.close()
# INCREASE COUNTER
counter += 1
# def main():
# app = QApplication(sys.argv)
# window = MainApp()
# window.show()
# app.exec_()
def main():
| 64 | 64 | 25 | 3 | 61 | keroo-adel/Binking_System_management. | banking.py | Python | main | main | 672 | 675 | 672 | 672 | 424d76b096eab01c4d01587a0bc707f36369654b | bigcode/the-stack | train |
7e10f5087be118c249c099fa | train | class | class splashscreen(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui=Ui_splashscreen()
self.ui.setupUi(self)
#########
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
#########
... | class splashscreen(QMainWindow):
| def __init__(self):
QMainWindow.__init__(self)
self.ui=Ui_splashscreen()
self.ui.setupUi(self)
#########
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
#########
self.shadow = QGraphicsDropShado... | self.textBrowser.setPlainText(self.textBrowser.toPlainText()+"\n"+"$ "+str(account.Balance))
self.label_39.setText("display all accounts")
self.animationitems()
self.Move_alluser()
def closeEvent(self,event):
reply = QMessageBox.question(self, 'Message',"Are you sure... | 107 | 107 | 359 | 7 | 100 | keroo-adel/Binking_System_management. | banking.py | Python | splashscreen | splashscreen | 617 | 665 | 617 | 617 | b58f10b217359d23faf676cda56d10f0e7b5812a | bigcode/the-stack | train |
e57b620cafc92c55716cbddc | train | class | class Login(QWidget , login):
def __init__(self):
QWidget.__init__(self)
self.setupUi(self)
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.shadow = QGraphicsDropShadowEffect(self)
self.shadow.setBlurRadiu... | class Login(QWidget , login):
| def __init__(self):
QWidget.__init__(self)
self.setupUi(self)
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.shadow = QGraphicsDropShadowEffect(self)
self.shadow.setBlurRadius(20)
self.shadow.setX... | QIcon, QKeySequence, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient)
from SplashScreen import Ui_splashscreen
from PyQt5 import QtCore,QtGui
import MySQLdb
from PyQt5.QtGui import QCursor, QWindow
from PyQt5.QtWidgets import QWidget, QMessageBox, QApplication
from PyQt5.QtCore import *
###### Globla va... | 173 | 173 | 579 | 6 | 167 | keroo-adel/Binking_System_management. | banking.py | Python | Login | Login | 25 | 91 | 25 | 25 | b2f6db9f4c6fb5fe9e4a53f3666d2a019a0796e1 | bigcode/the-stack | train |
eb6f2679bbc0364f47e75f2e | train | class | class MainApp(QMainWindow ,FORM_CLASS,banking):
def __init__(self,parent=None):
super(MainApp, self).__init__(parent)
QMainWindow.__init__(self)
self.setupUi(self)
QtCore.QTimer.singleShot(2000, lambda: self.equale.setText("❤😊 Welcome to KO BANK! 😊❤"))
se... | class MainApp(QMainWindow ,FORM_CLASS,banking):
| def __init__(self,parent=None):
super(MainApp, self).__init__(parent)
QMainWindow.__init__(self)
self.setupUi(self)
QtCore.QTimer.singleShot(2000, lambda: self.equale.setText("❤😊 Welcome to KO BANK! 😊❤"))
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
... | Browser_2.setPlainText(self.textBrowser_2.toPlainText()+"\n"+str(account.Name))
self.textBrowser.setPlainText(self.textBrowser.toPlainText()+"\n"+"$ "+str(account.Balance))
############ Accounts handle ############
class Account(banking):
def __init__(self, name, acct_num, deposit):
self._name ... | 256 | 256 | 4,548 | 13 | 242 | keroo-adel/Binking_System_management. | banking.py | Python | MainApp | MainApp | 252 | 615 | 252 | 252 | 977ad0ba34aa299399bcfabe311cdc2b3212c776 | bigcode/the-stack | train |
5c673fbb3d8b07a6e1f88860 | train | function | def main():
global FPSCLOCK, DISPLAYSURF
pygame.init()
FPSCLOCK = pygame.time.Clock()
DISPLAYSURF = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))
mousex = 0
mousey = 0
pygame.display.set_caption('Memory Game')
mainBoard = getRandomizedBoard()
revealedBoxes = gener... | def main():
| global FPSCLOCK, DISPLAYSURF
pygame.init()
FPSCLOCK = pygame.time.Clock()
DISPLAYSURF = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))
mousex = 0
mousey = 0
pygame.display.set_caption('Memory Game')
mainBoard = getRandomizedBoard()
revealedBoxes = generateRevealedBo... | 0, 255)
CYAN = ( 0, 255, 255)
BGCOLOR = NAVYBLUE
LIGHTBGCOLOR = GREY
BOXCOLOR = WHITE
HIGHLIGHTCOLOR = BLUE
DONUT = 'donut'
SQUARE = 'square'
DIAMOND = 'diamond'
LINES = 'lines'
OVAL = 'oval'
ALLCOLORS = (RED, GREEN, BLUE, YELLOW, ORANGE, PURPLE, CYAN)
ALLSHAPES = (DONUT, SQUARE, DIAMOND, LINE... | 167 | 168 | 562 | 3 | 164 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | main | main | 44 | 111 | 44 | 44 | 7959df9bbb5cb811557f3cbb84152fed617a6ba8 | bigcode/the-stack | train |
7dc2b3a0c5b6f666e37d1cc8 | train | function | def startGameAnimation(board):
coveredBoxes = generateRevealedBoxesData(False)
boxes = []
for x in range(BOARDWIDTH):
for y in range(BOARDHEIGHT):
boxes.append( (x, y) )
random.shuffle(boxes)
boxGroups = splitIntoGroupsOf(8, boxes)
drawBoard(board, coveredBoxes)
... | def startGameAnimation(board):
| coveredBoxes = generateRevealedBoxesData(False)
boxes = []
for x in range(BOARDWIDTH):
for y in range(BOARDHEIGHT):
boxes.append( (x, y) )
random.shuffle(boxes)
boxGroups = splitIntoGroupsOf(8, boxes)
drawBoard(board, coveredBoxes)
for boxGroup in boxGroups:
... | left, top = leftTopCoordsOfBox(boxx, boxy)
pygame.draw.rect(DISPLAYSURF, HIGHLIGHTCOLOR, (left - 5, top - 5, BOXSIZE + 10, BOXSIZE + 10), 4)
def startGameAnimation(board):
| 64 | 64 | 103 | 6 | 58 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | startGameAnimation | startGameAnimation | 227 | 239 | 227 | 227 | 984c88b4ac06e4fd58a93222032725c690da485d | bigcode/the-stack | train |
89e0a5deef56f7647b4b66d9 | train | function | def generateRevealedBoxesData(val):
revealedBoxes = []
for i in range(BOARDWIDTH):
revealedBoxes.append([val] * BOARDHEIGHT)
return revealedBoxes
| def generateRevealedBoxesData(val):
| revealedBoxes = []
for i in range(BOARDWIDTH):
revealedBoxes.append([val] * BOARDHEIGHT)
return revealedBoxes
| generateRevealedBoxesData(False)
drawBoard(mainBoard, revealedBoxes)
pygame.display.update()
pygame.time.wait(1000)
startGameAnimation(mainBoard)
firstSelection = None
pygame.display.... | 64 | 64 | 39 | 9 | 55 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | generateRevealedBoxesData | generateRevealedBoxesData | 114 | 118 | 114 | 114 | 1f502fa9eb1cdc1cc70752ac535470a45a352470 | bigcode/the-stack | train |
59075564f01097d9ce3b595a | train | function | def getShapeAndColor(board, boxx, boxy):
return board[boxx][boxy][0], board[boxx][boxy][1]
| def getShapeAndColor(board, boxx, boxy):
| return board[boxx][boxy][0], board[boxx][boxy][1]
| 1), (left + BOXSIZE - 1, top + i))
elif shape == OVAL:
pygame.draw.ellipse(DISPLAYSURF, color, (left, top + quarter, BOXSIZE, half))
def getShapeAndColor(board, boxx, boxy):
| 63 | 64 | 35 | 13 | 50 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | getShapeAndColor | getShapeAndColor | 185 | 186 | 185 | 185 | ebc08b1fd785bd611515d5988b0a1c4d9f558fa4 | bigcode/the-stack | train |
c1d77b789c537dcbb392fee4 | train | function | def getRandomizedBoard():
icons = []
for color in ALLCOLORS:
for shape in ALLSHAPES:
icons.append( (shape, color) )
random.shuffle(icons)
numIconsUsed = int(BOARDWIDTH * BOARDHEIGHT / 2)
icons = icons[:numIconsUsed] * 2
random.shuffle(icons)
board = []
f... | def getRandomizedBoard():
| icons = []
for color in ALLCOLORS:
for shape in ALLSHAPES:
icons.append( (shape, color) )
random.shuffle(icons)
numIconsUsed = int(BOARDWIDTH * BOARDHEIGHT / 2)
icons = icons[:numIconsUsed] * 2
random.shuffle(icons)
board = []
for x in range(BOARDWIDTH):
... | )
firstSelection = None
pygame.display.update()
FPSCLOCK.tick(FPS)
def generateRevealedBoxesData(val):
revealedBoxes = []
for i in range(BOARDWIDTH):
revealedBoxes.append([val] * BOARDHEIGHT)
return revealedBoxes
def getRandomizedBoard():
| 64 | 64 | 127 | 6 | 57 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | getRandomizedBoard | getRandomizedBoard | 121 | 139 | 121 | 121 | 8cf0fae756aca71b0894ff4f71fba19daaaec26f | bigcode/the-stack | train |
6b5cf8d4999ba882d4e95f66 | train | function | def coverBoxesAnimation(board, boxesToCover):
for coverage in range(0, BOXSIZE + REVEALSPEED, REVEALSPEED):
drawBoxCovers(board, boxesToCover, coverage)
| def coverBoxesAnimation(board, boxesToCover):
| for coverage in range(0, BOXSIZE + REVEALSPEED, REVEALSPEED):
drawBoxCovers(board, boxesToCover, coverage)
| CLOCK.tick(FPS)
def revealBoxesAnimation(board, boxesToReveal):
for coverage in range(BOXSIZE, (-REVEALSPEED) - 1, -REVEALSPEED):
drawBoxCovers(board, boxesToReveal, coverage)
def coverBoxesAnimation(board, boxesToCover):
| 64 | 64 | 45 | 10 | 54 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | coverBoxesAnimation | coverBoxesAnimation | 206 | 208 | 206 | 206 | 8cc55944597f5b49a182ddec8810153a9393fc1b | bigcode/the-stack | train |
f924444ad20785b2ca91ad5e | train | function | def splitIntoGroupsOf(groupSize, theList):
result = []
for i in range(0, len(theList), groupSize):
result.append(theList[i:i + groupSize])
return result
| def splitIntoGroupsOf(groupSize, theList):
| result = []
for i in range(0, len(theList), groupSize):
result.append(theList[i:i + groupSize])
return result
| .shuffle(icons)
board = []
for x in range(BOARDWIDTH):
column = []
for y in range(BOARDHEIGHT):
column.append(icons[0])
del icons[0]
board.append(column)
return board
def splitIntoGroupsOf(groupSize, theList):
| 64 | 64 | 45 | 11 | 52 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | splitIntoGroupsOf | splitIntoGroupsOf | 142 | 146 | 142 | 142 | 417ac9b23578c77b0ba95b1d03bde1e501f2956f | bigcode/the-stack | train |
ab4f5c7181ca6e4fc5b42723 | train | function | def drawIcon(shape, color, boxx, boxy):
quarter = int(BOXSIZE * 0.25)
half = int(BOXSIZE * 0.5)
left, top = leftTopCoordsOfBox(boxx, boxy)
if shape == DONUT:
pygame.draw.circle(DISPLAYSURF, color, (left + half, top + half), half - 5)
pygame.draw.circle(DISPLAYSURF, BGCOLOR, ... | def drawIcon(shape, color, boxx, boxy):
| quarter = int(BOXSIZE * 0.25)
half = int(BOXSIZE * 0.5)
left, top = leftTopCoordsOfBox(boxx, boxy)
if shape == DONUT:
pygame.draw.circle(DISPLAYSURF, color, (left + half, top + half), half - 5)
pygame.draw.circle(DISPLAYSURF, BGCOLOR, (left + half, top + half), quarter - 5)
... | def getBoxAtPixel(x, y):
for boxx in range(BOARDWIDTH):
for boxy in range(BOARDHEIGHT):
left, top = leftTopCoordsOfBox(boxx, boxy)
boxRect = pygame.Rect(left, top, BOXSIZE, BOXSIZE)
if boxRect.collidepoint(x, y):
return (boxx, boxy)
return (None... | 103 | 103 | 344 | 13 | 90 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | drawIcon | drawIcon | 165 | 182 | 165 | 165 | 3660f3c4058eee635da8e29ec02ebd67c9f85447 | bigcode/the-stack | train |
81e14f4052951b8da87c7255 | train | function | def drawBoxCovers(board, boxes, coverage):
for box in boxes:
left, top = leftTopCoordsOfBox(box[0], box[1])
pygame.draw.rect(DISPLAYSURF, BGCOLOR, (left, top, BOXSIZE, BOXSIZE))
shape, color = getShapeAndColor(board, box[0], box[1])
drawIcon(shape, color, box[0], box[1])
... | def drawBoxCovers(board, boxes, coverage):
| for box in boxes:
left, top = leftTopCoordsOfBox(box[0], box[1])
pygame.draw.rect(DISPLAYSURF, BGCOLOR, (left, top, BOXSIZE, BOXSIZE))
shape, color = getShapeAndColor(board, box[0], box[1])
drawIcon(shape, color, box[0], box[1])
if coverage > 0:
pygame.draw.... | , color, (left, top + quarter, BOXSIZE, half))
def getShapeAndColor(board, boxx, boxy):
return board[boxx][boxy][0], board[boxx][boxy][1]
def drawBoxCovers(board, boxes, coverage):
| 63 | 64 | 139 | 11 | 52 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | drawBoxCovers | drawBoxCovers | 189 | 198 | 189 | 189 | 6651cb29e35c3d9150030cd4543c9f969d328b1a | bigcode/the-stack | train |
42b8d1a199e3f04a255b0c96 | train | function | def hasWon(revealedBoxes):
for i in revealedBoxes:
if False in i:
return False
return True
| def hasWon(revealedBoxes):
| for i in revealedBoxes:
if False in i:
return False
return True
| = BGCOLOR
for i in range(13):
color1, color2 = color2, color1
DISPLAYSURF.fill(color1)
drawBoard(board, coveredBoxes)
pygame.display.update()
pygame.time.wait(300)
def hasWon(revealedBoxes):
| 64 | 64 | 29 | 8 | 56 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | hasWon | hasWon | 255 | 259 | 255 | 255 | 1d31bdd43a97bbfafb218db2a5e541baebef10cd | bigcode/the-stack | train |
62e3449b46121651e5c6909b | train | function | def gameWonAnimation(board):
coveredBoxes = generateRevealedBoxesData(True)
color1 = LIGHTBGCOLOR
color2 = BGCOLOR
for i in range(13):
color1, color2 = color2, color1
DISPLAYSURF.fill(color1)
drawBoard(board, coveredBoxes)
pygame.display.update()
pygame... | def gameWonAnimation(board):
| coveredBoxes = generateRevealedBoxesData(True)
color1 = LIGHTBGCOLOR
color2 = BGCOLOR
for i in range(13):
color1, color2 = color2, color1
DISPLAYSURF.fill(color1)
drawBoard(board, coveredBoxes)
pygame.display.update()
pygame.time.wait(300)
| x, y) )
random.shuffle(boxes)
boxGroups = splitIntoGroupsOf(8, boxes)
drawBoard(board, coveredBoxes)
for boxGroup in boxGroups:
revealBoxesAnimation(board, boxGroup)
coverBoxesAnimation(board, boxGroup)
def gameWonAnimation(board):
| 64 | 64 | 86 | 6 | 58 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | gameWonAnimation | gameWonAnimation | 242 | 252 | 242 | 242 | 21e6eda14888634e369ee3ce5abdce0dfcece6b2 | bigcode/the-stack | train |
c412cfd32398daf79eb3596f | train | function | def getBoxAtPixel(x, y):
for boxx in range(BOARDWIDTH):
for boxy in range(BOARDHEIGHT):
left, top = leftTopCoordsOfBox(boxx, boxy)
boxRect = pygame.Rect(left, top, BOXSIZE, BOXSIZE)
if boxRect.collidepoint(x, y):
return (boxx, boxy)
return (None... | def getBoxAtPixel(x, y):
| for boxx in range(BOARDWIDTH):
for boxy in range(BOARDHEIGHT):
left, top = leftTopCoordsOfBox(boxx, boxy)
boxRect = pygame.Rect(left, top, BOXSIZE, BOXSIZE)
if boxRect.collidepoint(x, y):
return (boxx, boxy)
return (None, None)
| def leftTopCoordsOfBox(boxx, boxy):
left = boxx * (BOXSIZE + GAPSIZE) + XMARGIN
top = boxy * (BOXSIZE + GAPSIZE) + YMARGIN
return (left, top)
def getBoxAtPixel(x, y):
| 64 | 64 | 90 | 9 | 55 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | getBoxAtPixel | getBoxAtPixel | 155 | 162 | 155 | 155 | c7b584bef557e187d8ac1bdcfdd9993905d1d271 | bigcode/the-stack | train |
c3e391b8237cd33bbbc2df14 | train | function | def revealBoxesAnimation(board, boxesToReveal):
for coverage in range(BOXSIZE, (-REVEALSPEED) - 1, -REVEALSPEED):
drawBoxCovers(board, boxesToReveal, coverage)
| def revealBoxesAnimation(board, boxesToReveal):
| for coverage in range(BOXSIZE, (-REVEALSPEED) - 1, -REVEALSPEED):
drawBoxCovers(board, boxesToReveal, coverage)
| , color, box[0], box[1])
if coverage > 0:
pygame.draw.rect(DISPLAYSURF, BOXCOLOR, (left, top, coverage, BOXSIZE))
pygame.display.update()
FPSCLOCK.tick(FPS)
def revealBoxesAnimation(board, boxesToReveal):
| 64 | 64 | 49 | 10 | 54 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | revealBoxesAnimation | revealBoxesAnimation | 201 | 203 | 201 | 201 | 6cdaf8f292bbc1b52a3361a1743defe16220ee64 | bigcode/the-stack | train |
ae6da82b25b2f0ba64890b07 | train | function | def drawHighlightBox(boxx, boxy):
left, top = leftTopCoordsOfBox(boxx, boxy)
pygame.draw.rect(DISPLAYSURF, HIGHLIGHTCOLOR, (left - 5, top - 5, BOXSIZE + 10, BOXSIZE + 10), 4)
| def drawHighlightBox(boxx, boxy):
| left, top = leftTopCoordsOfBox(boxx, boxy)
pygame.draw.rect(DISPLAYSURF, HIGHLIGHTCOLOR, (left - 5, top - 5, BOXSIZE + 10, BOXSIZE + 10), 4)
| PLAYSURF, BOXCOLOR, (left, top, BOXSIZE, BOXSIZE))
else:
shape, color = getShapeAndColor(board, boxx, boxy)
drawIcon(shape, color, boxx, boxy)
def drawHighlightBox(boxx, boxy):
| 64 | 64 | 69 | 10 | 54 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | drawHighlightBox | drawHighlightBox | 222 | 224 | 222 | 222 | 1d1fa474fe1a6c0d99bdd6fb5e0256599f28c327 | bigcode/the-stack | train |
cd4ea0ed164a0012f82e1729 | train | function | def drawBoard(board, revealed):
for boxx in range(BOARDWIDTH):
for boxy in range(BOARDHEIGHT):
left, top = leftTopCoordsOfBox(boxx, boxy)
if not revealed[boxx][boxy]:
pygame.draw.rect(DISPLAYSURF, BOXCOLOR, (left, top, BOXSIZE, BOXSIZE))
else:
... | def drawBoard(board, revealed):
| for boxx in range(BOARDWIDTH):
for boxy in range(BOARDHEIGHT):
left, top = leftTopCoordsOfBox(boxx, boxy)
if not revealed[boxx][boxy]:
pygame.draw.rect(DISPLAYSURF, BOXCOLOR, (left, top, BOXSIZE, BOXSIZE))
else:
shape, color = getShap... | drawBoxCovers(board, boxesToReveal, coverage)
def coverBoxesAnimation(board, boxesToCover):
for coverage in range(0, BOXSIZE + REVEALSPEED, REVEALSPEED):
drawBoxCovers(board, boxesToCover, coverage)
def drawBoard(board, revealed):
| 64 | 64 | 113 | 7 | 57 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | drawBoard | drawBoard | 211 | 219 | 211 | 211 | 7c1f73c2adb55eae4129cd89a1a248fb8314e8f3 | bigcode/the-stack | train |
b784c1edf1e1259d3f632ba7 | train | function | def leftTopCoordsOfBox(boxx, boxy):
left = boxx * (BOXSIZE + GAPSIZE) + XMARGIN
top = boxy * (BOXSIZE + GAPSIZE) + YMARGIN
return (left, top)
| def leftTopCoordsOfBox(boxx, boxy):
| left = boxx * (BOXSIZE + GAPSIZE) + XMARGIN
top = boxy * (BOXSIZE + GAPSIZE) + YMARGIN
return (left, top)
| .append(column)
return board
def splitIntoGroupsOf(groupSize, theList):
result = []
for i in range(0, len(theList), groupSize):
result.append(theList[i:i + groupSize])
return result
def leftTopCoordsOfBox(boxx, boxy):
| 64 | 64 | 55 | 12 | 51 | CodeMaster7000/Pygame-Memory-Game | Pygame Memory Game.py | Python | leftTopCoordsOfBox | leftTopCoordsOfBox | 149 | 152 | 149 | 149 | 2b919101bd240c9ceb1c2cee21466b203398dcd3 | bigcode/the-stack | train |
f053af429aed5e23a9033955 | train | function | def NewNIC(rg, subnet, index=int, vm_name=str):
return azure.network.NetworkInterface(
f'nic{index}',
name=f'{vm_name}-nic',
location=rg.location,
resource_group_name=rg.name,
ip_configurations=[{
'name': f'{vm_name}-ipconfig',
'subnet_id': subnet.id,
... | def NewNIC(rg, subnet, index=int, vm_name=str):
| return azure.network.NetworkInterface(
f'nic{index}',
name=f'{vm_name}-nic',
location=rg.location,
resource_group_name=rg.name,
ip_configurations=[{
'name': f'{vm_name}-ipconfig',
'subnet_id': subnet.id,
'privateIpAddressAllocation': 'Dynam... | (subnet, nsg, index=int):
return azure.network.SubnetNetworkSecurityGroupAssociation(
f'assoc_subnet_nsg{index}',
subnet_id=subnet.id,
network_security_group_id=nsg.id
)
def NewNIC(rg, subnet, index=int, vm_name=str):
| 64 | 64 | 93 | 15 | 49 | mino-s2000/pulumi-project | win-vm-with-2-subnet/__main__.py | Python | NewNIC | NewNIC | 93 | 104 | 93 | 93 | 2b506153a5b05934f4bb9fa9932f1e65143be0ae | bigcode/the-stack | train |
801e57aaf6c700297d3fcbfd | train | function | def NewNICwithPublicIP(rg, subnet, public_ip, index=int, vm_name=str):
return azure.network.NetworkInterface(
f'nic{index}',
name=f'{vm_name}-nic',
location=rg.location,
resource_group_name=rg.name,
ip_configurations=[{
'name': f'{vm_name}-ipconfig',
'... | def NewNICwithPublicIP(rg, subnet, public_ip, index=int, vm_name=str):
| return azure.network.NetworkInterface(
f'nic{index}',
name=f'{vm_name}-nic',
location=rg.location,
resource_group_name=rg.name,
ip_configurations=[{
'name': f'{vm_name}-ipconfig',
'subnet_id': subnet.id,
'privateIpAddressAllocation': 'Dynam... | .name,
ip_configurations=[{
'name': f'{vm_name}-ipconfig',
'subnet_id': subnet.id,
'privateIpAddressAllocation': 'Dynamic'
}]
)
def NewNICwithPublicIP(rg, subnet, public_ip, index=int, vm_name=str):
| 64 | 64 | 110 | 21 | 43 | mino-s2000/pulumi-project | win-vm-with-2-subnet/__main__.py | Python | NewNICwithPublicIP | NewNICwithPublicIP | 106 | 118 | 106 | 106 | e8123347188799ba0fa07241acff09080ded3b0e | bigcode/the-stack | train |
ab8d54ffae73b062dc0e7aa5 | train | function | def NewWindowsVM(rg, nic, storage, index=int, name=str, size='Standard_D2s_v3', username='azureuser', password=str):
return azure.compute.VirtualMachine(
f'vm{index}',
name=name,
location=rg.location,
resource_group_name=rg.name,
vm_size=size,
network_interface_ids=[n... | def NewWindowsVM(rg, nic, storage, index=int, name=str, size='Standard_D2s_v3', username='azureuser', password=str):
| return azure.compute.VirtualMachine(
f'vm{index}',
name=name,
location=rg.location,
resource_group_name=rg.name,
vm_size=size,
network_interface_ids=[nic.id],
delete_os_disk_on_termination=True,
storage_image_reference={
'publisher': 'Micro... | .location,
resource_group_name=rg.name,
account_tier='Standard',
account_kind='Storage',
account_replication_type='LRS',
enable_https_traffic_only=True
)
def NewWindowsVM(rg, nic, storage, index=int, name=str, size='Standard_D2s_v3', username='azureuser', password=str):
| 76 | 76 | 254 | 34 | 42 | mino-s2000/pulumi-project | win-vm-with-2-subnet/__main__.py | Python | NewWindowsVM | NewWindowsVM | 142 | 176 | 142 | 142 | 1c74a2dcb827b62e7ba11c6eb1830b6262471650 | bigcode/the-stack | train |
745d96e3edc331c31a073b04 | train | function | def NewSubnet(rg, vnet, index=int, name=str, addr_prefix=str):
return azure.network.Subnet(
f'subnet{index}',
name=name,
resource_group_name=rg.name,
virtual_network_name=vnet.name,
address_prefixes=[addr_prefix]
)
| def NewSubnet(rg, vnet, index=int, name=str, addr_prefix=str):
| return azure.network.Subnet(
f'subnet{index}',
name=name,
resource_group_name=rg.name,
virtual_network_name=vnet.name,
address_prefixes=[addr_prefix]
)
| _spaces=list):
return azure.network.VirtualNetwork(
f'vnet{index}',
name=name,
location=rg.location,
resource_group_name=rg.name,
address_spaces=addr_spaces
)
def NewSubnet(rg, vnet, index=int, name=str, addr_prefix=str):
| 64 | 64 | 64 | 19 | 45 | mino-s2000/pulumi-project | win-vm-with-2-subnet/__main__.py | Python | NewSubnet | NewSubnet | 69 | 76 | 69 | 69 | 0c4b67225d3d167643e126b09399b4e5f2f2513b | bigcode/the-stack | train |
0f5f66e29ab42c240e5e68e2 | train | function | def NewPublicIP(rg, index=int, vm_name=str):
return azure.network.PublicIp(
f'public_ip{index}',
name=f'{vm_name}-pip',
location=rg.location,
resource_group_name=rg.name,
allocation_method='Static',
sku='Standard'
)
| def NewPublicIP(rg, index=int, vm_name=str):
| return azure.network.PublicIp(
f'public_ip{index}',
name=f'{vm_name}-pip',
location=rg.location,
resource_group_name=rg.name,
allocation_method='Static',
sku='Standard'
)
| _configurations=[{
'name': f'{vm_name}-ipconfig',
'subnet_id': subnet.id,
'privateIpAddressAllocation': 'Dynamic',
'publicIpAddressId': public_ip.id
}]
)
def NewPublicIP(rg, index=int, vm_name=str):
| 64 | 64 | 65 | 14 | 50 | mino-s2000/pulumi-project | win-vm-with-2-subnet/__main__.py | Python | NewPublicIP | NewPublicIP | 120 | 128 | 120 | 120 | 9fab69c0fe4be2432e8b341c737e6a34a7b4b92a | bigcode/the-stack | train |
5cef42eca80be506c366efa1 | train | function | def NewStorage(rg, index=int, name=str):
return azure.storage.Account(
f'storage{index}',
name=name,
location=rg.location,
resource_group_name=rg.name,
account_tier='Standard',
account_kind='Storage',
account_replication_type='LRS',
enable_https_traffi... | def NewStorage(rg, index=int, name=str):
| return azure.storage.Account(
f'storage{index}',
name=name,
location=rg.location,
resource_group_name=rg.name,
account_tier='Standard',
account_kind='Storage',
account_replication_type='LRS',
enable_https_traffic_only=True
)
| ):
return azure.network.PublicIp(
f'public_ip{index}',
name=f'{vm_name}-pip',
location=rg.location,
resource_group_name=rg.name,
allocation_method='Static',
sku='Standard'
)
def NewStorage(rg, index=int, name=str):
| 64 | 64 | 76 | 12 | 52 | mino-s2000/pulumi-project | win-vm-with-2-subnet/__main__.py | Python | NewStorage | NewStorage | 130 | 140 | 130 | 130 | 6cfc8aa1eae140303f9d6ba39efc3625fb3a21dd | bigcode/the-stack | train |
7579cb4415705f2f4149acae | train | function | def NewNSG(rg, index=int, name=str):
return azure.network.NetworkSecurityGroup(
f'nsg{index}',
name=name,
location=rg.location,
resource_group_name=rg.name
)
| def NewNSG(rg, index=int, name=str):
| return azure.network.NetworkSecurityGroup(
f'nsg{index}',
name=name,
location=rg.location,
resource_group_name=rg.name
)
| =str, addr_prefix=str):
return azure.network.Subnet(
f'subnet{index}',
name=name,
resource_group_name=rg.name,
virtual_network_name=vnet.name,
address_prefixes=[addr_prefix]
)
def NewNSG(rg, index=int, name=str):
| 64 | 64 | 48 | 13 | 51 | mino-s2000/pulumi-project | win-vm-with-2-subnet/__main__.py | Python | NewNSG | NewNSG | 78 | 84 | 78 | 78 | 79f07484847ca0b36465e4c4ba7ec1f361b2a9ef | bigcode/the-stack | train |
7620240b49ca8e05b7e37124 | train | function | def NewVirtualNetwork(rg, index=int, name=str, addr_spaces=list):
return azure.network.VirtualNetwork(
f'vnet{index}',
name=name,
location=rg.location,
resource_group_name=rg.name,
address_spaces=addr_spaces
)
| def NewVirtualNetwork(rg, index=int, name=str, addr_spaces=list):
| return azure.network.VirtualNetwork(
f'vnet{index}',
name=name,
location=rg.location,
resource_group_name=rg.name,
address_spaces=addr_spaces
)
| False
}
]
def NewResourceGroup(index=int, name=str, location='japaneast'):
return azure.core.ResourceGroup(
f'rg{index}',
name=name,
location=location
)
def NewVirtualNetwork(rg, index=int, name=str, addr_spaces=list):
| 64 | 64 | 59 | 17 | 47 | mino-s2000/pulumi-project | win-vm-with-2-subnet/__main__.py | Python | NewVirtualNetwork | NewVirtualNetwork | 60 | 67 | 60 | 60 | 7b062770077dcfe8c3477f6f3b6fb7007ecf8f24 | bigcode/the-stack | train |
a8a58a16ab3d0c8b7f91321a | train | function | def NewResourceGroup(index=int, name=str, location='japaneast'):
return azure.core.ResourceGroup(
f'rg{index}',
name=name,
location=location
)
| def NewResourceGroup(index=int, name=str, location='japaneast'):
| return azure.core.ResourceGroup(
f'rg{index}',
name=name,
location=location
)
| ': data['vm'][1]['name'],
'os_type': 'Windows',
'location': data['rg']['location'],
'size': 'Standard_D2_v3',
'public': False
}
]
def NewResourceGroup(index=int, name=str, location='japaneast'):
| 64 | 64 | 42 | 17 | 47 | mino-s2000/pulumi-project | win-vm-with-2-subnet/__main__.py | Python | NewResourceGroup | NewResourceGroup | 53 | 58 | 53 | 53 | 14675ddff555e05cde13bb5315a5a28a8c704644 | bigcode/the-stack | train |
8ccdc83910e09af9585fd3e8 | train | function | def AssociateSubnetNSG(subnet, nsg, index=int):
return azure.network.SubnetNetworkSecurityGroupAssociation(
f'assoc_subnet_nsg{index}',
subnet_id=subnet.id,
network_security_group_id=nsg.id
)
| def AssociateSubnetNSG(subnet, nsg, index=int):
| return azure.network.SubnetNetworkSecurityGroupAssociation(
f'assoc_subnet_nsg{index}',
subnet_id=subnet.id,
network_security_group_id=nsg.id
)
| )
def NewNSG(rg, index=int, name=str):
return azure.network.NetworkSecurityGroup(
f'nsg{index}',
name=name,
location=rg.location,
resource_group_name=rg.name
)
def AssociateSubnetNSG(subnet, nsg, index=int):
| 64 | 64 | 54 | 14 | 50 | mino-s2000/pulumi-project | win-vm-with-2-subnet/__main__.py | Python | AssociateSubnetNSG | AssociateSubnetNSG | 86 | 91 | 86 | 86 | e7decaffd8124e87d3651ab0cba5d911c792ac07 | bigcode/the-stack | train |
ffa499247c6f3a52021e8151 | train | function | def main():
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import main_wrapper_tests
fLOG(OutputPrint=True)
main_wrapper_tests(__file__)
| def main():
| from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import main_wrapper_tests
fLOG(OutputPrint=True)
main_wrapper_tests(__file__)
| """
@file
@brief run all unit tests
"""
def main():
| 15 | 64 | 40 | 3 | 12 | sdpython/csharpyml | _unittests/run_unittests.py | Python | main | main | 7 | 11 | 7 | 7 | 1d3250d38e75d3efcd89485a1bf8fa53d6928c83 | bigcode/the-stack | train |
3568c865dd6caf659b30ba87 | train | class | class FieldSchemaBase:
view_schema: ViewSchemaBase
| class FieldSchemaBase:
| view_schema: ViewSchemaBase
| BaseSerializer,
write_only: bool = True,
read_only: bool = True,
required: bool = True,
) -> OpenAPISchema:
...
def map_query_serializer(self, serializer: BaseSerializer) -> t.List[OpenAPISchema]:
...
class FieldSchemaBase:
| 64 | 64 | 13 | 5 | 59 | WinaZar/restdoctor | restdoctor/rest_framework/schema/custom_types.py | Python | FieldSchemaBase | FieldSchemaBase | 68 | 69 | 68 | 68 | ae40d419409e3b1bdc95e43656da4c252de6a16c | bigcode/the-stack | train |
7319d0c023ab7e39f364a5f7 | train | class | class SchemaGenerator(RestFrameworkSchemaGenerator):
api_default_content_type: str
api_default_version: str
api_default_format: str
api_formats: list[str]
api_resource: str | None
include_default_schema: bool
openapi_version: VersionInfo
| class SchemaGenerator(RestFrameworkSchemaGenerator):
| api_default_content_type: str
api_default_version: str
api_default_format: str
api_formats: list[str]
api_resource: str | None
include_default_schema: bool
openapi_version: VersionInfo
| ...], t.Any]
ResponseCode = str
ActionDescription = str
CodeActionSchemaTuple = t.Tuple[ResponseCode, ActionDescription, t.Optional[OpenAPISchema]] # type: ignore
CodeDescriptionTuple = t.Tuple[ResponseCode, ActionDescription]
class SchemaGenerator(RestFrameworkSchemaGenerator):
| 64 | 64 | 60 | 8 | 56 | WinaZar/restdoctor | restdoctor/rest_framework/schema/custom_types.py | Python | SchemaGenerator | SchemaGenerator | 21 | 28 | 21 | 21 | 7430edc70f93e74e51102b4d54f34153f5964f2f | bigcode/the-stack | train |
7da25bfce6f50847f2ca44df | train | class | class SerializerSchemaBase:
view_schema: ViewSchemaBase
| class SerializerSchemaBase:
| view_schema: ViewSchemaBase
| _only: bool = True,
required: bool = True,
) -> OpenAPISchema:
...
def map_query_serializer(self, serializer: BaseSerializer) -> t.List[OpenAPISchema]:
...
class FieldSchemaBase:
view_schema: ViewSchemaBase
class SerializerSchemaBase:
| 64 | 64 | 13 | 5 | 58 | WinaZar/restdoctor | restdoctor/rest_framework/schema/custom_types.py | Python | SerializerSchemaBase | SerializerSchemaBase | 72 | 73 | 72 | 72 | 07f5b10ba643d8f35fb9ed5dd741a47888ffda81 | bigcode/the-stack | train |
ab07440a08c518178c78d913 | train | class | class SerializerSchemaProtocol(t.Protocol):
def get_serializer_schema(
self,
serializer: BaseSerializer,
write_only: bool = True,
read_only: bool = True,
required: bool = True,
) -> OpenAPISchema:
...
def map_serializer(
self,
serializer: Base... | class SerializerSchemaProtocol(t.Protocol):
| def get_serializer_schema(
self,
serializer: BaseSerializer,
write_only: bool = True,
read_only: bool = True,
required: bool = True,
) -> OpenAPISchema:
...
def map_serializer(
self,
serializer: BaseSerializer,
write_only: bool = True,... | field: Field) -> t.Optional[OpenAPISchema]:
...
def get_field_description(self, field: Field) -> t.Optional[str]:
...
def map_field_validators(self, field: Field, schema: OpenAPISchema) -> None:
...
class SerializerSchemaProtocol(t.Protocol):
| 64 | 64 | 125 | 7 | 57 | WinaZar/restdoctor | restdoctor/rest_framework/schema/custom_types.py | Python | SerializerSchemaProtocol | SerializerSchemaProtocol | 45 | 65 | 45 | 45 | 2d59c15b0815d358dc116d3a528be2981cb3ebb1 | bigcode/the-stack | train |
1e5f6945c0b70d847179ca5d | train | class | class ViewSchemaBase(abc.ABC):
generator: t.Optional[SchemaGenerator] = None
serializer_schema: SerializerSchemaProtocol
field_schema: FieldSchemaProtocol
def get_field_schema(self, field: Field) -> OpenAPISchema:
return self.field_schema.get_field_schema(field)
def get_serializer_schema(
... | class ViewSchemaBase(abc.ABC):
| generator: t.Optional[SchemaGenerator] = None
serializer_schema: SerializerSchemaProtocol
field_schema: FieldSchemaProtocol
def get_field_schema(self, field: Field) -> OpenAPISchema:
return self.field_schema.get_field_schema(field)
def get_serializer_schema(
self,
serialize... | self,
serializer: BaseSerializer,
write_only: bool = True,
read_only: bool = True,
required: bool = True,
) -> OpenAPISchema:
...
def map_query_serializer(self, serializer: BaseSerializer) -> t.List[OpenAPISchema]:
...
class FieldSchemaBase:
view_sc... | 100 | 100 | 334 | 9 | 90 | WinaZar/restdoctor | restdoctor/rest_framework/schema/custom_types.py | Python | ViewSchemaBase | ViewSchemaBase | 76 | 116 | 76 | 76 | 37391860852721fc742650fa26f25b0afb7c1903 | bigcode/the-stack | train |
027428be0173d8b536c017c4 | train | class | class FieldSchemaProtocol(t.Protocol):
def get_field_schema(self, field: Field) -> OpenAPISchema:
...
def map_field(self, field: Field) -> t.Optional[OpenAPISchema]:
...
def get_field_description(self, field: Field) -> t.Optional[str]:
...
def map_field_validators(self, field:... | class FieldSchemaProtocol(t.Protocol):
| def get_field_schema(self, field: Field) -> OpenAPISchema:
...
def map_field(self, field: Field) -> t.Optional[OpenAPISchema]:
...
def get_field_description(self, field: Field) -> t.Optional[str]:
...
def map_field_validators(self, field: Field, schema: OpenAPISchema) -> None:... | (RestFrameworkSchemaGenerator):
api_default_content_type: str
api_default_version: str
api_default_format: str
api_formats: list[str]
api_resource: str | None
include_default_schema: bool
openapi_version: VersionInfo
class FieldSchemaProtocol(t.Protocol):
| 64 | 64 | 89 | 7 | 56 | WinaZar/restdoctor | restdoctor/rest_framework/schema/custom_types.py | Python | FieldSchemaProtocol | FieldSchemaProtocol | 31 | 42 | 31 | 31 | a6fc6dae9740d0fdaafe0497b37fcb0efb52e6c1 | bigcode/the-stack | train |
5be1a7f383f74c8217b49aec | train | function | def get_cards():
num = 0
cards = os.environ.get('CUDA_VISIBLE_DEVICES', '')
if cards != '':
num = len(cards.split(","))
return num
| def get_cards():
| num = 0
cards = os.environ.get('CUDA_VISIBLE_DEVICES', '')
if cards != '':
num = len(cards.split(","))
return num
| print("kpis\ttrain_duration_card%s\t%s" % (card_num, _time))
print("kpis\ttrain_ppl_card%s\t%f" % (card_num, _ppl))
with profile_context(args.profile, args.profiler_path):
train()
def get_cards():
| 64 | 64 | 40 | 4 | 60 | weiwei1115/models | PaddleNLP/legacy/seq2seq/seq2seq/train.py | Python | get_cards | get_cards | 271 | 276 | 271 | 271 | 03c70f270481c66e48400ea8219a75e50651c284 | bigcode/the-stack | train |
025f59c979935e85ca866b60 | train | function | def main():
args = parse_args()
print(args)
num_layers = args.num_layers
src_vocab_size = args.src_vocab_size
tar_vocab_size = args.tar_vocab_size
batch_size = args.batch_size
dropout = args.dropout
init_scale = args.init_scale
max_grad_norm = args.max_grad_norm
hidden_size = arg... | def main():
| args = parse_args()
print(args)
num_layers = args.num_layers
src_vocab_size = args.src_vocab_size
tar_vocab_size = args.tar_vocab_size
batch_size = args.batch_size
dropout = args.dropout
init_scale = args.init_scale
max_grad_norm = args.max_grad_norm
hidden_size = args.hidden_siz... | 0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
... | 256 | 256 | 1,718 | 3 | 252 | weiwei1115/models | PaddleNLP/legacy/seq2seq/seq2seq/train.py | Python | main | main | 58 | 268 | 58 | 58 | 2a4086ad5c0a5cfdf754824c446f1adfdca0c99a | bigcode/the-stack | train |
9f540b0f1c4a68f1d3b8e600 | train | function | def check_version():
"""
Log error and exit when the installed version of paddlepaddle is
not satisfied.
"""
err = "PaddlePaddle version 1.6 or higher is required, " \
"or a suitable develop version is satisfied as well. \n" \
"Please make sure the version is good with your code.... | def check_version():
| """
Log error and exit when the installed version of paddlepaddle is
not satisfied.
"""
err = "PaddlePaddle version 1.6 or higher is required, " \
"or a suitable develop version is satisfied as well. \n" \
"Please make sure the version is good with your code." \
try:
... | , _ppl))
with profile_context(args.profile, args.profiler_path):
train()
def get_cards():
num = 0
cards = os.environ.get('CUDA_VISIBLE_DEVICES', '')
if cards != '':
num = len(cards.split(","))
return num
def check_version():
| 64 | 64 | 109 | 4 | 59 | weiwei1115/models | PaddleNLP/legacy/seq2seq/seq2seq/train.py | Python | check_version | check_version | 279 | 292 | 279 | 279 | cc3185e4ed6ee9acac89c4b9fc66d5c8e1e9dd26 | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.