code stringlengths 10 2.58M | original_code stringlengths 3 3.18M | original_language stringclasses 1
value | source stringclasses 7
values |
|---|---|---|---|
import os
function walk extension directory output
begin
if not exists path directory
begin
print string Directory { directory } not found
return
end
if exists path directory and call splitext directory at 1 == extension
begin
append output directory
return
end
for each in list directory directory
begin
set fpth = join... | import os
def walk(extension, directory, output):
if not os.path.exists(directory):
print(f'Directory {directory} not found')
return
if os.path.exists(directory) and os.path.splitext(directory)[1] == extension:
output.append(directory)
return
for each in os.listdir(directory... | Python | zaydzuhri_stack_edu_python |
from automata import BA
from weightedAut import wBA
comment from fileToBA import *
from determinize import determinize
from DSGame import findMinWeight
comment detLP is defined when weight of word is given by infimum of weight of runs
comment Input
comment wAut1 and wAut2 are input weighted automata
comment num is disc... | from automata import BA
from weightedAut import wBA
#from fileToBA import *
from determinize import determinize
from DSGame import findMinWeight
# detLP is defined when weight of word is given by infimum of weight of runs
# Input
# wAut1 and wAut2 are input weighted automata
# num is discount factor
# Output
# ... | Python | zaydzuhri_stack_edu_python |
for tuple key value in items professor_dict
begin
set key = tuple reversed key
set d at key = value
end
for tuple key value in sorted items d
begin
print key value
end | for key,value in professor_dict.items():
key = tuple(reversed(key))
d[key] = value
for key, value in sorted(d.items()):
print(key,value)
| Python | zaydzuhri_stack_edu_python |
function test_get_experiment_from_key__invalid_key self
begin
with patch string optimizely.logger.SimpleLogger.log as mock_logging
begin
call get_experiment_from_key string invalid_key
end
call assert_called_once_with ERROR string Experiment key "invalid_key" is not in datafile.
end function | def test_get_experiment_from_key__invalid_key(self):
with mock.patch('optimizely.logger.SimpleLogger.log') as mock_logging:
self.project_config.get_experiment_from_key('invalid_key')
mock_logging.assert_called_once_with(enums.LogLevels.ERROR, 'Experiment key "invalid_key" is not in datafile.') | Python | nomic_cornstack_python_v1 |
comment python code
comment script_name: Dopamine_73608420
comment author: Nicole Fronda
comment description: Sonification of Heart Rate on Dopamine for Random Patient 73608420
from earsketch import *
from math import *
comment ------- FUNCTIONS ------- #
function getMean ls
begin
return sum ls / length ls
end function... | # python code
# script_name: Dopamine_73608420
# author: Nicole Fronda
# description: Sonification of Heart Rate on Dopamine for Random Patient 73608420
from earsketch import *
from math import *
# ------- FUNCTIONS ------- #
def getMean(ls):
return sum(ls) / len(ls)
def buildBeatTrack(sounds, track, start, dura... | Python | zaydzuhri_stack_edu_python |
function _collection_default_options self name **kargs
begin
string Get a Collection instance with the default settings.
set wc = if expression acknowledged then write_concern else call WriteConcern
return call get_collection name codec_options=DEFAULT_CODEC_OPTIONS read_preference=PRIMARY write_concern=wc
end function | def _collection_default_options(self, name, **kargs):
"""Get a Collection instance with the default settings."""
wc = (self.write_concern
if self.write_concern.acknowledged else WriteConcern())
return self.get_collection(
name, codec_options=DEFAULT_CODEC_OPTIONS,
... | Python | jtatman_500k |
import pygame
from typing import List , Optional , Dict , Tuple
from Graphics.constants import SPRITE_WIDTH , WOBBLE_COUNT
from Graphics.spritesheet import SpriteSheet
set sprite_sheet : Optional at SpriteSheet = none
set LOADED_TRIPLES : Dict at tuple Tuple at tuple Tuple at tuple int int Tuple at tuple int int int Li... | import pygame
from typing import List, Optional, Dict, Tuple
from Graphics.constants import SPRITE_WIDTH, WOBBLE_COUNT
from Graphics.spritesheet import SpriteSheet
sprite_sheet: Optional[SpriteSheet] = None
LOADED_TRIPLES: Dict[Tuple[Tuple[int, int], Tuple[int, int, int]], List[pygame.Surface]] = {}
def load_spri... | Python | zaydzuhri_stack_edu_python |
comment !/usr/bin/env python
comment Google Code Challenge - Credit Problem
comment http://code.google.com/codejam/contest/351101/dashboard#s=p0
import itertools
import bisect
from time import time
function check items credit
begin
set orig = list items
sort items
set extsplice = call bisect_left items credit
set intsp... | #!/usr/bin/env python
# Google Code Challenge - Credit Problem
# http://code.google.com/codejam/contest/351101/dashboard#s=p0
import itertools
import bisect
from time import time
def check(items, credit):
orig = list(items)
items.sort()
extsplice = bisect.bisect_left(items, credit)
intsplice = bisect... | Python | zaydzuhri_stack_edu_python |
function ma_process eps theta
begin
comment reverse the order of theta as Xt, Xt-1, Xt-k in an array is Xt-k, Xt-1, Xt.
set theta = array list 1 + list theta at slice : : - 1 at tuple slice : : none
set tuple eps_q _ = call lag_view eps length theta
return eps_q @ theta
end function | def ma_process(eps, theta):
# reverse the order of theta as Xt, Xt-1, Xt-k in an array is Xt-k, Xt-1, Xt.
theta = np.array([1] + list(theta))[::-1][:, None]
eps_q, _ = lag_view(eps, len(theta))
return eps_q @ theta | Python | nomic_cornstack_python_v1 |
function clear_select_fields self
begin
set select = tuple
set values_select = tuple
end function | def clear_select_fields(self):
self.select = ()
self.values_select = () | Python | nomic_cornstack_python_v1 |
function resolve_resolver_value self resolver
begin
try
begin
return call resolve
end
except RecursiveResolve
begin
comment Recursive resolve issues shouldn't be masked by a placeholder.
raise
end
except Exception
begin
if call are_placeholders_enabled
begin
set placeholder_value = call create_placeholder_value resolve... | def resolve_resolver_value(self, resolver: "Resolver") -> Any:
try:
return resolver.resolve()
except RecursiveResolve:
# Recursive resolve issues shouldn't be masked by a placeholder.
raise
except Exception:
if are_placeholders_enabled():
... | Python | nomic_cornstack_python_v1 |
function plot_connectivity_surrogate self measure_name repeats=100 fig=none
begin
string Plot spectral connectivity measure under the assumption of no actual connectivity. Repeatedly samples connectivity from phase-randomized data. This provides estimates of the connectivity distribution if there was no causal structur... | def plot_connectivity_surrogate(self, measure_name, repeats=100, fig=None):
""" Plot spectral connectivity measure under the assumption of no actual connectivity.
Repeatedly samples connectivity from phase-randomized data. This provides estimates of the connectivity
distribution if there was no... | Python | jtatman_500k |
function to_bytes self
begin
string Create bytes from properties
comment Verify that the properties make sense
call sanitize
comment Write the version
set bitstream = call BitStream string uint:4=%d % version
comment Write the header length
set options_len = ceil length options / 4.0
set bitstream = bitstream + call Bi... | def to_bytes(self):
'''
Create bytes from properties
'''
# Verify that the properties make sense
self.sanitize()
# Write the version
bitstream = BitStream('uint:4=%d' % self.version)
# Write the header length
options_len = math.ceil(len(self.opti... | Python | jtatman_500k |
function ingest_xcam path_to_file
begin
call ingest_xcam_roi_file path_to_file
end function | def ingest_xcam(path_to_file: str) -> None:
ingest_xcam_roi_file(path_to_file) | Python | nomic_cornstack_python_v1 |
import nibabel as nib
from nibabel.processing import resample_from_to
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from matplotlib import cm as cm
import scipy
import os
import warnings
function sorrenson_dice data1_file data2_file reslice=true
begin
comment Load nifti images
set data1_im... | import nibabel as nib
from nibabel.processing import resample_from_to
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from matplotlib import cm as cm
import scipy
import os
import warnings
def sorrenson_dice(data1_file, data2_file, reslice=True):
# Load nifti images
data1_img = nib.... | Python | zaydzuhri_stack_edu_python |
function generate
begin
comment Create the list of article from our data
set generator = call GenerateLDA
call generateLDA
return call jsonify dict string code 200 ; string message string LDA model successfully created.
end function | def generate():
# Create the list of article from our data
generator = GenerateLDA()
generator.generateLDA()
return jsonify({"code": 200, "message" : "LDA model successfully created."}) | Python | nomic_cornstack_python_v1 |
import dolfin as df
import scipy.special as ss
import numpy as np
import math as math
from scipy import optimize
from numba import jit
from numba import njit , prange
from import covariance_matern
from import covariance_matern_jit
function alpha_function x n beta
begin
set output = beta * call jv n x + call jvp n x
r... | import dolfin as df
import scipy.special as ss
import numpy as np
import math as math
from scipy import optimize
from numba import jit
from numba import njit, prange
from . import covariance_matern
from . import covariance_matern_jit
def alpha_function(x, n, beta):
output = beta * ss.jv(n, x) + ss.jvp(n, x)
... | Python | zaydzuhri_stack_edu_python |
comment 类的继承与多态
string 判断是否为其子类 issubclass(son, male) 调用父类的方法 def eat(self): super(Cat, self).eat() pass
class zoo extends object
begin
string 动物
set tag = string 动物园
function __init__ self name age
begin
set name = name
set age = age
end function
function eat self
begin
print string 动物都喜欢吃东西
end function
end class
cla... | #类的继承与多态
'''
判断是否为其子类
issubclass(son, male)
调用父类的方法
def eat(self):
super(Cat, self).eat()
pass
'''
class zoo(object):
'''
动物
'''
tag = "动物园"
def __init__(self, name, age):
self.name = name
self.age = age
def eat(self):
p... | Python | zaydzuhri_stack_edu_python |
comment !/bin/python3
import math
import os
import random
import re
import sys
from collections import Counter
comment Complete the 'makingAnagrams' function below.
comment The function is expected to return an INTEGER.
comment The function accepts following parameters:
comment 1. STRING s1
comment 2. STRING s2
functio... | #!/bin/python3
import math
import os
import random
import re
import sys
from collections import Counter
#
# Complete the 'makingAnagrams' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
# 1. STRING s1
# 2. STRING s2
#
def makingAnagrams(s1, s2):
... | Python | zaydzuhri_stack_edu_python |
function decode_angle_torch target_angs num_theta_bins
begin
if shape at - 1 == 2 * num_theta_bins
begin
comment if target_angs.shape[-1] == num_theta_bins + 1:
set bin_inds = argument maximum dim=- 1
set bin_res = target_angs at tuple Ellipsis slice num_theta_bins : :
end
else
begin
set bin_inds = target_angs at tup... | def decode_angle_torch(target_angs, num_theta_bins):
if target_angs.shape[-1] == 2 * num_theta_bins:
# if target_angs.shape[-1] == num_theta_bins + 1:
bin_inds = target_angs[..., :num_theta_bins].argmax(dim=-1)
bin_res = target_angs[..., num_theta_bins:]
else:
bin_inds = target_a... | Python | nomic_cornstack_python_v1 |
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import image_processing as ImProc
import capture as capture
import numpy as np
class DriverData
begin
function __init__ self
begin
comment this class is the driver of data.
string It ge... | import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import image_processing as ImProc
import capture as capture
import numpy as np
class DriverData():
def __init__(self):
## this class is the driver of data.
... | Python | zaydzuhri_stack_edu_python |
function filter_img img new_img f
begin
set datas = call getdata
set new_data = list
for item in datas
begin
if f dist item at 0 and f dist item at 1 and f dist item at 2
begin
append new_data tuple 0 0 0 0
end
else
begin
append new_data item
end
end
call putdata new_data
end function | def filter_img(img, new_img, f):
datas = img.getdata()
new_data = []
for item in datas:
if f(item[0]) and f(item[1]) and f(item[2]):
new_data.append((0, 0, 0, 0))
else:
new_data.append(item)
new_img.putdata(new_data) | Python | nomic_cornstack_python_v1 |
function __init__ self selrestrs=tuple logical_or=false logical_and=false
begin
set selrestrs = tuple sorted selrestrs
assert not logical_or and logical_and
set logical_or = logical_or
set logical_and = logical_and
end function | def __init__(self, selrestrs=(), logical_or=False, logical_and=False):
self.selrestrs = tuple(sorted(selrestrs))
assert not (logical_or and logical_and)
self.logical_or = logical_or
self.logical_and = logical_and | Python | nomic_cornstack_python_v1 |
function generate_default_tiles default_value
begin
set default_tiles = list comprehension list default_value * BOARDHEIGHT for i in call xrange BOARDWIDTH
return default_tiles
end function | def generate_default_tiles(default_value):
default_tiles = [[default_value]*BOARDHEIGHT for i in xrange(BOARDWIDTH)]
return default_tiles | Python | nomic_cornstack_python_v1 |
function is_closed self
begin
if _state is none
begin
return none
end
return _state == STATE_CLOSED
end function | def is_closed(self) -> bool | None:
if self._state is None:
return None
return self._state == STATE_CLOSED | Python | nomic_cornstack_python_v1 |
import pygame , random , sys , colors , board , pieces
function main
begin
string Función principal del juego.
call init
comment Establecemos el largo y alto de la pantalla [largo,alto]
set screen_size = list 640 480
set screen = call set_mode screen_size
set fuente = call Font string Masanbol.ttf 30
set texto1 = call ... | import pygame,random,sys,colors,board,pieces
def main():
""" Función principal del juego. """
pygame.init()
# Establecemos el largo y alto de la pantalla [largo,alto]
screen_size = [640, 480]
screen = pygame.display.set_mode(screen_size)
fuente = pygame.font.Font('Masanbol.ttf', 30)
texto1 ... | Python | zaydzuhri_stack_edu_python |
function make_logging_api client
begin
string Create an instance of the Logging API adapter. :type client: :class:`~google.cloud.logging.client.Client` :param client: The client that holds configuration details. :rtype: :class:`_LoggingAPI` :returns: A metrics API instance with the proper credentials.
set generated = c... | def make_logging_api(client):
"""Create an instance of the Logging API adapter.
:type client: :class:`~google.cloud.logging.client.Client`
:param client: The client that holds configuration details.
:rtype: :class:`_LoggingAPI`
:returns: A metrics API instance with the proper credentials.
"""
... | Python | jtatman_500k |
function abstract f
begin
function raiser *args **kargs
begin
raise exception string Abstract function must be overridden by a child class before being called
end function
return raiser
end function | def abstract(f):
def raiser(*args,**kargs):
raise Exception('Abstract function must be overridden by a child class before being called')
return raiser | Python | nomic_cornstack_python_v1 |
function checkAll lst
begin
for i in lst
begin
if boolean i == false
begin
return false
end
end
return true
end function
print call checkAll list string a false
print call checkAll list 1 0 3
print call checkAll list 1 2 | def checkAll(lst):
for i in lst:
if (bool(i)==False):
return False
return True
print (checkAll(["a",False]))
print (checkAll([1,0,3]))
print (checkAll([1,2]))
| Python | zaydzuhri_stack_edu_python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.