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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b8966966d28b91171cc26c0deabc2f97e8ab2303 | 2,298 | py | Python | Protheus_WebApp/Modules/SIGAGTP/GTPA107TestCase.py | 98llm/tir-script-samples | 0bff8393b79356aa562e9e6512c11ee6e039b177 | [
"MIT"
] | 17 | 2018-09-24T17:27:08.000Z | 2021-09-16T19:09:46.000Z | Protheus_WebApp/Modules/SIGAGTP/GTPA107TestCase.py | 98llm/tir-script-samples | 0bff8393b79356aa562e9e6512c11ee6e039b177 | [
"MIT"
] | 4 | 2018-09-24T17:30:32.000Z | 2022-01-03T11:39:30.000Z | Protheus_WebApp/Modules/SIGAGTP/GTPA107TestCase.py | 98llm/tir-script-samples | 0bff8393b79356aa562e9e6512c11ee6e039b177 | [
"MIT"
] | 18 | 2019-06-07T17:41:34.000Z | 2022-01-31T18:17:31.000Z | from tir import Webapp
import unittest
class GTPA107(unittest.TestCase):
@classmethod
def setUpClass(inst):
inst.oHelper = Webapp()
inst.oHelper.Setup("SIGAGTP", "20/04/2020", "T1", "D MG 01 ")
inst.oHelper.Program('GTPA107')
def test_GTPA107_CT001(self):
self.oHelper.SearchBrowse("D MG 000033", "Filial+lote Remessa")
self.oHelper.SetButton("Visualizar")
self.oHelper.SetButton("Fechar")
self.oHelper.AssertTrue()
def test_GTPA107_CT002(self):
self.oHelper.SearchBrowse("D MG 000033", "Filial+lote Remessa")
self.oHelper.SetButton("Outras Ações", "Cancelar Remessa")
self.oHelper.SetButton("OK")
self.oHelper.SetValue('GQG_NUMINI', '000010')
self.oHelper.SetValue('GQG_NUMFIM', '000010')
self.oHelper.SetButton("Confirmar")
self.oHelper.SetButton("Fechar")
self.oHelper.AssertTrue()
def test_GTPA107_CT003(self):
self.oHelper.SearchBrowse("D MG 000034", "Filial+lote Remessa")
self.oHelper.SetButton("Outras Ações", "Transferir Remessa")
self.oHelper.SetButton("OK")
self.oHelper.SetValue('GQG_NUMINI', '000010')
self.oHelper.SetValue('GQG_NUMFIM', '000010')
self.oHelper.SetValue('GQG_AGENCI', 'AGREM5')
self.oHelper.SetButton("Confirmar")
self.oHelper.SetButton("Fechar")
self.oHelper.AssertTrue()
def test_GTPA107_CT004(self):
self.oHelper.SearchBrowse("D MG 000035", "Filial+lote Remessa")
self.oHelper.SetButton("Outras Ações", "Devolução de Remessa")
self.oHelper.SetButton("OK")
self.oHelper.SetValue('GQG_NUMINI', '000010')
self.oHelper.SetValue('GQG_NUMFIM', '000010')
self.oHelper.SetButton("Confirmar")
self.oHelper.SetButton("Fechar")
self.oHelper.AssertTrue()
def test_GTPA107_CT006(self):
self.oHelper.SearchBrowse("D MG 000042", "Filial+lote Remessa")
self.oHelper.SetButton("Outras Ações", "Baixa Protocolo")
self.oHelper.SetButton("Sim")
self.oHelper.SetButton("Fechar")
self.oHelper.AssertTrue()
def test_GTPA107_CT007(self):
self.oHelper.SearchBrowse("D MG 000043", "Filial+lote Remessa")
self.oHelper.SetButton("Outras Ações", "Estorno Baixa Protocolo")
self.oHelper.SetButton("Sim")
self.oHelper.SetButton("Fechar")
self.oHelper.AssertTrue()
@classmethod
def tearDownClass(inst):
inst.oHelper.TearDown()
if __name__ == '__main__':
unittest.main()
| 32.366197 | 68 | 0.734987 | 285 | 2,298 | 5.831579 | 0.238596 | 0.258123 | 0.240674 | 0.146209 | 0.779182 | 0.772563 | 0.700361 | 0.700361 | 0.578219 | 0.578219 | 0 | 0.061765 | 0.112272 | 2,298 | 70 | 69 | 32.828571 | 0.752941 | 0 | 0 | 0.517241 | 0 | 0 | 0.25631 | 0 | 0 | 0 | 0 | 0 | 0.103448 | 1 | 0.137931 | false | 0 | 0.034483 | 0 | 0.189655 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 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 | 5 |
b8af4eb90305cd51b0b8ccea53704aa80c337336 | 159 | py | Python | links/managers.py | suwalszczyzna/libs-django | a023214bb448250764336d9680a65969547360ed | [
"Apache-2.0"
] | null | null | null | links/managers.py | suwalszczyzna/libs-django | a023214bb448250764336d9680a65969547360ed | [
"Apache-2.0"
] | null | null | null | links/managers.py | suwalszczyzna/libs-django | a023214bb448250764336d9680a65969547360ed | [
"Apache-2.0"
] | null | null | null | from django.db import models
class PublishedManager(models.Manager):
def published(self, **kwargs):
return self.filter(published=True, **kwargs)
| 22.714286 | 52 | 0.72327 | 19 | 159 | 6.052632 | 0.789474 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.163522 | 159 | 6 | 53 | 26.5 | 0.864662 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.25 | 0.25 | 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 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 5 |
b8bd853876e720c910b6503802a2ea247d30223d | 93 | py | Python | enthought/endo/version.py | enthought/etsproxy | 4aafd628611ebf7fe8311c9d1a0abcf7f7bb5347 | [
"BSD-3-Clause"
] | 3 | 2016-12-09T06:05:18.000Z | 2018-03-01T13:00:29.000Z | enthought/endo/version.py | enthought/etsproxy | 4aafd628611ebf7fe8311c9d1a0abcf7f7bb5347 | [
"BSD-3-Clause"
] | 1 | 2020-12-02T00:51:32.000Z | 2020-12-02T08:48:55.000Z | enthought/endo/version.py | enthought/etsproxy | 4aafd628611ebf7fe8311c9d1a0abcf7f7bb5347 | [
"BSD-3-Clause"
] | null | null | null | # proxy module
from __future__ import absolute_import
from etsdevtools.endo.version import *
| 23.25 | 38 | 0.83871 | 12 | 93 | 6.083333 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.11828 | 93 | 3 | 39 | 31 | 0.890244 | 0.129032 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
b21b1036d71ca9ddef6593a18a1d92f5b74250c2 | 4,014 | py | Python | models/vgg19.py | SoobumKim/Drum-Classification-pytorch | 1c40e8f08151deb4fab8b42ba9d086e86c29f3ba | [
"Apache-2.0"
] | 1 | 2021-06-10T01:43:44.000Z | 2021-06-10T01:43:44.000Z | models/vgg19.py | SoobumKim/Drum-Classification-pytorch | 1c40e8f08151deb4fab8b42ba9d086e86c29f3ba | [
"Apache-2.0"
] | null | null | null | models/vgg19.py | SoobumKim/Drum-Classification-pytorch | 1c40e8f08151deb4fab8b42ba9d086e86c29f3ba | [
"Apache-2.0"
] | null | null | null | import torch.nn as nn
class VGG19(nn.Module):
def __init__(self,in_channel=4):
super(VGG19, self).__init__()
self.conv1 = nn.Sequential(
#4 256 384
nn.Conv2d(in_channel, 64, 3, padding=1),
nn.BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(64, 64, 3, padding=1),
nn.BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2)
)
self.maxpool = nn.MaxPool2d(2,2)
#64 128 192
self.conv2 = nn.Sequential(
nn.Conv2d(64, 128, 3, padding=1),
nn.BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(128, 128, 3, padding=1),
nn.BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2)
)
#128 64 96
self.conv3 = nn.Sequential(
nn.Conv2d(128, 256, 3, padding=1),
nn.BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(256, 256, 3, padding=1),
nn.BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(256, 256, 3, padding=1),
nn.BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(256, 256, 3, padding=1),
nn.BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2)
)
#256 32 48
self.conv4 = nn.Sequential(
nn.Conv2d(256, 512, 3, padding=1),
nn.BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(512, 512, 3, padding=1),
nn.BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(512, 512, 3, padding=1),
nn.BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(512, 512, 3, padding=1),
nn.BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2)
)
#512 16 24
self.conv5 = nn.Sequential(
nn.Conv2d(512, 512, 3, padding=1),
nn.BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(512, 512, 3, padding=1),
nn.BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(512, 512, 3, padding=1),
nn.BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2),
nn.Conv2d(512, 512, 3, padding=1),
nn.BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True),
nn.LeakyReLU(0.2)
)
#512 8 12
self.avg_pool = nn.AdaptiveAvgPool2d(7)
#512 7 7
self.classifier = nn.Sequential(
nn.Linear(512*7*7,4096),
nn.ReLU(True),
nn.Linear(4096,4096),
nn.ReLU(True),
nn.Linear(4096,23),
)
def forward(self, x):
x = self.conv1(x)
x = self.maxpool(x)
x = self.conv2(x)
x = self.maxpool(x)
x = self.conv3(x)
x = self.maxpool(x)
x = self.conv4(x)
x = self.maxpool(x)
x = self.conv5(x)
x = self.maxpool(x)
x = self.avg_pool(x)
x = x.view(x.size(0), -1)
x = self.classifier(x)
return x
| 41.381443 | 96 | 0.54858 | 575 | 4,014 | 3.753043 | 0.114783 | 0.050046 | 0.066728 | 0.081557 | 0.787303 | 0.787303 | 0.787303 | 0.719184 | 0.719184 | 0.719184 | 0 | 0.145016 | 0.307673 | 4,014 | 96 | 97 | 41.8125 | 0.631522 | 0.015197 | 0 | 0.569767 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.023256 | false | 0 | 0.011628 | 0 | 0.05814 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 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 | 5 |
b24d7974f85e3ccfda57ee01eebb863f7b9eed34 | 73 | py | Python | mute.py | gitstrah/cross5548pt | 0e0e78e279319e512c9a445b618e66b48d904160 | [
"MIT"
] | null | null | null | mute.py | gitstrah/cross5548pt | 0e0e78e279319e512c9a445b618e66b48d904160 | [
"MIT"
] | null | null | null | mute.py | gitstrah/cross5548pt | 0e0e78e279319e512c9a445b618e66b48d904160 | [
"MIT"
] | null | null | null | #!/usr/bin/python
# mute
from amp import Amp
amp = Amp()
amp.pwm.mute()
| 10.428571 | 19 | 0.657534 | 13 | 73 | 3.692308 | 0.615385 | 0.375 | 0.375 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.164384 | 73 | 6 | 20 | 12.166667 | 0.786885 | 0.287671 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 5 |
b25b34d97a9ca73caf58fc814ea2d97100ee562f | 272 | py | Python | asyncsleepiq/exceptions.py | mfugate1/asyncsleepiq | aeec67cdf017b0e8fc50f7da37001e7a984f37d2 | [
"MIT"
] | null | null | null | asyncsleepiq/exceptions.py | mfugate1/asyncsleepiq | aeec67cdf017b0e8fc50f7da37001e7a984f37d2 | [
"MIT"
] | 6 | 2022-02-20T04:03:13.000Z | 2022-03-25T01:48:44.000Z | asyncsleepiq/exceptions.py | mfugate1/asyncsleepiq | aeec67cdf017b0e8fc50f7da37001e7a984f37d2 | [
"MIT"
] | 2 | 2022-02-19T18:45:35.000Z | 2022-03-04T14:13:35.000Z | """SleepIQ Exceptions."""
class SleepIQLoginException(Exception):
"""Exception in Login process."""
class SleepIQTimeoutException(Exception):
"""Timeout in Login process."""
class SleepIQAPIException(Exception):
"""Exception in API call."""
| 19.428571 | 42 | 0.676471 | 23 | 272 | 8 | 0.565217 | 0.195652 | 0.217391 | 0.206522 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.1875 | 272 | 13 | 43 | 20.923077 | 0.832579 | 0.352941 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 1 | 0 | 1 | 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 | 1 | 0 | 0 | 5 |
b2a3a8f786acdb34db58bd839f58ffa02ad1f4cc | 120 | py | Python | jtyoui/mail/__init__.py | gjh123/Jtyoui | 3fc819a4cebd9f6dc99660214efa92bc7f43eef1 | [
"MIT"
] | 2 | 2019-10-12T06:29:40.000Z | 2019-10-12T06:29:47.000Z | jtyoui/mail/__init__.py | yy1244/Jtyoui | d3c212ed9d6ffa6b37a8ca49098ab59c89216f09 | [
"MIT"
] | null | null | null | jtyoui/mail/__init__.py | yy1244/Jtyoui | d3c212ed9d6ffa6b37a8ca49098ab59c89216f09 | [
"MIT"
] | null | null | null | #!/usr/bin/python3.7
# -*- coding: utf-8 -*-
# @Time : 2019/2/18
# @Email : jtyoui@qq.com
from .qq import send_qq_mail
| 17.142857 | 28 | 0.625 | 21 | 120 | 3.47619 | 0.904762 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.09901 | 0.158333 | 120 | 6 | 29 | 20 | 0.623762 | 0.683333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
b2a85b6cdc1874e25dd812d755237109cc30a791 | 134 | py | Python | janus/tasks.py | fachschaft/django-janus | dfb50eae659329ba9d86d0ce09dcc5fac681b94c | [
"BSD-3-Clause"
] | 2 | 2020-03-22T22:14:15.000Z | 2020-06-20T13:11:12.000Z | janus/tasks.py | fachschaft/django-janus | dfb50eae659329ba9d86d0ce09dcc5fac681b94c | [
"BSD-3-Clause"
] | null | null | null | janus/tasks.py | fachschaft/django-janus | dfb50eae659329ba9d86d0ce09dcc5fac681b94c | [
"BSD-3-Clause"
] | 1 | 2020-03-16T20:44:51.000Z | 2020-03-16T20:44:51.000Z | from celery import shared_task
from oauth2_provider.models import clear_expired
@shared_task
def cleanup_token():
clear_expired() | 22.333333 | 48 | 0.828358 | 19 | 134 | 5.526316 | 0.684211 | 0.190476 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008475 | 0.119403 | 134 | 6 | 49 | 22.333333 | 0.881356 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | true | 0 | 0.4 | 0 | 0.6 | 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 | 1 | 0 | 1 | 0 | 0 | 5 |
a245dece9aafe2a3d132114b2a36412a3b6f23c6 | 179 | py | Python | libraries/hours/admin.py | cca/libraries_wagtail | f0baf62d0418ea5bb548c082aa84966aca363e56 | [
"ECL-2.0"
] | 9 | 2017-12-19T21:15:23.000Z | 2022-03-23T08:11:52.000Z | libraries/hours/admin.py | cca/libraries_wagtail | f0baf62d0418ea5bb548c082aa84966aca363e56 | [
"ECL-2.0"
] | 140 | 2017-07-12T00:09:53.000Z | 2021-11-02T17:30:43.000Z | libraries/hours/admin.py | cca/libraries_wagtail | f0baf62d0418ea5bb548c082aa84966aca363e56 | [
"ECL-2.0"
] | 3 | 2017-08-21T10:47:34.000Z | 2020-08-20T14:04:18.000Z | from django.contrib import admin
from .models import Library, OpenHours, Closure
# Register your models here.
for m in [Library, OpenHours, Closure]:
admin.site.register(m)
| 22.375 | 47 | 0.759777 | 25 | 179 | 5.44 | 0.64 | 0.235294 | 0.338235 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.156425 | 179 | 7 | 48 | 25.571429 | 0.900662 | 0.145251 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 5 |
a26953798afbaa65c073038686b0be91d834c9fd | 130 | py | Python | social_user_info/social_medias/__init__.py | dev-prakhar/social-authentication | 12215b9a4d1f31913a1714f0d7a6aa1fab6de906 | [
"MIT"
] | 3 | 2019-06-15T21:03:54.000Z | 2021-04-23T04:51:31.000Z | social_user_info/social_medias/__init__.py | dev-prakhar/social-authentication | 12215b9a4d1f31913a1714f0d7a6aa1fab6de906 | [
"MIT"
] | 2 | 2019-07-31T18:43:27.000Z | 2019-07-31T18:45:01.000Z | social_user_info/social_medias/__init__.py | dev-prakhar/social-authentication | 12215b9a4d1f31913a1714f0d7a6aa1fab6de906 | [
"MIT"
] | null | null | null | from .google import GoogleAPI
from .github import GitHubAPI
from .facebook import FacebookAPI
from .microsoft import MicrosoftAPI
| 26 | 35 | 0.846154 | 16 | 130 | 6.875 | 0.625 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.123077 | 130 | 4 | 36 | 32.5 | 0.964912 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
a2daf75bdd1ffbcc1814859081dd34e96427f5a2 | 176 | py | Python | tests/test_utils.py | TeoZosa/nbstripout | e238b50d7aad4309865fe50c5afdad6d626a4220 | [
"MIT"
] | null | null | null | tests/test_utils.py | TeoZosa/nbstripout | e238b50d7aad4309865fe50c5afdad6d626a4220 | [
"MIT"
] | null | null | null | tests/test_utils.py | TeoZosa/nbstripout | e238b50d7aad4309865fe50c5afdad6d626a4220 | [
"MIT"
] | 1 | 2021-12-11T20:38:05.000Z | 2021-12-11T20:38:05.000Z | from nbstripout._utils import pop_recursive
def test_pop_recursive():
d = {'a': {'b': 1, 'c': 2}}
assert pop_recursive(d, 'a.c') == 2
assert d == {'a': {'b': 1}}
| 22 | 43 | 0.5625 | 28 | 176 | 3.357143 | 0.535714 | 0.382979 | 0.276596 | 0.297872 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.028986 | 0.215909 | 176 | 7 | 44 | 25.142857 | 0.652174 | 0 | 0 | 0 | 0 | 0 | 0.045455 | 0 | 0 | 0 | 0 | 0 | 0.4 | 1 | 0.2 | false | 0 | 0.2 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 1 | 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 | 5 |
0c26e456ccf2ade210145d81ca73837f7cc4cb24 | 145 | py | Python | microframework/admin.py | wiktor-grochal/django-microframework | 41816635d555243d6a64140691871fd1b471e16f | [
"BSD-3-Clause"
] | 1 | 2019-11-19T00:28:21.000Z | 2019-11-19T00:28:21.000Z | microframework/admin.py | wiktor-grochal/django-microframework | 41816635d555243d6a64140691871fd1b471e16f | [
"BSD-3-Clause"
] | null | null | null | microframework/admin.py | wiktor-grochal/django-microframework | 41816635d555243d6a64140691871fd1b471e16f | [
"BSD-3-Clause"
] | null | null | null | from django.contrib import admin
from .models import SyncData, PendingObjects
admin.site.register(SyncData)
admin.site.register(PendingObjects)
| 24.166667 | 44 | 0.841379 | 18 | 145 | 6.777778 | 0.555556 | 0.147541 | 0.278689 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.082759 | 145 | 5 | 45 | 29 | 0.917293 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
0c34bb60530dc6c9fd6ef62d1a1e32bcca446fd2 | 1,964 | py | Python | lerp.py | TheMindVirus/pyshader | 162457511f5121cd4b20103323beea507eb0ec98 | [
"MIT"
] | 1 | 2022-01-11T08:31:39.000Z | 2022-01-11T08:31:39.000Z | lerp.py | TheMindVirus/pyshader | 162457511f5121cd4b20103323beea507eb0ec98 | [
"MIT"
] | null | null | null | lerp.py | TheMindVirus/pyshader | 162457511f5121cd4b20103323beea507eb0ec98 | [
"MIT"
] | null | null | null | """
0-x-1
|
a-y-b
(x-0)/(1-x)=(y-a)/(b-y)
x(b-y)=(1-x)(y-a)
xb-xy=y-a-xy+xa
xb=y-a+xa
xb=y-a(1+x)
xb+a(1-x)=y
y=xb-ax+a
y=x(b-a)+a
x(b-a)=y-a
x=(y-a)/(b-a)
a(1-x)=y-xb
a=(y-xb)/(1-x)
xb=y+xa-a
b=(y+xa-a)/x
b=(y+a(x-1))/x
"""
def lerp(a,b,x):
return x*(b-a)+a #(x*b)-(x*a)+a
def arclerp(a,b,y):
return (y-a)/(b-a) if (b-a)!=0.0 else 0.5
def lerpa(b,x,y):
return (y-(x*b))/(1-x) if (1-x)!=0.0 else b
def lerpb(a,x,y):
return (y+(a*(x-1)))/x if x!=0.0 else a
print(lerp( 0.0, 2.0, 0.5))
print(lerp( 2.0, 0.0, 0.5))
print(lerp(-2.0, 2.0, 0.5))
print(lerp( 2.0, -2.0, 0.5))
print(lerp(-1.0, 2.0, 0.5))
print(lerp( 2.0, -1.0, 0.5))
print(lerp( 2.0, 2.0, 0.5))
print(lerp( 0.0, 0.0, 0.5))
print(lerp(-2.0, -2.0, 0.5))
#Expected
1.0
1.0
0.0
0.0
0.5
0.5
2.0
0.0
-2.0
print()
print(arclerp( 0.0, 2.0, 1.0))
print(arclerp( 2.0, -0.0, 1.0))
print(arclerp(-2.0, 2.0, 0.0))
print(arclerp( 2.0, -2.0, 0.0))
print(arclerp(-1.0, 2.0, 0.5))
print(arclerp( 2.0, -1.0, 0.5))
print(arclerp( 2.0, 2.0, 2.0))
print(arclerp( 0.0, -0.0, 0.5))
print(arclerp(-2.0, -2.0, -2.0))
#Expected
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
print()
print(lerpa( 2.0, 0.5, 1.0))
print(lerpa( 0.0, 0.5, 1.0))
print(lerpa( 2.0, 0.5, 0.0))
print(lerpa(-2.0, 0.5, 0.0))
print(lerpa( 2.0, 0.5, 0.5))
print(lerpa(-1.0, 0.5, 0.5))
print(lerpa( 2.0, 0.5, 2.0))
print(lerpa( 0.0, 0.5, 0.0))
print(lerpa(-2.0, 0.5, -2.0))
#Expected
0.0
2.0
-2.0
2.0
-1.0
2.0
2.0
0.0
-2.0
print()
print(lerpb( 0.0, 0.5, 1.0))
print(lerpb( 2.0, 0.5, 1.0))
print(lerpb(-2.0, 0.5, 0.0))
print(lerpb( 2.0, 0.5, 0.0))
print(lerpb(-1.0, 0.5, 0.5))
print(lerpb( 2.0, 0.5, 0.5))
print(lerpb( 2.0, 0.5, 2.0))
print(lerpb( 0.0, 0.5, 0.0))
print(lerpb(-2.0, 0.5, -2.0))
#Expected
2.0
0.0
2.0
-2.0
2.0
-1.0
2.0
0.0
-2.0
print()
| 15.587302 | 48 | 0.47556 | 521 | 1,964 | 1.792706 | 0.042226 | 0.156317 | 0.099572 | 0.08137 | 0.729122 | 0.707709 | 0.664882 | 0.537473 | 0.470021 | 0.436831 | 0 | 0.203557 | 0.227088 | 1,964 | 125 | 49 | 15.712 | 0.411726 | 0.136965 | 0 | 0.47619 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.047619 | false | 0 | 0 | 0.047619 | 0.095238 | 0.47619 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 1 | 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 | 5 |
a75c53f5102db14668c3c95c54e0b4876885d5c6 | 37 | py | Python | passer/daemon/monitor/fifo_task_scheduler.py | affixalex/passer | 035d4a8c67676794b0c2d77c888ae71b75189baa | [
"Apache-2.0"
] | 1 | 2022-03-01T07:03:08.000Z | 2022-03-01T07:03:08.000Z | passer/daemon/monitor/fifo_task_scheduler.py | affixalex/passer | 035d4a8c67676794b0c2d77c888ae71b75189baa | [
"Apache-2.0"
] | null | null | null | passer/daemon/monitor/fifo_task_scheduler.py | affixalex/passer | 035d4a8c67676794b0c2d77c888ae71b75189baa | [
"Apache-2.0"
] | null | null | null |
class FifoTaskScheduler():
pass | 9.25 | 26 | 0.702703 | 3 | 37 | 8.666667 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.216216 | 37 | 4 | 27 | 9.25 | 0.896552 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0.5 | 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 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 5 |
a780984762c3ccc81a9fede49033e6a163df3bb8 | 139 | py | Python | rpython/jit/backend/aarch64/test/test_ztranslation_basic.py | nanjekyejoannah/pypy | e80079fe13c29eda7b2a6b4cd4557051f975a2d9 | [
"Apache-2.0",
"OpenSSL"
] | 333 | 2015-08-08T18:03:38.000Z | 2022-03-22T18:13:12.000Z | rpython/jit/backend/aarch64/test/test_ztranslation_basic.py | nanjekyejoannah/pypy | e80079fe13c29eda7b2a6b4cd4557051f975a2d9 | [
"Apache-2.0",
"OpenSSL"
] | 7 | 2020-02-16T16:49:05.000Z | 2021-11-26T09:00:56.000Z | rpython/jit/backend/aarch64/test/test_ztranslation_basic.py | nanjekyejoannah/pypy | e80079fe13c29eda7b2a6b4cd4557051f975a2d9 | [
"Apache-2.0",
"OpenSSL"
] | 55 | 2015-08-16T02:41:30.000Z | 2022-03-20T20:33:35.000Z | from rpython.jit.backend.llsupport.test.ztranslation_test import TranslationTest
class TestTranslationAarch64(TranslationTest):
pass
| 23.166667 | 80 | 0.848921 | 14 | 139 | 8.357143 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015873 | 0.093525 | 139 | 5 | 81 | 27.8 | 0.912698 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.333333 | 0.333333 | 0 | 0.666667 | 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 | 1 | 1 | 0 | 0 | 0 | 0 | 5 |
a7bc858c014d857bf64ad436544c2a98ccd7285f | 255 | py | Python | frontier/feincms/module/extensions/changedate.py | mcmaxwell/frontier | d1f59154108566c652965a43c4b999de33c05c58 | [
"MIT"
] | null | null | null | frontier/feincms/module/extensions/changedate.py | mcmaxwell/frontier | d1f59154108566c652965a43c4b999de33c05c58 | [
"MIT"
] | null | null | null | frontier/feincms/module/extensions/changedate.py | mcmaxwell/frontier | d1f59154108566c652965a43c4b999de33c05c58 | [
"MIT"
] | null | null | null | # flake8: noqa
from __future__ import absolute_import, unicode_literals
import warnings
from feincms.extensions.changedate import *
warnings.warn(
'Import %s from feincms.extensions.%s' % (__name__, __name__),
DeprecationWarning, stacklevel=2)
| 23.181818 | 66 | 0.776471 | 29 | 255 | 6.344828 | 0.62069 | 0.152174 | 0.228261 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009091 | 0.137255 | 255 | 10 | 67 | 25.5 | 0.827273 | 0.047059 | 0 | 0 | 0 | 0 | 0.149378 | 0.087137 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.666667 | 0 | 0.666667 | 0 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
ac158531c1b9b51f6872b18a6568a8ba38cc2b46 | 209 | py | Python | api/core/test_testing.py | SeedyROM/cosm | fbf3570625a814a7826c04b3dae61bbd52e0a436 | [
"MIT"
] | null | null | null | api/core/test_testing.py | SeedyROM/cosm | fbf3570625a814a7826c04b3dae61bbd52e0a436 | [
"MIT"
] | 7 | 2020-06-05T18:26:53.000Z | 2022-02-12T01:45:10.000Z | api/core/test_testing.py | SeedyROM/cosm | fbf3570625a814a7826c04b3dae61bbd52e0a436 | [
"MIT"
] | null | null | null | from core.testing import APITestCase
class TestAPITestCase(APITestCase):
def test_tests(self):
self.assertTrue(hasattr(self, 'pytestmark'))
self.assertTrue(hasattr(self, 'mixer'))
| 29.857143 | 52 | 0.69378 | 22 | 209 | 6.545455 | 0.681818 | 0.194444 | 0.291667 | 0.347222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.196172 | 209 | 7 | 53 | 29.857143 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0.071429 | 0 | 0 | 0 | 0 | 0 | 0.4 | 1 | 0.2 | false | 0 | 0.2 | 0 | 0.6 | 0 | 1 | 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 | 1 | 0 | 0 | 5 |
ac57a62f1a7d8f8b6671ce8703aebb510d3e1426 | 11,471 | py | Python | hyperion/view/example_instrument_view.py | caldarolamartin/hyperion | 19d6d2041f5029cd33da86c095d76e19ce89fcac | [
"BSD-3-Clause"
] | 1 | 2020-02-09T15:15:59.000Z | 2020-02-09T15:15:59.000Z | hyperion/view/example_instrument_view.py | caldarolamartin/hyperion | 19d6d2041f5029cd33da86c095d76e19ce89fcac | [
"BSD-3-Clause"
] | 1 | 2020-02-14T10:26:50.000Z | 2020-02-14T10:26:50.000Z | hyperion/view/example_instrument_view.py | caldarolamartin/hyperion | 19d6d2041f5029cd33da86c095d76e19ce89fcac | [
"BSD-3-Clause"
] | 1 | 2020-02-14T10:12:09.000Z | 2020-02-14T10:12:09.000Z | import sys
import time
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import *
from hyperion.instrument.example_instrument import ExampleInstrument
from hyperion.view.general_worker import WorkThread
from PyQt5.QtCore import QTimer
from hyperion.core import logman
from hyperion.view.base_guis import BaseGui
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
class ExampleInstrumentGui(BaseGui):
""""
This is simple pyqt5 gui with the ability to create threads and stop them,
that is harder than it sounds.
"""
def __init__(self, example_instr, output_gui=None, also_close_output=True):
super().__init__()
self.logger = logman.getLogger(__name__)
self.also_close_output = also_close_output
self.example_instr = example_instr
self.output_gui = output_gui
if self.output_gui is None:
self.curve = lambda *args, **kwargs: None
else:
self.curve = self.output_gui.plot() # initialize plot
# self.output_gui.show_dock = lambda *args, **kwargs: None # this will be overwritten by ExpGui
self.title = 'Example Gui'
self.left = 40
self.top = 40
self.width = 320
self.height = 200
self.initUI()
self.cont_plot_timer = QTimer()
self.cont_plot_timer.timeout.connect(self.show_one_plot)
def stop(self):
"""
Stop the instruments activity. This can be used by a measurement or an ExperimentGui to tell an instrument to stop doing what it's doing (so that it can start taking
"""
if self.cont_plot_timer.isActive():
self.cont_plot_timer.stop()
def closeEvent(self, event):
if self.also_close_output and self.output_gui is not None:
if self.cont_plot_timer.isActive():
self.logger.debug('Stop continuous plotting')
self.cont_plot_timer.stop()
self.logger.debug('Closing output widget')
try:
self.output_gui.close()
except:
pass
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
# self.setAutoFillBackground(True)
# self.p = self.palette()
# self.set_color(Qt.red)
self.button_once = QPushButton('Generate random plot')
self.button_once.clicked.connect(self.show_one_plot)
self.button_cont = QPushButton('Start continuous plot')
self.button_cont.clicked.connect(self.show_continuous_plot)
self.layout = QVBoxLayout()
self.layout.addWidget(self.button_once)
self.layout.addWidget(self.button_cont)
self.setLayout(self.layout)
self.show()
def show_one_plot(self):
self.output_gui.show_dock(True) # Optional. Ensures the output gui is opened in ExpGui if it was hidden
# Grab data from instrument here (or check if new data is available)
data = self.example_instr.return_fake_1D_data()
# update the plot
self.curve.setData(data)
def show_continuous_plot(self):
if not self.cont_plot_timer.isActive():
self.button_once.setDisabled(True)
self.button_cont.setText('Stop continuous')
self.cont_plot_timer.start(100) # in ms
self.continuous = True
else:
self.continuous = False
self.cont_plot_timer.stop()
self.button_once.setDisabled(False)
self.button_cont.setText('Start continuous plot')
class ExampleInstrumentGuiMultiplePlots(BaseGui):
def __init__(self, example_ins, output_gui_dict, also_close_output=True):
super().__init__()
self.logger = logman.getLogger(__name__)
self.also_close_output = also_close_output
self.output_gui_dict = output_gui_dict
if type(self.output_gui_dict) is not dict:
self.logger.error('This example needs a dictionary of visualization guis')
self.plot_a = self.output_gui_dict['Spectrum'].plot()
self.plot_b = self.output_gui_dict['Power'].plot()
self.title = 'Example Gui Multiple Plots'
self.left = 40
self.top = 40
self.width = 320
self.height = 200
self.example_ins = example_ins
self.initUI()
self.cont_plot_timer = QTimer()
self.cont_plot_timer.timeout.connect(self.show_plot_b)
def stop(self):
"""
Stop the instruments activity. This can be used by a measurement or an ExperimentGui to tell an instrument to stop doing what it's doing (so that it can start taking
"""
if self.cont_plot_timer.isActive():
self.cont_plot_timer.stop()
def closeEvent(self, event):
if self.also_close_output and self.output_gui_dict is not None:
if self.cont_plot_timer.isActive():
self.logger.debug('Stop continuous plotting')
self.cont_plot_timer.stop()
self.logger.debug('Closing output widgets')
try:
for instance in self.output_gui_dict.values():
instance.close()
except:
pass
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
# self.setAutoFillBackground(True)
# self.p = self.palette()
# self.set_color(Qt.red)
self.button_once = QPushButton('Generate random plot')
self.button_once.clicked.connect(self.show_plot_a)
self.button_cont = QPushButton('Start continuous plot')
self.button_cont.clicked.connect(self.show_continuous_plot)
self.layout = QVBoxLayout()
self.layout.addWidget(self.button_once)
self.layout.addWidget(self.button_cont)
self.setLayout(self.layout)
self.show()
def show_plot_a(self):
self.output_gui_dict['Spectrum'].show_dock(True) # Optional. Ensures the output gui is opened in ExpGui if it was hidden
# Grab data from instrument here (or check if new data is available)
data = np.random.normal(size=100)
# update the plot
self.plot_a.setData(data)
def show_plot_b(self):
self.output_gui_dict['Power'].show_dock(True) # Optional. Ensures the output gui is opened in ExpGui if it was hidden
# Grab data from instrument here (or check if new data is available)
data = np.random.normal(size=100)
# update the plot
self.plot_b.setData(data)
def show_continuous_plot(self):
if not self.cont_plot_timer.isActive():
self.button_cont.setText('Stop continuous')
self.cont_plot_timer.start(100) # in ms
self.continuous = True
else:
self.continuous = False
self.cont_plot_timer.stop()
self.button_cont.setText('Start continuous plot')
class ExampleInstrumentGui2D(BaseGui):
""""
This is simple pyqt5 gui with the ability to create threads and stop them,
that is harder than it sounds.
"""
def __init__(self, example_instr, output_gui=None, also_close_output=True):
super().__init__()
self.logger = logman.getLogger(__name__)
self.also_close_output = also_close_output
self.example_instr = example_instr
# if output_gui is dict, just grab the first value
if type(output_gui) is dict:
self.imv = list(output_gui.values())[0]
else:
self.imv = output_gui
colors = [
(0, 0, 0),
(45, 5, 61),
(84, 42, 55),
(150, 87, 60),
(208, 171, 141),
(255, 255, 255)
]
cmap = pg.ColorMap(pos=np.linspace(0.0, 1.0, 6), color=colors)
self.imv.setColorMap(cmap)
self.title = 'Example Gui'
self.left = 40
self.top = 40
self.width = 320
self.height = 200
self.initUI()
self.cont_plot_timer = QTimer()
self.cont_plot_timer.timeout.connect(self.show_one_plot)
def stop(self):
"""
Stop the instruments activity. This can be used by a measurement or an ExperimentGui to tell an instrument to stop doing what it's doing (so that it can start taking
"""
if self.cont_plot_timer.isActive():
# self.cont_plot_timer.stop() # stop the thread
self.show_continuous_plot() # "pretent" to hit the stop continuous button
def closeEvent(self, event):
if self.also_close_output and self.output_gui is not None:
if self.cont_plot_timer.isActive():
self.logger.debug('Stop continuous plotting')
self.cont_plot_timer.stop()
self.logger.debug('Closing output widget')
try:
self.output_gui.close()
except:
pass
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
# self.setAutoFillBackground(True)
# self.p = self.palette()
# self.set_color(Qt.red)
self.button_once = QPushButton('Generate random image')
self.button_once.clicked.connect(self.show_one_plot)
self.button_cont = QPushButton('Start random video')
self.button_cont.clicked.connect(self.show_continuous_plot)
self.layout = QVBoxLayout()
self.layout.addWidget(self.button_once)
self.layout.addWidget(self.button_cont)
self.setLayout(self.layout)
self.show()
def show_one_plot(self):
self.imv.show_dock(True) # Optional. Ensures the output gui is opened in ExpGui if it was hidden
# Grab data from instrument here (or check if new data is available))
data = self.example_instr.return_fake_2D_data()
# update the plot
self.imv.setImage(data.transpose(), xvals=np.linspace(1., 3., data.shape[0]))
def show_continuous_plot(self):
if not self.cont_plot_timer.isActive():
self.button_once.setDisabled(True)
self.button_cont.setText('Stop continuous')
self.cont_plot_timer.start(100) # in ms
self.continuous = True
else:
self.continuous = False
self.cont_plot_timer.stop()
self.button_once.setDisabled(False)
self.button_cont.setText('Start continuous plot')
class ExampleOutputGui(pg.PlotWidget):
# class ExampleOutput(pg.GraphicsWindow):
def __init__(self, parent=None, **kwargs):
super().__init__(parent=parent, **kwargs)
# self.show()
if __name__ == '__main__':
from PyQt5.QtGui import QIcon
import os
import hyperion
example_ins = ExampleInstrument(settings = {'port':'COM8', 'dummy':False,
'controller': 'hyperion.controller.example_controller/ExampleController'})
app = QApplication(sys.argv)
app.setWindowIcon(QIcon(os.path.join(hyperion.package_path, 'view', 'logo_hyperion.png')))
output = ExampleOutputGui()
# win = pg.GraphicsWindow(title="Basic plotting examples")
# output = win.addPlot(title = 'Plot Window Title')
# win.show()
output = pg.PlotWidget(title='Title')
output.show()
ex = ExampleInstrumentGui(example_ins, output)
sys.exit(app.exec_()) | 36.766026 | 173 | 0.639003 | 1,458 | 11,471 | 4.844993 | 0.170096 | 0.038222 | 0.045866 | 0.064977 | 0.739807 | 0.715176 | 0.711495 | 0.711495 | 0.70654 | 0.70654 | 0 | 0.012259 | 0.267544 | 11,471 | 312 | 174 | 36.766026 | 0.828493 | 0.174701 | 0 | 0.645161 | 0 | 0 | 0.064865 | 0.006004 | 0 | 0 | 0 | 0 | 0 | 1 | 0.092166 | false | 0.013825 | 0.069124 | 0 | 0.179724 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 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 | 5 |
ac6ede83759005031d8a137c5613048f3148ecf9 | 160 | py | Python | test_project/base.py | ChihweiLHBird/test_project | bc4b4220a17bf944bbcbef371cbef03f84e799ac | [
"MIT"
] | null | null | null | test_project/base.py | ChihweiLHBird/test_project | bc4b4220a17bf944bbcbef371cbef03f84e799ac | [
"MIT"
] | null | null | null | test_project/base.py | ChihweiLHBird/test_project | bc4b4220a17bf944bbcbef371cbef03f84e799ac | [
"MIT"
] | 1 | 2021-04-03T13:47:02.000Z | 2021-04-03T13:47:02.000Z | import numpy
class testClass(object):
def testArr(self):
return numpy.array([1,2,3])
def runtest():
obj = testClass()
print(obj.testArr()) | 17.777778 | 35 | 0.63125 | 21 | 160 | 4.809524 | 0.761905 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.024 | 0.21875 | 160 | 9 | 36 | 17.777778 | 0.784 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0 | 0.142857 | 0.142857 | 0.714286 | 0.142857 | 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 | 1 | 1 | 0 | 0 | 5 |
3bb940edc9a2a5aa2c4f77846f70d6161e824a2f | 129 | py | Python | predict/models.py | meet-soni5720/Plant-leaves-disease-analyzer | 19bc3c5eff40bfdcd39d85da77e155b38c6f5a76 | [
"MIT"
] | 2 | 2020-02-20T17:23:32.000Z | 2020-08-10T02:26:30.000Z | predict/models.py | meet-soni5720/Plant-leaves-disease-analyzer | 19bc3c5eff40bfdcd39d85da77e155b38c6f5a76 | [
"MIT"
] | 1 | 2021-02-04T11:18:43.000Z | 2021-02-04T11:18:43.000Z | predict/models.py | meet-soni5720/Plant-leaves-disease-analyzer | 19bc3c5eff40bfdcd39d85da77e155b38c6f5a76 | [
"MIT"
] | 1 | 2020-10-01T04:56:26.000Z | 2020-10-01T04:56:26.000Z | version https://git-lfs.github.com/spec/v1
oid sha256:0b6a57c5320208d4d2884ca35a203a08e4cd6492c102a9e049a4f50c2bd40782
size 2008
| 32.25 | 75 | 0.883721 | 13 | 129 | 8.769231 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.422764 | 0.046512 | 129 | 3 | 76 | 43 | 0.504065 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
ce316a8c4b0ff125b585812e374e9626fe428398 | 20 | py | Python | checkov/version.py | graybrandonpfg/checkov | 3081a8560f6369465314ee8f4ac8a8ec01649d68 | [
"Apache-2.0"
] | null | null | null | checkov/version.py | graybrandonpfg/checkov | 3081a8560f6369465314ee8f4ac8a8ec01649d68 | [
"Apache-2.0"
] | null | null | null | checkov/version.py | graybrandonpfg/checkov | 3081a8560f6369465314ee8f4ac8a8ec01649d68 | [
"Apache-2.0"
] | null | null | null | version = '2.0.399'
| 10 | 19 | 0.6 | 4 | 20 | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.294118 | 0.15 | 20 | 1 | 20 | 20 | 0.411765 | 0 | 0 | 0 | 0 | 0 | 0.35 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
ce44b6f291bc0602f3487616d18818f4286a6cab | 88 | py | Python | src/bitcoin_acks/database/__init__.py | benthecarman/wasabi-acks | e9663d845e8f63f06e5e49737966fafa5e8a1eb4 | [
"MIT"
] | null | null | null | src/bitcoin_acks/database/__init__.py | benthecarman/wasabi-acks | e9663d845e8f63f06e5e49737966fafa5e8a1eb4 | [
"MIT"
] | null | null | null | src/bitcoin_acks/database/__init__.py | benthecarman/wasabi-acks | e9663d845e8f63f06e5e49737966fafa5e8a1eb4 | [
"MIT"
] | null | null | null | from .createdb import create_database, drop_database
from .session import session_scope
| 29.333333 | 52 | 0.863636 | 12 | 88 | 6.083333 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.102273 | 88 | 2 | 53 | 44 | 0.924051 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
cbefe2861fe18c1f7b07b88e857812f0315b5553 | 68 | py | Python | i2b2tools/__init__.py | cjliux/i2b2tools | 305f2555121de4f09780ca13c018644b8759e363 | [
"Apache-2.0"
] | 1 | 2020-09-12T14:29:15.000Z | 2020-09-12T14:29:15.000Z | i2b2tools/__init__.py | cjliux/i2b2tools | 305f2555121de4f09780ca13c018644b8759e363 | [
"Apache-2.0"
] | null | null | null | i2b2tools/__init__.py | cjliux/i2b2tools | 305f2555121de4f09780ca13c018644b8759e363 | [
"Apache-2.0"
] | null | null | null | from .lib import *
from .helpers import *
from .converters import *
| 17 | 25 | 0.735294 | 9 | 68 | 5.555556 | 0.555556 | 0.4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.176471 | 68 | 3 | 26 | 22.666667 | 0.892857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
0230d69b69e01bc2cbc73aa5b4e3dbc3ae944f6d | 169 | py | Python | newsapi/news/admin.py | arifhusaini97/03-DRF-Level-One | 4df897430f170699d1fcac7de35b9ad396dcfa82 | [
"MIT"
] | null | null | null | newsapi/news/admin.py | arifhusaini97/03-DRF-Level-One | 4df897430f170699d1fcac7de35b9ad396dcfa82 | [
"MIT"
] | null | null | null | newsapi/news/admin.py | arifhusaini97/03-DRF-Level-One | 4df897430f170699d1fcac7de35b9ad396dcfa82 | [
"MIT"
] | null | null | null | from django.contrib import admin
from news.models import Article, Journalist
# Register your models here.
admin.site.register(Article)
admin.site.register(Journalist)
| 21.125 | 43 | 0.816568 | 23 | 169 | 6 | 0.565217 | 0.130435 | 0.246377 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.106509 | 169 | 7 | 44 | 24.142857 | 0.913907 | 0.153846 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
02328a28679e25ed31d6cb20eeae04d50600f7e5 | 40 | py | Python | structures/__init__.py | AakashSudhakar/helical | f30df5be43a35aaa4cfb1e146affeee9bba3c032 | [
"MIT"
] | null | null | null | structures/__init__.py | AakashSudhakar/helical | f30df5be43a35aaa4cfb1e146affeee9bba3c032 | [
"MIT"
] | 14 | 2020-01-28T22:39:11.000Z | 2022-02-10T00:10:34.000Z | structures/__init__.py | AakashSudhakar/helical | f30df5be43a35aaa4cfb1e146affeee9bba3c032 | [
"MIT"
] | null | null | null | # helical-project/structures/__init__.py | 40 | 40 | 0.85 | 5 | 40 | 6 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025 | 40 | 1 | 40 | 40 | 0.769231 | 0.95 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 1 | 1 | 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 | 5 |
5a0738c80612120866267a0cfb657d25f66d97f8 | 104,167 | py | Python | test/python/circuit/test_control_flow_builders.py | Roshan-Thomas/qiskit-terra | 77219b5c7b7146b1545c5e5190739b36f4064b2f | [
"Apache-2.0"
] | 1,599 | 2018-07-10T10:59:12.000Z | 2022-03-31T23:56:25.000Z | test/python/circuit/test_control_flow_builders.py | Roshan-Thomas/qiskit-terra | 77219b5c7b7146b1545c5e5190739b36f4064b2f | [
"Apache-2.0"
] | 5,244 | 2018-07-10T06:20:13.000Z | 2022-03-31T22:18:48.000Z | test/python/circuit/test_control_flow_builders.py | Roshan-Thomas/qiskit-terra | 77219b5c7b7146b1545c5e5190739b36f4064b2f | [
"Apache-2.0"
] | 1,409 | 2018-07-10T02:16:12.000Z | 2022-03-31T09:01:32.000Z | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""Test operations on the builder interfaces for control flow in dynamic QuantumCircuits."""
import copy
import math
import ddt
from qiskit.circuit import (
ClassicalRegister,
Clbit,
Measure,
Parameter,
QuantumCircuit,
QuantumRegister,
Qubit,
)
from qiskit.circuit.controlflow import ForLoopOp, IfElseOp, WhileLoopOp, BreakLoopOp, ContinueLoopOp
from qiskit.circuit.controlflow.builder import ControlFlowBuilderBlock
from qiskit.circuit.controlflow.if_else import IfElsePlaceholder
from qiskit.circuit.exceptions import CircuitError
from qiskit.test import QiskitTestCase
class SentinelException(Exception):
"""An exception that we know was raised deliberately."""
@ddt.ddt
class TestControlFlowBuilders(QiskitTestCase):
"""Test that the control-flow builder interfaces work, and manage resources correctly."""
def assertCircuitsEquivalent(self, a, b):
"""Assert that two circuits (``a`` and ``b``) contain all the same qubits and clbits, and
then have the same instructions in order, recursing into nested control-flow constructs.
Relying on ``QuantumCircuit.__eq__`` doesn't work reliably in all cases here, because we
don't care about the order that the builder interface chooses for resources in the inner
blocks. This order is non-deterministic, because internally it uses sets for efficiency,
and the order of iteration through a set is dependent on the hash seed. Instead, we just
need to be a bit more explicit about what we care about. This isn't a full method for
comparing if two circuits are equivalent, but for the restricted cases used in these tests,
where we deliberately construct the expected result to be equal in the good case, it should
test all that is needed.
"""
self.assertIsInstance(a, QuantumCircuit)
self.assertIsInstance(b, QuantumCircuit)
# For our purposes here, we don't care about the order bits were added.
self.assertEqual(set(a.qubits), set(b.qubits))
self.assertEqual(set(a.clbits), set(b.clbits))
self.assertEqual(set(a.qregs), set(b.qregs))
self.assertEqual(set(a.cregs), set(b.cregs))
self.assertEqual(len(a.data), len(b.data))
for (a_op, a_qubits, a_clbits), (b_op, b_qubits, b_clbits) in zip(a.data, b.data):
# Make sure that the operations are the same.
self.assertEqual(type(a_op), type(b_op))
self.assertEqual(hasattr(a_op, "condition"), hasattr(b_op, "condition"))
if hasattr(a_op, "condition") and not isinstance(a_op, (IfElseOp, WhileLoopOp)):
self.assertEqual(a_op.condition, b_op.condition)
self.assertEqual(hasattr(a_op, "label"), hasattr(b_op, "label"))
if hasattr(a_op, "condition"):
self.assertEqual(a_op.label, b_op.label)
# If it's a block op, we don't care what order the resources are specified in.
if isinstance(a_op, WhileLoopOp):
self.assertEqual(set(a_qubits), set(b_qubits))
self.assertEqual(set(a_clbits), set(b_clbits))
self.assertEqual(a_op.condition, b_op.condition)
self.assertCircuitsEquivalent(a_op.blocks[0], b_op.blocks[0])
elif isinstance(a_op, ForLoopOp):
self.assertEqual(set(a_qubits), set(b_qubits))
self.assertEqual(set(a_clbits), set(b_clbits))
a_indexset, a_loop_parameter, a_body = a_op.params
b_indexset, b_loop_parameter, b_body = b_op.params
self.assertEqual(a_loop_parameter is None, b_loop_parameter is None)
self.assertEqual(a_indexset, b_indexset)
if a_loop_parameter is not None:
a_body = a_body.assign_parameters({a_loop_parameter: b_loop_parameter})
self.assertCircuitsEquivalent(a_body, b_body)
elif isinstance(a_op, IfElseOp):
self.assertEqual(set(a_qubits), set(b_qubits))
self.assertEqual(set(a_clbits), set(b_clbits))
self.assertEqual(a_op.condition, b_op.condition)
self.assertEqual(len(a_op.blocks), len(b_op.blocks))
self.assertCircuitsEquivalent(a_op.blocks[0], b_op.blocks[0])
if len(a_op.blocks) > 1:
self.assertCircuitsEquivalent(a_op.blocks[1], b_op.blocks[1])
elif isinstance(a_op, (BreakLoopOp, ContinueLoopOp)):
self.assertEqual(set(a_qubits), set(b_qubits))
self.assertEqual(set(a_clbits), set(b_clbits))
else:
# For any other op, we care that the resources are the same, and in the same order,
# but we don't mind what sort of iterable they're contained in.
self.assertEqual(tuple(a_qubits), tuple(b_qubits))
self.assertEqual(tuple(a_clbits), tuple(b_clbits))
self.assertEqual(a_op, b_op)
def test_if_simple(self):
"""Test a simple if statement builds correctly, in the midst of other instructions."""
qubits = [Qubit(), Qubit()]
clbits = [Clbit(), Clbit()]
test = QuantumCircuit(qubits, clbits)
test.h(0)
test.measure(0, 0)
with test.if_test((clbits[0], 0)):
test.x(0)
test.h(0)
test.measure(0, 1)
with test.if_test((clbits[1], 0)):
test.h(1)
test.cx(1, 0)
if_true0 = QuantumCircuit([qubits[0], clbits[0]])
if_true0.x(qubits[0])
if_true1 = QuantumCircuit([qubits[0], qubits[1], clbits[1]])
if_true1.h(qubits[1])
if_true1.cx(qubits[1], qubits[0])
expected = QuantumCircuit(qubits, clbits)
expected.h(qubits[0])
expected.measure(qubits[0], clbits[0])
expected.if_test((clbits[0], 0), if_true0, [qubits[0]], [clbits[0]])
expected.h(qubits[0])
expected.measure(qubits[0], clbits[1])
expected.if_test((clbits[1], 0), if_true1, [qubits[0], qubits[1]], [clbits[1]])
self.assertCircuitsEquivalent(test, expected)
def test_if_register(self):
"""Test a simple if statement builds correctly, when using a register as the condition.
This requires the builder to unpack all the bits from the register to use as resources."""
qr = QuantumRegister(2)
cr = ClassicalRegister(2)
test = QuantumCircuit(qr, cr)
test.measure(qr, cr)
with test.if_test((cr, 0)):
test.x(0)
if_true0 = QuantumCircuit([qr[0]], cr)
if_true0.x(qr[0])
expected = QuantumCircuit(qr, cr)
expected.measure(qr, cr)
expected.if_test((cr, 0), if_true0, [qr[0]], [cr[:]])
self.assertCircuitsEquivalent(test, expected)
def test_register_condition_in_nested_block(self):
"""Test that nested blocks can use registers of the outermost circuits as conditions, and
they get propagated through all the blocks."""
qr = QuantumRegister(2)
clbits = [Clbit(), Clbit(), Clbit()]
cr1 = ClassicalRegister(3)
# Try aliased classical registers as well, to catch potential overlap bugs.
cr2 = ClassicalRegister(bits=clbits[:2])
cr3 = ClassicalRegister(bits=clbits[1:])
cr4 = ClassicalRegister(bits=clbits)
with self.subTest("for/if"):
test = QuantumCircuit(qr, clbits, cr1, cr2, cr3, cr4)
with test.for_loop(range(3)):
with test.if_test((cr1, 0)):
test.x(0)
with test.if_test((cr2, 0)):
test.y(0)
with test.if_test((cr3, 0)):
test.z(0)
true_body1 = QuantumCircuit([qr[0]], cr1)
true_body1.x(0)
true_body2 = QuantumCircuit([qr[0]], cr2)
true_body2.y(0)
true_body3 = QuantumCircuit([qr[0]], cr3)
true_body3.z(0)
for_body = QuantumCircuit([qr[0]], clbits, cr1, cr2, cr3) # but not cr4.
for_body.if_test((cr1, 0), true_body1, [qr[0]], cr1)
for_body.if_test((cr2, 0), true_body2, [qr[0]], cr2)
for_body.if_test((cr3, 0), true_body3, [qr[0]], cr3)
expected = QuantumCircuit(qr, clbits, cr1, cr2, cr3, cr4)
expected.for_loop(range(3), None, for_body, [qr[0]], clbits + list(cr1))
self.assertCircuitsEquivalent(test, expected)
with self.subTest("for/while"):
test = QuantumCircuit(qr, clbits, cr1, cr2, cr3, cr4)
with test.for_loop(range(3)):
with test.while_loop((cr1, 0)):
test.x(0)
with test.while_loop((cr2, 0)):
test.y(0)
with test.while_loop((cr3, 0)):
test.z(0)
while_body1 = QuantumCircuit([qr[0]], cr1)
while_body1.x(0)
while_body2 = QuantumCircuit([qr[0]], cr2)
while_body2.y(0)
while_body3 = QuantumCircuit([qr[0]], cr3)
while_body3.z(0)
for_body = QuantumCircuit([qr[0]], clbits, cr1, cr2, cr3)
for_body.while_loop((cr1, 0), while_body1, [qr[0]], cr1)
for_body.while_loop((cr2, 0), while_body2, [qr[0]], cr2)
for_body.while_loop((cr3, 0), while_body3, [qr[0]], cr3)
expected = QuantumCircuit(qr, clbits, cr1, cr2, cr3, cr4)
expected.for_loop(range(3), None, for_body, [qr[0]], clbits + list(cr1))
self.assertCircuitsEquivalent(test, expected)
with self.subTest("if/c_if"):
test = QuantumCircuit(qr, clbits, cr1, cr2, cr3, cr4)
with test.if_test((cr1, 0)):
test.x(0).c_if(cr2, 0)
test.z(0).c_if(cr3, 0)
true_body = QuantumCircuit([qr[0]], cr1, cr2, cr3)
true_body.x(0).c_if(cr2, 0)
true_body.z(0).c_if(cr3, 0)
expected = QuantumCircuit(qr, clbits, cr1, cr2, cr3, cr4)
expected.if_test((cr1, 0), true_body, [qr[0]], clbits + list(cr1))
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while/else/c_if"):
test = QuantumCircuit(qr, clbits, cr1, cr2, cr3, cr4)
with test.while_loop((cr1, 0)):
with test.if_test((cr2, 0)) as else_:
test.x(0).c_if(cr3, 0)
with else_:
test.z(0).c_if(cr4, 0)
true_body = QuantumCircuit([qr[0]], cr2, cr3, cr4)
true_body.x(0).c_if(cr3, 0)
false_body = QuantumCircuit([qr[0]], cr2, cr3, cr4)
false_body.z(0).c_if(cr4, 0)
while_body = QuantumCircuit([qr[0]], cr1, cr2, cr3, cr4)
while_body.if_else((cr2, 0), true_body, false_body, [qr[0]], clbits)
expected = QuantumCircuit(qr, clbits, cr1, cr2, cr3, cr4)
expected.while_loop((cr1, 0), while_body, [qr[0]], clbits + list(cr1))
self.assertCircuitsEquivalent(test, expected)
def test_if_else_simple(self):
"""Test a simple if/else statement builds correctly, in the midst of other instructions.
This test has paired if and else blocks the same natural width."""
qubits = [Qubit(), Qubit()]
clbits = [Clbit(), Clbit()]
test = QuantumCircuit(qubits, clbits)
test.h(0)
test.measure(0, 0)
with test.if_test((clbits[0], 0)) as else_:
test.x(0)
with else_:
test.z(0)
test.h(0)
test.measure(0, 1)
with test.if_test((clbits[1], 0)) as else_:
test.h(1)
test.cx(1, 0)
with else_:
test.h(0)
test.h(1)
# Both the if and else blocks in this circuit are the same natural width to begin with.
if_true0 = QuantumCircuit([qubits[0], clbits[0]])
if_true0.x(qubits[0])
if_false0 = QuantumCircuit([qubits[0], clbits[0]])
if_false0.z(qubits[0])
if_true1 = QuantumCircuit([qubits[0], qubits[1], clbits[1]])
if_true1.h(qubits[1])
if_true1.cx(qubits[1], qubits[0])
if_false1 = QuantumCircuit([qubits[0], qubits[1], clbits[1]])
if_false1.h(qubits[0])
if_false1.h(qubits[1])
expected = QuantumCircuit(qubits, clbits)
expected.h(qubits[0])
expected.measure(qubits[0], clbits[0])
expected.if_else((clbits[0], 0), if_true0, if_false0, [qubits[0]], [clbits[0]])
expected.h(qubits[0])
expected.measure(qubits[0], clbits[1])
expected.if_else((clbits[1], 0), if_true1, if_false1, [qubits[0], qubits[1]], [clbits[1]])
self.assertCircuitsEquivalent(test, expected)
def test_if_else_resources_expand_true_superset_false(self):
"""Test that the resources of the if and else bodies come out correctly if the true body
needs a superset of the resources of the false body."""
qubits = [Qubit(), Qubit()]
clbits = [Clbit(), Clbit()]
test = QuantumCircuit(qubits, clbits)
test.h(0)
test.measure(0, 0)
with test.if_test((clbits[0], 0)) as else_:
test.x(0)
test.measure(1, 1)
with else_:
test.z(0)
if_true0 = QuantumCircuit(qubits, clbits)
if_true0.x(qubits[0])
if_true0.measure(qubits[1], clbits[1])
# The false body doesn't actually use qubits[1] or clbits[1], but it still needs to contain
# them so the bodies match.
if_false0 = QuantumCircuit(qubits, clbits)
if_false0.z(qubits[0])
expected = QuantumCircuit(qubits, clbits)
expected.h(qubits[0])
expected.measure(qubits[0], clbits[0])
expected.if_else((clbits[0], 0), if_true0, if_false0, qubits, clbits)
self.assertCircuitsEquivalent(test, expected)
def test_if_else_resources_expand_false_superset_true(self):
"""Test that the resources of the if and else bodies come out correctly if the false body
needs a superset of the resources of the true body. This requires that the manager
correctly adds resources to the true body after it has been created."""
qubits = [Qubit(), Qubit()]
clbits = [Clbit(), Clbit()]
test = QuantumCircuit(qubits, clbits)
test.h(0)
test.measure(0, 0)
with test.if_test((clbits[0], 0)) as else_:
test.x(0)
with else_:
test.z(0)
test.measure(1, 1)
# The true body doesn't actually use qubits[1] or clbits[1], but it still needs to contain
# them so the bodies match.
if_true0 = QuantumCircuit(qubits, clbits)
if_true0.x(qubits[0])
if_false0 = QuantumCircuit(qubits, clbits)
if_false0.z(qubits[0])
if_false0.measure(qubits[1], clbits[1])
expected = QuantumCircuit(qubits, clbits)
expected.h(qubits[0])
expected.measure(qubits[0], clbits[0])
expected.if_else((clbits[0], 0), if_true0, if_false0, qubits, clbits)
self.assertCircuitsEquivalent(test, expected)
def test_if_else_resources_expand_true_false_symmetric_difference(self):
"""Test that the resources of the if and else bodies come out correctly if the sets of
resources for the true body and the false body have some overlap, but neither is a subset of
the other. This tests that the flow of resources from block to block is simultaneously
bidirectional."""
qubits = [Qubit(), Qubit()]
clbits = [Clbit(), Clbit()]
test = QuantumCircuit(qubits, clbits)
test.h(0)
test.measure(0, 0)
with test.if_test((clbits[0], 0)) as else_:
test.x(0)
with else_:
test.z(1)
# The true body doesn't use qubits[1] and the false body doesn't use qubits[0].
if_true0 = QuantumCircuit(qubits, [clbits[0]])
if_true0.x(qubits[0])
if_false0 = QuantumCircuit(qubits, [clbits[0]])
if_false0.z(qubits[1])
expected = QuantumCircuit(qubits, clbits)
expected.h(qubits[0])
expected.measure(qubits[0], clbits[0])
expected.if_else((clbits[0], 0), if_true0, if_false0, qubits, [clbits[0]])
self.assertCircuitsEquivalent(test, expected)
def test_if_else_empty_branches(self):
"""Test that the context managers can cope with a body being empty."""
qubits = [Qubit()]
clbits = [Clbit()]
cond = (clbits[0], 0)
test = QuantumCircuit(qubits, clbits)
# Sole empty if.
with test.if_test(cond):
pass
# Normal if with an empty else body.
with test.if_test(cond) as else_:
test.x(0)
with else_:
pass
# Empty if with a normal else body.
with test.if_test(cond) as else_:
pass
with else_:
test.x(0)
# Both empty.
with test.if_test(cond) as else_:
pass
with else_:
pass
empty_with_qubit = QuantumCircuit([qubits[0], clbits[0]])
empty = QuantumCircuit([clbits[0]])
only_x = QuantumCircuit([qubits[0], clbits[0]])
only_x.x(qubits[0])
expected = QuantumCircuit(qubits, clbits)
expected.if_test(cond, empty, [], [clbits[0]])
expected.if_else(cond, only_x, empty_with_qubit, [qubits[0]], [clbits[0]])
expected.if_else(cond, empty_with_qubit, only_x, [qubits[0]], [clbits[0]])
expected.if_else(cond, empty, empty, [], [clbits[0]])
self.assertCircuitsEquivalent(test, expected)
def test_if_else_tracks_registers(self):
"""Test that classical registers used in both branches of if statements are tracked
correctly."""
qr = QuantumRegister(2)
cr = [ClassicalRegister(2) for _ in [None] * 4]
test = QuantumCircuit(qr, *cr)
with test.if_test((cr[0], 0)) as else_:
test.h(0).c_if(cr[1], 0)
# Test repetition.
test.h(0).c_if(cr[1], 0)
with else_:
test.h(0).c_if(cr[2], 0)
true_body = QuantumCircuit([qr[0]], cr[0], cr[1], cr[2])
true_body.h(qr[0]).c_if(cr[1], 0)
true_body.h(qr[0]).c_if(cr[1], 0)
false_body = QuantumCircuit([qr[0]], cr[0], cr[1], cr[2])
false_body.h(qr[0]).c_if(cr[2], 0)
expected = QuantumCircuit(qr, *cr)
expected.if_else(
(cr[0], 0), true_body, false_body, [qr[0]], list(cr[0]) + list(cr[1]) + list(cr[2])
)
self.assertCircuitsEquivalent(test, expected)
def test_if_else_nested(self):
"""Test that the if and else context managers can be nested, and don't interfere with each
other."""
qubits = [Qubit(), Qubit(), Qubit()]
clbits = [Clbit(), Clbit(), Clbit()]
outer_cond = (clbits[0], 0)
inner_cond = (clbits[2], 1)
with self.subTest("if (if) else"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(outer_cond) as else_:
with test.if_test(inner_cond):
test.h(0)
with else_:
test.h(1)
inner_true = QuantumCircuit([qubits[0], clbits[2]])
inner_true.h(qubits[0])
outer_true = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[2]])
outer_true.if_test(inner_cond, inner_true, [qubits[0]], [clbits[2]])
outer_false = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[2]])
outer_false.h(qubits[1])
expected = QuantumCircuit(qubits, clbits)
expected.if_else(
outer_cond, outer_true, outer_false, [qubits[0], qubits[1]], [clbits[0], clbits[2]]
)
self.assertCircuitsEquivalent(test, expected)
with self.subTest("if (if else) else"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(outer_cond) as outer_else:
with test.if_test(inner_cond) as inner_else:
test.h(0)
with inner_else:
test.h(2)
with outer_else:
test.h(1)
inner_true = QuantumCircuit([qubits[0], qubits[2], clbits[2]])
inner_true.h(qubits[0])
inner_false = QuantumCircuit([qubits[0], qubits[2], clbits[2]])
inner_false.h(qubits[2])
outer_true = QuantumCircuit(qubits, [clbits[0], clbits[2]])
outer_true.if_else(
inner_cond, inner_true, inner_false, [qubits[0], qubits[2]], [clbits[2]]
)
outer_false = QuantumCircuit(qubits, [clbits[0], clbits[2]])
outer_false.h(qubits[1])
expected = QuantumCircuit(qubits, clbits)
expected.if_else(outer_cond, outer_true, outer_false, qubits, [clbits[0], clbits[2]])
self.assertCircuitsEquivalent(test, expected)
def test_break_continue_expand_to_match_arguments_simple(self):
"""Test that ``break`` and ``continue`` statements expand to include all resources in the
containing loop for simple cases with unconditional breaks."""
qubits = [Qubit(), Qubit()]
clbits = [Clbit(), Clbit()]
with self.subTest("for"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
test.break_loop()
test.h(0)
test.continue_loop()
test.measure(1, 0)
body = QuantumCircuit(qubits, [clbits[0]])
body.break_loop()
body.h(qubits[0])
body.continue_loop()
body.measure(qubits[1], clbits[0])
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(range(2), None, body, qubits, [clbits[0]])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while"):
cond = (clbits[0], 0)
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond):
test.break_loop()
test.h(0)
test.continue_loop()
test.measure(1, 0)
body = QuantumCircuit(qubits, [clbits[0]])
body.break_loop()
body.h(qubits[0])
body.continue_loop()
body.measure(qubits[1], clbits[0])
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(cond, body, qubits, [clbits[0]])
self.assertCircuitsEquivalent(test, expected)
@ddt.data(QuantumCircuit.break_loop, QuantumCircuit.continue_loop)
def test_break_continue_accept_c_if(self, loop_operation):
"""Test that ``break`` and ``continue`` statements accept :meth:`.Instruction.c_if` calls,
and that these propagate through correctly."""
qubits = [Qubit(), Qubit()]
clbits = [Clbit(), Clbit()]
with self.subTest("for"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
test.h(0)
loop_operation(test).c_if(1, 0)
body = QuantumCircuit([qubits[0]], [clbits[1]])
body.h(qubits[0])
loop_operation(body).c_if(clbits[1], 0)
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(range(2), None, body, [qubits[0]], [clbits[1]])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while"):
cond = (clbits[0], 0)
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond):
test.h(0)
loop_operation(test).c_if(1, 0)
body = QuantumCircuit([qubits[0]], clbits)
body.h(qubits[0])
loop_operation(body).c_if(clbits[1], 0)
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(cond, body, [qubits[0]], clbits)
self.assertCircuitsEquivalent(test, expected)
@ddt.data(QuantumCircuit.break_loop, QuantumCircuit.continue_loop)
def test_break_continue_only_expand_to_nearest_loop(self, loop_operation):
"""Test that a ``break`` or ``continue`` nested in more than one loop only expands as far as
the inner loop scope, not further."""
qubits = [Qubit(), Qubit(), Qubit()]
clbits = [Clbit(), Clbit(), Clbit()]
cond_inner = (clbits[0], 0)
cond_outer = (clbits[1], 0)
with self.subTest("for for"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
test.measure(1, 1)
with test.for_loop(range(2)):
test.h(0)
loop_operation(test)
loop_operation(test)
inner_body = QuantumCircuit([qubits[0]])
inner_body.h(qubits[0])
loop_operation(inner_body)
outer_body = QuantumCircuit([qubits[0], qubits[1], clbits[1]])
outer_body.measure(qubits[1], clbits[1])
outer_body.for_loop(range(2), None, inner_body, [qubits[0]], [])
loop_operation(outer_body)
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(range(2), None, outer_body, [qubits[0], qubits[1]], [clbits[1]])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("for while"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
test.measure(1, 1)
with test.while_loop(cond_inner):
test.h(0)
loop_operation(test)
loop_operation(test)
inner_body = QuantumCircuit([qubits[0], clbits[0]])
inner_body.h(qubits[0])
loop_operation(inner_body)
outer_body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1]])
outer_body.measure(qubits[1], clbits[1])
outer_body.while_loop(cond_inner, inner_body, [qubits[0]], [clbits[0]])
loop_operation(outer_body)
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(
range(2), None, outer_body, [qubits[0], qubits[1]], [clbits[0], clbits[1]]
)
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while for"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond_outer):
test.measure(1, 1)
with test.for_loop(range(2)):
test.h(0)
loop_operation(test)
loop_operation(test)
inner_body = QuantumCircuit([qubits[0]])
inner_body.h(qubits[0])
loop_operation(inner_body)
outer_body = QuantumCircuit([qubits[0], qubits[1], clbits[1]])
outer_body.measure(qubits[1], clbits[1])
outer_body.for_loop(range(2), None, inner_body, [qubits[0]], [])
loop_operation(outer_body)
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(cond_outer, outer_body, [qubits[0], qubits[1]], [clbits[1]])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while while"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond_outer):
test.measure(1, 1)
with test.while_loop(cond_inner):
test.h(0)
loop_operation(test)
loop_operation(test)
inner_body = QuantumCircuit([qubits[0], clbits[0]])
inner_body.h(qubits[0])
loop_operation(inner_body)
outer_body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1]])
outer_body.measure(qubits[1], clbits[1])
outer_body.while_loop(cond_inner, inner_body, [qubits[0]], [clbits[0]])
loop_operation(outer_body)
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(
cond_outer, outer_body, [qubits[0], qubits[1]], [clbits[0], clbits[1]]
)
self.assertCircuitsEquivalent(test, expected)
with self.subTest("for (for, for)"):
# This test is specifically to check that multiple inner loops with different numbers of
# variables to each ``break`` still expand correctly.
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
test.measure(1, 1)
with test.for_loop(range(2)):
test.h(0)
loop_operation(test)
with test.for_loop(range(2)):
test.h(2)
loop_operation(test)
loop_operation(test)
inner_body1 = QuantumCircuit([qubits[0]])
inner_body1.h(qubits[0])
loop_operation(inner_body1)
inner_body2 = QuantumCircuit([qubits[2]])
inner_body2.h(qubits[2])
loop_operation(inner_body2)
outer_body = QuantumCircuit([qubits[0], qubits[1], qubits[2], clbits[1]])
outer_body.measure(qubits[1], clbits[1])
outer_body.for_loop(range(2), None, inner_body1, [qubits[0]], [])
outer_body.for_loop(range(2), None, inner_body2, [qubits[2]], [])
loop_operation(outer_body)
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(range(2), None, outer_body, qubits, [clbits[1]])
self.assertCircuitsEquivalent(test, expected)
@ddt.data(QuantumCircuit.break_loop, QuantumCircuit.continue_loop)
def test_break_continue_nested_in_if(self, loop_operation):
"""Test that ``break`` and ``continue`` work correctly when inside an ``if`` block within a
loop. This includes testing that multiple different ``if`` statements with and without
``break`` expand to the correct number of arguments.
This is a very important case; it requires that the :obj:`.IfElseOp` is not built until the
loop builds, and that the width expands to include everything that the loop knows about, not
just the inner context. We test both ``if`` and ``if/else`` paths separately, because the
chaining of the context managers allows lots of possibilities for super weird edge cases.
There are several tests that build up in complexity to aid debugging if something goes
wrong; the aim is that there will be more information available depending on which of the
subtests pass and which fail.
"""
qubits = [Qubit(), Qubit(), Qubit()]
clbits = [Clbit(), Clbit(), Clbit(), Clbit()]
cond_inner = (clbits[0], 0)
cond_outer = (clbits[1], 0)
with self.subTest("for/if"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
with test.if_test(cond_inner):
loop_operation(test)
# The second empty `if` is to test that only blocks that _need_ to expand to be the
# full width of the loop do so.
with test.if_test(cond_inner):
pass
test.h(0).c_if(2, 0)
true_body1 = QuantumCircuit([qubits[0], clbits[0], clbits[2]])
loop_operation(true_body1)
true_body2 = QuantumCircuit([clbits[0]])
loop_body = QuantumCircuit([qubits[0], clbits[0], clbits[2]])
loop_body.if_test(cond_inner, true_body1, [qubits[0]], [clbits[0], clbits[2]])
loop_body.if_test(cond_inner, true_body2, [], [clbits[0]])
loop_body.h(qubits[0]).c_if(clbits[2], 0)
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(range(2), None, loop_body, [qubits[0]], [clbits[0], clbits[2]])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("for/else"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
with test.if_test(cond_inner) as else_:
test.h(1)
with else_:
loop_operation(test)
with test.if_test(cond_inner) as else_:
pass
with else_:
pass
test.h(0).c_if(2, 0)
true_body1 = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[2]])
true_body1.h(qubits[1])
false_body1 = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[2]])
loop_operation(false_body1)
true_body2 = QuantumCircuit([clbits[0]])
false_body2 = QuantumCircuit([clbits[0]])
loop_body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[2]])
loop_body.if_else(
cond_inner, true_body1, false_body1, [qubits[0], qubits[1]], [clbits[0], clbits[2]]
)
loop_body.if_else(cond_inner, true_body2, false_body2, [], [clbits[0]])
loop_body.h(qubits[0]).c_if(clbits[2], 0)
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(
range(2), None, loop_body, [qubits[0], qubits[1]], [clbits[0], clbits[2]]
)
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while/if"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond_outer):
with test.if_test(cond_inner):
loop_operation(test)
with test.if_test(cond_inner):
pass
test.h(0).c_if(2, 0)
true_body1 = QuantumCircuit([qubits[0], clbits[0], clbits[1], clbits[2]])
loop_operation(true_body1)
true_body2 = QuantumCircuit([clbits[0]])
loop_body = QuantumCircuit([qubits[0], clbits[0], clbits[1], clbits[2]])
loop_body.if_test(
cond_inner, true_body1, [qubits[0]], [clbits[0], clbits[1], clbits[2]]
)
loop_body.if_test(cond_inner, true_body2, [], [clbits[0]])
loop_body.h(qubits[0]).c_if(clbits[2], 0)
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(
cond_outer, loop_body, [qubits[0]], [clbits[0], clbits[1], clbits[2]]
)
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while/else"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond_outer):
with test.if_test(cond_inner) as else_:
test.h(1)
with else_:
loop_operation(test)
with test.if_test(cond_inner) as else_:
pass
with else_:
pass
test.h(0).c_if(2, 0)
true_body1 = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1], clbits[2]])
true_body1.h(qubits[1])
false_body1 = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1], clbits[2]])
loop_operation(false_body1)
true_body2 = QuantumCircuit([clbits[0]])
false_body2 = QuantumCircuit([clbits[0]])
loop_body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1], clbits[2]])
loop_body.if_else(
cond_inner,
true_body1,
false_body1,
[qubits[0], qubits[1]],
[clbits[0], clbits[1], clbits[2]],
)
loop_body.if_else(cond_inner, true_body2, false_body2, [], [clbits[0]])
loop_body.h(qubits[0]).c_if(clbits[2], 0)
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(
cond_outer, loop_body, [qubits[0], qubits[1]], [clbits[0], clbits[1], clbits[2]]
)
self.assertCircuitsEquivalent(test, expected)
@ddt.data(QuantumCircuit.break_loop, QuantumCircuit.continue_loop)
def test_break_continue_deeply_nested_in_if(self, loop_operation):
"""Test that ``break`` and ``continue`` work correctly when inside more than one ``if``
block within a loop. This includes testing that multiple different ``if`` statements with
and without ``break`` expand to the correct number of arguments.
These are the deepest tests, hitting all parts of the deferred builder scopes. We test both
``if`` and ``if/else`` paths at various levels of the scoping to try and account for as many
weird edge cases with the deferred behaviour as possible. We try to make sure, particularly
in the most complicated examples, that there are resources added before and after every
single scope, to try and catch all possibilities of where resources may be missed.
There are several tests that build up in complexity to aid debugging if something goes
wrong; the aim is that there will be more information available depending on which of the
subtests pass and which fail.
"""
# These are deliberately more than is absolutely needed so we can detect if extra resources
# are being erroneously included as well.
qubits = [Qubit() for _ in [None] * 20]
clbits = [Clbit() for _ in [None] * 20]
cond_inner = (clbits[0], 0)
cond_outer = (clbits[1], 0)
cond_loop = (clbits[2], 0)
with self.subTest("for/if/if"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
# outer true 1
with test.if_test(cond_outer):
# inner true 1
with test.if_test(cond_inner):
loop_operation(test)
# inner true 2
with test.if_test(cond_inner):
test.h(0).c_if(3, 0)
test.h(1).c_if(4, 0)
# outer true 2
with test.if_test(cond_outer):
test.h(2).c_if(5, 0)
test.h(3).c_if(6, 0)
inner_true_body1 = QuantumCircuit(qubits[:4], clbits[:2], clbits[3:7])
loop_operation(inner_true_body1)
inner_true_body2 = QuantumCircuit([qubits[0], clbits[0], clbits[3]])
inner_true_body2.h(qubits[0]).c_if(clbits[3], 0)
outer_true_body1 = QuantumCircuit(qubits[:4], clbits[:2], clbits[3:7])
outer_true_body1.if_test(
cond_inner, inner_true_body1, qubits[:4], clbits[:2] + clbits[3:7]
)
outer_true_body1.if_test(
cond_inner, inner_true_body2, [qubits[0]], [clbits[0], clbits[3]]
)
outer_true_body1.h(qubits[1]).c_if(clbits[4], 0)
outer_true_body2 = QuantumCircuit([qubits[2], clbits[1], clbits[5]])
outer_true_body2.h(qubits[2]).c_if(clbits[5], 0)
loop_body = QuantumCircuit(qubits[:4], clbits[:2] + clbits[3:7])
loop_body.if_test(cond_outer, outer_true_body1, qubits[:4], clbits[:2] + clbits[3:7])
loop_body.if_test(cond_outer, outer_true_body2, [qubits[2]], [clbits[1], clbits[5]])
loop_body.h(qubits[3]).c_if(clbits[6], 0)
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(range(2), None, loop_body, qubits[:4], clbits[:2] + clbits[3:7])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("for/if/else"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
# outer 1
with test.if_test(cond_outer):
# inner 1
with test.if_test(cond_inner) as inner1_else:
test.h(0).c_if(3, 0)
with inner1_else:
loop_operation(test).c_if(4, 0)
# inner 2
with test.if_test(cond_inner) as inner2_else:
test.h(1).c_if(5, 0)
with inner2_else:
test.h(2).c_if(6, 0)
test.h(3).c_if(7, 0)
# outer 2
with test.if_test(cond_outer) as outer2_else:
test.h(4).c_if(8, 0)
with outer2_else:
test.h(5).c_if(9, 0)
test.h(6).c_if(10, 0)
inner1_true = QuantumCircuit(qubits[:7], clbits[:2], clbits[3:11])
inner1_true.h(qubits[0]).c_if(clbits[3], 0)
inner1_false = QuantumCircuit(qubits[:7], clbits[:2], clbits[3:11])
loop_operation(inner1_false).c_if(clbits[4], 0)
inner2_true = QuantumCircuit([qubits[1], qubits[2], clbits[0], clbits[5], clbits[6]])
inner2_true.h(qubits[1]).c_if(clbits[5], 0)
inner2_false = QuantumCircuit([qubits[1], qubits[2], clbits[0], clbits[5], clbits[6]])
inner2_false.h(qubits[2]).c_if(clbits[6], 0)
outer1_true = QuantumCircuit(qubits[:7], clbits[:2], clbits[3:11])
outer1_true.if_else(
cond_inner, inner1_true, inner1_false, qubits[:7], clbits[:2] + clbits[3:11]
)
outer1_true.if_else(
cond_inner,
inner2_true,
inner2_false,
qubits[1:3],
[clbits[0], clbits[5], clbits[6]],
)
outer1_true.h(qubits[3]).c_if(clbits[7], 0)
outer2_true = QuantumCircuit([qubits[4], qubits[5], clbits[1], clbits[8], clbits[9]])
outer2_true.h(qubits[4]).c_if(clbits[8], 0)
outer2_false = QuantumCircuit([qubits[4], qubits[5], clbits[1], clbits[8], clbits[9]])
outer2_false.h(qubits[5]).c_if(clbits[9], 0)
loop_body = QuantumCircuit(qubits[:7], clbits[:2], clbits[3:11])
loop_body.if_test(cond_outer, outer1_true, qubits[:7], clbits[:2] + clbits[3:11])
loop_body.if_else(
cond_outer,
outer2_true,
outer2_false,
qubits[4:6],
[clbits[1], clbits[8], clbits[9]],
)
loop_body.h(qubits[6]).c_if(clbits[10], 0)
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(range(2), None, loop_body, qubits[:7], clbits[:2] + clbits[3:11])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("for/else/else"):
# Look on my works, ye Mighty, and despair!
# (but also hopefully this is less hubristic pretension and more a useful stress test)
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
test.h(0).c_if(3, 0)
# outer 1
with test.if_test(cond_outer) as outer1_else:
test.h(1).c_if(4, 0)
with outer1_else:
test.h(2).c_if(5, 0)
# outer 2 (nesting the inner condition in the 'if')
with test.if_test(cond_outer) as outer2_else:
test.h(3).c_if(6, 0)
# inner 21
with test.if_test(cond_inner) as inner21_else:
loop_operation(test)
with inner21_else:
test.h(4).c_if(7, 0)
# inner 22
with test.if_test(cond_inner) as inner22_else:
test.h(5).c_if(8, 0)
with inner22_else:
loop_operation(test)
test.h(6).c_if(9, 0)
with outer2_else:
test.h(7).c_if(10, 0)
# inner 23
with test.if_test(cond_inner) as inner23_else:
test.h(8).c_if(11, 0)
with inner23_else:
test.h(9).c_if(12, 0)
# outer 3 (nesting the inner condition in an 'else' branch)
with test.if_test(cond_outer) as outer3_else:
test.h(10).c_if(13, 0)
with outer3_else:
test.h(11).c_if(14, 0)
# inner 31
with test.if_test(cond_inner) as inner31_else:
loop_operation(test)
with inner31_else:
test.h(12).c_if(15, 0)
# inner 32
with test.if_test(cond_inner) as inner32_else:
test.h(13).c_if(16, 0)
with inner32_else:
loop_operation(test)
# inner 33
with test.if_test(cond_inner) as inner33_else:
test.h(14).c_if(17, 0)
with inner33_else:
test.h(15).c_if(18, 0)
test.h(16).c_if(19, 0)
# End of test "for" loop.
# No `clbits[2]` here because that's only used in `cond_loop`, for while loops.
loop_qubits = qubits[:17]
loop_clbits = clbits[:2] + clbits[3:20]
loop_bits = loop_qubits + loop_clbits
outer1_true = QuantumCircuit([qubits[1], qubits[2], clbits[1], clbits[4], clbits[5]])
outer1_true.h(qubits[1]).c_if(clbits[4], 0)
outer1_false = QuantumCircuit([qubits[1], qubits[2], clbits[1], clbits[4], clbits[5]])
outer1_false.h(qubits[2]).c_if(clbits[5], 0)
inner21_true = QuantumCircuit(loop_bits)
loop_operation(inner21_true)
inner21_false = QuantumCircuit(loop_bits)
inner21_false.h(qubits[4]).c_if(clbits[7], 0)
inner22_true = QuantumCircuit(loop_bits)
inner22_true.h(qubits[5]).c_if(clbits[8], 0)
inner22_false = QuantumCircuit(loop_bits)
loop_operation(inner22_false)
inner23_true = QuantumCircuit(qubits[8:10], [clbits[0], clbits[11], clbits[12]])
inner23_true.h(qubits[8]).c_if(clbits[11], 0)
inner23_false = QuantumCircuit(qubits[8:10], [clbits[0], clbits[11], clbits[12]])
inner23_false.h(qubits[9]).c_if(clbits[12], 0)
outer2_true = QuantumCircuit(loop_bits)
outer2_true.h(qubits[3]).c_if(clbits[6], 0)
outer2_true.if_else(cond_inner, inner21_true, inner21_false, loop_qubits, loop_clbits)
outer2_true.if_else(cond_inner, inner22_true, inner22_false, loop_qubits, loop_clbits)
outer2_true.h(qubits[6]).c_if(clbits[9], 0)
outer2_false = QuantumCircuit(loop_bits)
outer2_false.h(qubits[7]).c_if(clbits[10], 0)
outer2_false.if_else(
cond_inner,
inner23_true,
inner23_false,
[qubits[8], qubits[9]],
[clbits[0], clbits[11], clbits[12]],
)
inner31_true = QuantumCircuit(loop_bits)
loop_operation(inner31_true)
inner31_false = QuantumCircuit(loop_bits)
inner31_false.h(qubits[12]).c_if(clbits[15], 0)
inner32_true = QuantumCircuit(loop_bits)
inner32_true.h(qubits[13]).c_if(clbits[16], 0)
inner32_false = QuantumCircuit(loop_bits)
loop_operation(inner32_false)
inner33_true = QuantumCircuit(qubits[14:16], [clbits[0], clbits[17], clbits[18]])
inner33_true.h(qubits[14]).c_if(clbits[17], 0)
inner33_false = QuantumCircuit(qubits[14:16], [clbits[0], clbits[17], clbits[18]])
inner33_false.h(qubits[15]).c_if(clbits[18], 0)
outer3_true = QuantumCircuit(loop_bits)
outer3_true.h(qubits[10]).c_if(clbits[13], 0)
outer3_false = QuantumCircuit(loop_bits)
outer3_false.h(qubits[11]).c_if(clbits[14], 0)
outer3_false.if_else(cond_inner, inner31_true, inner31_false, loop_qubits, loop_clbits)
outer3_false.if_else(cond_inner, inner32_true, inner32_false, loop_qubits, loop_clbits)
outer3_false.if_else(
cond_inner,
inner33_true,
inner33_false,
qubits[14:16],
[clbits[0], clbits[17], clbits[18]],
)
loop_body = QuantumCircuit(loop_bits)
loop_body.h(qubits[0]).c_if(clbits[3], 0)
loop_body.if_else(
cond_outer,
outer1_true,
outer1_false,
qubits[1:3],
[clbits[1], clbits[4], clbits[5]],
)
loop_body.if_else(cond_outer, outer2_true, outer2_false, loop_qubits, loop_clbits)
loop_body.if_else(cond_outer, outer3_true, outer3_false, loop_qubits, loop_clbits)
loop_body.h(qubits[16]).c_if(clbits[19], 0)
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(range(2), None, loop_body, loop_qubits, loop_clbits)
self.assertCircuitsEquivalent(test, expected)
# And now we repeat everything for "while" loops... Trying to parameterize the test over
# 'for/while' mostly just ends up in it being a bit illegible, because so many parameters
# vary in the explicit construction form. These tests are just copies of the above tests,
# but with `while_loop(cond_loop)` instead of `for_loop(range(2))`, and the corresponding
# clbit ranges updated to include `clbits[2]` from the condition.
with self.subTest("while/if/if"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond_loop):
# outer true 1
with test.if_test(cond_outer):
# inner true 1
with test.if_test(cond_inner):
loop_operation(test)
# inner true 2
with test.if_test(cond_inner):
test.h(0).c_if(3, 0)
test.h(1).c_if(4, 0)
# outer true 2
with test.if_test(cond_outer):
test.h(2).c_if(5, 0)
test.h(3).c_if(6, 0)
inner_true_body1 = QuantumCircuit(qubits[:4], clbits[:7])
loop_operation(inner_true_body1)
inner_true_body2 = QuantumCircuit([qubits[0], clbits[0], clbits[3]])
inner_true_body2.h(qubits[0]).c_if(clbits[3], 0)
outer_true_body1 = QuantumCircuit(qubits[:4], clbits[:7])
outer_true_body1.if_test(cond_inner, inner_true_body1, qubits[:4], clbits[:7])
outer_true_body1.if_test(
cond_inner, inner_true_body2, [qubits[0]], [clbits[0], clbits[3]]
)
outer_true_body1.h(qubits[1]).c_if(clbits[4], 0)
outer_true_body2 = QuantumCircuit([qubits[2], clbits[1], clbits[5]])
outer_true_body2.h(qubits[2]).c_if(clbits[5], 0)
loop_body = QuantumCircuit(qubits[:4], clbits[:7])
loop_body.if_test(cond_outer, outer_true_body1, qubits[:4], clbits[:7])
loop_body.if_test(cond_outer, outer_true_body2, [qubits[2]], [clbits[1], clbits[5]])
loop_body.h(qubits[3]).c_if(clbits[6], 0)
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(cond_loop, loop_body, qubits[:4], clbits[:7])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while/if/else"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond_loop):
# outer 1
with test.if_test(cond_outer):
# inner 1
with test.if_test(cond_inner) as inner1_else:
test.h(0).c_if(3, 0)
with inner1_else:
loop_operation(test).c_if(4, 0)
# inner 2
with test.if_test(cond_inner) as inner2_else:
test.h(1).c_if(5, 0)
with inner2_else:
test.h(2).c_if(6, 0)
test.h(3).c_if(7, 0)
# outer 2
with test.if_test(cond_outer) as outer2_else:
test.h(4).c_if(8, 0)
with outer2_else:
test.h(5).c_if(9, 0)
test.h(6).c_if(10, 0)
inner1_true = QuantumCircuit(qubits[:7], clbits[:11])
inner1_true.h(qubits[0]).c_if(clbits[3], 0)
inner1_false = QuantumCircuit(qubits[:7], clbits[:11])
loop_operation(inner1_false).c_if(clbits[4], 0)
inner2_true = QuantumCircuit([qubits[1], qubits[2], clbits[0], clbits[5], clbits[6]])
inner2_true.h(qubits[1]).c_if(clbits[5], 0)
inner2_false = QuantumCircuit([qubits[1], qubits[2], clbits[0], clbits[5], clbits[6]])
inner2_false.h(qubits[2]).c_if(clbits[6], 0)
outer1_true = QuantumCircuit(qubits[:7], clbits[:11])
outer1_true.if_else(cond_inner, inner1_true, inner1_false, qubits[:7], clbits[:11])
outer1_true.if_else(
cond_inner,
inner2_true,
inner2_false,
qubits[1:3],
[clbits[0], clbits[5], clbits[6]],
)
outer1_true.h(qubits[3]).c_if(clbits[7], 0)
outer2_true = QuantumCircuit([qubits[4], qubits[5], clbits[1], clbits[8], clbits[9]])
outer2_true.h(qubits[4]).c_if(clbits[8], 0)
outer2_false = QuantumCircuit([qubits[4], qubits[5], clbits[1], clbits[8], clbits[9]])
outer2_false.h(qubits[5]).c_if(clbits[9], 0)
loop_body = QuantumCircuit(qubits[:7], clbits[:11])
loop_body.if_test(cond_outer, outer1_true, qubits[:7], clbits[:11])
loop_body.if_else(
cond_outer,
outer2_true,
outer2_false,
qubits[4:6],
[clbits[1], clbits[8], clbits[9]],
)
loop_body.h(qubits[6]).c_if(clbits[10], 0)
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(cond_loop, loop_body, qubits[:7], clbits[:11])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while/else/else"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond_loop):
test.h(0).c_if(3, 0)
# outer 1
with test.if_test(cond_outer) as outer1_else:
test.h(1).c_if(4, 0)
with outer1_else:
test.h(2).c_if(5, 0)
# outer 2 (nesting the inner condition in the 'if')
with test.if_test(cond_outer) as outer2_else:
test.h(3).c_if(6, 0)
# inner 21
with test.if_test(cond_inner) as inner21_else:
loop_operation(test)
with inner21_else:
test.h(4).c_if(7, 0)
# inner 22
with test.if_test(cond_inner) as inner22_else:
test.h(5).c_if(8, 0)
with inner22_else:
loop_operation(test)
test.h(6).c_if(9, 0)
with outer2_else:
test.h(7).c_if(10, 0)
# inner 23
with test.if_test(cond_inner) as inner23_else:
test.h(8).c_if(11, 0)
with inner23_else:
test.h(9).c_if(12, 0)
# outer 3 (nesting the inner condition in an 'else' branch)
with test.if_test(cond_outer) as outer3_else:
test.h(10).c_if(13, 0)
with outer3_else:
test.h(11).c_if(14, 0)
# inner 31
with test.if_test(cond_inner) as inner31_else:
loop_operation(test)
with inner31_else:
test.h(12).c_if(15, 0)
# inner 32
with test.if_test(cond_inner) as inner32_else:
test.h(13).c_if(16, 0)
with inner32_else:
loop_operation(test)
# inner 33
with test.if_test(cond_inner) as inner33_else:
test.h(14).c_if(17, 0)
with inner33_else:
test.h(15).c_if(18, 0)
test.h(16).c_if(19, 0)
# End of test "for" loop.
# No `clbits[2]` here because that's only used in `cond_loop`, for while loops.
loop_qubits = qubits[:17]
loop_clbits = clbits[:20]
loop_bits = loop_qubits + loop_clbits
outer1_true = QuantumCircuit([qubits[1], qubits[2], clbits[1], clbits[4], clbits[5]])
outer1_true.h(qubits[1]).c_if(clbits[4], 0)
outer1_false = QuantumCircuit([qubits[1], qubits[2], clbits[1], clbits[4], clbits[5]])
outer1_false.h(qubits[2]).c_if(clbits[5], 0)
inner21_true = QuantumCircuit(loop_bits)
loop_operation(inner21_true)
inner21_false = QuantumCircuit(loop_bits)
inner21_false.h(qubits[4]).c_if(clbits[7], 0)
inner22_true = QuantumCircuit(loop_bits)
inner22_true.h(qubits[5]).c_if(clbits[8], 0)
inner22_false = QuantumCircuit(loop_bits)
loop_operation(inner22_false)
inner23_true = QuantumCircuit(qubits[8:10], [clbits[0], clbits[11], clbits[12]])
inner23_true.h(qubits[8]).c_if(clbits[11], 0)
inner23_false = QuantumCircuit(qubits[8:10], [clbits[0], clbits[11], clbits[12]])
inner23_false.h(qubits[9]).c_if(clbits[12], 0)
outer2_true = QuantumCircuit(loop_bits)
outer2_true.h(qubits[3]).c_if(clbits[6], 0)
outer2_true.if_else(cond_inner, inner21_true, inner21_false, loop_qubits, loop_clbits)
outer2_true.if_else(cond_inner, inner22_true, inner22_false, loop_qubits, loop_clbits)
outer2_true.h(qubits[6]).c_if(clbits[9], 0)
outer2_false = QuantumCircuit(loop_bits)
outer2_false.h(qubits[7]).c_if(clbits[10], 0)
outer2_false.if_else(
cond_inner,
inner23_true,
inner23_false,
[qubits[8], qubits[9]],
[clbits[0], clbits[11], clbits[12]],
)
inner31_true = QuantumCircuit(loop_bits)
loop_operation(inner31_true)
inner31_false = QuantumCircuit(loop_bits)
inner31_false.h(qubits[12]).c_if(clbits[15], 0)
inner32_true = QuantumCircuit(loop_bits)
inner32_true.h(qubits[13]).c_if(clbits[16], 0)
inner32_false = QuantumCircuit(loop_bits)
loop_operation(inner32_false)
inner33_true = QuantumCircuit(qubits[14:16], [clbits[0], clbits[17], clbits[18]])
inner33_true.h(qubits[14]).c_if(clbits[17], 0)
inner33_false = QuantumCircuit(qubits[14:16], [clbits[0], clbits[17], clbits[18]])
inner33_false.h(qubits[15]).c_if(clbits[18], 0)
outer3_true = QuantumCircuit(loop_bits)
outer3_true.h(qubits[10]).c_if(clbits[13], 0)
outer3_false = QuantumCircuit(loop_bits)
outer3_false.h(qubits[11]).c_if(clbits[14], 0)
outer3_false.if_else(cond_inner, inner31_true, inner31_false, loop_qubits, loop_clbits)
outer3_false.if_else(cond_inner, inner32_true, inner32_false, loop_qubits, loop_clbits)
outer3_false.if_else(
cond_inner,
inner33_true,
inner33_false,
qubits[14:16],
[clbits[0], clbits[17], clbits[18]],
)
loop_body = QuantumCircuit(loop_bits)
loop_body.h(qubits[0]).c_if(clbits[3], 0)
loop_body.if_else(
cond_outer,
outer1_true,
outer1_false,
qubits[1:3],
[clbits[1], clbits[4], clbits[5]],
)
loop_body.if_else(cond_outer, outer2_true, outer2_false, loop_qubits, loop_clbits)
loop_body.if_else(cond_outer, outer3_true, outer3_false, loop_qubits, loop_clbits)
loop_body.h(qubits[16]).c_if(clbits[19], 0)
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(cond_loop, loop_body, loop_qubits, loop_clbits)
self.assertCircuitsEquivalent(test, expected)
def test_for_handles_iterables_correctly(self):
"""Test that the ``indexset`` in ``for`` loops is handled the way we expect. In general,
this means all iterables are consumed into a tuple on first access, except for ``range``
which is passed through as-is."""
bits = [Qubit(), Clbit()]
expected_indices = (3, 9, 1)
with self.subTest("list"):
test = QuantumCircuit(bits)
with test.for_loop(list(expected_indices)):
pass
instruction, _, _ = test.data[-1]
self.assertIsInstance(instruction, ForLoopOp)
indices, _, _ = instruction.params
self.assertEqual(indices, expected_indices)
with self.subTest("tuple"):
test = QuantumCircuit(bits)
with test.for_loop(tuple(expected_indices)):
pass
instruction, _, _ = test.data[-1]
self.assertIsInstance(instruction, ForLoopOp)
indices, _, _ = instruction.params
self.assertEqual(indices, expected_indices)
with self.subTest("consumable"):
def consumable():
yield from expected_indices
test = QuantumCircuit(bits)
with test.for_loop(consumable()):
pass
instruction, _, _ = test.data[-1]
self.assertIsInstance(instruction, ForLoopOp)
indices, _, _ = instruction.params
self.assertEqual(indices, expected_indices)
with self.subTest("range"):
range_indices = range(0, 8, 2)
test = QuantumCircuit(bits)
with test.for_loop(range_indices):
pass
instruction, _, _ = test.data[-1]
self.assertIsInstance(instruction, ForLoopOp)
indices, _, _ = instruction.params
self.assertEqual(indices, range_indices)
def test_for_returns_a_given_parameter(self):
"""Test that the ``for``-loop manager returns the parameter that we gave it."""
parameter = Parameter("x")
test = QuantumCircuit(1, 1)
with test.for_loop((0, 1), parameter) as test_parameter:
pass
self.assertIs(test_parameter, parameter)
def test_for_binds_parameter_to_op(self):
"""Test that the ``for`` manager binds a parameter to the resulting :obj:`.ForLoopOp` if a
user-generated one is given, or if a generated parameter is used. Generated parameters that
are not used should not be bound."""
parameter = Parameter("x")
with self.subTest("passed and used"):
circuit = QuantumCircuit(1, 1)
with circuit.for_loop((0, 0.5 * math.pi), parameter) as received_parameter:
circuit.rx(received_parameter, 0)
self.assertIs(parameter, received_parameter)
instruction = circuit.data[-1][0]
self.assertIsInstance(instruction, ForLoopOp)
_, bound_parameter, _ = instruction.params
self.assertIs(bound_parameter, parameter)
with self.subTest("passed and unused"):
circuit = QuantumCircuit(1, 1)
with circuit.for_loop((0, 0.5 * math.pi), parameter) as received_parameter:
circuit.x(0)
self.assertIs(parameter, received_parameter)
instruction = circuit.data[-1][0]
self.assertIsInstance(instruction, ForLoopOp)
_, bound_parameter, _ = instruction.params
self.assertIs(parameter, received_parameter)
with self.subTest("generated and used"):
circuit = QuantumCircuit(1, 1)
with circuit.for_loop((0, 0.5 * math.pi)) as received_parameter:
circuit.rx(received_parameter, 0)
self.assertIsInstance(received_parameter, Parameter)
instruction = circuit.data[-1][0]
self.assertIsInstance(instruction, ForLoopOp)
_, bound_parameter, _ = instruction.params
self.assertIs(bound_parameter, received_parameter)
with self.subTest("generated and used in deferred-build if"):
circuit = QuantumCircuit(1, 1)
with circuit.for_loop((0, 0.5 * math.pi)) as received_parameter:
with circuit.if_test((0, 0)):
circuit.rx(received_parameter, 0)
circuit.break_loop()
self.assertIsInstance(received_parameter, Parameter)
instruction = circuit.data[-1][0]
self.assertIsInstance(instruction, ForLoopOp)
_, bound_parameter, _ = instruction.params
self.assertIs(bound_parameter, received_parameter)
with self.subTest("generated and used in deferred-build else"):
circuit = QuantumCircuit(1, 1)
with circuit.for_loop((0, 0.5 * math.pi)) as received_parameter:
with circuit.if_test((0, 0)) as else_:
pass
with else_:
circuit.rx(received_parameter, 0)
circuit.break_loop()
self.assertIsInstance(received_parameter, Parameter)
instruction = circuit.data[-1][0]
self.assertIsInstance(instruction, ForLoopOp)
_, bound_parameter, _ = instruction.params
self.assertIs(bound_parameter, received_parameter)
def test_for_does_not_bind_generated_parameter_if_unused(self):
"""Test that the ``for`` manager does not bind a generated parameter into the resulting
:obj:`.ForLoopOp` if the parameter was not used."""
test = QuantumCircuit(1, 1)
with test.for_loop(range(2)) as generated_parameter:
pass
instruction = test.data[-1][0]
self.assertIsInstance(instruction, ForLoopOp)
_, bound_parameter, _ = instruction.params
self.assertIsNot(generated_parameter, None)
self.assertIs(bound_parameter, None)
def test_for_allocates_parameters(self):
"""Test that the ``for``-loop manager allocates a parameter if it is given ``None``, and
that it always allocates new parameters."""
test = QuantumCircuit(1, 1)
with test.for_loop(range(2)) as outer_parameter:
with test.for_loop(range(2)) as inner_parameter:
pass
with test.for_loop(range(2)) as final_parameter:
pass
self.assertIsInstance(outer_parameter, Parameter)
self.assertIsInstance(inner_parameter, Parameter)
self.assertIsInstance(final_parameter, Parameter)
self.assertNotEqual(outer_parameter, inner_parameter)
self.assertNotEqual(outer_parameter, final_parameter)
self.assertNotEqual(inner_parameter, final_parameter)
def test_access_of_resources_from_direct_append(self):
"""Test that direct calls to :obj:`.QuantumCircuit.append` within a builder block still
collect all the relevant resources."""
qubits = [Qubit(), Qubit()]
clbits = [Clbit(), Clbit()]
cond = (clbits[0], 0)
with self.subTest("if"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond):
test.append(Measure(), [qubits[1]], [clbits[1]])
true_body = QuantumCircuit([qubits[1]], clbits)
true_body.measure(qubits[1], clbits[1])
expected = QuantumCircuit(qubits, clbits)
expected.if_test(cond, true_body, [qubits[1]], clbits)
self.assertCircuitsEquivalent(test, expected)
with self.subTest("else"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond) as else_:
pass
with else_:
test.append(Measure(), [qubits[1]], [clbits[1]])
true_body = QuantumCircuit([qubits[1]], clbits)
false_body = QuantumCircuit([qubits[1]], clbits)
false_body.measure(qubits[1], clbits[1])
expected = QuantumCircuit(qubits, clbits)
expected.if_else(cond, true_body, false_body, [qubits[1]], clbits)
self.assertCircuitsEquivalent(test, expected)
with self.subTest("for"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
test.append(Measure(), [qubits[1]], [clbits[1]])
body = QuantumCircuit([qubits[1]], [clbits[1]])
body.measure(qubits[1], clbits[1])
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(range(2), None, body, [qubits[1]], [clbits[1]])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond):
test.append(Measure(), [qubits[1]], [clbits[1]])
body = QuantumCircuit([qubits[1]], clbits)
body.measure(qubits[1], clbits[1])
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(cond, body, [qubits[1]], clbits)
self.assertCircuitsEquivalent(test, expected)
def test_access_of_clbit_from_c_if(self):
"""Test that resources added from a call to :meth:`.InstructionSet.c_if` propagate through
the context managers correctly."""
qubits = [Qubit(), Qubit()]
clbits = [Clbit(), Clbit()]
bits = qubits + clbits
cond = (clbits[0], 0)
with self.subTest("if"):
test = QuantumCircuit(bits)
with test.if_test(cond):
test.h(0).c_if(1, 0)
body = QuantumCircuit([qubits[0]], clbits)
body.h(qubits[0]).c_if(clbits[1], 0)
expected = QuantumCircuit(bits)
expected.if_test(cond, body, [qubits[0]], clbits)
with self.subTest("else"):
test = QuantumCircuit(bits)
with test.if_test(cond) as else_:
pass
with else_:
test.h(0).c_if(1, 0)
true_body = QuantumCircuit([qubits[0]], clbits)
false_body = QuantumCircuit([qubits[0]], clbits)
false_body.h(qubits[0]).c_if(clbits[1], 0)
expected = QuantumCircuit(bits)
expected.if_else(cond, true_body, false_body, [qubits[0]], clbits)
with self.subTest("for"):
test = QuantumCircuit(bits)
with test.for_loop(range(2)):
test.h(0).c_if(1, 0)
body = QuantumCircuit([qubits[0]], clbits)
body.h(qubits[0]).c_if(clbits[1], 0)
expected = QuantumCircuit(bits)
expected.for_loop(range(2), None, body, [qubits[0]], clbits)
with self.subTest("while"):
test = QuantumCircuit(bits)
with test.while_loop(cond):
test.h(0).c_if(1, 0)
body = QuantumCircuit([qubits[0]], clbits)
body.h(qubits[0]).c_if(clbits[1], 0)
expected = QuantumCircuit(bits)
expected.while_loop(cond, body, [qubits[0]], clbits)
with self.subTest("if inside for"):
test = QuantumCircuit(bits)
with test.for_loop(range(2)):
with test.if_test(cond):
test.h(0).c_if(1, 0)
true_body = QuantumCircuit([qubits[0]], clbits)
true_body.h(qubits[0]).c_if(clbits[1], 0)
body = QuantumCircuit([qubits[0]], clbits)
body.if_test(cond, body, [qubits[0]], clbits)
expected = QuantumCircuit(bits)
expected.for_loop(range(2), None, body, [qubits[0]], clbits)
def test_access_of_classicalregister_from_c_if(self):
"""Test that resources added from a call to :meth:`.InstructionSet.c_if` propagate through
the context managers correctly."""
qubits = [Qubit(), Qubit()]
creg = ClassicalRegister(2)
clbits = [Clbit()]
all_clbits = list(clbits) + list(creg)
cond = (clbits[0], 0)
with self.subTest("if"):
test = QuantumCircuit(qubits, clbits, creg)
with test.if_test(cond):
test.h(0).c_if(creg, 0)
body = QuantumCircuit([qubits[0]], clbits, creg)
body.h(qubits[0]).c_if(creg, 0)
expected = QuantumCircuit(qubits, clbits, creg)
expected.if_test(cond, body, [qubits[0]], all_clbits)
with self.subTest("else"):
test = QuantumCircuit(qubits, clbits, creg)
with test.if_test(cond) as else_:
pass
with else_:
test.h(0).c_if(1, 0)
true_body = QuantumCircuit([qubits[0]], clbits, creg)
false_body = QuantumCircuit([qubits[0]], clbits, creg)
false_body.h(qubits[0]).c_if(creg, 0)
expected = QuantumCircuit(qubits, clbits, creg)
expected.if_else(cond, true_body, false_body, [qubits[0]], all_clbits)
with self.subTest("for"):
test = QuantumCircuit(qubits, clbits, creg)
with test.for_loop(range(2)):
test.h(0).c_if(1, 0)
body = QuantumCircuit([qubits[0]], clbits, creg)
body.h(qubits[0]).c_if(creg, 0)
expected = QuantumCircuit(qubits, clbits, creg)
expected.for_loop(range(2), None, body, [qubits[0]], all_clbits)
with self.subTest("while"):
test = QuantumCircuit(qubits, clbits, creg)
with test.while_loop(cond):
test.h(0).c_if(creg, 0)
body = QuantumCircuit([qubits[0]], clbits, creg)
body.h(qubits[0]).c_if(creg, 0)
expected = QuantumCircuit(qubits, clbits, creg)
expected.while_loop(cond, body, [qubits[0]], all_clbits)
with self.subTest("if inside for"):
test = QuantumCircuit(qubits, clbits, creg)
with test.for_loop(range(2)):
with test.if_test(cond):
test.h(0).c_if(creg, 0)
true_body = QuantumCircuit([qubits[0]], clbits, creg)
true_body.h(qubits[0]).c_if(creg, 0)
body = QuantumCircuit([qubits[0]], clbits, creg)
body.if_test(cond, body, [qubits[0]], all_clbits)
expected = QuantumCircuit(qubits, clbits, creg)
expected.for_loop(range(2), None, body, [qubits[0]], all_clbits)
def test_accept_broadcast_gates(self):
"""Test that the context managers accept gates that are broadcast during their addition to
the scope."""
qubits = [Qubit(), Qubit(), Qubit()]
clbits = [Clbit(), Clbit(), Clbit()]
cond = (clbits[0], 0)
with self.subTest("if"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond):
test.measure([0, 1], [0, 1])
body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1]])
body.measure(qubits[0], clbits[0])
body.measure(qubits[1], clbits[1])
expected = QuantumCircuit(qubits, clbits)
expected.if_test(cond, body, [qubits[0], qubits[1]], [clbits[0], clbits[1]])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("else"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond) as else_:
pass
with else_:
test.measure([0, 1], [0, 1])
true_body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1]])
false_body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1]])
false_body.measure(qubits[0], clbits[0])
false_body.measure(qubits[1], clbits[1])
expected = QuantumCircuit(qubits, clbits)
expected.if_else(
cond, true_body, false_body, [qubits[0], qubits[1]], [clbits[0], clbits[1]]
)
self.assertCircuitsEquivalent(test, expected)
with self.subTest("for"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
test.measure([0, 1], [0, 1])
body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1]])
body.measure(qubits[0], clbits[0])
body.measure(qubits[1], clbits[1])
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(range(2), None, body, [qubits[0], qubits[1]], [clbits[0], clbits[1]])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("while"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond):
test.measure([0, 1], [0, 1])
body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1]])
body.measure(qubits[0], clbits[0])
body.measure(qubits[1], clbits[1])
expected = QuantumCircuit(qubits, clbits)
expected.while_loop(cond, body, [qubits[0], qubits[1]], [clbits[0], clbits[1]])
self.assertCircuitsEquivalent(test, expected)
with self.subTest("if inside for"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(2)):
with test.if_test(cond):
test.measure([0, 1], [0, 1])
true_body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1]])
true_body.measure(qubits[0], clbits[0])
true_body.measure(qubits[1], clbits[1])
for_body = QuantumCircuit([qubits[0], qubits[1], clbits[0], clbits[1]])
for_body.if_test(cond, true_body, [qubits[0], qubits[1]], [clbits[0], clbits[1]])
expected = QuantumCircuit(qubits, clbits)
expected.for_loop(
range(2), None, for_body, [qubits[0], qubits[1]], [clbits[0], clbits[1]]
)
self.assertCircuitsEquivalent(test, expected)
def test_labels_propagated_to_instruction(self):
"""Test that labels given to the circuit-builder interface are passed through."""
bits = [Qubit(), Clbit()]
cond = (bits[1], 0)
label = "sentinel_label"
with self.subTest("if"):
test = QuantumCircuit(bits)
with test.if_test(cond, label=label):
pass
instruction = test.data[-1][0]
self.assertIsInstance(instruction, IfElseOp)
self.assertEqual(instruction.label, label)
with self.subTest("if else"):
test = QuantumCircuit(bits)
with test.if_test(cond, label=label) as else_:
pass
with else_:
pass
instruction = test.data[-1][0]
self.assertIsInstance(instruction, IfElseOp)
self.assertEqual(instruction.label, label)
with self.subTest("for"):
test = QuantumCircuit(bits)
with test.for_loop(range(2), label=label):
pass
instruction = test.data[-1][0]
self.assertIsInstance(instruction, ForLoopOp)
self.assertEqual(instruction.label, label)
with self.subTest("while"):
test = QuantumCircuit(bits)
with test.while_loop(cond, label=label):
pass
instruction = test.data[-1][0]
self.assertIsInstance(instruction, WhileLoopOp)
self.assertEqual(instruction.label, label)
# The tests of 'if' and 'else' inside 'for' are to ensure we're hitting the paths where the
# 'if' scope is built lazily at the completion of the 'for'.
with self.subTest("if inside for"):
test = QuantumCircuit(bits)
with test.for_loop(range(2)):
with test.if_test(cond, label=label):
# Use break to ensure that we're triggering the lazy building of 'if'.
test.break_loop()
instruction = test.data[-1][0].blocks[0].data[-1][0]
self.assertIsInstance(instruction, IfElseOp)
self.assertEqual(instruction.label, label)
with self.subTest("else inside for"):
test = QuantumCircuit(bits)
with test.for_loop(range(2)):
with test.if_test(cond, label=label) as else_:
# Use break to ensure that we're triggering the lazy building of 'if'.
test.break_loop()
with else_:
test.break_loop()
instruction = test.data[-1][0].blocks[0].data[-1][0]
self.assertIsInstance(instruction, IfElseOp)
self.assertEqual(instruction.label, label)
def test_copy_of_circuits(self):
"""Test that various methods of copying a circuit made with the builder interface works."""
test = QuantumCircuit(5, 5)
cond = (test.clbits[2], False)
with test.if_test(cond) as else_:
test.cx(0, 1)
with else_:
test.h(2)
with test.for_loop(range(5)):
with test.if_test(cond):
test.x(3)
with test.while_loop(cond):
test.measure(0, 4)
self.assertEqual(test, test.copy())
self.assertEqual(test, copy.copy(test))
self.assertEqual(test, copy.deepcopy(test))
def test_copy_of_instructions(self):
"""Test that various methods of copying the actual instructions created by the builder
interface work."""
qubits = [Qubit() for _ in [None] * 3]
clbits = [Clbit() for _ in [None] * 3]
cond = (clbits[1], False)
with self.subTest("if"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond):
test.cx(0, 1)
test.measure(2, 2)
if_instruction, _, _ = test.data[0]
self.assertEqual(if_instruction, if_instruction.copy())
self.assertEqual(if_instruction, copy.copy(if_instruction))
self.assertEqual(if_instruction, copy.deepcopy(if_instruction))
with self.subTest("if/else"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond) as else_:
test.cx(0, 1)
test.measure(2, 2)
with else_:
test.cx(1, 0)
test.measure(2, 2)
if_instruction, _, _ = test.data[0]
self.assertEqual(if_instruction, if_instruction.copy())
self.assertEqual(if_instruction, copy.copy(if_instruction))
self.assertEqual(if_instruction, copy.deepcopy(if_instruction))
with self.subTest("for"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(4)):
test.cx(0, 1)
test.measure(2, 2)
for_instruction, _, _ = test.data[0]
self.assertEqual(for_instruction, for_instruction.copy())
self.assertEqual(for_instruction, copy.copy(for_instruction))
self.assertEqual(for_instruction, copy.deepcopy(for_instruction))
with self.subTest("while"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond):
test.cx(0, 1)
test.measure(2, 2)
while_instruction, _, _ = test.data[0]
self.assertEqual(while_instruction, while_instruction.copy())
self.assertEqual(while_instruction, copy.copy(while_instruction))
self.assertEqual(while_instruction, copy.deepcopy(while_instruction))
def test_copy_of_instruction_parameters(self):
"""Test that various methods of copying the parameters inside instructions created by the
builder interface work. Regression test of gh-7367."""
qubits = [Qubit() for _ in [None] * 3]
clbits = [Clbit() for _ in [None] * 3]
cond = (clbits[1], False)
with self.subTest("if"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond):
test.cx(0, 1)
test.measure(2, 2)
if_instruction, _, _ = test.data[0]
(true_body,) = if_instruction.blocks
self.assertEqual(true_body, true_body.copy())
self.assertEqual(true_body, copy.copy(true_body))
self.assertEqual(true_body, copy.deepcopy(true_body))
with self.subTest("if/else"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond) as else_:
test.cx(0, 1)
test.measure(2, 2)
with else_:
test.cx(1, 0)
test.measure(2, 2)
if_instruction, _, _ = test.data[0]
true_body, false_body = if_instruction.blocks
self.assertEqual(true_body, true_body.copy())
self.assertEqual(true_body, copy.copy(true_body))
self.assertEqual(true_body, copy.deepcopy(true_body))
self.assertEqual(false_body, false_body.copy())
self.assertEqual(false_body, copy.copy(false_body))
self.assertEqual(false_body, copy.deepcopy(false_body))
with self.subTest("for"):
test = QuantumCircuit(qubits, clbits)
with test.for_loop(range(4)):
test.cx(0, 1)
test.measure(2, 2)
for_instruction, _, _ = test.data[0]
(for_body,) = for_instruction.blocks
self.assertEqual(for_body, for_body.copy())
self.assertEqual(for_body, copy.copy(for_body))
self.assertEqual(for_body, copy.deepcopy(for_body))
with self.subTest("while"):
test = QuantumCircuit(qubits, clbits)
with test.while_loop(cond):
test.cx(0, 1)
test.measure(2, 2)
while_instruction, _, _ = test.data[0]
(while_body,) = while_instruction.blocks
self.assertEqual(while_body, while_body.copy())
self.assertEqual(while_body, copy.copy(while_body))
self.assertEqual(while_body, copy.deepcopy(while_body))
@ddt.ddt
class TestControlFlowBuildersFailurePaths(QiskitTestCase):
"""Tests for the failure paths of the control-flow builders."""
def test_if_rejects_break_continue_if_not_in_loop(self):
"""Test that the ``if`` and ``else`` context managers raise a suitable exception if you try
to use a ``break`` or ``continue`` within them without being inside a loop. This is for
safety; without the loop context, the context manager will cause the wrong resources to be
assigned to the ``break``, so if you want to make a manual loop, you have to use manual
``if`` as well. That way the onus is on you."""
qubits = [Qubit()]
clbits = [Clbit()]
cond = (clbits[0], 0)
message = r"The current builder scope cannot take a '.*' because it is not in a loop\."
with self.subTest("if break"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond):
with self.assertRaisesRegex(CircuitError, message):
test.break_loop()
with self.subTest("if continue"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond):
with self.assertRaisesRegex(CircuitError, message):
test.continue_loop()
with self.subTest("else break"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond) as else_:
pass
with else_:
with self.assertRaisesRegex(CircuitError, message):
test.break_loop()
with self.subTest("else continue"):
test = QuantumCircuit(qubits, clbits)
with test.if_test(cond) as else_:
pass
with else_:
with self.assertRaisesRegex(CircuitError, message):
test.continue_loop()
def test_for_rejects_reentry(self):
"""Test that the ``for``-loop context manager rejects attempts to re-enter it. Since it
holds some forms of state during execution (the loop variable, which may be generated), we
can't safely re-enter it and get the expected behaviour."""
for_manager = QuantumCircuit(2, 2).for_loop(range(2))
with for_manager:
pass
with self.assertRaisesRegex(
CircuitError, r"A for-loop context manager cannot be re-entered."
):
with for_manager:
pass
def test_cannot_enter_else_context_incorrectly(self):
"""Test that various forms of using an 'else_' context manager incorrectly raise
exceptions."""
bits = [Qubit(), Clbit()]
cond = (bits[1], 0)
with self.subTest("not the next instruction"):
test = QuantumCircuit(bits)
with test.if_test(cond) as else_:
pass
test.h(0)
with self.assertRaisesRegex(CircuitError, "The 'if' block is not the most recent"):
with else_:
test.h(0)
with self.subTest("inside the attached if"):
test = QuantumCircuit(bits)
with test.if_test(cond) as else_:
with self.assertRaisesRegex(
CircuitError, r"Cannot attach an 'else' branch to an incomplete 'if' block\."
):
with else_:
test.h(0)
with self.subTest("inner else"):
test = QuantumCircuit(bits)
with test.if_test(cond) as else1:
with test.if_test(cond):
pass
with self.assertRaisesRegex(
CircuitError, r"Cannot attach an 'else' branch to an incomplete 'if' block\."
):
with else1:
test.h(0)
with self.subTest("reused else"):
test = QuantumCircuit(bits)
with test.if_test(cond) as else_:
pass
with else_:
pass
with self.assertRaisesRegex(CircuitError, r"Cannot re-use an 'else' context\."):
with else_:
pass
with self.subTest("else from an inner block"):
test = QuantumCircuit(bits)
with test.if_test(cond):
with test.if_test(cond) as else_:
pass
with self.assertRaisesRegex(CircuitError, "The 'if' block is not the most recent"):
with else_:
pass
def test_if_placeholder_rejects_c_if(self):
"""Test that the :obj:`.IfElsePlaceholder" class rejects attempts to use
:meth:`.Instruction.c_if` on it.
It *should* be the case that you need to use private methods to get access to one of these
placeholder objects at all, because they're appended to a scope at the exit of a context
manager, so not returned from a method call. Just in case, here's a test that it correctly
rejects the dangerous method that can overwrite ``condition``.
"""
bits = [Qubit(), Clbit()]
with self.subTest("if"):
test = QuantumCircuit(bits)
with test.for_loop(range(2)):
with test.if_test((bits[1], 0)):
test.break_loop()
# These tests need to be done before the 'for' context exits so we don't trigger the
# "can't add conditions from out-of-scope" handling.
placeholder, _, _ = test._peek_previous_instruction_in_scope()
self.assertIsInstance(placeholder, IfElsePlaceholder)
with self.assertRaisesRegex(
NotImplementedError,
r"IfElseOp cannot be classically controlled through Instruction\.c_if",
):
placeholder.c_if(bits[1], 0)
with self.subTest("else"):
test = QuantumCircuit(bits)
with test.for_loop(range(2)):
with test.if_test((bits[1], 0)) as else_:
pass
with else_:
test.break_loop()
# These tests need to be done before the 'for' context exits so we don't trigger the
# "can't add conditions from out-of-scope" handling.
placeholder, _, _ = test._peek_previous_instruction_in_scope()
self.assertIsInstance(placeholder, IfElsePlaceholder)
with self.assertRaisesRegex(
NotImplementedError,
r"IfElseOp cannot be classically controlled through Instruction\.c_if",
):
placeholder.c_if(bits[1], 0)
def test_reject_c_if_from_outside_scope(self):
"""Test that the context managers reject :meth:`.InstructionSet.c_if` calls if they occur
after their scope has completed."""
bits = [Qubit(), Clbit()]
cond = (bits[1], 0)
with self.subTest("if"):
test = QuantumCircuit(bits)
with test.if_test(cond):
instructions = test.h(0)
with self.assertRaisesRegex(
CircuitError, r"Cannot add resources after the scope has been built\."
):
instructions.c_if(*cond)
with self.subTest("else"):
test = QuantumCircuit(bits)
with test.if_test(cond) as else_:
pass
with else_:
instructions = test.h(0)
with self.assertRaisesRegex(
CircuitError, r"Cannot add resources after the scope has been built\."
):
instructions.c_if(*cond)
with self.subTest("for"):
test = QuantumCircuit(bits)
with test.for_loop(range(2)):
instructions = test.h(0)
with self.assertRaisesRegex(
CircuitError, r"Cannot add resources after the scope has been built\."
):
instructions.c_if(*cond)
with self.subTest("while"):
test = QuantumCircuit(bits)
with test.while_loop(cond):
instructions = test.h(0)
with self.assertRaisesRegex(
CircuitError, r"Cannot add resources after the scope has been built\."
):
instructions.c_if(*cond)
with self.subTest("if inside for"):
# As a side-effect of how the lazy building of 'if' statements works, we actually
# *could* add a condition to the gate after the 'if' block as long as we were still
# within the 'for' loop. It should actually manage the resource correctly as well, but
# it's "undefined behaviour" than something we specifically want to forbid or allow.
test = QuantumCircuit(bits)
with test.for_loop(range(2)):
with test.if_test(cond):
instructions = test.h(0)
with self.assertRaisesRegex(
CircuitError, r"Cannot add resources after the scope has been built\."
):
instructions.c_if(*cond)
def test_raising_inside_context_manager_leave_circuit_usable(self):
"""Test that if we leave a builder by raising some sort of exception, the circuit is left in
a usable state, and extra resources have not been added to the circuit."""
x, y = Parameter("x"), Parameter("y")
with self.subTest("for"):
test = QuantumCircuit(1, 1)
test.h(0)
with self.assertRaises(SentinelException):
with test.for_loop(range(2), x) as bound_x:
test.x(0)
test.rx(bound_x, 0)
test.ry(y, 0)
raise SentinelException
test.z(0)
expected = QuantumCircuit(1, 1)
expected.h(0)
expected.z(0)
self.assertEqual(test, expected)
# We don't want _either_ the loop variable or the loose variable to be in the circuit.
self.assertEqual(set(), set(test.parameters))
with self.subTest("while"):
bits = [Qubit(), Clbit()]
test = QuantumCircuit(bits)
test.h(0)
with self.assertRaises(SentinelException):
with test.while_loop((bits[1], 0)):
test.x(0)
test.rx(x, 0)
raise SentinelException
test.z(0)
expected = QuantumCircuit(bits)
expected.h(0)
expected.z(0)
self.assertEqual(test, expected)
self.assertEqual(set(), set(test.parameters))
with self.subTest("if"):
bits = [Qubit(), Clbit()]
test = QuantumCircuit(bits)
test.h(0)
with self.assertRaises(SentinelException):
with test.if_test((bits[1], 0)):
test.x(0)
test.rx(x, 0)
raise SentinelException
test.z(0)
expected = QuantumCircuit(bits)
expected.h(0)
expected.z(0)
self.assertEqual(test, expected)
self.assertEqual(set(), set(test.parameters))
with self.subTest("else"):
bits = [Qubit(), Clbit()]
test = QuantumCircuit(bits)
test.h(0)
with test.if_test((bits[1], 0)) as else_:
test.rx(x, 0)
with self.assertRaises(SentinelException):
with else_:
test.x(0)
test.rx(y, 0)
raise SentinelException
test.z(0)
# Note that we expect the "else" manager to restore the "if" block if something errors
# out during "else" block.
true_body = QuantumCircuit(bits)
true_body.rx(x, 0)
expected = QuantumCircuit(bits)
expected.h(0)
expected.if_test((bits[1], 0), true_body, [0], [0])
expected.z(0)
self.assertEqual(test, expected)
self.assertEqual({x}, set(test.parameters))
def test_can_reuse_else_manager_after_exception(self):
"""Test that the "else" context manager is usable after a first attempt to construct it
raises an exception. Normally you cannot re-enter an "else" block, but we want the user to
be able to recover from errors if they so try."""
bits = [Qubit(), Clbit()]
test = QuantumCircuit(bits)
test.h(0)
with test.if_test((bits[1], 0)) as else_:
test.x(0)
with self.assertRaises(SentinelException):
with else_:
test.y(0)
raise SentinelException
with else_:
test.h(0)
test.z(0)
true_body = QuantumCircuit(bits)
true_body.x(0)
false_body = QuantumCircuit(bits)
false_body.h(0)
expected = QuantumCircuit(bits)
expected.h(0)
expected.if_else((bits[1], 0), true_body, false_body, [0], [0])
expected.z(0)
self.assertEqual(test, expected)
@ddt.data((None, [0]), ([0], None), ([0], [0]))
def test_context_managers_reject_passing_qubits(self, resources):
"""Test that the context-manager forms of the control-flow circuit methods raise exceptions
if they are given explicit qubits or clbits."""
test = QuantumCircuit(1, 1)
qubits, clbits = resources
with self.subTest("for"):
with self.assertRaisesRegex(
CircuitError,
r"When using 'for_loop' as a context manager, you cannot pass qubits or clbits\.",
):
test.for_loop(range(2), None, body=None, qubits=qubits, clbits=clbits)
with self.subTest("while"):
with self.assertRaisesRegex(
CircuitError,
r"When using 'while_loop' as a context manager, you cannot pass qubits or clbits\.",
):
test.while_loop((test.clbits[0], 0), body=None, qubits=qubits, clbits=clbits)
with self.subTest("if"):
with self.assertRaisesRegex(
CircuitError,
r"When using 'if_test' as a context manager, you cannot pass qubits or clbits\.",
):
test.if_test((test.clbits[0], 0), true_body=None, qubits=qubits, clbits=clbits)
@ddt.data((None, [0]), ([0], None), (None, None))
def test_non_context_manager_calling_states_reject_missing_resources(self, resources):
"""Test that the non-context-manager forms of the control-flow circuit methods raise
exceptions if they are not given explicit qubits or clbits."""
test = QuantumCircuit(1, 1)
body = QuantumCircuit(1, 1)
qubits, clbits = resources
with self.subTest("for"):
with self.assertRaisesRegex(
CircuitError,
r"When using 'for_loop' with a body, you must pass qubits and clbits\.",
):
test.for_loop(range(2), None, body=body, qubits=qubits, clbits=clbits)
with self.subTest("while"):
with self.assertRaisesRegex(
CircuitError,
r"When using 'while_loop' with a body, you must pass qubits and clbits\.",
):
test.while_loop((test.clbits[0], 0), body=body, qubits=qubits, clbits=clbits)
with self.subTest("if"):
with self.assertRaisesRegex(
CircuitError,
r"When using 'if_test' with a body, you must pass qubits and clbits\.",
):
test.if_test((test.clbits[0], 0), true_body=body, qubits=qubits, clbits=clbits)
@ddt.data(None, [Clbit()], 0)
def test_builder_block_add_bits_reject_bad_bits(self, bit):
"""Test that :obj:`.ControlFlowBuilderBlock` raises if something is given that is an
incorrect type.
This isn't intended to be something users do at all; the builder block is an internal
construct only, but this keeps coverage checking happy."""
def dummy_requester(resource):
raise CircuitError
builder_block = ControlFlowBuilderBlock(
qubits=(), clbits=(), resource_requester=dummy_requester
)
with self.assertRaisesRegex(TypeError, r"Can only add qubits or classical bits.*"):
builder_block.add_bits([bit])
| 42.396011 | 100 | 0.56924 | 12,708 | 104,167 | 4.515187 | 0.050755 | 0.071106 | 0.018474 | 0.025375 | 0.792311 | 0.764844 | 0.740794 | 0.716185 | 0.689242 | 0.659858 | 0 | 0.034212 | 0.317289 | 104,167 | 2,456 | 101 | 42.413274 | 0.772625 | 0.120729 | 0 | 0.744865 | 0 | 0 | 0.022671 | 0 | 0 | 0 | 0 | 0 | 0.102703 | 1 | 0.022162 | false | 0.027568 | 0.004865 | 0 | 0.028649 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 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 | 5 |
5a4a81a090c1454678f9c7db50403976b52c0f9e | 462 | py | Python | metalacc/website/forms.py | stricoff92/metalaccounting | 6c9f650b3dd3c74c3ebbe847e0c05bb233e14153 | [
"MIT"
] | null | null | null | metalacc/website/forms.py | stricoff92/metalaccounting | 6c9f650b3dd3c74c3ebbe847e0c05bb233e14153 | [
"MIT"
] | 3 | 2021-03-30T14:01:37.000Z | 2021-06-10T19:46:42.000Z | metalacc/website/forms.py | stricoff92/metalaccounting | 6c9f650b3dd3c74c3ebbe847e0c05bb233e14153 | [
"MIT"
] | null | null | null |
from django import forms
class LoginForm(forms.Form):
email = forms.CharField()
password = forms.CharField(widget=forms.PasswordInput)
class RegisterNewUser(forms.Form):
email = forms.CharField(required=True)
password1 = forms.CharField(required=True)
password2 = forms.CharField(required=True)
class ContactUsForm(forms.Form):
email = forms.CharField(required=False)
message = forms.CharField(required=True, max_length=2048)
| 28.875 | 61 | 0.746753 | 53 | 462 | 6.490566 | 0.433962 | 0.284884 | 0.319767 | 0.302326 | 0.290698 | 0.209302 | 0 | 0 | 0 | 0 | 0 | 0.015228 | 0.147186 | 462 | 16 | 62 | 28.875 | 0.857868 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.272727 | 0.090909 | 0 | 1 | 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 | 1 | 0 | 0 | 1 | 0 | 0 | 5 |
ce8d177288b4b88692926e562682c21261fb5968 | 70 | py | Python | pyramid_scheme/__init__.py | rbu/pyramid_scheme | 47867f801f77d4c8d0bb0cf54ec9ba501a1823d0 | [
"MIT"
] | 1 | 2015-03-16T16:03:59.000Z | 2015-03-16T16:03:59.000Z | pyramid_scheme/__init__.py | rbu/pyramid_scheme | 47867f801f77d4c8d0bb0cf54ec9ba501a1823d0 | [
"MIT"
] | null | null | null | pyramid_scheme/__init__.py | rbu/pyramid_scheme | 47867f801f77d4c8d0bb0cf54ec9ba501a1823d0 | [
"MIT"
] | null | null | null | from future.standard_library import install_aliases
install_aliases()
| 23.333333 | 51 | 0.885714 | 9 | 70 | 6.555556 | 0.777778 | 0.474576 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.071429 | 70 | 2 | 52 | 35 | 0.907692 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
ceaee8db92c2a7b6b6b18e66a58f16601156d9bc | 1,301 | py | Python | examples/Blackjack/screens/start/buttons.py | flywinged/TGL | a567ae717e7f9390eb9a5ce3383e5b796389af05 | [
"MIT"
] | 1 | 2020-06-19T18:59:02.000Z | 2020-06-19T18:59:02.000Z | examples/Blackjack/screens/start/buttons.py | flywinged/TGL | a567ae717e7f9390eb9a5ce3383e5b796389af05 | [
"MIT"
] | 16 | 2020-06-17T22:26:18.000Z | 2020-07-28T21:39:10.000Z | examples/Blackjack/screens/start/buttons.py | flywinged/TGL | a567ae717e7f9390eb9a5ce3383e5b796389af05 | [
"MIT"
] | null | null | null | # Copyright Clayton Brown 2019. See LICENSE file.
from gent import Box
from gent import TextLine
from gent import Game
from gent import Selection_Fill
class PlayButton(TextLine):
'''
Simple button which displays "Play" on the main start screen. When pressed, does stuff.
'''
def __init__(self, game: Game):
TextLine.__init__(
self,
Box(20, 7, 12, 1),
"Start",
(255, 255, 255),
(0, 0, 0),
justify="C",
isSelectable=True,
game=game,
selectionHandler=Selection_Fill(defaultColor=(60, 15, 90))
)
self.game: Game = game
def onPress(self):
self.game.goToScreen("Game")
class QuitButton(TextLine):
'''
Simple button which displays "Play" on the main start screen. When pressed, does stuff.
'''
def __init__(self, game: Game):
TextLine.__init__(
self,
Box(20, 8, 12, 1),
"Quit",
(255, 255, 255),
(0, 0, 0),
justify="C",
isSelectable=True,
game=game,
selectionHandler=Selection_Fill(defaultColor=(60, 15, 90))
)
self.game: Game = Game
def onPress(self):
self.game.quit() | 23.654545 | 91 | 0.537279 | 145 | 1,301 | 4.689655 | 0.372414 | 0.094118 | 0.082353 | 0.073529 | 0.723529 | 0.723529 | 0.723529 | 0.723529 | 0.723529 | 0.723529 | 0 | 0.061905 | 0.354343 | 1,301 | 55 | 92 | 23.654545 | 0.747619 | 0.172175 | 0 | 0.555556 | 0 | 0 | 0.014327 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.111111 | 0 | 0.277778 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 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 | 5 |
0ce49ff1aec887cee6c3fb31c3042490b574f038 | 46 | py | Python | vkfeed/tools/__init__.py | JOKERMAX89/vkfeed | d20c915e641c9bf9c0aed1358e68b385de979ea1 | [
"BSD-2-Clause"
] | 78 | 2015-01-02T00:21:03.000Z | 2022-01-30T21:02:44.000Z | vkfeed/tools/__init__.py | JOKERMAX89/vkfeed | d20c915e641c9bf9c0aed1358e68b385de979ea1 | [
"BSD-2-Clause"
] | 3 | 2015-10-12T06:55:05.000Z | 2017-06-16T16:52:50.000Z | vkfeed/tools/__init__.py | JOKERMAX89/vkfeed | d20c915e641c9bf9c0aed1358e68b385de979ea1 | [
"BSD-2-Clause"
] | 28 | 2015-01-02T19:22:27.000Z | 2021-05-19T06:14:53.000Z | '''Contains various self-sufficient tools.'''
| 23 | 45 | 0.73913 | 5 | 46 | 6.8 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.086957 | 46 | 1 | 46 | 46 | 0.809524 | 0.847826 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 1 | 1 | 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 | 5 |
0cf61620fe05f08f1d702cc8f39ad44072d761bb | 102 | py | Python | wfsim/__init__.py | jorana/WFSim | efb4907b4a3fab2f57c4f056edecde4aeaa199d0 | [
"BSD-3-Clause"
] | null | null | null | wfsim/__init__.py | jorana/WFSim | efb4907b4a3fab2f57c4f056edecde4aeaa199d0 | [
"BSD-3-Clause"
] | null | null | null | wfsim/__init__.py | jorana/WFSim | efb4907b4a3fab2f57c4f056edecde4aeaa199d0 | [
"BSD-3-Clause"
] | null | null | null | __version__ = '0.0.4'
from .core import *
from .strax_interface import *
from .pax_interface import * | 20.4 | 30 | 0.745098 | 15 | 102 | 4.666667 | 0.6 | 0.285714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.034483 | 0.147059 | 102 | 5 | 31 | 20.4 | 0.770115 | 0 | 0 | 0 | 0 | 0 | 0.048544 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.75 | 0 | 0.75 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 5 |
0bab28aa408b9132d1a8c628d86d6eda22875029 | 288 | py | Python | rlp/sedes/__init__.py | pipermerriam/pyrlp | 8b1452098ed1ef1930a28488423b0091672a0553 | [
"MIT"
] | 1 | 2020-04-09T04:01:52.000Z | 2020-04-09T04:01:52.000Z | rlp/sedes/__init__.py | pipermerriam/pyrlp | 8b1452098ed1ef1930a28488423b0091672a0553 | [
"MIT"
] | null | null | null | rlp/sedes/__init__.py | pipermerriam/pyrlp | 8b1452098ed1ef1930a28488423b0091672a0553 | [
"MIT"
] | null | null | null | from . import raw # noqa: F401
from .binary import Binary, binary # noqa: F401
from .big_endian_int import BigEndianInt, big_endian_int # noqa: F401
from .lists import CountableList, List # noqa: F401
from .serializable import Serializable, make_immutable, make_mutable # noqa: F401
| 48 | 82 | 0.774306 | 40 | 288 | 5.425 | 0.425 | 0.184332 | 0.221198 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.061728 | 0.15625 | 288 | 5 | 83 | 57.6 | 0.831276 | 0.1875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
0bbe12980a8ab00442c6146117277a6c73c25995 | 81 | py | Python | turabnet/tensor.py | turab91/neuralNet_scratch | bcdda7afb64e568b733103b90028119f65372e1b | [
"MIT"
] | null | null | null | turabnet/tensor.py | turab91/neuralNet_scratch | bcdda7afb64e568b733103b90028119f65372e1b | [
"MIT"
] | null | null | null | turabnet/tensor.py | turab91/neuralNet_scratch | bcdda7afb64e568b733103b90028119f65372e1b | [
"MIT"
] | null | null | null | """
a tensor is an n-dimensional array
"""
from numpy import ndarray as Tensor
| 11.571429 | 35 | 0.716049 | 13 | 81 | 4.461538 | 0.923077 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.197531 | 81 | 6 | 36 | 13.5 | 0.892308 | 0.419753 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
e7e4d6ad62904bca7bb6097e8099fb3c810527c0 | 133 | py | Python | tests/IT/fixtures/test_function_tag.py | testandconquer/pytest-conquer | da600c7f5bcd06aa62c5cca9b75370bf1a6ebf05 | [
"MIT"
] | null | null | null | tests/IT/fixtures/test_function_tag.py | testandconquer/pytest-conquer | da600c7f5bcd06aa62c5cca9b75370bf1a6ebf05 | [
"MIT"
] | 5 | 2018-12-27T02:52:01.000Z | 2019-01-02T01:52:55.000Z | tests/IT/fixtures/test_function_tag.py | testandconquer/pytest-conquer | da600c7f5bcd06aa62c5cca9b75370bf1a6ebf05 | [
"MIT"
] | null | null | null | import pytest
@pytest.mark.conquer(group='test')
@pytest.mark.other_mark # will be ignored
def test_pass():
assert 2 + 2 == 4
| 16.625 | 42 | 0.691729 | 21 | 133 | 4.285714 | 0.714286 | 0.222222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.027273 | 0.172932 | 133 | 7 | 43 | 19 | 0.790909 | 0.112782 | 0 | 0 | 0 | 0 | 0.034483 | 0 | 0 | 0 | 0 | 0 | 0.2 | 1 | 0.2 | true | 0.2 | 0.2 | 0 | 0.4 | 0 | 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 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 5 |
f01187dbec2a42f1d01ab49aee3a4d741c1a2587 | 99 | py | Python | 7_kyu/Identical_Elements.py | UlrichBerntien/Codewars-Katas | bbd025e67aa352d313564d3862db19fffa39f552 | [
"MIT"
] | null | null | null | 7_kyu/Identical_Elements.py | UlrichBerntien/Codewars-Katas | bbd025e67aa352d313564d3862db19fffa39f552 | [
"MIT"
] | null | null | null | 7_kyu/Identical_Elements.py | UlrichBerntien/Codewars-Katas | bbd025e67aa352d313564d3862db19fffa39f552 | [
"MIT"
] | null | null | null | def duplicate_elements(m, n):
# simple version is fast enough
return any(x in m for x in n) | 33 | 35 | 0.686869 | 19 | 99 | 3.526316 | 0.789474 | 0.089552 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.242424 | 99 | 3 | 36 | 33 | 0.893333 | 0.292929 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.5 | false | 0 | 0 | 0.5 | 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 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 5 |
f0181fc84bd2a9e637fed02a05abc5510c3d5ccd | 17 | py | Python | webware/Testing/URL/test5join2/__init__.py | PeaceWorksTechnologySolutions/w4py3 | 7f9e7088034e3e3ac53158edfa4f377b5b2f45fe | [
"MIT"
] | 11 | 2020-10-18T07:33:56.000Z | 2021-09-27T21:03:38.000Z | webware/Testing/URL/test5join2/__init__.py | PeaceWorksTechnologySolutions/w4py3 | 7f9e7088034e3e3ac53158edfa4f377b5b2f45fe | [
"MIT"
] | 9 | 2020-01-03T18:58:25.000Z | 2020-01-09T18:36:23.000Z | webware/Testing/URL/test5join2/__init__.py | PeaceWorksTechnologySolutions/w4py3 | 7f9e7088034e3e3ac53158edfa4f377b5b2f45fe | [
"MIT"
] | 4 | 2020-06-30T09:41:56.000Z | 2021-02-20T13:48:08.000Z | # URL/test5join2
| 8.5 | 16 | 0.764706 | 2 | 17 | 6.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.133333 | 0.117647 | 17 | 1 | 17 | 17 | 0.733333 | 0.823529 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 1 | 1 | 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 | 5 |
f01afd1545e72face17ac505945d6943bf8c3de2 | 173 | py | Python | test/testings/__init__.py | HansBug/hbutils | 6872311c8a441c5955572e0093b10189a2b90708 | [
"Apache-2.0"
] | null | null | null | test/testings/__init__.py | HansBug/hbutils | 6872311c8a441c5955572e0093b10189a2b90708 | [
"Apache-2.0"
] | 25 | 2021-10-03T06:19:05.000Z | 2022-03-27T12:48:57.000Z | test/testings/__init__.py | HansBug/hbutils | 6872311c8a441c5955572e0093b10189a2b90708 | [
"Apache-2.0"
] | null | null | null | from .path import normpath
from .platform import linux_mark, macos_mark, windows_mark, pypy_mark, cpython_mark, py36_mark, py37_mark, py38_mark, \
py39_mark, py310_mark
| 43.25 | 119 | 0.803468 | 27 | 173 | 4.777778 | 0.592593 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.072848 | 0.127168 | 173 | 3 | 120 | 57.666667 | 0.781457 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.666667 | 0 | 0.666667 | 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 | 1 | 0 | 1 | 0 | 0 | 5 |
b2d65b2dfe5a0ebd7bb4d070924a771e2cbddc4e | 132 | py | Python | elasticache_hashring/client.py | justcompile/django-elasticache-hashring | be88c9212a3a845719276c4c40acbc687ec1a92e | [
"Apache-2.0"
] | null | null | null | elasticache_hashring/client.py | justcompile/django-elasticache-hashring | be88c9212a3a845719276c4c40acbc687ec1a92e | [
"Apache-2.0"
] | null | null | null | elasticache_hashring/client.py | justcompile/django-elasticache-hashring | be88c9212a3a845719276c4c40acbc687ec1a92e | [
"Apache-2.0"
] | null | null | null | # just a stub module to ease the subclassing of the MemcachedCache class
from hash_ring.memcache_ring import MemcacheRing as Client
| 44 | 72 | 0.840909 | 21 | 132 | 5.190476 | 0.904762 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.143939 | 132 | 2 | 73 | 66 | 0.964602 | 0.530303 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
65274e45529955535f68162e7b903f9cc600feef | 293 | py | Python | threads/models.py | making3/summonerqa | 7ab8472b2d24236ba1e6919fa0f00881f4a3e633 | [
"MIT"
] | null | null | null | threads/models.py | making3/summonerqa | 7ab8472b2d24236ba1e6919fa0f00881f4a3e633 | [
"MIT"
] | null | null | null | threads/models.py | making3/summonerqa | 7ab8472b2d24236ba1e6919fa0f00881f4a3e633 | [
"MIT"
] | null | null | null | from django.db import models
class Thread(models.Model):
reddit_id = models.CharField(max_length=20)
title = models.CharField(max_length=100)
score = models.IntegerField(default=0)
permalink = models.CharField(max_length=500)
def __str__(self):
return self.title
| 26.636364 | 48 | 0.723549 | 39 | 293 | 5.230769 | 0.666667 | 0.220588 | 0.264706 | 0.352941 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.037344 | 0.177474 | 293 | 10 | 49 | 29.3 | 0.809129 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.125 | 0.125 | 1 | 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 | 1 | 1 | 0 | 0 | 5 |
6541f2b599dc0c53b97b61aafa69dad54fe69650 | 208 | py | Python | Lab_7/Submission/4.2.8.py | Saif-M-Dhrubo/Crypto-Lab | 2807320d7ca389adee86f69f704b9f91f9cd8054 | [
"MIT"
] | 2 | 2019-04-28T16:34:15.000Z | 2019-04-28T17:54:06.000Z | Lab_7/mp4/4.2.8.py | saif-mahmud/Crypto-Lab | 2807320d7ca389adee86f69f704b9f91f9cd8054 | [
"MIT"
] | null | null | null | Lab_7/mp4/4.2.8.py | saif-mahmud/Crypto-Lab | 2807320d7ca389adee86f69f704b9f91f9cd8054 | [
"MIT"
] | 1 | 2020-01-08T06:48:08.000Z | 2020-01-08T06:48:08.000Z | from struct import pack
from shellcode import shellcode
print 'A' * 40 + pack("<I", 0x080f3750) + pack("<I", 0xbffe8b8c) + " " + shellcode + 'A' * 17 + pack("<I", 0xbffe8b8c) + pack("<I", 0x080f3748) + " A"
| 41.6 | 150 | 0.620192 | 27 | 208 | 4.777778 | 0.481481 | 0.155039 | 0.232558 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.152047 | 0.177885 | 208 | 4 | 151 | 52 | 0.602339 | 0 | 0 | 0 | 0 | 0 | 0.0625 | 0 | 0 | 0 | 0.192308 | 0 | 0 | 0 | null | null | 0 | 0.666667 | null | null | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
e8dc096c82b376caf38672b85c5e9caddd4d9a10 | 220 | py | Python | src/testapp/models.py | cruzaria/DMRP | 8dcaf507cc779852f2193b841ecf3273fe81cbca | [
"WTFPL"
] | null | null | null | src/testapp/models.py | cruzaria/DMRP | 8dcaf507cc779852f2193b841ecf3273fe81cbca | [
"WTFPL"
] | null | null | null | src/testapp/models.py | cruzaria/DMRP | 8dcaf507cc779852f2193b841ecf3273fe81cbca | [
"WTFPL"
] | null | null | null | from django.db import models
# Create your models here.
class Testapp(models.Model):
surname = models.CharField(max_length=64)
course = models.CharField(max_length=64)
name = models.CharField(max_length=64)
| 27.5 | 45 | 0.75 | 31 | 220 | 5.225806 | 0.580645 | 0.277778 | 0.333333 | 0.444444 | 0.481481 | 0 | 0 | 0 | 0 | 0 | 0 | 0.032086 | 0.15 | 220 | 7 | 46 | 31.428571 | 0.834225 | 0.109091 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 1 | 0 | 0 | 0 | 0 | null | 1 | 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 | 1 | 0 | 0 | 5 |
68776ad60a0b3ed7c629c3a9f3c29400b6ccc6a9 | 35,333 | py | Python | mfem/_par/array.py | GabrielJie/PyMFEM | fa654447ac6819c5aa0341397b91a299f4ce5492 | [
"BSD-3-Clause"
] | 1 | 2022-01-19T07:16:59.000Z | 2022-01-19T07:16:59.000Z | mfem/_par/array.py | GabrielJie/PyMFEM | fa654447ac6819c5aa0341397b91a299f4ce5492 | [
"BSD-3-Clause"
] | null | null | null | mfem/_par/array.py | GabrielJie/PyMFEM | fa654447ac6819c5aa0341397b91a299f4ce5492 | [
"BSD-3-Clause"
] | null | null | null | # This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info as _swig_python_version_info
if _swig_python_version_info < (2, 7, 0):
raise RuntimeError("Python 2.7 or later required")
# Import the low-level C/C++ module
if __package__ or "." in __name__:
from . import _array
else:
import _array
try:
import builtins as __builtin__
except ImportError:
import __builtin__
_swig_new_instance_method = _array.SWIG_PyInstanceMethod_New
_swig_new_static_method = _array.SWIG_PyStaticMethod_New
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except __builtin__.Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
def _swig_setattr_nondynamic_instance_variable(set):
def set_instance_attr(self, name, value):
if name == "thisown":
self.this.own(value)
elif name == "this":
set(self, name, value)
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
set(self, name, value)
else:
raise AttributeError("You cannot add instance attributes to %s" % self)
return set_instance_attr
def _swig_setattr_nondynamic_class_variable(set):
def set_class_attr(cls, name, value):
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
set(cls, name, value)
else:
raise AttributeError("You cannot add class attributes to %s" % cls)
return set_class_attr
def _swig_add_metaclass(metaclass):
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
def wrapper(cls):
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
return wrapper
class _SwigNonDynamicMeta(type):
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
import mfem._par.mem_manager
def doubleSwap(*args):
r"""
doubleSwap(doubleArray arg1, doubleArray arg2)
doubleSwap(mfem::Array2D< double > & arg1, mfem::Array2D< double > & arg2)
doubleSwap(double & a, double & b)
"""
return _array.doubleSwap(*args)
doubleSwap = _array.doubleSwap
def intSwap(*args):
r"""
intSwap(intArray arg1, intArray arg2)
intSwap(mfem::Array2D< int > & arg1, mfem::Array2D< int > & arg2)
intSwap(int & a, int & b)
"""
return _array.intSwap(*args)
intSwap = _array.intSwap
class intArray(object):
r"""Proxy of C++ mfem::Array< int > class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
__swig_destroy__ = _array.delete_intArray
def GetData(self, *args):
r"""
GetData(intArray self) -> int
GetData(intArray self) -> int const *
"""
return _array.intArray_GetData(self, *args)
GetData = _swig_new_instance_method(_array.intArray_GetData)
def GetMemory(self, *args):
r"""
GetMemory(intArray self) -> mfem::Memory< int >
GetMemory(intArray self) -> mfem::Memory< int > const &
"""
return _array.intArray_GetMemory(self, *args)
GetMemory = _swig_new_instance_method(_array.intArray_GetMemory)
def UseDevice(self):
r"""UseDevice(intArray self) -> bool"""
return _array.intArray_UseDevice(self)
UseDevice = _swig_new_instance_method(_array.intArray_UseDevice)
def OwnsData(self):
r"""OwnsData(intArray self) -> bool"""
return _array.intArray_OwnsData(self)
OwnsData = _swig_new_instance_method(_array.intArray_OwnsData)
def StealData(self, p):
r"""StealData(intArray self, int ** p)"""
return _array.intArray_StealData(self, p)
StealData = _swig_new_instance_method(_array.intArray_StealData)
def LoseData(self):
r"""LoseData(intArray self)"""
return _array.intArray_LoseData(self)
LoseData = _swig_new_instance_method(_array.intArray_LoseData)
def MakeDataOwner(self):
r"""MakeDataOwner(intArray self)"""
return _array.intArray_MakeDataOwner(self)
MakeDataOwner = _swig_new_instance_method(_array.intArray_MakeDataOwner)
def Size(self):
r"""Size(intArray self) -> int"""
return _array.intArray_Size(self)
Size = _swig_new_instance_method(_array.intArray_Size)
def SetSize(self, *args):
r"""
SetSize(intArray self, int nsize)
SetSize(intArray self, int nsize, int const & initval)
SetSize(intArray self, int nsize, mfem::MemoryType mt)
"""
return _array.intArray_SetSize(self, *args)
SetSize = _swig_new_instance_method(_array.intArray_SetSize)
def Capacity(self):
r"""Capacity(intArray self) -> int"""
return _array.intArray_Capacity(self)
Capacity = _swig_new_instance_method(_array.intArray_Capacity)
def Reserve(self, capacity):
r"""Reserve(intArray self, int capacity)"""
return _array.intArray_Reserve(self, capacity)
Reserve = _swig_new_instance_method(_array.intArray_Reserve)
def Append(self, *args):
r"""
Append(intArray self, int const & el) -> int
Append(intArray self, int const * els, int nels) -> int
Append(intArray self, intArray els) -> int
"""
return _array.intArray_Append(self, *args)
Append = _swig_new_instance_method(_array.intArray_Append)
def Prepend(self, el):
r"""Prepend(intArray self, int const & el) -> int"""
return _array.intArray_Prepend(self, el)
Prepend = _swig_new_instance_method(_array.intArray_Prepend)
def Last(self, *args):
r"""
Last(intArray self) -> int
Last(intArray self) -> int const &
"""
return _array.intArray_Last(self, *args)
Last = _swig_new_instance_method(_array.intArray_Last)
def Union(self, el):
r"""Union(intArray self, int const & el) -> int"""
return _array.intArray_Union(self, el)
Union = _swig_new_instance_method(_array.intArray_Union)
def Find(self, el):
r"""Find(intArray self, int const & el) -> int"""
return _array.intArray_Find(self, el)
Find = _swig_new_instance_method(_array.intArray_Find)
def FindSorted(self, el):
r"""FindSorted(intArray self, int const & el) -> int"""
return _array.intArray_FindSorted(self, el)
FindSorted = _swig_new_instance_method(_array.intArray_FindSorted)
def DeleteLast(self):
r"""DeleteLast(intArray self)"""
return _array.intArray_DeleteLast(self)
DeleteLast = _swig_new_instance_method(_array.intArray_DeleteLast)
def DeleteFirst(self, el):
r"""DeleteFirst(intArray self, int const & el)"""
return _array.intArray_DeleteFirst(self, el)
DeleteFirst = _swig_new_instance_method(_array.intArray_DeleteFirst)
def DeleteAll(self):
r"""DeleteAll(intArray self)"""
return _array.intArray_DeleteAll(self)
DeleteAll = _swig_new_instance_method(_array.intArray_DeleteAll)
def Copy(self, copy):
r"""Copy(intArray self, intArray copy)"""
return _array.intArray_Copy(self, copy)
Copy = _swig_new_instance_method(_array.intArray_Copy)
def MakeRef(self, *args):
r"""
MakeRef(intArray self, int * arg2, int arg3)
MakeRef(intArray self, intArray master)
"""
return _array.intArray_MakeRef(self, *args)
MakeRef = _swig_new_instance_method(_array.intArray_MakeRef)
def GetSubArray(self, offset, sa_size, sa):
r"""GetSubArray(intArray self, int offset, int sa_size, intArray sa)"""
return _array.intArray_GetSubArray(self, offset, sa_size, sa)
GetSubArray = _swig_new_instance_method(_array.intArray_GetSubArray)
def Load(self, *args):
r"""
Load(intArray self, std::istream & _in, int fmt=0)
Load(intArray self, int new_size, std::istream & _in)
"""
return _array.intArray_Load(self, *args)
Load = _swig_new_instance_method(_array.intArray_Load)
def Max(self):
r"""Max(intArray self) -> int"""
return _array.intArray_Max(self)
Max = _swig_new_instance_method(_array.intArray_Max)
def Min(self):
r"""Min(intArray self) -> int"""
return _array.intArray_Min(self)
Min = _swig_new_instance_method(_array.intArray_Min)
def Sort(self):
r"""Sort(intArray self)"""
return _array.intArray_Sort(self)
Sort = _swig_new_instance_method(_array.intArray_Sort)
def Unique(self):
r"""Unique(intArray self)"""
return _array.intArray_Unique(self)
Unique = _swig_new_instance_method(_array.intArray_Unique)
def IsSorted(self):
r"""IsSorted(intArray self) -> int"""
return _array.intArray_IsSorted(self)
IsSorted = _swig_new_instance_method(_array.intArray_IsSorted)
def PartialSum(self):
r"""PartialSum(intArray self)"""
return _array.intArray_PartialSum(self)
PartialSum = _swig_new_instance_method(_array.intArray_PartialSum)
def Sum(self):
r"""Sum(intArray self) -> int"""
return _array.intArray_Sum(self)
Sum = _swig_new_instance_method(_array.intArray_Sum)
def begin(self, *args):
r"""
begin(intArray self) -> int
begin(intArray self) -> int const *
"""
return _array.intArray_begin(self, *args)
begin = _swig_new_instance_method(_array.intArray_begin)
def end(self, *args):
r"""
end(intArray self) -> int
end(intArray self) -> int const *
"""
return _array.intArray_end(self, *args)
end = _swig_new_instance_method(_array.intArray_end)
def MemoryUsage(self):
r"""MemoryUsage(intArray self) -> long"""
return _array.intArray_MemoryUsage(self)
MemoryUsage = _swig_new_instance_method(_array.intArray_MemoryUsage)
def Read(self, on_dev=True):
r"""Read(intArray self, bool on_dev=True) -> int const *"""
return _array.intArray_Read(self, on_dev)
Read = _swig_new_instance_method(_array.intArray_Read)
def HostRead(self):
r"""HostRead(intArray self) -> int const *"""
return _array.intArray_HostRead(self)
HostRead = _swig_new_instance_method(_array.intArray_HostRead)
def Write(self, on_dev=True):
r"""Write(intArray self, bool on_dev=True) -> int *"""
return _array.intArray_Write(self, on_dev)
Write = _swig_new_instance_method(_array.intArray_Write)
def HostWrite(self):
r"""HostWrite(intArray self) -> int *"""
return _array.intArray_HostWrite(self)
HostWrite = _swig_new_instance_method(_array.intArray_HostWrite)
def ReadWrite(self, on_dev=True):
r"""ReadWrite(intArray self, bool on_dev=True) -> int *"""
return _array.intArray_ReadWrite(self, on_dev)
ReadWrite = _swig_new_instance_method(_array.intArray_ReadWrite)
def HostReadWrite(self):
r"""HostReadWrite(intArray self) -> int *"""
return _array.intArray_HostReadWrite(self)
HostReadWrite = _swig_new_instance_method(_array.intArray_HostReadWrite)
def __init__(self, *args):
r"""
__init__(intArray self) -> intArray
__init__(intArray self, mfem::MemoryType mt) -> intArray
__init__(intArray self, int asize) -> intArray
__init__(intArray self, int asize, mfem::MemoryType mt) -> intArray
__init__(intArray self, int * data_) -> intArray
__init__(intArray self, intArray src) -> intArray
__init__(intArray self, void * List_or_Tuple) -> intArray
"""
_array.intArray_swiginit(self, _array.new_intArray(*args))
def __setitem__(self, i, v):
r"""__setitem__(intArray self, int i, int const v)"""
i = int(i)
return _array.intArray___setitem__(self, i, v)
def Assign(self, *args):
r"""
Assign(intArray self, int const * arg2)
Assign(intArray self, int const & a)
"""
return _array.intArray_Assign(self, *args)
Assign = _swig_new_instance_method(_array.intArray_Assign)
def ToList(self):
return [self[i] for i in range(self.Size())]
def __iter__(self):
class iter_array:
def __init__(self, obj):
self.obj = obj
self.idx = 0
self.size = obj.Size()
def __iter__(self):
self.idx = 0
def __next__(self):
if self.idx < self.size:
res = self.obj[self.idx]
self.idx += 1
return res
else:
raise StopIteration
return iter_array(self)
def Print(self, *args):
r"""
Print(intArray self, std::ostream & out=mfem::out, int width=4)
Print(intArray self, char const * file, int precision=16)
"""
return _array.intArray_Print(self, *args)
Print = _swig_new_instance_method(_array.intArray_Print)
def PrintGZ(self, file, precision=16):
r"""PrintGZ(intArray self, char const * file, int precision=16)"""
return _array.intArray_PrintGZ(self, file, precision)
PrintGZ = _swig_new_instance_method(_array.intArray_PrintGZ)
def SaveGZ(self, file, precision=16):
r"""SaveGZ(intArray self, char const * file, int precision=16)"""
return _array.intArray_SaveGZ(self, file, precision)
SaveGZ = _swig_new_instance_method(_array.intArray_SaveGZ)
def Save(self, *args):
r"""
Save(intArray self, std::ostream & out, int fmt=0)
Save(intArray self, char const * file, int precision=16)
Save(intArray self)
"""
return _array.intArray_Save(self, *args)
Save = _swig_new_instance_method(_array.intArray_Save)
def __getitem__(self, param):
r"""__getitem__(intArray self, PyObject * param) -> PyObject *"""
return _array.intArray___getitem__(self, param)
__getitem__ = _swig_new_instance_method(_array.intArray___getitem__)
# Register intArray in _array:
_array.intArray_swigregister(intArray)
class doubleArray(object):
r"""Proxy of C++ mfem::Array< double > class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
__swig_destroy__ = _array.delete_doubleArray
def GetData(self, *args):
r"""
GetData(doubleArray self) -> double
GetData(doubleArray self) -> double const *
"""
return _array.doubleArray_GetData(self, *args)
GetData = _swig_new_instance_method(_array.doubleArray_GetData)
def GetMemory(self, *args):
r"""
GetMemory(doubleArray self) -> mfem::Memory< double >
GetMemory(doubleArray self) -> mfem::Memory< double > const &
"""
return _array.doubleArray_GetMemory(self, *args)
GetMemory = _swig_new_instance_method(_array.doubleArray_GetMemory)
def UseDevice(self):
r"""UseDevice(doubleArray self) -> bool"""
return _array.doubleArray_UseDevice(self)
UseDevice = _swig_new_instance_method(_array.doubleArray_UseDevice)
def OwnsData(self):
r"""OwnsData(doubleArray self) -> bool"""
return _array.doubleArray_OwnsData(self)
OwnsData = _swig_new_instance_method(_array.doubleArray_OwnsData)
def StealData(self, p):
r"""StealData(doubleArray self, double ** p)"""
return _array.doubleArray_StealData(self, p)
StealData = _swig_new_instance_method(_array.doubleArray_StealData)
def LoseData(self):
r"""LoseData(doubleArray self)"""
return _array.doubleArray_LoseData(self)
LoseData = _swig_new_instance_method(_array.doubleArray_LoseData)
def MakeDataOwner(self):
r"""MakeDataOwner(doubleArray self)"""
return _array.doubleArray_MakeDataOwner(self)
MakeDataOwner = _swig_new_instance_method(_array.doubleArray_MakeDataOwner)
def Size(self):
r"""Size(doubleArray self) -> int"""
return _array.doubleArray_Size(self)
Size = _swig_new_instance_method(_array.doubleArray_Size)
def SetSize(self, *args):
r"""
SetSize(doubleArray self, int nsize)
SetSize(doubleArray self, int nsize, double const & initval)
SetSize(doubleArray self, int nsize, mfem::MemoryType mt)
"""
return _array.doubleArray_SetSize(self, *args)
SetSize = _swig_new_instance_method(_array.doubleArray_SetSize)
def Capacity(self):
r"""Capacity(doubleArray self) -> int"""
return _array.doubleArray_Capacity(self)
Capacity = _swig_new_instance_method(_array.doubleArray_Capacity)
def Reserve(self, capacity):
r"""Reserve(doubleArray self, int capacity)"""
return _array.doubleArray_Reserve(self, capacity)
Reserve = _swig_new_instance_method(_array.doubleArray_Reserve)
def Append(self, *args):
r"""
Append(doubleArray self, double const & el) -> int
Append(doubleArray self, double const * els, int nels) -> int
Append(doubleArray self, doubleArray els) -> int
"""
return _array.doubleArray_Append(self, *args)
Append = _swig_new_instance_method(_array.doubleArray_Append)
def Prepend(self, el):
r"""Prepend(doubleArray self, double const & el) -> int"""
return _array.doubleArray_Prepend(self, el)
Prepend = _swig_new_instance_method(_array.doubleArray_Prepend)
def Last(self, *args):
r"""
Last(doubleArray self) -> double
Last(doubleArray self) -> double const &
"""
return _array.doubleArray_Last(self, *args)
Last = _swig_new_instance_method(_array.doubleArray_Last)
def Union(self, el):
r"""Union(doubleArray self, double const & el) -> int"""
return _array.doubleArray_Union(self, el)
Union = _swig_new_instance_method(_array.doubleArray_Union)
def Find(self, el):
r"""Find(doubleArray self, double const & el) -> int"""
return _array.doubleArray_Find(self, el)
Find = _swig_new_instance_method(_array.doubleArray_Find)
def FindSorted(self, el):
r"""FindSorted(doubleArray self, double const & el) -> int"""
return _array.doubleArray_FindSorted(self, el)
FindSorted = _swig_new_instance_method(_array.doubleArray_FindSorted)
def DeleteLast(self):
r"""DeleteLast(doubleArray self)"""
return _array.doubleArray_DeleteLast(self)
DeleteLast = _swig_new_instance_method(_array.doubleArray_DeleteLast)
def DeleteFirst(self, el):
r"""DeleteFirst(doubleArray self, double const & el)"""
return _array.doubleArray_DeleteFirst(self, el)
DeleteFirst = _swig_new_instance_method(_array.doubleArray_DeleteFirst)
def DeleteAll(self):
r"""DeleteAll(doubleArray self)"""
return _array.doubleArray_DeleteAll(self)
DeleteAll = _swig_new_instance_method(_array.doubleArray_DeleteAll)
def Copy(self, copy):
r"""Copy(doubleArray self, doubleArray copy)"""
return _array.doubleArray_Copy(self, copy)
Copy = _swig_new_instance_method(_array.doubleArray_Copy)
def MakeRef(self, *args):
r"""
MakeRef(doubleArray self, double * arg2, int arg3)
MakeRef(doubleArray self, doubleArray master)
"""
return _array.doubleArray_MakeRef(self, *args)
MakeRef = _swig_new_instance_method(_array.doubleArray_MakeRef)
def GetSubArray(self, offset, sa_size, sa):
r"""GetSubArray(doubleArray self, int offset, int sa_size, doubleArray sa)"""
return _array.doubleArray_GetSubArray(self, offset, sa_size, sa)
GetSubArray = _swig_new_instance_method(_array.doubleArray_GetSubArray)
def Load(self, *args):
r"""
Load(doubleArray self, std::istream & _in, int fmt=0)
Load(doubleArray self, int new_size, std::istream & _in)
"""
return _array.doubleArray_Load(self, *args)
Load = _swig_new_instance_method(_array.doubleArray_Load)
def Max(self):
r"""Max(doubleArray self) -> double"""
return _array.doubleArray_Max(self)
Max = _swig_new_instance_method(_array.doubleArray_Max)
def Min(self):
r"""Min(doubleArray self) -> double"""
return _array.doubleArray_Min(self)
Min = _swig_new_instance_method(_array.doubleArray_Min)
def Sort(self):
r"""Sort(doubleArray self)"""
return _array.doubleArray_Sort(self)
Sort = _swig_new_instance_method(_array.doubleArray_Sort)
def Unique(self):
r"""Unique(doubleArray self)"""
return _array.doubleArray_Unique(self)
Unique = _swig_new_instance_method(_array.doubleArray_Unique)
def IsSorted(self):
r"""IsSorted(doubleArray self) -> int"""
return _array.doubleArray_IsSorted(self)
IsSorted = _swig_new_instance_method(_array.doubleArray_IsSorted)
def PartialSum(self):
r"""PartialSum(doubleArray self)"""
return _array.doubleArray_PartialSum(self)
PartialSum = _swig_new_instance_method(_array.doubleArray_PartialSum)
def Sum(self):
r"""Sum(doubleArray self) -> double"""
return _array.doubleArray_Sum(self)
Sum = _swig_new_instance_method(_array.doubleArray_Sum)
def begin(self, *args):
r"""
begin(doubleArray self) -> double
begin(doubleArray self) -> double const *
"""
return _array.doubleArray_begin(self, *args)
begin = _swig_new_instance_method(_array.doubleArray_begin)
def end(self, *args):
r"""
end(doubleArray self) -> double
end(doubleArray self) -> double const *
"""
return _array.doubleArray_end(self, *args)
end = _swig_new_instance_method(_array.doubleArray_end)
def MemoryUsage(self):
r"""MemoryUsage(doubleArray self) -> long"""
return _array.doubleArray_MemoryUsage(self)
MemoryUsage = _swig_new_instance_method(_array.doubleArray_MemoryUsage)
def Read(self, on_dev=True):
r"""Read(doubleArray self, bool on_dev=True) -> double const *"""
return _array.doubleArray_Read(self, on_dev)
Read = _swig_new_instance_method(_array.doubleArray_Read)
def HostRead(self):
r"""HostRead(doubleArray self) -> double const *"""
return _array.doubleArray_HostRead(self)
HostRead = _swig_new_instance_method(_array.doubleArray_HostRead)
def Write(self, on_dev=True):
r"""Write(doubleArray self, bool on_dev=True) -> double *"""
return _array.doubleArray_Write(self, on_dev)
Write = _swig_new_instance_method(_array.doubleArray_Write)
def HostWrite(self):
r"""HostWrite(doubleArray self) -> double *"""
return _array.doubleArray_HostWrite(self)
HostWrite = _swig_new_instance_method(_array.doubleArray_HostWrite)
def ReadWrite(self, on_dev=True):
r"""ReadWrite(doubleArray self, bool on_dev=True) -> double *"""
return _array.doubleArray_ReadWrite(self, on_dev)
ReadWrite = _swig_new_instance_method(_array.doubleArray_ReadWrite)
def HostReadWrite(self):
r"""HostReadWrite(doubleArray self) -> double *"""
return _array.doubleArray_HostReadWrite(self)
HostReadWrite = _swig_new_instance_method(_array.doubleArray_HostReadWrite)
def __init__(self, *args):
r"""
__init__(doubleArray self) -> doubleArray
__init__(doubleArray self, mfem::MemoryType mt) -> doubleArray
__init__(doubleArray self, int asize) -> doubleArray
__init__(doubleArray self, int asize, mfem::MemoryType mt) -> doubleArray
__init__(doubleArray self, double * data_) -> doubleArray
__init__(doubleArray self, doubleArray src) -> doubleArray
__init__(doubleArray self, void * List_or_Tuple) -> doubleArray
"""
_array.doubleArray_swiginit(self, _array.new_doubleArray(*args))
def __setitem__(self, i, v):
r"""__setitem__(doubleArray self, int i, double const v)"""
i = int(i)
return _array.doubleArray___setitem__(self, i, v)
def Assign(self, *args):
r"""
Assign(doubleArray self, double const * arg2)
Assign(doubleArray self, double const & a)
"""
return _array.doubleArray_Assign(self, *args)
Assign = _swig_new_instance_method(_array.doubleArray_Assign)
def ToList(self):
return [self[i] for i in range(self.Size())]
def __iter__(self):
class iter_array:
def __init__(self, obj):
self.obj = obj
self.idx = 0
self.size = obj.Size()
def __iter__(self):
self.idx = 0
def __next__(self):
if self.idx < self.size:
res = self.obj[self.idx]
self.idx += 1
return res
else:
raise StopIteration
return iter_array(self)
def Print(self, *args):
r"""
Print(doubleArray self, std::ostream & out=mfem::out, int width=4)
Print(doubleArray self, char const * file, int precision=16)
"""
return _array.doubleArray_Print(self, *args)
Print = _swig_new_instance_method(_array.doubleArray_Print)
def PrintGZ(self, file, precision=16):
r"""PrintGZ(doubleArray self, char const * file, int precision=16)"""
return _array.doubleArray_PrintGZ(self, file, precision)
PrintGZ = _swig_new_instance_method(_array.doubleArray_PrintGZ)
def SaveGZ(self, file, precision=16):
r"""SaveGZ(doubleArray self, char const * file, int precision=16)"""
return _array.doubleArray_SaveGZ(self, file, precision)
SaveGZ = _swig_new_instance_method(_array.doubleArray_SaveGZ)
def Save(self, *args):
r"""
Save(doubleArray self, std::ostream & out, int fmt=0)
Save(doubleArray self, char const * file, int precision=16)
Save(doubleArray self)
"""
return _array.doubleArray_Save(self, *args)
Save = _swig_new_instance_method(_array.doubleArray_Save)
def __getitem__(self, param):
r"""__getitem__(doubleArray self, PyObject * param) -> PyObject *"""
return _array.doubleArray___getitem__(self, param)
__getitem__ = _swig_new_instance_method(_array.doubleArray___getitem__)
# Register doubleArray in _array:
_array.doubleArray_swigregister(doubleArray)
class boolArray(object):
r"""Proxy of C++ mfem::Array< bool > class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
__swig_destroy__ = _array.delete_boolArray
def GetData(self, *args):
r"""
GetData(boolArray self) -> bool
GetData(boolArray self) -> bool const *
"""
return _array.boolArray_GetData(self, *args)
GetData = _swig_new_instance_method(_array.boolArray_GetData)
def GetMemory(self, *args):
r"""
GetMemory(boolArray self) -> mfem::Memory< bool >
GetMemory(boolArray self) -> mfem::Memory< bool > const &
"""
return _array.boolArray_GetMemory(self, *args)
GetMemory = _swig_new_instance_method(_array.boolArray_GetMemory)
def UseDevice(self):
r"""UseDevice(boolArray self) -> bool"""
return _array.boolArray_UseDevice(self)
UseDevice = _swig_new_instance_method(_array.boolArray_UseDevice)
def OwnsData(self):
r"""OwnsData(boolArray self) -> bool"""
return _array.boolArray_OwnsData(self)
OwnsData = _swig_new_instance_method(_array.boolArray_OwnsData)
def StealData(self, p):
r"""StealData(boolArray self, bool ** p)"""
return _array.boolArray_StealData(self, p)
StealData = _swig_new_instance_method(_array.boolArray_StealData)
def LoseData(self):
r"""LoseData(boolArray self)"""
return _array.boolArray_LoseData(self)
LoseData = _swig_new_instance_method(_array.boolArray_LoseData)
def MakeDataOwner(self):
r"""MakeDataOwner(boolArray self)"""
return _array.boolArray_MakeDataOwner(self)
MakeDataOwner = _swig_new_instance_method(_array.boolArray_MakeDataOwner)
def Size(self):
r"""Size(boolArray self) -> int"""
return _array.boolArray_Size(self)
Size = _swig_new_instance_method(_array.boolArray_Size)
def SetSize(self, *args):
r"""
SetSize(boolArray self, int nsize)
SetSize(boolArray self, int nsize, bool const & initval)
SetSize(boolArray self, int nsize, mfem::MemoryType mt)
"""
return _array.boolArray_SetSize(self, *args)
SetSize = _swig_new_instance_method(_array.boolArray_SetSize)
def Capacity(self):
r"""Capacity(boolArray self) -> int"""
return _array.boolArray_Capacity(self)
Capacity = _swig_new_instance_method(_array.boolArray_Capacity)
def Reserve(self, capacity):
r"""Reserve(boolArray self, int capacity)"""
return _array.boolArray_Reserve(self, capacity)
Reserve = _swig_new_instance_method(_array.boolArray_Reserve)
def Append(self, *args):
r"""
Append(boolArray self, bool const & el) -> int
Append(boolArray self, bool const * els, int nels) -> int
Append(boolArray self, boolArray els) -> int
"""
return _array.boolArray_Append(self, *args)
Append = _swig_new_instance_method(_array.boolArray_Append)
def Prepend(self, el):
r"""Prepend(boolArray self, bool const & el) -> int"""
return _array.boolArray_Prepend(self, el)
Prepend = _swig_new_instance_method(_array.boolArray_Prepend)
def Last(self, *args):
r"""
Last(boolArray self) -> bool
Last(boolArray self) -> bool const &
"""
return _array.boolArray_Last(self, *args)
Last = _swig_new_instance_method(_array.boolArray_Last)
def DeleteLast(self):
r"""DeleteLast(boolArray self)"""
return _array.boolArray_DeleteLast(self)
DeleteLast = _swig_new_instance_method(_array.boolArray_DeleteLast)
def DeleteAll(self):
r"""DeleteAll(boolArray self)"""
return _array.boolArray_DeleteAll(self)
DeleteAll = _swig_new_instance_method(_array.boolArray_DeleteAll)
def Copy(self, copy):
r"""Copy(boolArray self, boolArray copy)"""
return _array.boolArray_Copy(self, copy)
Copy = _swig_new_instance_method(_array.boolArray_Copy)
def MakeRef(self, *args):
r"""
MakeRef(boolArray self, bool * arg2, int arg3)
MakeRef(boolArray self, boolArray master)
"""
return _array.boolArray_MakeRef(self, *args)
MakeRef = _swig_new_instance_method(_array.boolArray_MakeRef)
def GetSubArray(self, offset, sa_size, sa):
r"""GetSubArray(boolArray self, int offset, int sa_size, boolArray sa)"""
return _array.boolArray_GetSubArray(self, offset, sa_size, sa)
GetSubArray = _swig_new_instance_method(_array.boolArray_GetSubArray)
def begin(self, *args):
r"""
begin(boolArray self) -> bool
begin(boolArray self) -> bool const *
"""
return _array.boolArray_begin(self, *args)
begin = _swig_new_instance_method(_array.boolArray_begin)
def end(self, *args):
r"""
end(boolArray self) -> bool
end(boolArray self) -> bool const *
"""
return _array.boolArray_end(self, *args)
end = _swig_new_instance_method(_array.boolArray_end)
def MemoryUsage(self):
r"""MemoryUsage(boolArray self) -> long"""
return _array.boolArray_MemoryUsage(self)
MemoryUsage = _swig_new_instance_method(_array.boolArray_MemoryUsage)
def Read(self, on_dev=True):
r"""Read(boolArray self, bool on_dev=True) -> bool const *"""
return _array.boolArray_Read(self, on_dev)
Read = _swig_new_instance_method(_array.boolArray_Read)
def HostRead(self):
r"""HostRead(boolArray self) -> bool const *"""
return _array.boolArray_HostRead(self)
HostRead = _swig_new_instance_method(_array.boolArray_HostRead)
def Write(self, on_dev=True):
r"""Write(boolArray self, bool on_dev=True) -> bool *"""
return _array.boolArray_Write(self, on_dev)
Write = _swig_new_instance_method(_array.boolArray_Write)
def HostWrite(self):
r"""HostWrite(boolArray self) -> bool *"""
return _array.boolArray_HostWrite(self)
HostWrite = _swig_new_instance_method(_array.boolArray_HostWrite)
def ReadWrite(self, on_dev=True):
r"""ReadWrite(boolArray self, bool on_dev=True) -> bool *"""
return _array.boolArray_ReadWrite(self, on_dev)
ReadWrite = _swig_new_instance_method(_array.boolArray_ReadWrite)
def HostReadWrite(self):
r"""HostReadWrite(boolArray self) -> bool *"""
return _array.boolArray_HostReadWrite(self)
HostReadWrite = _swig_new_instance_method(_array.boolArray_HostReadWrite)
def __init__(self, *args):
r"""
__init__(boolArray self) -> boolArray
__init__(boolArray self, mfem::MemoryType mt) -> boolArray
__init__(boolArray self, int asize) -> boolArray
__init__(boolArray self, int asize, mfem::MemoryType mt) -> boolArray
__init__(boolArray self, bool * data_) -> boolArray
__init__(boolArray self, boolArray src) -> boolArray
__init__(boolArray self, void * List_or_Tuple) -> boolArray
"""
_array.boolArray_swiginit(self, _array.new_boolArray(*args))
def __setitem__(self, i, v):
r"""__setitem__(boolArray self, int i, bool const v)"""
i = int(i)
return _array.boolArray___setitem__(self, i, v)
def Assign(self, *args):
r"""
Assign(boolArray self, bool const * arg2)
Assign(boolArray self, bool const & a)
"""
return _array.boolArray_Assign(self, *args)
Assign = _swig_new_instance_method(_array.boolArray_Assign)
def ToList(self):
return [self[i] for i in range(self.Size())]
def __iter__(self):
class iter_array:
def __init__(self, obj):
self.obj = obj
self.idx = 0
self.size = obj.Size()
def __iter__(self):
self.idx = 0
def __next__(self):
if self.idx < self.size:
res = self.obj[self.idx]
self.idx += 1
return res
else:
raise StopIteration
return iter_array(self)
def __getitem__(self, param):
r"""__getitem__(boolArray self, PyObject * param) -> PyObject *"""
return _array.boolArray___getitem__(self, param)
__getitem__ = _swig_new_instance_method(_array.boolArray___getitem__)
# Register boolArray in _array:
_array.boolArray_swigregister(boolArray)
| 36.425773 | 118 | 0.664535 | 4,136 | 35,333 | 5.323985 | 0.055851 | 0.063442 | 0.083787 | 0.117302 | 0.81753 | 0.74337 | 0.542598 | 0.426703 | 0.295822 | 0.134015 | 0 | 0.002493 | 0.228087 | 35,333 | 969 | 119 | 36.463364 | 0.804869 | 0.256644 | 0 | 0.312796 | 1 | 0 | 0.007985 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.240126 | false | 0 | 0.011058 | 0.006319 | 0.693523 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 5 |
d7a7aa2512ed536471f60cbe41bb9fc9053e31e0 | 57 | py | Python | main.py | CARD-AI/CDR-Generator | 39c75fa28b15dffb65a784d72a96a7130e17ead0 | [
"MIT"
] | 1 | 2022-03-01T10:49:59.000Z | 2022-03-01T10:49:59.000Z | main.py | CARD-AI/CDR-Generator | 39c75fa28b15dffb65a784d72a96a7130e17ead0 | [
"MIT"
] | null | null | null | main.py | CARD-AI/CDR-Generator | 39c75fa28b15dffb65a784d72a96a7130e17ead0 | [
"MIT"
] | 1 | 2022-01-20T08:37:39.000Z | 2022-01-20T08:37:39.000Z | from cdr_generator import run_generator
run_generator()
| 14.25 | 39 | 0.859649 | 8 | 57 | 5.75 | 0.625 | 0.521739 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.105263 | 57 | 3 | 40 | 19 | 0.901961 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
cc0b9c5922d5e03272ed688c5974913c1cd1f919 | 230 | py | Python | test/unit/test_loghelpers.py | Spendency/cw-logs-to-lambda | 24dcd104ddbae159f2568d0672d05731b9884504 | [
"MIT"
] | 2 | 2019-04-17T17:44:31.000Z | 2020-08-04T02:49:40.000Z | test/unit/test_loghelpers.py | Spendency/cw-logs-to-lambda | 24dcd104ddbae159f2568d0672d05731b9884504 | [
"MIT"
] | 1 | 2019-12-18T19:30:06.000Z | 2019-12-18T19:30:06.000Z | test/unit/test_loghelpers.py | keetonian/cw-logs-to-chime | 731cfc75f602309ce2ba70d233ff17b292133101 | [
"MIT"
] | 1 | 2021-03-24T08:27:26.000Z | 2021-03-24T08:27:26.000Z | import pytest
import loghelpers
import test_constants
def test_extract_log_events(mocker):
log_events = loghelpers.extract_log_events(test_constants.AWS_LOG_EVENT)
assert log_events == test_constants.EXTRACTED_LOG_EVENTS | 28.75 | 76 | 0.847826 | 32 | 230 | 5.65625 | 0.4375 | 0.248619 | 0.176796 | 0.243094 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.104348 | 230 | 8 | 77 | 28.75 | 0.878641 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 1 | 0.166667 | false | 0 | 0.5 | 0 | 0.666667 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 5 |
cc2b9bea4a7d519d654f4b9cf4cbb0c0a88e0ebe | 37 | py | Python | mil/validators/wrapper.py | yangsenwxy/mil | 8e6b6f0b55bddc961b957a682935cb346f3bca4c | [
"MIT"
] | 25 | 2020-11-02T23:33:32.000Z | 2022-03-14T22:57:54.000Z | mil/validators/wrapper.py | yangsenwxy/mil | 8e6b6f0b55bddc961b957a682935cb346f3bca4c | [
"MIT"
] | 4 | 2021-06-14T05:46:37.000Z | 2021-07-12T16:25:26.000Z | mil/validators/wrapper.py | yangsenwxy/mil | 8e6b6f0b55bddc961b957a682935cb346f3bca4c | [
"MIT"
] | 12 | 2020-12-28T04:02:06.000Z | 2022-02-04T10:33:44.000Z | from sklearn.model_selection import * | 37 | 37 | 0.864865 | 5 | 37 | 6.2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.081081 | 37 | 1 | 37 | 37 | 0.911765 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
0bda39b1fbc5fd42a9f3588f56722d184404d516 | 417 | py | Python | apps/session/group/urls.py | sparcs-kaist/araplus | 031ce946b393c5035dbfbb3e7233cc5dae61f440 | [
"MIT"
] | 17 | 2015-06-30T09:03:37.000Z | 2016-01-26T16:54:01.000Z | apps/session/group/urls.py | sparcs-kaist/araplus | 031ce946b393c5035dbfbb3e7233cc5dae61f440 | [
"MIT"
] | 136 | 2015-07-01T18:49:51.000Z | 2016-07-19T14:58:31.000Z | apps/session/group/urls.py | sparcs-kaist/araplus | 031ce946b393c5035dbfbb3e7233cc5dae61f440 | [
"MIT"
] | 11 | 2015-07-01T18:36:06.000Z | 2018-12-19T02:52:09.000Z | from apps.session.urls import url
# This url is under "session/group/"
urlpatterns = [
url(r'^$', 'apps.session.group.views.view_group_list'),
url(r'^make/', 'apps.session.group.views.make_group'),
url(r'^message/(?P<groupname>[a-z A-Z 0-9]+)/$',
'apps.session.group.views.group_message'),
url(r'^message/(?P<groupname>[a-z A-Z 0-9]+)/manage/',
'apps.session.group.views.manage'),
]
| 32.076923 | 59 | 0.635492 | 65 | 417 | 4.015385 | 0.369231 | 0.210728 | 0.245211 | 0.321839 | 0.206897 | 0.206897 | 0.206897 | 0.206897 | 0.206897 | 0.206897 | 0 | 0.011204 | 0.143885 | 417 | 12 | 60 | 34.75 | 0.719888 | 0.081535 | 0 | 0 | 0 | 0 | 0.624672 | 0.519685 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.111111 | 0 | 0.111111 | 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 | 1 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
0bfa748404008a190465df55a806ba5d87f51a41 | 15,556 | py | Python | venv/lib/python3.6/site-packages/ansible_collections/amazon/aws/tests/unit/module_utils/test_iam.py | usegalaxy-no/usegalaxy | 75dad095769fe918eb39677f2c887e681a747f3a | [
"MIT"
] | 22 | 2021-07-16T08:11:22.000Z | 2022-03-31T07:15:34.000Z | venv/lib/python3.6/site-packages/ansible_collections/amazon/aws/tests/unit/module_utils/test_iam.py | usegalaxy-no/usegalaxy | 75dad095769fe918eb39677f2c887e681a747f3a | [
"MIT"
] | 12 | 2020-02-21T07:24:52.000Z | 2020-04-14T09:54:32.000Z | venv/lib/python3.6/site-packages/ansible_collections/amazon/aws/tests/unit/module_utils/test_iam.py | usegalaxy-no/usegalaxy | 75dad095769fe918eb39677f2c887e681a747f3a | [
"MIT"
] | 39 | 2021-07-05T02:31:42.000Z | 2022-03-31T02:46:03.000Z | #
# (c) 2020 Red Hat Inc.
#
# This file is part of Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import pytest
import botocore
from ansible_collections.amazon.aws.tests.unit.compat.mock import MagicMock
from ansible_collections.amazon.aws.tests.unit.compat import unittest
import ansible_collections.amazon.aws.plugins.module_utils.iam as utils_iam
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import HAS_BOTO3
if not HAS_BOTO3:
pytestmark = pytest.mark.skip("test_iam.py requires the python modules 'boto3' and 'botocore'")
class IamUtilsTestSuite(unittest.TestCase):
def _make_denied_exception(self, partition):
return botocore.exceptions.ClientError(
{
"Error": {
"Code": "AccessDenied",
"Message": "User: arn:" + partition + ":iam::123456789012:user/ExampleUser "
+ "is not authorized to perform: iam:GetUser on resource: user ExampleUser"
},
"ResponseMetadata": {
"RequestId": "01234567-89ab-cdef-0123-456789abcdef"
}
}, 'getUser')
def _make_unexpected_exception(self):
return botocore.exceptions.ClientError(
{
"Error": {
"Code": "SomeThingWentWrong",
"Message": "Boom!"
},
"ResponseMetadata": {
"RequestId": "01234567-89ab-cdef-0123-456789abcdef"
}
}, 'someCall')
def _make_encoded_exception(self):
return botocore.exceptions.ClientError(
{
"Error": {
"Code": "AccessDenied",
"Message": "You are not authorized to perform this operation. Encoded authorization failure message: " +
"fEwXX6llx3cClm9J4pURgz1XPnJPrYexEbrJcLhFkwygMdOgx_-aEsj0LqRM6Kxt2HVI6prUhDwbJqBo9U2V7iRKZ" +
"T6ZdJvHH02cXmD0Jwl5vrTsf0PhBcWYlH5wl2qME7xTfdolEUr4CzumCiti7ETiO-RDdHqWlasBOW5bWsZ4GSpPdU" +
"06YAX0TfwVBs48uU5RpCHfz1uhSzez-3elbtp9CmTOHLt5pzJodiovccO55BQKYLPtmJcs6S9YLEEogmpI4Cb1D26" +
"fYahDh51jEmaohPnW5pb1nQe2yPEtuIhtRzNjhFCOOMwY5DBzNsymK-Gj6eJLm7FSGHee4AHLU_XmZMe_6bcLAiOx" +
"6Zdl65Kdd0hLcpwVxyZMi27HnYjAdqRlV3wuCW2PkhAW14qZQLfiuHZDEwnPe2PBGSlFcCmkQvJvX-YLoA7Uyc2wf" +
"NX5RJm38STwfiJSkQaNDhHKTWKiLOsgY4Gze6uZoG7zOcFXFRyaA4cbMmI76uyBO7j-9uQUCtBYqYto8x_9CUJcxI" +
"VC5SPG_C1mk-WoDMew01f0qy-bNaCgmJ9TOQGd08FyuT1SaMpCC0gX6mHuOnEgkFw3veBIowMpp9XcM-yc42fmIOp" +
"FOdvQO6uE9p55Qc-uXvsDTTvT3A7EeFU8a_YoAIt9UgNYM6VTvoprLz7dBI_P6C-bdPPZCY2amm-dJNVZelT6TbJB" +
"H_Vxh0fzeiSUBersy_QzB0moc-vPWgnB-IkgnYLV-4L3K0L2"
},
"ResponseMetadata": {
"RequestId": "01234567-89ab-cdef-0123-456789abcdef"
}
}, 'someCall')
def _make_botocore_exception(self):
return botocore.exceptions.EndpointConnectionError(endpoint_url='junk.endpoint')
def setUp(self):
self.sts_client = MagicMock()
self.iam_client = MagicMock()
self.module = MagicMock()
clients = {'sts': self.sts_client, 'iam': self.iam_client}
def get_client(*args, **kwargs):
return clients[args[0]]
self.module.client.side_effect = get_client
self.module.fail_json_aws.side_effect = SystemExit(1)
self.module.fail_json.side_effect = SystemExit(2)
# ========== get_aws_account_id ============
# This is just a minimal (compatability) wrapper around get_aws_account_info
# Perform some basic testing and call it a day.
# Test the simplest case - We're permitted to call GetCallerIdentity
def test_get_aws_account_id__caller_success(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [{'UserId': 'AIDA1234567890ABCDEFG',
'Account': '123456789012',
'Arn': 'arn:aws:iam::123456789012:user/ExampleUser'}]
# Run module
return_value = utils_iam.get_aws_account_id(self.module)
# Check we only saw the calls we mocked out
self.module.client.assert_called_once()
self.sts_client.get_caller_identity.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, '123456789012')
# Test the simplest case - We're permitted to call GetCallerIdentity
# (China partition)
def test_get_aws_account_id__caller_success_cn(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [{'UserId': 'AIDA1234567890ABCDEFG',
'Account': '123456789012',
'Arn': 'arn:aws-cn:iam::123456789012:user/ExampleUser'}]
# Run module
return_value = utils_iam.get_aws_account_id(self.module)
# Check we only saw the calls we mocked out
self.module.client.assert_called_once()
self.sts_client.get_caller_identity.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, '123456789012')
# ========== get_aws_account_info ============
# Test the simplest case - We're permitted to call GetCallerIdentity
def test_get_aws_account_info__caller_success(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [{'UserId': 'AIDA1234567890ABCDEFG',
'Account': '123456789012',
'Arn': 'arn:aws:iam::123456789012:user/ExampleUser'}]
# Run module
return_value = utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.module.client.assert_called_once()
self.sts_client.get_caller_identity.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, ('123456789012', 'aws',))
# (China partition)
def test_get_aws_account_info__caller_success_cn(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [{'UserId': 'AIDA1234567890ABCDEFG',
'Account': '123456789012',
'Arn': 'arn:aws-cn:iam::123456789012:user/ExampleUser'}]
# Run module
return_value = utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.module.client.assert_called_once()
self.sts_client.get_caller_identity.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, ('123456789012', 'aws-cn',))
# (US-Gov partition)
def test_get_aws_account_info__caller_success_gov(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [{'UserId': 'AIDA1234567890ABCDEFG',
'Account': '123456789012',
'Arn': 'arn:aws-us-gov:iam::123456789012:user/ExampleUser'}]
# Run module
return_value = utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.module.client.assert_called_once()
self.sts_client.get_caller_identity.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, ('123456789012', 'aws-us-gov',))
# If sts:get_caller_identity fails (most likely something wierd on the
# client side), then try a few extra options.
# Test response if STS fails and we need to fall back to GetUser
def test_get_aws_account_info__user_success(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [self._make_botocore_exception()]
self.iam_client.get_user.side_effect = [{"User": {"Path": "/", "UserName": "ExampleUser", "UserId": "AIDA1234567890ABCDEFG",
"Arn": "arn:aws:iam::123456789012:user/ExampleUser", "CreateDate": "2020-09-08T14:04:32Z"}}]
# Run module
return_value = utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.assertEqual(self.module.client.call_count, 2)
self.sts_client.get_caller_identity.assert_called_once()
self.iam_client.get_user.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, ('123456789012', 'aws',))
# (China partition)
def test_get_aws_account_info__user_success_cn(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [self._make_botocore_exception()]
self.iam_client.get_user.side_effect = [{"User": {"Path": "/", "UserName": "ExampleUser", "UserId": "AIDA1234567890ABCDEFG",
"Arn": "arn:aws-cn:iam::123456789012:user/ExampleUser", "CreateDate": "2020-09-08T14:04:32Z"}}]
# Run module
return_value = utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.assertEqual(self.module.client.call_count, 2)
self.sts_client.get_caller_identity.assert_called_once()
self.iam_client.get_user.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, ('123456789012', 'aws-cn',))
# (US-Gov partition)
def test_get_aws_account_info__user_success_gov(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [self._make_botocore_exception()]
self.iam_client.get_user.side_effect = [{"User": {"Path": "/", "UserName": "ExampleUser", "UserId": "AIDA1234567890ABCDEFG",
"Arn": "arn:aws-us-gov:iam::123456789012:user/ExampleUser", "CreateDate": "2020-09-08T14:04:32Z"}}]
# Run module
return_value = utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.assertEqual(self.module.client.call_count, 2)
self.sts_client.get_caller_identity.assert_called_once()
self.iam_client.get_user.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, ('123456789012', 'aws-us-gov',))
# Test response if STS and IAM fails and we need to fall back to the denial message
def test_get_aws_account_info__user_denied(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [self._make_botocore_exception()]
self.iam_client.get_user.side_effect = [self._make_denied_exception('aws')]
# Run module
return_value = utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.assertEqual(self.module.client.call_count, 2)
self.sts_client.get_caller_identity.assert_called_once()
self.iam_client.get_user.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, ('123456789012', 'aws',))
# (China partition)
def test_get_aws_account_info__user_denied_cn(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [self._make_botocore_exception()]
self.iam_client.get_user.side_effect = [self._make_denied_exception('aws-cn')]
# Run module
return_value = utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.assertEqual(self.module.client.call_count, 2)
self.sts_client.get_caller_identity.assert_called_once()
self.iam_client.get_user.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, ('123456789012', 'aws-cn',))
# (US-Gov partition)
def test_get_aws_account_info__user_denied_gov(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [self._make_botocore_exception()]
self.iam_client.get_user.side_effect = [self._make_denied_exception('aws-us-gov')]
# Run module
return_value = utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.assertEqual(self.module.client.call_count, 2)
self.sts_client.get_caller_identity.assert_called_once()
self.iam_client.get_user.assert_called_once()
# Check we got the values back we expected.
self.assertEqual(return_value, ('123456789012', 'aws-us-gov',))
# Test that we fail gracefully if Boto throws exceptions at us...
def test_get_aws_account_info__boto_failures(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [self._make_botocore_exception()]
self.iam_client.get_user.side_effect = [self._make_botocore_exception()]
# Run module
with pytest.raises(SystemExit) as e:
utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.assertEqual(self.module.client.call_count, 2)
self.sts_client.get_caller_identity.assert_called_once()
self.iam_client.get_user.assert_called_once()
# Check we got the values back we expected.
assert e.type == SystemExit
assert e.value.code == 1 # 1 == fail_json_aws
def test_get_aws_account_info__client_failures(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [self._make_unexpected_exception()]
self.iam_client.get_user.side_effect = [self._make_unexpected_exception()]
# Run module
with pytest.raises(SystemExit) as e:
utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.assertEqual(self.module.client.call_count, 2)
self.sts_client.get_caller_identity.assert_called_once()
self.iam_client.get_user.assert_called_once()
# Check we got the values back we expected.
assert e.type == SystemExit
assert e.value.code == 1 # 1 == fail_json_aws
def test_get_aws_account_info__encoded_failures(self):
# Prepare
self.sts_client.get_caller_identity.side_effect = [self._make_encoded_exception()]
self.iam_client.get_user.side_effect = [self._make_encoded_exception()]
# Run module
with pytest.raises(SystemExit) as e:
utils_iam.get_aws_account_info(self.module)
# Check we only saw the calls we mocked out
self.assertEqual(self.module.client.call_count, 2)
self.sts_client.get_caller_identity.assert_called_once()
self.iam_client.get_user.assert_called_once()
# Check we got the values back we expected.
assert e.type == SystemExit
assert e.value.code == 1 # 1 == fail_json (we couldn't parse the AccessDenied errors)
| 52.377104 | 157 | 0.647403 | 1,786 | 15,556 | 5.355543 | 0.135498 | 0.043283 | 0.042133 | 0.046837 | 0.779927 | 0.77564 | 0.76874 | 0.751908 | 0.706743 | 0.703816 | 0 | 0.054296 | 0.260028 | 15,556 | 296 | 158 | 52.554054 | 0.776648 | 0.163345 | 0 | 0.593583 | 0 | 0 | 0.187457 | 0.110587 | 0 | 0 | 0 | 0 | 0.28877 | 1 | 0.106952 | false | 0 | 0.037433 | 0.026738 | 0.176471 | 0.005348 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 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 | 5 |
041fbb10a33308c29b6bd39df7635f8510f6864c | 641 | py | Python | mnist_data_handler.py | SeongJunChoi/Stacked_LSTMS_Highway_Residual_On_TimeSeries_Datasets | 4c9e9647b4a134a2b7f63b0289687cc92262d5c8 | [
"Apache-2.0"
] | 14 | 2017-10-12T08:48:31.000Z | 2021-06-10T05:55:34.000Z | mnist_data_handler.py | SeongJunChoi/Stacked_LSTMS_Highway_Residual_On_TimeSeries_Datasets | 4c9e9647b4a134a2b7f63b0289687cc92262d5c8 | [
"Apache-2.0"
] | 1 | 2017-10-12T08:45:02.000Z | 2017-10-12T08:45:02.000Z | mnist_data_handler.py | SeongJunChoi/Stacked_LSTMS_Highway_Residual_On_TimeSeries_Datasets | 4c9e9647b4a134a2b7f63b0289687cc92262d5c8 | [
"Apache-2.0"
] | 2 | 2018-05-06T06:15:59.000Z | 2018-06-11T20:03:49.000Z | from tensorflow.examples.tutorials.mnist import input_data
def get_mnist_data():
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
trX, trY, teX, teY = mnist.train.images, mnist.train.labels, mnist.test.images, mnist.test.labels
trX = trX.reshape(-1, 28, 28)
teX = teX.reshape(-1, 28, 28)
return (trX, trY, teX, teY)
def get_mnist_data_with_time_series_size():
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
trX, trY, teX, teY = mnist.train.images, mnist.train.labels, mnist.test.images, mnist.test.labels
trX = trX.reshape(-1, 28, 28)
teX = teX.reshape(-1, 28, 28)
return (trX, trY, teX, teY, 28)
| 35.611111 | 98 | 0.726989 | 109 | 641 | 4.100917 | 0.284404 | 0.080537 | 0.080537 | 0.107383 | 0.774049 | 0.774049 | 0.774049 | 0.774049 | 0.774049 | 0.774049 | 0 | 0.039146 | 0.123245 | 641 | 17 | 99 | 37.705882 | 0.756228 | 0 | 0 | 0.615385 | 0 | 0 | 0.034321 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0 | 0.076923 | 0 | 0.384615 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 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 | 5 |
042a801f5532af0962ef2feff411615841499244 | 41 | py | Python | bitforex/BitforexException.py | uamrws/bitforex-aio | 0865224b175a75bc9a021c816239e4c82704904a | [
"MIT"
] | null | null | null | bitforex/BitforexException.py | uamrws/bitforex-aio | 0865224b175a75bc9a021c816239e4c82704904a | [
"MIT"
] | 2 | 2022-02-07T03:03:14.000Z | 2022-02-07T19:19:21.000Z | bitforex/BitforexException.py | uamrws/bitforex-aio | 0865224b175a75bc9a021c816239e4c82704904a | [
"MIT"
] | 2 | 2021-11-02T11:58:14.000Z | 2022-02-07T03:05:39.000Z | class BitforexException(Exception):
pass | 20.5 | 35 | 0.853659 | 4 | 41 | 8.75 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.073171 | 41 | 2 | 36 | 20.5 | 0.921053 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0.5 | 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 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 5 |
04598fe443bd9c365dcdc246041d1dadc13fb9ac | 181 | py | Python | E2_6/MyAsciiArg.py | AidaNajafi/AidaNajafi.github.io | a5d86dc67a1d272794586e0a5c612a3893b75e69 | [
"Apache-2.0"
] | null | null | null | E2_6/MyAsciiArg.py | AidaNajafi/AidaNajafi.github.io | a5d86dc67a1d272794586e0a5c612a3893b75e69 | [
"Apache-2.0"
] | null | null | null | E2_6/MyAsciiArg.py | AidaNajafi/AidaNajafi.github.io | a5d86dc67a1d272794586e0a5c612a3893b75e69 | [
"Apache-2.0"
] | null | null | null | # b=base size
def print_cone(b):
for i in range(b):
for j in range((i-1)/2):
print("^")
print(("/"*j, "|"*j, '"\"'*j)
print_cone(9)
| 20.111111 | 41 | 0.403315 | 27 | 181 | 2.62963 | 0.518519 | 0.253521 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.026316 | 0.370166 | 181 | 9 | 42 | 20.111111 | 0.596491 | 0 | 0 | 0 | 0 | 0 | 0.035503 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.666667 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 5 |
f086fcb97804d3b4cb6b5e59211a716187f12f16 | 121 | py | Python | meshrcnn/utils/__init__.py | MAYURGAIKWAD/meshrcnn | b47ecd47ca7de7055b7d141e63ddab286c5245f3 | [
"BSD-3-Clause"
] | 1,028 | 2020-01-23T23:30:54.000Z | 2022-03-27T22:33:50.000Z | meshrcnn/utils/__init__.py | MAYURGAIKWAD/meshrcnn | b47ecd47ca7de7055b7d141e63ddab286c5245f3 | [
"BSD-3-Clause"
] | 103 | 2020-01-24T05:29:48.000Z | 2022-03-08T13:04:24.000Z | meshrcnn/utils/__init__.py | MAYURGAIKWAD/meshrcnn | b47ecd47ca7de7055b7d141e63ddab286c5245f3 | [
"BSD-3-Clause"
] | 179 | 2020-01-24T08:14:30.000Z | 2022-03-19T00:34:05.000Z | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from . import model_zoo # registers pathhandlers
| 40.333333 | 70 | 0.77686 | 16 | 121 | 5.8125 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.157025 | 121 | 2 | 71 | 60.5 | 0.911765 | 0.752066 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
f09927be9936ecb174d188d9c00dc407226e37d1 | 211 | py | Python | examples/make_cartpole_dataset.py | takuseno/minerva | c073cd309e84bf1785de8f5b8b5d46d3599d1010 | [
"MIT"
] | 68 | 2020-09-09T04:22:35.000Z | 2022-03-20T10:15:51.000Z | examples/make_cartpole_dataset.py | takuseno/minerva | c073cd309e84bf1785de8f5b8b5d46d3599d1010 | [
"MIT"
] | 3 | 2021-05-15T03:15:47.000Z | 2021-07-09T21:35:22.000Z | examples/make_cartpole_dataset.py | takuseno/minerva | c073cd309e84bf1785de8f5b8b5d46d3599d1010 | [
"MIT"
] | 5 | 2020-09-09T02:35:10.000Z | 2022-03-04T02:23:00.000Z | from d3rlpy.datasets import get_cartpole
from minerva.dataset import export_mdp_dataset_as_csv
# prepare MDPDataset
dataset, _ = get_cartpole()
# save as CSV
export_mdp_dataset_as_csv(dataset, 'cartpole.csv')
| 23.444444 | 53 | 0.824645 | 31 | 211 | 5.258065 | 0.483871 | 0.092025 | 0.196319 | 0.220859 | 0.257669 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005319 | 0.109005 | 211 | 8 | 54 | 26.375 | 0.861702 | 0.14218 | 0 | 0 | 0 | 0 | 0.067416 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
0b0505222f25f0493ea05837c36157fdcb806b30 | 58 | py | Python | test_receiver.py | paukstis/dnstap-receiver | d0190340cc58975f92bcfeebfed025fe637a7b78 | [
"MIT"
] | null | null | null | test_receiver.py | paukstis/dnstap-receiver | d0190340cc58975f92bcfeebfed025fe637a7b78 | [
"MIT"
] | null | null | null | test_receiver.py | paukstis/dnstap-receiver | d0190340cc58975f92bcfeebfed025fe637a7b78 | [
"MIT"
] | null | null | null |
import dnstap_receiver
dnstap_receiver.start_receiver()
| 11.6 | 32 | 0.862069 | 7 | 58 | 6.714286 | 0.571429 | 0.595745 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.086207 | 58 | 4 | 33 | 14.5 | 0.886792 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
0b16321d337647eb045e6b7e3c5e2decb8e7f5ac | 5,323 | py | Python | python-client/cloudera/director/d6_1/models/__init__.py | daanknoope/director-sdk | a099fedd5afe365aedbb50daa75de048ef6f7ab4 | [
"Apache-2.0"
] | 24 | 2015-03-04T01:39:36.000Z | 2020-06-30T13:34:27.000Z | python-client/cloudera/director/d6_1/models/__init__.py | daanknoope/director-sdk | a099fedd5afe365aedbb50daa75de048ef6f7ab4 | [
"Apache-2.0"
] | 5 | 2015-11-04T08:18:47.000Z | 2019-01-05T11:12:19.000Z | python-client/cloudera/director/d6_1/models/__init__.py | daanknoope/director-sdk | a099fedd5afe365aedbb50daa75de048ef6f7ab4 | [
"Apache-2.0"
] | 26 | 2015-02-24T21:13:53.000Z | 2020-12-15T06:01:46.000Z | # coding: utf-8
# flake8: noqa
"""
Licensed to Cloudera, Inc. under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. Cloudera, Inc. licenses this file
to you 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 __future__ import absolute_import
# import models into model package
from cloudera.director.d6_1.models.capabilities import Capabilities
from cloudera.director.d6_1.models.cloud_provider_metadata import CloudProviderMetadata
from cloudera.director.d6_1.models.cluster import Cluster
from cloudera.director.d6_1.models.cluster_administration_settings import ClusterAdministrationSettings
from cloudera.director.d6_1.models.cluster_template import ClusterTemplate
from cloudera.director.d6_1.models.cluster_update_event_summary import ClusterUpdateEventSummary
from cloudera.director.d6_1.models.configuration_property import ConfigurationProperty
from cloudera.director.d6_1.models.configuration_property_value import ConfigurationPropertyValue
from cloudera.director.d6_1.models.deployment import Deployment
from cloudera.director.d6_1.models.deployment_template import DeploymentTemplate
from cloudera.director.d6_1.models.diagnostic_data_summary import DiagnosticDataSummary
from cloudera.director.d6_1.models.display_property import DisplayProperty
from cloudera.director.d6_1.models.environment import Environment
from cloudera.director.d6_1.models.error_info import ErrorInfo
from cloudera.director.d6_1.models.eula import Eula
from cloudera.director.d6_1.models.external_account import ExternalAccount
from cloudera.director.d6_1.models.external_database import ExternalDatabase
from cloudera.director.d6_1.models.external_database_server import ExternalDatabaseServer
from cloudera.director.d6_1.models.external_database_server_template import ExternalDatabaseServerTemplate
from cloudera.director.d6_1.models.external_database_server_usage import ExternalDatabaseServerUsage
from cloudera.director.d6_1.models.external_database_template import ExternalDatabaseTemplate
from cloudera.director.d6_1.models.health import Health
from cloudera.director.d6_1.models.health_check import HealthCheck
from cloudera.director.d6_1.models.import_result import ImportResult
from cloudera.director.d6_1.models.import_status import ImportStatus
from cloudera.director.d6_1.models.instance import Instance
from cloudera.director.d6_1.models.instance_provider_config import InstanceProviderConfig
from cloudera.director.d6_1.models.instance_state import InstanceState
from cloudera.director.d6_1.models.instance_template import InstanceTemplate
from cloudera.director.d6_1.models.login import Login
from cloudera.director.d6_1.models.metering_setting import MeteringSetting
from cloudera.director.d6_1.models.metrics import Metrics
from cloudera.director.d6_1.models.migrating_group import MigratingGroup
from cloudera.director.d6_1.models.migration import Migration
from cloudera.director.d6_1.models.normalization_configuration import NormalizationConfiguration
from cloudera.director.d6_1.models.notification import Notification
from cloudera.director.d6_1.models.password_change import PasswordChange
from cloudera.director.d6_1.models.resource_provider_metadata import ResourceProviderMetadata
from cloudera.director.d6_1.models.script import Script
from cloudera.director.d6_1.models.service import Service
from cloudera.director.d6_1.models.ssh_credentials import SshCredentials
from cloudera.director.d6_1.models.status import Status
from cloudera.director.d6_1.models.time_series import TimeSeries
from cloudera.director.d6_1.models.time_series_aggregate_statistics import TimeSeriesAggregateStatistics
from cloudera.director.d6_1.models.time_series_cross_entity_metadata import TimeSeriesCrossEntityMetadata
from cloudera.director.d6_1.models.time_series_data import TimeSeriesData
from cloudera.director.d6_1.models.time_series_metadata import TimeSeriesMetadata
from cloudera.director.d6_1.models.time_series_response import TimeSeriesResponse
from cloudera.director.d6_1.models.time_series_response_list import TimeSeriesResponseList
from cloudera.director.d6_1.models.time_series_row import TimeSeriesRow
from cloudera.director.d6_1.models.user import User
from cloudera.director.d6_1.models.user_management_status import UserManagementStatus
from cloudera.director.d6_1.models.validation_exception_condition import ValidationExceptionCondition
from cloudera.director.d6_1.models.validation_result import ValidationResult
from cloudera.director.d6_1.models.validation_results import ValidationResults
from cloudera.director.d6_1.models.virtual_instance import VirtualInstance
from cloudera.director.d6_1.models.virtual_instance_group import VirtualInstanceGroup
from cloudera.director.d6_1.models.warning_info import WarningInfo
| 63.369048 | 106 | 0.87864 | 725 | 5,323 | 6.266207 | 0.273103 | 0.153203 | 0.255338 | 0.280872 | 0.461809 | 0.461809 | 0.327757 | 0.16707 | 0.054369 | 0 | 0 | 0.024641 | 0.069885 | 5,323 | 83 | 107 | 64.13253 | 0.892951 | 0.150479 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.016949 | 1 | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 0 | 5 |
9bc5623f4ea26c307d6a0fadacbd4d349a9e66ee | 14,357 | py | Python | rolling/stats.py | DavidPratt512/rolling | ec1f0fcf975182e00b4cd906a07803afa16c3816 | [
"MIT"
] | null | null | null | rolling/stats.py | DavidPratt512/rolling | ec1f0fcf975182e00b4cd906a07803afa16c3816 | [
"MIT"
] | null | null | null | rolling/stats.py | DavidPratt512/rolling | ec1f0fcf975182e00b4cd906a07803afa16c3816 | [
"MIT"
] | null | null | null | from collections import deque
from itertools import islice
from math import sqrt
from .base import RollingObject
from .arithmetic import Sum
from .structures.skiplist import IndexableSkiplist
from .structures.bicounter import BiCounter
class Mean(Sum):
"""
Iterator object that computes the mean of
a rolling window over a Python iterable.
Parameters
----------
iterable : any iterable object
window_size : integer, the size of the rolling
window moving over the iterable
Complexity
----------
Update time: O(1)
Memory usage: O(k)
where k is the size of the rolling window
"""
@property
def current_value(self):
return self._sum / self._obs
class Var(RollingObject):
"""
Iterator object that computes the variance
of a rolling window over a Python iterable.
Parameters
----------
iterable : any iterable object
window_size : integer, the size of the rolling
window moving over the iterable
ddof : int, default 1, the divisor used in calculation
is (N - ddof) where N is the number of observations
Complexity
----------
Update time: O(1)
Memory usage: O(k)
where k is the size of the rolling window
Notes
-----
Welford's algorithm is used to compute the variance.
Note that ddof must be less than window_size, otherwise
a value error is raised during initialisation.
Otherwise, if (N - ddof) is less than 0 (for variable-size
windows), the variance is computed as NaN.
"""
def _init_fixed(self, iterable, window_size, ddof=1, **kwargs):
if window_size <= ddof:
raise ValueError("window_size must be greater than ddof")
self.ddof = ddof
self._buffer = deque(maxlen=window_size)
self._mean = 0.0 # mean of values
self._sslm = 0.0 # sum of squared values less the mean
for new in islice(self._iterator, window_size - 1):
self._add_new(new)
# insert mean at the start of the buffer so that the
# the first call to update returns the correct value
self._buffer.appendleft(self._mean)
def _init_variable(self, iterable, window_size, ddof=1, **kwargs):
if window_size <= ddof:
raise ValueError("window_size must be greater than ddof")
self.ddof = ddof
self._buffer = deque(maxlen=window_size)
self._mean = 0.0 # mean of values
self._sslm = 0.0 # sum of squared values less the mean
def _add_new(self, new):
self._buffer.append(new)
delta = new - self._mean
self._mean += delta / self._obs
self._sslm += delta * (new - self._mean)
def _remove_old(self):
old = self._buffer.popleft()
delta = old - self._mean
self._mean -= delta / self._obs
self._sslm -= delta * (old - self._mean)
def _update_window(self, new):
old = self._buffer[0]
self._buffer.append(new)
delta = new - old
delta_old = old - self._mean
self._mean += delta / self._obs
delta_new = new - self._mean
self._sslm += delta * (delta_old + delta_new)
@property
def current_value(self):
if self._obs <= self.ddof:
return float("nan")
else:
return self._sslm / (self._obs - self.ddof)
@property
def _obs(self):
return len(self._buffer)
class Std(Var):
"""
Iterator object that computes the standard deviation
of a rolling window over a Python iterable.
Parameters
----------
iterable : any iterable object
window_size : integer, the size of the rolling
window moving over the iterable
ddof : int, default 1, the divisor used in calculation
is (N - ddof) where N is the number of observations
Complexity
----------
Update time: O(1)
Memory usage: O(k)
where k is the size of the rolling window
Notes
-----
Welford's algorithm is used to compute the variance,
of which the standard deviation is the square root.
Note that ddof must be less than window_size, otherwise
a value error is raised during initialisation.
Otherwise, if N-ddof is less than 0 (for variable-size
windows), the variance is computed as NaN.
"""
@property
def current_value(self):
if self._obs <= self.ddof:
return float("nan")
else:
return sqrt(self._sslm / (self._obs - self.ddof))
class Median(RollingObject):
"""
Iterator object that computes the median value
of a rolling window over a Python iterable.
Parameters
----------
iterable : any iterable object
window_size : integer, the size of the rolling
window moving over the iterable
Complexity
----------
Update time: O(log k)
Memory usage: O(k)
where k is the size of the rolling window
Notes
-----
An indexable skiplist is used to track the median
as the window moves (using an idea of R. Hettinger [1]).
[1] http://code.activestate.com/recipes/576930/
"""
def _init_fixed(self, iterable, window_size, **kwargs):
self._buffer = deque(maxlen=window_size)
self._skiplist = IndexableSkiplist(window_size)
# update buffer and skiplist with initial values
for new in islice(self._iterator, window_size - 1):
self._add_new(new)
try:
# insert a dummy value (the last element seen) so that
# the window is full and iterator works as expected
self._buffer.appendleft(new)
self._skiplist.insert(new)
except UnboundLocalError:
# if we didn't see any elements (the iterable had no
# elements or just one element), just use 0 instead
self._buffer.appendleft(0)
self._skiplist.insert(0)
def _init_variable(self, iterable, window_size, **kwargs):
self._buffer = deque(maxlen=window_size)
self._skiplist = IndexableSkiplist(window_size)
def _update_window(self, new):
old = self._buffer.popleft()
self._skiplist.remove(old)
self._skiplist.insert(new)
self._buffer.append(new)
def _add_new(self, new):
self._skiplist.insert(new)
self._buffer.append(new)
def _remove_old(self):
old = self._buffer.popleft()
self._skiplist.remove(old)
@property
def current_value(self):
if self._obs % 2 == 1:
return self._skiplist[self._obs // 2]
else:
i = self._obs // 2
return (self._skiplist[i] + self._skiplist[i - 1]) / 2
@property
def _obs(self):
return len(self._buffer)
class Mode(RollingObject):
"""
Iterator object that computes the mode
of a rolling window over a Python iterable.
IMPORTANT: the return set of modal values may be mutated
as iteration continues. This means that calling list()
on the rolling Mode object can lead to incorrect-looking
results as there may be multiple references to the same set.
Parameters
----------
iterable : any iterable object
window_size : integer, the size of the rolling
window moving over the iterable
return_count : bool, default False
if True, also return an integer showing the
count of the most common values
Complexity
----------
Update time: O(1)
Memory usage: O(k)
where k is the size of the rolling window
Notes
-----
A set of the most common items in the window is
returned. There can be multiple items in this
set if items are tied for the most common item.
This contrasts with Python's statistics module
where mode() will raise an error if the mode
is not unique.
"""
def _init_fixed(self, iterable, window_size, return_count=False, **kwargs):
self._buffer = deque(maxlen=window_size)
self.return_count = return_count
self._bicounter = BiCounter()
for item in islice(self._iterator, window_size - 1):
self._add_new(item)
# insert a value to be removed on the first call to update
self._buffer.appendleft("DUMMY_VALUE")
self._bicounter.increment("DUMMY_VALUE")
def _init_variable(self, iterable, window_size, return_count=False, **kwargs):
self._buffer = deque(maxlen=window_size)
self.return_count = return_count
self._bicounter = BiCounter()
def _update_window(self, new):
old = self._buffer.popleft()
self._bicounter.decrement(old)
self._bicounter.increment(new)
self._buffer.append(new)
def _add_new(self, new):
self._bicounter.increment(new)
self._buffer.append(new)
def _remove_old(self):
old = self._buffer.popleft()
self._bicounter.decrement(old)
@property
def current_value(self):
if self.return_count:
return self._bicounter.most_common_items, self._bicounter.largest_count
else:
return self._bicounter.most_common_items
@property
def _obs(self):
return len(self._buffer)
class Skew(RollingObject):
"""
Iterator object that computes the skewness
of a rolling window over a Python iterable.
Parameters
----------
iterable : any iterable object
window_size : integer, the size of the rolling
window moving over the iterable (must be
greater than 2)
Complexity
----------
Update time: O(1)
Memory usage: O(k)
where k is the size of the rolling window
Notes
-----
This implementation of rolling skewness is based
on the pandas code here:
https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/window.pyx
"""
def _init_fixed(self, iterable, window_size, **kwargs):
if window_size <= 2:
raise ValueError("window_size must be greater than 2")
self._buffer = deque(maxlen=window_size)
self._x1 = 0.0
self._x2 = 0.0
self._x3 = 0.0
for new in islice(self._iterator, window_size - 1):
self._add_new(new)
# insert zero at the start of the buffer so that the
# the first call to update returns the correct value
self._buffer.appendleft(0)
def _init_variable(self, iterable, window_size, **kwargs):
if window_size <= 2:
raise ValueError("window_size must be greater than 2")
self._buffer = deque(maxlen=window_size)
self._x1 = 0.0
self._x2 = 0.0
self._x3 = 0.0
def _add_new(self, new):
self._buffer.append(new)
self._x1 += new
self._x2 += new * new
self._x3 += new * new * new
def _remove_old(self):
old = self._buffer.popleft()
self._x1 -= old
self._x2 -= old * old
self._x3 -= old * old * old
def _update_window(self, new):
old = self._buffer[0]
self._buffer.append(new)
self._x1 += new - old
self._x2 += new * new - old * old
self._x3 += new * new * new - old * old * old
@property
def current_value(self):
N = self._obs
if N < 3:
return float("nan")
# compute moments
A = self._x1 / N
B = self._x2 / N - A * A
C = self._x3 / N - A * A * A - 3 * A * B
if B <= 1e-14:
return float("nan")
R = sqrt(B)
return (sqrt(N * (N - 1)) * C) / ((N - 2) * R * R * R)
@property
def _obs(self):
return len(self._buffer)
class Kurtosis(RollingObject):
"""
Iterator object that computes the kurtosis
of a rolling window over a Python iterable.
Parameters
----------
iterable : any iterable object
window_size : integer, the size of the rolling
window moving over the iterable (must be
greater than 3)
Complexity
----------
Update time: O(1)
Memory usage: O(k)
where k is the size of the rolling window
Notes
-----
This implementation of rolling kurtosis is based
on the pandas code here:
https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/window.pyx
"""
def _init_fixed(self, iterable, window_size, **kwargs):
if window_size <= 3:
raise ValueError("window_size must be greater than 3")
self._buffer = deque(maxlen=window_size)
self._x1 = 0.0
self._x2 = 0.0
self._x3 = 0.0
self._x4 = 0.0
for new in islice(self._iterator, window_size - 1):
self._add_new(new)
# insert zero at the start of the buffer so that the
# the first call to update returns the correct value
self._buffer.appendleft(0)
def _init_variable(self, iterable, window_size, **kwargs):
if window_size <= 3:
raise ValueError("window_size must be greater than 3")
self._buffer = deque(maxlen=window_size)
self._x1 = 0.0
self._x2 = 0.0
self._x3 = 0.0
self._x4 = 0.0
def _add_new(self, new):
self._buffer.append(new)
self._x1 += new
self._x2 += new * new
self._x3 += new ** 3
self._x4 += new ** 4
def _remove_old(self):
old = self._buffer.popleft()
self._x1 -= old
self._x2 -= old * old
self._x3 -= old ** 3
self._x4 -= old ** 4
def _update_window(self, new):
old = self._buffer[0]
self._buffer.append(new)
self._x1 += new - old
self._x2 += new * new - old * old
self._x3 += new ** 3 - old ** 3
self._x4 += new ** 4 - old ** 4
@property
def current_value(self):
N = self._obs
if N <= 3:
return float("nan")
# compute moments
A = self._x1 / N
R = A * A
B = self._x2 / N - R
R *= A
C = self._x3 / N - R - 3 * A * B
R *= A
D = self._x4 / N - R - 6 * B * A * A - 4 * C * A
if B <= 1e-14:
return float("nan")
K = (N * N - 1) * D / (B * B) - 3 * ((N - 1) ** 2)
return K / ((N - 2) * (N - 3))
@property
def _obs(self):
return len(self._buffer)
| 25.915162 | 83 | 0.599847 | 1,926 | 14,357 | 4.324507 | 0.124611 | 0.05763 | 0.015128 | 0.02017 | 0.794453 | 0.772842 | 0.73166 | 0.720134 | 0.684236 | 0.649298 | 0 | 0.015517 | 0.304242 | 14,357 | 553 | 84 | 25.962025 | 0.8183 | 0.351884 | 0 | 0.719665 | 0 | 0 | 0.028858 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.154812 | false | 0 | 0.029289 | 0.025105 | 0.297071 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 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 | 5 |
5003606df40d46ce4dda52839a339ce6dbae1002 | 91 | py | Python | coinstac_computation/__init__.py | trendscenter/coinstac-computation | e57eb780720cda83c921c1eb3760d5366d3e29bb | [
"MIT"
] | 1 | 2021-11-20T23:32:12.000Z | 2021-11-20T23:32:12.000Z | coinstac_computation/__init__.py | trendscenter/coinstac-computation | e57eb780720cda83c921c1eb3760d5366d3e29bb | [
"MIT"
] | null | null | null | coinstac_computation/__init__.py | trendscenter/coinstac-computation | e57eb780720cda83c921c1eb3760d5366d3e29bb | [
"MIT"
] | null | null | null | from .nodes import COINSTACPyNode
from .utils import ComputationPhase, PhaseEndWithSuccess
| 30.333333 | 56 | 0.868132 | 9 | 91 | 8.777778 | 0.777778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.098901 | 91 | 2 | 57 | 45.5 | 0.963415 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
500fd4bfb28e435f35a6292b6c675bc1c9da9d3e | 6,381 | py | Python | test/test_geo_read.py | sensiblecodeio/csv-to-cantabular-metadata-2021 | 32bad86f5acaec76af6538bdeff89fc78575c8dd | [
"Apache-2.0"
] | null | null | null | test/test_geo_read.py | sensiblecodeio/csv-to-cantabular-metadata-2021 | 32bad86f5acaec76af6538bdeff89fc78575c8dd | [
"Apache-2.0"
] | null | null | null | test/test_geo_read.py | sensiblecodeio/csv-to-cantabular-metadata-2021 | 32bad86f5acaec76af6538bdeff89fc78575c8dd | [
"Apache-2.0"
] | null | null | null | import unittest.mock
import unittest
from ons_csv_to_ctb_json_geo import read_geo_cats, AreaName
def mock_open(*args, **kargs):
f_open = unittest.mock.mock_open(*args, **kargs)
f_open.return_value.__iter__ = lambda self : iter(self.readline, '')
return f_open
class TestGeoRead(unittest.TestCase):
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""OA11CD,LAD22CD,LAD22NM,LAD22NMW,COUNTRY22CD,COUNTRY22NM
OA1,LAD1,LAD1 Name,LAD1 Name (Welsh),COUNTRY1,COUNTRY1 Name
OA2,LAD1,LAD1 Name,LAD1 Name (Welsh),COUNTRY1,COUNTRY1 Name
OA3,LAD2,LAD2 Name,LAD2 Name (Welsh),COUNTRY1,COUNTRY1 Name
OA3,LAD2,LAD2 Name,LAD2 Name (Welsh),COUNTRY1,COUNTRY1 Name
OA5,LAD3,LAD3 Name,LAD3 Name (Welsh),COUNTRY1,COUNTRY1 Name
OA6,LAD4,LAD4 Name,,COUNTRY1,COUNTRY1 Name
OA7,LAD5,LAD5 Name,LAD5 Name (Welsh),COUNTRY1,COUNTRY1 Name
""")
def test_read_file(self, m):
data = read_geo_cats('file.csv')
self.assertEqual(data,
{
'LAD': {
'LAD1': AreaName('LAD1 Name', 'LAD1 Name (Welsh)'),
'LAD2': AreaName('LAD2 Name', 'LAD2 Name (Welsh)'),
'LAD3': AreaName('LAD3 Name', 'LAD3 Name (Welsh)'),
'LAD4': AreaName('LAD4 Name', ''),
'LAD5': AreaName('LAD5 Name', 'LAD5 Name (Welsh)')
},
'COUNTRY': {
'COUNTRY1': AreaName('COUNTRY1 Name', ''),
},
})
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data=""" LAD22CD , LAD22NM,LAD22NMW
LAD1 , LAD1 Name,LAD1 Name (Welsh)
LAD2 , LAD2 Name,LAD2 Name (Welsh)
LAD3 , LAD3 Name,LAD3 Name (Welsh)
""")
def test_whitespace_stripping(self, m):
data = read_geo_cats('file.csv')
self.assertEqual(data,
{'LAD': {
'LAD1': AreaName('LAD1 Name', 'LAD1 Name (Welsh)'),
'LAD2': AreaName('LAD2 Name', 'LAD2 Name (Welsh)'),
'LAD3': AreaName('LAD3 Name', 'LAD3 Name (Welsh)'),
}
})
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""AbyZ_-422CD,AbyZ_-422NM,AbyZ_-422NMW
1,Name,Name (Welsh)
""")
def test_valid_varname_characters(self, m):
data = read_geo_cats('file.csv')
self.assertEqual(data,
{'AbyZ_-4': {
'1': AreaName('Name', 'Name (Welsh)'),
}
})
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""OA11CD,LAD22CD,LAD22NM,LAD22NMW,COUNTRY22CD,COUNTRY22NM
OA1,LAD1,LAD1 Name,LAD1 Name (Welsh),COUNTRY1,COUNTRY1 Name,extra
""")
def test_too_many_columns(self, m):
with self.assertRaisesRegex(ValueError, 'Reading file.csv: too many fields on row 2'):
read_geo_cats('file.csv')
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""OA11CD,LAD22CD,LAD22NM,LAD22NMW,COUNTRY22CD,COUNTRY22NM
OA1,LAD1,LAD1 Name,LAD1 Name (Welsh),COUNTRY1
""")
def test_too_few_columns(self, m):
with self.assertRaisesRegex(ValueError, 'Reading file.csv: too few fields on row 2'):
read_geo_cats('file.csv')
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""LAD22CD,LAD22NM,LAD22NMW
LAD1,LAD1 Name,LAD1 Name (Welsh)
LAD2,LAD2 Name,LAD2 Name (Welsh)
LAD2,LAD2 Name,LAD2 Name (Welsh)
LAD3,LAD3 Name,LAD3 Name (Welsh)
LAD3,LAD3 Name,Other Name (Welsh)
""")
def test_different_welsh_names(self, m):
with self.assertRaisesRegex(ValueError, '^Reading file.csv: different Welsh name for code LAD3 of LAD: "Other Name \(Welsh\)" and "LAD3 Name \(Welsh\)"$'):
read_geo_cats('file.csv')
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""LAD22CD,LAD22NM,LAD22NMW
LAD1,LAD1 Name,LAD1 Name (Welsh)
LAD2,LAD2 Name,LAD2 Name (Welsh)
LAD2,Other Name,LAD2 Name (Welsh)
""")
def test_different_names(self, m):
with self.assertRaisesRegex(ValueError, '^Reading file.csv: different name for code LAD2 of LAD: "Other Name" and "LAD2 Name"$'):
read_geo_cats('file.csv')
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""LAD22CD,LAD22NM,LAD22NMW,LAD22NM,LAD22NMW
""")
def test_duplicate_column_names(self, m):
with self.assertRaisesRegex(ValueError, '^Reading file.csv: duplicate column names: LAD22NM, LAD22NMW$'):
read_geo_cats('file.csv')
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""LAD22CD,LAD22NM,LAD22NMW,LAD22NM,LAD22NMW
""")
def test_duplicate_column_names(self, m):
with self.assertRaisesRegex(ValueError, '^Reading file.csv: duplicate column names: LAD22NM, LAD22NMW$'):
read_geo_cats('file.csv')
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""OA22CD,LA1DCD
""")
def test_invalid_varname_missing_year(self, m):
with self.assertRaisesRegex(ValueError, '^Reading file.csv: invalid code column name: LA1DCD$'):
read_geo_cats('file.csv')
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""OA22CD,LA^22CD
""")
def test_invalid_varname_character(self, m):
with self.assertRaisesRegex(ValueError, '^Reading file.csv: invalid code column name: LA\^22CD$'):
read_geo_cats('file.csv')
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""OA22CD,LA1DCD
""")
def test_invalid_code_column_name(self, m):
with self.assertRaisesRegex(ValueError, '^Reading file.csv: invalid code column name: LA1DCD$'):
read_geo_cats('file.csv')
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""LAD11CD,LAD22CD
""")
def test_multiple_code_columns(self, m):
with self.assertRaisesRegex(ValueError, '^Reading file.csv: multiple code columns found for LAD: LAD22CD and LAD11CD$'):
read_geo_cats('file.csv')
@unittest.mock.patch('builtins.open', new_callable=mock_open, read_data="""LAD11CD,LAD11NM,LAD11NMW,OA11NM,COUNTRY11NMW,DISTRICT22CD,DISTRICT22NMW
""")
def test_unexpected_fields(self, m):
with self.assertRaisesRegex(ValueError, '^Unexpected fieldnames: COUNTRY11NMW, DISTRICT22NMW, OA11NM'):
read_geo_cats('file.csv')
if __name__ == '__main__':
unittest.main()
| 44.93662 | 163 | 0.671995 | 819 | 6,381 | 5.065934 | 0.136752 | 0.065076 | 0.039769 | 0.084358 | 0.78766 | 0.748614 | 0.722343 | 0.722343 | 0.722343 | 0.718486 | 0 | 0.048319 | 0.189155 | 6,381 | 141 | 164 | 45.255319 | 0.753576 | 0 | 0 | 0.544715 | 0 | 0.01626 | 0.421251 | 0.094029 | 0 | 0 | 0 | 0 | 0.113821 | 1 | 0.121951 | false | 0 | 0.02439 | 0 | 0.162602 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 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 | 5 |
50112d4517a9591bd43ff4b903f526becb6d6ff0 | 863 | py | Python | apps/transactions/executor/entities/person.py | pedro-hs/financial-account | 7e8e4d0f3ac888fa36a091d0e733a8e1926180d2 | [
"MIT"
] | null | null | null | apps/transactions/executor/entities/person.py | pedro-hs/financial-account | 7e8e4d0f3ac888fa36a091d0e733a8e1926180d2 | [
"MIT"
] | null | null | null | apps/transactions/executor/entities/person.py | pedro-hs/financial-account | 7e8e4d0f3ac888fa36a091d0e733a8e1926180d2 | [
"MIT"
] | null | null | null | from apps.accounts.models import PersonAccount
from apps.transactions.models import PersonTransaction
class PersonEntity:
def __init__(self, account):
self.account = account
self.account_instance = self.get_account_instance()
def get_account_instance(self):
return PersonAccount.objects.filter(pk=self.account.number).first()
def get_email(self):
return (self.account_instance.user.email
if hasattr(self.account_instance, 'user') else None)
def get_owner_id(self):
return (self.account_instance.user.cpf
if hasattr(self.account_instance, 'user') else None)
def get_user_data(self):
return (self.account_instance.user
if hasattr(self.account_instance, 'user') else None)
def get_transaction_model(self):
return PersonTransaction
| 31.962963 | 75 | 0.696408 | 104 | 863 | 5.567308 | 0.326923 | 0.189983 | 0.229706 | 0.238342 | 0.409326 | 0.409326 | 0.238342 | 0.238342 | 0.238342 | 0.238342 | 0 | 0 | 0.219003 | 863 | 26 | 76 | 33.192308 | 0.85905 | 0 | 0 | 0.157895 | 0 | 0 | 0.013905 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.315789 | false | 0 | 0.105263 | 0.263158 | 0.736842 | 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 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 5 |
5011843f2a5a3b00e9ea8e20e682f5d82a33e3cc | 1,134 | py | Python | alpyro_msgs/actionlib_tutorials/fibonacciactionresult.py | rho2/alpyro_msgs | b5a680976c40c83df70d61bb2db1de32a1cde8d3 | [
"MIT"
] | 1 | 2020-12-13T13:07:10.000Z | 2020-12-13T13:07:10.000Z | alpyro_msgs/actionlib_tutorials/fibonacciactionresult.py | rho2/alpyro_msgs | b5a680976c40c83df70d61bb2db1de32a1cde8d3 | [
"MIT"
] | null | null | null | alpyro_msgs/actionlib_tutorials/fibonacciactionresult.py | rho2/alpyro_msgs | b5a680976c40c83df70d61bb2db1de32a1cde8d3 | [
"MIT"
] | null | null | null | from typing import List
from typing_extensions import Annotated
from typing import Final
from alpyro_msgs import RosMessage
from alpyro_msgs.actionlib_msgs.goalstatus import GoalStatus
from alpyro_msgs.actionlib_tutorials.fibonacciresult import FibonacciResult
from alpyro_msgs.std_msgs.header import Header
class FibonacciActionResult(RosMessage):
__msg_typ__ = "actionlib_tutorials/FibonacciActionResult"
__msg_def__ = "c3RkX21zZ3MvSGVhZGVyIGhlYWRlcgogIHVpbnQzMiBzZXEKICB0aW1lIHN0YW1wCiAgc3RyaW5nIGZyYW1lX2lkCmFjdGlvbmxpYl9tc2dzL0dvYWxTdGF0dXMgc3RhdHVzCiAgdWludDggUEVORElORz0wCiAgdWludDggQUNUSVZFPTEKICB1aW50OCBQUkVFTVBURUQ9MgogIHVpbnQ4IFNVQ0NFRURFRD0zCiAgdWludDggQUJPUlRFRD00CiAgdWludDggUkVKRUNURUQ9NQogIHVpbnQ4IFBSRUVNUFRJTkc9NgogIHVpbnQ4IFJFQ0FMTElORz03CiAgdWludDggUkVDQUxMRUQ9OAogIHVpbnQ4IExPU1Q9OQogIGFjdGlvbmxpYl9tc2dzL0dvYWxJRCBnb2FsX2lkCiAgICB0aW1lIHN0YW1wCiAgICBzdHJpbmcgaWQKICB1aW50OCBzdGF0dXMKICBzdHJpbmcgdGV4dAphY3Rpb25saWJfdHV0b3JpYWxzL0ZpYm9uYWNjaVJlc3VsdCByZXN1bHQKICBpbnQzMltdIHNlcXVlbmNlCgo="
__md5_sum__ = "bee73a9fe29ae25e966e105f5553dd03"
header: Header
status: GoalStatus
result: FibonacciResult
| 63 | 606 | 0.926808 | 62 | 1,134 | 16.564516 | 0.435484 | 0.038948 | 0.054528 | 0.044791 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.075419 | 0.05291 | 1,134 | 17 | 607 | 66.705882 | 0.880819 | 0 | 0 | 0 | 0 | 0 | 0.582892 | 0.582892 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 1 | 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 | 0 | 0 | 0 | 1 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
501c98e3dd3e5374f0231f042c459a0fa155cb2a | 363 | py | Python | ssh_session_manager/Command.py | JosephTLyons/ssh-session-manager | 07bd7e79760981b4820f670d4bd309865d2a75a0 | [
"MIT"
] | 1 | 2021-11-15T09:40:16.000Z | 2021-11-15T09:40:16.000Z | ssh_session_manager/Command.py | JosephTLyons/ssh-session-manager | 07bd7e79760981b4820f670d4bd309865d2a75a0 | [
"MIT"
] | null | null | null | ssh_session_manager/Command.py | JosephTLyons/ssh-session-manager | 07bd7e79760981b4820f670d4bd309865d2a75a0 | [
"MIT"
] | 1 | 2021-04-19T09:16:37.000Z | 2021-04-19T09:16:37.000Z | class Command:
def __init__(self, command_to_execute, command_user_input=None):
self.command_to_execute = command_to_execute
# Do not forget to supply any newlines expected by the command in order to execute the input
self.command_user_input = command_user_input
def __str__(self):
return f"\"{self.command_to_execute}\""
| 40.333333 | 100 | 0.727273 | 52 | 363 | 4.653846 | 0.461538 | 0.18595 | 0.264463 | 0.247934 | 0.223141 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.206612 | 363 | 8 | 101 | 45.375 | 0.840278 | 0.247934 | 0 | 0 | 0 | 0 | 0.00369 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0 | 0.166667 | 0.666667 | 0 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 5 |
5039cab8c1170e2b87f0986cc6081dd32ba69793 | 126 | py | Python | app1/views.py | zxk18339930029/demo2 | 69c1c80cdbc6be773b97a68d30275b648e5ce7b0 | [
"MIT"
] | null | null | null | app1/views.py | zxk18339930029/demo2 | 69c1c80cdbc6be773b97a68d30275b648e5ce7b0 | [
"MIT"
] | null | null | null | app1/views.py | zxk18339930029/demo2 | 69c1c80cdbc6be773b97a68d30275b648e5ce7b0 | [
"MIT"
] | null | null | null | from django.shortcuts import render
def like(request):
return render(request,'render.html')
# Create your views here.
| 14 | 40 | 0.738095 | 17 | 126 | 5.470588 | 0.823529 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 126 | 8 | 41 | 15.75 | 0.885714 | 0.18254 | 0 | 0 | 0 | 0 | 0.108911 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.333333 | 0.333333 | 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 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 5 |
504f01d17bae412bafe26290ade3ebc5ae5dca9f | 41 | py | Python | python/testData/intentions/PyConvertToFStringIntentionTest/formatMethodSimple.py | jnthn/intellij-community | 8fa7c8a3ace62400c838e0d5926a7be106aa8557 | [
"Apache-2.0"
] | 2 | 2019-04-28T07:48:50.000Z | 2020-12-11T14:18:08.000Z | python/testData/intentions/PyConvertToFStringIntentionTest/formatMethodSimple.py | Cyril-lamirand/intellij-community | 60ab6c61b82fc761dd68363eca7d9d69663cfa39 | [
"Apache-2.0"
] | 173 | 2018-07-05T13:59:39.000Z | 2018-08-09T01:12:03.000Z | python/testData/intentions/PyConvertToFStringIntentionTest/formatMethodSimple.py | Cyril-lamirand/intellij-community | 60ab6c61b82fc761dd68363eca7d9d69663cfa39 | [
"Apache-2.0"
] | 2 | 2020-03-15T08:57:37.000Z | 2020-04-07T04:48:14.000Z | '{} {foo:!r:3.5}'.format(42, foo='spam')
| 20.5 | 40 | 0.512195 | 8 | 41 | 2.625 | 0.875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.105263 | 0.073171 | 41 | 1 | 41 | 41 | 0.447368 | 0 | 0 | 0 | 0 | 0 | 0.463415 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
acb64bdcebe8ab099b63628f0507174270cc8738 | 174 | py | Python | DesmOEIS/__init__.py | CascadeIllusion/DesmOEIS | 831bc835966d3b1423ef207cc998d7c5bbff0fab | [
"MIT"
] | null | null | null | DesmOEIS/__init__.py | CascadeIllusion/DesmOEIS | 831bc835966d3b1423ef207cc998d7c5bbff0fab | [
"MIT"
] | null | null | null | DesmOEIS/__init__.py | CascadeIllusion/DesmOEIS | 831bc835966d3b1423ef207cc998d7c5bbff0fab | [
"MIT"
] | null | null | null | from DesmOEIS.console import main
from parsing import parse_id, find_id, parse_integers
from desmos import create_expression, create_desmos_list
from sequence import Sequence | 43.5 | 56 | 0.873563 | 26 | 174 | 5.615385 | 0.576923 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.103448 | 174 | 4 | 57 | 43.5 | 0.935897 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
acd06bc47fd5f969341e3e25c18bec8fa5a1998e | 143 | py | Python | littlenn/layers/__init__.py | qbeer/littlenn | e783cb5d713f5669449fa993b3001848c028309b | [
"MIT"
] | null | null | null | littlenn/layers/__init__.py | qbeer/littlenn | e783cb5d713f5669449fa993b3001848c028309b | [
"MIT"
] | null | null | null | littlenn/layers/__init__.py | qbeer/littlenn | e783cb5d713f5669449fa993b3001848c028309b | [
"MIT"
] | null | null | null | from .dense import Dense
from .dropout import Dropout
from .batch_norm import BatchNorm
from .flatten import Flatten
from .conv2d import Conv2D | 28.6 | 33 | 0.832168 | 21 | 143 | 5.619048 | 0.428571 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.016129 | 0.132867 | 143 | 5 | 34 | 28.6 | 0.935484 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
acda256dc7ae42496ec51611727cb6b58df3437c | 26 | py | Python | tests/api/chats/test_friend.py | yylingyun/wxpy | ab63e12da822dc85615fa203e5be9fa28ae0b59f | [
"MIT"
] | 14,391 | 2017-02-21T01:57:11.000Z | 2022-03-31T07:51:04.000Z | tests/api/chats/test_friend.py | yylingyun/wxpy | ab63e12da822dc85615fa203e5be9fa28ae0b59f | [
"MIT"
] | 443 | 2017-03-02T04:32:03.000Z | 2020-08-02T11:42:33.000Z | tests/api/chats/test_friend.py | yylingyun/wxpy | ab63e12da822dc85615fa203e5be9fa28ae0b59f | [
"MIT"
] | 2,645 | 2017-02-21T05:55:27.000Z | 2022-03-31T09:04:17.000Z | class TestFriend:
pass | 13 | 17 | 0.730769 | 3 | 26 | 6.333333 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.230769 | 26 | 2 | 18 | 13 | 0.95 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0.5 | 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 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 5 |
ace2611ed4bd1c4014d8eb90901fef85a20fce58 | 1,561 | py | Python | DailyProgrammer/DP20121030C.py | DayGitH/Python-Challenges | bc32f1332a92fcc2dfa6f5ea4d95f8a8d64c3edf | [
"MIT"
] | 2 | 2020-12-23T18:59:22.000Z | 2021-04-14T13:16:09.000Z | DailyProgrammer/DP20121030C.py | DayGitH/Python-Challenges | bc32f1332a92fcc2dfa6f5ea4d95f8a8d64c3edf | [
"MIT"
] | null | null | null | DailyProgrammer/DP20121030C.py | DayGitH/Python-Challenges | bc32f1332a92fcc2dfa6f5ea4d95f8a8d64c3edf | [
"MIT"
] | null | null | null | """
[10/30/2012] Challenge #109 [Difficult] Death Mountains
https://www.reddit.com/r/dailyprogrammer/comments/12csl5/10302012_challenge_109_difficult_death_mountains/
**Description:**
You are a proud explorer, walking towards a range of mountains. These mountains, as they appear to you, are a series of
isosceles triangles all clustered on the horizon. [Check out this example image](http://imgur.com/a/lyhMt), sketched by
your awesome aid nint22 (smiling-mountain not important). Your goal, given the position of the base of these triangles,
how tall they are, and their base-width, is to compute the overall unique area. Note that you should not count areas
that have overlapping mountains - you only care about what you can see (i.e. only count the purple areas once in the
[example image](http://imgur.com/a/lyhMt)).
**Formal Inputs & Outputs:**
*Input Description:*
Integer n - The number of triangles
Array of triangles T - An array of triangles, where each triangle has a position (float x), a base-length (float
width), and a triangle-height (float height).
*Output Description:*
Print the area of the triangles you see (without measuring overlap more than once), accurate to the second decimal
digit.
**Sample Inputs & Outputs:**
Todo... will have to solve this myself (which is pretty dang hard).
**Notes:**
It is critically important to NOT count overlapped triangle areas more than once. Again, only count the purple areas
once in the [example image](http://imgur.com/a/lyhMt)..
"""
def main():
pass
if __name__ == "__main__":
main()
| 44.6 | 119 | 0.759769 | 246 | 1,561 | 4.768293 | 0.560976 | 0.030691 | 0.040921 | 0.053708 | 0.190963 | 0.131287 | 0.131287 | 0.105712 | 0.105712 | 0.105712 | 0 | 0.020331 | 0.149263 | 1,561 | 34 | 120 | 45.911765 | 0.862952 | 0.953876 | 0 | 0 | 0 | 0 | 0.125 | 0 | 0 | 0 | 0 | 0.029412 | 0 | 1 | 0.25 | true | 0.25 | 0 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 5 |
4a1a6f1f8799e7096e391137961093d55cb289cb | 372 | py | Python | mushroom/__init__.py | ML2R-center/mushroom | 07fe4f43fd7bb7ebdec71db8f75e0a9b87573e00 | [
"MIT"
] | 2 | 2019-02-28T04:56:29.000Z | 2020-09-01T07:52:35.000Z | mushroom/__init__.py | ML2R-center/mushroom | 07fe4f43fd7bb7ebdec71db8f75e0a9b87573e00 | [
"MIT"
] | 1 | 2020-02-15T03:15:04.000Z | 2022-03-24T05:21:08.000Z | mushroom/__init__.py | ML2R-center/mushroom | 07fe4f43fd7bb7ebdec71db8f75e0a9b87573e00 | [
"MIT"
] | 2 | 2019-12-05T03:15:46.000Z | 2021-01-12T11:23:35.000Z | from mushroom.result_analysis import get_accuracy_precision_recall_from_series
from mushroom.result_analysis import analysis_with_different_length_stems
from mushroom.result_analysis import get_accuracy_precision_recall_from_series_with_stem_length
from mushroom.core import mushroom_triple_classification_with_different_pars
from mushroom.util import download_nball_files | 74.4 | 95 | 0.935484 | 52 | 372 | 6.173077 | 0.442308 | 0.186916 | 0.168224 | 0.242991 | 0.523364 | 0.423676 | 0.423676 | 0.423676 | 0.423676 | 0.423676 | 0 | 0 | 0.051075 | 372 | 5 | 96 | 74.4 | 0.909348 | 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 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
c5866309c0601fa07a25bccf1b832dee9aa748fb | 25 | py | Python | src/dlist/__init__.py | dyf/dlist | bcc944b7b18f194f543e4c16c6b33a8688a98937 | [
"MIT"
] | null | null | null | src/dlist/__init__.py | dyf/dlist | bcc944b7b18f194f543e4c16c6b33a8688a98937 | [
"MIT"
] | null | null | null | src/dlist/__init__.py | dyf/dlist | bcc944b7b18f194f543e4c16c6b33a8688a98937 | [
"MIT"
] | null | null | null | from .dlist import dlist
| 12.5 | 24 | 0.8 | 4 | 25 | 5 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.16 | 25 | 1 | 25 | 25 | 0.952381 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
c5a79c026544e11e67508952fc2ed9fe0347bb58 | 366 | py | Python | stric/datasets/__init__.py | LucaZancato/stric | 8daeeca48b8d0b2db8156e7f1c66c0956c133353 | [
"Apache-2.0"
] | null | null | null | stric/datasets/__init__.py | LucaZancato/stric | 8daeeca48b8d0b2db8156e7f1c66c0956c133353 | [
"Apache-2.0"
] | null | null | null | stric/datasets/__init__.py | LucaZancato/stric | 8daeeca48b8d0b2db8156e7f1c66c0956c133353 | [
"Apache-2.0"
] | null | null | null | from .yahoo_dataset import YahooDataset
from .co2_dataset import CO2Dataset
from .m4_dataset import M4Dataset
from .nab_dataset import NABDataset
from .nasa_dataset import NASADataset
from .nonlinear_sysid_benchmark import NonlinearBenchmark
from .smd_dataset import SMDDataset
from .synthetic_dataset import SyntheticDataset
from .UCI_benchmark import UCIBenchmark
| 36.6 | 57 | 0.877049 | 46 | 366 | 6.76087 | 0.5 | 0.292605 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012121 | 0.098361 | 366 | 9 | 58 | 40.666667 | 0.930303 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
c5ee8958991c9b3e140a37a79761da6818164543 | 267 | py | Python | src/models/downsamples/__init__.py | takedarts/skipresnet | d6f1e16042f8433a287355009e17e4e5768ad319 | [
"MIT"
] | 3 | 2022-02-03T13:25:12.000Z | 2022-02-04T16:12:23.000Z | src/models/downsamples/__init__.py | takedarts/skipresnet | d6f1e16042f8433a287355009e17e4e5768ad319 | [
"MIT"
] | null | null | null | src/models/downsamples/__init__.py | takedarts/skipresnet | d6f1e16042f8433a287355009e17e4e5768ad319 | [
"MIT"
] | 1 | 2022-02-04T12:28:02.000Z | 2022-02-04T12:28:02.000Z | from .average import AverageDownsample
from .average_linear import AverageLinearDownsample
from .convnext import ConvNeXtDownsample
from .linear import LinearDownsample
from .nfnet import NFDownsample
from .none import NoneDownsample
from .swin import SwinDownsample
| 33.375 | 51 | 0.868914 | 29 | 267 | 7.965517 | 0.517241 | 0.095238 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.104869 | 267 | 7 | 52 | 38.142857 | 0.966527 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
a85ff35101832f192a4fa2d8e89305ac9c248d38 | 106 | py | Python | bgpfu/prefixlist/__init__.py | grizz/bgpfu | e88ccc3aa201e37e492f7a506d3c94ff1bb46995 | [
"Apache-2.0"
] | null | null | null | bgpfu/prefixlist/__init__.py | grizz/bgpfu | e88ccc3aa201e37e492f7a506d3c94ff1bb46995 | [
"Apache-2.0"
] | 1 | 2018-04-20T16:42:22.000Z | 2020-05-26T11:24:36.000Z | bgpfu/prefixlist/__init__.py | grizz/bgpfu | e88ccc3aa201e37e492f7a506d3c94ff1bb46995 | [
"Apache-2.0"
] | null | null | null |
# namespace
from base import PrefixListBase
from simple import SimplePrefixList
from set import PrefixSet | 21.2 | 35 | 0.858491 | 13 | 106 | 7 | 0.692308 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.132075 | 106 | 5 | 36 | 21.2 | 0.98913 | 0.084906 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
a87c1e32628f70eab4e4d0da312fcf320a9fd464 | 11,479 | py | Python | challengeutils/synapseservices/discussion.py | Sage-Bionetworks/challengeutils | 72b1af6e4ee85751b9e772b0a5260915a859106c | [
"Apache-2.0"
] | 5 | 2020-02-17T20:31:17.000Z | 2021-09-06T21:16:50.000Z | challengeutils/synapseservices/discussion.py | Sage-Bionetworks/challengeutils | 72b1af6e4ee85751b9e772b0a5260915a859106c | [
"Apache-2.0"
] | 146 | 2018-11-13T21:47:26.000Z | 2022-03-12T06:58:05.000Z | challengeutils/synapseservices/discussion.py | Sage-Bionetworks/challengeutils | 72b1af6e4ee85751b9e772b0a5260915a859106c | [
"Apache-2.0"
] | 6 | 2018-10-18T16:20:24.000Z | 2020-05-07T23:12:28.000Z | from .base_service import Service, deserialize_model
class Forum(Service):
def __init__(self, id=None, projectId=None, etag=None):
self.openapi_types = {
'id': str,
'projectid': str,
'etag': str
}
self.attribute_map = {
'id': 'id',
'projectid': 'projectId',
'etag': 'etag'
}
self._id = id
self._projectid = projectId
self._etag = etag
@classmethod
def from_dict(cls, dikt) -> 'Forum':
"""Returns the dict as a model"""
return deserialize_model(dikt, cls)
@property
def id(self):
"""The `id` property of this Challenge."""
return self._id
@id.setter
def id(self, value):
self._id = value
@property
def projectid(self):
"""The `projectId` property of this Challenge."""
return self._projectid
@projectid.setter
def projectid(self, value):
if value is None:
raise ValueError("Invalid value for `projectid`, must not be `None`") # noqa: E501
self._projectid = value
@property
def etag(self):
"""The `etag` property of this Challenge."""
return self._etag
@etag.setter
def etag(self, value):
self._etag = value
class Thread(Service):
def __init__(
self, id: str = None, forumId: str = None, projectId: str = None,
title: str = None, createdOn: str = None, createdBy: str = None,
modifiedOn: str = None, etag: str = None, messageKey: str = None,
numberOfViews: int = None, numberOfReplies: int = None,
lastActivity: str = None, activeAuthors: list = None,
isEdited: bool = False, isDeleted: bool = False,
isPinned: bool = False
):
self.openapi_types = {
'id': str,
'forumid': str,
'projectid': str,
'title': str,
'createdon': str,
'createdby': str,
'modifiedon': str,
'etag': str,
'messagekey': str,
'number_of_views': int,
'number_of_replies': int,
'last_activity': str,
'active_authors': list,
'is_edited': bool,
'is_deleted': bool,
'is_pinned': bool
}
self.attribute_map = {
'id': 'id',
'forumid': 'forumId',
'projectid': 'projectId',
'title': 'title',
'createdon': 'createdOn',
'createdby': 'createdBy',
'modifiedon': 'modifiedOn',
'etag': 'etag',
'messagekey': 'messageKey',
'number_of_views': 'numberOfViews',
'number_of_replies': 'numberOfReplies',
'last_activity': 'lastActivity',
'active_authors': 'activeAuthors',
'is_edited': 'isEdited',
'is_deleted': 'isDeleted',
'is_pinned': 'isPinned'
}
self._id = id
self._forumid = forumId
self._projectid = projectId
self._title = title
self._createdon = createdOn
self._createdby = createdBy
self._modifiedon = modifiedOn
self._etag = etag
self._messagekey = messageKey
self._number_of_views = numberOfViews
self._number_of_replies = numberOfReplies
self._last_activity = lastActivity
self._active_authors = activeAuthors
self._is_edited = isEdited
self._is_deleted = isDeleted
self._is_pinned = isPinned
@classmethod
def from_dict(cls, dikt) -> 'Thread':
"""Returns the dict as a model"""
return deserialize_model(dikt, cls)
@property
def id(self):
"""The `id` property of this Challenge."""
return self._id
@id.setter
def id(self, value):
self._id = value
@property
def forumid(self):
"""The `forumid` property of this Challenge."""
return self._forumid
@forumid.setter
def forumid(self, value):
self._forumid = value
@property
def projectid(self):
"""The `projectid` property of this Challenge."""
return self._projectid
@projectid.setter
def projectid(self, value):
if value is None:
raise ValueError("Invalid value for `projectid`, must not be `None`") # noqa: E501
self._projectid = value
@property
def title(self):
"""The `title` property of this Challenge."""
return self._title
@title.setter
def title(self, value):
self._title = value
@property
def createdon(self):
"""The `createdon` property of this Challenge."""
return self._createdon
@createdon.setter
def createdon(self, value):
self._createdon = value
@property
def createdby(self):
"""The `createdby` property of this Challenge."""
return self._createdby
@createdby.setter
def createdby(self, value):
self._createdby = value
@property
def modifiedon(self):
"""The `modifiedon` property of this Challenge."""
return self._modifiedon
@modifiedon.setter
def modifiedon(self, value):
self._modifiedon = value
@property
def etag(self):
"""The `etag` property of this Challenge."""
return self._etag
@etag.setter
def etag(self, value):
self._etag = value
@property
def messagekey(self):
"""The `projectId` property of this Challenge."""
return self._messagekey
@messagekey.setter
def messagekey(self, value):
self._messagekey = value
@property
def number_of_views(self):
"""The `number_of_views` property of this Challenge."""
return self._number_of_views
@number_of_views.setter
def number_of_views(self, value):
self._number_of_views = value
@property
def number_of_replies(self):
"""The `number_of_replies` property of this Challenge."""
return self._number_of_replies
@number_of_replies.setter
def number_of_replies(self, value):
self._number_of_replies = value
@property
def last_activity(self):
"""The `last_activity` property of this Challenge."""
return self._last_activity
@last_activity.setter
def last_activity(self, value):
self._last_activity = value
@property
def active_authors(self):
"""The `active_authors` property of this Challenge."""
return self._active_authors
@active_authors.setter
def active_authors(self, value):
self._active_authors = value
@property
def is_edited(self):
"""The `is_edited` property of this Challenge."""
return self._is_edited
@is_edited.setter
def is_edited(self, value):
self._is_edited = value
@property
def is_deleted(self):
"""The `is_deleted` property of this Challenge."""
return self._is_deleted
@is_deleted.setter
def is_deleted(self, value):
self._is_deleted = value
@property
def is_pinned(self):
"""The `is_deleted` property of this Challenge."""
return self._is_pinned
@is_pinned.setter
def is_pinned(self, value):
self._is_pinned = value
class Reply(Service):
def __init__(
self, id: str = None, threadId: str = None, forumId: str = None,
projectId: str = None, createdOn: str = None,
createdBy: str = None, modifiedOn: str = None, etag: str = None,
messageKey: str = None, isEdited: bool = False,
isDeleted: bool = False
):
self.openapi_types = {
'id': str,
'threadid': str,
'forumid': str,
'projectid': str,
'createdon': str,
'createdby': str,
'modifiedon': str,
'etag': str,
'messagekey': str,
'is_edited': bool,
'is_deleted': bool,
}
self.attribute_map = {
'id': 'id',
'threadid': 'threadId',
'forumid': 'forumId',
'projectid': 'projectId',
'createdon': 'createdOn',
'createdby': 'createdBy',
'modifiedon': 'modifiedOn',
'etag': 'etag',
'messagekey': 'messageKey',
'is_edited': 'isEdited',
'is_deleted': 'isDeleted',
}
self._id = id
self._threadid = threadId
self._forumid = forumId
self._projectid = projectId
self._createdon = createdOn
self._createdby = createdBy
self._modifiedon = modifiedOn
self._etag = etag
self._messagekey = messageKey
self._is_edited = isEdited
self._is_deleted = isDeleted
@classmethod
def from_dict(cls, dikt) -> 'Thread':
"""Returns the dict as a model"""
return deserialize_model(dikt, cls)
@property
def id(self):
"""The `id` property of this Challenge."""
return self._id
@id.setter
def id(self, value):
self._id = value
@property
def threadid(self):
"""The `threadid` property of this Challenge."""
return self._threadid
@threadid.setter
def threadid(self, value):
self._threadid = value
@property
def forumid(self):
"""The `forumid` property of this Challenge."""
return self._forumid
@forumid.setter
def forumid(self, value):
self._forumid = value
@property
def projectid(self):
"""The `projectid` property of this Challenge."""
return self._projectid
@projectid.setter
def projectid(self, value):
if value is None:
raise ValueError("Invalid value for `projectid`, must not be `None`") # noqa: E501
self._projectid = value
@property
def createdon(self):
"""The `createdon` property of this Challenge."""
return self._createdon
@createdon.setter
def createdon(self, value):
self._createdon = value
@property
def createdby(self):
"""The `createdby` property of this Challenge."""
return self._createdby
@createdby.setter
def createdby(self, value):
self._createdby = value
@property
def modifiedon(self):
"""The `modifiedon` property of this Challenge."""
return self._modifiedon
@modifiedon.setter
def modifiedon(self, value):
self._modifiedon = value
@property
def etag(self):
"""The `etag` property of this Challenge."""
return self._etag
@etag.setter
def etag(self, value):
self._etag = value
@property
def messagekey(self):
"""The `projectId` property of this Challenge."""
return self._messagekey
@messagekey.setter
def messagekey(self, value):
self._messagekey = value
@property
def is_edited(self):
"""The `is_edited` property of this Challenge."""
return self._is_edited
@is_edited.setter
def is_edited(self, value):
self._is_edited = value
@property
def is_deleted(self):
"""The `is_deleted` property of this Challenge."""
return self._is_deleted
@is_deleted.setter
def is_deleted(self, value):
self._is_deleted = value
| 26.510393 | 95 | 0.574876 | 1,201 | 11,479 | 5.31557 | 0.063281 | 0.051692 | 0.065789 | 0.108083 | 0.792607 | 0.756109 | 0.705514 | 0.665414 | 0.629543 | 0.629543 | 0 | 0.001149 | 0.317362 | 11,479 | 432 | 96 | 26.571759 | 0.813553 | 0.123704 | 0 | 0.742138 | 0 | 0 | 0.092508 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.207547 | false | 0 | 0.003145 | 0 | 0.323899 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
a87e06950048b966a663821ee63ccb72f211bf0d | 83 | py | Python | csdl/std/arcsch.py | LSDOlab/csdl | 04c2c5764f6ca9b865ec87ecfeaf6f22ecacc5a3 | [
"MIT"
] | null | null | null | csdl/std/arcsch.py | LSDOlab/csdl | 04c2c5764f6ca9b865ec87ecfeaf6f22ecacc5a3 | [
"MIT"
] | null | null | null | csdl/std/arcsch.py | LSDOlab/csdl | 04c2c5764f6ca9b865ec87ecfeaf6f22ecacc5a3 | [
"MIT"
] | 1 | 2021-10-04T19:40:32.000Z | 2021-10-04T19:40:32.000Z | from csdl.std.log import log
def arcsch(x):
log(1 / x + (1 / x**2 + 1)**0.5)
| 13.833333 | 36 | 0.53012 | 18 | 83 | 2.444444 | 0.666667 | 0.090909 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.096774 | 0.253012 | 83 | 5 | 37 | 16.6 | 0.612903 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.333333 | 0 | 0.666667 | 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 | 1 | 0 | 1 | 0 | 0 | 5 |
a880cfc5a612b5e51340640b6821f292918c636f | 66 | py | Python | gym_brt/envs/simulation/mujoco/__init__.py | Data-Science-in-Mechanical-Engineering/vision-based-furuta-pendulum | 84bfc5a089a2a8ace250f030f0298d45a3f9772f | [
"MIT"
] | null | null | null | gym_brt/envs/simulation/mujoco/__init__.py | Data-Science-in-Mechanical-Engineering/vision-based-furuta-pendulum | 84bfc5a089a2a8ace250f030f0298d45a3f9772f | [
"MIT"
] | null | null | null | gym_brt/envs/simulation/mujoco/__init__.py | Data-Science-in-Mechanical-Engineering/vision-based-furuta-pendulum | 84bfc5a089a2a8ace250f030f0298d45a3f9772f | [
"MIT"
] | null | null | null | from gym_brt.envs.simulation.mujoco.qube_mujoco import QubeMujoco
| 33 | 65 | 0.878788 | 10 | 66 | 5.6 | 0.9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.060606 | 66 | 1 | 66 | 66 | 0.903226 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 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 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 5 |
a89610cf54a34479154d33a419ee7f80ee6fa356 | 433 | py | Python | threads/views.py | making3/summonerqa | 7ab8472b2d24236ba1e6919fa0f00881f4a3e633 | [
"MIT"
] | null | null | null | threads/views.py | making3/summonerqa | 7ab8472b2d24236ba1e6919fa0f00881f4a3e633 | [
"MIT"
] | null | null | null | threads/views.py | making3/summonerqa | 7ab8472b2d24236ba1e6919fa0f00881f4a3e633 | [
"MIT"
] | null | null | null | from django.http import HttpResponse
from django.shortcuts import render
from comments.models import Comment
def index(request):
# TODO: Implement list of threads (possible datatables filtering again).
return HttpResponse("Hello....")
def comments(request, thread_id):
comments = Comment.objects.filter(thread=thread_id)
context = { 'comments': comments }
return render(request, 'threads/index.html', context)
| 30.928571 | 76 | 0.750577 | 52 | 433 | 6.211538 | 0.576923 | 0.06192 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.150115 | 433 | 13 | 77 | 33.307692 | 0.877717 | 0.161663 | 0 | 0 | 0 | 0 | 0.096953 | 0 | 0 | 0 | 0 | 0.076923 | 0 | 1 | 0.222222 | false | 0 | 0.333333 | 0.111111 | 0.777778 | 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 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 5 |
a8bdaa1a7840e5d1398c4c06dba7c9b888af70ca | 130 | py | Python | Desafio 13.py | MoomenEltelbany/PythonDesafios | aa2f44d3104cf3607f58dc42c2f8fc8023f128de | [
"MIT"
] | null | null | null | Desafio 13.py | MoomenEltelbany/PythonDesafios | aa2f44d3104cf3607f58dc42c2f8fc8023f128de | [
"MIT"
] | null | null | null | Desafio 13.py | MoomenEltelbany/PythonDesafios | aa2f44d3104cf3607f58dc42c2f8fc8023f128de | [
"MIT"
] | null | null | null | salario = float(input('Digite o seu salário: '))
print(f'O seu salario novo com 15% de aumento é {salario+ (salario*0.15):.2f}')
| 32.5 | 79 | 0.684615 | 23 | 130 | 3.869565 | 0.73913 | 0.089888 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.054054 | 0.146154 | 130 | 3 | 80 | 43.333333 | 0.747748 | 0 | 0 | 0 | 0 | 0.5 | 0.7 | 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 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 5 |
a8c67eb546ab3b25c2d47336ada94ca81b7118d7 | 31 | py | Python | genie_core/services/GamepadService.py | JereMIbq1995/genie-core | f87b6de56749630a46200298f7021047e854c8a3 | [
"MIT"
] | null | null | null | genie_core/services/GamepadService.py | JereMIbq1995/genie-core | f87b6de56749630a46200298f7021047e854c8a3 | [
"MIT"
] | null | null | null | genie_core/services/GamepadService.py | JereMIbq1995/genie-core | f87b6de56749630a46200298f7021047e854c8a3 | [
"MIT"
] | null | null | null |
class GamepadService:
pass | 10.333333 | 21 | 0.741935 | 3 | 31 | 7.666667 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.225806 | 31 | 3 | 22 | 10.333333 | 0.958333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0.5 | 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 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 5 |
763b983c4ae72b797d2817ee983cf1cbf1ce8188 | 1,554 | py | Python | tests/test_markdown.py | PlaidWeb/Publ | 67efc5e32bf25dbac72a83d1167de038b79db5a7 | [
"MIT"
] | 27 | 2018-11-30T21:32:26.000Z | 2022-03-20T19:46:25.000Z | tests/test_markdown.py | PlaidWeb/Publ | 67efc5e32bf25dbac72a83d1167de038b79db5a7 | [
"MIT"
] | 249 | 2018-09-30T07:04:37.000Z | 2022-03-29T04:31:00.000Z | tests/test_markdown.py | fluffy-critter/Publ | 868c5a17c605707dde4d1a95d79405301bd12f05 | [
"MIT"
] | 4 | 2019-03-01T06:46:13.000Z | 2019-06-30T17:45:46.000Z | """ Tests of Markdown renderer """
# pylint:disable=missing-function-docstring
from publ import markdown
from . import PublMock
def test_render_title():
app = PublMock()
with app.app_context():
assert markdown.render_title("This *is* a test") == "This <em>is</em> a test"
assert markdown.render_title("This *is* a test", markup=False) == "This is a test"
assert markdown.render_title("This is ~~not~~ a test", markup=False) == "This is a test"
assert markdown.render_title("This is <s>not</s> a test", markup=False) == "This is a test"
assert markdown.render_title("This & That", markup=False) == "This & That"
assert markdown.render_title("This & That", markup=True) == "This & That"
assert markdown.render_title('The "sun" is a liberal myth',
markup=False,
smartquotes=False) == 'The "sun" is a liberal myth'
assert markdown.render_title('The "sun" is a liberal myth',
markup=False,
smartquotes=True) == 'The “sun” is a liberal myth'
assert markdown.render_title('The "sun" is a liberal myth',
markup=True, smartquotes=False) == \
'The "sun" is a liberal myth'
assert markdown.render_title('The "sun" is a liberal myth',
markup=True, smartquotes=True) == \
'The “sun” is a liberal myth'
| 50.129032 | 99 | 0.566281 | 191 | 1,554 | 4.539267 | 0.209424 | 0.044983 | 0.230681 | 0.288351 | 0.716263 | 0.707036 | 0.707036 | 0.650519 | 0.567474 | 0.567474 | 0 | 0 | 0.315959 | 1,554 | 30 | 100 | 51.8 | 0.815616 | 0.045045 | 0 | 0.26087 | 0 | 0 | 0.291131 | 0 | 0 | 0 | 0 | 0 | 0.434783 | 1 | 0.043478 | false | 0 | 0.086957 | 0 | 0.130435 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
763e1212c3687c4335f7b6d052bb94ec4f1ddd85 | 464 | py | Python | build/android/pylib/base/test_server.py | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2,219 | 2018-03-26T02:57:34.000Z | 2022-03-31T00:27:59.000Z | build/android/pylib/base/test_server.py | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 250 | 2018-02-02T23:16:57.000Z | 2022-03-21T06:09:53.000Z | build/android/pylib/base/test_server.py | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 473 | 2019-03-24T16:34:23.000Z | 2022-03-31T02:01:05.000Z | # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
class TestServer(object):
"""Base class for any server that needs to be set up for the tests."""
def __init__(self, *args, **kwargs):
pass
def SetUp(self):
raise NotImplementedError
def Reset(self):
raise NotImplementedError
def TearDown(self):
raise NotImplementedError
| 24.421053 | 72 | 0.724138 | 66 | 464 | 5.030303 | 0.742424 | 0.081325 | 0.253012 | 0.186747 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010811 | 0.202586 | 464 | 18 | 73 | 25.777778 | 0.886486 | 0.476293 | 0 | 0.333333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.444444 | false | 0.111111 | 0 | 0 | 0.555556 | 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 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 5 |
76458f239c17efc5181709e945e478fe3930e6de | 88 | py | Python | tests/test_category.py | mwerumuchai/one-minute-pitch | f7533e6040cd34dd18519798a4678bb622b548ff | [
"MIT"
] | null | null | null | tests/test_category.py | mwerumuchai/one-minute-pitch | f7533e6040cd34dd18519798a4678bb622b548ff | [
"MIT"
] | null | null | null | tests/test_category.py | mwerumuchai/one-minute-pitch | f7533e6040cd34dd18519798a4678bb622b548ff | [
"MIT"
] | 2 | 2017-11-05T11:55:55.000Z | 2019-11-26T11:31:00.000Z | # from app.models import Category
# from app import db
#
# def setUp(self):
# self.
| 14.666667 | 33 | 0.659091 | 13 | 88 | 4.461538 | 0.692308 | 0.241379 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.227273 | 88 | 5 | 34 | 17.6 | 0.852941 | 0.875 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 1 | 0 | 0 | null | 1 | 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 | 5 |
767cfc6f1ad2edb3183ea3474eaf71b3c4516880 | 48 | py | Python | bace/classifiers/bayesian/__init__.py | fsmb/bace | 019562479f83bf4ceebf8c8f35ecec216f907c1a | [
"MIT"
] | null | null | null | bace/classifiers/bayesian/__init__.py | fsmb/bace | 019562479f83bf4ceebf8c8f35ecec216f907c1a | [
"MIT"
] | 1 | 2019-04-03T18:26:35.000Z | 2019-04-03T18:26:35.000Z | bace/classifiers/bayesian/__init__.py | fsmb/bace | 019562479f83bf4ceebf8c8f35ecec216f907c1a | [
"MIT"
] | 1 | 2019-04-10T00:52:41.000Z | 2019-04-10T00:52:41.000Z | # print(f'Invoking __init__.py for {__name__}')
| 24 | 47 | 0.729167 | 7 | 48 | 3.857143 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.104167 | 48 | 1 | 48 | 48 | 0.627907 | 0.9375 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 1 | 1 | 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 | 5 |
76813e6074808addf5e1bc4767afdb48297633c3 | 45 | py | Python | run.py | Gordon003/COMP3900 | d9425f18a0246fb3658ea1c099d3f1e17af8e151 | [
"MIT"
] | null | null | null | run.py | Gordon003/COMP3900 | d9425f18a0246fb3658ea1c099d3f1e17af8e151 | [
"MIT"
] | null | null | null | run.py | Gordon003/COMP3900 | d9425f18a0246fb3658ea1c099d3f1e17af8e151 | [
"MIT"
] | null | null | null | from routes import app
app.run(debug = True) | 15 | 22 | 0.755556 | 8 | 45 | 4.25 | 0.875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.155556 | 45 | 3 | 23 | 15 | 0.894737 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
76aad0ae3f92584021eb50560ec437657f507e2f | 24,454 | py | Python | digifarming/digifarming/migrations/0001_initial.py | gatirobi/digifarming | d3348c0df6680282ba0705503d45ca94548be02b | [
"MIT"
] | null | null | null | digifarming/digifarming/migrations/0001_initial.py | gatirobi/digifarming | d3348c0df6680282ba0705503d45ca94548be02b | [
"MIT"
] | null | null | null | digifarming/digifarming/migrations/0001_initial.py | gatirobi/digifarming | d3348c0df6680282ba0705503d45ca94548be02b | [
"MIT"
] | null | null | null | # Generated by Django 3.0.5 on 2020-04-14 21:43
import digifarming.managers
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import hashid_field.field
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0011_update_proxy_permissions'),
]
operations = [
migrations.CreateModel(
name='ArrivalView',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
],
options={
'db_table': 'ArrivalsView',
'managed': False,
},
),
migrations.CreateModel(
name='DepartureView',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
],
options={
'db_table': 'DeparturesView',
'managed': False,
},
),
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('email', models.EmailField(max_length=254, unique=True)),
('phone', models.CharField(max_length=50)),
('id_number', models.CharField(max_length=50)),
('gender', models.CharField(choices=[('Female', 'Female'), ('Male', 'Male')], max_length=100)),
('created_on', models.DateTimeField(default=django.utils.timezone.now)),
('is_staff', models.BooleanField(default=False)),
('is_client', models.BooleanField(default=False)),
('is_superuser', models.BooleanField(default=False)),
('is_active', models.BooleanField(default=True)),
('status', models.IntegerField(default=1)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
],
options={
'abstract': False,
},
managers=[
('objects', digifarming.managers.UserManager()),
],
),
migrations.CreateModel(
name='Client',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('client_full_name', models.CharField(max_length=100)),
('client_phone', models.CharField(max_length=100)),
('client_email', models.EmailField(max_length=100, unique=True)),
('client_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('client_status', models.IntegerField(default=1)),
('client_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Commodity',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('commodity_name', models.CharField(max_length=100)),
('commodity_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('commodity_status', models.IntegerField(default=1)),
],
),
migrations.CreateModel(
name='CommodityCategory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('commodity_category_name', models.CharField(max_length=100)),
('commodity_category_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('commodity_category_status', models.IntegerField(default=1)),
('commodity_category_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='CommodityMetric',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('commodity_metric_name', models.CharField(max_length=100)),
('commodity_metric_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('commodity_metric_status', models.IntegerField(default=1)),
('commodity_metric_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='CommodityType',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('commodity_type_name', models.CharField(max_length=100)),
('commodity_type_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('commodity_type_status', models.IntegerField(default=1)),
('commodity_category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.CommodityCategory')),
('commodity_type_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Facility',
fields=[
('id', hashid_field.field.HashidAutoField(alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', min_length=7, primary_key=True, serialize=False)),
('facility_name', models.CharField(max_length=50)),
('facility_location', models.CharField(max_length=50)),
('facility_capacity', models.IntegerField(max_length=50)),
('status', models.IntegerField(default=1)),
('created_on', models.DateTimeField(default=django.utils.timezone.now)),
('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='JobShift',
fields=[
('id', hashid_field.field.HashidAutoField(alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', min_length=7, primary_key=True, serialize=False)),
('job_shift', models.CharField(max_length=100)),
('shift_start_time', models.TimeField()),
('shift_end_time', models.TimeField()),
('created_on', models.DateTimeField(default=django.utils.timezone.now)),
('job_shift_status', models.IntegerField(default=1)),
('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='JobTitle',
fields=[
('id', hashid_field.field.HashidAutoField(alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', min_length=7, primary_key=True, serialize=False)),
('job_title', models.CharField(max_length=100)),
('job_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('job_title_status', models.IntegerField(default=1)),
('job_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Order',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('order_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('order_order_status', models.IntegerField(default=0)),
('order_paid', models.BooleanField(default=False)),
('order_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='TransportCategory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('transport_category_name', models.CharField(max_length=100)),
('transport_category_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('transport_category_status', models.IntegerField(default=1)),
('transport_category_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='UserTrackingMovements',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('user_tracking_status', models.CharField(max_length=100)),
('user_tracking_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('user_tracking', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('user_tracking_facility', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.Facility')),
],
),
migrations.CreateModel(
name='TransportType',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('transport_type_name', models.CharField(max_length=100)),
('transport_type_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('transport_type_status', models.IntegerField(default=1)),
('transport_category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.CommodityCategory')),
('transport_type_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='TransportItems',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('transport_name', models.CharField(max_length=100)),
('transport_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('transport_status', models.IntegerField(default=1)),
('transport_category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.TransportCategory')),
('transport_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('transport_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.TransportType')),
],
),
migrations.CreateModel(
name='Supply',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('supply_quantity', models.IntegerField()),
('supply_cost', models.IntegerField()),
('supply_destination', models.CharField(max_length=100)),
('supply_latitude', models.CharField(max_length=100)),
('supply_longitude', models.CharField(max_length=100)),
('supply_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('supply_client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.Client')),
('supply_commodity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.Commodity')),
('supply_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('supply_metric', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.CommodityMetric')),
],
),
migrations.CreateModel(
name='Staff',
fields=[
('id', hashid_field.field.HashidAutoField(alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', min_length=7, primary_key=True, serialize=False)),
('staff_id', models.CharField(max_length=100)),
('is_hr', models.BooleanField(default=False)),
('staff_end_date', models.DateTimeField(blank=True, null=True)),
('staff_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='staff_created_by', to=settings.AUTH_USER_MODEL)),
('staff_job_shift', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.JobShift')),
('staff_job_tUsersitle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.JobTitle')),
('staff_user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='staff_user', to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='RequestType',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('request_type_name', models.CharField(max_length=50)),
('request_type_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('request_type_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Request',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('request_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('request_request_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.RequestType')),
('request_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Rating',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('rating', models.IntegerField()),
('rating_comment', models.TextField(blank=True)),
('rating_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('rating_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='OrderItem',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('order_item_quantity', models.IntegerField(default=1)),
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.Order')),
('order_item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.Commodity')),
('order_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.CommodityType')),
],
),
migrations.CreateModel(
name='Menu',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('meal_name', models.CharField(max_length=100)),
('meal_cost', models.IntegerField()),
('meal_image', models.ImageField(blank=True, null=True, upload_to='media/meal/')),
('meal_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('meal_status', models.IntegerField(default=1)),
('meal_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='HarvestDispatch',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('dispatch_quantity', models.IntegerField()),
('dispatch_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('dispatch_commodity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.Commodity')),
('dispatch_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='dispatcher', to=settings.AUTH_USER_MODEL)),
('dispatch_facility', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.Facility')),
('dispatch_metric', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.CommodityMetric')),
('dispatch_to_staff', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='receiver', to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='FacilityType',
fields=[
('id', hashid_field.field.HashidAutoField(alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', min_length=7, primary_key=True, serialize=False)),
('facility_type_name', models.CharField(max_length=100)),
('facility_type_status', models.IntegerField(default=1)),
('facility_type_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('facility_type_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddField(
model_name='facility',
name='facility_type',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.FacilityType'),
),
migrations.CreateModel(
name='CustomerTranportation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('customer_quantity', models.IntegerField()),
('customer_cost', models.IntegerField()),
('customer_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('customer_client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.Client')),
('customer_commodity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.Commodity')),
('customer_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('customer_metric', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.CommodityMetric')),
('customer_transport_item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.TransportItems')),
],
),
migrations.AddField(
model_name='commodity',
name='commodity_category',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.CommodityCategory'),
),
migrations.AddField(
model_name='commodity',
name='commodity_created_by',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='commodity',
name='commodity_type',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.CommodityType'),
),
migrations.CreateModel(
name='ClientType',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('client_type_name', models.CharField(max_length=100)),
('client_type_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('client_type_status', models.IntegerField(default=1)),
('client_type_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddField(
model_name='client',
name='client_type',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.ClientType'),
),
migrations.CreateModel(
name='Cleaning',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('cleaning_time', models.DateTimeField(default=django.utils.timezone.now)),
('cleaning_facility', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.Facility')),
('cleaning_staff', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Chat',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('chat_message', models.CharField(max_length=700, null=True)),
('chat_type', models.CharField(max_length=100)),
('chat_time', models.DateTimeField(default=django.utils.timezone.now)),
('chat_recipient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='chat_receiver', to=settings.AUTH_USER_MODEL)),
('chat_sender', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='chat_sender', to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='AlertType',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('alert_type_name', models.CharField(max_length=100)),
('alert_type_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('alert_type_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Alert',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('alert_message', models.TextField()),
('alert_created_on', models.DateTimeField(default=django.utils.timezone.now)),
('alert_created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('alert_title', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='digifarming.AlertType')),
],
),
]
| 61.442211 | 266 | 0.627791 | 2,444 | 24,454 | 6.068331 | 0.079378 | 0.031825 | 0.05475 | 0.086036 | 0.81714 | 0.776617 | 0.725305 | 0.678444 | 0.661722 | 0.627132 | 0 | 0.009936 | 0.23857 | 24,454 | 397 | 267 | 61.596977 | 0.786574 | 0.00184 | 0 | 0.464103 | 1 | 0 | 0.176056 | 0.06367 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.002564 | 0.015385 | 0 | 0.025641 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
4f29d5f371558f0b8773b5cb605f8964056902e2 | 178 | py | Python | src/mysite/administrator/admin.py | SnapdragonLee/Newbee-backend | 69ef9430511ce6e4d5026c52b2645e2ba18c978e | [
"Apache-2.0"
] | null | null | null | src/mysite/administrator/admin.py | SnapdragonLee/Newbee-backend | 69ef9430511ce6e4d5026c52b2645e2ba18c978e | [
"Apache-2.0"
] | null | null | null | src/mysite/administrator/admin.py | SnapdragonLee/Newbee-backend | 69ef9430511ce6e4d5026c52b2645e2ba18c978e | [
"Apache-2.0"
] | null | null | null | from django.contrib import admin
from .models import Question, SubQuestion, Solution
admin.site.register(Question)
admin.site.register(SubQuestion)
admin.site.register(Solution) | 29.666667 | 51 | 0.837079 | 23 | 178 | 6.478261 | 0.478261 | 0.181208 | 0.342282 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.073034 | 178 | 6 | 52 | 29.666667 | 0.90303 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.4 | 0 | 0.4 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
4f45d85432cac5ab0e378eabd4dee64ad297f656 | 135 | py | Python | vae-imports.py | rparkin1/VAE | 9bd92fd71b355cbf151f815bed4973c1d27203b4 | [
"MIT"
] | 1 | 2020-10-04T23:46:08.000Z | 2020-10-04T23:46:08.000Z | vae-imports.py | rparkin1/VAE | 9bd92fd71b355cbf151f815bed4973c1d27203b4 | [
"MIT"
] | null | null | null | vae-imports.py | rparkin1/VAE | 9bd92fd71b355cbf151f815bed4973c1d27203b4 | [
"MIT"
] | null | null | null | import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
%matplotlib inline
np.random.seed(0)
tf.set_random_seed(0) | 16.875 | 31 | 0.807407 | 24 | 135 | 4.458333 | 0.583333 | 0.186916 | 0.205607 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.016949 | 0.125926 | 135 | 8 | 32 | 16.875 | 0.889831 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.5 | null | null | 0 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
4f86308e21102fb2c298fb14ed78d634d0215da9 | 692 | py | Python | ryan/exp.py | ryanlee/projects | 2e23054b0842720000908e7e788eb563243d69e3 | [
"MIT"
] | null | null | null | ryan/exp.py | ryanlee/projects | 2e23054b0842720000908e7e788eb563243d69e3 | [
"MIT"
] | 3 | 2021-06-08T21:11:42.000Z | 2022-01-13T02:26:52.000Z | ryan/exp.py | ryanlee/projects | 2e23054b0842720000908e7e788eb563243d69e3 | [
"MIT"
] | null | null | null |
################################################################################
# exception
################################################################################
class RyanException() :
"""docstring for Exception"""
def __init__(self):
Exception.__init__(self)
class E (RyanException):
def __init__(self, text, **args):
self.text = text
self.args = args
def __repr__(self):
return ("[ERROR] %s = " % self.text) + repr(self.args)
class W (RyanException):
def __init__(self, text, **args):
self.text = text
self.args = args
def __repr__(self):
return ("[ERROR] %s = " % self.text) + repr(self.args)
| 30.086957 | 80 | 0.447977 | 62 | 692 | 4.612903 | 0.258065 | 0.167832 | 0.115385 | 0.167832 | 0.692308 | 0.692308 | 0.692308 | 0.692308 | 0.692308 | 0.692308 | 0 | 0 | 0.208092 | 692 | 22 | 81 | 31.454545 | 0.521898 | 0.049133 | 0 | 0.666667 | 0 | 0 | 0.053061 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0 | 0.133333 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 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 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 5 |
4fa955bd338360c1ceaf7bd92d08c7a99c11c4e6 | 1,829 | py | Python | RecoLocalCalo/Configuration/python/customizeEcalOnlyForProfiling.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 852 | 2015-01-11T21:03:51.000Z | 2022-03-25T21:14:00.000Z | RecoLocalCalo/Configuration/python/customizeEcalOnlyForProfiling.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 30,371 | 2015-01-02T00:14:40.000Z | 2022-03-31T23:26:05.000Z | RecoLocalCalo/Configuration/python/customizeEcalOnlyForProfiling.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 3,240 | 2015-01-02T05:53:18.000Z | 2022-03-31T17:24:21.000Z | import FWCore.ParameterSet.Config as cms
# Customise the ECAL-only reconstruction to run on GPU
#
# Currently, this means running only the unpacker and multifit, up to the uncalbrated rechits
def customizeEcalOnlyForProfilingGPUOnly(process):
process.consumer = cms.EDAnalyzer("GenericConsumer",
eventProducts = cms.untracked.vstring('ecalMultiFitUncalibRecHitGPU')
)
process.consume_step = cms.EndPath(process.consumer)
process.schedule = cms.Schedule(process.raw2digi_step, process.reconstruction_step, process.consume_step)
return process
# Customise the ECAL-only reconstruction to run on GPU, and copy the data to the host
#
# Currently, this means running only the unpacker and multifit, up to the uncalbrated rechits
def customizeEcalOnlyForProfilingGPUWithHostCopy(process):
process.consumer = cms.EDAnalyzer("GenericConsumer",
eventProducts = cms.untracked.vstring('ecalMultiFitUncalibRecHitSoA')
)
process.consume_step = cms.EndPath(process.consumer)
process.schedule = cms.Schedule(process.raw2digi_step, process.reconstruction_step, process.consume_step)
return process
# Customise the ECAL-only reconstruction to run on GPU, copy the data to the host, and convert to legacy format
#
# Currently, this means running only the unpacker and multifit, up to the uncalbrated rechits, on the GPU
# and the rechits producer on the CPU
#
# The same customisation can be also used on the CPU workflow, running up to the rechits on CPU.
def customizeEcalOnlyForProfiling(process):
process.consumer = cms.EDAnalyzer("GenericConsumer",
eventProducts = cms.untracked.vstring('ecalRecHit')
)
process.consume_step = cms.EndPath(process.consumer)
process.schedule = cms.Schedule(process.raw2digi_step, process.reconstruction_step, process.consume_step)
return process
| 35.173077 | 111 | 0.791689 | 226 | 1,829 | 6.353982 | 0.265487 | 0.020891 | 0.075209 | 0.041783 | 0.754875 | 0.754875 | 0.72702 | 0.72702 | 0.72702 | 0.696379 | 0 | 0.0019 | 0.136687 | 1,829 | 51 | 112 | 35.862745 | 0.907536 | 0.363587 | 0 | 0.545455 | 0 | 0 | 0.096438 | 0.048653 | 0 | 0 | 0 | 0 | 0 | 1 | 0.136364 | false | 0 | 0.045455 | 0 | 0.318182 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 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 | 5 |
4fc763b421ba4cbfd38d9940dd89f1d250c4b7be | 1,462 | py | Python | dev/Tickets/524.py | tarment10/CoolProp | de465e1cf6755d23231f289c6f7c24fd58eca465 | [
"MIT"
] | null | null | null | dev/Tickets/524.py | tarment10/CoolProp | de465e1cf6755d23231f289c6f7c24fd58eca465 | [
"MIT"
] | null | null | null | dev/Tickets/524.py | tarment10/CoolProp | de465e1cf6755d23231f289c6f7c24fd58eca465 | [
"MIT"
] | null | null | null | import CoolProp
from CoolProp.CoolProp import PropsSI
from CoolProp.CoolProp import set_reference_state
print("CoolProp version %s" % CoolProp.__version__)
print("CoolProp revision %s" % CoolProp.__gitrevision__)
REF = 'R134a'
T0 = 273.15
RefState = 'IIR'
set_reference_state(REF,RefState)
print(REF, RefState)
print("HMass at %s C %s" % (T0-273.15,"C", PropsSI('HMASS','T',T0,'Q',0,REF)/1000))
print("SMass at %s C %s" % (T0-273.15,"C", PropsSI('SMASS','T',T0,'Q',0,REF)/1000))
T0 = 273.15-40
RefState = 'ASHRAE'
set_reference_state(REF,RefState)
print(REF, RefState)
print("HMass at %s C %s" % (T0-273.15, PropsSI('HMASS','T',T0,'Q',0,REF)/1000))
print("SMass at %s C %s" % (T0-273.15, PropsSI('SMASS','T',T0,'Q',0,REF)/1000))
P0 = 101325
RefState = 'NBP'
set_reference_state(REF,RefState)
print(REF, RefState)
print("HMass at %s Pa %s" % (P0, PropsSI('HMASS','P',P0,'Q',0,REF)/1000))
print("SMass at %s Pa %s" % (P0, PropsSI('SMASS','P',P0,'Q',0,REF)/1000))
T0 = 273.15
RefState = 'IIR'
set_reference_state(REF,RefState)
print(REF, RefState)
print("HMass at %s C %s" % (T0-273.15, PropsSI('HMASS','T',T0,'Q',0,REF)/1000))
print("SMass at %s C %s" % (T0-273.15, PropsSI('SMASS','T',T0,'Q',0,REF)/1000))
T0 = 273.15
RefState = 'DEF'
set_reference_state(REF,RefState)
print(REF, RefState)
print("HMass at %s C %s" % (T0-273.15,"C",PropsSI('HMASS','T',T0,'Q',0,REF)/1000))
print("SMass at %s C %s" % (T0-273.15,"C",PropsSI('SMASS','T',T0,'Q',0,REF)/1000))
| 33.227273 | 83 | 0.661423 | 263 | 1,462 | 3.60076 | 0.13308 | 0.063358 | 0.088701 | 0.095037 | 0.76452 | 0.76452 | 0.732841 | 0.732841 | 0.691658 | 0.691658 | 0 | 0.111536 | 0.104651 | 1,462 | 43 | 84 | 34 | 0.611917 | 0 | 0 | 0.638889 | 0 | 0 | 0.20383 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.083333 | 0 | 0.083333 | 0.472222 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 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 | 1 | 0 | 5 |
4fef65661079075a2a4146190a7e8653583a5d0c | 4,322 | py | Python | models/ensemble.py | gugarosa/evolutionary_ensembles | 4f73f26bbdfd58bc06ba96fb4d22624dd5a65b5a | [
"MIT"
] | 5 | 2020-09-23T13:12:37.000Z | 2021-07-24T16:02:53.000Z | models/ensemble.py | gugarosa/evolutionary_ensembles | 4f73f26bbdfd58bc06ba96fb4d22624dd5a65b5a | [
"MIT"
] | null | null | null | models/ensemble.py | gugarosa/evolutionary_ensembles | 4f73f26bbdfd58bc06ba96fb4d22624dd5a65b5a | [
"MIT"
] | 3 | 2021-01-12T15:16:01.000Z | 2021-10-30T08:04:49.000Z | import numpy as np
import utils.constants as c
import utils.metrics as m
def boolean_classifiers(preds, labels):
"""Creates a function that boolean chooses classifier's predictions and minimizes it accuracy.
Args:
preds (np.array): Array of predictions of shape (n_samples, n_classifiers).
labels (np.array): Array of ground truth labels of shape (n_samples, 1).
Returns:
A function to be optimized.
"""
def f(w):
"""Weights predictions and returns an accuracy score.
Args:
w (float): Array of weights.
Returns:
1 - accuracy.
"""
# Rounding entire weights
w = np.round(w)
# Gathering the maximum label identifier
max_label = np.max(labels)
# Creating an array to hold the weighted predictions
w_preds = np.zeros((preds.shape[0], max_label+1))
# For every possible prediction
for i in range(preds.shape[0]):
# For every possible classifier
for j in range(preds.shape[1]):
# Sums the boolean classifier's prediction to its position in the final array
w_preds[i][preds[i][j]] += w[j]
# Gathers the most weighted prediction
hat_preds = np.argmax(w_preds, axis=1)
# Calculates the accuracy
acc = m.accuracy(hat_preds, labels)
return 1 - acc
return f
def weighted_classifiers(preds, labels):
"""Creates a function that weights classifier's predictions and minimizes it accuracy.
Args:
preds (np.array): Array of predictions of shape (n_samples, n_classifiers).
labels (np.array): Array of ground truth labels of shape (n_samples, 1).
Returns:
A function to be optimized.
"""
def f(w):
"""Weights predictions and returns an accuracy score.
Args:
w (float): Array of weights.
Returns:
1 - accuracy.
"""
# Ensuring that the sum of weights is one and avoids division by zero
w = w / max(w.sum(), c.EPSILON)
# Gathering the maximum label identifier
max_label = np.max(labels)
# Creating an array to hold the weighted predictions
w_preds = np.zeros((preds.shape[0], max_label+1))
# For every possible prediction
for i in range(preds.shape[0]):
# For every possible classifier
for j in range(preds.shape[1]):
# Sums the weighted classifier's prediction to its position in the final array
w_preds[i][preds[i][j]] += w[j]
# Gathers the most weighted prediction
hat_preds = np.argmax(w_preds, axis=1)
# Calculates the accuracy
acc = m.accuracy(hat_preds, labels)
return 1 - acc
return f
def majority_voting(preds):
"""Gathers the majority votes by finding the most frequent number in an array.
Args:
preds (np.array): An array of predictions.
Returns:
An array of votes (labels).
"""
# Calculate the majority votes by finding the most frequent number in array
votes = [np.argmax(np.bincount(pred)) for pred in preds]
return np.asarray(votes)
def evaluate(weights, preds, labels):
"""Evaluates an ensemble based on optimized weights and classifiers' predictions.
Args:
weights (np.array): Array of weights (n_classifiers, 1).
preds (np.array): Array of predictions of shape (n_samples, n_classifiers).
labels (np.array): Array of ground truth labels of shape (n_samples, 1).
Returns:
An accuracy score.
"""
# Gathering the maximum label identifier
max_label = np.max(labels)
# Creating an array to hold the weighted predictions
w_preds = np.zeros((preds.shape[0], max_label+1))
# For every possible prediction
for i in range(preds.shape[0]):
# For every possible classifier
for j in range(preds.shape[1]):
# Sums the weighted classifier's prediction to its position in the final array
w_preds[i][preds[i][j]] += weights[j]
# Gathers the most weighted prediction
hat_preds = np.argmax(w_preds, axis=1)
# Calculates the accuracy
acc = m.accuracy(hat_preds, labels)
return acc
| 27.528662 | 98 | 0.623554 | 580 | 4,322 | 4.587931 | 0.177586 | 0.028936 | 0.031567 | 0.036828 | 0.795566 | 0.795566 | 0.795566 | 0.763999 | 0.763999 | 0.763999 | 0 | 0.007519 | 0.292226 | 4,322 | 156 | 99 | 27.705128 | 0.862373 | 0.548126 | 0 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0 | 0.076923 | 0 | 0.384615 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 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 | 5 |
8b00d6181c22d7daaec8ebfb107ae3537b240adc | 52 | py | Python | main.py | closure-reference/python-dd-testing | 94c8bad35302b7d14d392e7fe506735144d624f3 | [
"WTFPL"
] | null | null | null | main.py | closure-reference/python-dd-testing | 94c8bad35302b7d14d392e7fe506735144d624f3 | [
"WTFPL"
] | null | null | null | main.py | closure-reference/python-dd-testing | 94c8bad35302b7d14d392e7fe506735144d624f3 | [
"WTFPL"
] | null | null | null | from testing import run_file
run_file("spec.json")
| 13 | 28 | 0.788462 | 9 | 52 | 4.333333 | 0.777778 | 0.358974 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.115385 | 52 | 3 | 29 | 17.333333 | 0.847826 | 0 | 0 | 0 | 0 | 0 | 0.173077 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.5 | 0 | 0.5 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 5 |
8b2959c6135994a1ea0d0d4e9f666a47ee7992dc | 37 | py | Python | src/portal_visualization/builders/__init__.py | hubmapconsortium/portal-visualization | c322f7bae6e06dbf2fee6359b6406af7d172584b | [
"MIT"
] | null | null | null | src/portal_visualization/builders/__init__.py | hubmapconsortium/portal-visualization | c322f7bae6e06dbf2fee6359b6406af7d172584b | [
"MIT"
] | 24 | 2022-01-26T21:21:10.000Z | 2022-03-23T20:19:32.000Z | src/portal_visualization/builders/__init__.py | hubmapconsortium/portal-visualization | c322f7bae6e06dbf2fee6359b6406af7d172584b | [
"MIT"
] | null | null | null | # pytest doctests fail without this.
| 18.5 | 36 | 0.783784 | 5 | 37 | 5.8 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.162162 | 37 | 1 | 37 | 37 | 0.935484 | 0.918919 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 1 | 1 | 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 | 5 |
8b2e956dbb778c87d25ec6359b0c57a8a5c3a16c | 44 | py | Python | managers/operatorsSimaudit/__init__.py | HarshKhilawala/cerebmodels | d2a2f2ef947ef9dc23ddce6e55159240cd3233cb | [
"BSD-3-Clause"
] | null | null | null | managers/operatorsSimaudit/__init__.py | HarshKhilawala/cerebmodels | d2a2f2ef947ef9dc23ddce6e55159240cd3233cb | [
"BSD-3-Clause"
] | 9 | 2020-03-24T17:09:03.000Z | 2021-05-17T16:11:17.000Z | managers/operatorsSimaudit/__init__.py | myHBPwork/cerebmodels | 371ea7f1bbe388f1acade17c7128b8ca6ab8fb7a | [
"BSD-3-Clause"
] | 1 | 2021-05-21T03:08:41.000Z | 2021-05-21T03:08:41.000Z | # ../managers/operatorsSimaudit/__init__.py
| 22 | 43 | 0.795455 | 4 | 44 | 7.75 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.045455 | 44 | 1 | 44 | 44 | 0.738095 | 0.931818 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 1 | 1 | 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 | 5 |
8b39e4e9485367681096fa71baac7c9df859b98e | 96 | py | Python | venv/lib/python3.8/site-packages/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/defines.py | Retraces/UkraineBot | 3d5d7f8aaa58fa0cb8b98733b8808e5dfbdb8b71 | [
"MIT"
] | 2 | 2022-03-13T01:58:52.000Z | 2022-03-31T06:07:54.000Z | venv/lib/python3.8/site-packages/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/defines.py | DesmoSearch/Desmobot | b70b45df3485351f471080deb5c785c4bc5c4beb | [
"MIT"
] | 19 | 2021-11-20T04:09:18.000Z | 2022-03-23T15:05:55.000Z | venv/lib/python3.8/site-packages/debugpy/_vendored/pydevd/pydevd_attach_to_process/winappdbg/win32/defines.py | DesmoSearch/Desmobot | b70b45df3485351f471080deb5c785c4bc5c4beb | [
"MIT"
] | null | null | null | /home/runner/.cache/pip/pool/55/ea/dc/d342a76375d2c48d0a3296fcd54e0fea4e8c50709ef8d82cc651bb21ef | 96 | 96 | 0.895833 | 9 | 96 | 9.555556 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | 0 | 96 | 1 | 96 | 96 | 0.520833 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
8b46d45468c1cd6ae6ccec50819dbe05e021334b | 197 | py | Python | utls/errors.py | noobprogammier/Weather-Sinoptik | 9a6ec56fa692f5b401369f6203e4b26e8deaa51f | [
"Apache-2.0"
] | null | null | null | utls/errors.py | noobprogammier/Weather-Sinoptik | 9a6ec56fa692f5b401369f6203e4b26e8deaa51f | [
"Apache-2.0"
] | null | null | null | utls/errors.py | noobprogammier/Weather-Sinoptik | 9a6ec56fa692f5b401369f6203e4b26e8deaa51f | [
"Apache-2.0"
] | null | null | null | error_tab = {}
error_tab["Argument"] = "Unexpected argument '%s'!"
error_tab["Missing"] = "Missing argument '%s'!"
error_tab["TypeError"] = "Type Error required '%s', got '%s'!"
exc = Exception | 39.4 | 63 | 0.654822 | 25 | 197 | 5 | 0.48 | 0.256 | 0.224 | 0.272 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.137056 | 197 | 5 | 64 | 39.4 | 0.735294 | 0 | 0 | 0 | 0 | 0 | 0.546392 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 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 | 5 |
8c9dc3ce5e48c8291e6679bc6d476fedade4447a | 151 | py | Python | InteractiveProgramming/user39_VpaZAK7n4p_0.py | mr-ice/pipython | ea27af520946cb710cb717815be625489fc8a1a3 | [
"MIT"
] | null | null | null | InteractiveProgramming/user39_VpaZAK7n4p_0.py | mr-ice/pipython | ea27af520946cb710cb717815be625489fc8a1a3 | [
"MIT"
] | null | null | null | InteractiveProgramming/user39_VpaZAK7n4p_0.py | mr-ice/pipython | ea27af520946cb710cb717815be625489fc8a1a3 | [
"MIT"
] | null | null | null | # program template for mini-project 0
# Modify the print statement according to
# the mini-project instructions
print "We want... a shrubbery!" | 25.166667 | 43 | 0.735099 | 21 | 151 | 5.285714 | 0.809524 | 0.198198 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008197 | 0.192053 | 151 | 6 | 44 | 25.166667 | 0.901639 | 0.701987 | 0 | 0 | 0 | 0 | 0.621622 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 1 | 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 | 1 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 5 |
8cd66c7d502130394312cc4a2e6815b1b8c52e69 | 433 | py | Python | utils/utils.py | balemessenger/rss_reader_bot | 453f817544e5ae54c7bbee39a1fad97064de5da4 | [
"Apache-2.0"
] | null | null | null | utils/utils.py | balemessenger/rss_reader_bot | 453f817544e5ae54c7bbee39a1fad97064de5da4 | [
"Apache-2.0"
] | 1 | 2021-06-02T00:00:14.000Z | 2021-06-02T00:00:14.000Z | utils/utils.py | balemessenger/rss_reader_bot | 453f817544e5ae54c7bbee39a1fad97064de5da4 | [
"Apache-2.0"
] | 1 | 2019-07-16T10:07:13.000Z | 2019-07-16T10:07:13.000Z | from main_config import BotConfig
def un_healthy():
try:
with open(BotConfig.heathens_path, "w") as file:
file.truncate(0)
file.write("0")
file.close()
except:
un_healthy()
def healthy():
try:
with open(BotConfig.heathens_path, "w") as file:
file.truncate(0)
file.write("1")
file.close()
except:
un_healthy()
| 19.681818 | 56 | 0.528868 | 50 | 433 | 4.46 | 0.44 | 0.121076 | 0.125561 | 0.161435 | 0.825112 | 0.609865 | 0.609865 | 0.609865 | 0.609865 | 0.609865 | 0 | 0.014337 | 0.355658 | 433 | 21 | 57 | 20.619048 | 0.784946 | 0 | 0 | 0.705882 | 0 | 0 | 0.009238 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.117647 | true | 0 | 0.058824 | 0 | 0.176471 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 1 | 0 | 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 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
8cd8c95a56822952673e7e7d9e21da5a46459cd4 | 169 | py | Python | enforce_typing/__init__.py | mr-strawberry66/python-type-enforcement | afb4cf66f1e46104d5952fa08db8756d1a802a8f | [
"MIT"
] | 1 | 2022-03-16T14:28:27.000Z | 2022-03-16T14:28:27.000Z | enforce_typing/__init__.py | mr-strawberry66/python-static-type-checking | afb4cf66f1e46104d5952fa08db8756d1a802a8f | [
"MIT"
] | 1 | 2022-03-16T14:27:00.000Z | 2022-03-16T14:43:46.000Z | enforce_typing/__init__.py | mr-strawberry66/python-static-type-checking | afb4cf66f1e46104d5952fa08db8756d1a802a8f | [
"MIT"
] | null | null | null | """Expose public methods."""
from .enforce_typing import enforce_typing
from .exceptions import EnforcedTypingError
__all__ = ["EnforcedTypingError", "enforce_typing"]
| 28.166667 | 51 | 0.804734 | 17 | 169 | 7.588235 | 0.588235 | 0.302326 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.094675 | 169 | 5 | 52 | 33.8 | 0.843137 | 0.130178 | 0 | 0 | 0 | 0 | 0.234043 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.666667 | 0 | 0.666667 | 0 | 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 | 1 | 0 | 1 | 0 | 0 | 5 |
50721049d7b5e82ded4606a7773c59366f5d76f7 | 10,075 | py | Python | OPMS_v3-dev3.1/apps/host_management/migrations/0001_initial.py | litiian/asyncstudy | a59119f189ca96fdd7f64b0b3212207572165dce | [
"Apache-2.0"
] | null | null | null | OPMS_v3-dev3.1/apps/host_management/migrations/0001_initial.py | litiian/asyncstudy | a59119f189ca96fdd7f64b0b3212207572165dce | [
"Apache-2.0"
] | null | null | null | OPMS_v3-dev3.1/apps/host_management/migrations/0001_initial.py | litiian/asyncstudy | a59119f189ca96fdd7f64b0b3212207572165dce | [
"Apache-2.0"
] | null | null | null | # Generated by Django 2.0.6 on 2018-07-09 11:08
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='HostInfo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('in_ip', models.GenericIPAddressField(verbose_name='内外IP')),
('out_ip', models.GenericIPAddressField(blank=True, null=True, verbose_name='外外IP')),
('hostname', models.CharField(max_length=30, verbose_name='主机名')),
('cpu', models.CharField(max_length=30, verbose_name='CPU')),
('disk', models.IntegerField(verbose_name='磁盘')),
('memory', models.IntegerField(verbose_name='内存')),
('network', models.IntegerField(verbose_name='带宽')),
('ssh_port', models.IntegerField(verbose_name='远程端口')),
('root_ssh', models.BooleanField(default=True, verbose_name='是否允许 root 远程')),
('admin_user', models.CharField(max_length=20, verbose_name='管理员用户')),
('admin_pass', models.CharField(max_length=20, verbose_name='管理员密码')),
('normal_user', models.CharField(max_length=20, verbose_name='普通用户')),
('normal_pass', models.CharField(max_length=20, verbose_name='普通用户密码')),
('add_time', models.DateTimeField(auto_now_add=True, verbose_name='添加时间')),
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
('desc', models.CharField(blank=True, max_length=200, null=True, verbose_name='备注')),
('status', models.PositiveSmallIntegerField(choices=[(1, '正常'), (2, '停用')], verbose_name='状态')),
],
options={
'verbose_name': '主机信息',
'verbose_name_plural': '主机信息',
},
),
migrations.CreateModel(
name='IdcInfo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30, verbose_name='机房名称')),
('address', models.CharField(max_length=100, verbose_name='地址')),
('desc', models.CharField(blank=True, max_length=200, null=True, verbose_name='描述')),
('add_time', models.DateTimeField(auto_now_add=True, verbose_name='添加时间')),
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
('status', models.PositiveSmallIntegerField(choices=[(1, '正常'), (2, '停用')], verbose_name='状态')),
('add_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='idc_add_user', to=settings.AUTH_USER_MODEL, verbose_name='添加人')),
('update_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='idc_update_user', to=settings.AUTH_USER_MODEL, verbose_name='修改人')),
],
options={
'verbose_name': '机房',
'verbose_name_plural': '机房',
},
),
migrations.CreateModel(
name='OperatingEnvironmentInfo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30, verbose_name='环境名称')),
('desc', models.CharField(blank=True, max_length=200, null=True, verbose_name='描述')),
('add_time', models.DateTimeField(auto_now_add=True, verbose_name='添加时间')),
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
('status', models.PositiveSmallIntegerField(choices=[(1, '正常'), (2, '停用')], verbose_name='状态')),
('add_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='env_add_user', to=settings.AUTH_USER_MODEL, verbose_name='添加人')),
('update_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='env_update_user', to=settings.AUTH_USER_MODEL, verbose_name='修改人')),
],
options={
'verbose_name': '服务环境',
'verbose_name_plural': '服务环境',
},
),
migrations.CreateModel(
name='OperatingSystemInfo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30, verbose_name='系统名称')),
('version', models.CharField(max_length=10, verbose_name='系统版本')),
('desc', models.CharField(blank=True, max_length=200, null=True, verbose_name='描述')),
('add_time', models.DateTimeField(auto_now_add=True, verbose_name='添加时间')),
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
('status', models.PositiveSmallIntegerField(choices=[(1, '正常'), (2, '停用')], verbose_name='状态')),
('add_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='os_add_user', to=settings.AUTH_USER_MODEL, verbose_name='添加人')),
('update_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='os_update_user', to=settings.AUTH_USER_MODEL, verbose_name='修改人')),
],
options={
'verbose_name': '操作系统',
'verbose_name_plural': '操作系统',
},
),
migrations.CreateModel(
name='ProjectInfo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30, verbose_name='项目名称')),
('pro_user', models.CharField(max_length=30, verbose_name='开发人员')),
('op_user', models.CharField(max_length=30, verbose_name='运维人员')),
('run_env', models.CharField(max_length=100, verbose_name='运行环境')),
('add_time', models.DateTimeField(auto_now_add=True, verbose_name='添加时间')),
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
('status', models.PositiveSmallIntegerField(choices=[(1, '正常'), (2, '停用')], verbose_name='状态')),
('add_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pro_add_user', to=settings.AUTH_USER_MODEL, verbose_name='添加人')),
('update_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pro_update_user', to=settings.AUTH_USER_MODEL, verbose_name='修改人')),
],
options={
'verbose_name': '用途',
'verbose_name_plural': '用途',
},
),
migrations.CreateModel(
name='UseInfo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30, verbose_name='用途')),
('desc', models.CharField(blank=True, max_length=200, null=True, verbose_name='描述')),
('add_time', models.DateTimeField(auto_now_add=True, verbose_name='添加时间')),
('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
('status', models.PositiveSmallIntegerField(choices=[(1, '正常'), (2, '停用')], verbose_name='状态')),
('add_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='use_add_user', to=settings.AUTH_USER_MODEL, verbose_name='添加人')),
('update_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='use_update_user', to=settings.AUTH_USER_MODEL, verbose_name='修改人')),
],
options={
'verbose_name': '用途',
'verbose_name_plural': '用途',
},
),
migrations.AddField(
model_name='hostinfo',
name='idc',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='host_management.IdcInfo', verbose_name='机房'),
),
migrations.AddField(
model_name='hostinfo',
name='op_env',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='host_management.OperatingEnvironmentInfo', verbose_name='服务环境'),
),
migrations.AddField(
model_name='hostinfo',
name='op_user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='host_op_user', to=settings.AUTH_USER_MODEL, verbose_name='负责人'),
),
migrations.AddField(
model_name='hostinfo',
name='project',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='host_management.ProjectInfo', verbose_name='项目'),
),
migrations.AddField(
model_name='hostinfo',
name='system',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='host_management.OperatingSystemInfo', verbose_name='操作系统'),
),
migrations.AddField(
model_name='hostinfo',
name='update_user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='host_update_user', to=settings.AUTH_USER_MODEL, verbose_name='修改人'),
),
migrations.AddField(
model_name='hostinfo',
name='use',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='host_management.UseInfo', verbose_name='用途'),
),
]
| 59.615385 | 177 | 0.608834 | 1,090 | 10,075 | 5.383486 | 0.134862 | 0.15184 | 0.048569 | 0.067485 | 0.792774 | 0.792774 | 0.761247 | 0.721711 | 0.673313 | 0.673313 | 0 | 0.009944 | 0.24139 | 10,075 | 168 | 178 | 59.970238 | 0.757818 | 0.004467 | 0 | 0.515528 | 1 | 0 | 0.138014 | 0.017152 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.012422 | 0.018634 | 0 | 0.043478 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
5077abcf0a5cbc0b9e9d46a200b9b92f0a4045cb | 56 | py | Python | annodize/test/test_func_fields.py | NowanIlfideme/annodize | d31f68b62f473990a43334ef50a0a176847b1f7a | [
"MIT"
] | null | null | null | annodize/test/test_func_fields.py | NowanIlfideme/annodize | d31f68b62f473990a43334ef50a0a176847b1f7a | [
"MIT"
] | null | null | null | annodize/test/test_func_fields.py | NowanIlfideme/annodize | d31f68b62f473990a43334ef50a0a176847b1f7a | [
"MIT"
] | null | null | null | """Tests for FunctionFields."""
# FIXME: Create tests!
| 14 | 31 | 0.678571 | 6 | 56 | 6.333333 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 56 | 3 | 32 | 18.666667 | 0.791667 | 0.839286 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0.333333 | null | 1 | null | true | 0 | 0 | null | null | null | 1 | 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 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
508914a75cdf30b02ffcd9483b862cc6e5f9f7df | 4,605 | py | Python | test/unittests/test_optional_return_type.py | Azure/autorest.python | c36f5c1a2d614a1eeba6fec6a2c02517f2d1cce7 | [
"MIT"
] | 35 | 2018-04-03T12:15:53.000Z | 2022-03-11T14:03:34.000Z | test/unittests/test_optional_return_type.py | Azure/autorest.python | c36f5c1a2d614a1eeba6fec6a2c02517f2d1cce7 | [
"MIT"
] | 652 | 2017-08-28T22:44:41.000Z | 2022-03-31T21:20:31.000Z | test/unittests/test_optional_return_type.py | Azure/autorest.python | c36f5c1a2d614a1eeba6fec6a2c02517f2d1cce7 | [
"MIT"
] | 29 | 2017-08-28T20:57:01.000Z | 2022-03-11T14:03:38.000Z | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import pytest
from autorest.codegen.models import (
Operation, LROOperation, PagingOperation, SchemaResponse, ParameterList
)
@pytest.fixture
def operation():
return Operation(
yaml_data={},
name="optional_return_type_test",
description="Operation to test optional return types",
api_versions=set(["2020-05-01"]),
parameters=ParameterList(),
multiple_media_type_parameters=ParameterList(),
)
@pytest.fixture
def lro_operation():
return LROOperation(
yaml_data={},
name="lro_optional_return_type_test",
description="LRO Operation to test optional return types",
api_versions=set(["2020-05-01"]),
parameters=ParameterList(),
multiple_media_type_parameters=ParameterList(),
)
@pytest.fixture
def paging_operation():
return PagingOperation(
yaml_data={"extensions": {"x-ms-pageable": {}}},
name="paging_optional_return_type_test",
description="Paging Operation to test optional return types",
api_versions=set(["2020-05-01"]),
parameters=ParameterList(),
multiple_media_type_parameters=ParameterList(),
)
def test_success_with_body_and_fail_no_body(operation):
operation.responses = [
SchemaResponse(
yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=[200]
),
SchemaResponse(
yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=[202]
),
SchemaResponse(
yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema=None, status_codes=["default"]
)
]
assert operation.has_optional_return_type is False
def test_success_no_body_fail_with_body(operation):
operation.responses = [
SchemaResponse(
yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema=None, status_codes=[200]
),
SchemaResponse(
yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=["default"]
)
]
assert operation.has_optional_return_type is False
def test_optional_return_type_operation(operation):
operation.responses = [
SchemaResponse(
yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=[200]
),
SchemaResponse(
yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema=None, status_codes=[202]
),
SchemaResponse(
yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=["default"]
)
]
assert operation.has_optional_return_type is True
def test_lro_operation(lro_operation):
lro_operation.responses = [
SchemaResponse(
yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=[200]
),
SchemaResponse(
yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema=None, status_codes=[202]
),
SchemaResponse(
yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=["default"]
)
]
assert lro_operation.has_optional_return_type is False
def test_paging_operation(paging_operation):
paging_operation.responses = [
SchemaResponse(
yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=[200]
),
SchemaResponse(
yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema=None, status_codes=[202]
),
SchemaResponse(
yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=["default"]
)
]
assert paging_operation.has_optional_return_type is False
| 39.358974 | 142 | 0.625841 | 482 | 4,605 | 5.746888 | 0.174274 | 0.049097 | 0.111191 | 0.136462 | 0.793502 | 0.757762 | 0.757762 | 0.744404 | 0.744404 | 0.727076 | 0 | 0.013836 | 0.199566 | 4,605 | 116 | 143 | 39.698276 | 0.737656 | 0.064929 | 0 | 0.552083 | 0 | 0 | 0.154419 | 0.02 | 0 | 0 | 0 | 0 | 0.052083 | 1 | 0.083333 | false | 0 | 0.020833 | 0.03125 | 0.135417 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 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 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.