hexsha string | size int64 | ext string | lang string | max_stars_repo_path string | max_stars_repo_name string | max_stars_repo_head_hexsha string | max_stars_repo_licenses list | max_stars_count int64 | max_stars_repo_stars_event_min_datetime string | max_stars_repo_stars_event_max_datetime string | max_issues_repo_path string | max_issues_repo_name string | max_issues_repo_head_hexsha string | max_issues_repo_licenses list | max_issues_count int64 | max_issues_repo_issues_event_min_datetime string | max_issues_repo_issues_event_max_datetime string | max_forks_repo_path string | max_forks_repo_name string | max_forks_repo_head_hexsha string | max_forks_repo_licenses list | max_forks_count int64 | max_forks_repo_forks_event_min_datetime string | max_forks_repo_forks_event_max_datetime string | content string | avg_line_length float64 | max_line_length int64 | alphanum_fraction float64 | qsc_code_num_words_quality_signal int64 | qsc_code_num_chars_quality_signal float64 | qsc_code_mean_word_length_quality_signal float64 | qsc_code_frac_words_unique_quality_signal float64 | qsc_code_frac_chars_top_2grams_quality_signal float64 | qsc_code_frac_chars_top_3grams_quality_signal float64 | qsc_code_frac_chars_top_4grams_quality_signal float64 | qsc_code_frac_chars_dupe_5grams_quality_signal float64 | qsc_code_frac_chars_dupe_6grams_quality_signal float64 | qsc_code_frac_chars_dupe_7grams_quality_signal float64 | qsc_code_frac_chars_dupe_8grams_quality_signal float64 | qsc_code_frac_chars_dupe_9grams_quality_signal float64 | qsc_code_frac_chars_dupe_10grams_quality_signal float64 | qsc_code_frac_chars_replacement_symbols_quality_signal float64 | qsc_code_frac_chars_digital_quality_signal float64 | qsc_code_frac_chars_whitespace_quality_signal float64 | qsc_code_size_file_byte_quality_signal float64 | qsc_code_num_lines_quality_signal float64 | qsc_code_num_chars_line_max_quality_signal float64 | qsc_code_num_chars_line_mean_quality_signal float64 | qsc_code_frac_chars_alphabet_quality_signal float64 | qsc_code_frac_chars_comments_quality_signal float64 | qsc_code_cate_xml_start_quality_signal float64 | qsc_code_frac_lines_dupe_lines_quality_signal float64 | qsc_code_cate_autogen_quality_signal float64 | qsc_code_frac_lines_long_string_quality_signal float64 | qsc_code_frac_chars_string_length_quality_signal float64 | qsc_code_frac_chars_long_word_length_quality_signal float64 | qsc_code_frac_lines_string_concat_quality_signal float64 | qsc_code_cate_encoded_data_quality_signal float64 | qsc_code_frac_chars_hex_words_quality_signal float64 | qsc_code_frac_lines_prompt_comments_quality_signal float64 | qsc_code_frac_lines_assert_quality_signal float64 | qsc_codepython_cate_ast_quality_signal float64 | qsc_codepython_frac_lines_func_ratio_quality_signal float64 | qsc_codepython_cate_var_zero_quality_signal bool | qsc_codepython_frac_lines_pass_quality_signal float64 | qsc_codepython_frac_lines_import_quality_signal float64 | qsc_codepython_frac_lines_simplefunc_quality_signal float64 | qsc_codepython_score_lines_no_logic_quality_signal float64 | qsc_codepython_frac_lines_print_quality_signal float64 | qsc_code_num_words int64 | qsc_code_num_chars int64 | qsc_code_mean_word_length int64 | qsc_code_frac_words_unique null | qsc_code_frac_chars_top_2grams int64 | qsc_code_frac_chars_top_3grams int64 | qsc_code_frac_chars_top_4grams int64 | qsc_code_frac_chars_dupe_5grams int64 | qsc_code_frac_chars_dupe_6grams int64 | qsc_code_frac_chars_dupe_7grams int64 | qsc_code_frac_chars_dupe_8grams int64 | qsc_code_frac_chars_dupe_9grams int64 | qsc_code_frac_chars_dupe_10grams int64 | qsc_code_frac_chars_replacement_symbols int64 | qsc_code_frac_chars_digital int64 | qsc_code_frac_chars_whitespace int64 | qsc_code_size_file_byte int64 | qsc_code_num_lines int64 | qsc_code_num_chars_line_max int64 | qsc_code_num_chars_line_mean int64 | qsc_code_frac_chars_alphabet int64 | qsc_code_frac_chars_comments int64 | qsc_code_cate_xml_start int64 | qsc_code_frac_lines_dupe_lines int64 | qsc_code_cate_autogen int64 | qsc_code_frac_lines_long_string int64 | qsc_code_frac_chars_string_length int64 | qsc_code_frac_chars_long_word_length int64 | qsc_code_frac_lines_string_concat null | qsc_code_cate_encoded_data int64 | qsc_code_frac_chars_hex_words int64 | qsc_code_frac_lines_prompt_comments int64 | qsc_code_frac_lines_assert int64 | qsc_codepython_cate_ast int64 | qsc_codepython_frac_lines_func_ratio int64 | qsc_codepython_cate_var_zero int64 | qsc_codepython_frac_lines_pass int64 | qsc_codepython_frac_lines_import int64 | qsc_codepython_frac_lines_simplefunc int64 | qsc_codepython_score_lines_no_logic int64 | qsc_codepython_frac_lines_print int64 | effective string | hits int64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5a591a2701e2667b7dd6620ab5efc124f7cfdf69 | 142 | py | Python | jyotisha/panchangam/scripts/__init__.py | vedatemple/jyotisha | 02ff8530c567ad534905300d63b17da177e90226 | [
"MIT"
] | null | null | null | jyotisha/panchangam/scripts/__init__.py | vedatemple/jyotisha | 02ff8530c567ad534905300d63b17da177e90226 | [
"MIT"
] | null | null | null | jyotisha/panchangam/scripts/__init__.py | vedatemple/jyotisha | 02ff8530c567ad534905300d63b17da177e90226 | [
"MIT"
] | null | null | null | import logging
logging.basicConfig(
level=logging.DEBUG,
format="%(levelname)s: %(asctime)s {%(filename)s:%(lineno)d}: %(message)s "
)
| 15.777778 | 77 | 0.676056 | 18 | 142 | 5.333333 | 0.722222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.119718 | 142 | 8 | 78 | 17.75 | 0.768 | 0 | 0 | 0 | 0 | 0.2 | 0.471429 | 0.185714 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.2 | 0 | 0.2 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce81ce96f6587395133bea4b7d5fedf8012af11c | 189 | py | Python | SoftUni_SimpleCalculations/2DRectangleArea.py | MihailTsvetogorov/SoftUni-Random-Dumb-Projects | c7eeedb4701a0b075ab0a86f91111a3875b29d45 | [
"MIT"
] | null | null | null | SoftUni_SimpleCalculations/2DRectangleArea.py | MihailTsvetogorov/SoftUni-Random-Dumb-Projects | c7eeedb4701a0b075ab0a86f91111a3875b29d45 | [
"MIT"
] | null | null | null | SoftUni_SimpleCalculations/2DRectangleArea.py | MihailTsvetogorov/SoftUni-Random-Dumb-Projects | c7eeedb4701a0b075ab0a86f91111a3875b29d45 | [
"MIT"
] | null | null | null | import math
X1 = float(input())
Y1 = float(input())
X2 = float(input())
Y2 = float(input())
print(math.fabs(X1-X2) * math.fabs(Y1-Y2))
print(2*math.fabs(X1-X2) + 2*math.fabs(Y1-Y2))
| 23.625 | 47 | 0.624339 | 34 | 189 | 3.470588 | 0.323529 | 0.338983 | 0.169492 | 0.20339 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.08642 | 0.142857 | 189 | 7 | 48 | 27 | 0.641975 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 0.142857 | 0.285714 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce90ba6025935f53327fecbf4211e806913258c0 | 15,856 | py | Python | EUSTACE_SST_MAT/ReadNetCDF.py | Kate-Willett/HadISDH_Marine_Build | 293b4c89dc6e04e47d3f6e3645cf0f610beca2f2 | [
"CC0-1.0"
] | null | null | null | EUSTACE_SST_MAT/ReadNetCDF.py | Kate-Willett/HadISDH_Marine_Build | 293b4c89dc6e04e47d3f6e3645cf0f610beca2f2 | [
"CC0-1.0"
] | null | null | null | EUSTACE_SST_MAT/ReadNetCDF.py | Kate-Willett/HadISDH_Marine_Build | 293b4c89dc6e04e47d3f6e3645cf0f610beca2f2 | [
"CC0-1.0"
] | null | null | null | #!/usr/local/sci/bin/python
# PYTHON3
#
# Author: Kate Willett
# Created: 16 October 2015
# Last update: 10 April 2019
# Location: /data/local/hadkw/HADCRUH2/UPDATE2014/PROGS/PYTHON/
# GitHub: https://github.com/Kate-Willett/Climate_Explorer/tree/master/PYTHON/
# -----------------------
# CODE PURPOSE AND OUTPUT
# -----------------------
# This reads in a netCDF file and outputs numpy arrays or lists of numpy arrays:
# GetGrid: of a time,lat,lon gridded dataset
# GetGrid4: of a time,lat,lon gridded dataset using netCDF4
# GetGrid4Slice: of a time,lat,lon gridded dataset slice using netCDF4
# GetField: of a lat,lon gridded field of e.g trends
# GetTS: of a time, point/station dataset
#
# -----------------------
# LIST OF MODULES
# -----------------------
# Inbuilt:
# import numpy as np
# import scipy.stats
# import itertools
# from scipy.io import netcdf
## from netCDF4 import Dataset
# import netCDF4 as nc4
# import pdb # pdb.set_trace() or c
#
# Kate's:
#
# -----------------------
# DATA
# -----------------------
# The code requires a netCDF file
#
# -----------------------
# HOW TO RUN THE CODE
# -----------------------
# GetGrid:
# INPUTS:
# # A scalar string containing the filepath+filename
# FileName = '/MyDir/MyFile.nc'
# # A LIST of strings with the names of each variable to read in
# ReadInfo = ['t_anoms'[ # ['t_anoms','t_abs']
# OPTIONAL LatInfo and LonInfo lists to build LatList and LonList if read in isn't going to work
# Default reads in lat and lon variables assuming LatInfo=['latitude'],LonInfo=['longitude']
# Option 1: just provide the variable names to read in:
# LatInfo = ['latitude'] # variable name, number of latitudes, start latitude
# LonInfo = ['longitude'] # variable name, number of longitudes, start longitude
# Option 2: provide number of boxes and start lat/lon:
# LatInfo = [36,-87.5] # number of latitudes, start latitude
# LonInfo = [72,-177.5] # number of longitudes, start longitude
#
# module load scitools/default-current
# python
# from ReadNetCDF import GetGrid
#
# # Premaking of arrays not strictly necessary:
# TmpData = np.reshape(np.repeat(mdi,NMons*NLats*NLons),(NMons,NLats,NLons)) # entire field of data read in
# LatList = [] # list of latitude gridbox centres
# LonList = [] # list of longitude gridbox centres
# # Multiple grid read in case at little more complicated, and still not necessary but nice?:
# import itertools
# TmpData=list(itertools.repeat(np.reshape(np.repeat(mdi,NMons*NLats*NLons),(NMons,NLats,NLons)),len(ReadInfo)))
#
# TmpData,LatList,LonList = ReadNetCDF.GetGrid(FileName,ReadInfo,LatInfo,LonInfo)
# # Multiple grid read in case requires unpacking of the list of np.arrays
# TmpData1=TmpData[0] # etc.
#
# GetField:
#
# GetTS:
#
# -----------------------
# OUTPUT
# -----------------------
# GetGrid:
# TmpData: a numpy array of the 3D gridded field as time, lat, lon or a list of numpy arrays to be unpacked
# LatList: a numpy array of latitude gridbox centres
# LonList: a numpy array of longitude gridbox centre
#
# GetField:
#
# GetTS:
#
# -----------------------
# VERSION/RELEASE NOTES
# -----------------------
#
# Version 3 (10th April 2019)
# ---------
#
# Enhancements
# Mow python 3
#
# Changes
# Now python 3
#
# Bug fixes
#
# Version 2 (28th February 2018)
# ---------
#
# Enhancements
# GetGrid4Slice can now pull out a slice (time, lat or lon)
#
# Changes
# I've added a new GetGrid4 which does the same as GetGrid but works using netCDF4.
# This 'should' then mean that it can work with netCDF4 format and also automatically scale/offset data on read in
# Later I may make it such that you can pull out the variable entirely rather than just the data array so that
# you can access all attributes
#
# Bug fixes
#
#
# Version 1 (16th October 2015)
# ---------
#
# Enhancements
#
# Changes
#
# Bug fixes
#
# -----------------------
# OTHER INFORMATION
# -----------------------
#
#************************************************************************
# Functions
#************************************************************************
# GETGRID
def GetGrid(FileName,
ReadInfo,
LatInfo = ['latitude'],
LonInfo = ['longitude']):
''' Open the NetCDF File
Get the list of latitudes either from file or derive
Get the list of longitudes either from file or derive
Get the data (1 to 10 fields)
INPUTS:
FileName: string containing filepath/name
ReadInfo: a LIST of string variable names (1+) for the grid to read in
LatInfo:
LatInfo=['latitude'[ # DEFAULT
LatInfo=['lat'[ # alternative LIST of string variable name
LatInfo=[36,-87.5] # list containing number of lats, a float for the start latitude
LatInfo:
LatInfo=['longitude'[ # DEFAULT
LatInfo=['lon'[ # alternative LIST of string variable name
LatInfo=[72,-177.5] # list containing number of lons, a float for the start longitude
OUTPUTS:
LatList: a numpy array of latitude gridbox centres
LonList: a numpy array of longitude gridbox centres
TheData:
1 variable: a numpy array of time,lat,lon
2+ variables: a list of numpy arrays of time,lat,lon to be unpacked '''
# Set up python imports
import numpy as np
import scipy.stats
from scipy.io import netcdf
import pdb # pdb.set_trace() or c
# print(FileName,ReadInfo,LatInfo,LonInfo)
# Open the netCDF file
ncf=netcdf.netcdf_file(FileName,'r')
# ncf.variables this lists the variable names
# If LatInfo is only 1 element long then read in the variable, else calculate using given nlats, start_lat
if (len(LatInfo) == 1):
var=ncf.variables[LatInfo[0]]
TheLatList=np.array(var.data)
else:
if (LatInfo[1] < 0):
TheLatList=np.arange(LatInfo[1], LatInfo[1]+180.,(180./LatInfo[0]))
else:
TheLatList=np.arange(LatInfo[1], LatInfo[1]-180.,-(180./LatInfo[0]))
# If LonInfo is only 1 element long then read in the variable, else calculate using given nlons, start_lon
if (len(LonInfo) == 1):
var=ncf.variables[LonInfo[0]]
TheLonList=np.array(var.data)
else:
if (LonInfo[1] < 10):
TheLonList=np.arange(LonInfo[1], LonInfo[1]+360.,(360./LonInfo[0]))
else:
TheLonList=np.arange(LonInfo[1], LonInfo[1]-360.,-(360./LonInfo[0]))
# If ReadInfo is only 1 element long then read into a numpy array, else make a list of arrays and then read in all
if (len(ReadInfo) == 1):
var=ncf.variables[ReadInfo[0]]
TheData=np.array(var.data) # times, lats, lons
#pdb.set_trace()
else:
# Initialise TheData as a list
TheData=[]
for loo in range(len(ReadInfo)):
var=ncf.variables[ReadInfo[loo]]
#pdb.set_trace()
TmpData=np.array(var.data) # times, lats, lons
TheData.append(TmpData)
# # Maybe I've done something wrong but its reading it transposed
# TheData=np.transpose(TheData)
ncf.close()
return TheData,TheLatList,TheLonList # GetGrid
#************************************************************************
#************************************************************************
# GETGRID4
def GetGrid4(FileName,
ReadInfo,
LatInfo = ['latitude'],
LonInfo = ['longitude']):
''' Open the NetCDF File
Get the list of latitudes either from file or derive
Get the list of longitudes either from file or derive
Get the data (1 to 10 fields)
INPUTS:
FileName: string containing filepath/name
ReadInfo: a LIST of string variable names (1+) for the grid to read in
LatInfo:
LatInfo=['latitude'[ # DEFAULT
LatInfo=['lat'[ # alternative LIST of string variable name
LatInfo=[36,-87.5] # list containing number of lats, a float for the start latitude
LatInfo:
LatInfo=['longitude'[ # DEFAULT
LatInfo=['lon'[ # alternative LIST of string variable name
LatInfo=[72,-177.5] # list containing number of lons, a float for the start longitude
OUTPUTS:
LatList: a numpy array of latitude gridbox centres
LonList: a numpy array of longitude gridbox centres
TheData:
1 variable: a numpy array of time,lat,lon
2+ variables: a list of numpy arrays of time,lat,lon to be unpacked '''
# Set up python imports
import numpy as np
import scipy.stats
from scipy.io import netcdf
#from netCDF4 import Dataset
import netCDF4 as nc4
import pdb # pdb.set_trace() or c
# print(FileName,ReadInfo,LatInfo,LonInfo)
# Open the netCDF file
ncf=nc4.Dataset(FileName,'r')
# ncf.variables this lists the variable names
# If LatInfo is only 1 element long then read in the variable, else calculate using given nlats, start_lat
if (len(LatInfo) == 1):
var = ncf.variables[LatInfo[0]] # loads the data and attributes
TheLatList = np.copy(var[:]) # just pulls out the data as a numpy array
#var.ncattrs() # prints the attributues
else:
if (LatInfo[1] < 0):
TheLatList=np.arange(LatInfo[1], LatInfo[1]+180.,(180./LatInfo[0]))
else:
TheLatList=np.arange(LatInfo[1], LatInfo[1]-180.,-(180./LatInfo[0]))
# If LonInfo is only 1 element long then read in the variable, else calculate using given nlons, start_lon
if (len(LonInfo) == 1):
var = ncf.variables[LonInfo[0]]
TheLonList = np.copy(var[:])
else:
if (LonInfo[1] < 10):
TheLonList=np.arange(LonInfo[1], LonInfo[1]+360.,(360./LonInfo[0]))
else:
TheLonList=np.arange(LonInfo[1], LonInfo[1]-360.,-(360./LonInfo[0]))
# If ReadInfo is only 1 element long then read into a numpy array, else make a list of arrays and then read in all
if (len(ReadInfo) == 1):
var = ncf.variables[ReadInfo[0]]
TheData = np.copy(var[:]) # times, lats, lons - THIS AUTOMATICALLY APPLIES SCALE AND OFFSET!!!
#var.ncattrs() # prints the attributues
#pdb.set_trace()
else:
# Initialise TheData as a list
TheData = []
for loo in range(len(ReadInfo)):
var = ncf.variables[ReadInfo[loo]]
#var.ncattrs() # prints the attributues
#var.add_offset # prints the add_offset attribute
#pdb.set_trace()
TmpData = np.copy(var[:]) # times, lats, lons - THIS AUTOMATICALLY APPLIES SCALE AND OFFSET!!!
TheData.append(TmpData)
# # Maybe I've done something wrong but its reading it transposed
# TheData=np.transpose(TheData)
ncf.close()
return TheData,TheLatList,TheLonList # GetGrid4
#*********************************************************************************
#************************************************************************
# GETGRID4SLICE
def GetGrid4Slice(FileName,
ReadInfo,
SliceInfo,
LatInfo = ['latitude'],
LonInfo = ['longitude']):
''' Open the NetCDF File
Get the list of latitudes either from file or derive
Get the list of longitudes either from file or derive
Get the data (1 to 10 fields)
INPUTS:
FileName: string containing filepath/name
ReadInfo: a LIST of string variable names (1+) for the grid to read in
SliceInfo: a dictionary of TimeSlice, LatSlice and LonSlice
each element is either a 2 element list of start and stop+1 of slice
SliceInfo = dict([('TimeSlice',[0,12]), # a slice (e.g., 12 months of a year
('LatSlice',[0,180]), # all at 1deg res
('LonSlice',[0,360])]) # all 1deg res
LatInfo:
LatInfo=['latitude'[ # DEFAULT
LatInfo=['lat'[ # alternative LIST of string variable name
LatInfo=[36,-87.5] # list containing number of lats, a float for the start latitude
NOTE: THIS HAS TO BE ALL LATS EVEN IF YOU'RE PULLING OUT A SLICE
LATS WILL BE SUBSET TO SLICE
LonInfo:
LonInfo=['longitude'[ # DEFAULT
LonInfo=['lon'[ # alternative LIST of string variable name
LonInfo=[72,-177.5] # list containing number of lons, a float for the start longitude
NOTE: THIS HAS TO BE ALL LonS EVEN IF YOU'RE PULLING OUT A SLICE
LonS WILL BE SUBSET TO SLICE
OUTPUTS:
LatList: a numpy array of latitude gridbox centres
LonList: a numpy array of longitude gridbox centres
TheData:
1 variable: a numpy array of time,lat,lon
2+ variables: a list of numpy arrays of time,lat,lon to be unpacked
IF MORE THAN ONE VARIABLE THE SLICES MUST BE THE SAME'''
# Set up python imports
import numpy as np
import scipy.stats
from scipy.io import netcdf
#from netCDF4 import Dataset
import netCDF4 as nc4
import pdb # pdb.set_trace() or c
# print(FileName,ReadInfo,LatInfo,LonInfo)
# Open the netCDF file
ncf=nc4.Dataset(FileName,'r')
# ncf.variables this lists the variable names
# If LatInfo is only 1 element long then read in the variable, else calculate using given nlats, start_lat
if (len(LatInfo) == 1):
var = ncf.variables[LatInfo[0]] # loads the data and attributes
TheLatList = np.copy(var[:]) # just pulls out the data as a numpy array
#var.ncattrs() # prints the attributues
else:
if (LatInfo[1] < 0):
TheLatList=np.arange(LatInfo[1], LatInfo[1]+180.,(180./LatInfo[0]))
else:
TheLatList=np.arange(LatInfo[1], LatInfo[1]-180.,-(180./LatInfo[0]))
# If LonInfo is only 1 element long then read in the variable, else calculate using given nlons, start_lon
if (len(LonInfo) == 1):
var = ncf.variables[LonInfo[0]]
TheLonList = np.copy(var[:])
else:
if (LonInfo[1] < 10):
TheLonList=np.arange(LonInfo[1], LonInfo[1]+360.,(360./LonInfo[0]))
else:
TheLonList=np.arange(LonInfo[1], LonInfo[1]-360.,-(360./LonInfo[0]))
# If ReadInfo is only 1 element long then read into a numpy array, else make a list of arrays and then read in all
if (len(ReadInfo) == 1):
var = ncf.variables[ReadInfo[0]]
TheData = np.copy(var[SliceInfo['TimeSlice'][0]:SliceInfo['TimeSlice'][1],
SliceInfo['LatSlice'][0]:SliceInfo['LatSlice'][1],
SliceInfo['LonSlice'][0]:SliceInfo['LonSlice'][1]]) # times, lats, lons - THIS AUTOMATICALLY APPLIES SCALE AND OFFSET!!!
#var.ncattrs() # prints the attributues
#pdb.set_trace()
else:
# Initialise TheData as a list
TheData = []
for loo in range(len(ReadInfo)):
var = ncf.variables[ReadInfo[loo]]
#var.ncattrs() # prints the attributues
#var.add_offset # prints the add_offset attribute
#pdb.set_trace()
TmpData = np.copy(var[SliceInfo['TimeSlice'][0]:SliceInfo['TimeSlice'][1],
SliceInfo['LatSlice'][0]:SliceInfo['LatSlice'][1],
SliceInfo['LonSlice'][0]:SliceInfo['LonSlice'][1]]) # times, lats, lons - THIS AUTOMATICALLY APPLIES SCALE AND OFFSET!!!
TheData.append(TmpData)
# # Maybe I've done something wrong but its reading it transposed
# TheData=np.transpose(TheData)
ncf.close()
# Sort out the lons and lats to slice if necessary
if ((SliceInfo['LatSlice'][1] - SliceInfo['LatSlice'][0]) != len(TheLatList)):
TheLatList = TheLatList[SliceInfo['LatSlice'][0]:SliceInfo['LatSlice'][1]]
if ((SliceInfo['LonSlice'][1] - SliceInfo['LonSlice'][0]) != len(TheLonList)):
TheLonList = TheLonList[SliceInfo['LonSlice'][0]:SliceInfo['LonSlice'][1]]
return TheData,TheLatList,TheLonList # GetGrid4
#*********************************************************************************
| 38.299517 | 135 | 0.618126 | 2,080 | 15,856 | 4.7 | 0.147596 | 0.017185 | 0.019128 | 0.015957 | 0.736804 | 0.710004 | 0.688728 | 0.668065 | 0.662541 | 0.662541 | 0 | 0.026127 | 0.227548 | 15,856 | 413 | 136 | 38.392252 | 0.772044 | 0.659876 | 0 | 0.857143 | 0 | 0 | 0.043444 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.02521 | false | 0 | 0.117647 | 0 | 0.168067 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ce9812609a6c60f1e975408c46ab122ed16f2831 | 201 | py | Python | inputs/timeElapsed.py | hongaar/ringctl | 9e2adbdf16e85852019466e42be9d88a9e63cde5 | [
"MIT"
] | null | null | null | inputs/timeElapsed.py | hongaar/ringctl | 9e2adbdf16e85852019466e42be9d88a9e63cde5 | [
"MIT"
] | null | null | null | inputs/timeElapsed.py | hongaar/ringctl | 9e2adbdf16e85852019466e42be9d88a9e63cde5 | [
"MIT"
] | null | null | null | import time
from utils.number import Number
class TimeElapsed(Number):
def __init__(self):
self.__start_ms = time.time()
def get(self):
return time.time() - self.__start_ms
| 16.75 | 44 | 0.666667 | 27 | 201 | 4.592593 | 0.518519 | 0.145161 | 0.177419 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.233831 | 201 | 11 | 45 | 18.272727 | 0.805195 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.285714 | 0.142857 | 0.857143 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
ceb4188dd707c36d133bbe1d44fddcd7ffe0ef2c | 307 | py | Python | Day16/Duplicate_Characters_in_String.py | tushartrip1010/100_days_code_py | ee74b429e98cdd8bdf8661cf987da67c9fee5a3e | [
"Apache-2.0"
] | null | null | null | Day16/Duplicate_Characters_in_String.py | tushartrip1010/100_days_code_py | ee74b429e98cdd8bdf8661cf987da67c9fee5a3e | [
"Apache-2.0"
] | null | null | null | Day16/Duplicate_Characters_in_String.py | tushartrip1010/100_days_code_py | ee74b429e98cdd8bdf8661cf987da67c9fee5a3e | [
"Apache-2.0"
] | null | null | null | def Duplicate_Charaters(Test_String):
Duplicates = []
for char in Test_String:
if Test_String.count(char) > 1 and char not in Duplicates:
Duplicates.append(char)
return Duplicates
Test_String = input("Enter a String: ")
print(*(Duplicate_Charaters(Test_String)))
| 27.909091 | 67 | 0.674267 | 38 | 307 | 5.263158 | 0.526316 | 0.25 | 0.22 | 0.28 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004255 | 0.234528 | 307 | 10 | 68 | 30.7 | 0.846809 | 0 | 0 | 0 | 0 | 0 | 0.053872 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0 | 0 | 0.25 | 0.125 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ceb805f391530b5ecf54edb5533245a407bab0a2 | 115 | py | Python | scripts/logger.py | bree7e/rosreestr2coord | 93e1c41c31ab2de1905ac4c50107d1eb00a2417b | [
"MIT"
] | 1 | 2019-07-23T15:13:39.000Z | 2019-07-23T15:13:39.000Z | scripts/logger.py | bree7e/rosreestr2coord | 93e1c41c31ab2de1905ac4c50107d1eb00a2417b | [
"MIT"
] | null | null | null | scripts/logger.py | bree7e/rosreestr2coord | 93e1c41c31ab2de1905ac4c50107d1eb00a2417b | [
"MIT"
] | null | null | null | import logging
logging.basicConfig(filename='debug.log',level=logging.DEBUG)
logger = logging.getLogger(__name__)
| 23 | 61 | 0.817391 | 14 | 115 | 6.428571 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.06087 | 115 | 4 | 62 | 28.75 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0.078261 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
cebc8b7bcb545ba7e34897259d686a647147d51f | 669 | py | Python | inference/gibbs.py | SsnL/amcmc | 32fe639267ead1bd7c5f0addfceb2dc61776e94f | [
"MIT"
] | null | null | null | inference/gibbs.py | SsnL/amcmc | 32fe639267ead1bd7c5f0addfceb2dc61776e94f | [
"MIT"
] | null | null | null | inference/gibbs.py | SsnL/amcmc | 32fe639267ead1bd7c5f0addfceb2dc61776e94f | [
"MIT"
] | null | null | null | from ..structure import *
from ..utils import *
class Gibbs(MCMC):
def __init__(self, problem, verbose_int = 100, N = 1000, T = 10000, record_start = 3000):
MCMC.__init__(self, problem, "Gibbs", verbose_int, N, T, record_start)
def particle_to_tuple(self, p):
return p
def init_particle(self):
return tuple((np.random.choice(self.problem.net[rv].values) for rv in self.problem.rvs))
def update_particle(self, particle):
d = self.tuple_to_dict(particle)
rv = self.problem.rvs[np.random.choice(len(self.problem.rvs))]
d[rv] = self.problem.net[rv].sample_blanket(d)
return self.dict_to_tuple(d)
| 33.45 | 96 | 0.665172 | 99 | 669 | 4.282828 | 0.414141 | 0.181604 | 0.099057 | 0.075472 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.030019 | 0.203288 | 669 | 19 | 97 | 35.210526 | 0.765478 | 0 | 0 | 0 | 0 | 0 | 0.007485 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.142857 | 0.142857 | 0.714286 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
cec139d86d3152cb78167104fc660d3c977db70f | 330 | py | Python | 21/21.py | PaeP3nguin/advent-of-code-2017 | fb6b42437016f905df156cb6e8f02047ca2e86ae | [
"MIT"
] | null | null | null | 21/21.py | PaeP3nguin/advent-of-code-2017 | fb6b42437016f905df156cb6e8f02047ca2e86ae | [
"MIT"
] | null | null | null | 21/21.py | PaeP3nguin/advent-of-code-2017 | fb6b42437016f905df156cb6e8f02047ca2e86ae | [
"MIT"
] | null | null | null | #!python3
def main():
with open('21.txt', 'r') as f, open('21_out.txt', 'w') as f_out:
lines = f.readlines()
# Part 1
answer = 0
print(answer)
print(answer, file=f_out)
# Part 2
print(answer)
print(answer, file=f_out)
if __name__ == '__main__':
main()
| 16.5 | 68 | 0.509091 | 45 | 330 | 3.466667 | 0.511111 | 0.282051 | 0.205128 | 0.282051 | 0.384615 | 0.384615 | 0.384615 | 0 | 0 | 0 | 0 | 0.036866 | 0.342424 | 330 | 19 | 69 | 17.368421 | 0.682028 | 0.066667 | 0 | 0.4 | 0 | 0 | 0.085246 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0 | 0 | 0 | 0.1 | 0.4 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ced6c5cc14ce5451d01bd23ad8004924b9790d1e | 1,132 | py | Python | double_dummy/hash_state.py | andCelli/efg_tools | 0de50f41e971d6ebb461ae4733843096af87e014 | [
"MIT"
] | null | null | null | double_dummy/hash_state.py | andCelli/efg_tools | 0de50f41e971d6ebb461ae4733843096af87e014 | [
"MIT"
] | null | null | null | double_dummy/hash_state.py | andCelli/efg_tools | 0de50f41e971d6ebb461ae4733843096af87e014 | [
"MIT"
] | null | null | null | class HashState:
def __init__(self, player, cards, leading, upper, lower, tricks):
self.current_player = player
self.cards = cards
self.upper_bound = upper
self.lower_bound = lower
self.leading_suite = leading
self.tricks_left = tricks
def get_current_player(self):
return self.current_player
def set_current_player(self, player):
self.current_player = player
def get_cards(self):
return self.cards
def set_cards(self, cards):
self.cards = cards
def get_upper_bound(self):
return self.upper_bound
def set_upper_bound(self, upper):
self.upper_bound = upper
def get_lower_bound(self):
return self.lower_bound
def set_lower_bound(self, lower):
self.lower_bound = lower
def get_leading_suite(self):
return self.leading_suite
def set_leading_suite(self, leading):
self.leading_suite = leading
def get_tricks_left(self):
return self.tricks_left
def set_tricks_left(self, tricks):
self.tricks_left = tricks
| 25.155556 | 69 | 0.644876 | 144 | 1,132 | 4.784722 | 0.125 | 0.05225 | 0.121916 | 0.066763 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.282686 | 1,132 | 44 | 70 | 25.727273 | 0.848522 | 0 | 0 | 0.375 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.40625 | false | 0 | 0 | 0.1875 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0c7609326b0fbbc4eff08ba0b9cb3e6cdb3c2eb9 | 970 | py | Python | workflows/helpers.py | xflows/textflows | 7fd99cebe29bcb25ea21b8bfb7dca2d0b663ea2b | [
"MIT"
] | 18 | 2015-07-29T07:14:41.000Z | 2021-05-31T16:10:49.000Z | workflows/helpers.py | xflows/textflows | 7fd99cebe29bcb25ea21b8bfb7dca2d0b663ea2b | [
"MIT"
] | null | null | null | workflows/helpers.py | xflows/textflows | 7fd99cebe29bcb25ea21b8bfb7dca2d0b663ea2b | [
"MIT"
] | 8 | 2016-02-05T10:13:40.000Z | 2020-11-10T14:36:31.000Z | import os
from collections import Iterable
def flat(lis):
for item in lis:
if isinstance(item, list):# and not isinstance(item, basestring):
for x in flat(item):
yield x
else:
yield item
def flatten(lis):
return list(flat(lis))
def ensure_dir(f):
d = os.path.dirname(f)
if not os.path.exists(d):
os.makedirs(d)
class UnpicklableObject:
def __init__(self, init_string):
self.init_string = init_string
self.imports = []
def addimport(self,import_string):
self.imports.append(import_string)
def generate(self):
for i in self.imports:
exec(i)
return eval(self.init_string)
def __unicode__(self):
return self.init_string
def __str__(self):
return self.init_string
def __repr__(self):
return self.init_string | 23.658537 | 75 | 0.562887 | 117 | 970 | 4.444444 | 0.384615 | 0.134615 | 0.161538 | 0.098077 | 0.15 | 0.103846 | 0 | 0 | 0 | 0 | 0 | 0 | 0.353608 | 970 | 41 | 76 | 23.658537 | 0.829346 | 0.038144 | 0 | 0.096774 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.290323 | false | 0 | 0.193548 | 0.129032 | 0.677419 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0c8326d2e06a8e81cf625405601a6d2a852be6b0 | 2,463 | py | Python | azext_iot/sdk/dps/models/__init__.py | SpaceKatt/azure-iot-cli-extension | b85c2065767793f3912ae474d0497f2114802a04 | [
"MIT"
] | 1 | 2019-02-06T06:52:49.000Z | 2019-02-06T06:52:49.000Z | azext_iot/dps_sdk/models/__init__.py | anoop6543/azure-iot-cli-extension | 3bd69768ff5658c9243e1212a91ff514f1f68cd9 | [
"MIT"
] | 1 | 2020-07-13T19:57:48.000Z | 2020-07-13T19:57:48.000Z | azext_iot/sdk/dps/models/__init__.py | digimaun/azure-iot-cli-extension | 3970b0441c770ccf206f7c8e4494a30992361a9f | [
"MIT"
] | null | null | null | # coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from .provisioning_service_error_details import ProvisioningServiceErrorDetails, ProvisioningServiceErrorDetailsException
from .device_capabilities import DeviceCapabilities
from .individual_enrollment_registration_state import IndividualEnrollmentRegistrationState
from .tpm_attestation import TpmAttestation
from .x509_certificate_info import X509CertificateInfo
from .x509_certificate_with_info import X509CertificateWithInfo
from .x509_certificates import X509Certificates
from .x509_ca_references import X509CAReferences
from .x509_attestation import X509Attestation
from .symmetric_key_attestation import SymmetricKeyAttestation
from .attestation_mechanism import AttestationMechanism
from .metadata import Metadata
from .twin_collection import TwinCollection
from .initial_twin_properties import InitialTwinProperties
from .initial_twin import InitialTwin
from .reprovision_policy import ReprovisionPolicy
from .custom_allocation_definition import CustomAllocationDefinition
from .individual_enrollment import IndividualEnrollment
from .device_registration_state import DeviceRegistrationState
from .enrollment_group import EnrollmentGroup
from .bulk_enrollment_operation import BulkEnrollmentOperation
from .bulk_enrollment_operation_error import BulkEnrollmentOperationError
from .bulk_enrollment_operation_result import BulkEnrollmentOperationResult
from .query_specification import QuerySpecification
__all__ = [
'ProvisioningServiceErrorDetails', 'ProvisioningServiceErrorDetailsException',
'DeviceCapabilities',
'IndividualEnrollmentRegistrationState',
'TpmAttestation',
'X509CertificateInfo',
'X509CertificateWithInfo',
'X509Certificates',
'X509CAReferences',
'X509Attestation',
'SymmetricKeyAttestation',
'AttestationMechanism',
'Metadata',
'TwinCollection',
'InitialTwinProperties',
'InitialTwin',
'ReprovisionPolicy',
'CustomAllocationDefinition',
'IndividualEnrollment',
'DeviceRegistrationState',
'EnrollmentGroup',
'BulkEnrollmentOperation',
'BulkEnrollmentOperationError',
'BulkEnrollmentOperationResult',
'QuerySpecification',
]
| 41.745763 | 121 | 0.789687 | 188 | 2,463 | 10.111702 | 0.468085 | 0.021042 | 0.028406 | 0.042609 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020833 | 0.103532 | 2,463 | 58 | 122 | 42.465517 | 0.840127 | 0.122209 | 0 | 0 | 1 | 0 | 0.243619 | 0.141067 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.48 | 0 | 0.48 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0c8e9184db55165c00e4295bab37b6b9797fc0bb | 1,739 | py | Python | Game Files/AIConnector.py | Diaphteiros/deeplearninggame | e8d4eb7901e97427cd949ea577f41b8f9ef8d4e3 | [
"MIT"
] | null | null | null | Game Files/AIConnector.py | Diaphteiros/deeplearninggame | e8d4eb7901e97427cd949ea577f41b8f9ef8d4e3 | [
"MIT"
] | null | null | null | Game Files/AIConnector.py | Diaphteiros/deeplearninggame | e8d4eb7901e97427cd949ea577f41b8f9ef8d4e3 | [
"MIT"
] | null | null | null | import DLFCN
import sys
sys.setdlopenflags(DLFCN.RTLD_NOW | DLFCN.RTLD_GLOBAL)
import lua
from utils import isNumber
# path to the main lua file
PATH_TO_LUA_MAIN = "train.lua"
# for lua interface
LG = lua.globals()
# loads the AI
LG.dofile(PATH_TO_LUA_MAIN)
# calls setParams in AIConnector.lua
# giving the dict as argument is possible, but it won't be a lua table then, which could cause trouble
# therefore a serialized version is given and reconstructed in lua
# returns the set dict (serialized in lua style) (for debugging purposes mainly)
def setParams(params):
cmd = "{"
for key, value in params.items():
if value is None:
cmd += "{}=nil, ".format(key)
elif isNumber(value):
cmd += "{}={}, ".format(key, value) # no quotes needed for numbers
else:
cmd += "{}=\"{}\", ".format(key, value) # lua table constructor ignores trailing commas, so this is fine
cmd += "}"
LG.aiconnector.setParams(lua.eval(cmd))
return cmd
# calls the getAction() method from AIConnector.lua and forwards its return value
def getAction():
return LG.aiconnector.getAction()
# sets the global SCREENSHOT_FILEPATH in lua
def setScreenshotPath(path):
LG.SCREENSHOT_FILEPATH = path
return path # for debugging
# returns wether the AI requested a new level to be loaded (boolean)
def getReload():
return LG.aiconnector.getReload()
# returns the action counter
def getActionCount():
return LG.aiconnector.getActionCount()
# returns world count
def getWorldCount():
return LG.aiconnector.getWorldCount()
# increases world count by given amount
def increaseWorldCount(amount=1):
return LG.aiconnector.increaseWorldCount(amount)
# cleanup at program end (close open files etc)
def cleanup():
LG.aiconnector.cleanup()
| 25.202899 | 107 | 0.742956 | 247 | 1,739 | 5.190283 | 0.473684 | 0.070983 | 0.074103 | 0.020281 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.000684 | 0.159287 | 1,739 | 68 | 108 | 25.573529 | 0.876197 | 0.439908 | 0 | 0 | 0 | 0 | 0.033473 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.228571 | false | 0 | 0.114286 | 0.142857 | 0.542857 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0ca23edda5e5f9b208468678c8c5ee585d47d95d | 457 | py | Python | PythonExercicios/ex029.py | Luis-Emanuel/Python | 92936dfb005b9755a53425d16c3ff54119eebe78 | [
"MIT"
] | null | null | null | PythonExercicios/ex029.py | Luis-Emanuel/Python | 92936dfb005b9755a53425d16c3ff54119eebe78 | [
"MIT"
] | null | null | null | PythonExercicios/ex029.py | Luis-Emanuel/Python | 92936dfb005b9755a53425d16c3ff54119eebe78 | [
"MIT"
] | null | null | null | #Escreva um programa que leia a velocidade de um carro. Se ele ultrapassar 80kmH, mostre uma messagem
#dizendo que ele foi mutado. A multa vai custar R$7,00 por cada Km acima do limite.
vel = float(input('Qual é a velocidade atual do carro? '))
if vel > 80:
print('MULTADO! Você excedeu o limite permitido que é de 80Km/h')
mul = (vel - 80) * 7
print(f'Você deve pagar uma multa de R${mul:.2f}')
print('Tenha um bom dia! Dirija com segurança!')
| 50.777778 | 101 | 0.706783 | 83 | 457 | 3.891566 | 0.698795 | 0.068111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035422 | 0.196937 | 457 | 8 | 102 | 57.125 | 0.844687 | 0.398249 | 0 | 0 | 0 | 0 | 0.626374 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.5 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
0cc153b2620c1e8a5d21da4d6581787a57505d53 | 2,801 | py | Python | src/ggrc_basic_permissions/migrations/versions/20150123215041_3bb32fb65d47_make_audit_role_implications_to_private_.py | Smotko/ggrc-core | b3abb58b24e7559960d71a94ba79c75539e7fe29 | [
"Apache-2.0"
] | null | null | null | src/ggrc_basic_permissions/migrations/versions/20150123215041_3bb32fb65d47_make_audit_role_implications_to_private_.py | Smotko/ggrc-core | b3abb58b24e7559960d71a94ba79c75539e7fe29 | [
"Apache-2.0"
] | 12 | 2015-01-08T14:50:19.000Z | 2017-11-29T19:37:53.000Z | src/ggrc_basic_permissions/migrations/versions/20150123215041_3bb32fb65d47_make_audit_role_implications_to_private_.py | mikecb/ggrc-core | 1cda560cb0920021416e07740c6cca1acba56268 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 2015-01-08T13:25:09.000Z | 2015-01-08T13:25:09.000Z | # Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file>
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
# Created By: anze@reciprocitylabs.com
# Maintained By: anze@reciprocitylabs.com
"""Make audit role implications to private programs mapped via responses
Revision ID: 3bb32fb65d47
Revises: 51e046bb002
Create Date: 2015-01-23 21:50:41.635827
"""
# revision identifiers, used by Alembic.
revision = '3bb32fb65d47'
down_revision = '51e046bb002'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.execute("""
INSERT INTO context_implications (
source_context_id, source_context_scope, context_id, context_scope
)
SELECT DISTINCT rs.context_id as source_context_id,
'Audit' AS source_context_scope,
p.context_id,
'Program' AS context_scope
FROM relationships r
INNER JOIN responses rs
ON rs.id = r.source_id
AND r.source_type IN ('Response', 'DocumentationResponse',
'InterviewResponse')
INNER JOIN programs p
ON p.id = r.destination_id
AND r.destination_type = 'Program'
WHERE p.private = 1
AND (SELECT count(*) from context_implications
WHERE source_context_id = rs.context_id
AND context_id = p.context_id) < 1
""")
op.execute("""
INSERT INTO context_implications (
source_context_id, source_context_scope, context_id, context_scope
)
SELECT DISTINCT sp.context_id as source_context_id,
'Program' AS source_context_scope,
p.context_id,
'Program' AS context_scope
FROM relationships r
INNER JOIN responses rs
ON rs.id = r.source_id
AND r.source_type IN ('Response', 'DocumentationResponse',
'InterviewResponse')
INNER JOIN requests rqs
ON rqs.id = rs.request_id
INNER JOIN audits a
ON a.id = rqs.audit_id
INNER JOIN programs sp
ON sp.id = a.program_id
INNER JOIN programs p
ON p.id = r.destination_id
AND r.destination_type = 'Program'
WHERE p.private = 1
AND (SELECT count(*) from context_implications
WHERE source_context_id = sp.context_id
AND context_id = p.context_id) < 1
""")
def downgrade():
op.execute("""
DELETE context_implications
FROM context_implications ci
INNER JOIN audits a ON a.context_id = ci.source_context_id
INNER JOIN programs p ON p.context_id = ci.context_id
WHERE a.program_id != p.id
""")
op.execute("""
DELETE context_implications
FROM context_implications ci
INNER JOIN programs sp ON sp.context_id = ci.source_context_id
INNER JOIN programs p ON p.context_id = ci.context_id
""")
| 31.47191 | 78 | 0.671546 | 374 | 2,801 | 4.850267 | 0.254011 | 0.128997 | 0.066152 | 0.039691 | 0.702867 | 0.702867 | 0.637817 | 0.636714 | 0.636714 | 0.601433 | 0 | 0.028667 | 0.252767 | 2,801 | 88 | 79 | 31.829545 | 0.838032 | 0.152803 | 0 | 0.656716 | 0 | 0 | 0.910631 | 0.055909 | 0 | 0 | 0 | 0 | 0 | 1 | 0.029851 | false | 0 | 0.029851 | 0 | 0.059701 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0ccafa8c90ef8f2571c7fafe47116df0f3e5c57a | 141 | py | Python | kuku/tests/test_dump.py | xarg/kuku | bbd906347929b768753d88ec26cf579ec17f2e0a | [
"Apache-2.0"
] | 42 | 2018-09-27T23:11:27.000Z | 2022-02-27T19:23:16.000Z | kuku/tests/test_dump.py | xarg/kuku | bbd906347929b768753d88ec26cf579ec17f2e0a | [
"Apache-2.0"
] | 3 | 2018-10-12T00:56:27.000Z | 2020-01-08T00:40:58.000Z | kuku/tests/test_dump.py | xarg/kuku | bbd906347929b768753d88ec26cf579ec17f2e0a | [
"Apache-2.0"
] | 8 | 2018-09-27T23:44:22.000Z | 2021-04-20T04:06:57.000Z | from kuku.dump import dump
def test_dump_with_none_object():
output = dump({"dir1": [None, ]})
assert output == "# Source: dir1\n"
| 20.142857 | 39 | 0.652482 | 20 | 141 | 4.4 | 0.7 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017544 | 0.191489 | 141 | 6 | 40 | 23.5 | 0.754386 | 0 | 0 | 0 | 0 | 0 | 0.141844 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0.25 | false | 0 | 0.25 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0b53d668bec9092e44fcd4261979427d86719a2c | 86 | py | Python | ExtremeRainfall/weather.py | Shruti-codes/Shruti-codes.github.io | 3e14eb2fd9ddf2347a6a16e41626ba8aa9b47609 | [
"MIT"
] | 2 | 2022-01-30T13:58:30.000Z | 2022-03-28T06:26:46.000Z | ExtremeRainfall/weather.py | Shruti-codes/Shruti-codes.github.io | 3e14eb2fd9ddf2347a6a16e41626ba8aa9b47609 | [
"MIT"
] | null | null | null | ExtremeRainfall/weather.py | Shruti-codes/Shruti-codes.github.io | 3e14eb2fd9ddf2347a6a16e41626ba8aa9b47609 | [
"MIT"
] | null | null | null | import pandas as pd
cities = pd.read_csv("res.csv")
cities.to_html("comparison.html") | 21.5 | 33 | 0.755814 | 15 | 86 | 4.2 | 0.733333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.093023 | 86 | 4 | 33 | 21.5 | 0.807692 | 0 | 0 | 0 | 0 | 0 | 0.252874 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
0b60de57425211355f096749bb79260ad0e69978 | 701 | py | Python | rpiRobot/src/cortex/domain/objective/item.py | olgam4/design3 | 6e05d123a24deae7dda646df535844a158ef5cc0 | [
"WTFPL"
] | null | null | null | rpiRobot/src/cortex/domain/objective/item.py | olgam4/design3 | 6e05d123a24deae7dda646df535844a158ef5cc0 | [
"WTFPL"
] | null | null | null | rpiRobot/src/cortex/domain/objective/item.py | olgam4/design3 | 6e05d123a24deae7dda646df535844a158ef5cc0 | [
"WTFPL"
] | null | null | null | from coordinate.cameraCoordinate import CameraCoordinate
from cortex.domain.objective.color import Color
from cortex.domain.objective.shape import Shape
class Item:
def __init__(self, color: Color, shape: Shape, position: CameraCoordinate) -> None:
self._color = color
self._shape = shape
self._position = position
@property
def color(self) -> Color:
return self._color
@property
def shape(self) -> Shape:
return self._shape
@property
def position(self) -> CameraCoordinate:
return self._position
def __repr__(self) -> str:
return "{}({},{},{})".format(Item.__name__, self.color, self.shape, self.position)
| 26.961538 | 90 | 0.669044 | 78 | 701 | 5.782051 | 0.282051 | 0.099778 | 0.070953 | 0.110865 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.223966 | 701 | 25 | 91 | 28.04 | 0.829044 | 0 | 0 | 0.157895 | 0 | 0 | 0.017118 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.263158 | false | 0 | 0.157895 | 0.210526 | 0.684211 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0b8a665877454c954c8e1e91fb5b31d5af0194be | 1,598 | py | Python | test/test_mdupdates_api.py | lockss/lockss-metadata-extractor-python | ac23fc499bc3d392a3564815360d52acae7fc383 | [
"BSD-3-Clause"
] | null | null | null | test/test_mdupdates_api.py | lockss/lockss-metadata-extractor-python | ac23fc499bc3d392a3564815360d52acae7fc383 | [
"BSD-3-Clause"
] | null | null | null | test/test_mdupdates_api.py | lockss/lockss-metadata-extractor-python | ac23fc499bc3d392a3564815360d52acae7fc383 | [
"BSD-3-Clause"
] | null | null | null | # coding: utf-8
"""
LOCKSS Metadata Extraction Service REST API
API of the LOCKSS Metadata Extraction REST Service # noqa: E501
OpenAPI spec version: 1.0.0
Contact: lockss-support@lockss.org
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import unittest
import lockss_metadata_extractor
from lockss_metadata_extractor.api.mdupdates_api import MdupdatesApi # noqa: E501
from lockss_metadata_extractor.rest import ApiException
class TestMdupdatesApi(unittest.TestCase):
"""MdupdatesApi unit test stubs"""
def setUp(self):
self.api = lockss_metadata_extractor.api.mdupdates_api.MdupdatesApi() # noqa: E501
def tearDown(self):
pass
def test_delete_mdupdates(self):
"""Test case for delete_mdupdates
Delete all of the currently queued and active jobs # noqa: E501
"""
pass
def test_delete_mdupdates_jobid(self):
"""Test case for delete_mdupdates_jobid
Delete a job # noqa: E501
"""
pass
def test_get_mdupdates(self):
"""Test case for get_mdupdates
Get a list of currently active jobs # noqa: E501
"""
pass
def test_get_mdupdates_jobid(self):
"""Test case for get_mdupdates_jobid
Get a job # noqa: E501
"""
pass
def test_post_mdupdates(self):
"""Test case for post_mdupdates
Perform an AU metadata update operation # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()
| 22.828571 | 91 | 0.662703 | 197 | 1,598 | 5.162437 | 0.365482 | 0.06293 | 0.054081 | 0.073746 | 0.386431 | 0.331367 | 0.12586 | 0 | 0 | 0 | 0 | 0.023729 | 0.261577 | 1,598 | 69 | 92 | 23.15942 | 0.838136 | 0.430538 | 0 | 0.272727 | 0 | 0 | 0.010458 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.318182 | false | 0.272727 | 0.227273 | 0 | 0.590909 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
0b9fa9ecd36974de6d0fc33078bb7c9da5c44a7f | 4,231 | py | Python | my_solutions/google_pythonclass_lists.py | andrmich/google-python-class | 48383352d7649caf0417579545b354d7d6fe15cc | [
"Apache-2.0"
] | null | null | null | my_solutions/google_pythonclass_lists.py | andrmich/google-python-class | 48383352d7649caf0417579545b354d7d6fe15cc | [
"Apache-2.0"
] | null | null | null | my_solutions/google_pythonclass_lists.py | andrmich/google-python-class | 48383352d7649caf0417579545b354d7d6fe15cc | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/python -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
# Basic list exercises
# Fill in the code for the functions below. main() is already set up
# to call the functions with a few different inputs,
# printing 'OK' when each function is correct.
# The starter code for each function includes a 'return'
# which is just a placeholder for your code.
# It's ok if you do not complete all the functions, and there
# are some additional functions to try in list2.py.
# A. match_ends
# Given a list of strings, return the count of the number of
# strings where the string length is 2 or more and the first
# and last chars of the string are the same.
# Note: python does not have a ++ operator, but += works.
def match_ends(words):
return len([word for word in words if len(word)>=2 and word[0]==word[-1]])
#print(match_ends(['aaa', 'be', 'abc', 'hello']))
# test(match_ends(['aba', 'xyz', 'aa', 'x', 'bbb']), 3)
# test(match_ends(['', 'x', 'xy', 'xyx', 'xx']), 2)
# test(match_ends(['aaa', 'be', 'abc', 'hello']), 1)
# B. front_x
# Given a list of strings, return a list with the strings
# in sorted order, except group all the strings that begin with 'x' first.
# e.g. ['mix', 'xyz', 'apple', 'xanadu', 'aardvark'] yields
# ['xanadu', 'xyz', 'aardvark', 'apple', 'mix']
# Hint: this can be done by making 2 lists and sorting each of them
# before combining them.
def front_x(words):
strings_with_x = sorted([word for word in words if word[0] == 'x'])
other_strings = sorted([word for word in words if word[0]!= 'x'])
return strings_with_x + other_strings
#print(front_x(['mix', 'xyz', 'apple', 'xanadu', 'aardvark']))
# test(front_x(['bbb', 'ccc', 'axx', 'xzz', 'xaa']),
# ['xaa', 'xzz', 'axx', 'bbb', 'ccc'])
# test(front_x(['ccc', 'bbb', 'aaa', 'xcc', 'xaa']),
# ['xaa', 'xcc', 'aaa', 'bbb', 'ccc'])
# test(front_x(['mix', 'xyz', 'apple', 'xanadu', 'aardvark']),
# ['xanadu', 'xyz', 'aardvark', 'apple', 'mix'])
# C. sort_last
# Given a list of non-empty tuples, return a list sorted in increasing
# order by the last element in each tuple.
# e.g. [(1, 7), (1, 3), (3, 4, 5), (2, 2)] yields
# [(2, 2), (1, 3), (3, 4, 5), (1, 7)]
# Hint: use a custom key= function to extract the last element form each tuple.
def sort_last(tuples):
def last_element(tuples):
return tuples[-1]
return sorted(tuples, key=last_element)
#print(sort_last([(1, 7), (1, 3), (3, 4, 5), (2, 2)]))
# test(sort_last([(1, 3), (3, 2), (2, 1)]),
# [(2, 1), (3, 2), (1, 3)])
# test(sort_last([(2, 3), (1, 2), (3, 1)]),
# [(3, 1), (1, 2), (2, 3)])
# test(sort_last([(1, 7), (1, 3), (3, 4, 5), (2, 2)]),
# [(2, 2), (1, 3), (3, 4, 5), (1, 7)])
#list2
# Additional basic list exercises
# D. Given a list of numbers, return a list where
# all adjacent == elements have been reduced to a single element,
# so [1, 2, 2, 3] returns [1, 2, 3]. You may create a new list or
# modify the passed in list.
def remove_adjacent(nums):
result = []
if len(nums) > 0:
for number in nums:
if len(result) == 0:
result.append(number)
if number != result[-1]:
result.append(number)
return result
print(remove_adjacent([2, 2, 3, 3, 3, 4, 3]))
# test(remove_adjacent([1, 2, 2, 3]), [1, 2, 3])
# test(remove_adjacent([2, 2, 3, 3, 3]), [2, 3])
# test(remove_adjacent([]), [])
# E. Given two lists sorted in increasing order, create and return a merged
# list of all the elements in sorted order. You may modify the passed in lists.
# Ideally, the solution should work in "linear" time, making a single
# pass of both lists.
def linear_merge(list1, list2):
return sorted((list1+list2))
print(linear_merge(['aa', 'aa'], ['aa', 'bb', 'bb']))
# test(linear_merge(['aa', 'xx', 'zz'], ['bb', 'cc']),
# ['aa', 'bb', 'cc', 'xx', 'zz'])
# test(linear_merge(['aa', 'xx'], ['bb', 'cc', 'zz']),
# ['aa', 'bb', 'cc', 'xx', 'zz'])
# test(linear_merge(['aa', 'aa'], ['aa', 'bb', 'bb']),
# ['aa', 'aa', 'aa', 'bb', 'bb'])
| 38.463636 | 79 | 0.598204 | 690 | 4,231 | 3.615942 | 0.285507 | 0.009619 | 0.007214 | 0.008016 | 0.235671 | 0.169138 | 0.123447 | 0.071743 | 0.071743 | 0.039279 | 0 | 0.036982 | 0.201134 | 4,231 | 109 | 80 | 38.816514 | 0.701183 | 0.75845 | 0 | 0.086957 | 0 | 0 | 0.012592 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.26087 | false | 0 | 0 | 0.130435 | 0.521739 | 0.086957 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
0ba6460bef51f7ed3e087a9178c58eecc3c8d65a | 816 | py | Python | website/views/__init__.py | czhu1217/cmimc-online | 5ef49ceec0bb86d8ae120a6ecfd723532e277821 | [
"MIT"
] | null | null | null | website/views/__init__.py | czhu1217/cmimc-online | 5ef49ceec0bb86d8ae120a6ecfd723532e277821 | [
"MIT"
] | null | null | null | website/views/__init__.py | czhu1217/cmimc-online | 5ef49ceec0bb86d8ae120a6ecfd723532e277821 | [
"MIT"
] | null | null | null | from .general_info import home, math_info, math_sample_problems, math_schedule, math_mini_events, prog_info, prog_sample_problems, prog_schedule, prog_mini_events, reg_info, faq, resources, updates, math_rules
from .team import new_team, join_team, team_info, coach_teams
from .contest import contest_list
from .problem import view_problem
from .submit import submit, resubmit
from .exam import all_problems, miniround_scores, match_results
from .submission import all_submissions, view_submission, admin_all_submissions
from .downloads import match_replay, ai_starter_file, ai_visualizer, mailinglist, download_subs
from .signup import signup
from .leaderboard import leaderboard, problem_leaderboard, contest_leaderboard
from .results import sweepstakes, indiv_sweepstakes, exam_results
from .upload import upload
| 62.769231 | 209 | 0.855392 | 114 | 816 | 5.798246 | 0.447368 | 0.04236 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.094363 | 816 | 12 | 210 | 68 | 0.894452 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
0ba7783408a498e4517964546238a2793d58d91a | 493 | py | Python | tests/test_unittest/test_basic.py | python-marcus-mariano/Tutorial-unittest-vs-pytest | 0428ab1dc253121e8ba641b071918e4118e00bc5 | [
"MIT"
] | null | null | null | tests/test_unittest/test_basic.py | python-marcus-mariano/Tutorial-unittest-vs-pytest | 0428ab1dc253121e8ba641b071918e4118e00bc5 | [
"MIT"
] | null | null | null | tests/test_unittest/test_basic.py | python-marcus-mariano/Tutorial-unittest-vs-pytest | 0428ab1dc253121e8ba641b071918e4118e00bc5 | [
"MIT"
] | null | null | null | """
Pytest versus Unittest
Unitest versus Pytest em Português
Homepage and documentation:
https://github.com/python-marcus-mariano/Tutorial-unittest-vs-pytest
Copyright (c) 2019, Marcus Mariano.
License: MIT (see LICENSE for details)
"""
from unittest.case import TestCase
class BasicAssertionTestCase(TestCase):
"""Tem que começar com orientação."""
def test_basic_assertion(self):
"""Não respeita a PEP 8 - dois níveis de alinhamento."""
self.assertTrue(True)
| 22.409091 | 68 | 0.736308 | 62 | 493 | 5.822581 | 0.822581 | 0.072022 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012107 | 0.162272 | 493 | 21 | 69 | 23.47619 | 0.861985 | 0.640974 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.75 | 1 | 0.25 | false | 0 | 0.25 | 0 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
0bae59dfdf933d64e8515f922b223a56deae25fb | 739 | py | Python | backend/stream/apis/twitter.py | ucinlp/covid19-backend | 17a0846ff44dc3215d3e330e2e3f67d88672c770 | [
"Apache-2.0"
] | 6 | 2021-04-17T05:46:42.000Z | 2022-01-03T23:47:48.000Z | backend/stream/apis/twitter.py | ucinlp/covid19-backend | 17a0846ff44dc3215d3e330e2e3f67d88672c770 | [
"Apache-2.0"
] | 20 | 2020-04-09T16:03:35.000Z | 2022-01-25T01:34:48.000Z | backend/stream/apis/twitter.py | ucinlp/covid19-backend | 17a0846ff44dc3215d3e330e2e3f67d88672c770 | [
"Apache-2.0"
] | null | null | null | import requests
import os
from backend.stream.apis.base import ApiClient
class TwitterClient(ApiClient):
ROOT_URL = 'https://api.twitter.com/1.1/'
def __init__(self):
super().__init__('Twitter')
self.CONSUMER_KEY = os.environ.get('', None)
self.CONSUMER_SECRET = os.environ.get('', None)
self.ACCESS_TOKEN = os.environ.get('', None)
self.ACCESS_TOKEN_SECRET = os.environ.get('', None)
def fetch(self, query, endpoint='everything', country=None):
params = {'q': query}
response = requests.get(url=self.ROOT_URL + endpoint, params=params)
return response.json()
def fetch_selected(self):
pass
def push(self, bot_text, **kwargs):
pass
| 27.37037 | 76 | 0.641407 | 93 | 739 | 4.913978 | 0.494624 | 0.078775 | 0.105033 | 0.140044 | 0.2407 | 0.135667 | 0.135667 | 0 | 0 | 0 | 0 | 0.003478 | 0.221922 | 739 | 26 | 77 | 28.423077 | 0.791304 | 0 | 0 | 0.105263 | 0 | 0 | 0.062246 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.210526 | false | 0.105263 | 0.157895 | 0 | 0.526316 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
0bbf852e156523dfe36e314f60621dbd8fbd2388 | 973 | py | Python | setup.py | natefduncan/landdox | 58908554034577cc20c6f89ee6056da90cbfbd4e | [
"MIT"
] | 1 | 2019-12-13T16:19:56.000Z | 2019-12-13T16:19:56.000Z | setup.py | natefduncan/landdox | 58908554034577cc20c6f89ee6056da90cbfbd4e | [
"MIT"
] | null | null | null | setup.py | natefduncan/landdox | 58908554034577cc20c6f89ee6056da90cbfbd4e | [
"MIT"
] | null | null | null | from distutils.core import setup
setup(
name = 'landdox',
packages = ['landdox'],
version = '1.2', #
description = 'Simple wrapper around LandDox API',
author = 'Nathan Duncan',
author_email = 'nduncan@fifthpartners.com',
url = 'https://github.com/natefduncan/landdox',
download_url = 'https://github.com/natefduncan/landdox/archive/1.2.tar.gz',
keywords = ['landdox', 'oil'],
install_requires=['requests', 'pandas'],
classifiers = [
'Development Status :: 3 - Alpha', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable"
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
],
)
| 36.037037 | 110 | 0.615622 | 104 | 973 | 5.730769 | 0.634615 | 0.159396 | 0.209732 | 0.218121 | 0.11745 | 0.11745 | 0 | 0 | 0 | 0 | 0 | 0.022546 | 0.225077 | 973 | 26 | 111 | 37.423077 | 0.767905 | 0.064748 | 0 | 0 | 0 | 0 | 0.590708 | 0.027655 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.041667 | 0 | 0.041667 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
e7ebce4e211d3919af4dd402d2cf20958bdba681 | 784 | py | Python | tests/test_an.py | MapleCCC/inflect | 98e19e3eb3ad28f9fa882baaad01674c44b59952 | [
"MIT"
] | 174 | 2020-11-16T09:17:38.000Z | 2022-03-16T18:11:50.000Z | tests/test_an.py | MapleCCC/inflect | 98e19e3eb3ad28f9fa882baaad01674c44b59952 | [
"MIT"
] | 32 | 2020-11-15T16:13:52.000Z | 2022-03-23T21:47:53.000Z | tests/test_an.py | MapleCCC/inflect | 98e19e3eb3ad28f9fa882baaad01674c44b59952 | [
"MIT"
] | 23 | 2020-11-16T18:03:36.000Z | 2022-03-24T00:56:49.000Z | import inflect
def test_an():
p = inflect.engine()
assert p.an("cat") == "a cat"
assert p.an("ant") == "an ant"
assert p.an("a") == "an a"
assert p.an("b") == "a b"
assert p.an("honest cat") == "an honest cat"
assert p.an("dishonest cat") == "a dishonest cat"
assert p.an("Honolulu sunset") == "a Honolulu sunset"
assert p.an("mpeg") == "an mpeg"
assert p.an("onetime holiday") == "a onetime holiday"
assert p.an("Ugandan person") == "a Ugandan person"
assert p.an("Ukranian person") == "a Ukranian person"
assert p.an("Unabomber") == "a Unabomber"
assert p.an("unanimous decision") == "a unanimous decision"
assert p.an("US farmer") == "a US farmer"
assert p.an("wild PIKACHU appeared") == "a wild PIKACHU appeared"
| 35.636364 | 69 | 0.603316 | 118 | 784 | 4 | 0.254237 | 0.222458 | 0.286017 | 0.076271 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.215561 | 784 | 21 | 70 | 37.333333 | 0.76748 | 0 | 0 | 0 | 0 | 0 | 0.428571 | 0 | 0 | 0 | 0 | 0 | 0.833333 | 1 | 0.055556 | false | 0 | 0.055556 | 0 | 0.111111 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f002cc2ecccbe264540b8ae3cc5a3afc2c3fbc52 | 655 | py | Python | BricksO/bricks/__init__.py | Jhonan01/Brick | 09d62d8cde3a5503ad8b84eaea54edbd91445479 | [
"Apache-2.0"
] | null | null | null | BricksO/bricks/__init__.py | Jhonan01/Brick | 09d62d8cde3a5503ad8b84eaea54edbd91445479 | [
"Apache-2.0"
] | null | null | null | BricksO/bricks/__init__.py | Jhonan01/Brick | 09d62d8cde3a5503ad8b84eaea54edbd91445479 | [
"Apache-2.0"
] | null | null | null | from flask import Flask
from bricks.config import Config
from peewee import *
db = SqliteDatabase('dados.db')
def create_app(config_class=Config):
app = Flask(__name__)
app.config.from_object(config_class)
from bricks.lance import lance_bp
app.register_blueprint(lance_bp)
from bricks.login import login_bp
app.register_blueprint(login_bp)
from bricks.cadastro_usuario import cadastroUsuario_bp
app.register_blueprint(cadastroUsuario_bp)
from bricks.index import index_bp
app.register_blueprint(index_bp)
from bricks.incluir_item import incluirItem_bp
app.register_blueprint(incluirItem_bp)
return app
| 16.794872 | 56 | 0.78626 | 90 | 655 | 5.444444 | 0.311111 | 0.122449 | 0.132653 | 0.22449 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.154198 | 655 | 38 | 57 | 17.236842 | 0.884477 | 0 | 0 | 0 | 0 | 0 | 0.012289 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.055556 | false | 0 | 0.444444 | 0 | 0.555556 | 0.277778 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
f01a8d49690691d145c4616554a2cee86ae9e90c | 224 | py | Python | primitives_ubc/clfyCCFS/__init__.py | tonyjo/ubc_primitives | bc94a403f176fe28db2a9ac9d1a48cb9db021f90 | [
"Apache-2.0"
] | null | null | null | primitives_ubc/clfyCCFS/__init__.py | tonyjo/ubc_primitives | bc94a403f176fe28db2a9ac9d1a48cb9db021f90 | [
"Apache-2.0"
] | 4 | 2020-07-19T00:45:29.000Z | 2020-12-10T18:25:41.000Z | primitives_ubc/clfyCCFS/__init__.py | tonyjo/ubc_primitives | bc94a403f176fe28db2a9ac9d1a48cb9db021f90 | [
"Apache-2.0"
] | 1 | 2021-04-30T18:13:49.000Z | 2021-04-30T18:13:49.000Z | from .ccfsClfy import CanonicalCorrelationForestsClassifierPrimitive
__all__ = ['CanonicalCorrelationForestsClassifierPrimitive']
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__) # type: ignore
| 28 | 68 | 0.848214 | 18 | 224 | 9.555556 | 0.611111 | 0.116279 | 0.162791 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.098214 | 224 | 7 | 69 | 32 | 0.851485 | 0.053571 | 0 | 0 | 0 | 0 | 0.219048 | 0.219048 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
f03db48e6fda9d28f091f7c2636f2b9c5cd546c2 | 592 | py | Python | examples/zdaemon/zdaemon_simple.py | Jumpscale/jumpscale_examples7 | 7d7be2401489a0c5465950c66bbdbb266fe57fe7 | [
"Apache-2.0"
] | 1 | 2015-10-26T10:38:37.000Z | 2015-10-26T10:38:37.000Z | examples/zdaemon/zdaemon_simple.py | Jumpscale/jumpscale6_core | 0502ddc1abab3c37ed982c142d21ea3955d471d3 | [
"BSD-2-Clause"
] | null | null | null | examples/zdaemon/zdaemon_simple.py | Jumpscale/jumpscale6_core | 0502ddc1abab3c37ed982c142d21ea3955d471d3 | [
"BSD-2-Clause"
] | null | null | null |
from JumpScale import j
import JumpScale.grid.zdaemon
j.application.start("zdaemon")
j.logger.consoleloglevel = 6
zd = j.core.zdaemon.getZDaemon(port=3333, nrCmdGreenlets=50)
class MyCommands():
def __init__(self, daemon):
self.daemon = daemon
def authenticate(self, user, login, **args):
return True # will authenticall all (is std)
def pingcmd(self, **args):
return "pong"
def echo(self, msg="", **args):
return msg
zd.addCMDsInterface(MyCommands,"acategory") # pass as class not as object !!!
zd.start()
j.application.stop()
| 18.5 | 78 | 0.668919 | 75 | 592 | 5.226667 | 0.613333 | 0.076531 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014862 | 0.204392 | 592 | 31 | 79 | 19.096774 | 0.81741 | 0.10473 | 0 | 0 | 0 | 0 | 0.038023 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.235294 | false | 0 | 0.117647 | 0.176471 | 0.588235 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
f0580c5d303d915d9514204efa7bc624faad2a4f | 732 | py | Python | setup.py | dsteinkopf/docker-push-latest-if-changed | bd2c1b0e2f7e3d18df0c298e92789ce35fe30321 | [
"MIT"
] | 23 | 2017-10-26T21:04:31.000Z | 2022-02-08T00:44:51.000Z | setup.py | dsteinkopf/docker-push-latest-if-changed | bd2c1b0e2f7e3d18df0c298e92789ce35fe30321 | [
"MIT"
] | 4 | 2021-09-30T00:53:26.000Z | 2022-02-03T01:16:54.000Z | setup.py | dsteinkopf/docker-push-latest-if-changed | bd2c1b0e2f7e3d18df0c298e92789ce35fe30321 | [
"MIT"
] | 10 | 2017-10-26T20:56:28.000Z | 2022-02-02T23:17:49.000Z | from setuptools import setup
setup(
name='docker-push-latest-if-changed',
description='Only push newly tagged docker images if the images changes.',
url='https://github.com/Yelp/docker-push-latest-if-changed',
version='0.0.0',
author='Anthony Sottile',
author_email='asottile@umich.edu',
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
],
py_modules=['docker_push_latest_if_changed'],
entry_points={'console_scripts': [
'docker-push-latest-if-changed = docker_push_latest_if_changed:main',
]},
)
| 34.857143 | 78 | 0.662568 | 86 | 732 | 5.5 | 0.581395 | 0.105708 | 0.169133 | 0.190275 | 0.264271 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010187 | 0.195355 | 732 | 20 | 79 | 36.6 | 0.792869 | 0 | 0 | 0 | 0 | 0 | 0.625683 | 0.165301 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.052632 | 0 | 0.052632 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f065d6fd4333e61d5da3e0f2f26ac5f4da66ae6c | 2,031 | py | Python | coursedashboards/models/term.py | uw-it-aca/course-dashboards | 0f195f7233fc8e24e9ca0d2624ca288869e133ba | [
"Apache-2.0"
] | 1 | 2018-04-05T19:00:27.000Z | 2018-04-05T19:00:27.000Z | coursedashboards/models/term.py | uw-it-aca/course-dashboards | 0f195f7233fc8e24e9ca0d2624ca288869e133ba | [
"Apache-2.0"
] | 188 | 2017-08-31T23:38:23.000Z | 2022-03-29T18:06:00.000Z | coursedashboards/models/term.py | uw-it-aca/course-dashboards | 0f195f7233fc8e24e9ca0d2624ca288869e133ba | [
"Apache-2.0"
] | null | null | null | from django.utils import timezone
from django.db import models
class Term(models.Model):
SPRING = 'spring'
SUMMER = 'summer'
AUTUMN = 'autumn'
WINTER = 'winter'
QUARTERNAME_CHOICES = (
(WINTER, 'Winter'),
(SPRING, 'Spring'),
(SUMMER, 'Summer'),
(AUTUMN, 'Autumn'),
)
quarter = models.CharField(max_length=6,
choices=QUARTERNAME_CHOICES)
year = models.PositiveSmallIntegerField()
last_queried = models.DateTimeField(null=True, blank=True)
term_key = models.PositiveSmallIntegerField(db_index=True, default=0)
def __str__(self):
return "{}-{}".format(self.year, self.quarter)
def get_term_key(self):
return self.year * 10 + self._quarter_to_int(self.quarter)
def save(self, *args, **kwargs):
if self.term_key is 0:
self.term_key = self.get_term_key()
super(Term, self).save(*args, **kwargs)
def __hash__(self):
return super().__hash__()
def __eq__(self, other):
return (other is not None and
type(self) == type(other) and
self.int_key() == other.int_key())
def __ne__(self, other):
return not self.__eq__(other)
def __lt__(self, other):
return (type(self) == type(other) and
self.int_key() < other.int_key())
def __le__(self, other):
return self.__lt__(other) or self.__eq__(other)
def __gt__(self, other):
return (type(self) == type(other) and
self.int_key() > other.int_key())
def __ge__(self, other):
return self.__gt__(other) or self.__eq__(other)
@staticmethod
def _quarter_to_int(quarter):
if quarter.lower() == Term.WINTER:
return 1
if quarter.lower() == Term.SPRING:
return 2
if quarter.lower() == Term.SUMMER:
return 3
return 4
def int_key(self):
return int(self.year) * 10 + self._quarter_to_int(self.quarter)
| 27.445946 | 73 | 0.589857 | 245 | 2,031 | 4.546939 | 0.273469 | 0.037702 | 0.08079 | 0.045781 | 0.308797 | 0.276481 | 0.211849 | 0.211849 | 0.211849 | 0.145422 | 0 | 0.007591 | 0.286558 | 2,031 | 73 | 74 | 27.821918 | 0.761215 | 0 | 0 | 0.036364 | 0 | 0 | 0.026096 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.218182 | false | 0 | 0.036364 | 0.181818 | 0.690909 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
f067903015e03b9e0ac86531f3cf4433a6406861 | 397 | py | Python | sevenbridges/models/compound/limits/rate.py | sbg/sevenbridges-python | b3e14016066563470d978c9b13e1a236a41abea8 | [
"Apache-2.0"
] | 46 | 2016-04-27T12:51:17.000Z | 2021-11-24T23:43:12.000Z | sevenbridges/models/compound/limits/rate.py | sbg/sevenbridges-python | b3e14016066563470d978c9b13e1a236a41abea8 | [
"Apache-2.0"
] | 111 | 2016-05-25T15:44:31.000Z | 2022-02-05T20:45:37.000Z | sevenbridges/models/compound/limits/rate.py | sbg/sevenbridges-python | b3e14016066563470d978c9b13e1a236a41abea8 | [
"Apache-2.0"
] | 37 | 2016-04-27T12:10:43.000Z | 2021-03-18T11:22:28.000Z | from sevenbridges.meta.fields import IntegerField, DateTimeField
from sevenbridges.meta.resource import Resource
class Rate(Resource):
"""
Rate resource.
"""
limit = IntegerField(read_only=True)
remaining = IntegerField(read_only=True)
reset = DateTimeField(read_only=True)
def __str__(self):
return f'<Rate: limit={self.limit}, remaining={self.remaining}>'
| 26.466667 | 72 | 0.715365 | 45 | 397 | 6.155556 | 0.466667 | 0.086643 | 0.129964 | 0.173285 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.173804 | 397 | 14 | 73 | 28.357143 | 0.844512 | 0.035264 | 0 | 0 | 0 | 0 | 0.147139 | 0.073569 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.25 | 0.125 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
f06ee03c2ec9173fc586b9e108aee338d6d6c049 | 244 | py | Python | src/services/apps.py | jhernandez18p/mobyapp | 4add7bd3b3f1e933bbb6941674bf84f4c4462685 | [
"MIT"
] | null | null | null | src/services/apps.py | jhernandez18p/mobyapp | 4add7bd3b3f1e933bbb6941674bf84f4c4462685 | [
"MIT"
] | 7 | 2020-06-05T17:31:06.000Z | 2022-03-11T23:16:34.000Z | src/services/apps.py | jhernandez18p/mobyapp | 4add7bd3b3f1e933bbb6941674bf84f4c4462685 | [
"MIT"
] | null | null | null | from django.apps import AppConfig
from django.db.models.signals import post_migrate
from django.utils.translation import gettext_lazy as _
class ServicesConfig(AppConfig):
name = 'src.services'
verbose_name = _("Modulo de Servicios") | 27.111111 | 54 | 0.786885 | 32 | 244 | 5.84375 | 0.75 | 0.160428 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.139344 | 244 | 9 | 55 | 27.111111 | 0.890476 | 0 | 0 | 0 | 0 | 0 | 0.126531 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
b2bf676dabcbc2046cd67307c44e2f4238865d58 | 191 | py | Python | ctfcli/templates/web/default/{{cookiecutter.name}}/src/config.py | pedrosa-t/ctfcli | 0ceb70524da8e52917b802ef17d302006f8dede6 | [
"Apache-2.0"
] | 82 | 2020-04-02T16:54:41.000Z | 2022-03-26T03:52:01.000Z | ctfcli/templates/web/default/{{cookiecutter.name}}/src/config.py | pedrosa-t/ctfcli | 0ceb70524da8e52917b802ef17d302006f8dede6 | [
"Apache-2.0"
] | 46 | 2020-04-05T22:36:00.000Z | 2022-03-01T20:31:51.000Z | ctfcli/templates/web/default/{{cookiecutter.name}}/src/config.py | pedrosa-t/ctfcli | 0ceb70524da8e52917b802ef17d302006f8dede6 | [
"Apache-2.0"
] | 34 | 2020-04-05T16:49:29.000Z | 2022-03-10T17:46:51.000Z | import os
class Config(object):
SECRET_KEY = os.urandom(32)
BOOTSTRAP_SERVE_LOCAL = True
SQLALCHEMY_DATABASE_URI = "sqlite:///app.db"
SQLALCHEMY_TRACK_MODIFICATIONS = False
| 21.222222 | 48 | 0.732984 | 24 | 191 | 5.541667 | 0.916667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012739 | 0.17801 | 191 | 8 | 49 | 23.875 | 0.834395 | 0 | 0 | 0 | 0 | 0 | 0.08377 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
b2d2d30faa446ff76e03dbafbd01eafe53dd6396 | 319 | py | Python | pizzapi/__init__.py | dsteen338/pizzapi | 437715c52a1a1cfd8021ca34dbacca217ed979a2 | [
"MIT"
] | null | null | null | pizzapi/__init__.py | dsteen338/pizzapi | 437715c52a1a1cfd8021ca34dbacca217ed979a2 | [
"MIT"
] | null | null | null | pizzapi/__init__.py | dsteen338/pizzapi | 437715c52a1a1cfd8021ca34dbacca217ed979a2 | [
"MIT"
] | 3 | 2019-03-17T15:13:45.000Z | 2019-03-17T15:43:49.000Z | from .address import Address
from .coupon import Coupon
from .customer import Customer
from .menu import Menu
from .order import Order
from .payment import PaymentObject
from .store import Store
from .track import track_by_order, track_by_phone
from .utils import request_json, request_xml
from .example import Example
| 29 | 49 | 0.830721 | 48 | 319 | 5.395833 | 0.375 | 0.054054 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.131661 | 319 | 10 | 50 | 31.9 | 0.935018 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
b2e2f0e80fb461e109cc647ea292e557daad1c35 | 2,664 | py | Python | FusionIIIT/applications/finance_accounts/models.py | thesid01/Fusion | 40aec72a9f0469081456305720c2ea5874576948 | [
"bzip2-1.0.6"
] | 2 | 2020-06-17T11:59:08.000Z | 2020-07-10T12:17:35.000Z | FusionIIIT/applications/finance_accounts/models.py | anirudh773/Fusion | 104a31ae8237b098f4d7f2d9fd4e077028d089b0 | [
"bzip2-1.0.6"
] | null | null | null | FusionIIIT/applications/finance_accounts/models.py | anirudh773/Fusion | 104a31ae8237b098f4d7f2d9fd4e077028d089b0 | [
"bzip2-1.0.6"
] | 4 | 2020-01-16T17:00:08.000Z | 2020-06-30T15:58:32.000Z | from django.db import models
class Paymentscheme(models.Model):
month = models.CharField(max_length = 70 , null = True)
year = models.IntegerField(null = True)
pf = models.IntegerField(null = True)
name = models.CharField(max_length = 70)
designation = models.CharField(max_length = 50)
pay = models.IntegerField()
gr_pay = models.IntegerField()
da = models.IntegerField()
ta = models.IntegerField()
hra = models.IntegerField()
fpa = models.IntegerField()
special_allow = models.IntegerField()
nps = models.IntegerField()
gpf = models.IntegerField()
income_tax = models.IntegerField()
p_tax = models.IntegerField()
gslis = models.IntegerField()
gis = models.IntegerField()
license_fee = models.IntegerField()
electricity_charges = models.IntegerField()
others = models.IntegerField()
gr_reduction = models.IntegerField(default=0);
net_payment = models.IntegerField(default=0);
senior_verify = models.BooleanField(default = False)
ass_registrar_verify = models.BooleanField(default = False)
ass_registrar_aud_verify = models.BooleanField(default = False)
registrar_director_verify = models.BooleanField(default = False)
runpayroll = models.BooleanField(default = False)
view = models.BooleanField(default = True)
class Receipts(models.Model):
receipt_id = models.AutoField(primary_key=True)
TransactionId = models.IntegerField(default=0)
ToWhom = models.CharField(max_length=80)
FromWhom = models.CharField(max_length=80)
Purpose = models.CharField(max_length=20)
Date = models.DateField()
class Payments(models.Model):
payment_id = models.AutoField(primary_key=True)
TransactionId = models.IntegerField(default=0)
ToWhom = models.CharField(max_length=80)
FromWhom = models.CharField(max_length=80)
Purpose = models.CharField(max_length=20)
Date = models.DateField()
class Bank(models.Model):
bank_id = models.AutoField(primary_key=True)
Account_no = models.IntegerField(default=0)
Bank_Name = models.CharField(max_length=50)
IFSC_Code = models.CharField(max_length=20)
Branch_Name = models.CharField(max_length=80)
class Company(models.Model):
company_id = models.AutoField(primary_key=True)
Company_Name = models.CharField(max_length=20)
Start_Date = models.DateField()
End_Date = models.DateField()
Description = models.CharField(max_length=200)
Status = models.CharField(max_length=200)
| 39.761194 | 69 | 0.686562 | 293 | 2,664 | 6.085324 | 0.283276 | 0.232193 | 0.15143 | 0.201907 | 0.48682 | 0.305104 | 0.270331 | 0.216489 | 0.216489 | 0.216489 | 0 | 0.01767 | 0.213964 | 2,664 | 66 | 70 | 40.363636 | 0.833811 | 0 | 0 | 0.172414 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.017241 | 0 | 1 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
b2eee133f67888d556c4bea6791beed6627798d5 | 476 | py | Python | netbox_routing/forms/filtersets/objects.py | DanSheps/netbox-routing | a4deb55ba2e8048556035faa0430b31dcac1259b | [
"Apache-2.0"
] | 2 | 2022-03-30T14:01:32.000Z | 2022-03-30T20:49:01.000Z | netbox_routing/forms/filtersets/objects.py | DanSheps/netbox-routing | a4deb55ba2e8048556035faa0430b31dcac1259b | [
"Apache-2.0"
] | null | null | null | netbox_routing/forms/filtersets/objects.py | DanSheps/netbox-routing | a4deb55ba2e8048556035faa0430b31dcac1259b | [
"Apache-2.0"
] | null | null | null | from netbox.forms import NetBoxModelFilterSetForm
from netbox_routing.models import PrefixList, PrefixListEntry, RouteMap, RouteMapEntry
class PrefixListFilterSetForm(NetBoxModelFilterSetForm):
model = PrefixList
class PrefixListEntryFilterSetForm(NetBoxModelFilterSetForm):
model = PrefixListEntry
class RouteMapFilterSetForm(NetBoxModelFilterSetForm):
model = RouteMap
class RouteMapEntryFilterSetForm(NetBoxModelFilterSetForm):
model = RouteMapEntry | 26.444444 | 86 | 0.842437 | 34 | 476 | 11.764706 | 0.5 | 0.29 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.113445 | 476 | 18 | 87 | 26.444444 | 0.947867 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 1 | 0 | 0 | 0 | 1 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
b2eefded9997aa8fa5cc4ff9bd6d37c8d2861468 | 361 | py | Python | chapter 3/sampleCode13.py | DTAIEB/Thoughtful-Data-Science | 8b80e8f3e33b6fdc6672ecee1f27e0b983b28241 | [
"Apache-2.0"
] | 15 | 2018-06-01T19:18:32.000Z | 2021-11-28T03:31:35.000Z | chapter 3/sampleCode13.py | chshychen/Thoughtful-Data-Science | 8b80e8f3e33b6fdc6672ecee1f27e0b983b28241 | [
"Apache-2.0"
] | 1 | 2018-12-17T02:01:42.000Z | 2018-12-17T02:01:42.000Z | chapter 3/sampleCode13.py | chshychen/Thoughtful-Data-Science | 8b80e8f3e33b6fdc6672ecee1f27e0b983b28241 | [
"Apache-2.0"
] | 10 | 2018-09-16T06:06:57.000Z | 2021-06-29T05:49:18.000Z | @PixieApp
class GitHubTracking(RepoAnalysis):
@route()
def main_screen(self):
<<Code omitted here>>
@route(query="*")
@templateArgs
def do_search(self, query):
<<Code omitted here>>
@route(page="*")
@templateArgs
def do_retrieve_page(self, page):
<<Code omitted here>>
app = GitHubTracking()
app.run()
| 19 | 37 | 0.612188 | 39 | 361 | 5.564103 | 0.512821 | 0.152074 | 0.207373 | 0.184332 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.243767 | 361 | 18 | 38 | 20.055556 | 0.794872 | 0 | 0 | 0.333333 | 0 | 0 | 0.00554 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
b2f2a6be3bf5dcc0b5d53e647922ef7f03b34367 | 174 | py | Python | 04/createArray.py | dunjin/DataAnalysisInAction | bec8af3763831b671a84a1355b5d220972f81137 | [
"CNRI-Python",
"Xnet",
"X11"
] | 656 | 2018-12-31T05:35:33.000Z | 2022-03-13T15:37:58.000Z | 04/createArray.py | dunjin/DataAnalysisInAction | bec8af3763831b671a84a1355b5d220972f81137 | [
"CNRI-Python",
"Xnet",
"X11"
] | 14 | 2019-01-02T01:55:07.000Z | 2020-10-12T11:28:01.000Z | 04/createArray.py | dunjin/DataAnalysisInAction | bec8af3763831b671a84a1355b5d220972f81137 | [
"CNRI-Python",
"Xnet",
"X11"
] | 260 | 2019-01-10T01:44:08.000Z | 2022-03-18T11:33:52.000Z | # encoding:utf-8
import numpy as np
a = np.array([1, 2, 3])
b = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
b[1, 1] = 10
print a.shape
print b.shape
print a.dtype
print b
| 14.5 | 47 | 0.568966 | 40 | 174 | 2.475 | 0.55 | 0.141414 | 0.161616 | 0.181818 | 0.20202 | 0 | 0 | 0 | 0 | 0 | 0 | 0.124088 | 0.212644 | 174 | 11 | 48 | 15.818182 | 0.59854 | 0.08046 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.125 | null | null | 0.5 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
65148e51e22dd47bcc4c1c5d1566c56fa2437d25 | 94 | py | Python | classwork04/string.py | AKozhemyako/lesson04 | 59ec462b4fe429bd2e234ff4431fc9c83d7adaa2 | [
"MIT"
] | null | null | null | classwork04/string.py | AKozhemyako/lesson04 | 59ec462b4fe429bd2e234ff4431fc9c83d7adaa2 | [
"MIT"
] | null | null | null | classwork04/string.py | AKozhemyako/lesson04 | 59ec462b4fe429bd2e234ff4431fc9c83d7adaa2 | [
"MIT"
] | null | null | null | string = "Hello world"
for char in string:
print(char)
length = len(string)
print(length)
| 15.666667 | 22 | 0.702128 | 14 | 94 | 4.714286 | 0.642857 | 0.333333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.180851 | 94 | 5 | 23 | 18.8 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0.117021 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.4 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
651d8d981336aaa54bb58bf03572d260967977a8 | 1,524 | py | Python | src/genie/libs/parser/iosxr/tests/ShowRouteIpv4/cli/equal/golden13_expected.py | balmasea/genieparser | d1e71a96dfb081e0a8591707b9d4872decd5d9d3 | [
"Apache-2.0"
] | 204 | 2018-06-27T00:55:27.000Z | 2022-03-06T21:12:18.000Z | src/genie/libs/parser/iosxr/tests/ShowRouteIpv4/cli/equal/golden13_expected.py | balmasea/genieparser | d1e71a96dfb081e0a8591707b9d4872decd5d9d3 | [
"Apache-2.0"
] | 468 | 2018-06-19T00:33:18.000Z | 2022-03-31T23:23:35.000Z | src/genie/libs/parser/iosxr/tests/ShowRouteIpv4/cli/equal/golden13_expected.py | balmasea/genieparser | d1e71a96dfb081e0a8591707b9d4872decd5d9d3 | [
"Apache-2.0"
] | 309 | 2019-01-16T20:21:07.000Z | 2022-03-30T12:56:41.000Z | expected_output = {
'vrf': {
'HIPTV': {
'address_family': {
'ipv4': {
'routes': {
'172.25.254.37/32': {
'known_via': 'bgp 7992',
'ip': '172.25.254.37',
'metric': 0,
'installed': {
'date': 'Feb 6 13:12:22.999',
'for': '10w6d',
},
'next_hop': {
'next_hop_list': {
1: {
'index': 1,
'metric': 0,
'next_hop': '172.25.253.121',
'from': '172.25.253.121',
},
},
},
'active': True,
'distance': 20,
'route': '172.25.254.37/32',
'mask': '32',
'tag': '65525',
'type': 'external',
},
},
},
},
},
},
}
| 40.105263 | 73 | 0.170604 | 71 | 1,524 | 3.56338 | 0.676056 | 0.098814 | 0.094862 | 0.118577 | 0.094862 | 0 | 0 | 0 | 0 | 0 | 0 | 0.206651 | 0.723753 | 1,524 | 37 | 74 | 41.189189 | 0.394299 | 0 | 0 | 0.054054 | 0 | 0 | 0.169291 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
654a4447c54dbcbbc16c29a772ebd9c59f2e6ba0 | 217 | py | Python | quora_problems/problem_2.py | loftwah/Daily-Coding-Problem | 0327f0b4f69ef419436846c831110795c7a3c1fe | [
"MIT"
] | 129 | 2018-10-14T17:52:29.000Z | 2022-01-29T15:45:57.000Z | quora_problems/problem_2.py | loftwah/Daily-Coding-Problem | 0327f0b4f69ef419436846c831110795c7a3c1fe | [
"MIT"
] | 2 | 2019-11-30T23:28:23.000Z | 2020-01-03T16:30:32.000Z | quora_problems/problem_2.py | loftwah/Daily-Coding-Problem | 0327f0b4f69ef419436846c831110795c7a3c1fe | [
"MIT"
] | 60 | 2019-02-21T09:18:31.000Z | 2022-03-25T21:01:04.000Z | """This problem was asked by Quora.
Given an absolute pathname that may have . or .. as part of it,
return the shortest standardized path.
For example, given "/usr/bin/../bin/./scripts/../", return "/usr/bin/".
""" | 31 | 71 | 0.682028 | 33 | 217 | 4.484848 | 0.848485 | 0.081081 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.156682 | 217 | 7 | 72 | 31 | 0.808743 | 0.967742 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
e8da22e9110c1f115ea2b759b8a8a7d807f10455 | 162 | py | Python | src/posts/urls.py | Ameesha2001/Ekyam-scl-maxo | d9a8ec0e2d297d20fcf9139cfe50a7c814cdb2f5 | [
"MIT"
] | 10 | 2021-01-02T14:54:33.000Z | 2022-02-09T07:11:05.000Z | src/posts/urls.py | Ameesha2001/Ekyam-scl-maxo | d9a8ec0e2d297d20fcf9139cfe50a7c814cdb2f5 | [
"MIT"
] | 2 | 2021-01-06T09:04:24.000Z | 2021-01-08T06:20:34.000Z | src/posts/urls.py | Ameesha2001/Ekyam-scl-maxo | d9a8ec0e2d297d20fcf9139cfe50a7c814cdb2f5 | [
"MIT"
] | 8 | 2020-12-24T07:58:24.000Z | 2022-01-04T15:22:30.000Z | from django.urls import path
from . import views
app_name = 'posts'
urlpatterns = [
path('create/<int:pk>/', views.create_post, name='create_post'),
] | 18 | 68 | 0.67284 | 22 | 162 | 4.818182 | 0.636364 | 0.188679 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.179012 | 162 | 9 | 69 | 18 | 0.796992 | 0 | 0 | 0 | 0 | 0 | 0.196319 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
e8f03e469faf18c367d33abf291b6276feee4792 | 528 | py | Python | week1/JY/activation.py | maybedy/MLDLStudy | abe121bc73c1958f1cd2d30fd30384137140187b | [
"MIT"
] | null | null | null | week1/JY/activation.py | maybedy/MLDLStudy | abe121bc73c1958f1cd2d30fd30384137140187b | [
"MIT"
] | null | null | null | week1/JY/activation.py | maybedy/MLDLStudy | abe121bc73c1958f1cd2d30fd30384137140187b | [
"MIT"
] | null | null | null | import numpy as np
def identity_function(x):
return x
def leaky_relu(x):
return np.max(0.1 * x, x)
def relu(x):
return np.max(0, x)
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def tanh(x):
return np.tanh(x)
def step_function(x):
return np.array(x > 0, dtype=np.int)
def softmax(x):
if x.ndim == 2:
x = x.T
x -= np.max(x, axis=0)
y = np.exp(x) / np.sum(np.exp(x), axis=0)
return y.T
x -= np.max(x) # 오버플로 대책
return np.exp(x) / np.sum(np.exp(x))
| 14.27027 | 49 | 0.534091 | 102 | 528 | 2.735294 | 0.303922 | 0.150538 | 0.107527 | 0.09319 | 0.301075 | 0.243728 | 0.121864 | 0.121864 | 0 | 0 | 0 | 0.024064 | 0.291667 | 528 | 36 | 50 | 14.666667 | 0.721925 | 0.013258 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.047619 | 0.285714 | 0.761905 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
e8f2ca70ba3d73c2c849e83314e7ea697bc98e34 | 176 | py | Python | qpropgen/__init__.py | foxoman/qpropgen | bbc7d5cc70a8d065593d39ac932473fc303c340f | [
"Apache-2.0"
] | 1 | 2019-04-05T08:38:37.000Z | 2019-04-05T08:38:37.000Z | qpropgen/__init__.py | foxoman/qpropgen | bbc7d5cc70a8d065593d39ac932473fc303c340f | [
"Apache-2.0"
] | null | null | null | qpropgen/__init__.py | foxoman/qpropgen | bbc7d5cc70a8d065593d39ac932473fc303c340f | [
"Apache-2.0"
] | null | null | null | __appname__ = 'qpropgen'
__version__ = '0.1.0'
__license__ = 'Apache 2.0'
DESCRIPTION = """\
Generate a QML-friendly QObject-based C++ class from a class definition file.
"""
| 22 | 77 | 0.710227 | 24 | 176 | 4.708333 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.033333 | 0.147727 | 176 | 7 | 78 | 25.142857 | 0.72 | 0 | 0 | 0 | 1 | 0 | 0.585227 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
334d09454e5c1c7326788e9cb165af97ed207503 | 159 | py | Python | Class 11/11-Programs/sqrt no. below given no..py | edwardmasih/Python-School-Level | 545e8fcd87f540be2bbf01d3493bd84dd5504739 | [
"MIT"
] | null | null | null | Class 11/11-Programs/sqrt no. below given no..py | edwardmasih/Python-School-Level | 545e8fcd87f540be2bbf01d3493bd84dd5504739 | [
"MIT"
] | null | null | null | Class 11/11-Programs/sqrt no. below given no..py | edwardmasih/Python-School-Level | 545e8fcd87f540be2bbf01d3493bd84dd5504739 | [
"MIT"
] | null | null | null | import math
n=int(input('Enter a Number :- ' ))
for i in range (n,n,1):
for j in range(n,n-1,-1):
while j**j==i:
print (i and j)
| 22.714286 | 36 | 0.490566 | 31 | 159 | 2.516129 | 0.548387 | 0.179487 | 0.205128 | 0.230769 | 0.25641 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028302 | 0.333333 | 159 | 6 | 37 | 26.5 | 0.707547 | 0 | 0 | 0 | 0 | 0 | 0.117647 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0.166667 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
334f0d72c8c35e94324e583e070a632e6a5616df | 1,035 | py | Python | test.py | javaage/ptushare | 276fab662f859fce84cd2b8d14f17e0e7690ea44 | [
"Apache-2.0"
] | null | null | null | test.py | javaage/ptushare | 276fab662f859fce84cd2b8d14f17e0e7690ea44 | [
"Apache-2.0"
] | null | null | null | test.py | javaage/ptushare | 276fab662f859fce84cd2b8d14f17e0e7690ea44 | [
"Apache-2.0"
] | null | null | null | #! python2
#-*- coding:utf-8 –*-
import tushare as ts
import time
import datetime
import common
now=datetime.datetime.now()
delta=datetime.timedelta(days=-90)
n_days=now+delta
day90 = n_days.strftime('%Y-%m-%d')
basics = ts.get_stock_basics()
basics = basics[ basics['pe'] < 41]
basics = basics[ basics['pe'] > 0]
basics = basics[basics['pb'] < 5]
basics = basics[basics['pb'] > 0]
basics = basics[basics['rev'] > 0]
basics = basics[basics['profit'] > 0]
basics = basics[basics['industry'] <> '区域地产']
basics = basics[basics['industry'] <> '全国地产']
basics = basics[basics['industry'] <> '银行']
#print basics
codes = [];
pe41 = basics.index
#common.allcode
for code in pe41:
df = ts.get_k_data(code, start='1990-12-01')
#print df.tail(60)['close'].max()/df.tail(60)['close'].min()
if(df.shape[0] > 0 and df.tail(60)['close'].max()/df.tail(60)['close'].min() < 1.3):
if (cmp(df[df['close'] > df.iat[df.shape[0] - 1, 2]]['date'].max(), day90) < 0):
codes.append(code)
print code
print codes
| 26.538462 | 88 | 0.627053 | 159 | 1,035 | 4.050314 | 0.421384 | 0.354037 | 0.279503 | 0.118012 | 0.099379 | 0.099379 | 0.099379 | 0.099379 | 0.099379 | 0.099379 | 0 | 0.049255 | 0.156522 | 1,035 | 38 | 89 | 27.236842 | 0.687285 | 0.110145 | 0 | 0 | 0 | 0 | 0.096386 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.148148 | null | null | 0.074074 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3364bbf6365d6038916d257c129c039a10d708a1 | 182 | py | Python | test.py | bozcani/borsa-analysis-poc | 85df998b85e6a3bb4720dc50d39426521be3c368 | [
"MIT"
] | null | null | null | test.py | bozcani/borsa-analysis-poc | 85df998b85e6a3bb4720dc50d39426521be3c368 | [
"MIT"
] | null | null | null | test.py | bozcani/borsa-analysis-poc | 85df998b85e6a3bb4720dc50d39426521be3c368 | [
"MIT"
] | null | null | null | import django
import sys
import os
sys.path.append(os.path.abspath("/home/ilker/repos/borsa/"))
django.setup()
from BasicApp.models import Stock, OHLCV
print(Stock.objects.all())
| 16.545455 | 60 | 0.763736 | 28 | 182 | 4.964286 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.093407 | 182 | 10 | 61 | 18.2 | 0.842424 | 0 | 0 | 0 | 0 | 0 | 0.131868 | 0.131868 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.571429 | 0 | 0.571429 | 0.142857 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
336f43652286951fe004c0510e98f5c92536a4fa | 25 | py | Python | bw2calc/version.py | mixib/brightway2-calc | 0fa409b6e7bccbef2a220dd6a811356798518ebe | [
"BSD-3-Clause"
] | null | null | null | bw2calc/version.py | mixib/brightway2-calc | 0fa409b6e7bccbef2a220dd6a811356798518ebe | [
"BSD-3-Clause"
] | null | null | null | bw2calc/version.py | mixib/brightway2-calc | 0fa409b6e7bccbef2a220dd6a811356798518ebe | [
"BSD-3-Clause"
] | null | null | null | version = (2, 0, "DEV1")
| 12.5 | 24 | 0.52 | 4 | 25 | 3.25 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.15 | 0.2 | 25 | 1 | 25 | 25 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0.16 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
682f93fff4b564279e5675023b1fefe7aa3a8aef | 616 | py | Python | rssdldmng/pysqlw/mysqlw.py | alexpayne482/rssdldmng | 4428f10171902861702fc0f528d3d9576923541a | [
"MIT"
] | null | null | null | rssdldmng/pysqlw/mysqlw.py | alexpayne482/rssdldmng | 4428f10171902861702fc0f528d3d9576923541a | [
"MIT"
] | 1 | 2019-11-25T15:54:02.000Z | 2019-11-25T15:54:02.000Z | rssdldmng/pysqlw/mysqlw.py | alexpayne482/rssdldmng | 4428f10171902861702fc0f528d3d9576923541a | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from sqltype import sqltype
class mysqlw(sqltype):
@property
def required(self):
return ['db_host', 'db_user', 'db_pass', 'db_name']
def connect(self):
try:
import MySQLdb
self.dbc = MySQLdb.connect(self.args.get('db_host'), self.args.get('db_user'),
self.args.get('db_pass'), self.args.get('db_name'))
self.cursor = self.dbc.cursor(MySQLdb.cursors.DictCursor)
except Exception as e:
return False
return True
def format(self, item):
return '%s'
| 28 | 90 | 0.555195 | 75 | 616 | 4.453333 | 0.48 | 0.095808 | 0.131737 | 0.155689 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002364 | 0.313312 | 616 | 21 | 91 | 29.333333 | 0.787234 | 0.034091 | 0 | 0 | 0 | 0 | 0.097808 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1875 | false | 0.125 | 0.125 | 0.125 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 3 |
68343af4f9ea2a9ab6f631c46eac37e51c9a73ac | 331 | py | Python | opencv_project_python-master/opencv_project_python-master/03.numpy_matplotlib/np_reshape.py | dongrami0425/Python_OpenCV-Study | c7faee4f63720659280c3222ba5abfe27740d1f4 | [
"MIT"
] | null | null | null | opencv_project_python-master/opencv_project_python-master/03.numpy_matplotlib/np_reshape.py | dongrami0425/Python_OpenCV-Study | c7faee4f63720659280c3222ba5abfe27740d1f4 | [
"MIT"
] | null | null | null | opencv_project_python-master/opencv_project_python-master/03.numpy_matplotlib/np_reshape.py | dongrami0425/Python_OpenCV-Study | c7faee4f63720659280c3222ba5abfe27740d1f4 | [
"MIT"
] | null | null | null | import numpy as np
a = np.arange(6)
b = a.reshape(2,3)
c = np.arange(24).reshape(2,3,4)
d = np.arange(100).reshape(2, -1)
e = np.arange(100).reshape(-1, 5)
f = np.ravel(c)
g = np.arange(10).reshape(2,-1)
print(a, a.shape)
print(b, b.shape)
print(c, c.shape)
print(d, d.shape)
print(e, e.shape)
print(f, f.shape)
print(g.T)
| 13.791667 | 33 | 0.625378 | 73 | 331 | 2.835616 | 0.356164 | 0.289855 | 0.086957 | 0.173913 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.077739 | 0.145015 | 331 | 23 | 34 | 14.391304 | 0.65371 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.066667 | 0 | 0.066667 | 0.466667 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
684d0d9690dfb9b57c83b1501fd692caf1366bb9 | 166 | py | Python | Q14.py | jorgeyuri11/BLASTOFF | ea011365d6ce52bcde169f05be69b68e2e5e04f5 | [
"Apache-2.0"
] | null | null | null | Q14.py | jorgeyuri11/BLASTOFF | ea011365d6ce52bcde169f05be69b68e2e5e04f5 | [
"Apache-2.0"
] | null | null | null | Q14.py | jorgeyuri11/BLASTOFF | ea011365d6ce52bcde169f05be69b68e2e5e04f5 | [
"Apache-2.0"
] | null | null | null | def isPalindrome(x):
if x == x[::-1]:
print("A palavra é palíndromo!")
else:
print("A palavra não é palíndromo!")
isPalindrome("arara") | 23.714286 | 45 | 0.560241 | 21 | 166 | 4.428571 | 0.619048 | 0.129032 | 0.27957 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008403 | 0.283133 | 166 | 7 | 46 | 23.714286 | 0.773109 | 0 | 0 | 0 | 0 | 0 | 0.341615 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0 | 0 | 0.166667 | 0.333333 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
68b1dd062d5ab2abc558fdb99ad46410c9bbd0a8 | 56 | py | Python | example_snippets/multimenus_snippets/Snippets/SciPy/Physical and mathematical constants/CODATA physical constants/H/helion-proton mass ratio.py | kuanpern/jupyterlab-snippets-multimenus | 477f51cfdbad7409eab45abe53cf774cd70f380c | [
"BSD-3-Clause"
] | null | null | null | example_snippets/multimenus_snippets/Snippets/SciPy/Physical and mathematical constants/CODATA physical constants/H/helion-proton mass ratio.py | kuanpern/jupyterlab-snippets-multimenus | 477f51cfdbad7409eab45abe53cf774cd70f380c | [
"BSD-3-Clause"
] | null | null | null | example_snippets/multimenus_snippets/Snippets/SciPy/Physical and mathematical constants/CODATA physical constants/H/helion-proton mass ratio.py | kuanpern/jupyterlab-snippets-multimenus | 477f51cfdbad7409eab45abe53cf774cd70f380c | [
"BSD-3-Clause"
] | 1 | 2021-02-04T04:51:48.000Z | 2021-02-04T04:51:48.000Z | constants.physical_constants["helion-proton mass ratio"] | 56 | 56 | 0.857143 | 7 | 56 | 6.714286 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035714 | 56 | 1 | 56 | 56 | 0.87037 | 0 | 0 | 0 | 0 | 0 | 0.421053 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
68b37999fea14422370bba871272a4fb66e80904 | 3,359 | py | Python | test/test.py | 30x/permissions-migration | aa61286753c382d76e8071d5a8fbb33a5c14d4bf | [
"Apache-2.0"
] | null | null | null | test/test.py | 30x/permissions-migration | aa61286753c382d76e8071d5a8fbb33a5c14d4bf | [
"Apache-2.0"
] | null | null | null | test/test.py | 30x/permissions-migration | aa61286753c382d76e8071d5a8fbb33a5c14d4bf | [
"Apache-2.0"
] | null | null | null | import requests
import base64
import json
from os import environ as env
from urlparse import urljoin
EXTERNAL_SCHEME = env['EXTERNAL_SCHEME']
BASE_URL = '%s://%s:%s' % (EXTERNAL_SCHEME, env['EXTERNAL_SY_ROUTER_HOST'], env['EXTERNAL_SY_ROUTER_PORT']) if 'EXTERNAL_SY_ROUTER_PORT' in env else '%s://%s' % (EXTERNAL_SCHEME, env['EXTERNAL_SY_ROUTER_HOST'])
def b64_decode(data):
missing_padding = (4 - len(data) % 4) % 4
if missing_padding:
data += b'='* missing_padding
return base64.decodestring(data)
TOKEN1 = env['APIGEE_TOKEN1']
USER1 = json.loads(b64_decode(TOKEN1.split('.')[1]))['user_id']
def main():
print 'sending requests to %s' % BASE_URL
migration_request = {
'resource': 'https://api.e2e.apigee.net/v1/o/usergrid-e2e'
}
# POST migration-request ( success )
permissions_migration_url = urljoin(BASE_URL, '/az-permissions-migration/migration-request')
headers = {'Content-Type': 'application/json','Authorization': 'Bearer %s' % TOKEN1}
r = requests.post(permissions_migration_url, headers=headers, json=migration_request)
if r.status_code == 200:
print 'correctly migrated edge org'
else:
print 'failed to migrate edge org for resource %s %s %s' % (migration_request['resource'], r.status_code, r.text)
return
# POST migration-request ( conflict )
permissions_migration_url = urljoin(BASE_URL, '/az-permissions-migration/migration-request')
headers = {'Content-Type': 'application/json','Authorization': 'Bearer %s' % TOKEN1}
r = requests.post(permissions_migration_url, headers=headers, json=migration_request)
if r.status_code == 409:
print 'correctly received conflict for resource %s ' % (migration_request['resource'])
else:
print 'failed to migrate edge org %s %s' % (r.status_code, r.text)
return
# POST migration-request ( bad resource path)
migration_request = {
'resource': 'https://api.e2e.apigee.net/v1/notanedgeapi/usergrid-e2e'
}
permissions_migration_url = urljoin(BASE_URL, '/az-permissions-migration/migration-request')
headers = {'Content-Type': 'application/json','Authorization': 'Bearer %s' % TOKEN1}
r = requests.post(permissions_migration_url, headers=headers, json=migration_request)
if r.status_code == 404:
print 'correctly refused migration for bad resource due to non-edge path %s ' % (migration_request['resource'])
else:
print 'failed to refuse migration for bad resource due to non-edge path %s %s' % (r.status_code, r.text)
return
# POST migration-request ( bad resource host)
migration_request = {
'resource': 'https://api.enterprise.apigee.com/v1/o/usergrid-e2e'
}
permissions_migration_url = urljoin(BASE_URL, '/az-permissions-migration/migration-request')
headers = {'Content-Type': 'application/json','Authorization': 'Bearer %s' % TOKEN1}
r = requests.post(permissions_migration_url, headers=headers, json=migration_request)
if r.status_code == 404:
print 'correctly refused migration for bad resource due to host mismatch %s ' % (migration_request['resource'])
else:
print 'failed to refuse migration for bad resource due to host mismatch %s %s' % (r.status_code, r.text)
return
return
if __name__ == '__main__':
main() | 42.518987 | 210 | 0.694254 | 430 | 3,359 | 5.255814 | 0.216279 | 0.134513 | 0.081416 | 0.053097 | 0.733186 | 0.719027 | 0.719027 | 0.699115 | 0.670354 | 0.565487 | 0 | 0.01453 | 0.180411 | 3,359 | 79 | 211 | 42.518987 | 0.806393 | 0.047038 | 0 | 0.433333 | 0 | 0 | 0.370034 | 0.082577 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.083333 | null | null | 0.15 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
d7a1294030ed594e4017032f3567ca255a83efbd | 141 | py | Python | src/core/constants.py | quiquegarcia/2020-website | 02dd1e42ddaab5712e4faa7bcc2c5f80c68d0e8d | [
"MIT"
] | null | null | null | src/core/constants.py | quiquegarcia/2020-website | 02dd1e42ddaab5712e4faa7bcc2c5f80c68d0e8d | [
"MIT"
] | null | null | null | src/core/constants.py | quiquegarcia/2020-website | 02dd1e42ddaab5712e4faa7bcc2c5f80c68d0e8d | [
"MIT"
] | null | null | null | from django.utils.translation import ugettext_lazy as _
FULL_NAME_REQUIRED = _('Your name')
RESERVATION_REQUIRED = _('Hotel confirmation')
| 23.5 | 55 | 0.801418 | 17 | 141 | 6.235294 | 0.882353 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.113475 | 141 | 5 | 56 | 28.2 | 0.848 | 0 | 0 | 0 | 0 | 0 | 0.191489 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
d7aec2c6c9824fca3d25a7235cfb180f0e5d36a2 | 1,759 | py | Python | app/config.py | Haikson/flask_project | 74b008cf0c617b9f3d9a29e57d660db83dd01bb6 | [
"MIT"
] | null | null | null | app/config.py | Haikson/flask_project | 74b008cf0c617b9f3d9a29e57d660db83dd01bb6 | [
"MIT"
] | null | null | null | app/config.py | Haikson/flask_project | 74b008cf0c617b9f3d9a29e57d660db83dd01bb6 | [
"MIT"
] | null | null | null | import os
basedir = os.path.abspath(os.path.dirname(__file__))
class BaseConfig(object):
"""Base configuration."""
FLASK_DEBUG = False
SECRET_KEY = ';ajksd0jd0pqojdasdm[qpodsmq09d03jdlskmd03j1ldmlsad9jiodn;ajwd09j1ndla' # todo generate secret key
BCRYPT_LOG_ROUNDS = 13
WTF_CSRF_ENABLED = True
DEBUG_TB_ENABLED = False
DEBUG_TB_INTERCEPT_REDIRECTS = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_RECORD_QUERIES = True
SQLALCHEMY_POOL_SIZE = 5
# EMAIL CONFIG
EMAIL_BACKEND = 'flask_email.backends.smtp.Mail'
DEFAULT_FROM_EMAIL = '{email}'
DEFAULT_TO_EMAIL = ['kamo@haikson.com', 'info@techelec.ru']
EMAIL_HOST = '{email_smtp_host}'
EMAIL_PORT = 587
EMAIL_HOST_USER = '{email}'
EMAIL_HOST_PASSWORD = '{password}'
EMAIL_USE_TLS = False
EMAIL_USE_SSL = False
# administrator list
ADMINS = ['kamo@haikson.com']
class DevelopmentConfig(BaseConfig):
"""Development configuration."""
FLASK_DEBUG = True
DEBUG = True
BCRYPT_LOG_ROUNDS = 4
WTF_CSRF_ENABLED = False
# SQLALCHEMY_DATABASE_URI = 'sqlite:///{0}'.format(
# os.path.join(basedir, 'dev.db'))
SQLALCHEMY_DATABASE_URI = '{database_engine}://{login}:{password}@{host}:{port}/{database}'
DEBUG_TB_ENABLED = True
class TestingConfig(BaseConfig):
"""Testing configuration."""
TESTING = True
BCRYPT_LOG_ROUNDS = 4
WTF_CSRF_ENABLED = False
SQLALCHEMY_DATABASE_URI = 'sqlite:///'
DEBUG_TB_ENABLED = False
PRESERVE_CONTEXT_ON_EXCEPTION = False
class ProductionConfig(BaseConfig):
"""Production configuration."""
SQLALCHEMY_DATABASE_URI = '{database_engine}://{login}:{password}@{host}:{port}/{database}'
DEBUG_TB_ENABLED = False
| 29.813559 | 116 | 0.706083 | 199 | 1,759 | 5.904523 | 0.442211 | 0.029787 | 0.04766 | 0.048511 | 0.245106 | 0.245106 | 0.245106 | 0.245106 | 0.245106 | 0.245106 | 0 | 0.015278 | 0.181353 | 1,759 | 58 | 117 | 30.327586 | 0.800694 | 0.136441 | 0 | 0.230769 | 0 | 0 | 0.216867 | 0.150602 | 0 | 0 | 0 | 0.017241 | 0 | 1 | 0 | false | 0.076923 | 0.025641 | 0 | 0.974359 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
d7b501b4b46ec8afcbb1ba1012b26064f0640ce0 | 69 | py | Python | apps/controllerx/cx_core/feature_support/light.py | francoisauclair911/controllerx | 00b38cdbddb75e470d1577f1d22c8e99d62e1256 | [
"MIT"
] | 204 | 2020-01-18T10:12:13.000Z | 2022-03-27T09:40:17.000Z | apps/controllerx/cx_core/feature_support/light.py | francoisauclair911/controllerx | 00b38cdbddb75e470d1577f1d22c8e99d62e1256 | [
"MIT"
] | 329 | 2020-01-17T17:18:53.000Z | 2022-03-29T11:20:30.000Z | apps/controllerx/cx_core/feature_support/light.py | francoisauclair911/controllerx | 00b38cdbddb75e470d1577f1d22c8e99d62e1256 | [
"MIT"
] | 66 | 2020-01-19T20:17:21.000Z | 2022-03-13T15:03:41.000Z | class LightSupport:
EFFECT = 4
FLASH = 8
TRANSITION = 32
| 13.8 | 19 | 0.608696 | 8 | 69 | 5.25 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.086957 | 0.333333 | 69 | 4 | 20 | 17.25 | 0.826087 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
d7b52bad0508de3818ed27bd8a1ecf95751c13b0 | 44,464 | py | Python | people/tests/unit_test_interactors.py | jordifierro/pachatary-api | c03ad67ceb856068daa6d082091372eb1ed3d009 | [
"MIT"
] | 3 | 2018-12-05T16:44:59.000Z | 2020-08-01T14:12:32.000Z | people/tests/unit_test_interactors.py | jordifierro/pachatary-api | c03ad67ceb856068daa6d082091372eb1ed3d009 | [
"MIT"
] | 6 | 2020-06-03T15:56:59.000Z | 2022-02-10T07:23:55.000Z | people/tests/unit_test_interactors.py | jordifierro/pachatary-api | c03ad67ceb856068daa6d082091372eb1ed3d009 | [
"MIT"
] | null | null | null | from mock import Mock, call
from pachatary.exceptions import InvalidEntityException, EntityDoesNotExistException, ConflictException, \
NoLoggedException
from people.entities import Person, AuthToken
from people.interactors import CreateGuestPersonAndReturnAuthTokenInteractor, AuthenticateInteractor, \
RegisterUsernameAndEmailInteractor, ConfirmEmailInteractor, LoginEmailInteractor, LoginInteractor, \
BlockInteractor
from profiles.entities import Profile
from experiences.entities import Experience
from experiences.interactors import SaveUnsaveExperienceInteractor
class TestCreateGuestPersonAndReturnAuthToken:
def test_creates_guest_person_and_returns_auth_token(self):
TestCreateGuestPersonAndReturnAuthToken._ScenarioMaker() \
.given_a_client_secret_key() \
.given_a_client_secret_key_validator_that_accepts_that_key() \
.given_a_person_repo_that_returns_a_person() \
.given_an_auth_token_repo_that_returns_a_token() \
.when_execute_interactor() \
.then_result_should_be_that_token() \
.then_client_secret_key_should_be_validated() \
.then_person_repo_create_guest_person_should_be_called() \
.then_create_auth_token_should_be_called_with_returned_person_id()
def test_invalid_client_secret_key_returns_invalid_entity_exception_and_doesnt_create_person(self):
TestCreateGuestPersonAndReturnAuthToken._ScenarioMaker() \
.given_a_client_secret_key() \
.given_a_client_secret_key_validator_that_doesnt_accept_that_key() \
.given_a_person_repo_that_returns_a_person() \
.given_an_auth_token_repo_that_returns_a_token() \
.when_execute_interactor() \
.then_should_raise_invalid_entity_exception() \
.then_client_secret_key_should_be_validated() \
.then_person_repo_create_guest_person_should_not_be_called() \
.then_create_auth_token_should_not_be_called()
class _ScenarioMaker:
def __init__(self):
self.person = None
self.auth_token = None
self.person_repo = None
self.auth_token_repo = None
self.result = None
self.client_secret_key = None
self.client_secret_key_validator = None
def given_a_client_secret_key(self):
self.client_secret_key = "scrt"
return self
def given_a_client_secret_key_validator_that_accepts_that_key(self):
self.client_secret_key_validator = Mock()
self.client_secret_key_validator.validate.return_value = True
return self
def given_a_client_secret_key_validator_that_doesnt_accept_that_key(self):
self.client_secret_key_validator = Mock()
self.client_secret_key_validator.validate.side_effect = InvalidEntityException(
source='client_secret_key',
code='invalid',
message='Invalid client secret key')
return self
def given_a_person_repo_that_returns_a_person(self):
self.person = Person(id='3')
self.person_repo = Mock()
self.person_repo.create_guest_person.return_value = self.person
return self
def given_an_auth_token_repo_that_returns_a_token(self):
self.auth_token = AuthToken(person_id='3', access_token='A', refresh_token='R')
self.auth_token_repo = Mock()
self.auth_token_repo.create_auth_token.return_value = self.auth_token
return self
def when_execute_interactor(self):
try:
interactor = CreateGuestPersonAndReturnAuthTokenInteractor(
client_secret_key_validator=self.client_secret_key_validator,
person_repo=self.person_repo,
auth_token_repo=self.auth_token_repo)
self.result = interactor.set_params(client_secret_key=self.client_secret_key).execute()
except Exception as e:
self.error = e
return self
def then_result_should_be_that_token(self):
assert self.result == self.auth_token
return self
def then_should_raise_invalid_entity_exception(self):
assert type(self.error) is InvalidEntityException
assert self.error.source == 'client_secret_key'
assert self.error.code == 'invalid'
return self
def then_client_secret_key_should_be_validated(self):
self.client_secret_key_validator.validate.assert_called_once_with(client_secret_key=self.client_secret_key)
return self
def then_person_repo_create_guest_person_should_be_called(self):
self.person_repo.create_guest_person.assert_called_once()
return self
def then_person_repo_create_guest_person_should_not_be_called(self):
self.person_repo.create_guest_person.assert_not_called()
return self
def then_create_auth_token_should_be_called_with_returned_person_id(self):
self.auth_token_repo.create_auth_token.assert_called_once_with(person_id=self.person.id)
return self
def then_create_auth_token_should_not_be_called(self):
self.auth_token_repo.create_auth_token.assert_not_called()
return self
class TestAuthenticateInteractor:
def test_correct_access_token_returns_person_id(self):
TestAuthenticateInteractor.ScenarioMaker() \
.given_an_access_token() \
.given_an_auth_token() \
.given_an_auth_repo_that_returns_that_auth_token() \
.when_authenticate_interactor_is_executed() \
.then_should_call_repo_get_auth_token_with_access_token() \
.then_should_return_auth_token_person_id()
def test_wrong_access_token_returns_none(self):
TestAuthenticateInteractor.ScenarioMaker() \
.given_an_access_token() \
.given_an_auth_repo_that_raises_entity_does_not_exist() \
.when_authenticate_interactor_is_executed() \
.then_should_return_none()
class ScenarioMaker:
def __init__(self):
self.result = None
self.repo = None
self.access_token = None
self.auth_token = None
def given_an_access_token(self):
self.access_token = 'A_T'
return self
def given_an_auth_token(self):
self.auth_token = AuthToken(person_id='1', access_token='A', refresh_token='R')
return self
def given_an_auth_repo_that_returns_that_auth_token(self):
self.repo = Mock()
self.repo.get_auth_token.return_value = self.auth_token
return self
def given_an_auth_repo_that_raises_entity_does_not_exist(self):
self.repo = Mock()
self.repo.get_auth_token.side_effect = EntityDoesNotExistException
return self
def when_authenticate_interactor_is_executed(self):
self.result = AuthenticateInteractor(self.repo).set_params(access_token=self.access_token).execute()
return self
def then_should_call_repo_get_auth_token_with_access_token(self):
self.repo.get_auth_token.assert_called_once_with(access_token=self.access_token)
return self
def then_should_return_auth_token_person_id(self):
assert self.result == self.auth_token.person_id
return self
def then_should_return_none(self):
assert self.result is None
return self
class TestRegisterUsernameAndEmailInteractor:
def test_correct_username_and_email_when_profile_doesnt_exist(self):
TestRegisterUsernameAndEmailInteractor.ScenarioMaker() \
.given_a_person_validator_that_returns(True) \
.given_a_person_repo_that_returns_on_get(Person(id='3', email='b', is_email_confirmed=False)) \
.given_a_person_repo_that_returns_on_update(Person(id='4', email='o', is_email_confirmed=False)) \
.given_a_profile_validator_that_returns(True) \
.given_a_profile_repo_that_returns_on_get(False) \
.given_a_confirmation_token_repo_that_returns('KT') \
.when_execute(logged_person_id='1', username='u', email='e') \
.then_should_call_person_repo_get_with(id='1') \
.then_should_call_person_validator_with(Person(id='3', email='e', is_email_confirmed=False)) \
.then_should_call_profile_repo_get_with(person_id='1', logged_person_id='1') \
.then_should_call_profile_validator_with(Profile(person_id='1', username='u')) \
.then_should_call_profile_repo_create_with(Profile(person_id='1', username='u')) \
.then_should_call_person_repo_update_with(Person(id='3', email='e', is_email_confirmed=False)) \
.then_should_call_confirmation_token_repo_delete_with(person_id='1') \
.then_should_call_confirmation_token_repo_create_with(person_id='1') \
.then_should_call_mailer_with(confirmation_token='KT', username='u', email='e') \
.then_should_return(True)
def test_correct_username_and_email_when_profile_exists(self):
TestRegisterUsernameAndEmailInteractor.ScenarioMaker() \
.given_a_person_validator_that_returns(True) \
.given_a_person_repo_that_returns_on_get(Person(id='3', email='b', is_email_confirmed=False)) \
.given_a_person_repo_that_returns_on_update(Person(id='4', email='o', is_email_confirmed=False)) \
.given_a_profile_validator_that_returns(True) \
.given_a_profile_repo_that_returns_on_get(Profile(person_id='7', username='p')) \
.given_a_confirmation_token_repo_that_returns('KT') \
.when_execute(logged_person_id='1', username='u', email='e') \
.then_should_call_person_repo_get_with(id='1') \
.then_should_call_person_validator_with(Person(id='3', email='e', is_email_confirmed=False)) \
.then_should_call_profile_repo_get_with(person_id='1', logged_person_id='1') \
.then_should_call_profile_validator_with(Profile(person_id='7', username='u')) \
.then_should_call_profile_repo_update_with(Profile(person_id='7', username='u')) \
.then_should_call_person_repo_update_with(Person(id='3', email='e', is_email_confirmed=False)) \
.then_should_call_confirmation_token_repo_delete_with(person_id='1') \
.then_should_call_confirmation_token_repo_create_with(person_id='1') \
.then_should_call_mailer_with(confirmation_token='KT', username='u', email='e') \
.then_should_return(True)
def test_incorrect_email_raises_invalid_entity_exception(self):
TestRegisterUsernameAndEmailInteractor.ScenarioMaker() \
.given_a_person_validator_that_returns(
error=InvalidEntityException(source='e', code='i', message='m')) \
.given_a_person_repo_that_returns_on_get(Person(id='3', email='b', is_email_confirmed=False)) \
.when_execute(logged_person_id='1', username='u', email='e') \
.then_should_call_person_repo_get_with(id='1') \
.then_should_call_person_validator_with(Person(id='3', email='e', is_email_confirmed=False)) \
.then_should_call_profile_repo_get_with(False) \
.then_should_call_profile_validator_with(False) \
.then_should_call_profile_repo_update_with(False) \
.then_should_call_person_repo_update_with(False) \
.then_should_call_confirmation_token_repo_delete_with(False) \
.then_should_call_confirmation_token_repo_create_with(False) \
.then_should_call_mailer_with(False) \
.then_should_raise(InvalidEntityException(source='e', code='i', message='m'))
def test_incorrect_username_raises_invalid_entity_exception(self):
TestRegisterUsernameAndEmailInteractor.ScenarioMaker() \
.given_a_person_validator_that_returns(True) \
.given_a_person_repo_that_returns_on_get(Person(id='3', email='b', is_email_confirmed=False)) \
.given_a_profile_validator_that_returns(
error=InvalidEntityException(source='u', code='i', message='m')) \
.given_a_profile_repo_that_returns_on_get(False) \
.when_execute(logged_person_id='1', username='u', email='e') \
.then_should_call_person_repo_get_with(id='1') \
.then_should_call_person_validator_with(Person(id='3', email='e', is_email_confirmed=False)) \
.then_should_call_profile_repo_get_with(person_id='1', logged_person_id='1') \
.then_should_call_profile_validator_with(Profile(person_id='1', username='u')) \
.then_should_call_profile_repo_update_with(False) \
.then_should_call_person_repo_update_with(False) \
.then_should_call_confirmation_token_repo_delete_with(False) \
.then_should_call_confirmation_token_repo_create_with(False) \
.then_should_call_mailer_with(False) \
.then_should_raise(InvalidEntityException(source='u', code='i', message='m'))
def test_cannot_register_once_email_is_confirmed(self):
TestRegisterUsernameAndEmailInteractor.ScenarioMaker() \
.given_a_person_validator_that_returns(True) \
.given_a_person_repo_that_returns_on_get(Person(id='3', email='b', is_email_confirmed=True)) \
.when_execute(logged_person_id='1', username='u', email='e') \
.then_should_call_person_repo_get_with(id='1') \
.then_should_call_person_validator_with(False) \
.then_should_call_profile_repo_get_with(False) \
.then_should_call_profile_validator_with(False) \
.then_should_call_profile_repo_update_with(False) \
.then_should_call_person_repo_update_with(False) \
.then_should_call_confirmation_token_repo_delete_with(False) \
.then_should_call_confirmation_token_repo_create_with(False) \
.then_should_call_mailer_with(False) \
.then_should_raise(
ConflictException(source='person', code='already_registered',
message='Person already registered'))
def test_no_logged_person_id_raises_unauthorized(self):
TestRegisterUsernameAndEmailInteractor.ScenarioMaker() \
.when_execute(logged_person_id=None, username='u', email='e') \
.then_should_call_person_repo_get_with(False) \
.then_should_call_person_validator_with(False) \
.then_should_call_profile_repo_get_with(False) \
.then_should_call_profile_validator_with(False) \
.then_should_call_profile_repo_update_with(False) \
.then_should_call_person_repo_update_with(False) \
.then_should_call_confirmation_token_repo_delete_with(False) \
.then_should_call_confirmation_token_repo_create_with(False) \
.then_should_call_mailer_with(False) \
.then_should_raise(NoLoggedException())
class ScenarioMaker:
def __init__(self):
self.person_validator = Mock()
self.person_repo = Mock()
self.profile_validator = Mock()
self.profile_repo = Mock()
self.confirmation_token_repo = Mock()
self.mailer_service = Mock()
def given_a_person_validator_that_returns(self, is_correct=False, error=None):
if not is_correct:
self.person_validator.validate.side_effect = error
else:
self.person_validator.validate.return_value = True
return self
def given_a_person_repo_that_returns_on_get(self, person):
if person is False:
self.person_repo.get_person.side_effect = EntityDoesNotExistException()
else:
self.person_repo.get_person.return_value = person
return self
def given_a_person_repo_that_returns_on_update(self, person):
self.person_repo.update_person.return_value = person
return self
def given_a_profile_validator_that_returns(self, is_correct=False, error=None):
if not is_correct:
self.profile_validator.validate.side_effect = error
else:
self.profile_validator.validate.return_value = True
return self
def given_a_profile_repo_that_returns_on_get(self, profile):
if profile is False:
self.profile_repo.get_profile.side_effect = EntityDoesNotExistException()
else:
self.profile_repo.get_profile.return_value = profile
return self
def given_a_confirmation_token_repo_that_returns(self, confirmation_token):
self.confirmation_token_repo.create_confirmation_token.return_value = confirmation_token
return self
def when_execute(self, logged_person_id, username, email):
try:
self.result = RegisterUsernameAndEmailInteractor(
person_repo=self.person_repo, person_validator=self.person_validator,
profile_repo=self.profile_repo, profile_validator=self.profile_validator,
confirmation_token_repo=self.confirmation_token_repo,
mailer_service=self.mailer_service) \
.set_params(logged_person_id=logged_person_id, username=username, email=email).execute()
except Exception as e:
self.error = e
return self
def then_should_call_person_repo_get_with(self, id):
if id is False:
self.person_repo.get_person.assert_not_called()
else:
self.person_repo.get_person.assert_called_once_with(id=id)
return self
def then_should_call_person_validator_with(self, person):
if person is False:
self.person_validator.validate.assert_not_called()
else:
self.person_validator.validate.assert_called_once_with(person)
return self
def then_should_call_profile_repo_get_with(self, person_id, logged_person_id=None):
if person_id is False:
self.profile_repo.get_profile.assert_not_called()
else:
self.profile_repo.get_profile.assert_called_once_with(person_id=person_id,
logged_person_id=logged_person_id)
return self
def then_should_call_profile_validator_with(self, profile):
if profile is False:
self.profile_validator.validate.assert_not_called()
else:
self.profile_validator.validate.assert_called_once_with(profile)
return self
def then_should_call_profile_repo_create_with(self, profile):
if profile is False:
self.profile_repo.create_profile.assert_not_called()
else:
self.profile_repo.create_profile.assert_called_once_with(profile)
return self
def then_should_call_profile_repo_update_with(self, profile):
if profile is False:
self.profile_repo.update_profile.assert_not_called()
else:
self.profile_repo.update_profile.assert_called_once_with(profile)
return self
def then_should_call_person_repo_update_with(self, person):
if person is False:
self.person_repo.update_person.assert_not_called()
else:
self.person_repo.update_person.assert_called_once_with(person)
return self
def then_should_call_confirmation_token_repo_delete_with(self, person_id):
if person_id is False:
self.confirmation_token_repo.delete_confirmation_tokens.assert_not_called()
else:
self.confirmation_token_repo.delete_confirmation_tokens.assert_called_once_with(person_id=person_id)
return self
def then_should_call_confirmation_token_repo_create_with(self, person_id):
if person_id is False:
self.confirmation_token_repo.create_confirmation_token.assert_not_called()
else:
self.confirmation_token_repo.create_confirmation_token.assert_called_once_with(person_id=person_id)
return self
def then_should_call_mailer_with(self, confirmation_token, username=None, email=None):
if confirmation_token is False:
self.mailer_service.send_ask_confirmation_mail.assert_not_called()
else:
self.mailer_service.send_ask_confirmation_mail.assert_called_once_with(
confirmation_token=confirmation_token, username=username, email=email)
return self
def then_should_return(self, result):
assert self.result == result
return self
def then_should_raise(self, error):
assert self.error == error
return self
class TestConfirmEmailInteractor:
def test_confirm_email_returns_person_confirmed(self):
TestConfirmEmailInteractor.ScenarioMaker() \
.given_a_logged_person_id() \
.given_a_confirmation_token() \
.given_a_confirmation_token_repo_that_returns_that_confirmation_token() \
.given_an_updated_person() \
.given_a_person() \
.given_a_person_repo_that_returns_those_persons_on_get_and_update() \
.when_confirm_email_interactor_is_executed() \
.then_should_call_confirmation_token_repo_get_person_id_with_confirmation_token() \
.then_should_delete_all_confirmation_tokens_for_that_person() \
.then_should_call_person_repo_get() \
.then_should_call_person_repo_update_with_is_email_confirmed_true() \
.then_should_return_true()
def test_unauthenticated_raises_unauthorized(self):
TestConfirmEmailInteractor.ScenarioMaker() \
.when_confirm_email_interactor_is_executed() \
.then_should_raise_unauthorized() \
.then_should_not_delete_all_confirmation_tokens_for_that_person() \
.then_should_not_call_person_repo_update()
def test_no_confirmation_token_raises_unauthorized(self):
TestConfirmEmailInteractor.ScenarioMaker() \
.given_a_logged_person_id() \
.given_a_confirmation_token_repo_that_raises_entity_does_not_exist() \
.when_confirm_email_interactor_is_executed() \
.then_should_raise_invalid_params_for_wrong_confirmation_token() \
.then_should_not_delete_all_confirmation_tokens_for_that_person() \
.then_should_not_call_person_repo_update()
def test_not_coincident_person_id_raises_unauthorized(self):
TestConfirmEmailInteractor.ScenarioMaker() \
.given_a_logged_person_id() \
.given_a_confirmation_token_repo_that_returns_another_person_id() \
.when_confirm_email_interactor_is_executed() \
.then_should_raise_invalid_params_for_wrong_confirmation_token() \
.then_should_not_delete_all_confirmation_tokens_for_that_person() \
.then_should_not_call_person_repo_update()
class ScenarioMaker:
def __init__(self):
self.result = None
self.error = None
self.updated_person = None
self.person = None
self.logged_person_id = None
self.confirmation_token = None
self.confirmation_token_repo = Mock()
self.person_repo = Mock()
def given_a_logged_person_id(self):
self.logged_person_id = '2'
return self
def given_a_confirmation_token(self):
self.confirmation_token = 'ABC'
return self
def given_a_confirmation_token_repo_that_returns_that_confirmation_token(self):
self.confirmation_token_repo.get_person_id.return_value = self.logged_person_id
return self
def given_a_confirmation_token_repo_that_returns_another_person_id(self):
self.confirmation_token_repo.get_person_id.return_value = '99'
return self
def given_a_confirmation_token_repo_that_raises_entity_does_not_exist(self):
self.confirmation_token_repo.get_person_id.side_effect = EntityDoesNotExistException()
return self
def given_a_person(self):
self.person = Person(id='4', email='e@m.c', is_email_confirmed=False)
return self
def given_an_updated_person(self):
self.updated_person = Person(id='4', email='e@m.c', is_email_confirmed=True)
return self
def given_a_person_repo_that_returns_those_persons_on_get_and_update(self):
self.person_repo.update_person.return_value = self.updated_person
self.person_repo.get_person.return_value = self.person
return self
def when_confirm_email_interactor_is_executed(self):
try:
interactor = ConfirmEmailInteractor(confirmation_token_repo=self.confirmation_token_repo,
person_repo=self.person_repo)
self.result = interactor.set_params(logged_person_id=self.logged_person_id,
confirmation_token=self.confirmation_token).execute()
except Exception as e:
self.error = e
return self
def then_should_call_confirmation_token_repo_get_person_id_with_confirmation_token(self):
self.confirmation_token_repo.get_person_id \
.assert_called_once_with(confirmation_token=self.confirmation_token)
return self
def then_should_delete_all_confirmation_tokens_for_that_person(self):
self.confirmation_token_repo.delete_confirmation_tokens \
.assert_called_once_with(person_id=self.logged_person_id)
return self
def then_should_call_person_repo_get(self):
self.person_repo.get_person.assert_called_once_with(id=self.logged_person_id)
return self
def then_should_call_person_repo_update_with_is_email_confirmed_true(self):
update_person = Person(id=self.person.id, email=self.person.email, is_email_confirmed=True)
self.person_repo.update_person.assert_called_once_with(update_person)
return self
def then_should_return_true(self):
assert self.result is True
return self
def then_should_raise_unauthorized(self):
assert type(self.error) is NoLoggedException
return self
def then_should_not_delete_all_confirmation_tokens_for_that_person(self):
self.confirmation_token_repo.delete_confirmation_tokens.assert_not_called()
return self
def then_should_not_call_person_repo_update(self):
self.person_repo.update_person.assert_not_called()
return self
def then_should_raise_invalid_params_for_wrong_confirmation_token(self):
assert type(self.error) is InvalidEntityException
assert self.error.source == 'confirmation_token'
assert self.error.code == 'invalid'
assert str(self.error) == 'Invalid confirmation token'
return self
class TestLoginEmailInteractor:
def test_when_email_doesnt_exists(self):
TestLoginEmailInteractor.ScenarioMaker() \
.given_an_email() \
.given_a_person_repo_that_raises_entity_does_not_exist() \
.when_login_email_interactor_executed() \
.then_should_call_get_person_repo_with_the_email() \
.then_should_not_call_login_token_repo() \
.then_should_not_call_mailer_service()
def test_when_email_has_not_been_confirmed(self):
TestLoginEmailInteractor.ScenarioMaker() \
.given_an_email() \
.given_a_person_repo_that_returns_person_without_confirmed_email() \
.when_login_email_interactor_executed() \
.then_should_call_get_person_repo_with_the_email() \
.then_should_not_call_login_token_repo() \
.then_should_not_call_mailer_service()
def test_success(self):
TestLoginEmailInteractor.ScenarioMaker() \
.given_an_email() \
.given_a_person() \
.given_a_person_repo_that_returns_that_person() \
.given_a_profile() \
.given_a_profile_repo_that_returns_that_profile() \
.given_a_login_token() \
.given_a_login_token_repo_that_returns_that_token() \
.when_login_email_interactor_executed() \
.then_should_call_get_person_repo_with_the_email() \
.then_should_call_get_profile_repo_with_the_person_id() \
.then_should_call_delete_login_tokens_with_person_id() \
.then_should_call_create_login_token_with_person_id() \
.then_should_send_mail_with_token_username_to_person_email()
class ScenarioMaker:
def __init__(self):
self.person_repo = Mock()
self.profile_repo = Mock()
self.login_token_repo = Mock()
self.mailer_service = Mock()
def given_an_email(self):
self.email = 'asdf@email.com'
return self
def given_a_person(self):
self.person = Person(id='8', email='e', is_email_confirmed=True)
return self
def given_a_profile(self):
self.profile = Profile(person_id=self.person.id, username='u')
return self
def given_a_login_token(self):
self.login_token = 'ABXZ'
return self
def given_a_person_repo_that_raises_entity_does_not_exist(self):
self.person_repo.get_person.side_effect = EntityDoesNotExistException()
return self
def given_a_person_repo_that_returns_person_without_confirmed_email(self):
self.person_repo.get_person.return_value = Person(id='5', is_email_confirmed=False)
return self
def given_a_person_repo_that_returns_that_person(self):
self.person_repo.get_person.return_value = self.person
return self
def given_a_profile_repo_that_returns_that_profile(self):
self.profile_repo.get_profile.return_value = self.profile
return self
def given_a_login_token_repo_that_returns_that_token(self):
self.login_token_repo.create_login_token.return_value = self.login_token
return self
def when_login_email_interactor_executed(self):
try:
interactor = LoginEmailInteractor(login_token_repo=self.login_token_repo,
person_repo=self.person_repo,
profile_repo=self.profile_repo,
mailer_service=self.mailer_service)
self.result = interactor.set_params(email=self.email).execute()
except Exception as e:
self.error = e
return self
def then_should_call_get_person_repo_with_the_email(self):
self.person_repo.get_person.assert_called_once_with(email=self.email)
return self
def then_should_call_get_profile_repo_with_the_person_id(self):
self.profile_repo.get_profile.assert_called_once_with(person_id=self.person.id,
logged_person_id=self.person.id)
return self
def then_should_not_call_login_token_repo(self):
self.login_token_repo.delete_login_tokens.assert_not_called()
self.login_token_repo.create_login_token.assert_not_called()
return self
def then_should_not_call_mailer_service(self):
self.mailer_service.send_login_mail.assert_not_called()
return self
def then_should_call_delete_login_tokens_with_person_id(self):
self.login_token_repo.delete_login_tokens.assert_called_once_with(person_id=self.person.id)
return self
def then_should_call_create_login_token_with_person_id(self):
self.login_token_repo.create_login_token.assert_called_once_with(person_id=self.person.id)
return self
def then_should_send_mail_with_token_username_to_person_email(self):
self.mailer_service.send_login_mail.assert_called_once_with(login_token=self.login_token,
username=self.profile.username,
email=self.person.email)
return self
class TestLoginInteractor:
def test_returns_auth_token_and_person(self):
TestLoginInteractor.ScenarioMaker() \
.given_a_login_token() \
.given_a_person_id() \
.given_a_login_token_repo_that_returns_that_person_id() \
.given_a_person() \
.given_a_person_repo_that_returns_that_person() \
.given_an_auth_token() \
.given_an_auth_token_repo_that_returns_that_auth_token() \
.when_login_interactor_is_executed() \
.then_should_call_login_token_repo_get_person_id_with_login_token() \
.then_should_call_login_token_repo_delete_login_token_with_person_id() \
.then_should_call_auth_token_repo_get_auth_token_with_person_id() \
.then_should_return_auth_token()
class ScenarioMaker:
def given_a_login_token(self):
self.login_token = 'tra'
return self
def given_a_person_id(self):
self.person_id = '4'
return self
def given_a_login_token_repo_that_returns_that_person_id(self):
self.login_token_repo = Mock()
self.login_token_repo.get_person_id.return_value = self.person_id
return self
def given_a_person(self):
self.person = Person(id='9', email='e')
return self
def given_a_person_repo_that_returns_that_person(self):
self.person_repo = Mock()
self.person_repo.get_person.return_value = self.person
return self
def given_an_auth_token(self):
self.auth_token = AuthToken('9', 'a', 'r')
return self
def given_an_auth_token_repo_that_returns_that_auth_token(self):
self.auth_token_repo = Mock()
self.auth_token_repo.get_auth_token.return_value = self.auth_token
return self
def when_login_interactor_is_executed(self):
self.result = LoginInteractor(self.person_repo, self.auth_token_repo, self.login_token_repo) \
.set_params(login_token=self.login_token).execute()
return self
def then_should_call_login_token_repo_get_person_id_with_login_token(self):
self.login_token_repo.get_person_id.assert_called_once_with(login_token=self.login_token)
return self
def then_should_call_login_token_repo_delete_login_token_with_person_id(self):
self.login_token_repo.delete_login_tokens.assert_called_once_with(person_id=self.person_id)
return self
def then_should_call_auth_token_repo_get_auth_token_with_person_id(self):
self.auth_token_repo.get_auth_token.assert_called_once_with(person_id=self.person_id)
return self
def then_should_return_auth_token(self):
self.result == self.auth_token
return self
class TestBlockIntearctor:
def test_block_interactor_raises_not_logged(self):
TestBlockIntearctor.ScenarioMaker() \
.given_a_permissions_validator_that_raises_no_logged() \
.when_block(logged_person_id='4', target_username='blocked') \
.then_should_call_permissions_validator('4') \
.then_should_not_call_block() \
.then_should_raise_no_logged_exception()
def test_already_blocked_returns_true(self):
TestBlockIntearctor.ScenarioMaker() \
.given_a_permissions_validator_that_validates() \
.given_a_block_repo_that_returns_to_block_exists(True) \
.given_a_profile_repo_that_returns_profile_with_person_id('33') \
.when_block(logged_person_id='4', target_username='blocked') \
.then_should_call_permissions_validator('4') \
.then_should_get_profile_with(username='blocked', logged_person_id='4') \
.then_should_call_block_exists('4', '33') \
.then_should_not_call_block() \
.then_should_return_true()
def test_self_block_raises_conflict_exception(self):
TestBlockIntearctor.ScenarioMaker() \
.given_a_permissions_validator_that_validates() \
.given_a_block_repo_that_returns_to_block_exists(False) \
.given_a_profile_repo_that_returns_profile_with_person_id('4') \
.when_block(logged_person_id='4', target_username='myself') \
.then_should_call_permissions_validator('4') \
.then_should_get_profile_with(username='myself', logged_person_id='4') \
.then_should_not_call_block() \
.then_should_raise_conflict_exception()
def test_block_unsaves_target_id_experiences_block_and_returns_true(self):
TestBlockIntearctor.ScenarioMaker() \
.given_a_permissions_validator_that_validates() \
.given_a_block_repo_that_returns_to_block_exists(False) \
.given_a_block_repo_that_returns_to_block(True) \
.given_a_experience_repo_that_returns([
Experience('t', 'd', id='11', author_id='9'),
Experience('t', 'd', id='12', author_id='33'),
Experience('t', 'd', id='13', author_id='9'),
Experience('t', 'd', id='14', author_id='33'),
Experience('t', 'd', id='15', author_id='9'),
Experience('t', 'd', id='16', author_id='9')]) \
.given_a_profile_repo_that_returns_profile_with_person_id('33') \
.when_block(logged_person_id='4', target_username='blocked') \
.then_should_call_permissions_validator('4') \
.then_should_call_block_exists('4', '33') \
.then_should_get_saved_experiences('4') \
.then_should_get_profile_with(username='blocked', logged_person_id='4') \
.then_should_unsave('4', ['12', '14']) \
.then_should_call_block('4', '33') \
.then_should_return_true()
class ScenarioMaker:
def __init__(self):
self.permissions_validator = Mock()
self.block_repo = Mock()
self.experience_repo = Mock()
self.profile_repo = Mock()
self.unsave_experience_interactor = Mock()
self.unsave_experience_interactor.set_params.return_value = self.unsave_experience_interactor
def given_a_permissions_validator_that_validates(self):
self.permissions_validator.return_value = True
return self
def given_a_permissions_validator_that_raises_no_logged(self):
self.permissions_validator.validate_permissions.side_effect = NoLoggedException()
return self
def given_a_block_repo_that_returns_to_block_exists(self, exists):
self.block_repo.block_exists.return_value = exists
return self
def given_a_block_repo_that_returns_to_block(self, exists):
self.block_repo.block.return_value = exists
return self
def given_a_profile_repo_that_returns_profile_with_person_id(self, person_id):
self.profile_repo.get_profile.return_value = Profile(person_id=person_id)
return self
def given_a_experience_repo_that_returns(self, experiences):
self.experience_repo.get_saved_experiences.return_value = {'results': experiences, 'next_offset': None}
return self
def when_block(self, logged_person_id, target_username):
try:
self.result = BlockInteractor(permissions_validator=self.permissions_validator,
block_repo=self.block_repo,
experience_repo=self.experience_repo,
profile_repo=self.profile_repo,
save_unsave_experience_interactor=self.unsave_experience_interactor) \
.set_params(logged_person_id=logged_person_id, target_username=target_username).execute()
except Exception as e:
self.error = e
return self
def then_should_call_permissions_validator(self, person_id):
self.permissions_validator.validate_permissions.assert_called_once_with(logged_person_id=person_id)
return self
def then_should_call_block_exists(self, creator_id, target_id):
self.block_repo.block_exists.assert_called_once_with(creator_id=creator_id, target_id=target_id)
return self
def then_should_not_call_block(self):
self.block_repo.block.assert_not_called()
return self
def then_should_get_saved_experiences(self, person_id):
self.experience_repo.get_saved_experiences.assert_called_once_with(logged_person_id=person_id,
offset=0, limit=1000000)
return self
def then_should_unsave(self, person_id, experiences_ids):
self.unsave_experience_interactor.set_params.assert_has_calls(
[call(action=SaveUnsaveExperienceInteractor.Action.UNSAVE,
experience_id=id, logged_person_id=person_id) for id in experiences_ids])
self.unsave_experience_interactor.execute.assert_has_calls([call() for id in experiences_ids])
return self
def then_should_call_block(self, creator_id, target_id):
self.block_repo.block.assert_called_once_with(creator_id=creator_id, target_id=target_id)
return self
def then_should_get_profile_with(self, username, logged_person_id):
self.profile_repo.get_profile.assert_called_once_with(username=username, logged_person_id=logged_person_id)
return self
def then_should_raise_no_logged_exception(self):
assert type(self.error) is NoLoggedException
return self
def then_should_raise_conflict_exception(self):
assert type(self.error) is ConflictException
assert self.error == ConflictException(source='person', code='conflict', message='Cannot block yourself')
return self
def then_should_return_true(self):
assert self.result is True
return self
| 48.700986 | 119 | 0.662918 | 5,178 | 44,464 | 5.166667 | 0.039784 | 0.059059 | 0.051284 | 0.033043 | 0.855829 | 0.810862 | 0.738347 | 0.672672 | 0.602736 | 0.522259 | 0 | 0.003405 | 0.266868 | 44,464 | 912 | 120 | 48.754386 | 0.817289 | 0 | 0 | 0.507916 | 0 | 0 | 0.011088 | 0 | 0 | 0 | 0 | 0 | 0.091029 | 1 | 0.174142 | false | 0 | 0.009235 | 0 | 0.33905 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
d7cd08be50fbb6ec043afec48e804c3df3c2bfc8 | 1,246 | py | Python | graph/grid.py | KodeWorker/CircuitRouter | 7428f2fa0631bfaa541ec8df61c8a0e14b2a2963 | [
"Apache-2.0"
] | null | null | null | graph/grid.py | KodeWorker/CircuitRouter | 7428f2fa0631bfaa541ec8df61c8a0e14b2a2963 | [
"Apache-2.0"
] | null | null | null | graph/grid.py | KodeWorker/CircuitRouter | 7428f2fa0631bfaa541ec8df61c8a0e14b2a2963 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
"""Basic Grid
description:
content:
- SquareGrid
- GridWithWeights
reference:
1. https://www.redblobgames.com/pathfinding/a-star/implementation.html
author: Shin-Fu (Kelvin) Wu
latest update: 2019/05/10
"""
class SquareGrid(object):
def __init__(self, width, height):
""" Square Grid
"""
self.width = width
self.height = height
self.walls = set()
def in_bounds(self, pos):
(x, y) = pos
return 0 <= x < self.width and 0 <= y < self.height
def passable(self, id):
return id not in self.walls
def neighbors(self, pos):
(x, y) = pos
results = [(x+1, y), (x, y-1), (x-1, y), (x, y+1)]
if (x + y) % 2 == 0: results.reverse() # aesthetics
results = list(filter(self.in_bounds, results))
results = list(filter(self.passable, results))
return results
class GridWithWeights(SquareGrid):
def __init__(self, width, height):
""" Square Grid with Weights
"""
super(GridWithWeights, self).__init__(width, height)
self.weights = {}
def cost(self, from_node, to_node):
return self.weights.get(to_node, 1) | 25.428571 | 74 | 0.568218 | 154 | 1,246 | 4.487013 | 0.435065 | 0.014472 | 0.031838 | 0.04631 | 0.144718 | 0.109986 | 0.092619 | 0 | 0 | 0 | 0 | 0.021615 | 0.294543 | 1,246 | 49 | 75 | 25.428571 | 0.764505 | 0.260835 | 0 | 0.173913 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.26087 | false | 0.086957 | 0 | 0.086957 | 0.521739 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
d7cf4fa3f1fddd1db79d8afe6c03e493b6fd7ad7 | 651 | py | Python | survol/sources_types/mysql/session/__init__.py | AugustinMascarelli/survol | 7a822900e82d1e6f016dba014af5741558b78f15 | [
"BSD-3-Clause"
] | null | null | null | survol/sources_types/mysql/session/__init__.py | AugustinMascarelli/survol | 7a822900e82d1e6f016dba014af5741558b78f15 | [
"BSD-3-Clause"
] | null | null | null | survol/sources_types/mysql/session/__init__.py | AugustinMascarelli/survol | 7a822900e82d1e6f016dba014af5741558b78f15 | [
"BSD-3-Clause"
] | null | null | null | """
MySql session
"""
import lib_common
from sources_types import mysql as survol_mysql
from sources_types.mysql import instance as survol_mysql_instance
def EntityOntology():
return ( ["Instance","Id",], )
def MakeUri(instanceName,sessionId):
return lib_common.gUriGen.UriMakeFromDict("mysql/session", { "Instance": instanceName, "Id": sessionId } )
def EntityName(entity_ids_arr):
return "Session:"+entity_ids_arr[1]+ "@" + entity_ids_arr[0]
def AddInfo(grph,node,entity_ids_arr):
instanceMySql = entity_ids_arr[0]
nodeInstance = survol_mysql_instance.MakeUri(instanceMySql)
grph.add((node,lib_common.MakeProp("Instance"),nodeInstance))
| 28.304348 | 107 | 0.777266 | 84 | 651 | 5.785714 | 0.392857 | 0.092593 | 0.123457 | 0.053498 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005102 | 0.096774 | 651 | 22 | 108 | 29.590909 | 0.821429 | 0.019969 | 0 | 0 | 0 | 0 | 0.079491 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.307692 | false | 0 | 0.230769 | 0.230769 | 0.769231 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
d7d4fb4dc9009313d2d7ca8b84ab7f025438f452 | 922 | py | Python | infoblox_netmri/api/remote/models/device_route_network_explorer_summaries_section_grid_remote.py | infobloxopen/infoblox_netmri | aa1c744df7e439dbe163bb9edd165e4e85a9771b | [
"Apache-2.0"
] | 12 | 2016-02-19T12:37:54.000Z | 2022-03-04T20:11:08.000Z | infoblox_netmri/api/remote/models/device_route_network_explorer_summaries_section_grid_remote.py | infobloxopen/infoblox_netmri | aa1c744df7e439dbe163bb9edd165e4e85a9771b | [
"Apache-2.0"
] | 18 | 2015-11-12T18:37:00.000Z | 2021-05-19T07:59:55.000Z | infoblox_netmri/api/remote/models/device_route_network_explorer_summaries_section_grid_remote.py | infobloxopen/infoblox_netmri | aa1c744df7e439dbe163bb9edd165e4e85a9771b | [
"Apache-2.0"
] | 18 | 2016-01-07T12:04:34.000Z | 2022-03-31T11:05:41.000Z | from ..remote import RemoteModel
class DeviceRouteNetworkExplorerSummariesSectionGridRemote(RemoteModel):
"""
| ``DeviceRouteID:`` none
| ``attribute type:`` string
| ``DeviceID:`` none
| ``attribute type:`` string
| ``RouteProto:`` none
| ``attribute type:`` string
| ``RouteCIDR:`` none
| ``attribute type:`` string
| ``VirtualNetworkID:`` none
| ``attribute type:`` string
| ``Network:`` none
| ``attribute type:`` string
| ``route_count:`` none
| ``attribute type:`` string
| ``route_numeric:`` none
| ``attribute type:`` string
"""
properties = ("DeviceRouteID",
"DeviceID",
"RouteProto",
"RouteCIDR",
"VirtualNetworkID",
"Network",
"route_count",
"route_numeric",
)
| 20.954545 | 72 | 0.502169 | 60 | 922 | 7.65 | 0.333333 | 0.22658 | 0.296296 | 0.400871 | 0.122004 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.352495 | 922 | 43 | 73 | 21.44186 | 0.768844 | 0.482646 | 0 | 0 | 0 | 0 | 0.219144 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.090909 | 0 | 0.272727 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cc0583c5450565d12db0939917e61aaeeefaba64 | 1,139 | py | Python | app/questionnaire/routing_path.py | petechd/eq-questionnaire-runner | 1c5b182a7f8bc878cfdd767ae080410fa679abd6 | [
"MIT"
] | 3 | 2020-09-28T13:21:21.000Z | 2021-05-05T14:14:51.000Z | app/questionnaire/routing_path.py | petechd/eq-questionnaire-runner | 1c5b182a7f8bc878cfdd767ae080410fa679abd6 | [
"MIT"
] | 402 | 2019-11-06T17:23:03.000Z | 2022-03-31T16:03:35.000Z | app/questionnaire/routing_path.py | petechd/eq-questionnaire-runner | 1c5b182a7f8bc878cfdd767ae080410fa679abd6 | [
"MIT"
] | 10 | 2020-03-03T14:23:27.000Z | 2022-01-31T12:21:21.000Z | class RoutingPath:
"""Holds a list of block_ids and has section_id, list_item_id and list_name attributes"""
def __init__(self, block_ids, section_id, list_item_id=None, list_name=None):
self.block_ids = tuple(block_ids)
self.section_id = section_id
self.list_item_id = list_item_id
self.list_name = list_name
def __len__(self):
return len(self.block_ids)
def __getitem__(self, index):
return self.block_ids[index]
def __iter__(self):
return iter(self.block_ids)
def __reversed__(self):
return reversed(self.block_ids)
def __eq__(self, other):
if isinstance(other, RoutingPath):
return (
self.block_ids == other.block_ids
and self.section_id == other.section_id
and self.list_item_id == other.list_item_id
and self.list_name == other.list_name
)
if isinstance(other, list):
return self.block_ids == tuple(other)
return self.block_ids == other
def index(self, *args):
return self.block_ids.index(*args)
| 29.973684 | 93 | 0.625988 | 152 | 1,139 | 4.289474 | 0.203947 | 0.159509 | 0.184049 | 0.138037 | 0.199387 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.286216 | 1,139 | 37 | 94 | 30.783784 | 0.801968 | 0.072871 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.259259 | false | 0 | 0 | 0.185185 | 0.592593 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
cc0e17f8ef10a219e415be4feecaf2e78255318a | 20,279 | py | Python | unittests/test_KappaComplex.py | hmedina/KaSaAn | 83e4e31ff0e0062762aacfbc65bbdd290808bb51 | [
"MIT"
] | 1 | 2020-05-11T14:31:54.000Z | 2020-05-11T14:31:54.000Z | unittests/test_KappaComplex.py | hmedina/KaSaAn | 83e4e31ff0e0062762aacfbc65bbdd290808bb51 | [
"MIT"
] | 4 | 2017-08-31T11:16:08.000Z | 2020-07-10T22:31:45.000Z | unittests/test_KappaComplex.py | hmedina/KaSaAn | 83e4e31ff0e0062762aacfbc65bbdd290808bb51 | [
"MIT"
] | 2 | 2018-02-06T20:53:26.000Z | 2019-05-11T18:05:38.000Z | #!/usr/bin/env python3
import unittest
from KaSaAn.core import KappaComplex, KappaAgent
class TestKappaComplex(unittest.TestCase):
"""Testing various elements of KappaComplex representation."""
def test_string_representation(self):
self.assertEqual(str(KappaComplex('_a(s1[1]), ~b(~a[1], bob[2]), bob(~b[2])')),
'_a(s1[1]{#}), bob(~b[2]{#}), ~b(bob[2]{#} ~a[1]{#})')
def test_get_number_of_bonds(self):
self.assertEqual(KappaComplex('_a(s1[1]{#}), bob(~b[2]{#}), ~b(bob[2]{#} ~a[1]{#})').get_number_of_bonds(), 2)
def test_get_size_of_complex(self):
self.assertEqual(KappaComplex('_a(s1[1]{#}), bob(~b[3]{#}), ~b(bob[2]{#} ~a[1]{#})').get_size_of_complex(), 3)
self.assertEqual(KappaComplex(
'Ah(a[.] b[.] c[1] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Ac(a[.] b[.] c[.] d[.] e[2] f[3] g[.] h[1] i[4] j[.] k[.] l[.] m[5] n[.] o[.] p[6] q[7] r[.] s[8] t[.] u[.] v[9] w[.] x[.] y[.] z[.]),Ae(a[.] b[.] c[2] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Af(a[.] b[.] c[3] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Ai(a[.] b[.] c[4] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Am(a[.] b[.] c[5] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Ap(a[.] b[.] c[6] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Aq(a[.] b[.] c[7] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),As(a[.] b[.] c[8] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Av(a[.] b[.] c[9] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.])').
get_size_of_complex(), 10)
def test_get_agent_types(self):
self.assertEqual(KappaComplex('_a(s1[1]{#}), bob(~b[3]{#}), ~b(bob[2]{#} ~a[1]{#})').get_agent_types(),
{KappaAgent('_a'), KappaAgent('~b'), KappaAgent('bob')})
self.assertEqual(KappaComplex('_a(s1[1]{#}), _a(~b[3]{#}), _a(bob[2]{#} ~a[1]{#})').get_agent_types(),
{KappaAgent('_a')})
def test_get_all_agents(self):
self.assertCountEqual(KappaComplex(
'Ah(a[.] b[.] c[1] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Ac(a[.] b[.] c[.] d[.] e[2] f[3] g[.] h[1] i[4] j[.] k[.] l[.] m[5] n[.] o[.] p[6] q[7] r[.] s[8] t[.] u[.] v[9] w[.] x[.] y[.] z[.]),Ae(a[.] b[.] c[2] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Af(a[.] b[.] c[3] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Ai(a[.] b[.] c[4] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Am(a[.] b[.] c[5] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Ap(a[.] b[.] c[6] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Aq(a[.] b[.] c[7] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),As(a[.] b[.] c[8] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Av(a[.] b[.] c[9] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.])').
get_all_agents(),
[KappaAgent('Ac(a[.]{#} b[.]{#} c[.]{#} d[.]{#} e[2]{#} f[3]{#} g[.]{#} h[1]{#} i[4]{#} j[.]{#} k[.]{#} l[.]{#} m[5]{#} n[.]{#} o[.]{#} p[6]{#} q[7]{#} r[.]{#} s[8]{#} t[.]{#} u[.]{#} v[9]{#} w[.]{#} x[.]{#} y[.]{#} z[.]{#})'),
KappaAgent('Ae(a[.]{#} b[.]{#} c[2]{#} d[.]{#} e[.]{#} f[.]{#} g[.]{#} h[.]{#} i[.]{#} j[.]{#} k[.]{#} l[.]{#} m[.]{#} n[.]{#} o[.]{#} p[.]{#} q[.]{#} r[.]{#} s[.]{#} t[.]{#} u[.]{#} v[.]{#} w[.]{#} x[.]{#} y[.]{#} z[.]{#})'),
KappaAgent('Af(a[.]{#} b[.]{#} c[3]{#} d[.]{#} e[.]{#} f[.]{#} g[.]{#} h[.]{#} i[.]{#} j[.]{#} k[.]{#} l[.]{#} m[.]{#} n[.]{#} o[.]{#} p[.]{#} q[.]{#} r[.]{#} s[.]{#} t[.]{#} u[.]{#} v[.]{#} w[.]{#} x[.]{#} y[.]{#} z[.]{#})'),
KappaAgent('Ah(a[.]{#} b[.]{#} c[1]{#} d[.]{#} e[.]{#} f[.]{#} g[.]{#} h[.]{#} i[.]{#} j[.]{#} k[.]{#} l[.]{#} m[.]{#} n[.]{#} o[.]{#} p[.]{#} q[.]{#} r[.]{#} s[.]{#} t[.]{#} u[.]{#} v[.]{#} w[.]{#} x[.]{#} y[.]{#} z[.]{#})'),
KappaAgent('Ai(a[.]{#} b[.]{#} c[4]{#} d[.]{#} e[.]{#} f[.]{#} g[.]{#} h[.]{#} i[.]{#} j[.]{#} k[.]{#} l[.]{#} m[.]{#} n[.]{#} o[.]{#} p[.]{#} q[.]{#} r[.]{#} s[.]{#} t[.]{#} u[.]{#} v[.]{#} w[.]{#} x[.]{#} y[.]{#} z[.]{#})'),
KappaAgent('Am(a[.]{#} b[.]{#} c[5]{#} d[.]{#} e[.]{#} f[.]{#} g[.]{#} h[.]{#} i[.]{#} j[.]{#} k[.]{#} l[.]{#} m[.]{#} n[.]{#} o[.]{#} p[.]{#} q[.]{#} r[.]{#} s[.]{#} t[.]{#} u[.]{#} v[.]{#} w[.]{#} x[.]{#} y[.]{#} z[.]{#})'),
KappaAgent('Ap(a[.]{#} b[.]{#} c[6]{#} d[.]{#} e[.]{#} f[.]{#} g[.]{#} h[.]{#} i[.]{#} j[.]{#} k[.]{#} l[.]{#} m[.]{#} n[.]{#} o[.]{#} p[.]{#} q[.]{#} r[.]{#} s[.]{#} t[.]{#} u[.]{#} v[.]{#} w[.]{#} x[.]{#} y[.]{#} z[.]{#})'),
KappaAgent('Aq(a[.]{#} b[.]{#} c[7]{#} d[.]{#} e[.]{#} f[.]{#} g[.]{#} h[.]{#} i[.]{#} j[.]{#} k[.]{#} l[.]{#} m[.]{#} n[.]{#} o[.]{#} p[.]{#} q[.]{#} r[.]{#} s[.]{#} t[.]{#} u[.]{#} v[.]{#} w[.]{#} x[.]{#} y[.]{#} z[.]{#})'),
KappaAgent('As(a[.]{#} b[.]{#} c[8]{#} d[.]{#} e[.]{#} f[.]{#} g[.]{#} h[.]{#} i[.]{#} j[.]{#} k[.]{#} l[.]{#} m[.]{#} n[.]{#} o[.]{#} p[.]{#} q[.]{#} r[.]{#} s[.]{#} t[.]{#} u[.]{#} v[.]{#} w[.]{#} x[.]{#} y[.]{#} z[.]{#})'),
KappaAgent('Av(a[.]{#} b[.]{#} c[9]{#} d[.]{#} e[.]{#} f[.]{#} g[.]{#} h[.]{#} i[.]{#} j[.]{#} k[.]{#} l[.]{#} m[.]{#} n[.]{#} o[.]{#} p[.]{#} q[.]{#} r[.]{#} s[.]{#} t[.]{#} u[.]{#} v[.]{#} w[.]{#} x[.]{#} y[.]{#} z[.]{#})')])
def test_get_complex_composition(self):
self.assertEqual(KappaComplex(
'Ah(a[.] b[.] c[1] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Ac(a[.] b[.] c[.] d[.] e[2] f[3] g[.] h[1] i[4] j[.] k[.] l[.] m[5] n[.] o[.] p[6] q[7] r[.] s[8] t[.] u[.] v[9] w[.] x[.] y[.] z[.]),Ae(a[.] b[.] c[2] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Af(a[.] b[.] c[3] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Ai(a[.] b[.] c[4] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Am(a[.] b[.] c[5] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Ap(a[.] b[.] c[6] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Aq(a[.] b[.] c[7] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),As(a[.] b[.] c[8] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.]),Av(a[.] b[.] c[9] d[.] e[.] f[.] g[.] h[.] i[.] j[.] k[.] l[.] m[.] n[.] o[.] p[.] q[.] r[.] s[.] t[.] u[.] v[.] w[.] x[.] y[.] z[.])').
get_complex_composition(),
{KappaAgent('Ae()'): 1, KappaAgent('Ah()'): 1, KappaAgent('Ap()'): 1,
KappaAgent('Ai()'): 1, KappaAgent('Ac()'): 1, KappaAgent('Af()'): 1,
KappaAgent('As()'): 1, KappaAgent('Aq()'): 1, KappaAgent('Am()'): 1,
KappaAgent('Av()'): 1})
def test_get_number_of_embeddings_of_agent(self):
self.assertEqual(KappaComplex('Bob(bob[.]), bob(bob{ph}), jane(bob{un}[_])').
get_number_of_embeddings_of_agent('Bob'), 1)
self.assertEqual(KappaComplex('Bob(bob[.]), bob(bob{ph}), jane(bob{un}[_])').
get_number_of_embeddings_of_agent('bob'), 1)
self.assertEqual(KappaComplex('Bob(bob[.]), bob(bob{ph}), jane(bob{un}[_])').
get_number_of_embeddings_of_agent('bob(bob[#])'), 1)
self.assertEqual(KappaComplex('Bob(bob[.]), bob(bob{ph}), jane(bob{un}[_])').
get_number_of_embeddings_of_agent('jane(bob{#})'), 1)
def test_get_number_of_embeddings_of_complex(self):
t1 = KappaComplex(
'A(b[1]), B(a[1], b[2]{b}, c[4]), B(a[6], b[2]{a}, ba[3], bb[3], c[5]), C(b1[4]{s1}, b2[5]), A(b[6])')
t2 = KappaComplex('A(b[1]), B(a[1])')
t3 = KappaComplex('B(b[1]), B(b[1])')
t4 = KappaComplex('B(b[1]{a}), B(b[1])')
t5 = KappaComplex('B(b[1]{b}), B(b[1])')
t6 = KappaComplex('Bob(h[3], t[1]), Bob(h[1], t[2]), Bob(h[2], t[3])')
t7 = KappaComplex('A(h[4], t[1]), A(h[1], t[2]), A(h[2], t[3], b[5]), A(h[3], t[4], b[6]), B(a[5]), B(a[6], s{r})')
self.assertEqual(0, t2.get_number_of_embeddings_of_complex(t3))
self.assertEqual(2, t1.get_number_of_embeddings_of_complex(t2))
self.assertEqual(1, t1.get_number_of_embeddings_of_complex(t3))
self.assertEqual(2, t1.get_number_of_embeddings_of_complex(t3, False))
self.assertEqual(1, t1.get_number_of_embeddings_of_complex(t4))
self.assertEqual(1, t1.get_number_of_embeddings_of_complex(t5))
self.assertEqual(1, t3.get_number_of_embeddings_of_complex(t3))
self.assertEqual(2, t3.get_number_of_embeddings_of_complex(t3, False))
self.assertEqual(1, t6.get_number_of_embeddings_of_complex(t6))
self.assertEqual(3, t6.get_number_of_embeddings_of_complex(t6, False))
self.assertEqual(1, t7.get_number_of_embeddings_of_complex(t7))
self.assertEqual(1, t7.get_number_of_embeddings_of_complex(KappaComplex('A(h[4], t[1]), A(h[1], t[2]), A(h[2], t[3]), A(h[3], t[4])')))
self.assertEqual(4, t7.get_number_of_embeddings_of_complex(KappaComplex('A(h[4], t[1]), A(h[1], t[2]), A(h[2], t[3]), A(h[3], t[4])'), False))
self.assertEqual(2, t7.get_number_of_embeddings_of_complex(KappaComplex('A(h[41], t[11]), A(h[11], t[21]), A(h[21], t[31]), A(h[31], t[41], b[91]), B(a[91])')))
self.assertEqual(2, t7.get_number_of_embeddings_of_complex(KappaComplex('A(h[41], t[11]), A(h[11], t[21]), A(h[21], t[31]), A(h[31], t[41], b[91]), B(a[91])'), False))
self.assertEqual(1, t7.get_number_of_embeddings_of_complex(KappaComplex('A(h[41], t[11]), A(h[11], t[21]), A(h[21], t[31]), A(h[31], t[41], b[91]), B(a[91], s{r})')))
self.assertEqual(0, t7.get_number_of_embeddings_of_complex(KappaComplex('A(h[41], t[11]), A(h[11], t[21]), A(h[21], t[31]), A(h[31], t[41], b[91]), B(a[91], s{x})')))
self.assertEqual(2, t7.get_number_of_embeddings_of_complex(KappaComplex('A(b[9]), B(a[9])')))
self.assertEqual(2, t7.get_number_of_embeddings_of_complex(KappaComplex('A(b[9]), B(a[9])'), False))
def test_get_number_of_embeddings(self):
t0 = KappaComplex(
'A(b[1]), B(a[1], b[2]{b}, c[4]), B(a[6], b[2]{a}, ba[3], bb[3], c[5]), C(b1[4]{s1}, b2[5]), A(b[6])')
c1 = KappaComplex('A(b[1]), B(a[1])')
s1 = 'A(b[1]), B(a[1])'
a2 = KappaAgent('B(b[_])')
s2 = 'B(b[_])'
self.assertEqual(t0.get_number_of_embeddings(c1), t0.get_number_of_embeddings(s1))
self.assertEqual(t0.get_number_of_embeddings(a2), t0.get_number_of_embeddings(s2))
def test_get_agent_identifiers(self):
self.assertTrue(33 in KappaComplex('x22:A(s[2]), x33:A(s[1])').get_agent_identifiers())
self.assertTrue(22 in KappaComplex('x22:A(s[2]), x33:A(s[1])').get_agent_identifiers())
self.assertCountEqual([22, 33], KappaComplex('x22:A(s[2]), x33:A(s[1])').get_agent_identifiers())
self.assertFalse(5 in KappaComplex('x22:A(s[2]), x33:A(s[1])').get_agent_identifiers())
self.assertEqual([], KappaComplex('A(s[2]), A(s[1])').get_agent_identifiers())
def test_to_networkx(self):
unlabeled_snap = KappaComplex('A(b[1]), B(a[1] c[2]), C(b[2])')
unlabeled_snap_ref_nodes = [(0, {'kappa': KappaAgent("A(b[1]{#})")}),
(1, {'kappa': KappaAgent("B(a[1]{#} c[2]{#})")}),
(2, {'kappa': KappaAgent("C(b[2]{#})")})]
self.assertEqual(list(unlabeled_snap.to_networkx().nodes().items()), unlabeled_snap_ref_nodes)
self.assertEqual(list(unlabeled_snap.to_networkx().edges()), [(0, 1), (1, 2)])
labeled_snap = KappaComplex('x0:A(b[1]), x8:B(a[1] c[2]), x36:C(b[2])')
labeled_snap_ref_nodes = [(0, {'kappa': KappaAgent("x0:A(b[1]{#})")}),
(36, {'kappa': KappaAgent("x36:C(b[2]{#})")}),
(8, {'kappa': KappaAgent("x8:B(a[1]{#} c[2]{#})")})]
self.assertEqual(list(labeled_snap.to_networkx().nodes().items()), labeled_snap_ref_nodes)
self.assertEqual(list(labeled_snap.to_networkx().edges()), [(0, 8), (36, 8)])
def test_to_cytoscape_cx(self):
ref_structure = [{'metaData': [{'name': 'nodes', 'version': '1.0'},
{'name': 'nodeAttributes', 'version': '1.0'},
{'name': 'edges', 'version': '1.0'},
{'name': 'edgeAttributes', 'version': '1.0'},
{'name': 'cyTablecolumn', 'version': '1.0'},
{'name': 'networkAttributes', 'version': '1.0'}]}, {
'cyTableColumn': [{'applies_to': 'node_table', 'n': 'name'},
{'applies_to': 'node_table', 'n': 'raw_expression'},
{'applies_to': 'edge_table', 'n': 'name'},
{'applies_to': 'edge_table', 'n': 's_agent_type'},
{'applies_to': 'edge_table', 'n': 't_agent_type'},
{'applies_to': 'edge_table', 'n': 's_port_name'},
{'applies_to': 'edge_table', 'n': 't_port_name'},
{'applies_to': 'edge_table', 'n': 'ident_in_snap'},
{'applies_to': 'network_table', 'n': 'name'}]},
{'networkAttributes': [{'n': 'name', 'v': 'network'}]}, {
'nodes': [{'@id': 0, 'n': 'A'}, {'@id': 1, 'n': 'A'}, {'@id': 2, 'n': 'A'},
{'@id': 3, 'n': 'A'}, {'@id': 4, 'n': 'B'}, {'@id': 5, 'n': 'B'},
{'@id': 6, 'n': 'C'}]}, {
'edges': [{'s': 0, 't': 1, '@id': 7}, {'s': 0, 't': 3, '@id': 8},
{'s': 1, 't': 2, '@id': 9}, {'s': 2, 't': 3, '@id': 10},
{'s': 2, 't': 4, '@id': 11}, {'s': 4, 't': 5, '@id': 12},
{'s': 5, 't': 6, '@id': 13}]}, {
'nodeAttributes': [{'po': 0, 'n': 'raw_expression', 'v': 'A(a[1]{ub} b[2]{#} c[.]{#})'},
{'po': 1, 'n': 'raw_expression', 'v': 'A(a[2]{ph} b[3]{#} c[.]{#})'},
{'po': 2, 'n': 'raw_expression', 'v': 'A(a[3]{ph} b[4]{#} c[5]{#})'},
{'po': 3, 'n': 'raw_expression', 'v': 'A(a[4]{ph} b[1]{#} c[.]{#})'},
{'po': 4, 'n': 'raw_expression', 'v': 'B(b[6]{#} c[5]{ub})'},
{'po': 5, 'n': 'raw_expression', 'v': 'B(b[6]{#} c[7]{ph})'},
{'po': 6, 'n': 'raw_expression', 'v': 'C(b[7]{#})'}]}, {
'edgeAttributes': [{'po': 7, 'n': 's_agent_type', 'v': 'A'},
{'po': 7, 'n': 't_agent_type', 'v': 'A'},
{'po': 7, 'n': 's_port_name', 'v': 'b'},
{'po': 7, 'n': 't_port_name', 'v': 'a'},
{'po': 7, 'n': 'ident_in_snap', 'v': '2'},
{'po': 8, 'n': 's_agent_type', 'v': 'A'},
{'po': 8, 'n': 't_agent_type', 'v': 'A'},
{'po': 8, 'n': 's_port_name', 'v': 'a'},
{'po': 8, 'n': 't_port_name', 'v': 'b'},
{'po': 8, 'n': 'ident_in_snap', 'v': '1'},
{'po': 9, 'n': 's_agent_type', 'v': 'A'},
{'po': 9, 'n': 't_agent_type', 'v': 'A'},
{'po': 9, 'n': 's_port_name', 'v': 'b'},
{'po': 9, 'n': 't_port_name', 'v': 'a'},
{'po': 9, 'n': 'ident_in_snap', 'v': '3'},
{'po': 10, 'n': 's_agent_type', 'v': 'A'},
{'po': 10, 'n': 't_agent_type', 'v': 'A'},
{'po': 10, 'n': 's_port_name', 'v': 'b'},
{'po': 10, 'n': 't_port_name', 'v': 'a'},
{'po': 10, 'n': 'ident_in_snap', 'v': '4'},
{'po': 11, 'n': 's_agent_type', 'v': 'A'},
{'po': 11, 'n': 't_agent_type', 'v': 'B'},
{'po': 11, 'n': 's_port_name', 'v': 'c'},
{'po': 11, 'n': 't_port_name', 'v': 'c'},
{'po': 11, 'n': 'ident_in_snap', 'v': '5'},
{'po': 12, 'n': 's_agent_type', 'v': 'B'},
{'po': 12, 'n': 't_agent_type', 'v': 'B'},
{'po': 12, 'n': 's_port_name', 'v': 'b'},
{'po': 12, 'n': 't_port_name', 'v': 'b'},
{'po': 12, 'n': 'ident_in_snap', 'v': '6'},
{'po': 13, 'n': 's_agent_type', 'v': 'B'},
{'po': 13, 'n': 't_agent_type', 'v': 'C'},
{'po': 13, 'n': 's_port_name', 'v': 'c'},
{'po': 13, 'n': 't_port_name', 'v': 'b'},
{'po': 13, 'n': 'ident_in_snap', 'v': '7'}]},
{'status': [{'error': '', 'success': True}]}]
test_complex = KappaComplex("A(a[1]{ub} b[2]{#} c[.]{#}), A(a[2]{ph} b[3]{#} c[.]{#}), A(a[3]{ph} b[4]{#} c[5]{#}), A(a[4]{ph} b[1]{#} c[.]{#}), B(b[6]{#} c[5]{ub}), B(b[6]{#} c[7]{ph}), C(b[7]{#})")
self.assertEqual(test_complex.to_cytoscape_cx(), ref_structure)
| 105.072539 | 1,355 | 0.347749 | 2,883 | 20,279 | 2.325702 | 0.056191 | 0.016406 | 0.017897 | 0.023863 | 0.7478 | 0.699776 | 0.646085 | 0.518867 | 0.490529 | 0.4783 | 0 | 0.040014 | 0.30248 | 20,279 | 192 | 1,356 | 105.619792 | 0.434005 | 0.003846 | 0 | 0.063218 | 0 | 0.183908 | 0.473484 | 0 | 0 | 0 | 0 | 0 | 0.247126 | 1 | 0.068966 | false | 0 | 0.011494 | 0 | 0.086207 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
cc2392067821e7811b20a96b7d78426c9fa889f0 | 502 | py | Python | Python/SampleScripts/PresidentsXml.py | tduoth/JsObjects | eb3e2a8b1f47d0da53c8b1a85a7949269711932f | [
"MIT"
] | 22 | 2015-02-26T09:07:18.000Z | 2020-05-10T16:22:05.000Z | Python/SampleScripts/PresidentsXml.py | tduoth/JsObjects | eb3e2a8b1f47d0da53c8b1a85a7949269711932f | [
"MIT"
] | 123 | 2016-04-05T18:32:41.000Z | 2022-03-13T21:09:21.000Z | Python/SampleScripts/PresidentsXml.py | tduoth/JsObjects | eb3e2a8b1f47d0da53c8b1a85a7949269711932f | [
"MIT"
] | 56 | 2015-03-19T22:26:37.000Z | 2021-12-06T02:52:02.000Z | #!/usr/bin/python
import MySQLdb;
import cgi
print "Content-type: text/xml"
print
print "<?xml version='1.0'?>"
print "<presidents>"
db = MySQLdb.connect(host="localhost", user="MyName", passwd="MyPassword", db="MyDatabase")
cursor = db.cursor()
cursor.execute("select first, last from presidents")
rows = cursor.fetchall()
for row in rows:
print "\t<president>"
print "\t\t<first>%s</first>" % (row[0])
print "\t\t<last>%s</last>" % (row[1])
print "\t</president>"
print "</presidents>"
| 25.1 | 91 | 0.665339 | 72 | 502 | 4.638889 | 0.527778 | 0.071856 | 0.08982 | 0.11976 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009112 | 0.125498 | 502 | 19 | 92 | 26.421053 | 0.751708 | 0.031873 | 0 | 0 | 0 | 0 | 0.421488 | 0.043388 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.0625 | 0.125 | null | null | 0.5625 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 3 |
cc2c021acc889a72c99033aea8e9c6989be7031f | 91 | py | Python | WarioEditor/toolkits/default/testFiles.py | McMasterRS/WARIO-Editor | 49156de97497e8457eb8a924256118a8f7fb5597 | [
"MIT"
] | 1 | 2020-09-05T05:45:14.000Z | 2020-09-05T05:45:14.000Z | WarioEditor/toolkits/default/testFiles.py | McMasterRS/WARIO-Editor | 49156de97497e8457eb8a924256118a8f7fb5597 | [
"MIT"
] | null | null | null | WarioEditor/toolkits/default/testFiles.py | McMasterRS/WARIO-Editor | 49156de97497e8457eb8a924256118a8f7fb5597 | [
"MIT"
] | null | null | null | from wario import Node
class testFiles(Node):
done = False
def process():
| 15.166667 | 22 | 0.615385 | 11 | 91 | 5.090909 | 0.909091 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.307692 | 91 | 6 | 23 | 15.166667 | 0.888889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.25 | null | null | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
0bcca5312461bf2219cc17cb090d29fed7378b49 | 159 | py | Python | src/hello-world.py | manish-panwar/python-examples | 6ca66a559e489a226ebc0b951ae909fb95f6fcae | [
"Apache-2.0"
] | null | null | null | src/hello-world.py | manish-panwar/python-examples | 6ca66a559e489a226ebc0b951ae909fb95f6fcae | [
"Apache-2.0"
] | null | null | null | src/hello-world.py | manish-panwar/python-examples | 6ca66a559e489a226ebc0b951ae909fb95f6fcae | [
"Apache-2.0"
] | null | null | null | name = "Manish"
age = 30
print("This is hello world!!!")
print(name)
print(float(age))
age = "31"
print(age)
print("this", "is", "cool", "and", "awesome!")
| 13.25 | 46 | 0.603774 | 24 | 159 | 4 | 0.583333 | 0.1875 | 0.229167 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02963 | 0.150943 | 159 | 11 | 47 | 14.454545 | 0.681481 | 0 | 0 | 0 | 0 | 0 | 0.320755 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.625 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
0403fa40fb7b02389b971b9a49457aa9cef4b01b | 1,231 | py | Python | backend/pitanja/serializers.py | mbranko/malamatura | 952ec93bdc5b0a27942ca784ab68200d8bd080ab | [
"MIT"
] | null | null | null | backend/pitanja/serializers.py | mbranko/malamatura | 952ec93bdc5b0a27942ca784ab68200d8bd080ab | [
"MIT"
] | 5 | 2021-03-30T13:12:52.000Z | 2022-03-02T08:20:46.000Z | backend/pitanja/serializers.py | mbranko/perftest-2 | a5af0b10f4337e7bb93632afe1694e820975ac87 | [
"MIT"
] | null | null | null | from rest_framework import serializers
from pitanja.models import Test, Pitanje, Odgovor, OdgovorUcenika
class TestSerializer(serializers.ModelSerializer):
class Meta:
model = Test
fields = '__all__'
class PitanjeSerializer(serializers.ModelSerializer):
class Meta:
model = Pitanje
fields = '__all__'
class OdgovorSerializer(serializers.ModelSerializer):
class Meta:
model = Odgovor
fields = '__all__'
class KompletOdgovorSerializer(serializers.ModelSerializer):
class Meta:
model = Odgovor
fields = ['id', 'redni_broj', 'tekst']
class KompletPitanjeSerializer(serializers.ModelSerializer):
odgovor_set = KompletOdgovorSerializer(many=True, read_only=True)
class Meta:
model = Pitanje
fields = ['id', 'redni_broj', 'tip', 'tekst', 'odgovor_set']
class KompletTestSerializer(serializers.ModelSerializer):
pitanje_set = KompletPitanjeSerializer(many=True, read_only=True)
class Meta:
model = Test
fields = ['id', 'naziv', 'datum_vazenja', 'pitanje_set']
class OdgovorUcenikaSerializer(serializers.ModelSerializer):
class Meta:
model = OdgovorUcenika
fields = '__all__'
| 25.122449 | 69 | 0.696182 | 113 | 1,231 | 7.353982 | 0.327434 | 0.219013 | 0.11793 | 0.21059 | 0.409146 | 0.209386 | 0.209386 | 0.081829 | 0 | 0 | 0 | 0 | 0.212835 | 1,231 | 48 | 70 | 25.645833 | 0.857585 | 0 | 0 | 0.53125 | 0 | 0 | 0.086921 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.0625 | 0 | 0.5625 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
0433b3da164c17aa29721014a65dc48522b8769b | 139 | py | Python | ansanp.py | iceee124/Learn-Coding | 1357774786091818a29a4d9dc5f3284f0e000cac | [
"MIT"
] | 54 | 2020-10-01T07:06:36.000Z | 2021-10-21T03:24:30.000Z | ansanp.py | iceee124/Learn-Coding | 1357774786091818a29a4d9dc5f3284f0e000cac | [
"MIT"
] | 19 | 2020-10-01T13:04:55.000Z | 2020-10-27T06:10:52.000Z | ansanp.py | iceee124/Learn-Coding | 1357774786091818a29a4d9dc5f3284f0e000cac | [
"MIT"
] | 97 | 2020-10-01T07:07:17.000Z | 2021-10-21T03:25:20.000Z | name, age = "ansan p", 18
username = "ansanpsam710*"
print ('Hello!')
print("Name: {}\nAge: {}\nUsername: {}".format(name, age, username))
| 27.8 | 68 | 0.633094 | 17 | 139 | 5.176471 | 0.705882 | 0.159091 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.040984 | 0.122302 | 139 | 4 | 69 | 34.75 | 0.680328 | 0 | 0 | 0 | 0 | 0 | 0.410072 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
044648c17df37ac1ac805c9b23128286129d55a2 | 2,807 | py | Python | Dragon/python/dragon/vm/torch/c_api.py | awesome-archive/Dragon | b35f9320909d07d138c2f6b345a4c24911f7c521 | [
"BSD-2-Clause"
] | null | null | null | Dragon/python/dragon/vm/torch/c_api.py | awesome-archive/Dragon | b35f9320909d07d138c2f6b345a4c24911f7c521 | [
"BSD-2-Clause"
] | null | null | null | Dragon/python/dragon/vm/torch/c_api.py | awesome-archive/Dragon | b35f9320909d07d138c2f6b345a4c24911f7c521 | [
"BSD-2-Clause"
] | null | null | null | # ------------------------------------------------------------
# Copyright (c) 2017-present, SeetaTech, Co.,Ltd.
#
# Licensed under the BSD 2-Clause License.
# You should have received a copy of the BSD 2-Clause License
# along with the software. If not, See,
#
# <https://opensource.org/licenses/BSD-2-Clause>
#
# ------------------------------------------------------------
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import copy
import numpy
import importlib
from dragon.core import mapping, tensor_utils
class Size(tuple):
def __init__(self, sizes):
super(Size, self).__init__()
def __setitem__(self, key, value):
raise TypeError("'torch.Size' object does not support item assignment")
def __repr__(self):
return 'torch.Size([{}])'.format(', '.join([str(s) for s in self]))
class device(object):
def __init__(self, type='cpu', index=0):
self.type, self.index = type, index
def copy(self):
return copy.deepcopy(self)
def __eq__(self, other):
return self.type == other.type and \
self.index == other.index
def __str__(self):
return '{}:{}'.format(self.type, self.index)
def __repr__(self):
return 'device(type={}, index={})'.format(self.type, self.index)
def from_numpy(data):
"""Create a tensor from the given numpy array.
Parameters
----------
data : numpy.ndarray
The array with various data type.
Return
------
dragon.vm.torch.Tensor
The torch tensor.
"""
if not isinstance(data, numpy.ndarray):
raise TypeError('The data should be a numpy.ndarray.')
if str(data.dtype) not in mapping.TENSOR_TYPE_TO_TORCH_TENSOR:
raise ValueError('Unsupported type({}) to torch tensor.'.format(data.dtype))
module = importlib.import_module('dragon.vm.torch.tensor')
return getattr(module, mapping.TENSOR_TYPE_TO_TORCH_TENSOR[str(data.dtype)])(data)
def from_dragon(tensor, own_storage=False):
"""Create a torch tensor from a existing dragon tensor.
Set ``own_storage`` as ``True`` for automatically releasing the storage.
Parameters
----------
tensor : Tensor or str
The dragon tensor.
own_storage : boolean
Whether to release storage during deconstructing.
Returns
-------
dragon.vm.torch.Tensor
The torch tensor.
"""
storage = tensor_utils.GetStorage(tensor)
if storage is None: return None
module = importlib.import_module('dragon.vm.torch.tensor')
T = getattr(module, mapping.TENSOR_TYPE_TO_TORCH_TENSOR[storage.dtype])()
T._storage, T._own_storage, T._tensor = storage, own_storage, tensor
T._device = device(*storage.device)
return T | 28.642857 | 86 | 0.637335 | 352 | 2,807 | 4.875 | 0.332386 | 0.070513 | 0.030303 | 0.044289 | 0.213287 | 0.189977 | 0.142191 | 0.10373 | 0 | 0 | 0 | 0.003583 | 0.204489 | 2,807 | 98 | 87 | 28.642857 | 0.76489 | 0.314214 | 0 | 0.097561 | 0 | 0 | 0.120462 | 0.024202 | 0 | 0 | 0 | 0 | 0 | 1 | 0.243902 | false | 0 | 0.219512 | 0.121951 | 0.682927 | 0.02439 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
f098831bab1decd03864282c0bd5007cce80be8f | 220 | py | Python | tests/integration/Story.py | marqov/storyscript | 4b99ff904305109cfb4310cb504127e2649ba44a | [
"MIT"
] | 1 | 2019-05-06T14:04:40.000Z | 2019-05-06T14:04:40.000Z | tests/integration/Story.py | marqov/storyscript | 4b99ff904305109cfb4310cb504127e2649ba44a | [
"MIT"
] | null | null | null | tests/integration/Story.py | marqov/storyscript | 4b99ff904305109cfb4310cb504127e2649ba44a | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from io import StringIO
from storyscript.Story import Story
def test_story_from_stream():
stream = StringIO('x = 0')
story = Story.from_stream(stream)
assert story.story == 'x = 0'
| 20 | 37 | 0.668182 | 31 | 220 | 4.612903 | 0.483871 | 0.125874 | 0.20979 | 0.293706 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.017045 | 0.2 | 220 | 10 | 38 | 22 | 0.795455 | 0.095455 | 0 | 0 | 0 | 0 | 0.050761 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
f0a5314711ce5aa96fac4d68cce8e38e46df0374 | 1,229 | py | Python | statistic_solver.py | TheReverseWasp/TIA-COVID-Peru-Prediction | 8f7f0130c87dce2dd4254caef20cc4e3fc5bde06 | [
"MIT"
] | null | null | null | statistic_solver.py | TheReverseWasp/TIA-COVID-Peru-Prediction | 8f7f0130c87dce2dd4254caef20cc4e3fc5bde06 | [
"MIT"
] | null | null | null | statistic_solver.py | TheReverseWasp/TIA-COVID-Peru-Prediction | 8f7f0130c87dce2dd4254caef20cc4e3fc5bde06 | [
"MIT"
] | null | null | null | import numpy as np
confirmed = [35120.47403822038, 39142.75526423077, 41861.51942625632,44692.013622337705, 47894.94126527191, 50055.05525701823, 53779.389725546374, 57094.04740253642, 60594.92180295287,63835.09279057236, 67559.4272591005, 70352.6781104966, 73034.19892783687, 76609.56001762388, 80780.8146223754,84430.66240153299, 89086.08048719316, 93964.95864096502, 98620.37672662521, 103871.68832724988, 108527.10641291006,112623.87432829101, 117242.04906926591, 120817.41015905293]
deaths = [906.2043399113949, 987.5279736100833, 1080.549391072327,1135.966973970448, 1226.6114445035673, 1265.1767407468863,1367.1183860105623, 1464.012357458458, 1563.069617684545,1651.7644575904053, 1736.373085359681, 1797.5861456018465,1838.0476579346914, 1924.4990872557603, 2037.9248581320592,2152.712699720553, 2256.6306828803545, 2364.688292714474,2464.359820124492, 2535.4011553095534, 2656.9192286524208,2778.0901075000234, 2904.9229273473375, 2983.1485178575044]
days = [53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76]
for i in range(len(days)):
print("\\textbf{" + str(days[i]) + "}" + " & " + str(round(confirmed[i], 0)) + " & " + str(round(deaths[i], 0)) + "\\\\\n\\hline")
| 111.727273 | 472 | 0.769731 | 150 | 1,229 | 6.306667 | 0.926667 | 0.016913 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.741792 | 0.082994 | 1,229 | 10 | 473 | 122.9 | 0.097604 | 0 | 0 | 0 | 0 | 0 | 0.023596 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0.166667 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f0c6a3302c4e2b9061592b41028c919184b6dff4 | 1,410 | py | Python | app/users/user.py | aRatnam12/Movie-Intersector | 69b4fc71d7f722d137ad6387b9347ce1dc677c17 | [
"CC-BY-3.0"
] | null | null | null | app/users/user.py | aRatnam12/Movie-Intersector | 69b4fc71d7f722d137ad6387b9347ce1dc677c17 | [
"CC-BY-3.0"
] | null | null | null | app/users/user.py | aRatnam12/Movie-Intersector | 69b4fc71d7f722d137ad6387b9347ce1dc677c17 | [
"CC-BY-3.0"
] | null | null | null | from werkzeug import generate_password_hash, check_password_hash
from flask.ext.login import UserMixin
from extensions import db
class User(db.Model, UserMixin):
__tablename__ = "user"
def __repr__(self):
return '<User %r>' % (self.user_name)
id = db.Column(db.Integer, primary_key = True)
user_name = db.Column(db.String(32), index = True, unique = True, nullable=False)
recent_first = db.Column(db.String(32))
recent_second = db.Column(db.String(32))
recent_results = db.Column(db.PickleType)
# User Password
_password = db.Column('password', db.String(32), nullable=False)
def get_password(self):
return self._password
def set_password(self, password):
self._password = generate_password_hash(password)
password = db.synonym('_password', descriptor = property(get_password, set_password))
def check_password(self, password):
if self.password is None:
return False
return check_password_hash(self.password, password)
@classmethod
def authenticate(cls, user_name, password):
user = User.query.filter(db.or_(User.user_name == user_name)).first()
if user:
authenticated = user.check_password(password)
else:
authenticated = False
return user, authenticated
@classmethod
def user_name_exists(cls, user_name):
return db.session.query(db.exists().where(User.user_name==user_name)).scalar()
| 30.652174 | 89 | 0.71844 | 187 | 1,410 | 5.197861 | 0.320856 | 0.074074 | 0.05144 | 0.049383 | 0.109054 | 0.049383 | 0 | 0 | 0 | 0 | 0 | 0.006838 | 0.170213 | 1,410 | 45 | 90 | 31.333333 | 0.823932 | 0.00922 | 0 | 0.060606 | 1 | 0 | 0.021505 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.181818 | false | 0.363636 | 0.090909 | 0.090909 | 0.727273 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
f0c7eda082d4c85f7a04f814e1c1ad49815e9492 | 145 | py | Python | setup.py | heni/virtualenv-make-relocatable | b7defe0294f327b33263f4664e8a29e575f16f5b | [
"MIT"
] | null | null | null | setup.py | heni/virtualenv-make-relocatable | b7defe0294f327b33263f4664e8a29e575f16f5b | [
"MIT"
] | 1 | 2022-03-03T19:42:13.000Z | 2022-03-03T19:42:13.000Z | setup.py | heni/virtualenv-make-relocatable | b7defe0294f327b33263f4664e8a29e575f16f5b | [
"MIT"
] | null | null | null | from setuptools import setup, find_packages
setup(
packages = [ "virtualenv_relocator" ],
scripts = [ "virtualenv-make-relocatable" ]
)
| 20.714286 | 47 | 0.710345 | 14 | 145 | 7.214286 | 0.785714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.17931 | 145 | 6 | 48 | 24.166667 | 0.84874 | 0 | 0 | 0 | 0 | 0 | 0.324138 | 0.186207 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.2 | 0 | 0.2 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
f0c974b25c8ad5e9306ad10242f37b7d0bddca09 | 1,069 | py | Python | stack.py | maqueredkop/data_structure_and_algorithms | 5aaa2c4fc4bad07453492dfd4994a161fdcfbef3 | [
"MIT"
] | null | null | null | stack.py | maqueredkop/data_structure_and_algorithms | 5aaa2c4fc4bad07453492dfd4994a161fdcfbef3 | [
"MIT"
] | null | null | null | stack.py | maqueredkop/data_structure_and_algorithms | 5aaa2c4fc4bad07453492dfd4994a161fdcfbef3 | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 22 21:18:39 2017
@author: maque
the demo code is from the book <Problem solving with algorithms and data
structure >
"""
class Stack:
"""
A stack (sometimes called a “push-down stack”) is an ordered collection of
items where the addition of new items and the removal of existing items
always takes place at the same end. This end is commonly referred to as the
“top.” The end opposite the top is known as the “base.”
LIFO means Last in first out
"""
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[len(self.items)-1]
def size(self):
return len(self.items)
stack = Stack()
stack.isEmpty()
stack.push('tree')
stack.push('river')
stack.push('wall')
stack.peek()
stack.pop()
stack.size()
| 19.089286 | 79 | 0.609916 | 154 | 1,069 | 4.207792 | 0.545455 | 0.097222 | 0.064815 | 0.087963 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019405 | 0.276894 | 1,069 | 55 | 80 | 19.436364 | 0.818887 | 0.460243 | 0 | 0 | 0 | 0 | 0.024528 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0 | 0.190476 | 0.52381 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
f0cbed410de84d5eb0daba1f65fbd5fe97911cec | 202 | py | Python | src/rastervision/core/command.py | nholeman/raster-vision | f3e1e26c555feed6fa018183c3fa04d7858d91bd | [
"Apache-2.0"
] | null | null | null | src/rastervision/core/command.py | nholeman/raster-vision | f3e1e26c555feed6fa018183c3fa04d7858d91bd | [
"Apache-2.0"
] | null | null | null | src/rastervision/core/command.py | nholeman/raster-vision | f3e1e26c555feed6fa018183c3fa04d7858d91bd | [
"Apache-2.0"
] | null | null | null | from abc import ABC, abstractmethod
class Command(ABC):
"""A command which can be run from the command line."""
@abstractmethod
def run(self):
"""Run the command."""
pass
| 18.363636 | 59 | 0.618812 | 26 | 202 | 4.807692 | 0.615385 | 0.16 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.272277 | 202 | 10 | 60 | 20.2 | 0.85034 | 0.326733 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.2 | 0.2 | 0 | 0.6 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
f0ce87e34267c568cbc491d2df75a0e4b9d937ef | 368 | py | Python | app/api/models/__init__.py | dtrifuno/job-tracker | 8a4613315b2332a535e93215888372b4c306df49 | [
"MIT"
] | null | null | null | app/api/models/__init__.py | dtrifuno/job-tracker | 8a4613315b2332a535e93215888372b4c306df49 | [
"MIT"
] | 2 | 2022-02-13T14:08:24.000Z | 2022-02-19T02:39:14.000Z | app/api/models/__init__.py | dtrifuno/job-tracker | 8a4613315b2332a535e93215888372b4c306df49 | [
"MIT"
] | null | null | null | from flask_sqlalchemy import SQLAlchemy, Model
class ModelClass(Model):
def update(self, kwargs):
for key, value in kwargs.items():
setattr(self, key, value)
db = SQLAlchemy(model_class=ModelClass)
from .profile import User, Profile, Address, Education, Skill, WorkExperience, PersonalProject # noqa
from .jobs import Job, Event # noqa
| 23 | 102 | 0.717391 | 45 | 368 | 5.822222 | 0.644444 | 0.114504 | 0.152672 | 0.229008 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.195652 | 368 | 15 | 103 | 24.533333 | 0.885135 | 0.024457 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.375 | 0 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
0b14c0d45a036cdbee261d07b1e42d43eb44222f | 101 | py | Python | Insurance/beneficiaries/apps.py | MarlvinzW/Insurance | 68dffbd2294769f69ed1dd638aab8e39552c1b61 | [
"MIT"
] | null | null | null | Insurance/beneficiaries/apps.py | MarlvinzW/Insurance | 68dffbd2294769f69ed1dd638aab8e39552c1b61 | [
"MIT"
] | null | null | null | Insurance/beneficiaries/apps.py | MarlvinzW/Insurance | 68dffbd2294769f69ed1dd638aab8e39552c1b61 | [
"MIT"
] | null | null | null | from django.apps import AppConfig
class BeneficiariesConfig(AppConfig):
name = 'beneficiaries'
| 16.833333 | 37 | 0.782178 | 10 | 101 | 7.9 | 0.9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.148515 | 101 | 5 | 38 | 20.2 | 0.918605 | 0 | 0 | 0 | 0 | 0 | 0.128713 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
9bdf602702adee1bb67551109b30ae626683097e | 561 | py | Python | PyShooter/weapons/crossweapon.py | ildave/PyShooter | ff04fcbcbd144a6959b291fe5242afff6d616eaa | [
"MIT"
] | null | null | null | PyShooter/weapons/crossweapon.py | ildave/PyShooter | ff04fcbcbd144a6959b291fe5242afff6d616eaa | [
"MIT"
] | null | null | null | PyShooter/weapons/crossweapon.py | ildave/PyShooter | ff04fcbcbd144a6959b291fe5242afff6d616eaa | [
"MIT"
] | null | null | null | import weapons.weapon
import gameobjects.bullet
import math
class CrossWeapon(weapons.weapon.Weapon):
def shoot(self):
b1 = gameobjects.bullet.Bullet(self.ship, self.game, 0)
b2 = gameobjects.bullet.Bullet(self.ship, self.game, math.pi / 2, 10)
b3 = gameobjects.bullet.Bullet(self.ship, self.game, math.pi, 10)
b4 = gameobjects.bullet.Bullet(self.ship, self.game, 3 * math.pi / 2, 10)
self.scene.bullets.add(b1)
self.scene.bullets.add(b2)
self.scene.bullets.add(b3)
self.scene.bullets.add(b4) | 40.071429 | 81 | 0.668449 | 81 | 561 | 4.62963 | 0.308642 | 0.226667 | 0.245333 | 0.288 | 0.448 | 0.448 | 0.448 | 0.24 | 0.24 | 0 | 0 | 0.04 | 0.197861 | 561 | 14 | 82 | 40.071429 | 0.793333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | false | 0 | 0.230769 | 0 | 0.384615 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9bdfc94fef6a59e7adc92b5af90c8c9ad2a54d55 | 6,557 | py | Python | varsome_api/models/elements/gnomad.py | saphetor/api-client | 46e47c6d4e9fc82f120fc168c660dae50eee4dbf | [
"Apache-2.0"
] | null | null | null | varsome_api/models/elements/gnomad.py | saphetor/api-client | 46e47c6d4e9fc82f120fc168c660dae50eee4dbf | [
"Apache-2.0"
] | null | null | null | varsome_api/models/elements/gnomad.py | saphetor/api-client | 46e47c6d4e9fc82f120fc168c660dae50eee4dbf | [
"Apache-2.0"
] | null | null | null | # Copyright 2018 Saphetor S.A.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by 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.
from jsonmodels import models, fields
class GnomADCoverage(models.Base):
version = fields.StringField(help_text="Version")
coverage_mean = fields.ListField(
help_text="Mean coverage",
items_types=(float, type(None)),
required=False,
nullable=True,
)
coverage_median = fields.ListField(
help_text="Median coverage",
items_types=(float, type(None)),
required=False,
nullable=True,
)
coverage_20_frequency = fields.ListField(
help_text="Proportion of samples with over 20x",
items_types=(float, type(None)),
required=False,
nullable=True,
)
class GnomAD(models.Base):
version = fields.StringField(help_text="Version")
ac = fields.IntField(help_text="Allele Count", required=False, nullable=True)
an = fields.IntField(help_text="Allele Number", required=False, nullable=True)
ac_adj = fields.FloatField(help_text="Allele Count", required=False, nullable=True)
an_adj = fields.FloatField(help_text="Allele Number", required=False, nullable=True)
af = fields.FloatField(help_text="Allele Frequency", required=False, nullable=True)
ac_afr = fields.IntField(
help_text="Allele Count African", required=False, nullable=True
)
ac_amr = fields.IntField(
help_text="Allele Count American", required=False, nullable=True
)
ac_asj = fields.IntField(
help_text="Allele Count Ashkenazi Jewish", required=False, nullable=True
)
ac_eas = fields.IntField(
help_text="Allele Count East Asian", required=False, nullable=True
)
ac_fin = fields.IntField(
help_text="Allele Count European (Finnish)", required=False, nullable=True
)
ac_nfe = fields.IntField(
help_text="Allele Count European (Non-Finnish)", required=False, nullable=True
)
ac_oth = fields.IntField(
help_text="Allele Count Other", required=False, nullable=True
)
ac_male = fields.IntField(
help_text="Allele Count Male", required=False, nullable=True
)
ac_female = fields.IntField(
help_text="Allele Count Female", required=False, nullable=True
)
hom = fields.IntField(
help_text="Number of Homozygotes", required=False, nullable=True
)
hemi = fields.IntField(
help_text="Number of Hemizygotes", required=False, nullable=True
)
ac_hom = fields.FloatField(
help_text="Number of Homozygotes", required=False, nullable=True
)
ac_hemi = fields.FloatField(
help_text="Number of Hemizygotes", required=False, nullable=True
)
an_afr = fields.IntField(
help_text="Allele Number African", required=False, nullable=True
)
an_amr = fields.IntField(
help_text="Allele Number American", required=False, nullable=True
)
an_asj = fields.IntField(
help_text="Allele Number Ashkenazi Jewish", required=False, nullable=True
)
an_eas = fields.IntField(
help_text="Allele Number East Asian", required=False, nullable=True
)
an_fin = fields.IntField(
help_text="Allele Number European (Finnish)", required=False, nullable=True
)
an_nfe = fields.IntField(
help_text="Allele Number European (Non-Finnish)", required=False, nullable=True
)
an_oth = fields.IntField(
help_text="Allele Number Other", required=False, nullable=True
)
an_male = fields.IntField(
help_text="Allele Number Male", required=False, nullable=True
)
an_female = fields.IntField(
help_text="Allele Number Female", required=False, nullable=True
)
hom_afr = fields.IntField(
help_text="Number of Homozygotes African", required=False, nullable=True
)
hom_amr = fields.IntField(
help_text="Number of Homozygotes American", required=False, nullable=True
)
hom_asj = fields.IntField(
help_text="Number of Homozygotes Ashkenazi Jewish",
required=False,
nullable=True,
)
hom_eas = fields.IntField(
help_text="Number of Homozygotes East Asian", required=False, nullable=True
)
hom_fin = fields.IntField(
help_text="Number of Homozygotes European (Finnish)",
required=False,
nullable=True,
)
hom_nfe = fields.IntField(
help_text="Number of Homozygotes European (Non-Finnish)",
required=False,
nullable=True,
)
hom_oth = fields.IntField(
help_text="Number of Homozygotes Other", required=False, nullable=True
)
hom_male = fields.IntField(
help_text="Number of Homozygotes Male", required=False, nullable=True
)
hom_female = fields.IntField(
help_text="Number of Homozygotes Female", required=False, nullable=True
)
af_afr = fields.FloatField(
help_text="Allele Frequency African", required=False, nullable=True
)
af_amr = fields.FloatField(
help_text="Allele Frequency American", required=False, nullable=True
)
af_asj = fields.FloatField(
help_text="Allele Frequency Ashkenazi Jewish", required=False, nullable=True
)
af_eas = fields.FloatField(
help_text="Allele Frequency East Asian", required=False, nullable=True
)
af_fin = fields.FloatField(
help_text="Allele Frequency European (Finnish)", required=False, nullable=True
)
af_nfe = fields.FloatField(
help_text="Allele Frequency European (Non-Finnish)",
required=False,
nullable=True,
)
af_oth = fields.FloatField(
help_text="Allele Frequency Other", required=False, nullable=True
)
af_male = fields.FloatField(
help_text="Allele Frequency Male", required=False, nullable=True
)
af_female = fields.FloatField(
help_text="Allele Frequency Female", required=False, nullable=True
)
main_data = fields.StringField(
help_text="Main data point", required=False, nullable=True
)
| 36.837079 | 88 | 0.680647 | 789 | 6,557 | 5.531052 | 0.160963 | 0.093492 | 0.235793 | 0.280706 | 0.827223 | 0.670944 | 0.335243 | 0.17461 | 0.109074 | 0.029331 | 0 | 0.002347 | 0.220375 | 6,557 | 177 | 89 | 37.045198 | 0.85133 | 0.08388 | 0 | 0.144654 | 0 | 0 | 0.203571 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.006289 | 0 | 0.339623 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9bea37f38b7328aba4b26b2c1b64b8dd07e600c4 | 1,977 | py | Python | communication/redis_object.py | wo1fsea/Arbitrager | 277b12c84561c403974d699f9d4a45085f8b8adf | [
"MIT"
] | 1 | 2021-03-07T23:09:20.000Z | 2021-03-07T23:09:20.000Z | communication/redis_object.py | wo1fsea/Arbitrager | 277b12c84561c403974d699f9d4a45085f8b8adf | [
"MIT"
] | null | null | null | communication/redis_object.py | wo1fsea/Arbitrager | 277b12c84561c403974d699f9d4a45085f8b8adf | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""----------------------------------------------------------------------------
Author:
Huang Quanyong (wo1fSea)
quanyongh@foxmail.com
Date:
2017/10/29
Description:
redis_object.py
----------------------------------------------------------------------------"""
import time
from . import db_connection
import msgpack
import _pickle as pickle
_delta_time = None
class Packer(object):
def pack(self, obj):
raise NotImplementedError()
def unpack(self, packed):
raise NotImplementedError()
class NoPacker(object):
def pack(self, obj):
return obj
def unpack(self, packed):
return packed
class MsgPacker(Packer):
def pack(self, obj):
return msgpack.packb(obj)
def unpack(self, packed):
return msgpack.unpackb(packed, encoding='utf-8')
class PicklePacker(Packer):
def pack(self, obj):
return pickle.dumps(obj)
def unpack(self, packed):
return pickle.loads(packed)
DEFAULT_PACKER = PicklePacker
class RedisObject(object):
Redis_Type = "none"
def __init__(self, key, packer=DEFAULT_PACKER):
self._key = key
self._packer = packer()
self.redis = db_connection.get_redis()
def get_type(self):
return self.redis.type(self._key).decode()
def set_expire(self, milliseconds):
self.redis.pexpire(self._key, milliseconds)
@property
def exists(self):
return self.redis.exists(self._key)
@property
def time(self):
global _delta_time
if _delta_time is None:
local_time = time.time()
redis_time = float("%d.%d" % self.redis.time())
_delta_time = redis_time - local_time
return _delta_time + time.time()
@property
def key(self):
return self._key
def pack(self, obj):
return self._packer.pack(obj)
def unpack(self, packed):
return self._packer.unpack(packed)
| 21.48913 | 79 | 0.584219 | 224 | 1,977 | 4.995536 | 0.294643 | 0.037534 | 0.049151 | 0.062556 | 0.205541 | 0.146559 | 0 | 0 | 0 | 0 | 0 | 0.007324 | 0.240263 | 1,977 | 91 | 80 | 21.725275 | 0.737683 | 0.148204 | 0 | 0.277778 | 0 | 0 | 0.008343 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.296296 | false | 0 | 0.074074 | 0.203704 | 0.703704 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
9beb954b649b90e4acbc485fdc9533020d3099f2 | 636 | py | Python | hello.py | RonaldZhao/flask-blog | ecf0e5a5378ff5da7f1ab6f3435bc466f3d66074 | [
"MIT"
] | null | null | null | hello.py | RonaldZhao/flask-blog | ecf0e5a5378ff5da7f1ab6f3435bc466f3d66074 | [
"MIT"
] | null | null | null | hello.py | RonaldZhao/flask-blog | ecf0e5a5378ff5da7f1ab6f3435bc466f3d66074 | [
"MIT"
] | null | null | null | from flask import Flask, render_template
app = Flask(__name__)
# 使用 route 装饰器将函数绑定到 URL 上
@app.route('/')
def home():
return '这是主页'
@app.route('/pages')
def pages():
return '这是pages页面'
# 在路由中使用变量
@app.route('/user/')
@app.route('/user/<username>')
def user(username=None):
# return '你好, {0}。'.format(username)
return render_template('index.html', name=username)
@app.route('/post/<int:post_id>')
def post(post_id):
return 'Post: {0}'.format(post_id)
# 自定义 404 页面
@app.errorhandler(404)
def page_not_found(error):
return render_template('page_not_found.html'), 404
if __name__ == '__main__':
app.run()
| 19.875 | 55 | 0.676101 | 91 | 636 | 4.483516 | 0.450549 | 0.098039 | 0.058824 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020258 | 0.146226 | 636 | 31 | 56 | 20.516129 | 0.731123 | 0.124214 | 0 | 0 | 0 | 0 | 0.193841 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.05 | 0.25 | 0.55 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
50128c8b779c282948cdd97def2b9b18769176e7 | 954 | py | Python | ex/ex033.py | Ozcry/PythonExercicio | b4d4a4fbd6467d1ced0815677ecbd78c2613c4c9 | [
"MIT"
] | null | null | null | ex/ex033.py | Ozcry/PythonExercicio | b4d4a4fbd6467d1ced0815677ecbd78c2613c4c9 | [
"MIT"
] | null | null | null | ex/ex033.py | Ozcry/PythonExercicio | b4d4a4fbd6467d1ced0815677ecbd78c2613c4c9 | [
"MIT"
] | null | null | null | '''Faça um programa que leia três números e mostre qual é o maior e qual é o menor.'''
n1 = float(input('\033[30mDigite o primeiro número:\033[m '))
n2 = float(input('\033[31mDigite o segundo número:\033[m '))
n3 = float(input('\033[32mDigite o terceiro número:\033[m '))
if n1 > n2 and n1 > n3:
print('\033[33mMaior número\033[m {}{:.1f}{}'.format('\033[31m', n1, '\033[m'))
if n2 > n1 and n2 > n3:
print('\033[34mMaior número\033[m {}{:.1f}{}'.format('\033[32m', n2, '\033[m'))
if n3 > n1 and n3 > n2:
print('\033[35mMaior número\033[m {}{:.1f}{}'.format('\033[33m', n3, '\033[m'))
if n1 < n2 and n1 < n3:
print('\033[36mMenor número\033[m {}{:.1f}{}'.format('\033[34m', n1, '\033[m'))
if n2 < n1 and n2 < n3:
print('\033[37mMenor número\033[m {}{:.1f}{}'.format('\033[35m', n2, '\033[m'))
if n3 < n1 and n3 < n2:
print('\033[30mMenor número\033[m {}{:.1f}{}'.format('\033[36m', n3, '\033[m'))
print('\033[33m----------\033[m')
| 53 | 86 | 0.585954 | 167 | 954 | 3.347305 | 0.269461 | 0.11449 | 0.161002 | 0.128801 | 0.50805 | 0.50805 | 0.282648 | 0.282648 | 0.282648 | 0.282648 | 0 | 0.205665 | 0.148847 | 954 | 17 | 87 | 56.117647 | 0.482759 | 0.083857 | 0 | 0 | 0 | 0 | 0.517281 | 0.02765 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.4375 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
501d44ffe2c1720f1671047fcd1e6e953e9fea3b | 425 | py | Python | envisage/ui/tasks/task_window_event.py | robmcmullen/envisage | 57338fcb0ea69c75bc3c86de18a5967d8e78c6c1 | [
"BSD-3-Clause"
] | null | null | null | envisage/ui/tasks/task_window_event.py | robmcmullen/envisage | 57338fcb0ea69c75bc3c86de18a5967d8e78c6c1 | [
"BSD-3-Clause"
] | 1 | 2017-05-22T21:15:22.000Z | 2017-05-22T21:15:22.000Z | envisage/ui/tasks/task_window_event.py | robmcmullen/envisage | 57338fcb0ea69c75bc3c86de18a5967d8e78c6c1 | [
"BSD-3-Clause"
] | 1 | 2019-10-01T07:03:58.000Z | 2019-10-01T07:03:58.000Z | # Enthought library imports.
from traits.api import HasTraits, Instance, Vetoable
# Local imports.
from .task_window import TaskWindow
class TaskWindowEvent(HasTraits):
""" A task window lifecycle event.
"""
# The window that the event occurred on.
window = Instance(TaskWindow)
class VetoableTaskWindowEvent(TaskWindowEvent, Vetoable):
""" A vetoable task window lifecycle event.
"""
pass
| 20.238095 | 57 | 0.722353 | 46 | 425 | 6.652174 | 0.543478 | 0.098039 | 0.124183 | 0.156863 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.197647 | 425 | 20 | 58 | 21.25 | 0.897361 | 0.381176 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.166667 | 0.333333 | 0 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 3 |
502895ec1b5a011566c64adb2ce5a5e2eff89648 | 1,265 | py | Python | zentral/contrib/inventory/serializers.py | n0thing2speak/zentral | 8f21eec33f77e727b7605034a2d9821a483663ca | [
"Apache-2.0"
] | 1 | 2019-06-10T06:11:27.000Z | 2019-06-10T06:11:27.000Z | zentral/contrib/inventory/serializers.py | n0thing2speak/zentral | 8f21eec33f77e727b7605034a2d9821a483663ca | [
"Apache-2.0"
] | null | null | null | zentral/contrib/inventory/serializers.py | n0thing2speak/zentral | 8f21eec33f77e727b7605034a2d9821a483663ca | [
"Apache-2.0"
] | null | null | null | from rest_framework import serializers
from .models import MetaBusinessUnit
class MetaBusinessUnitSerializer(serializers.ModelSerializer):
api_enrollment_enabled = serializers.BooleanField(required=False)
class Meta:
model = MetaBusinessUnit
fields = ("id", "name", "api_enrollment_enabled")
read_only_fields = ("api_enrollment_enabled",)
def validate_api_enrollment_enabled(self, value):
if self.instance and self.instance.api_enrollment_enabled() and not value:
raise serializers.ValidationError("Cannot disable API enrollment")
return value
def create(self, validated_data):
api_enrollment_enabled = validated_data.pop("api_enrollment_enabled", False)
mbu = super().create(validated_data)
if api_enrollment_enabled:
mbu.create_enrollment_business_unit()
return mbu
def update(self, instance, validated_data):
api_enrollment_enabled = validated_data.pop("api_enrollment_enabled", False)
mbu = super().update(instance, validated_data)
if not mbu.api_enrollment_enabled() and api_enrollment_enabled:
mbu.create_enrollment_business_unit()
# TODO: switch off api_enrollment_enabled
return mbu
| 39.53125 | 84 | 0.72332 | 140 | 1,265 | 6.235714 | 0.342857 | 0.208477 | 0.297824 | 0.052692 | 0.304696 | 0.304696 | 0.304696 | 0.304696 | 0.187858 | 0.187858 | 0 | 0 | 0.203162 | 1,265 | 31 | 85 | 40.806452 | 0.866071 | 0.03083 | 0 | 0.25 | 0 | 0 | 0.10049 | 0.071895 | 0 | 0 | 0 | 0.032258 | 0 | 1 | 0.125 | false | 0 | 0.083333 | 0 | 0.458333 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
5035e7de4b9cff4c0b219268de38ae4498a8fa5d | 378 | py | Python | spec/python/test_params_call_extra_parens.py | DarkShadow44/kaitai_struct_tests | 4bb13cef82965cca66dda2eb2b77cd64e9f70a12 | [
"MIT"
] | 11 | 2018-04-01T03:58:15.000Z | 2021-08-14T09:04:55.000Z | spec/python/test_params_call_extra_parens.py | DarkShadow44/kaitai_struct_tests | 4bb13cef82965cca66dda2eb2b77cd64e9f70a12 | [
"MIT"
] | 73 | 2016-07-20T10:27:15.000Z | 2020-12-17T18:56:46.000Z | spec/python/test_params_call_extra_parens.py | DarkShadow44/kaitai_struct_tests | 4bb13cef82965cca66dda2eb2b77cd64e9f70a12 | [
"MIT"
] | 37 | 2016-08-15T08:25:56.000Z | 2021-08-28T14:48:46.000Z | # Autogenerated from KST: please remove this line if doing any edits by hand!
import unittest
from params_call_extra_parens import ParamsCallExtraParens
class TestParamsCallExtraParens(unittest.TestCase):
def test_params_call_extra_parens(self):
with ParamsCallExtraParens.from_file('src/term_strz.bin') as r:
self.assertEqual(r.buf1.body, u"foo|b")
| 31.5 | 77 | 0.775132 | 51 | 378 | 5.568627 | 0.784314 | 0.070423 | 0.105634 | 0.147887 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003125 | 0.153439 | 378 | 11 | 78 | 34.363636 | 0.884375 | 0.198413 | 0 | 0 | 1 | 0 | 0.07309 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
5038a6c5c542e4f7d270a5a3767b26c452985db8 | 501 | py | Python | pythonProject/03al57exercicio/exercicio2.py | D-Wolter/PycharmProjects | c8d6144efa30261bff72a3e0414a0d80f6730f9b | [
"MIT"
] | null | null | null | pythonProject/03al57exercicio/exercicio2.py | D-Wolter/PycharmProjects | c8d6144efa30261bff72a3e0414a0d80f6730f9b | [
"MIT"
] | null | null | null | pythonProject/03al57exercicio/exercicio2.py | D-Wolter/PycharmProjects | c8d6144efa30261bff72a3e0414a0d80f6730f9b | [
"MIT"
] | null | null | null | '''
crie uma funcao1 que receba uma funcao2 como parametro e reotrne o valorda
funcao2 executada, faça a funcao1 executar duas funcoes que recebam um numero
diferente de argumentos
'''
def mestre(funcao, *args, **kwargs):
return funcao(*args, **kwargs)
def fala_oi(nome):
return f'oi {nome}'
def saudacao(nome, saudacao):
return f' {saudacao}{nome}'
executando = mestre(fala_oi, 'Daniel')
executando2 = mestre(saudacao, "Luiz", saudacao='bom dia!')
print(executando)
print(executando2) | 26.368421 | 77 | 0.732535 | 69 | 501 | 5.289855 | 0.608696 | 0.054795 | 0.087671 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014085 | 0.149701 | 501 | 19 | 78 | 26.368421 | 0.842723 | 0.351297 | 0 | 0 | 0 | 0 | 0.138365 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0 | 0.3 | 0.6 | 0.2 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
5044cfb461fffaf4c754dd64e64707175279b8e4 | 844 | py | Python | mapya/nodeType/mesh.py | parzival-roethlein/mapya | 2395a8922e557acfe7dc4b98c13be7f071127277 | [
"MIT"
] | 1 | 2020-03-20T11:48:34.000Z | 2020-03-20T11:48:34.000Z | mapya/nodeType/mesh.py | parzival-roethlein/mapya | 2395a8922e557acfe7dc4b98c13be7f071127277 | [
"MIT"
] | null | null | null | mapya/nodeType/mesh.py | parzival-roethlein/mapya | 2395a8922e557acfe7dc4b98c13be7f071127277 | [
"MIT"
] | null | null | null | """
['containerBase',
'entity',
'dagNode',
'shape',
'geometryShape',
'deformableShape',
'controlPoint',
'surfaceShape',
'mesh']
"""
import maya.api.OpenMaya as om
import maya.cmds as mc
from mapya.nodeType.deformableShape import DeformableShape
from prmaya.plugins import prSetPointsCmd
class Mesh(DeformableShape):
@property
def points(self):
return self.getPoints()
@points.setter
def points(self, value):
self.setPoints(value)
def getPoints(self, space=om.MSpace.kObject):
return om.MFnMesh(self.MDagPath).getPoints(space)
def setPoints(self, value, space=om.MSpace.kObject):
if not mc.pluginInfo('prSetPointsCmd', q=True, loaded=True):
mc.loadPlugin(prSetPointsCmd.__file__.replace('.pyc', '.py'))
prSetPointsCmd.setPoints(self.name, value, space)
| 22.810811 | 73 | 0.690758 | 94 | 844 | 6.159574 | 0.531915 | 0.034542 | 0.044905 | 0.069085 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.177725 | 844 | 36 | 74 | 23.444444 | 0.834294 | 0.155213 | 0 | 0 | 0 | 0 | 0.02983 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.235294 | false | 0 | 0.235294 | 0.117647 | 0.647059 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
50465f8fd950e38be06f6db7d1f613923340b62c | 389 | py | Python | libs/configuration.py | AdilsonTorres/ansible-setup-tools | c5b85c0844586e670dc71074b40cfb455688e478 | [
"MIT"
] | null | null | null | libs/configuration.py | AdilsonTorres/ansible-setup-tools | c5b85c0844586e670dc71074b40cfb455688e478 | [
"MIT"
] | 1 | 2018-04-09T21:19:00.000Z | 2018-04-09T21:29:37.000Z | libs/configuration.py | AdilsonTorres/ansible-setup-tools | c5b85c0844586e670dc71074b40cfb455688e478 | [
"MIT"
] | null | null | null |
CONF = {
"git_bash" : {
"name": "Git BRanch on bash prompt",
"commands": """
# ref: https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="[\$(date +%k:%M:%S)] \\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
"""
},
}
| 25.933333 | 102 | 0.498715 | 55 | 389 | 3.436364 | 0.672727 | 0.238095 | 0.148148 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.058065 | 0.203085 | 389 | 14 | 103 | 27.785714 | 0.551613 | 0 | 0 | 0 | 0 | 0.25 | 0.819121 | 0.149871 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
5048c1e1b2517d1c0ed97a9f5165cf26c36433c0 | 682 | py | Python | env/lib/python3.7/site-packages/hupper/logger.py | Kolawole39/masonite-guides-tutorial | 9a21cc635291a42f0722f69925be1809bb20e01c | [
"MIT"
] | null | null | null | env/lib/python3.7/site-packages/hupper/logger.py | Kolawole39/masonite-guides-tutorial | 9a21cc635291a42f0722f69925be1809bb20e01c | [
"MIT"
] | null | null | null | env/lib/python3.7/site-packages/hupper/logger.py | Kolawole39/masonite-guides-tutorial | 9a21cc635291a42f0722f69925be1809bb20e01c | [
"MIT"
] | null | null | null | from __future__ import print_function
import sys
from .interfaces import ILogger
class LogLevel:
ERROR = 0
INFO = 1
DEBUG = 2
class DefaultLogger(ILogger):
def __init__(self, level):
self.level = level
def _out(self, level, msg):
if level <= self.level:
print(msg, file=sys.stderr)
def error(self, msg):
self._out(LogLevel.ERROR, msg)
def info(self, msg):
self._out(LogLevel.INFO, msg)
def debug(self, msg):
self._out(LogLevel.DEBUG, msg)
class SilentLogger(ILogger):
def error(self, msg):
pass
def info(self, msg):
pass
def debug(self, msg):
pass
| 16.634146 | 39 | 0.601173 | 88 | 682 | 4.511364 | 0.318182 | 0.105793 | 0.083123 | 0.105793 | 0.166247 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00625 | 0.296188 | 682 | 40 | 40 | 17.05 | 0.820833 | 0 | 0 | 0.346154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.307692 | false | 0.115385 | 0.115385 | 0 | 0.653846 | 0.076923 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
504ba5c69b1673e83df13d10ba9287f7e69f97bc | 389 | py | Python | mysite/blog_vue/admin.py | wuchunlong0/blog_vue_uk_login_reg | 6db57b2e35afe46f07ae2d467f272c8fd86df8df | [
"Apache-2.0"
] | null | null | null | mysite/blog_vue/admin.py | wuchunlong0/blog_vue_uk_login_reg | 6db57b2e35afe46f07ae2d467f272c8fd86df8df | [
"Apache-2.0"
] | null | null | null | mysite/blog_vue/admin.py | wuchunlong0/blog_vue_uk_login_reg | 6db57b2e35afe46f07ae2d467f272c8fd86df8df | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
from . models import Blogs,Comment
@admin.register(Blogs)
class BlogAdmin(admin.ModelAdmin):
list_display = ('id','author','subject','summary','content','created_at')
# @admin.register(Comment)
# class CommentAdmin(admin.ModelAdmin):
# list_display = ('id','user_id')
| 24.3125 | 77 | 0.701799 | 46 | 389 | 5.73913 | 0.630435 | 0.098485 | 0.143939 | 0.19697 | 0.212121 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003012 | 0.14653 | 389 | 15 | 78 | 25.933333 | 0.792169 | 0.318766 | 0 | 0 | 0 | 0 | 0.15 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
505bd17c63b1a702dc4a398938ca008e17e1320f | 598 | py | Python | src/25-merge-sort/py/__main__.py | MichaelZalla/data-structures-review | 4ef1a70cf28031160eafc81fe3557791c58aed32 | [
"MIT"
] | null | null | null | src/25-merge-sort/py/__main__.py | MichaelZalla/data-structures-review | 4ef1a70cf28031160eafc81fe3557791c58aed32 | [
"MIT"
] | null | null | null | src/25-merge-sort/py/__main__.py | MichaelZalla/data-structures-review | 4ef1a70cf28031160eafc81fe3557791c58aed32 | [
"MIT"
] | null | null | null | from Merge import merge
from MergeSort import merge_sort
# Tests for merge routine
assert(merge([], []) == [])
assert(merge([1], []) == [1])
assert(merge([], [1]) == [1])
assert(merge([1], [1]) == [1,1])
assert(merge([1,2], [3]) == [1,2,3])
assert(merge([3], [1,2]) == [1,2,3])
assert(merge([1,2,3,4,4,5,6,7,7,8,9], [1,1,5,5,5,5,5,6,6,9]) == [1,1,1,2,3,4,4,5,5,5,5,5,5,6,6,6,7,7,8,9,9])
# Tests for merge_sort routine
assert(merge_sort([]) == [])
assert(merge_sort([5]) == [5])
assert(merge_sort([5,1]) == [1,5])
assert(merge_sort([5,8,1,2,7,9,4,2,1,5,1]) == [1,1,1,2,2,4,5,5,7,8,9])
| 19.933333 | 108 | 0.543478 | 134 | 598 | 2.380597 | 0.134328 | 0.075235 | 0.065831 | 0.062696 | 0.479624 | 0.203762 | 0.166144 | 0.122257 | 0 | 0 | 0 | 0.171103 | 0.120401 | 598 | 29 | 109 | 20.62069 | 0.435361 | 0.086957 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.846154 | 1 | 0 | true | 0 | 0.153846 | 0 | 0.153846 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
ac9546dd538e9d6ab2d267387541202fbf8215ac | 407 | py | Python | scripts/python/formats/disFile.py | therealjacinto/6502-be-computer | 66b87dcb52badda42c544ed200b562781ed7ed7c | [
"MIT"
] | 1 | 2020-08-20T04:37:02.000Z | 2020-08-20T04:37:02.000Z | scripts/python/formats/disFile.py | therealjacinto/6502-be-computer | 66b87dcb52badda42c544ed200b562781ed7ed7c | [
"MIT"
] | null | null | null | scripts/python/formats/disFile.py | therealjacinto/6502-be-computer | 66b87dcb52badda42c544ed200b562781ed7ed7c | [
"MIT"
] | null | null | null | import re
def formatOp(line):
opcode = line[17:20]
arg = line[21:].strip()
return (opcode, arg)
def formatAddr(line):
return line[1:5]
def formatOpArg(opTuple):
if opTuple[1].startswith("#$"):
return opTuple[1][2:]
elif re.match(r"^\$[0-9]", opTuple[1]):
return opTuple[1][1:]
return opTuple[1].lower()
def formatOpCode(opTuple):
return opTuple[0].lower() | 21.421053 | 43 | 0.609337 | 57 | 407 | 4.350877 | 0.473684 | 0.16129 | 0.169355 | 0.120968 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.055901 | 0.208845 | 407 | 19 | 44 | 21.421053 | 0.714286 | 0 | 0 | 0 | 0 | 0 | 0.02451 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.266667 | false | 0 | 0.066667 | 0.133333 | 0.733333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
ac99134b82f5918a8533851604aabc3ec625676e | 186 | py | Python | output/models/sun_data/elem_decl/name/name00503m/name00503m1_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | 1 | 2021-08-14T17:59:21.000Z | 2021-08-14T17:59:21.000Z | output/models/sun_data/elem_decl/name/name00503m/name00503m1_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | 4 | 2020-02-12T21:30:44.000Z | 2020-04-15T20:06:46.000Z | output/models/sun_data/elem_decl/name/name00503m/name00503m1_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | null | null | null | from output.models.sun_data.elem_decl.name.name00503m.name00503m1_xsd.name00503m1 import (
Global1,
Global2,
Root,
)
__all__ = [
"Global1",
"Global2",
"Root",
]
| 15.5 | 90 | 0.655914 | 20 | 186 | 5.75 | 0.8 | 0.243478 | 0.313043 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.143836 | 0.215054 | 186 | 11 | 91 | 16.909091 | 0.643836 | 0 | 0 | 0 | 0 | 0 | 0.096774 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.1 | 0 | 0.1 | 0 | 1 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
acb6f752327128a5f270ed874ac073b8fddef397 | 5,935 | py | Python | lib/RV_mod/CustomNestedSampler.py | Simske/exostriker | 587b0af4c9cadb46637a4ac61a5392a596e966b1 | [
"MIT"
] | null | null | null | lib/RV_mod/CustomNestedSampler.py | Simske/exostriker | 587b0af4c9cadb46637a4ac61a5392a596e966b1 | [
"MIT"
] | null | null | null | lib/RV_mod/CustomNestedSampler.py | Simske/exostriker | 587b0af4c9cadb46637a4ac61a5392a596e966b1 | [
"MIT"
] | null | null | null | #!/usr/bin/python
__author__ = 'Trifon Trifonov'
import sys
#sys.path.insert(0, '../lib')
import numpy as np
import dynesty
class CustomNestedSampler(dynesty.NestedSampler):
def convert_to_samples(self):
self.samples = self.results.samples
def unique_rows(self):
'''
Given an array, remove identical rows and also sort it
'''
# Perform lex sort and get sorted data
sorted_idx = np.lexsort(self.flatchain.T)
sorted_data = self.flatchain[sorted_idx,:]
# Get unique row mask
row_mask = np.append([True],np.any(np.diff(sorted_data,axis=0),1))
# Get unique rows
out = sorted_data[row_mask]
self.samples = out
# same for LnL
lnL = np.hstack(self.lnprobability)
sorted_lnL = lnL[sorted_idx]
self.lnL = sorted_lnL[row_mask]
lnL_min_idx = np.argmax(self.lnL)
#print(abs(lnL_min))
# get samples at minimum Lnl
self.minlnL = out[lnL_min_idx]
self.lnL_min = self.lnL[lnL_min_idx]
return
def correct_rows(self,f,ndset,npl):
'''Corrects angles and eccentricities for all samples'''
i=0
self.means=np.zeros(len(f))
for k in range(len(f)):
idx=f[k]
if (idx<2*ndset):
self.means[i]=np.mean(self.samples[:,i])
elif (idx<2*ndset+7*npl):
nr=idx-2*ndset
#x=int(nr/7)
if (np.mod(nr,7)<2):
self.means[i]=np.mean(self.samples[:,i])
elif (np.mod(nr,7)==2): # correct eccentricities
for j in range(len(self.samples)):
if (self.samples[j,i]<0):
self.samples[j,i]=abs(self.samples[j,i])
#if(f[k+1]==i+1):
# self.samples[j,i+1]=self.samples[j,i+1]+180.0
#if(f[k+2]==i+2):
# self.samples[j,i+2]=self.samples[j,i+2]+-180.0
self.means[i]=np.mean(self.samples[:,i])
elif (np.mod(nr,7)==3): # correct w to be in a 360 interval around mean value
self.means[i]=np.mean(self.samples[:,i])
meanw=self.means[i]
for j in range(len(self.samples)):
self.samples[j,i]=np.where(self.samples[j,i]<meanw-180.0,self.samples[j,i]+360.0,self.samples[j,i])
self.samples[j,i]=np.where(self.samples[j,i]>meanw+180.0,self.samples[j,i]-360.0,self.samples[j,i])
# now let's make sure meanw is between 0 and 360:
newmeanw=np.fmod(meanw,360.0)
delta=newmeanw-meanw
if not (delta==0):
for j in range(len(self.samples)):
self.samples[j,i]=self.samples[j,i]+delta
elif (np.mod(nr,7)==4):# correct M to be in a 360 interval around mean value
self.means[i]=np.mean(self.samples[:,i])
meanM=self.means[i]
for j in range(len(self.samples)):
self.samples[j,i]=np.where(self.samples[j,i]<meanM-180.0,self.samples[j,i]+360.0,self.samples[j,i])
self.samples[j,i]=np.where(self.samples[j,i]>meanM+180.0,self.samples[j,i]-360.0,self.samples[j,i])
# now let's make sure meanw is between 0 and 360:
newmeanM=np.fmod(meanM,360.0)
delta=newmeanM-meanM
if not (delta==0):
for j in range(len(self.samples)):
self.samples[j,i]=self.samples[j,i]+delta
elif (idx<2*ndset+6*npl):# correct i to be in a 180 interval around mean value
self.means[i]=np.mean(self.samples[:,i])
meani=self.means[i]
for j in range(len(self.samples)):
self.samples[j,i]=np.where(self.samples[j,i]<meani-90.0,self.samples[j,i]+180.0,self.samples[j,i])
self.samples[j,i]=np.where(self.samples[j,i]>meani+90.0,self.samples[j,i]-180.0,self.samples[j,i])
# now let's make sure meani is between 0 and 180:
newmeani=np.fmod(meani,180.0)
delta=newmeani-meani
if not (delta==0):
for j in range(len(self.samples)):
self.samples[j,i]=self.samples[j,i]+delta
elif (idx<2*ndset+7*npl):# correct lineofnodes to be in a 360 interval around mean value
self.means[i]=np.mean(self.samples[:,i])
meancap=self.means[i]
for j in range(len(self.samples)):
self.samples[j,i]=np.where(self.samples[j,i]<meancap-180.0,self.samples[j,i]+360.0,self.samples[j,i])
self.samples[j,i]=np.where(self.samples[j,i]>meancap+180.0,self.samples[j,i]-360.0,self.samples[j,i])
# now let's make sure meancap is between 0 and 360:
newmeancap=np.fmod(meancap,360.0)
delta=newmeancap-meancap
if not (delta==0):
for j in range(len(self.samples)):
self.samples[j,i]=self.samples[j,i]+delta
else:
self.means[i]=np.mean(self.samples[:,i])
i=i+1
return
def save_samples(self,f,ndset,npl):
self.unique_rows()
self.correct_rows(f,ndset,npl)
return
| 43.962963 | 127 | 0.487279 | 809 | 5,935 | 3.537701 | 0.156984 | 0.253669 | 0.197065 | 0.213487 | 0.573725 | 0.556953 | 0.551013 | 0.521314 | 0.51153 | 0.500349 | 0 | 0.040555 | 0.38096 | 5,935 | 134 | 128 | 44.291045 | 0.738432 | 0.146083 | 0 | 0.340909 | 0 | 0 | 0.002989 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.045455 | false | 0 | 0.034091 | 0 | 0.125 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
acc398831b9737d97091033403f974c7778787ba | 7,288 | py | Python | affiliates/banners/migrations/0004_auto__add_field_firefoxupgradebannervariation_width__add_field_firefox.py | glogiotatidis/affiliates | 34d0ded8e24be9dd207d6419a5157dc8ce34bc06 | [
"BSD-3-Clause"
] | 15 | 2015-01-01T07:17:44.000Z | 2020-11-09T06:28:29.000Z | affiliates/banners/migrations/0004_auto__add_field_firefoxupgradebannervariation_width__add_field_firefox.py | glogiotatidis/affiliates | 34d0ded8e24be9dd207d6419a5157dc8ce34bc06 | [
"BSD-3-Clause"
] | 16 | 2015-02-25T23:17:27.000Z | 2015-08-20T10:28:18.000Z | affiliates/banners/migrations/0004_auto__add_field_firefoxupgradebannervariation_width__add_field_firefox.py | glogiotatidis/affiliates | 34d0ded8e24be9dd207d6419a5157dc8ce34bc06 | [
"BSD-3-Clause"
] | 12 | 2015-01-17T20:57:03.000Z | 2019-11-03T15:04:31.000Z | # -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'FirefoxUpgradeBannerVariation.width'
db.add_column(u'banners_firefoxupgradebannervariation', 'width',
self.gf('django.db.models.fields.PositiveIntegerField')(default=0),
keep_default=False)
# Adding field 'FirefoxUpgradeBannerVariation.height'
db.add_column(u'banners_firefoxupgradebannervariation', 'height',
self.gf('django.db.models.fields.PositiveIntegerField')(default=0),
keep_default=False)
# Adding field 'ImageBannerVariation.width'
db.add_column(u'banners_imagebannervariation', 'width',
self.gf('django.db.models.fields.PositiveIntegerField')(default=0),
keep_default=False)
# Adding field 'ImageBannerVariation.height'
db.add_column(u'banners_imagebannervariation', 'height',
self.gf('django.db.models.fields.PositiveIntegerField')(default=0),
keep_default=False)
def backwards(self, orm):
# Deleting field 'FirefoxUpgradeBannerVariation.width'
db.delete_column(u'banners_firefoxupgradebannervariation', 'width')
# Deleting field 'FirefoxUpgradeBannerVariation.height'
db.delete_column(u'banners_firefoxupgradebannervariation', 'height')
# Deleting field 'ImageBannerVariation.width'
db.delete_column(u'banners_imagebannervariation', 'width')
# Deleting field 'ImageBannerVariation.height'
db.delete_column(u'banners_imagebannervariation', 'height')
models = {
u'banners.category': {
'Meta': {'object_name': 'Category'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
u'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
u'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'parent': ('mptt.fields.TreeForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': u"orm['banners.Category']"}),
u'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
u'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
},
u'banners.firefoxupgradebanner': {
'Meta': {'object_name': 'FirefoxUpgradeBanner'},
'category': ('mptt.fields.TreeForeignKey', [], {'to': u"orm['banners.Category']"}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'destination': ('django.db.models.fields.URLField', [], {'max_length': '255'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'visible': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
},
u'banners.firefoxupgradebannervariation': {
'Meta': {'object_name': 'FirefoxUpgradeBannerVariation'},
'banner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'variation_set'", 'to': u"orm['banners.FirefoxUpgradeBanner']"}),
'color': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'height': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '255'}),
'locale': ('affiliates.base.models.LocaleField', [], {'default': "'en-US'", 'max_length': '32'}),
'upgrade_image': ('django.db.models.fields.files.ImageField', [], {'max_length': '255'}),
'width': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
},
u'banners.imagebanner': {
'Meta': {'object_name': 'ImageBanner'},
'category': ('mptt.fields.TreeForeignKey', [], {'to': u"orm['banners.Category']"}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'destination': ('django.db.models.fields.URLField', [], {'max_length': '255'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'visible': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
},
u'banners.imagebannervariation': {
'Meta': {'object_name': 'ImageBannerVariation'},
'banner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'variation_set'", 'to': u"orm['banners.ImageBanner']"}),
'color': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'height': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '255'}),
'locale': ('affiliates.base.models.LocaleField', [], {'default': "'en-US'", 'max_length': '32'}),
'width': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
},
u'banners.textbanner': {
'Meta': {'object_name': 'TextBanner'},
'category': ('mptt.fields.TreeForeignKey', [], {'to': u"orm['banners.Category']"}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'destination': ('django.db.models.fields.URLField', [], {'max_length': '255'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'visible': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
},
u'banners.textbannervariation': {
'Meta': {'object_name': 'TextBannerVariation'},
'banner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'variation_set'", 'to': u"orm['banners.TextBanner']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'locale': ('affiliates.base.models.LocaleField', [], {'default': "'en-US'", 'max_length': '32'}),
'text': ('django.db.models.fields.TextField', [], {})
}
}
complete_apps = ['banners']
| 62.290598 | 156 | 0.586855 | 698 | 7,288 | 6.024355 | 0.138968 | 0.085612 | 0.146492 | 0.209275 | 0.780975 | 0.770273 | 0.674197 | 0.674197 | 0.66302 | 0.625922 | 0 | 0.008628 | 0.204857 | 7,288 | 116 | 157 | 62.827586 | 0.716997 | 0.055571 | 0 | 0.478723 | 0 | 0 | 0.545613 | 0.357195 | 0 | 0 | 0 | 0 | 0 | 1 | 0.021277 | false | 0 | 0.042553 | 0 | 0.095745 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
accfed889e7bf57ef6b53f3df5d588c30491fa95 | 5,635 | py | Python | scripts/python/catalyst/updatedSCR/opt_550C.py | coelectrolyzer/cats | 21f8e6f5f176767ec403ad2738c80a5a71fba959 | [
"MIT"
] | 1 | 2022-02-17T16:37:12.000Z | 2022-02-17T16:37:12.000Z | scripts/python/catalyst/updatedSCR/opt_550C.py | coelectrolyzer/cats | 21f8e6f5f176767ec403ad2738c80a5a71fba959 | [
"MIT"
] | 5 | 2021-10-30T00:06:31.000Z | 2022-03-09T13:34:07.000Z | scripts/python/catalyst/updatedSCR/opt_550C.py | coelectrolyzer/cats | 21f8e6f5f176767ec403ad2738c80a5a71fba959 | [
"MIT"
] | 3 | 2021-05-08T02:26:08.000Z | 2022-03-01T22:27:40.000Z | #This file is used to rerun a simulation using newly found parameters.
#The purpose is for additional refinement of kinetics. We will reuse this
#script for additional optimization passes.
import sys
sys.path.append('../..')
from catalyst.isothermal_monolith_catalysis import *
Tstr = "550C"
run = "05"
oldrun="04"
readfile = 'output/'+Tstr+'_model'+oldrun+'.json'
writefile = Tstr+"_model"+run+".json"
sim = Isothermal_Monolith_Simulator()
sim.load_model_full(readfile, reset_param_bounds=True)
sim.unfix_all_reactions()
# Fix the isotherm parameters (we assume that these are knowns)
'''
sim.fix_reaction("r1")
sim.fix_reaction("r2a")
sim.fix_reaction("r2b")
sim.fix_reaction("r3")
sim.fix_reaction("r4a")
sim.fix_reaction("r4b")
'''
# ============= Modify parameter bounds =================
# Specify modifications to parameter boundaries (default = +/- 20%)
for rxn in sim.model.arrhenius_rxns:
sim.fix_reaction(rxn)
for rxn in sim.model.equ_arrhenius_rxns:
sim.set_reaction_param_bounds(rxn, "A", factor=0)
sim.set_reaction_param_bounds(rxn, "E", factor=0)
sim.set_reaction_param_bounds(rxn, "dS", factor=0)
#call solver
sim.finalize_auto_scaling()
sim.run_solver()
sim.print_results_of_breakthrough(["NH3","NO","NO2","N2O","O2","N2","H2O"],
"Unaged", Tstr, file_name="Unaged_SCR_"+Tstr+"_breakthrough.txt")
sim.print_results_of_location(["NH3","NO","NO2","N2O","O2","N2","H2O"],
"Unaged", Tstr, 0, file_name="Unaged_SCR_"+Tstr+"_bypass.txt")
sim.print_results_of_integral_average(["Z1CuOH-NH3","Z2Cu-NH3","Z2Cu-(NH3)2","ZNH4",
"Z1CuOH-NH4NO3", "Z2Cu-NH4NO3", "ZH-NH4NO3"],
"Unaged", Tstr, file_name="Unaged_SCR_"+Tstr+"_average_ads.txt")
sim.print_results_of_breakthrough(["NH3","NO","NO2","N2O","O2","N2","H2O"],
"2hr", Tstr, file_name="2hr_SCR_"+Tstr+"_breakthrough.txt")
sim.print_results_of_location(["NH3","NO","NO2","N2O","O2","N2","H2O"],
"2hr", Tstr, 0, file_name="2hr_SCR_"+Tstr+"_bypass.txt")
sim.print_results_of_integral_average(["Z1CuOH-NH3","Z2Cu-NH3","Z2Cu-(NH3)2","ZNH4",
"Z1CuOH-NH4NO3", "Z2Cu-NH4NO3", "ZH-NH4NO3"],
"2hr", Tstr, file_name="2hr_SCR_"+Tstr+"_average_ads.txt")
sim.print_results_of_breakthrough(["NH3","NO","NO2","N2O","O2","N2","H2O"],
"4hr", Tstr, file_name="4hr_SCR_"+Tstr+"_breakthrough.txt")
sim.print_results_of_location(["NH3","NO","NO2","N2O","O2","N2","H2O"],
"4hr", Tstr, 0, file_name="4hr_SCR_"+Tstr+"_bypass.txt")
sim.print_results_of_integral_average(["Z1CuOH-NH3","Z2Cu-NH3","Z2Cu-(NH3)2","ZNH4",
"Z1CuOH-NH4NO3", "Z2Cu-NH4NO3", "ZH-NH4NO3"],
"4hr", Tstr, file_name="4hr_SCR_"+Tstr+"_average_ads.txt")
sim.print_results_of_breakthrough(["NH3","NO","NO2","N2O","O2","N2","H2O"],
"8hr", Tstr, file_name="8hr_SCR_"+Tstr+"_breakthrough.txt")
sim.print_results_of_location(["NH3","NO","NO2","N2O","O2","N2","H2O"],
"8hr", Tstr, 0, file_name="8hr_SCR_"+Tstr+"_bypass.txt")
sim.print_results_of_integral_average(["Z1CuOH-NH3","Z2Cu-NH3","Z2Cu-(NH3)2","ZNH4",
"Z1CuOH-NH4NO3", "Z2Cu-NH4NO3", "ZH-NH4NO3"],
"8hr", Tstr, file_name="8hr_SCR_"+Tstr+"_average_ads.txt")
sim.print_results_of_breakthrough(["NH3","NO","NO2","N2O","O2","N2","H2O"],
"16hr", Tstr, file_name="16hr_SCR_"+Tstr+"_breakthrough.txt")
sim.print_results_of_location(["NH3","NO","NO2","N2O","O2","N2","H2O"],
"16hr", Tstr, 0, file_name="16hr_SCR_"+Tstr+"_bypass.txt")
sim.print_results_of_integral_average(["Z1CuOH-NH3","Z2Cu-NH3","Z2Cu-(NH3)2","ZNH4",
"Z1CuOH-NH4NO3", "Z2Cu-NH4NO3", "ZH-NH4NO3"],
"16hr", Tstr, file_name="16hr_SCR_"+Tstr+"_average_ads.txt")
sim.print_kinetic_parameter_info(file_name=Tstr+"_opt_params"+run+".txt")
sim.save_model_state(file_name=writefile)
sim.plot_vs_data("NH3", "Unaged", Tstr, 5, display_live=False)
sim.plot_vs_data("NH3", "2hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NH3", "4hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NH3", "8hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NH3", "16hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NO", "Unaged", Tstr, 5, display_live=False)
sim.plot_vs_data("NO", "2hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NO", "4hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NO", "8hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NO", "16hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NO2", "Unaged", Tstr, 5, display_live=False)
sim.plot_vs_data("NO2", "2hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NO2", "4hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NO2", "8hr", Tstr, 5, display_live=False)
sim.plot_vs_data("NO2", "16hr", Tstr, 5, display_live=False)
sim.plot_vs_data("N2O", "Unaged", Tstr, 5, display_live=False)
sim.plot_vs_data("N2O", "2hr", Tstr, 5, display_live=False)
sim.plot_vs_data("N2O", "4hr", Tstr, 5, display_live=False)
sim.plot_vs_data("N2O", "8hr", Tstr, 5, display_live=False)
sim.plot_vs_data("N2O", "16hr", Tstr, 5, display_live=False)
| 50.765766 | 105 | 0.612777 | 777 | 5,635 | 4.163449 | 0.172458 | 0.043277 | 0.055641 | 0.080371 | 0.752087 | 0.719011 | 0.702628 | 0.64544 | 0.623802 | 0.599691 | 0 | 0.055074 | 0.200887 | 5,635 | 110 | 106 | 51.227273 | 0.663336 | 0.067613 | 0 | 0.263158 | 0 | 0 | 0.217929 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.065789 | 0.026316 | 0 | 0.026316 | 0.210526 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
aceda4ca077ef88f8c623e1f98ac49a59a00653c | 338 | py | Python | Python/ENEM.py | jacksontenorio8/python | a484f019960faa5aa29177eff44a1bb1e3f3b9d0 | [
"MIT"
] | null | null | null | Python/ENEM.py | jacksontenorio8/python | a484f019960faa5aa29177eff44a1bb1e3f3b9d0 | [
"MIT"
] | null | null | null | Python/ENEM.py | jacksontenorio8/python | a484f019960faa5aa29177eff44a1bb1e3f3b9d0 | [
"MIT"
] | null | null | null | n1 = float(input('Redação:'))
n2 = float(input('Ciências da Natureza e suas Tecnologias:'))
n3 = float(input('Ciências Humanas e suas Tecnologias:'))
n4 = float(input('Linguagens, Códigos e suas Tecnologias:'))
n5 = float(input('Matemática e suas Tecnologias:'))
x = (n1 + n2 + n3 + n4 + n5) / 5
print('Sua média no Enem é: {}'.format(x)) | 48.285714 | 61 | 0.680473 | 51 | 338 | 4.509804 | 0.529412 | 0.217391 | 0.278261 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.038062 | 0.14497 | 338 | 7 | 62 | 48.285714 | 0.757785 | 0 | 0 | 0 | 0 | 0 | 0.519174 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.142857 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4a05360d8ccb06f1e2662826f1085fc5a034833d | 521 | py | Python | cacahuate/indexes.py | categulario/cacahuate | 830b1656c8b5d183af637a47f9f3bcd04287f6b4 | [
"MIT"
] | null | null | null | cacahuate/indexes.py | categulario/cacahuate | 830b1656c8b5d183af637a47f9f3bcd04287f6b4 | [
"MIT"
] | null | null | null | cacahuate/indexes.py | categulario/cacahuate | 830b1656c8b5d183af637a47f9f3bcd04287f6b4 | [
"MIT"
] | null | null | null | from pymongo import MongoClient
def create_indexes(config):
# Create index
mongo = MongoClient(config['MONGO_URI'])
db = getattr(mongo, config['MONGO_DBNAME'])
db.execution.create_index("id", unique=True)
db.execution.create_index("status")
db.execution.create_index("started_at")
db.execution.create_index("finished_at")
db.pointer.create_index("status")
db.pointer.create_index("execution.id")
db.pointer.create_index("started_at")
db.pointer.create_index("finished_at")
| 28.944444 | 48 | 0.725528 | 68 | 521 | 5.338235 | 0.338235 | 0.272727 | 0.187328 | 0.242424 | 0.231405 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.140115 | 521 | 17 | 49 | 30.647059 | 0.810268 | 0.023033 | 0 | 0 | 0 | 0 | 0.175542 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | false | 0 | 0.083333 | 0 | 0.166667 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
4a22e9efe0e177af5a16467e8e24da5520b89845 | 21,414 | py | Python | gps_pb2.py | djhedges/exit_speed | 86c8a36dd7c53d9f67157c359625b8d33715f917 | [
"Apache-2.0"
] | 10 | 2020-09-25T19:48:50.000Z | 2021-10-13T13:42:56.000Z | gps_pb2.py | djhedges/exit_speed | 86c8a36dd7c53d9f67157c359625b8d33715f917 | [
"Apache-2.0"
] | null | null | null | gps_pb2.py | djhedges/exit_speed | 86c8a36dd7c53d9f67157c359625b8d33715f917 | [
"Apache-2.0"
] | 1 | 2021-02-08T14:50:48.000Z | 2021-02-08T14:50:48.000Z | # pytype: skip-file
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: gps.proto
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
DESCRIPTOR = _descriptor.FileDescriptor(
name='gps.proto',
package='gps',
syntax='proto3',
serialized_options=b'Z8github.com/djhedges/exit_speed/gps_go_proto;gps_go_proto',
serialized_pb=b'\n\tgps.proto\x12\x03gps\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xa7\x06\n\x05Point\x12\x0b\n\x03lat\x18\x01 \x01(\x01\x12\x0b\n\x03lon\x18\x02 \x01(\x01\x12\x0b\n\x03\x61lt\x18\x03 \x01(\x01\x12\r\n\x05speed\x18\x04 \x01(\x01\x12(\n\x04time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1d\n\x15start_finish_distance\x18\x06 \x01(\x01\x12\x13\n\x0btps_voltage\x18\x07 \x01(\x01\x12\x1a\n\x12water_temp_voltage\x18\x08 \x01(\x01\x12\x1c\n\x14oil_pressure_voltage\x18\t \x01(\x01\x12\x0b\n\x03rpm\x18\n \x01(\x01\x12\x0b\n\x03\x61\x66r\x18\x0b \x01(\x01\x12\x1a\n\x12\x66uel_level_voltage\x18\x0c \x01(\x01\x12\x17\n\x0f\x61\x63\x63\x65lerometer_x\x18\r \x01(\x01\x12\x17\n\x0f\x61\x63\x63\x65lerometer_y\x18\x0e \x01(\x01\x12\x17\n\x0f\x61\x63\x63\x65lerometer_z\x18\x0f \x01(\x01\x12\r\n\x05pitch\x18\x10 \x01(\x01\x12\x0c\n\x04roll\x18\x11 \x01(\x01\x12\x0e\n\x06gyro_x\x18\x12 \x01(\x01\x12\x0e\n\x06gyro_y\x18\x13 \x01(\x01\x12\x0e\n\x06gyro_z\x18\x14 \x01(\x01\x12\x0f\n\x07geohash\x18\x15 \x01(\t\x12$\n\x1c\x66ront_brake_pressure_voltage\x18\x16 \x01(\x01\x12#\n\x1brear_brake_pressure_voltage\x18\x17 \x01(\x01\x12\x17\n\x0f\x62\x61ttery_voltage\x18\x18 \x01(\x01\x12\x18\n\x10oil_temp_voltage\x18\x19 \x01(\x01\x12\x1b\n\x13\x65lapsed_duration_ms\x18\x1a \x01(\x01\x12\x1a\n\x12\x65lapsed_distance_m\x18\x1b \x01(\x01\x12\x16\n\x0elabjack_temp_f\x18\x1c \x01(\x01\x12\'\n\x0clf_tire_temp\x18\x1d \x01(\x0b\x32\x11.gps.TireIrSensor\x12\'\n\x0crf_tire_temp\x18\x1e \x01(\x0b\x32\x11.gps.TireIrSensor\x12\'\n\x0clr_tire_temp\x18\x1f \x01(\x0b\x32\x11.gps.TireIrSensor\x12\'\n\x0crr_tire_temp\x18 \x01(\x0b\x32\x11.gps.TireIrSensor\"^\n\x03Lap\x12\x1a\n\x06points\x18\x01 \x03(\x0b\x32\n.gps.Point\x12+\n\x08\x64uration\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x0e\n\x06number\x18\x03 \x01(\x05\"R\n\x07Session\x12\x16\n\x04laps\x18\x01 \x03(\x0b\x32\x08.gps.Lap\x12\r\n\x05track\x18\x02 \x01(\t\x12 \n\x0cstart_finish\x18\x03 \x01(\x0b\x32\n.gps.Point\"<\n\x0cTireIrSensor\x12\r\n\x05inner\x18\x01 \x01(\x01\x12\x0e\n\x06middle\x18\x02 \x01(\x01\x12\r\n\x05outer\x18\x03 \x01(\x01\x42:Z8github.com/djhedges/exit_speed/gps_go_proto;gps_go_protob\x06proto3'
,
dependencies=[google_dot_protobuf_dot_duration__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,])
_POINT = _descriptor.Descriptor(
name='Point',
full_name='gps.Point',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='lat', full_name='gps.Point.lat', index=0,
number=1, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='lon', full_name='gps.Point.lon', index=1,
number=2, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='alt', full_name='gps.Point.alt', index=2,
number=3, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='speed', full_name='gps.Point.speed', index=3,
number=4, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='time', full_name='gps.Point.time', index=4,
number=5, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='start_finish_distance', full_name='gps.Point.start_finish_distance', index=5,
number=6, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='tps_voltage', full_name='gps.Point.tps_voltage', index=6,
number=7, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='water_temp_voltage', full_name='gps.Point.water_temp_voltage', index=7,
number=8, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='oil_pressure_voltage', full_name='gps.Point.oil_pressure_voltage', index=8,
number=9, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='rpm', full_name='gps.Point.rpm', index=9,
number=10, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='afr', full_name='gps.Point.afr', index=10,
number=11, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='fuel_level_voltage', full_name='gps.Point.fuel_level_voltage', index=11,
number=12, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='accelerometer_x', full_name='gps.Point.accelerometer_x', index=12,
number=13, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='accelerometer_y', full_name='gps.Point.accelerometer_y', index=13,
number=14, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='accelerometer_z', full_name='gps.Point.accelerometer_z', index=14,
number=15, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='pitch', full_name='gps.Point.pitch', index=15,
number=16, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='roll', full_name='gps.Point.roll', index=16,
number=17, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='gyro_x', full_name='gps.Point.gyro_x', index=17,
number=18, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='gyro_y', full_name='gps.Point.gyro_y', index=18,
number=19, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='gyro_z', full_name='gps.Point.gyro_z', index=19,
number=20, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='geohash', full_name='gps.Point.geohash', index=20,
number=21, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=b"".decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='front_brake_pressure_voltage', full_name='gps.Point.front_brake_pressure_voltage', index=21,
number=22, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='rear_brake_pressure_voltage', full_name='gps.Point.rear_brake_pressure_voltage', index=22,
number=23, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='battery_voltage', full_name='gps.Point.battery_voltage', index=23,
number=24, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='oil_temp_voltage', full_name='gps.Point.oil_temp_voltage', index=24,
number=25, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='elapsed_duration_ms', full_name='gps.Point.elapsed_duration_ms', index=25,
number=26, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='elapsed_distance_m', full_name='gps.Point.elapsed_distance_m', index=26,
number=27, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='labjack_temp_f', full_name='gps.Point.labjack_temp_f', index=27,
number=28, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='lf_tire_temp', full_name='gps.Point.lf_tire_temp', index=28,
number=29, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='rf_tire_temp', full_name='gps.Point.rf_tire_temp', index=29,
number=30, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='lr_tire_temp', full_name='gps.Point.lr_tire_temp', index=30,
number=31, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='rr_tire_temp', full_name='gps.Point.rr_tire_temp', index=31,
number=32, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=84,
serialized_end=891,
)
_LAP = _descriptor.Descriptor(
name='Lap',
full_name='gps.Lap',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='points', full_name='gps.Lap.points', index=0,
number=1, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='duration', full_name='gps.Lap.duration', index=1,
number=2, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='number', full_name='gps.Lap.number', index=2,
number=3, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=893,
serialized_end=987,
)
_SESSION = _descriptor.Descriptor(
name='Session',
full_name='gps.Session',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='laps', full_name='gps.Session.laps', index=0,
number=1, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='track', full_name='gps.Session.track', index=1,
number=2, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=b"".decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='start_finish', full_name='gps.Session.start_finish', index=2,
number=3, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=989,
serialized_end=1071,
)
_TIREIRSENSOR = _descriptor.Descriptor(
name='TireIrSensor',
full_name='gps.TireIrSensor',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='inner', full_name='gps.TireIrSensor.inner', index=0,
number=1, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='middle', full_name='gps.TireIrSensor.middle', index=1,
number=2, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='outer', full_name='gps.TireIrSensor.outer', index=2,
number=3, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=1073,
serialized_end=1133,
)
_POINT.fields_by_name['time'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP
_POINT.fields_by_name['lf_tire_temp'].message_type = _TIREIRSENSOR
_POINT.fields_by_name['rf_tire_temp'].message_type = _TIREIRSENSOR
_POINT.fields_by_name['lr_tire_temp'].message_type = _TIREIRSENSOR
_POINT.fields_by_name['rr_tire_temp'].message_type = _TIREIRSENSOR
_LAP.fields_by_name['points'].message_type = _POINT
_LAP.fields_by_name['duration'].message_type = google_dot_protobuf_dot_duration__pb2._DURATION
_SESSION.fields_by_name['laps'].message_type = _LAP
_SESSION.fields_by_name['start_finish'].message_type = _POINT
DESCRIPTOR.message_types_by_name['Point'] = _POINT
DESCRIPTOR.message_types_by_name['Lap'] = _LAP
DESCRIPTOR.message_types_by_name['Session'] = _SESSION
DESCRIPTOR.message_types_by_name['TireIrSensor'] = _TIREIRSENSOR
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
Point = _reflection.GeneratedProtocolMessageType('Point', (_message.Message,), {
'DESCRIPTOR' : _POINT,
'__module__' : 'gps_pb2'
# @@protoc_insertion_point(class_scope:gps.Point)
})
_sym_db.RegisterMessage(Point)
Lap = _reflection.GeneratedProtocolMessageType('Lap', (_message.Message,), {
'DESCRIPTOR' : _LAP,
'__module__' : 'gps_pb2'
# @@protoc_insertion_point(class_scope:gps.Lap)
})
_sym_db.RegisterMessage(Lap)
Session = _reflection.GeneratedProtocolMessageType('Session', (_message.Message,), {
'DESCRIPTOR' : _SESSION,
'__module__' : 'gps_pb2'
# @@protoc_insertion_point(class_scope:gps.Session)
})
_sym_db.RegisterMessage(Session)
TireIrSensor = _reflection.GeneratedProtocolMessageType('TireIrSensor', (_message.Message,), {
'DESCRIPTOR' : _TIREIRSENSOR,
'__module__' : 'gps_pb2'
# @@protoc_insertion_point(class_scope:gps.TireIrSensor)
})
_sym_db.RegisterMessage(TireIrSensor)
DESCRIPTOR._options = None
# @@protoc_insertion_point(module_scope)
| 46.653595 | 2,244 | 0.736761 | 2,996 | 21,414 | 4.984312 | 0.086115 | 0.068037 | 0.033148 | 0.054912 | 0.734347 | 0.695908 | 0.657269 | 0.646822 | 0.63805 | 0.616353 | 0 | 0.050024 | 0.134632 | 21,414 | 458 | 2,245 | 46.755459 | 0.755815 | 0.018026 | 0 | 0.670588 | 1 | 0.007059 | 0.181282 | 0.131132 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.014118 | 0 | 0.014118 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
c5b510a3bd4ac2f1ebe80b2ae1c5e2d0e3bdfc7b | 434 | py | Python | catalyst/contrib/modules/__init__.py | andrey-avdeev/catalyst | fd17aaba7775c99b7e2b1ce86e60aa8f2379acc3 | [
"Apache-2.0"
] | 1 | 2019-12-15T18:29:15.000Z | 2019-12-15T18:29:15.000Z | catalyst/contrib/modules/__init__.py | andrey-avdeev/catalyst | fd17aaba7775c99b7e2b1ce86e60aa8f2379acc3 | [
"Apache-2.0"
] | null | null | null | catalyst/contrib/modules/__init__.py | andrey-avdeev/catalyst | fd17aaba7775c99b7e2b1ce86e60aa8f2379acc3 | [
"Apache-2.0"
] | 1 | 2021-12-20T07:32:25.000Z | 2021-12-20T07:32:25.000Z | # flake8: noqa
from torch.nn import *
from .common import Flatten, Lambda
from .lama import LamaPooling, TemporalAttentionPooling, TemporalConcatPooling
from .noisy import NoisyFactorizedLinear, NoisyLinear
from .pooling import (
GlobalAttnPool2d, GlobalAvgAttnPool2d, GlobalAvgPool2d,
GlobalConcatAttnPool2d, GlobalConcatPool2d, GlobalMaxAttnPool2d,
GlobalMaxPool2d
)
from .real_nvp import CouplingLayer, SquashingLayer
| 33.384615 | 78 | 0.827189 | 38 | 434 | 9.421053 | 0.736842 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020997 | 0.12212 | 434 | 12 | 79 | 36.166667 | 0.918635 | 0.02765 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.6 | 0 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
c5b70a98c509f5fe4e886322ea7fc5feb7d58378 | 113 | py | Python | django_kea/__init__.py | euronetzrt/django-kea | f0c2a2766008683b45371f0bfe24562bc1a399d6 | [
"MIT"
] | null | null | null | django_kea/__init__.py | euronetzrt/django-kea | f0c2a2766008683b45371f0bfe24562bc1a399d6 | [
"MIT"
] | null | null | null | django_kea/__init__.py | euronetzrt/django-kea | f0c2a2766008683b45371f0bfe24562bc1a399d6 | [
"MIT"
] | null | null | null | from django.apps import AppConfig
class ISCKea(AppConfig):
name = 'django_kea'
verbose_name = 'ISC Kea'
| 18.833333 | 33 | 0.716814 | 15 | 113 | 5.266667 | 0.733333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.19469 | 113 | 5 | 34 | 22.6 | 0.868132 | 0 | 0 | 0 | 0 | 0 | 0.150442 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
c5bdf021f642ddb75e5df75a94cb4bd64b8420c1 | 116 | py | Python | hello.py | Flaviusns/charlaGit | d0249648f5fb2948216642ff2e89133f0ef85664 | [
"MIT"
] | null | null | null | hello.py | Flaviusns/charlaGit | d0249648f5fb2948216642ff2e89133f0ef85664 | [
"MIT"
] | null | null | null | hello.py | Flaviusns/charlaGit | d0249648f5fb2948216642ff2e89133f0ef85664 | [
"MIT"
] | null | null | null | print("Hello world")
print("Adios")
def suma(a,b):
return a+b
print(suma(2,3))
print("Esto es una feature") | 10.545455 | 28 | 0.637931 | 21 | 116 | 3.52381 | 0.714286 | 0.054054 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020833 | 0.172414 | 116 | 11 | 28 | 10.545455 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0.299145 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0 | 0.166667 | 0.333333 | 0.666667 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.