uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9161a7f503e6405ee14cfdd1 | train | class | class MailToForm(forms.Form):
subject = forms.CharField(label=_('Subject'),
widget=forms.TextInput(attrs={'size':'75', 'maxlength':'70', 'class':'longinput'}))
body = forms.CharField(required=False, label=_('Message'),
widget=forms.Textarea(attrs={'ro... | class MailToForm(forms.Form):
| subject = forms.CharField(label=_('Subject'),
widget=forms.TextInput(attrs={'size':'75', 'maxlength':'70', 'class':'longinput'}))
body = forms.CharField(required=False, label=_('Message'),
widget=forms.Textarea(attrs={'rows':'10', 'cols':'75'}))
| return self.cleaned_data
def save(self, commit=True):
reputation = super(ReputationForm, self).save(commit=False)
reputation.from_user = self.from_user
reputation.to_user = self.to_user
if commit:
reputation.save()
return reputation
class MailToForm(forms.Form)... | 64 | 64 | 72 | 7 | 56 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | MailToForm | MailToForm | 380 | 384 | 380 | 380 | a38784472cf76756199a469154953508f0eca82d | bigcode/the-stack | train |
6119761cf94f84e1c9f939b6 | train | class | class ReportForm(forms.ModelForm):
class Meta:
model = Report
fields = ['reason', 'post']
def __init__(self, *args, **kwargs):
self.reported_by = kwargs.pop('reported_by', None)
self.post = kwargs.pop('post', None)
super(ReportForm, self).__init__(*args, **kwargs)
... | class ReportForm(forms.ModelForm):
| class Meta:
model = Report
fields = ['reason', 'post']
def __init__(self, *args, **kwargs):
self.reported_by = kwargs.pop('reported_by', None)
self.post = kwargs.pop('post', None)
super(ReportForm, self).__init__(*args, **kwargs)
self.fields['post'].widget = form... | ('Subject'),
widget=forms.TextInput(attrs={'size':'75', 'maxlength':'70', 'class':'longinput'}))
body = forms.CharField(required=False, label=_('Message'),
widget=forms.Textarea(attrs={'rows':'10', 'cols':'75'}))
class ReportForm(forms.ModelForm):
| 64 | 64 | 176 | 7 | 57 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | ReportForm | ReportForm | 387 | 407 | 387 | 388 | 7a03600df73008e17fc5c4f8f902e40eeadfad90 | bigcode/the-stack | train |
c847016db3e0e4c32cf1c614 | train | class | class MessagingProfileForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['jabber', 'icq', 'msn', 'aim', 'yahoo']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(MessagingProfileForm, self).__init__(*args, **kwargs)
| class MessagingProfileForm(forms.ModelForm):
| class Meta:
model = Profile
fields = ['jabber', 'icq', 'msn', 'aim', 'yahoo']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(MessagingProfileForm, self).__init__(*args, **kwargs)
| , self.profile.user.last_name = cleaned_name.split(None, 1)
else:
self.profile.user.first_name = cleaned_name
self.profile.user.last_name = ''
self.profile.user.save()
if commit:
self.profile.save()
return self.profile
class Mes... | 64 | 64 | 79 | 8 | 55 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | MessagingProfileForm | MessagingProfileForm | 225 | 232 | 225 | 225 | 5141c607e2e7593bfe8d78b423b029614f83c0ba | bigcode/the-stack | train |
dfbaaac0d7b52a9f4f266660 | train | class | class PostSearchForm(forms.Form):
keywords = forms.CharField(required=False, label=_('Keyword search'),
widget=forms.TextInput(attrs={'size':'40', 'maxlength':'100'}))
author = forms.CharField(required=False, label=_('Author search'),
widget=forms.Text... | class PostSearchForm(forms.Form):
| keywords = forms.CharField(required=False, label=_('Keyword search'),
widget=forms.TextInput(attrs={'size':'40', 'maxlength':'100'}))
author = forms.CharField(required=False, label=_('Author search'),
widget=forms.TextInput(attrs={'size':'25', 'maxleng... | ')
elif sort_by == 'num_posts':
if sort_dir == 'ASC':
return qs.order_by('forum_profile__post_count')
elif sort_dir == 'DESC':
return qs.order_by('-forum_profile__post_count')
else:
return qs
class PostSearchForm(for... | 64 | 64 | 179 | 7 | 56 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | PostSearchForm | PostSearchForm | 319 | 328 | 319 | 319 | 4c0a2fcdac89731df5ab6a518dde9b3071cf82e9 | bigcode/the-stack | train |
1e38b3f59765da2c010180cb | train | class | class EditPostForm(forms.ModelForm):
name = forms.CharField(required=False, label=_('Subject'),
widget=forms.TextInput(attrs={'size':'115'}))
class Meta:
model = Post
fields = ['body']
def __init__(self, *args, **kwargs):
self.topic = kwargs.pop('topic', ... | class EditPostForm(forms.ModelForm):
| name = forms.CharField(required=False, label=_('Subject'),
widget=forms.TextInput(attrs={'size':'115'}))
class Meta:
model = Post
fields = ['body']
def __init__(self, *args, **kwargs):
self.topic = kwargs.pop('topic', None)
super(EditPostForm, sel... | .MEDIA_ROOT, forum_settings.ATTACHMENT_UPLOAD_TO)
fname = '%d.0' % post.id
path = os.path.join(dir, fname)
file(path, 'wb').write(memfile.read())
obj.path = fname
obj.save()
class EditPostForm(forms.ModelForm):
| 64 | 64 | 186 | 8 | 56 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | EditPostForm | EditPostForm | 137 | 160 | 137 | 137 | 9054068d94a1601db65001ba016251b3968620bd | bigcode/the-stack | train |
cf30e704fce798fdb29442f2 | train | class | class AddPostForm(forms.ModelForm):
FORM_NAME = "AddPostForm" # used in view and template submit button
name = forms.CharField(label=_('Subject'), max_length=255,
widget=forms.TextInput(attrs={'size':'115'}))
attachment = forms.FileField(label=_('Attachment'), required=False)
... | class AddPostForm(forms.ModelForm):
| FORM_NAME = "AddPostForm" # used in view and template submit button
name = forms.CharField(label=_('Subject'), max_length=255,
widget=forms.TextInput(attrs={'size':'115'}))
attachment = forms.FileField(label=_('Attachment'), required=False)
subscribe = forms.BooleanField(labe... | import settings as forum_settings
from djangobb_forum.util import convert_text_to_html, set_language
SORT_USER_BY_CHOICES = (
('username', _(u'Username')),
('registered', _(u'Registered')),
('num_posts', _(u'No. of posts')),
)
SORT_POST_BY_CHOICES = (
('0', _(u'Post time')),
('1', _(u'Author')),... | 211 | 211 | 704 | 8 | 203 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | AddPostForm | AddPostForm | 48 | 134 | 48 | 48 | 762e50824abe4391f9ad32cd973714e544f7a940 | bigcode/the-stack | train |
e60ea1b92e34e5195abc7132 | train | class | class PollForm(forms.ModelForm):
answers = forms.CharField(min_length=2, widget=forms.Textarea,
help_text=_("Write each answer on a new line.")
)
days = forms.IntegerField(required=False, min_value=1,
help_text=_("Number of days for this poll to run. Leave empty for never ending poll.")
... | class PollForm(forms.ModelForm):
| answers = forms.CharField(min_length=2, widget=forms.Textarea,
help_text=_("Write each answer on a new line.")
)
days = forms.IntegerField(required=False, min_value=1,
help_text=_("Number of days for this poll to run. Leave empty for never ending poll.")
)
class Meta:
model =... | Field(
choices=choices, widget=forms.RadioSelect
)
else:
self.fields["choice"] = forms.MultipleChoiceField(
choices=choices, widget=forms.CheckboxSelectMultiple
)
def clean_choice(self):
ids = self.cleaned_data["choice"]
co... | 117 | 117 | 393 | 7 | 109 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | PollForm | PollForm | 441 | 486 | 441 | 441 | 473376172b8f42461fa3fd3b9d50554de1611f48 | bigcode/the-stack | train |
8a5c462cc9d5ac8cbf7d4569 | train | class | class UserSearchForm(forms.Form):
username = forms.CharField(required=False, label=_('Username'))
#show_group = forms.ChoiceField(choices=SHOW_GROUP_CHOICES)
sort_by = forms.ChoiceField(choices=SORT_USER_BY_CHOICES, label=_('Sort by'))
sort_dir = forms.ChoiceField(choices=SORT_DIR_CHOICES, label=_('Sort... | class UserSearchForm(forms.Form):
| username = forms.CharField(required=False, label=_('Username'))
#show_group = forms.ChoiceField(choices=SHOW_GROUP_CHOICES)
sort_by = forms.ChoiceField(choices=SORT_USER_BY_CHOICES, label=_('Sort by'))
sort_dir = forms.ChoiceField(choices=SORT_DIR_CHOICES, label=_('Sort order'))
def filter(self, qs... | _permission'].widget = forms.RadioSelect(
choices=self.fields['privacy_permission'].choices
)
class UploadAvatarForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['avatar']
def __... | 90 | 90 | 303 | 7 | 83 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | UserSearchForm | UserSearchForm | 287 | 316 | 287 | 287 | 9f8983518fc38bad0f05463722f70add70b1b8ac | bigcode/the-stack | train |
4adca5c1d3926d8d3ff729ab | train | class | class EssentialsProfileForm(forms.ModelForm):
username = forms.CharField(label=_('Username'))
email = forms.CharField(label=_('E-mail'))
class Meta:
model = Profile
fields = ['auto_subscribe', 'time_zone', 'language']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop... | class EssentialsProfileForm(forms.ModelForm):
| username = forms.CharField(label=_('Username'))
email = forms.CharField(label=_('E-mail'))
class Meta:
model = Profile
fields = ['auto_subscribe', 'time_zone', 'language']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
self.request = extr... | '})
def save(self, commit=True):
post = super(EditPostForm, self).save(commit=False)
post.updated = datetime.now()
topic_name = self.cleaned_data['name']
if topic_name:
post.topic.name = topic_name
if commit:
post.topic.save()
post.save()
... | 79 | 79 | 265 | 8 | 70 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | EssentialsProfileForm | EssentialsProfileForm | 163 | 192 | 163 | 163 | 6a4092c40401beb7344134f1669ee39c44b0c745 | bigcode/the-stack | train |
60b2c738f6f434ac6b3982e9 | train | class | class PersonalityProfileForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['show_avatar', 'signature']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
self.profile = kwargs['instance']
super(PersonalityProfileForm, self).__init__(... | class PersonalityProfileForm(forms.ModelForm):
| class Meta:
model = Profile
fields = ['show_avatar', 'signature']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
self.profile = kwargs['instance']
super(PersonalityProfileForm, self).__init__(*args, **kwargs)
self.fields['signature... | ', 'icq', 'msn', 'aim', 'yahoo']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(MessagingProfileForm, self).__init__(*args, **kwargs)
class PersonalityProfileForm(forms.ModelForm):
| 64 | 64 | 155 | 8 | 56 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | PersonalityProfileForm | PersonalityProfileForm | 235 | 251 | 235 | 235 | 2016fce68c38d1feca8f3682b4ed8245304c5c89 | bigcode/the-stack | train |
7117f98bb09f1aafc3ff9915 | train | class | class PrivacyProfileForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['privacy_permission']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(PrivacyProfileForm, self).__init__(*args, **kwargs)
self.fields['privacy_permission... | class PrivacyProfileForm(forms.ModelForm):
| class Meta:
model = Profile
fields = ['privacy_permission']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(PrivacyProfileForm, self).__init__(*args, **kwargs)
self.fields['privacy_permission'].widget = forms.RadioSelect(
... | Profile
fields = ['theme', 'markup', 'show_smilies']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(DisplayProfileForm, self).__init__(*args, **kwargs)
class PrivacyProfileForm(forms.ModelForm):
| 64 | 64 | 89 | 8 | 56 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | PrivacyProfileForm | PrivacyProfileForm | 264 | 274 | 264 | 264 | 849f287c2b660871648ed21a35719f3386c80cf0 | bigcode/the-stack | train |
98a5cdda39eec11a1239a22d | train | class | class DisplayProfileForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['theme', 'markup', 'show_smilies']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(DisplayProfileForm, self).__init__(*args, **kwargs)
| class DisplayProfileForm(forms.ModelForm):
| class Meta:
model = Profile
fields = ['theme', 'markup', 'show_smilies']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(DisplayProfileForm, self).__init__(*args, **kwargs)
| ':'75'})
def save(self, commit=True):
profile = super(PersonalityProfileForm, self).save(commit=False)
profile.signature_html = convert_text_to_html(profile.signature, self.profile.markup)
if commit:
profile.save()
return profile
class DisplayProfileForm(forms.ModelForm)... | 64 | 64 | 71 | 8 | 55 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | DisplayProfileForm | DisplayProfileForm | 254 | 261 | 254 | 254 | af71905b71c58d8c9b64daba8544381c6a1748eb | bigcode/the-stack | train |
59baf900828f860421b61c21 | train | class | class VotePollForm(forms.Form):
"""
Dynamic form for the poll.
"""
FORM_NAME = "VotePollForm" # used in view and template submit button
choice = forms.MultipleChoiceField()
def __init__(self, poll, *args, **kwargs):
self.poll = poll
super(VotePollForm, self).__init__(*args, **kw... | class VotePollForm(forms.Form):
| """
Dynamic form for the poll.
"""
FORM_NAME = "VotePollForm" # used in view and template submit button
choice = forms.MultipleChoiceField()
def __init__(self, poll, *args, **kwargs):
self.poll = poll
super(VotePollForm, self).__init__(*args, **kwargs)
choices = self.po... | ':'10', 'cols':'75'})
def save(self, commit=True):
report = super(ReportForm, self).save(commit=False)
report.created = datetime.now()
report.reported_by = self.reported_by
if commit:
report.save()
return report
class VotePollForm(forms.Form):
| 68 | 68 | 229 | 7 | 60 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | VotePollForm | VotePollForm | 410 | 438 | 410 | 410 | 4b4c1f08719595d881fa8cfeb4640cd374de2e4f | bigcode/the-stack | train |
56bb4f114df178936916b0be | train | class | class PersonalProfileForm(forms.ModelForm):
name = forms.CharField(label=_('Real name'), required=False)
class Meta:
model = Profile
fields = ['status', 'location', 'site']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
self.profile = kwargs[... | class PersonalProfileForm(forms.ModelForm):
| name = forms.CharField(label=_('Real name'), required=False)
class Meta:
model = Profile
fields = ['status', 'location', 'site']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
self.profile = kwargs['instance']
super(PersonalProfileFor... | ']
self.profile.user.email = self.cleaned_data['email']
self.profile.time_zone = self.cleaned_data['time_zone']
self.profile.language = self.cleaned_data['language']
self.profile.user.save()
if commit:
self.profile.save()
set_language(s... | 75 | 75 | 251 | 8 | 66 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | PersonalProfileForm | PersonalProfileForm | 195 | 222 | 195 | 195 | ea72d266faa92036595535250a57568c8a3f9427 | bigcode/the-stack | train |
ea181e18286190a5e4e51055 | train | class | class ReputationForm(forms.ModelForm):
class Meta:
model = Reputation
fields = ['reason', 'post', 'sign']
def __init__(self, *args, **kwargs):
self.from_user = kwargs.pop('from_user', None)
self.to_user = kwargs.pop('to_user', None)
self.post = kwargs.pop('post', None)
... | class ReputationForm(forms.ModelForm):
| class Meta:
model = Reputation
fields = ['reason', 'post', 'sign']
def __init__(self, *args, **kwargs):
self.from_user = kwargs.pop('from_user', None)
self.to_user = kwargs.pop('to_user', None)
self.post = kwargs.pop('post', None)
self.sign = kwargs.pop('sign', N... | (required=False, label=_('Forum'))
search_in = forms.ChoiceField(choices=SEARCH_IN_CHOICES, label=_('Search in'))
sort_by = forms.ChoiceField(choices=SORT_POST_BY_CHOICES, label=_('Sort by'))
sort_dir = forms.ChoiceField(choices=SORT_DIR_CHOICES, initial='DESC', label=_('Sort order'))
show_as = forms.Ch... | 109 | 110 | 367 | 7 | 102 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | ReputationForm | ReputationForm | 332 | 378 | 332 | 333 | 5b948ec1e7cb34f80deba75b60eb67b04af9d044 | bigcode/the-stack | train |
4363f32e9e98477583924ca2 | train | class | class UploadAvatarForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['avatar']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(UploadAvatarForm, self).__init__(*args, **kwargs)
| class UploadAvatarForm(forms.ModelForm):
| class Meta:
model = Profile
fields = ['avatar']
def __init__(self, *args, **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(UploadAvatarForm, self).__init__(*args, **kwargs)
| , **kwargs):
extra_args = kwargs.pop('extra_args', {})
super(PrivacyProfileForm, self).__init__(*args, **kwargs)
self.fields['privacy_permission'].widget = forms.RadioSelect(
choices=self.fields['privacy_permission'].choices
... | 64 | 64 | 63 | 8 | 56 | jgsogo/bb-djangobb | djangobb_forum/forms.py | Python | UploadAvatarForm | UploadAvatarForm | 277 | 284 | 277 | 277 | 1ee7ebfa7b1c37a34b501ebd293659eeab318758 | bigcode/the-stack | train |
086679d5b1b5740d7dc06286 | train | class | class TestPythonArgh(TestPythonPackageBase):
config = TestPythonPackageBase.config
sample_scripts = ["tests/package/sample_python_argh.py"]
def run_sample_scripts(self):
cmd = self.interpreter + " sample_python_argh.py -h"
output, exit_code = self.emulator.run(cmd)
self.assertIn("us... | class TestPythonArgh(TestPythonPackageBase):
| config = TestPythonPackageBase.config
sample_scripts = ["tests/package/sample_python_argh.py"]
def run_sample_scripts(self):
cmd = self.interpreter + " sample_python_argh.py -h"
output, exit_code = self.emulator.run(cmd)
self.assertIn("usage:", output[0])
self.assertEqual(ex... | from tests.package.test_python import TestPythonPackageBase
class TestPythonArgh(TestPythonPackageBase):
| 21 | 71 | 239 | 10 | 10 | bramkragten/operating-system | buildroot/support/testing/tests/package/test_python_argh.py | Python | TestPythonArgh | TestPythonArgh | 4 | 27 | 4 | 4 | 384c0786651dc970b2faa32d9e2442716de4a9f3 | bigcode/the-stack | train |
123fa21a3c803e7e2fcb1a01 | train | class | class TestPythonPy2Argh(TestPythonArgh):
__test__ = True
config = TestPythonArgh.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_ARGH=y
"""
| class TestPythonPy2Argh(TestPythonArgh):
| __test__ = True
config = TestPythonArgh.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_ARGH=y
"""
| _code, 0)
cmd = self.interpreter + " sample_python_argh.py"
output, exit_code = self.emulator.run(cmd)
self.assertIn("usage:", output[0])
self.assertEqual(exit_code, 2)
class TestPythonPy2Argh(TestPythonArgh):
| 64 | 64 | 53 | 12 | 52 | bramkragten/operating-system | buildroot/support/testing/tests/package/test_python_argh.py | Python | TestPythonPy2Argh | TestPythonPy2Argh | 30 | 36 | 30 | 30 | d9f78aa1cf8f54c5c895395f7722b8a6ac668f42 | bigcode/the-stack | train |
72498ea658e5cece367ae87b | train | class | class TestPythonPy3Argh(TestPythonArgh):
__test__ = True
config = TestPythonArgh.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_ARGH=y
"""
| class TestPythonPy3Argh(TestPythonArgh):
| __test__ = True
config = TestPythonArgh.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_ARGH=y
"""
| PythonPy2Argh(TestPythonArgh):
__test__ = True
config = TestPythonArgh.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_ARGH=y
"""
class TestPythonPy3Argh(TestPythonArgh):
| 63 | 64 | 54 | 12 | 51 | bramkragten/operating-system | buildroot/support/testing/tests/package/test_python_argh.py | Python | TestPythonPy3Argh | TestPythonPy3Argh | 39 | 45 | 39 | 39 | 3409e52319c6cce2ed67543bfaf0dc8026e5e017 | bigcode/the-stack | train |
ffb8ee6aa7df490b21eda084 | train | function | def degree_chi_state(LL, dim, noise_band_mats, inv_struct_bands):
min_ll = (LL+1)//2
chi_state = np.zeros(2*LL+1, dtype = complex)
for ll in range(min_ll, dim):
noise_band_mat = noise_band_mats[ll]
shift = -noise_band_mat.shape[0]//2 + LL
noise_band_mat_mid = np.roll(noise_band_mat, ... | def degree_chi_state(LL, dim, noise_band_mats, inv_struct_bands):
| min_ll = (LL+1)//2
chi_state = np.zeros(2*LL+1, dtype = complex)
for ll in range(min_ll, dim):
noise_band_mat = noise_band_mats[ll]
shift = -noise_band_mat.shape[0]//2 + LL
noise_band_mat_mid = np.roll(noise_band_mat, shift, axis = 0)[:2*LL+1,:]
chi_state += ( noise_band_mat_... | def noise_band_mat(LL, noise_mats):
return diagonals(noise_mats[LL].T)
# compute the fixed-degree components of the "chi state" in the "degree-order" basis
def degree_chi_state(LL, dim, noise_band_mats, inv_struct_bands):
| 64 | 64 | 145 | 20 | 43 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | degree_chi_state | degree_chi_state | 212 | 220 | 212 | 212 | 76b361a5ce05ccc9993ce57dadda8ac689ef9b4d | bigcode/the-stack | train |
4f876e744938c6e6927b476c | train | function | def quantum_error_scale(meas_scales):
dim = len(meas_scales)
return np.sqrt(sum( sqr_gamma(dim, ll) * degree_scale**2
for ll, degree_scale in meas_scales.items() ))
| def quantum_error_scale(meas_scales):
| dim = len(meas_scales)
return np.sqrt(sum( sqr_gamma(dim, ll) * degree_scale**2
for ll, degree_scale in meas_scales.items() ))
| signed_vals = signs * wigner_3j_vals
half_span = ( max(signed_vals) - min(signed_vals) ) / 2
return (2*ll+1) * half_span**2
# compute the quantum error scale
def quantum_error_scale(meas_scales):
| 64 | 64 | 50 | 9 | 54 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | quantum_error_scale | quantum_error_scale | 187 | 190 | 187 | 187 | 804468fb7ca514e88f5146efde9ded361fd2145d | bigcode/the-stack | train |
a8703ed37793d527ea526550 | train | function | def get_prefactors(labels):
dim, ll, LL = [ np.array(vals) for vals in zip(*labels) ]
wigner_6j_degrees = 2 * np.array([ ll, ll, LL ])
wigner_6j_spins = np.array([ dim, dim, dim ]) - 1
wigner_6j_factors = py3nj.wigner6j(*wigner_6j_degrees.astype(int), *wigner_6j_spins)
prefactors = (-1)**(dim-1+LL) ... | def get_prefactors(labels):
| dim, ll, LL = [ np.array(vals) for vals in zip(*labels) ]
wigner_6j_degrees = 2 * np.array([ ll, ll, LL ])
wigner_6j_spins = np.array([ dim, dim, dim ]) - 1
wigner_6j_factors = py3nj.wigner6j(*wigner_6j_degrees.astype(int), *wigner_6j_spins)
prefactors = (-1)**(dim-1+LL) * (2*ll+1) * np.sqrt(2*LL+1)... | ([ (-1)**mm for mm in range(-ll,ll+1) ])
inv_mat = signs[:,None] * np.flipud(mat)
return diagonals(inv_mat, -LL, LL)
# prefactors that convert between wigner-3j coefficients and structure constants
def get_prefactors(labels):
| 64 | 64 | 166 | 6 | 57 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | get_prefactors | get_prefactors | 145 | 151 | 145 | 145 | 3ff5084c20397ef4db8debfd087c8854c434e1a8 | bigcode/the-stack | train |
901ac68a5aa5c7f81fddc8f8 | train | function | def diagonals(mat, band_min = None, band_max = None):
rows, cols = mat.shape
fill = np.zeros(((cols - 1), cols), dtype = mat.dtype)
stacked = np.vstack((mat, fill, mat))
major_stride, minor_stride = stacked.strides
strides = major_stride, minor_stride * (cols + 1)
shape = (rows + cols - 1, cols)... | def diagonals(mat, band_min = None, band_max = None):
| rows, cols = mat.shape
fill = np.zeros(((cols - 1), cols), dtype = mat.dtype)
stacked = np.vstack((mat, fill, mat))
major_stride, minor_stride = stacked.strides
strides = major_stride, minor_stride * (cols + 1)
shape = (rows + cols - 1, cols)
reversed_diags = np.lib.stride_tricks.as_strided(... | matrix.shape[1]:
MM = matrix @ matrix.conj().T
else:
MM = matrix.conj().T @ matrix
return scipy.linalg.eigvalsh(MM)
# get diagonal bands of a matrix
def diagonals(mat, band_min = None, band_max = None):
| 64 | 64 | 192 | 15 | 48 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | diagonals | diagonals | 24 | 36 | 24 | 24 | 7722f45eb14440b3e34a51fae8333c16508a259c | bigcode/the-stack | train |
2f0a60b193f1f8584d969b98 | train | function | def random_state(dim):
point = np.array([ np.random.normal() for _ in range(dim**2) ])
point /= np.sqrt( np.random.exponential() + sum(point**2) )
# organize components into (2L+1)-sized vectors of "degree" L < dim
return { LL : point[ LL**2 : LL**2 + 2*LL+1 ] for LL in range(dim) }
| def random_state(dim):
| point = np.array([ np.random.normal() for _ in range(dim**2) ])
point /= np.sqrt( np.random.exponential() + sum(point**2) )
# organize components into (2L+1)-sized vectors of "degree" L < dim
return { LL : point[ LL**2 : LL**2 + 2*LL+1 ] for LL in range(dim) }
| ]-1) # polar angles
axes[:,1] *= 2*np.pi # azimuthal angles
return axes
# generate a random (probably unphysical) qudit "state",
# represented by a point within a `dim^2`-dimensional hypersphere
def random_state(dim):
| 64 | 64 | 93 | 5 | 58 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | random_state | random_state | 47 | 51 | 47 | 47 | 2913eb5c860a040ae7041287666ac2c79b9bbc98 | bigcode/the-stack | train |
7a0137c28214917fd4de04dc | train | function | def classical_error_scale(meas_scales):
return np.sqrt(sum( degree_scale**2 for degree_scale in meas_scales.values() ))
| def classical_error_scale(meas_scales):
| return np.sqrt(sum( degree_scale**2 for degree_scale in meas_scales.values() ))
| (dim, ll, LL):
return prefactors[dim,ll,LL] * inv_3j_bands[ll,LL]
return inv_struct_bands
##########################################################################################
# methods to compute classical and quantum error scales
# compute the classical error scale
def classical_error_scale(meas_s... | 64 | 64 | 29 | 9 | 54 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | classical_error_scale | classical_error_scale | 174 | 175 | 174 | 174 | 0e3cae3cb09e0b35ff080ee441630b8a29d9e7f6 | bigcode/the-stack | train |
d6be2df81a8388dfa8eea5b4 | train | function | def random_axes(axis_num):
axes = np.random.rand(axis_num,2)
axes[:,0] = np.arccos(2*axes[:,0]-1) # polar angles
axes[:,1] *= 2*np.pi # azimuthal angles
return axes
| def random_axes(axis_num):
| axes = np.random.rand(axis_num,2)
axes[:,0] = np.arccos(2*axes[:,0]-1) # polar angles
axes[:,1] *= 2*np.pi # azimuthal angles
return axes
| -cols
if band_max == None: band_max = +rows
bands = band_max - band_min
return np.roll(diags, -band_min, axis = 0)[:bands+1,:]
# generate random axes on the sphere by uniform sampling
def random_axes(axis_num):
| 64 | 64 | 60 | 6 | 57 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | random_axes | random_axes | 39 | 43 | 39 | 39 | 5322fbae801cf3b0676531f547fb4b92f21d41bf | bigcode/the-stack | train |
5ce562283da6d3cfd896c25e | train | function | def recon_error(state, meas_mat, inv_struct_bands):
dim = max(state.keys()) + 1
_noise_mats = noise_mats(dim, meas_mat)
_chi_state = chi_state(dim, _noise_mats, inv_struct_bands)
kwargs = dict( state = state, chi_state = _chi_state, noise_mats = _noise_mats )
_sqr_degree_error = functools.partial(sq... | def recon_error(state, meas_mat, inv_struct_bands):
| dim = max(state.keys()) + 1
_noise_mats = noise_mats(dim, meas_mat)
_chi_state = chi_state(dim, _noise_mats, inv_struct_bands)
kwargs = dict( state = state, chi_state = _chi_state, noise_mats = _noise_mats )
_sqr_degree_error = functools.partial(sqr_degree_error, **kwargs)
sqr_degree_errors = co... | @ state[LL]
neg = state[LL].conj() @ ( noise_mats[LL] @ state[LL] )
return pos - neg
# compute the reconstruction error for a state in the "degree-order" basis
def recon_error(state, meas_mat, inv_struct_bands):
| 64 | 64 | 143 | 13 | 50 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | recon_error | recon_error | 239 | 246 | 239 | 239 | d2fbcc4cb6308b7e90318aed973a69f8aaf1d86b | bigcode/the-stack | train |
fce4659b7f0106c3031485da | train | function | def get_struct_method(max_dim):
labels = [ ( dim, ll, LL )
for dim in range(max_dim,-1,-1)
for ll in range(dim-1,-1,-1)
for LL in range(min(dim-1,2*ll),-1,-1) ]
prefactors = get_prefactors(labels)
labels = [ ( ll, LL )
for ll in range(max_dim-1,-1... | def get_struct_method(max_dim):
| labels = [ ( dim, ll, LL )
for dim in range(max_dim,-1,-1)
for ll in range(dim-1,-1,-1)
for LL in range(min(dim-1,2*ll),-1,-1) ]
prefactors = get_prefactors(labels)
labels = [ ( ll, LL )
for ll in range(max_dim-1,-1,-1)
for LL in ra... | (-1)**(dim-1+LL) * (2*ll+1) * np.sqrt(2*LL+1) * wigner_6j_factors
return { label : prefactor for label, prefactor in zip(labels, prefactors) }
def get_struct_method(max_dim):
| 64 | 64 | 176 | 7 | 57 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | get_struct_method | get_struct_method | 153 | 168 | 153 | 153 | 2d77bab28418e4bc7a59a01978f516ce9523f48b | bigcode/the-stack | train |
087965de44dd6b48dec83a6a | train | function | def noise_mat(LL, meas_mat):
mat = meas_mat(LL)
vecs, vals, _ = scipy.linalg.svd(mat, full_matrices = False)
diag_vals = np.sum( abs(vecs/vals[None,:])**2, axis = 1)
return ( mat.conj().T * diag_vals[None,:] ) @ mat
| def noise_mat(LL, meas_mat):
| mat = meas_mat(LL)
vecs, vals, _ = scipy.linalg.svd(mat, full_matrices = False)
diag_vals = np.sum( abs(vecs/vals[None,:])**2, axis = 1)
return ( mat.conj().T * diag_vals[None,:] ) @ mat
| return np.sqrt(sum( sqr_gamma(dim, ll) * degree_scale**2
for ll, degree_scale in meas_scales.items() ))
##########################################################################################
# methods to compute the root-mean-squared reconstruction error
# compute the fixed-degree noise m... | 64 | 64 | 80 | 9 | 54 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | noise_mat | noise_mat | 196 | 200 | 196 | 196 | 96ae40a4de474105d5a27e958c865ec29808d512 | bigcode/the-stack | train |
dfad1de9e0af15369c65771a | train | function | def compute_batch(function, args):
args_list = list(args)
values = map(function, args_list)
return { arg : value for arg, value in zip(args_list, values) }
| def compute_batch(function, args):
| args_list = list(args)
values = map(function, args_list)
return { arg : value for arg, value in zip(args_list, values) }
| )-sized vectors of "degree" L < dim
return { LL : point[ LL**2 : LL**2 + 2*LL+1 ] for LL in range(dim) }
# run a batch of independent jobs, possibly in parallel (not yet implemented)
def compute_batch(function, args):
| 64 | 64 | 41 | 7 | 57 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | compute_batch | compute_batch | 54 | 57 | 54 | 54 | 72e15bb94f5125465f9df2b4865a7414b4dbf565 | bigcode/the-stack | train |
b75103aa5a621388e7012ec7 | train | function | def noise_band_mat(LL, noise_mats):
return diagonals(noise_mats[LL].T)
| def noise_band_mat(LL, noise_mats):
| return diagonals(noise_mats[LL].T)
| def noise_mats(dim, meas_mat):
_noise_mat = functools.partial(noise_mat, meas_mat = meas_mat)
return compute_batch(_noise_mat, range(dim-1,-1,-1))
# compute diagonal bands of transposed noise matrices
def noise_band_mat(LL, noise_mats):
| 64 | 64 | 24 | 11 | 52 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | noise_band_mat | noise_band_mat | 208 | 209 | 208 | 208 | 8b021a5f99744f4a9d497d465994dd2ec27194e0 | bigcode/the-stack | train |
9916d13df9f5cb305e2ccdf0 | train | function | def get_meas_methods(max_dim):
# pre-compute spin values and pi/2 rotation matrices exp(-i pi/2 S_y)
spin_vals = compute_batch(_spin_vals, range(max_dim-1,-1,-1))
rot_z_to_x = compute_batch(_rot_z_to_x, range(max_dim-1,-1,-1))
# save the vector `<L,0| exp(+i pi/2 S_y)` for all (relevant) L
# every ... | def get_meas_methods(max_dim):
# pre-compute spin values and pi/2 rotation matrices exp(-i pi/2 S_y)
| spin_vals = compute_batch(_spin_vals, range(max_dim-1,-1,-1))
rot_z_to_x = compute_batch(_rot_z_to_x, range(max_dim-1,-1,-1))
# save the vector `<L,0| exp(+i pi/2 S_y)` for all (relevant) L
# every other entry in this vector is zero, so remove it preemptively
rot_zero_vecs = [ rot_z_to_x[LL].T[LL,:... | ()
MM = _spin_vals(LL)[:-1]
diag_vals = np.sqrt(LL*(LL+1)-MM*(MM+1))
S_m = np.diag(diag_vals, 1)
S_y = ( S_m - S_m.T ) * 1j/2
return scipy.linalg.expm(-1j * np.pi/2 * S_y)
# get methods to compute
# (1) a fixed-degree measurement matrix, and
# (2) all fixed-degree error scales (for many qudit dimen... | 147 | 147 | 491 | 30 | 117 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | get_meas_methods | get_meas_methods | 85 | 120 | 85 | 86 | 400eaebc470c771c8e047d4793534113c91e03c4 | bigcode/the-stack | train |
c5c684aa478eeed744f7f4ee | train | function | def chi_state(dim, noise_mats, inv_struct_bands):
_noise_band_mat = functools.partial(noise_band_mat, noise_mats = noise_mats)
noise_band_mats = compute_batch(_noise_band_mat, range(dim-1,-1,-1))
kwargs = dict( dim = dim,
noise_band_mats = noise_band_mats,
inv_struct_ba... | def chi_state(dim, noise_mats, inv_struct_bands):
| _noise_band_mat = functools.partial(noise_band_mat, noise_mats = noise_mats)
noise_band_mats = compute_batch(_noise_band_mat, range(dim-1,-1,-1))
kwargs = dict( dim = dim,
noise_band_mats = noise_band_mats,
inv_struct_bands = inv_struct_bands )
_degree_chi_state = f... | 1,:]
chi_state += ( noise_band_mat_mid * inv_struct_bands(dim,ll,LL) ).sum(axis = 1)
return chi_state
# compute the full "chi state" in the "degree-order" basis
def chi_state(dim, noise_mats, inv_struct_bands):
| 64 | 64 | 125 | 14 | 49 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | chi_state | chi_state | 223 | 230 | 223 | 223 | 99d567a37bfec3ccc99c4a8c47eeb9b0160120ba | bigcode/the-stack | train |
e041ff3daed47eb5026c563b | train | function | def sqr_gamma(dim, ll):
ss = (dim-1)/2
mm_min, mm_max, wigner_3j_vals = wigner.wigner_3j_m(ll, ss, ss, 0)
signs = np.array([ (-1)**(2*ll+ss-mm) for mm in np.arange(mm_min, mm_max+1) ])
signed_vals = signs * wigner_3j_vals
half_span = ( max(signed_vals) - min(signed_vals) ) / 2
return (2*ll+1) * ... | def sqr_gamma(dim, ll):
| ss = (dim-1)/2
mm_min, mm_max, wigner_3j_vals = wigner.wigner_3j_m(ll, ss, ss, 0)
signs = np.array([ (-1)**(2*ll+ss-mm) for mm in np.arange(mm_min, mm_max+1) ])
signed_vals = signs * wigner_3j_vals
half_span = ( max(signed_vals) - min(signed_vals) ) / 2
return (2*ll+1) * half_span**2
| classical and quantum error scales
# compute the classical error scale
def classical_error_scale(meas_scales):
return np.sqrt(sum( degree_scale**2 for degree_scale in meas_scales.values() ))
# squared "gamma" factors that appear in the quantum error scale
def sqr_gamma(dim, ll):
| 64 | 64 | 129 | 8 | 55 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | sqr_gamma | sqr_gamma | 178 | 184 | 178 | 178 | b561db7289201ea0b002da18d5d95636c9d89c29 | bigcode/the-stack | train |
30d56c0248d363d7fabf3055 | train | function | def _spin_vals(LL):
return np.arange(-LL, LL+1)
| def _spin_vals(LL):
| return np.arange(-LL, LL+1)
| (+i pi/2 S_y) * e^{-i beta S_z} * exp(-i pi/2 S_y) * e^{-i alpha S_z}
# methods to pre-compute spin values and pi/2 rotation matrices exp(-i pi/2 S_y)
def _spin_vals(LL):
| 64 | 64 | 18 | 7 | 57 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | _spin_vals | _spin_vals | 70 | 71 | 70 | 70 | d6470f3d3488636518240f733382e6415d2fc6e8 | bigcode/the-stack | train |
8a61c89c0dc6102e9259a17b | train | function | def _rot_z_to_x(LL, status_updates = _status_updates):
if status_updates:
print("rot:", LL)
sys.stdout.flush()
MM = _spin_vals(LL)[:-1]
diag_vals = np.sqrt(LL*(LL+1)-MM*(MM+1))
S_m = np.diag(diag_vals, 1)
S_y = ( S_m - S_m.T ) * 1j/2
return scipy.linalg.expm(-1j * np.pi/2 * S_y)
| def _rot_z_to_x(LL, status_updates = _status_updates):
| if status_updates:
print("rot:", LL)
sys.stdout.flush()
MM = _spin_vals(LL)[:-1]
diag_vals = np.sqrt(LL*(LL+1)-MM*(MM+1))
S_m = np.diag(diag_vals, 1)
S_y = ( S_m - S_m.T ) * 1j/2
return scipy.linalg.expm(-1j * np.pi/2 * S_y)
| e^{-i alpha S_z}
# methods to pre-compute spin values and pi/2 rotation matrices exp(-i pi/2 S_y)
def _spin_vals(LL):
return np.arange(-LL, LL+1)
def _rot_z_to_x(LL, status_updates = _status_updates):
| 64 | 64 | 115 | 16 | 48 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | _rot_z_to_x | _rot_z_to_x | 72 | 80 | 72 | 72 | c7b78eaf5a3a85c0cd8e5dd61c7a7e335e87e8a3 | bigcode/the-stack | train |
d09b171122740d540207f6ca | train | function | def wigner_3j_mat(ll, LL):
matrix = np.zeros((2*ll+1,)*2)
for mm in range(-ll,ll+1):
start, end, vals = wigner.wigner_3j_m(ll, ll, LL, mm)
matrix[mm+ll, int(start)+ll : int(end)+ll+1] = vals
return matrix
| def wigner_3j_mat(ll, LL):
| matrix = np.zeros((2*ll+1,)*2)
for mm in range(-ll,ll+1):
start, end, vals = wigner.wigner_3j_m(ll, ll, LL, mm)
matrix[mm+ll, int(start)+ll : int(end)+ll+1] = vals
return matrix
| (_meas_scale, range(dim-1,-1,-1))
return meas_mat, meas_scales
##########################################################################################
# methods to compute diagonal bands of an "inverted" matrix of structure constants
# matrix of wigner-3j coefficients
def wigner_3j_mat(ll, LL):
| 64 | 64 | 86 | 11 | 52 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | wigner_3j_mat | wigner_3j_mat | 126 | 131 | 126 | 126 | 7b2a2ed8d469bf5eda0d468224f438e4a33dfbf7 | bigcode/the-stack | train |
6e4048c042697a865e75d142 | train | function | def get_sqr_svdvals(matrix):
# return scipy.linalg.svdvals(matrix)**2 # for some reason this is slower...
if matrix.shape[0] < matrix.shape[1]:
MM = matrix @ matrix.conj().T
else:
MM = matrix.conj().T @ matrix
return scipy.linalg.eigvalsh(MM)
| def get_sqr_svdvals(matrix):
# return scipy.linalg.svdvals(matrix)**2 # for some reason this is slower...
| if matrix.shape[0] < matrix.shape[1]:
MM = matrix @ matrix.conj().T
else:
MM = matrix.conj().T @ matrix
return scipy.linalg.eigvalsh(MM)
|
import numpy as np
import wigner, py3nj
_status_updates = False
##########################################################################################
# general simulation methods
# get squared singular values of a matrix
def get_sqr_svdvals(matrix):
# return scipy.linalg.svdvals(matrix)**2 # for some reas... | 64 | 64 | 77 | 28 | 35 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | get_sqr_svdvals | get_sqr_svdvals | 15 | 21 | 15 | 16 | fad62bcc46bc1271751890b9d76d8211bab7a01b | bigcode/the-stack | train |
0b614cd1fbb6c22ede597e0d | train | function | def inv_3j_band_mat(labels, status_updates = _status_updates):
ll, LL = labels
if status_updates and ll == LL:
print("inv_3j:", LL)
sys.stdout.flush()
mat = wigner_3j_mat(ll, LL)
signs = np.array([ (-1)**mm for mm in range(-ll,ll+1) ])
inv_mat = signs[:,None] * np.flipud(mat)
ret... | def inv_3j_band_mat(labels, status_updates = _status_updates):
| ll, LL = labels
if status_updates and ll == LL:
print("inv_3j:", LL)
sys.stdout.flush()
mat = wigner_3j_mat(ll, LL)
signs = np.array([ (-1)**mm for mm in range(-ll,ll+1) ])
inv_mat = signs[:,None] * np.flipud(mat)
return diagonals(inv_mat, -LL, LL)
| LL, mm)
matrix[mm+ll, int(start)+ll : int(end)+ll+1] = vals
return matrix
# diagonal bands of an "inverted" matrix of wigner-3j factors
def inv_3j_band_mat(labels, status_updates = _status_updates):
| 64 | 64 | 107 | 16 | 47 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | inv_3j_band_mat | inv_3j_band_mat | 134 | 142 | 134 | 134 | 18d543e8d2065a64301cec95070e90b7cf959e24 | bigcode/the-stack | train |
caf98dd63b13bcd11e7325ca | train | function | def sqr_degree_error(LL, state, chi_state, noise_mats):
pos = chi_state[LL].conj() @ state[LL]
neg = state[LL].conj() @ ( noise_mats[LL] @ state[LL] )
return pos - neg
| def sqr_degree_error(LL, state, chi_state, noise_mats):
| pos = chi_state[LL].conj() @ state[LL]
neg = state[LL].conj() @ ( noise_mats[LL] @ state[LL] )
return pos - neg
| degree_chi_state = functools.partial(degree_chi_state, **kwargs)
return compute_batch(_degree_chi_state, range(dim-1,-1,-1))
# compute contribution to squared reconstruction error from a single degree
def sqr_degree_error(LL, state, chi_state, noise_mats):
| 64 | 64 | 63 | 17 | 46 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | sqr_degree_error | sqr_degree_error | 233 | 236 | 233 | 233 | 3a6b900cabf9996e1f45c646418ee2d4eccd054a | bigcode/the-stack | train |
4c319ff2ca651d4d3747693b | train | function | def noise_mats(dim, meas_mat):
_noise_mat = functools.partial(noise_mat, meas_mat = meas_mat)
return compute_batch(_noise_mat, range(dim-1,-1,-1))
| def noise_mats(dim, meas_mat):
| _noise_mat = functools.partial(noise_mat, meas_mat = meas_mat)
return compute_batch(_noise_mat, range(dim-1,-1,-1))
| full_matrices = False)
diag_vals = np.sum( abs(vecs/vals[None,:])**2, axis = 1)
return ( mat.conj().T * diag_vals[None,:] ) @ mat
# compute all noise matrices
def noise_mats(dim, meas_mat):
| 64 | 64 | 43 | 9 | 54 | perlinm/spin_qudit_tomography | qudit_tomo_methods.py | Python | noise_mats | noise_mats | 203 | 205 | 203 | 203 | 0817ba3740e55ee6e05570844676b12bc6d6688c | bigcode/the-stack | train |
db527dc1b24c7ea82c71d302 | train | class | class UserSecretStore(Model):
"""Properties of a user's secret store.
:param key_vault_uri: The URI of the user's Key vault.
:type key_vault_uri: str
:param key_vault_id: The ID of the user's Key vault.
:type key_vault_id: str
"""
_attribute_map = {
'key_vault_uri': {'key': 'keyVau... | class UserSecretStore(Model):
| """Properties of a user's secret store.
:param key_vault_uri: The URI of the user's Key vault.
:type key_vault_uri: str
:param key_vault_id: The ID of the user's Key vault.
:type key_vault_id: str
"""
_attribute_map = {
'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'},
... | MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serial... | 64 | 64 | 176 | 6 | 57 | JonathanGailliez/azure-sdk-for-python | azure-mgmt-devtestlabs/azure/mgmt/devtestlabs/models/user_secret_store.py | Python | UserSecretStore | UserSecretStore | 15 | 32 | 15 | 15 | 1f2ad6f70bd88017cf0b4f7b0c2b8da379c6af23 | bigcode/the-stack | train |
a551364f5d3dcad7afca8407 | train | class | class DirectoryString(univ.Choice):
pass
| class DirectoryString(univ.Choice):
| pass
| the same as Attribute in RFC 5652, except that the
# attrValues SET must have one and only one member
Attribute = rfc7191.SingleAttribute
# DirectoryString is the same as RFC 5280, except the length is limited to 255
class DirectoryString(univ.Choice):
| 64 | 64 | 11 | 8 | 55 | russhousley/pyasn1-modules | pyasn1_alt_modules/rfc7894.py | Python | DirectoryString | DirectoryString | 42 | 43 | 42 | 42 | dc3c5b4fe1a72778e42389fbd63ea87312e10544 | bigcode/the-stack | train |
431f62b19465498a1279c456 | train | class | class CondHclStatusJobApi(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
config = Configuration()
if api_client:
... | class CondHclStatusJobApi(object):
| """
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
config = Configuration()
if api_client:
self.api_client = api_cl... | # coding: utf-8
"""
Intersight REST API
This is Intersight REST API
OpenAPI spec version: 1.0.9-262
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import sys
import os
import re
# python 2 and python 3 compatibility library
from s... | 112 | 256 | 2,961 | 9 | 102 | ategaw-cisco/intersight-python | intersight/apis/cond_hcl_status_job_api.py | Python | CondHclStatusJobApi | CondHclStatusJobApi | 27 | 282 | 27 | 27 | 905b591aa09676d44183c24ce4c2938550b5893a | bigcode/the-stack | train |
498ad07df34c3fa20d602bf3 | train | function | def aumentar(base, percent, formatado=False):
# Se False --> Significa que não quer formatar então não é chamada a função moeda
# Se True --> Significa que quer formatar então é chamada a função moeda
# --/ --/ --> É igual para os restantes <-- \-- \--
aumento_final = base + (base * percent/100)
ret... | def aumentar(base, percent, formatado=False):
# Se False --> Significa que não quer formatar então não é chamada a função moeda
# Se True --> Significa que quer formatar então é chamada a função moeda
# --/ --/ --> É igual para os restantes <-- \-- \--
| aumento_final = base + (base * percent/100)
return aumento_final if formatado is False else moeda(aumento_final)
| def aumentar(base, percent, formatado=False):
# Se False --> Significa que não quer formatar então não é chamada a função moeda
# Se True --> Significa que quer formatar então é chamada a função moeda
# --/ --/ --> É igual para os restantes <-- \-- \--
| 65 | 64 | 93 | 65 | 0 | luisgnc/Python-Exercises | Exercicios20/ex109/moeda_func/__init__.py | Python | aumentar | aumentar | 1 | 6 | 1 | 4 | d4246b857feb551a3bcf7dac4ff444faeef07363 | bigcode/the-stack | train |
a5b9fea9de2d4910312680de | train | function | def dobro(base, formatado=False):
dobrado = base * 2
return dobrado if formatado is False else moeda(dobrado)
| def dobro(base, formatado=False):
| dobrado = base * 2
return dobrado if formatado is False else moeda(dobrado)
| return aumento_final if formatado is False else moeda(aumento_final)
def diminuir(base, percent, formatado=False):
diminuicao_final = base - (base * percent/100)
return diminuicao_final if formatado is False else moeda(diminuicao_final)
def dobro(base, formatado=False):
| 64 | 64 | 32 | 8 | 56 | luisgnc/Python-Exercises | Exercicios20/ex109/moeda_func/__init__.py | Python | dobro | dobro | 14 | 16 | 14 | 14 | 7e2ac179ab4e8d547aa674945c5a5dcbf64deadd | bigcode/the-stack | train |
5d8525b06eb9dcbdfccd8711 | train | function | def diminuir(base, percent, formatado=False):
diminuicao_final = base - (base * percent/100)
return diminuicao_final if formatado is False else moeda(diminuicao_final)
| def diminuir(base, percent, formatado=False):
| diminuicao_final = base - (base * percent/100)
return diminuicao_final if formatado is False else moeda(diminuicao_final)
| formatar então é chamada a função moeda
# --/ --/ --> É igual para os restantes <-- \-- \--
aumento_final = base + (base * percent/100)
return aumento_final if formatado is False else moeda(aumento_final)
def diminuir(base, percent, formatado=False):
| 64 | 64 | 41 | 10 | 54 | luisgnc/Python-Exercises | Exercicios20/ex109/moeda_func/__init__.py | Python | diminuir | diminuir | 9 | 11 | 9 | 9 | 3c9a9455868b9ce78129147907a0c5e3af9fabf2 | bigcode/the-stack | train |
29b9533ac627e9fa74ac74e0 | train | function | def moeda(valor):
valor = str(valor)
valor = 'R$' + valor.replace('.', ',')
return valor
| def moeda(valor):
| valor = str(valor)
valor = 'R$' + valor.replace('.', ',')
return valor
| dobro(base, formatado=False):
dobrado = base * 2
return dobrado if formatado is False else moeda(dobrado)
def metade(base, formatado=False):
half = base / 2
return half if formatado is False else moeda(half)
def moeda(valor):
| 64 | 64 | 27 | 4 | 60 | luisgnc/Python-Exercises | Exercicios20/ex109/moeda_func/__init__.py | Python | moeda | moeda | 24 | 27 | 24 | 24 | 9be36d9ae29cf78bf23450022482d2427b7577e5 | bigcode/the-stack | train |
c8bf14683b83f4a2fd6f4983 | train | function | def metade(base, formatado=False):
half = base / 2
return half if formatado is False else moeda(half)
| def metade(base, formatado=False):
| half = base / 2
return half if formatado is False else moeda(half)
| (base * percent/100)
return diminuicao_final if formatado is False else moeda(diminuicao_final)
def dobro(base, formatado=False):
dobrado = base * 2
return dobrado if formatado is False else moeda(dobrado)
def metade(base, formatado=False):
| 64 | 64 | 29 | 8 | 56 | luisgnc/Python-Exercises | Exercicios20/ex109/moeda_func/__init__.py | Python | metade | metade | 19 | 21 | 19 | 19 | 9d103f0472831ef8f57dc2469f6409c96c39da27 | bigcode/the-stack | train |
964c0ba9dac48293f5dde127 | train | class | class Solution(object):
def swapPairs(self, head):
"""
:type head: ListNodex
:rtype: ListNode
"""
"""
Method 1:
p0 -> p1 -> p2 -> p3
Your runtime beats 44.87 % of python submissions.
"""
dummy = p0 = ListNode(0)
dummy.next = hea... | class Solution(object):
| def swapPairs(self, head):
"""
:type head: ListNodex
:rtype: ListNode
"""
"""
Method 1:
p0 -> p1 -> p2 -> p3
Your runtime beats 44.87 % of python submissions.
"""
dummy = p0 = ListNode(0)
dummy.next = head
while p0.next... | use only constant space. You may not modify the values in the list, only nodes itself can be changed
"""
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
| 64 | 64 | 150 | 4 | 59 | KartikKannapur/Data_Structures_and_Algorithms_Python | 00_Code/01_LeetCode/24_SwapNodesinPairs.py | Python | Solution | Solution | 19 | 43 | 19 | 19 | 75a5161757ab464654e27c91c51dca07e0aa6ac2 | bigcode/the-stack | train |
6d6a2f01e56efac841f428a4 | train | function | def cozmo_program(robot: cozmo.robot.Robot):
"""
Main entry point for running the scoring logic in the capture the flag game.
:param robot: judge robot in the game
"""
# get number of teams playing in the game
while True:
try:
teams: int = int(input("How many teams are play... | def cozmo_program(robot: cozmo.robot.Robot):
| """
Main entry point for running the scoring logic in the capture the flag game.
:param robot: judge robot in the game
"""
# get number of teams playing in the game
while True:
try:
teams: int = int(input("How many teams are playing?"))
except ValueError:
... | """Capture the Flag game mode for cozmo
Authors: Matthew Dargan, Daniel Stutz
"""
import concurrent.futures
import socket
from typing import Dict
from common.message_forwarder import start_connection, receive_message
from common.setup import *
def cozmo_program(robot: cozmo.robot.Robot):
| 64 | 189 | 630 | 12 | 52 | matthewdargan/Cozmo-Capture-the-Flag | judge.py | Python | cozmo_program | cozmo_program | 12 | 95 | 12 | 12 | 86df8dfcfef5cfead63367e10360143f30eadf80 | bigcode/the-stack | train |
fd90b6092bc76c6f84d5eb52 | train | class | class RPeak(DMmodel):
def __init__(self, time_series, *args, **para_dict):
self.series_data = time_series.val_tensor
self.sampling_rate = param_default(para_dict, 'sampling_rate', param_default_dict)
self.left_size = param_default(para_dict, 'left_size', param_default_dict)
self.righ... | class RPeak(DMmodel):
| def __init__(self, time_series, *args, **para_dict):
self.series_data = time_series.val_tensor
self.sampling_rate = param_default(para_dict, 'sampling_rate', param_default_dict)
self.left_size = param_default(para_dict, 'left_size', param_default_dict)
self.right_size = param_default... | from biosppy.signals import ecg
from .._model import DMmodel
from . import param_default, DTensor
param_default_dict = {
'sampling_rate': 360,
'left_size': 120,
'right_size': 136,
'out_path': None
}
class RPeak(DMmodel):
| 70 | 86 | 288 | 7 | 63 | sunxiaobing1999/spartan2 | spartan/model/rpeak/RPeak.py | Python | RPeak | RPeak | 14 | 39 | 14 | 14 | 869722f218c1200e6fefaee503d07782e6636ece | bigcode/the-stack | train |
f3a1e07a8ccf2310d97b3af0 | train | function | def setup(sphinx):
sphinx.add_config_value('recommonmark_config', {
'enable_eval_rst': True,
'enable_auto_toc_tree': False,
}, True)
sphinx.add_transform(AutoStructify)
| def setup(sphinx):
| sphinx.add_config_value('recommonmark_config', {
'enable_eval_rst': True,
'enable_auto_toc_tree': False,
}, True)
sphinx.add_transform(AutoStructify)
| rst_include']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# Setup Sphinx
def setup(sphinx):
| 64 | 64 | 50 | 5 | 58 | zimnx/scylla-manager | docs/source/conf.py | Python | setup | setup | 74 | 79 | 74 | 74 | fef5fb8f16015834f75c1b233692dc260f563e36 | bigcode/the-stack | train |
fbff1f6ab2579edd9812954d | train | class | class PipelineMeta(ParameterizedMetaclass):
# Public methods that should not be wrapped
blacklist = ['__init__', 'clone']
def __new__(mcs, classname, bases, classdict):
for method_name in classdict:
method_fn = classdict[method_name]
if method_name in mcs.blacklist or meth... | class PipelineMeta(ParameterizedMetaclass):
# Public methods that should not be wrapped
| blacklist = ['__init__', 'clone']
def __new__(mcs, classname, bases, classdict):
for method_name in classdict:
method_fn = classdict[method_name]
if method_name in mcs.blacklist or method_name.startswith('_'):
continue
elif isinstance(method_fn, type... | if len(kdims) == selected.ndims or not groupby:
# Propagate dataset
params['dataset'] = self._element.dataset
params['pipeline'] = self._element._pipeline
element = new_type(selected, **params)
return element.sort() if sort else element
group =... | 131 | 131 | 438 | 18 | 112 | wuyuanyi135/holoviews | holoviews/core/data/__init__.py | Python | PipelineMeta | PipelineMeta | 186 | 251 | 186 | 188 | 19a0038578905a01c281385416974ad6423a8403 | bigcode/the-stack | train |
b06a2123850a8163090fc26e | train | function | def concat(datasets, datatype=None):
"""Concatenates collection of datasets along NdMapping dimensions.
Concatenates multiple datasets wrapped in an NdMapping type along
all of its dimensions. Before concatenation all datasets are cast
to the same datatype, which may be explicitly defined or
implic... | def concat(datasets, datatype=None):
| """Concatenates collection of datasets along NdMapping dimensions.
Concatenates multiple datasets wrapped in an NdMapping type along
all of its dimensions. Before concatenation all datasets are cast
to the same datatype, which may be explicitly defined or
implicitly derived from the first datatype ... | (Conditional API import)
datatypes.append('dask')
except ImportError:
pass
if 'array' not in datatypes:
datatypes.append('array')
if 'multitabular' not in datatypes:
datatypes.append('multitabular')
def concat(datasets, datatype=None):
| 64 | 64 | 185 | 8 | 56 | wuyuanyi135/holoviews | holoviews/core/data/__init__.py | Python | concat | concat | 75 | 95 | 75 | 75 | fe945ded3b62e0ab581decb1385a25e4009891da | bigcode/the-stack | train |
271f1111f4ba44dd06d957c0 | train | class | class DataConversion(object):
"""
DataConversion is a very simple container object which can be
given an existing Dataset Element and provides methods to convert
the Dataset into most other Element types.
"""
def __init__(self, element):
self._element = element
def __call__(self, n... | class DataConversion(object):
| """
DataConversion is a very simple container object which can be
given an existing Dataset Element and provides methods to convert
the Dataset into most other Element types.
"""
def __init__(self, element):
self._element = element
def __call__(self, new_type, kdims=None, vdims=Non... | .dask import DaskInterface # noqa (Conditional API import)
datatypes.append('dask')
except ImportError:
pass
if 'array' not in datatypes:
datatypes.append('array')
if 'multitabular' not in datatypes:
datatypes.append('multitabular')
def concat(datasets, datatype=None):
"""Concatenates collecti... | 256 | 256 | 947 | 5 | 251 | wuyuanyi135/holoviews | holoviews/core/data/__init__.py | Python | DataConversion | DataConversion | 98 | 183 | 98 | 98 | 449b52d00886e81dff39ec2c150edc487461060d | bigcode/the-stack | train |
de1a97e28008fd6f7c77adef | train | class | @add_metaclass(PipelineMeta)
class Dataset(Element):
"""
Dataset provides a general baseclass for Element types that
contain structured data and supports a range of data formats.
The Dataset class supports various methods offering a consistent
way of working with the stored data regardless of the s... | @add_metaclass(PipelineMeta)
class Dataset(Element):
| """
Dataset provides a general baseclass for Element types that
contain structured data and supports a range of data formats.
The Dataset class supports various methods offering a consistent
way of working with the stored data regardless of the storage
format used. These operations include inde... | inst._in_method
if not in_method:
inst._in_method = True
try:
result = method_fn(*args, **kwargs)
op = method_op.instance(
input_type=type(inst),
method_name=method_name,
args=list(args... | 256 | 256 | 8,205 | 12 | 243 | wuyuanyi135/holoviews | holoviews/core/data/__init__.py | Python | Dataset | Dataset | 254 | 1,229 | 254 | 255 | 1d89bc1624c79fdf44506cc42e1b5ee661bdacd6 | bigcode/the-stack | train |
b7283dc8a8b31c498e22244d | train | function | def test_bad_kwarg():
good_arg = "f"
bad_arg = good_arg + "o"
compat_args = {good_arg: "foo", bad_arg + "o": "bar"}
kwargs = {good_arg: "foo", bad_arg: "bar"}
msg = rf"{_fname}\(\) got an unexpected keyword argument '{bad_arg}'"
with pytest.raises(TypeError, match=msg):
validate_kwarg... | def test_bad_kwarg():
| good_arg = "f"
bad_arg = good_arg + "o"
compat_args = {good_arg: "foo", bad_arg + "o": "bar"}
kwargs = {good_arg: "foo", bad_arg: "bar"}
msg = rf"{_fname}\(\) got an unexpected keyword argument '{bad_arg}'"
with pytest.raises(TypeError, match=msg):
validate_kwargs(_fname, kwargs, comp... | import pytest
from pandas.util._validators import (
validate_bool_kwarg,
validate_kwargs,
)
_fname = "func"
def test_bad_kwarg():
| 32 | 64 | 101 | 6 | 26 | 13rianlucero/CrabAgePrediction | crabageprediction/venv/Lib/site-packages/pandas/tests/util/test_validate_kwargs.py | Python | test_bad_kwarg | test_bad_kwarg | 11 | 21 | 11 | 11 | f88a4fee6b40f7937c6b9564aa9729c5ba55b460 | bigcode/the-stack | train |
5761cacb155238681b724f4d | train | function | @pytest.mark.parametrize("name", ["inplace", "copy"])
@pytest.mark.parametrize("value", [True, False, None])
def test_validate_bool_kwarg(name, value):
assert validate_bool_kwarg(value, name) == value
| @pytest.mark.parametrize("name", ["inplace", "copy"])
@pytest.mark.parametrize("value", [True, False, None])
def test_validate_bool_kwarg(name, value):
| assert validate_bool_kwarg(value, name) == value
| type(value).__name__}"
)
with pytest.raises(ValueError, match=msg):
validate_bool_kwarg(value, name)
@pytest.mark.parametrize("name", ["inplace", "copy"])
@pytest.mark.parametrize("value", [True, False, None])
def test_validate_bool_kwarg(name, value):
| 64 | 64 | 49 | 36 | 28 | 13rianlucero/CrabAgePrediction | crabageprediction/venv/Lib/site-packages/pandas/tests/util/test_validate_kwargs.py | Python | test_validate_bool_kwarg | test_validate_bool_kwarg | 63 | 66 | 63 | 65 | ab495848c61c30c3ce751292011dfa07a028fa3e | bigcode/the-stack | train |
d8915f2b7230f1d42e591f29 | train | function | def test_validation():
# No exceptions should be raised.
compat_args = {"f": None, "b": 1, "ba": "s"}
kwargs = {"f": None, "b": 1}
validate_kwargs(_fname, kwargs, compat_args)
| def test_validation():
# No exceptions should be raised.
| compat_args = {"f": None, "b": 1, "ba": "s"}
kwargs = {"f": None, "b": 1}
validate_kwargs(_fname, kwargs, compat_args)
| kwarg_vals = (2, "s", None)
kwargs = dict(zip(kwarg_keys[:i], kwarg_vals[:i]))
with pytest.raises(ValueError, match=msg):
validate_kwargs(_fname, kwargs, compat_args)
def test_validation():
# No exceptions should be raised.
| 64 | 64 | 58 | 12 | 52 | 13rianlucero/CrabAgePrediction | crabageprediction/venv/Lib/site-packages/pandas/tests/util/test_validate_kwargs.py | Python | test_validation | test_validation | 43 | 48 | 43 | 44 | c225950964e3786e7b8ab341da1ac68d229bf630 | bigcode/the-stack | train |
322919086dbd310b6f202d94 | train | function | @pytest.mark.parametrize("name", ["inplace", "copy"])
@pytest.mark.parametrize("value", [1, "True", [1, 2, 3], 5.0])
def test_validate_bool_kwarg_fail(name, value):
msg = (
f'For argument "{name}" expected type bool, '
f"received type {type(value).__name__}"
)
with pytest.raises(ValueError,... | @pytest.mark.parametrize("name", ["inplace", "copy"])
@pytest.mark.parametrize("value", [1, "True", [1, 2, 3], 5.0])
def test_validate_bool_kwarg_fail(name, value):
| msg = (
f'For argument "{name}" expected type bool, '
f"received type {type(value).__name__}"
)
with pytest.raises(ValueError, match=msg):
validate_bool_kwarg(value, name)
| 1}
validate_kwargs(_fname, kwargs, compat_args)
@pytest.mark.parametrize("name", ["inplace", "copy"])
@pytest.mark.parametrize("value", [1, "True", [1, 2, 3], 5.0])
def test_validate_bool_kwarg_fail(name, value):
| 64 | 64 | 101 | 50 | 14 | 13rianlucero/CrabAgePrediction | crabageprediction/venv/Lib/site-packages/pandas/tests/util/test_validate_kwargs.py | Python | test_validate_bool_kwarg_fail | test_validate_bool_kwarg_fail | 51 | 60 | 51 | 53 | 49c59ed25c0272859226f11cd5d3388d582783c1 | bigcode/the-stack | train |
317b1aadaa7c643ce3351695 | train | function | @pytest.mark.parametrize("i", range(1, 3))
def test_not_all_none(i):
bad_arg = "foo"
msg = (
rf"the '{bad_arg}' parameter is not supported "
rf"in the pandas implementation of {_fname}\(\)"
)
compat_args = {"foo": 1, "bar": "s", "baz": None}
kwarg_keys = ("foo", "bar", "baz")
k... | @pytest.mark.parametrize("i", range(1, 3))
def test_not_all_none(i):
| bad_arg = "foo"
msg = (
rf"the '{bad_arg}' parameter is not supported "
rf"in the pandas implementation of {_fname}\(\)"
)
compat_args = {"foo": 1, "bar": "s", "baz": None}
kwarg_keys = ("foo", "bar", "baz")
kwarg_vals = (2, "s", None)
kwargs = dict(zip(kwarg_keys[:i], kwa... | bar"}
msg = rf"{_fname}\(\) got an unexpected keyword argument '{bad_arg}'"
with pytest.raises(TypeError, match=msg):
validate_kwargs(_fname, kwargs, compat_args)
@pytest.mark.parametrize("i", range(1, 3))
def test_not_all_none(i):
| 64 | 64 | 146 | 20 | 44 | 13rianlucero/CrabAgePrediction | crabageprediction/venv/Lib/site-packages/pandas/tests/util/test_validate_kwargs.py | Python | test_not_all_none | test_not_all_none | 24 | 40 | 24 | 25 | 8c5ca823a529cb2b2865157bdd8795e945098ec3 | bigcode/the-stack | train |
8eef0a59b5a5878d01671491 | train | function | def los_from_pixel_coord_1D(x_index, num_pixels, pixel_thick, theta_detector, minor_radius=0.52, det_dist=0.0306, signed=True):
"""
This function takes the pixel x-index as an input and returns the signed impact parameters
associated with its line-of-sight. Must also supply the number of pixels, the thickne... | def los_from_pixel_coord_1D(x_index, num_pixels, pixel_thick, theta_detector, minor_radius=0.52, det_dist=0.0306, signed=True):
| """
This function takes the pixel x-index as an input and returns the signed impact parameters
associated with its line-of-sight. Must also supply the number of pixels, the thickness of each
pixel, and the poloidal position of the detector. All distances are in meters, angles in radians.
"""
x_d... | return -1.*x_dim/np.tan(self.impact_phi) + self.impact_p/np.sin(self.impact_phi)
def los_from_pixel_coord_1D(x_index, num_pixels, pixel_thick, theta_detector, minor_radius=0.52, det_dist=0.0306, signed=True):
| 67 | 67 | 224 | 39 | 28 | pdvanmeter/meSXR | mst_ida/models/base/geometry.py | Python | los_from_pixel_coord_1D | los_from_pixel_coord_1D | 67 | 83 | 67 | 67 | 2c3df4077a83e4517287b9ed622b722503928af3 | bigcode/the-stack | train |
e119665633903b0f6595d5bb | train | class | class flux_coords(object):
"""
This class provides a convenient interface for converting between (x,y) coordinates and shifted
flux surface coordinates, of the sort common in MST plasmas.
Inputs:
- delta_a = (float) Magnitude of the Shafranov shift, in meters.
- delta_h = (float) Magnit... | class flux_coords(object):
| """
This class provides a convenient interface for converting between (x,y) coordinates and shifted
flux surface coordinates, of the sort common in MST plasmas.
Inputs:
- delta_a = (float) Magnitude of the Shafranov shift, in meters.
- delta_h = (float) Magnitude of the LCFS shift, in m... | , det_dist=0.0306, signed=True):
"""
This function takes the pixel x-index as an input and returns the signed impact parameters
associated with its line-of-sight. Must also supply the number of pixels, the thickness of each
pixel, and the poloidal position of the detector. All distances are in meters, a... | 211 | 211 | 704 | 5 | 206 | pdvanmeter/meSXR | mst_ida/models/base/geometry.py | Python | flux_coords | flux_coords | 88 | 155 | 88 | 88 | ab42537e286f9549e79878ea14d21a3f2afe9bce | bigcode/the-stack | train |
c5987e92289533d17eacb83c | train | class | class line_of_sight(object):
"""
This class define a line of sight by the impact parameterization. The 1D coordinate ell then
defines positions along the LoS.
Inputs:
- impact_p = (float) The impact parameter, which is the distance from the MST machine origin to
the line of sight... | class line_of_sight(object):
| """
This class define a line of sight by the impact parameterization. The 1D coordinate ell then
defines positions along the LoS.
Inputs:
- impact_p = (float) The impact parameter, which is the distance from the MST machine origin to
the line of sight along a line which is perpen... | """
This file contains classes and methods to define the geometry of the ME-SXR detector, define and
interpret lines of sight, and related convert between various coordinate systems.
"""
from __future__ import division
import numpy as np
import scipy as sp
import scipy.constants
# Module-wide constants
MST_MINOR_RADIU... | 78 | 159 | 531 | 7 | 70 | pdvanmeter/meSXR | mst_ida/models/base/geometry.py | Python | line_of_sight | line_of_sight | 13 | 64 | 13 | 13 | dd96fd30ad296664f965698ce6677b0ba6a1fb13 | bigcode/the-stack | train |
542ada309f9537cfc33a8b5e | train | function | def sunflower_points(num_points, radius=MST_MINOR_RADIUS, cartesian=True):
"""
This functions allows one to somewhat uniformly place points in a circle. This will mainly be used
for interpolating the charge state fraction profile in two dimensions.
"""
r_set = np.zeros(num_points)
theta_set = np... | def sunflower_points(num_points, radius=MST_MINOR_RADIUS, cartesian=True):
| """
This functions allows one to somewhat uniformly place points in a circle. This will mainly be used
for interpolating the charge state fraction profile in two dimensions.
"""
r_set = np.zeros(num_points)
theta_set = np.zeros(num_points)
x_set = np.zeros(num_points)
y_set = np.zeros(nu... | used internally by multiple calculations. Note that x and y are normalized.
"""
return 1.0 - 4.0*self.alpha*(-x + self.alpha*y**2 + self.delta_a)
# ------------------------------------------------ Utilities ------------------------------------------------
def sunflower_points(num_points, radius=MST_M... | 64 | 65 | 217 | 16 | 47 | pdvanmeter/meSXR | mst_ida/models/base/geometry.py | Python | sunflower_points | sunflower_points | 159 | 183 | 159 | 159 | 4026433aa4194febc6a600a9ba70094f170d41ad | bigcode/the-stack | train |
25a61c62013f2921776630d5 | train | class | class IACSAspectCardinalType(CodeableEnum):
N = ("N")
NE = ("NE")
E = ("E")
SE = ("SE")
S = ("S")
SW = ("SW")
W = ("W")
NW = ("NW")
N_A = ("n/a")
| class IACSAspectCardinalType(CodeableEnum):
| N = ("N")
NE = ("NE")
E = ("E")
SE = ("SE")
S = ("S")
SW = ("SW")
W = ("W")
NW = ("NW")
N_A = ("n/a")
| CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__author__ = 'Kuba Radliński'
from moarri_profile_iacs.utils.enumeratings import CodeableEnum
class IACSAspectCardinalType(CodeableEnum):
| 64 | 64 | 67 | 11 | 52 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSAspectCardinalType | IACSAspectCardinalType | 22 | 31 | 22 | 22 | 1e2de79f35c00ed55d1cd31203fbedcc6f064dea | bigcode/the-stack | train |
cc8eb50cc599374aa4b8f640 | train | class | class IACSDirectionType(CodeableEnum):
TOP_DOWN = ("top down")
BOTTOM_UP = ("bottom up")
| class IACSDirectionType(CodeableEnum):
| TOP_DOWN = ("top down")
BOTTOM_UP = ("bottom up")
| = ("N")
NE = ("NE")
E = ("E")
SE = ("SE")
S = ("S")
SW = ("SW")
W = ("W")
NW = ("NW")
N_A = ("n/a")
class IACSDirectionType(CodeableEnum):
| 64 | 64 | 27 | 10 | 54 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSDirectionType | IACSDirectionType | 34 | 36 | 34 | 34 | e6934d3496c56555d516670fd1517ef650bd2c83 | bigcode/the-stack | train |
ee042cf578cfc39a89799d66 | train | class | class IACSUnitsWeightType(CodeableEnum):
KG = ('kg')
| class IACSUnitsWeightType(CodeableEnum):
| KG = ('kg')
| SurfAreaType(CodeableEnum):
M2KG1 = ('m2kg-1')
class IACSUnitsTempType(CodeableEnum):
DEGC = ('degC')
class IACSUnitsUnitType(CodeableEnum):
ONE = ('1')
class IACSUnitsWeightType(CodeableEnum):
| 64 | 64 | 16 | 10 | 54 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsWeightType | IACSUnitsWeightType | 247 | 248 | 247 | 247 | 404d35565a1157f26ca2e549ce888cc542d4247a | bigcode/the-stack | train |
cca075ea890392d9b84290fc | train | class | class IACSUnitsForceType(CodeableEnum):
N = ('N')
EMPTY = ('')
| class IACSUnitsForceType(CodeableEnum):
| N = ('N')
EMPTY = ('')
| RCX = ('rcx')
RRD = ('rrd')
class IACSUnitsAreaType(CodeableEnum):
M2 = ('m2')
class IACSUnitsDensityType(CodeableEnum):
KGM3 = ('kgm-3')
class IACSUnitsForceType(CodeableEnum):
| 64 | 64 | 21 | 10 | 54 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsForceType | IACSUnitsForceType | 208 | 210 | 208 | 208 | e97f5f2fe1ad0f7884e47fa5f0167dc8c0bc95c5 | bigcode/the-stack | train |
6603fe527c3fd30f48e9d3af | train | class | class IACSGrainSizeType(CodeableEnum):
pass
| class IACSGrainSizeType(CodeableEnum):
| pass
| True
return False
def children(self):
if len(self.code) > 2:
return []
return [x for x in list(IACSGrainShapeType) if x.code.startswith(self.code) and len(x.code)>2]
class IACSGrainSizeType(CodeableEnum):
| 64 | 64 | 14 | 11 | 53 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSGrainSizeType | IACSGrainSizeType | 98 | 99 | 98 | 98 | 0cd101d640b080875eaae9a7ab56521505d02a0a | bigcode/the-stack | train |
661d03e82f98bba974d0c587 | train | function | def IACSComprTestScoreCatType(CodeableEnum):
CTV = ("CTV")
CTE = ("CTE")
CTM = ("CTM")
CTH = ("CTH") | def IACSComprTestScoreCatType(CodeableEnum):
| CTV = ("CTV")
CTE = ("CTE")
CTM = ("CTM")
CTH = ("CTH") | 29 = ('29')
CT_30 = ('30')
def int_val(self):
return int(self.code)
# TODO implement categorisation of CT codes
def to_cat_type(self):
v = self.int_val()
return None
def IACSComprTestScoreCatType(CodeableEnum):
| 64 | 64 | 43 | 12 | 51 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSComprTestScoreCatType | IACSComprTestScoreCatType | 312 | 316 | 312 | 312 | 124034e68343ace6283d3a5a8d40291175f6ceac | bigcode/the-stack | train |
475d9b3df6fc8e33fd5088a4 | train | class | class IACSUnitsDensityType(CodeableEnum):
KGM3 = ('kgm-3')
| class IACSUnitsDensityType(CodeableEnum):
| KGM3 = ('kgm-3')
| ('rsm')
RWA = ('rwa')
RCV = ('rcv')
RCX = ('rcx')
RRD = ('rrd')
class IACSUnitsAreaType(CodeableEnum):
M2 = ('m2')
class IACSUnitsDensityType(CodeableEnum):
| 64 | 64 | 21 | 10 | 54 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsDensityType | IACSUnitsDensityType | 204 | 205 | 204 | 204 | 1b9087b0e634aa8dbb4b550be9dbc4af9f2f423d | bigcode/the-stack | train |
100ac940dffdb02a765c8ca2 | train | function | def IACSComprTestScoreCatType(CodeableEnum):
CTV = ("CTV")
CTE = ("CTE")
CTM = ("CTM")
CTH = ("CTH")
| def IACSComprTestScoreCatType(CodeableEnum):
| CTV = ("CTV")
CTE = ("CTE")
CTM = ("CTM")
CTH = ("CTH")
| ms-1')
EMPTY = ('')
class IACSWindSpdType(CodeableEnum):
C = ('C')
L = ('L')
M = ('M')
S = ('S')
X = ('X')
def IACSComprTestScoreCatType(CodeableEnum):
| 64 | 64 | 43 | 12 | 52 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSComprTestScoreCatType | IACSComprTestScoreCatType | 264 | 268 | 264 | 264 | 2d589e9b206c5298214a105e38e64581c710ed90 | bigcode/the-stack | train |
f44df31440483e24a1604f4d | train | class | class IACSNilReasonType(CodeableEnum):
INAPPLICABLE = ('inapplicable')
MISSING = ('missing')
TEMPLATE = ('template')
UNKNOWN = ('unknown')
WITHHELD = ('withheld')
| class IACSNilReasonType(CodeableEnum):
| INAPPLICABLE = ('inapplicable')
MISSING = ('missing')
TEMPLATE = ('template')
UNKNOWN = ('unknown')
WITHHELD = ('withheld')
| D')
DM = ('D-M')
M = ('M')
MW = ('M-W')
W = ('W')
WV = ('W-V')
V = ('V')
VS = ('V-S')
S = ('S')
class IACSNilReasonType(CodeableEnum):
| 64 | 64 | 49 | 10 | 54 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSNilReasonType | IACSNilReasonType | 144 | 149 | 144 | 144 | 07357efa58277fa71ebd75827ede32797c7b7c12 | bigcode/the-stack | train |
83a6ede24b8a28686580620c | train | class | class IACSGrainShapeType(CodeableEnum):
PP = ('PP')
PP_CO = ('PPco')
PP_ND = ('PPnd')
PP_PL = ('PPpl')
PP_SD = ('PPsd')
PP_IR = ('PPir')
PP_GP = ('PPgp')
PP_HL = ('PPhl')
PP_IP = ('PPip')
PP_RM = ('PPrm')
MM = ('MM')
MM_RP = ('MMrp')
MM_CI = ('MMci')
DF = ('DF')
... | class IACSGrainShapeType(CodeableEnum):
| PP = ('PP')
PP_CO = ('PPco')
PP_ND = ('PPnd')
PP_PL = ('PPpl')
PP_SD = ('PPsd')
PP_IR = ('PPir')
PP_GP = ('PPgp')
PP_HL = ('PPhl')
PP_IP = ('PPip')
PP_RM = ('PPrm')
MM = ('MM')
MM_RP = ('MMrp')
MM_CI = ('MMci')
DF = ('DF')
DF_DC = ('DFdc')
DF_BK = ('DFbk')... | limitations under the License.
__author__ = 'Kuba Radliński'
from moarri_profile_iacs.utils.enumeratings import CodeableEnum
class IACSAspectCardinalType(CodeableEnum):
N = ("N")
NE = ("NE")
E = ("E")
SE = ("SE")
S = ("S")
SW = ("SW")
W = ("W")
NW = ("NW")
N_A = ("n/a")
class ... | 135 | 135 | 451 | 11 | 124 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSGrainShapeType | IACSGrainShapeType | 39 | 95 | 39 | 39 | 9db4a198e3973f50501774083a78535baf52c6b6 | bigcode/the-stack | train |
846b5066ccd126635e081cc7 | train | class | class IACSUnitsInclineType(CodeableEnum):
DEG = ('deg')
| class IACSUnitsInclineType(CodeableEnum):
| DEG = ('deg')
| Enum):
M2 = ('m2')
class IACSUnitsDensityType(CodeableEnum):
KGM3 = ('kgm-3')
class IACSUnitsForceType(CodeableEnum):
N = ('N')
EMPTY = ('')
class IACSUnitsInclineType(CodeableEnum):
| 63 | 64 | 17 | 11 | 52 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsInclineType | IACSUnitsInclineType | 213 | 214 | 213 | 213 | 40182348b9c44f4ab5f35978cf920e3c7e789a87 | bigcode/the-stack | train |
12f56199d30da78e97cc3ca0 | train | class | class IACSHardnessType(CodeableEnum):
F_MINUS = ('F-', 10, 0.75)
F = ('F', 20, 1)
F_PLUS = ('F+', 35, 1.25)
FF4 = ('F-4F', 50, 1.5)
F4_MINUS = ('4F-', 75, 1.75)
F4 = ('4F', 100, 2)
F4_PLUS = ('4F+', 137, 2.25)
F4F1 = ('4F-1F', 175, 2.5)
F1_MINUS = ('1F-', 210, 2.75)
F1 = ('1F', 2... | class IACSHardnessType(CodeableEnum):
| F_MINUS = ('F-', 10, 0.75)
F = ('F', 20, 1)
F_PLUS = ('F+', 35, 1.25)
FF4 = ('F-4F', 50, 1.5)
F4_MINUS = ('4F-', 75, 1.75)
F4 = ('4F', 100, 2)
F4_PLUS = ('4F+', 137, 2.25)
F4F1 = ('4F-1F', 175, 2.5)
F1_MINUS = ('1F-', 210, 2.75)
F1 = ('1F', 250, 3)
F1_PLUS = ('1F+', 235, 3.25... | ('IFbi')
IF_RC = ('IFrc')
IF_SC = ('IFsc')
def is_parent(self):
if len(self.children()) > 0:
return True
return False
def children(self):
if len(self.code) > 2:
return []
return [x for x in list(IACSGrainShapeType) if x.code.startswith(self.code... | 116 | 116 | 389 | 11 | 104 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSHardnessType | IACSHardnessType | 102 | 129 | 102 | 102 | 6b3f9852c5538803a8bbba1c533273fcc626348e | bigcode/the-stack | train |
396bf8c6dd9fc50f73fccfe2 | train | class | class IACSPrecipTIType(CodeableEnum):
DZ_MINUS = ('-DZ')
DZ = ('DZ')
DZ_PLUS = ('+DZ')
RA_MINUS = ('-RA')
RA = ('RA')
RA_PLUS = ('+RA')
SN_MINUS = ('-SN')
SN = ('SN')
SN_PLUS = ('+SN')
SG_MINUS = ('-SG')
SG = ('SG')
SG_PLUS = ('+SG')
IC_MINUS = ('-IC')
IC = ('IC')... | class IACSPrecipTIType(CodeableEnum):
| DZ_MINUS = ('-DZ')
DZ = ('DZ')
DZ_PLUS = ('+DZ')
RA_MINUS = ('-RA')
RA = ('RA')
RA_PLUS = ('+RA')
SN_MINUS = ('-SN')
SN = ('SN')
SN_PLUS = ('+SN')
SG_MINUS = ('-SG')
SG = ('SG')
SG_PLUS = ('+SG')
IC_MINUS = ('-IC')
IC = ('IC')
IC_PLUS = ('+IC')
PE_MINUS = ... | S = ('S')
class IACSNilReasonType(CodeableEnum):
INAPPLICABLE = ('inapplicable')
MISSING = ('missing')
TEMPLATE = ('template')
UNKNOWN = ('unknown')
WITHHELD = ('withheld')
class IACSPrecipTIType(CodeableEnum):
| 65 | 65 | 217 | 11 | 54 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSPrecipTIType | IACSPrecipTIType | 152 | 180 | 152 | 152 | 9702cc7890d9f68bf6303c02bedfc549d29725fc | bigcode/the-stack | train |
db2b5c4df045a7de579ef297 | train | class | class IACSComprTestScoreNumType(CodeableEnum):
CT_0 = ('0')
CT_01 = ('1')
CT_02 = ('2')
CT_03 = ('3')
CT_04 = ('4')
CT_05 = ('5')
CT_06 = ('6')
CT_07 = ('7')
CT_08 = ('8')
CT_09 = ('9')
CT_10 = ('10')
CT_11 = ('11')
CT_12 = ('12')
CT_13 = ('13')
CT_14 = ('14')... | class IACSComprTestScoreNumType(CodeableEnum):
| CT_0 = ('0')
CT_01 = ('1')
CT_02 = ('2')
CT_03 = ('3')
CT_04 = ('4')
CT_05 = ('5')
CT_06 = ('6')
CT_07 = ('7')
CT_08 = ('8')
CT_09 = ('9')
CT_10 = ('10')
CT_11 = ('11')
CT_12 = ('12')
CT_13 = ('13')
CT_14 = ('14')
CT_15 = ('15')
CT_16 = ('16')
CT_1... | (CodeableEnum):
C = ('C')
L = ('L')
M = ('M')
S = ('S')
X = ('X')
def IACSComprTestScoreCatType(CodeableEnum):
CTV = ("CTV")
CTE = ("CTE")
CTM = ("CTM")
CTH = ("CTH")
class IACSComprTestScoreNumType(CodeableEnum):
| 89 | 89 | 299 | 12 | 77 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSComprTestScoreNumType | IACSComprTestScoreNumType | 271 | 310 | 271 | 271 | 576fe41c2e4b2627988a23be26671df7a2c6a550 | bigcode/the-stack | train |
9655d747f568b12ebb77c98d | train | class | class IACSUnitsSpecSurfAreaType(CodeableEnum):
M2KG1 = ('m2kg-1')
| class IACSUnitsSpecSurfAreaType(CodeableEnum):
| M2KG1 = ('m2kg-1')
| class IACSUnitsLwcType(CodeableEnum):
PRCVOL = ('% per Vol')
EMPTY = ('')
class IACSUnitsPressureType(CodeableEnum):
NM2 = ('Nm-2')
PA = ('Pa')
class IACSUnitsSpecSurfAreaType(CodeableEnum):
| 64 | 64 | 25 | 12 | 52 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsSpecSurfAreaType | IACSUnitsSpecSurfAreaType | 235 | 236 | 235 | 235 | 4bf8ba1c80883ca817292fbdf9f7ee3312bd9783 | bigcode/the-stack | train |
da49099de35b9fd4d463ecaa | train | class | class IACSUnitsLwcType(CodeableEnum):
PRCVOL = ('% per Vol')
EMPTY = ('')
| class IACSUnitsLwcType(CodeableEnum):
| PRCVOL = ('% per Vol')
EMPTY = ('')
| InclineType(CodeableEnum):
DEG = ('deg')
class IACSUnitsLengthType(CodeableEnum):
CM = ('cm')
MM = ('mm')
M = ('m')
IN = ('in')
FT = ('ft')
class IACSUnitsLwcType(CodeableEnum):
| 64 | 64 | 26 | 11 | 53 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsLwcType | IACSUnitsLwcType | 225 | 227 | 225 | 225 | 856fa63161074936d1577802d78a071fea9eaa49 | bigcode/the-stack | train |
4ff29e4342c77e018a3e7250 | train | class | class IACSUnitsLengthType(CodeableEnum):
CM = ('cm')
MM = ('mm')
M = ('m')
IN = ('in')
FT = ('ft')
| class IACSUnitsLengthType(CodeableEnum):
| CM = ('cm')
MM = ('mm')
M = ('m')
IN = ('in')
FT = ('ft')
| (CodeableEnum):
KGM3 = ('kgm-3')
class IACSUnitsForceType(CodeableEnum):
N = ('N')
EMPTY = ('')
class IACSUnitsInclineType(CodeableEnum):
DEG = ('deg')
class IACSUnitsLengthType(CodeableEnum):
| 64 | 64 | 40 | 10 | 54 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsLengthType | IACSUnitsLengthType | 217 | 222 | 217 | 217 | de4c2bc2fddcb91e820f13abdd0b2f4dd73cde11 | bigcode/the-stack | train |
ff39f4ca2e3ed59a5d34116a | train | class | class IACSUnitsTempType(CodeableEnum):
DEGC = ('degC')
| class IACSUnitsTempType(CodeableEnum):
| DEGC = ('degC')
| = ('')
class IACSUnitsPressureType(CodeableEnum):
NM2 = ('Nm-2')
PA = ('Pa')
class IACSUnitsSpecSurfAreaType(CodeableEnum):
M2KG1 = ('m2kg-1')
class IACSUnitsTempType(CodeableEnum):
| 64 | 64 | 18 | 10 | 54 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsTempType | IACSUnitsTempType | 239 | 240 | 239 | 239 | ebfe91d422a91b25bced2fa3eecb5b2458d19e2a | bigcode/the-stack | train |
8cc9f5435cd061bab122230b | train | class | class IACSSurfaceRoughnessType(CodeableEnum):
RSM = ('rsm')
RWA = ('rwa')
RCV = ('rcv')
RCX = ('rcx')
RRD = ('rrd')
| class IACSSurfaceRoughnessType(CodeableEnum):
| RSM = ('rsm')
RWA = ('rwa')
RCV = ('rcv')
RCX = ('rcx')
RRD = ('rrd')
| SSkyConditionType(CodeableEnum):
CLR = ('CLR')
FEW = ('FEW')
SCI = ('SCT')
BKN = ('BKN')
OVC = ('OVC')
X = ('X')
class IACSSurfaceRoughnessType(CodeableEnum):
| 64 | 64 | 53 | 13 | 51 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSSurfaceRoughnessType | IACSSurfaceRoughnessType | 192 | 197 | 192 | 192 | 2d71f89a51d51d53f1a6bcabba39174e5cce0872 | bigcode/the-stack | train |
431983f38f28a07f5bd7846c | train | class | class IACSUnitsWindSpdType(CodeableEnum):
MS1 = ('ms-1')
EMPTY = ('')
| class IACSUnitsWindSpdType(CodeableEnum):
| MS1 = ('ms-1')
EMPTY = ('')
| 1')
class IACSUnitsTempType(CodeableEnum):
DEGC = ('degC')
class IACSUnitsUnitType(CodeableEnum):
ONE = ('1')
class IACSUnitsWeightType(CodeableEnum):
KG = ('kg')
class IACSUnitsWindSpdType(CodeableEnum):
| 64 | 64 | 26 | 12 | 52 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsWindSpdType | IACSUnitsWindSpdType | 251 | 253 | 251 | 251 | fe14d7bde1987b482594c7a6e1006a91ae2d6eed | bigcode/the-stack | train |
bc522510d68d4542d3533663 | train | class | class IACSUnitsAreaType(CodeableEnum):
M2 = ('m2')
| class IACSUnitsAreaType(CodeableEnum):
| M2 = ('m2')
| ')
class IACSSurfaceRoughnessType(CodeableEnum):
RSM = ('rsm')
RWA = ('rwa')
RCV = ('rcv')
RCX = ('rcx')
RRD = ('rrd')
class IACSUnitsAreaType(CodeableEnum):
| 64 | 64 | 18 | 10 | 54 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsAreaType | IACSUnitsAreaType | 200 | 201 | 200 | 200 | 04a35409540cdbfdf9500994b9c614b2eb16272f | bigcode/the-stack | train |
5c2d3bb2e21d9c8275f3ac79 | train | class | class IACSSkyConditionType(CodeableEnum):
CLR = ('CLR')
FEW = ('FEW')
SCI = ('SCT')
BKN = ('BKN')
OVC = ('OVC')
X = ('X')
| class IACSSkyConditionType(CodeableEnum):
| CLR = ('CLR')
FEW = ('FEW')
SCI = ('SCT')
BKN = ('BKN')
OVC = ('OVC')
X = ('X')
| ')
GS_MINUS = ('-GS')
GS = ('GS')
GS_PLUS = ('+GS')
UP = ('UP')
NIL = ('Nil')
RASN = ('RASN')
FZRA = ('FZRA')
class IACSSkyConditionType(CodeableEnum):
| 64 | 64 | 54 | 11 | 53 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSSkyConditionType | IACSSkyConditionType | 183 | 189 | 183 | 183 | 9479f5f09e971725cf8d323f200175cde4ddf09f | bigcode/the-stack | train |
92427903d86834593b732875 | train | class | class IACSUnitsUnitType(CodeableEnum):
ONE = ('1')
| class IACSUnitsUnitType(CodeableEnum):
| ONE = ('1')
| ('Nm-2')
PA = ('Pa')
class IACSUnitsSpecSurfAreaType(CodeableEnum):
M2KG1 = ('m2kg-1')
class IACSUnitsTempType(CodeableEnum):
DEGC = ('degC')
class IACSUnitsUnitType(CodeableEnum):
| 64 | 64 | 16 | 10 | 54 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsUnitType | IACSUnitsUnitType | 243 | 244 | 243 | 243 | 3f079ef8125148840269561c30922c9cbf81cb2c | bigcode/the-stack | train |
334304134a62db3f08d4cdd3 | train | class | class IACSWindSpdType(CodeableEnum):
C = ('C')
L = ('L')
M = ('M')
S = ('S')
X = ('X')
| class IACSWindSpdType(CodeableEnum):
| C = ('C')
L = ('L')
M = ('M')
S = ('S')
X = ('X')
| ableEnum):
ONE = ('1')
class IACSUnitsWeightType(CodeableEnum):
KG = ('kg')
class IACSUnitsWindSpdType(CodeableEnum):
MS1 = ('ms-1')
EMPTY = ('')
class IACSWindSpdType(CodeableEnum):
| 63 | 64 | 42 | 12 | 51 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSWindSpdType | IACSWindSpdType | 256 | 261 | 256 | 256 | 71d64cbd550c246820e5225d73e683dc95a3854d | bigcode/the-stack | train |
961bd1ccd58c91a802865662 | train | class | class IACSUnitsPressureType(CodeableEnum):
NM2 = ('Nm-2')
PA = ('Pa')
| class IACSUnitsPressureType(CodeableEnum):
| NM2 = ('Nm-2')
PA = ('Pa')
| ('cm')
MM = ('mm')
M = ('m')
IN = ('in')
FT = ('ft')
class IACSUnitsLwcType(CodeableEnum):
PRCVOL = ('% per Vol')
EMPTY = ('')
class IACSUnitsPressureType(CodeableEnum):
| 63 | 64 | 25 | 10 | 53 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSUnitsPressureType | IACSUnitsPressureType | 230 | 232 | 230 | 230 | 9edc25c7fa6e3b5b8fb7b5570fdfdd64b54c86a3 | bigcode/the-stack | train |
e1a70f96499f6f0a500278e6 | train | class | class IACSLiquidWaterContentType(CodeableEnum):
D = ('D')
DM = ('D-M')
M = ('M')
MW = ('M-W')
W = ('W')
WV = ('W-V')
V = ('V')
VS = ('V-S')
S = ('S')
| class IACSLiquidWaterContentType(CodeableEnum):
| D = ('D')
DM = ('D-M')
M = ('M')
MW = ('M-W')
W = ('W')
WV = ('W-V')
V = ('V')
VS = ('V-S')
S = ('S')
| 75)
I = ('I', 1200, 6)
def __init__(self, code, hardness, yf_value):
self.code = code
self.hardness = hardness
self.yf_value = yf_value
class IACSLiquidWaterContentType(CodeableEnum):
| 64 | 64 | 70 | 12 | 51 | moarri/moarri_profile_iacs | moarri_profile_iacs/iacs_profile/iacs_caaml_types.py | Python | IACSLiquidWaterContentType | IACSLiquidWaterContentType | 132 | 141 | 132 | 132 | 6ede54282aa2d33027c4800b5f13d7d5e349f501 | bigcode/the-stack | train |
e18ead875e9aa3220d00fbfe | train | class | class UserProfilePicture(LoginRequiredMixin, UpdateView):
fields = ["profile_picture"]
template_name = "users/user_profile_picture_form.html"
def get_success_url(self):
return reverse("users:detail", kwargs={"username": self.request.user.username})
def get_object(self):
return User.obj... | class UserProfilePicture(LoginRequiredMixin, UpdateView):
| fields = ["profile_picture"]
template_name = "users/user_profile_picture_form.html"
def get_success_url(self):
return reverse("users:detail", kwargs={"username": self.request.user.username})
def get_object(self):
return User.objects.get(username=self.request.user.username)
def for... | .contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.views.generic import DetailView, RedirectView, UpdateView
User = get_user_model()
class UserProfilePicture(LoginRequiredMixin,... | 64 | 64 | 106 | 11 | 53 | theptrk/django-s3-example | learn_s3/users/views.py | Python | UserProfilePicture | UserProfilePicture | 11 | 25 | 11 | 11 | f73308784c1d7f6965f69187818efba818ff09a9 | bigcode/the-stack | train |
325a756af696fec11badcf6e | train | class | class UserDetailView(LoginRequiredMixin, DetailView):
model = User
slug_field = "username"
slug_url_kwarg = "username"
| class UserDetailView(LoginRequiredMixin, DetailView):
| model = User
slug_field = "username"
slug_url_kwarg = "username"
| .get(username=self.request.user.username)
def form_valid(self, form):
messages.add_message(
self.request, messages.INFO, _("Infos successfully updated")
)
return super().form_valid(form)
user_profile_picture_view = UserProfilePicture.as_view()
class UserDetailView(LoginRequire... | 64 | 64 | 32 | 11 | 53 | theptrk/django-s3-example | learn_s3/users/views.py | Python | UserDetailView | UserDetailView | 31 | 35 | 31 | 32 | 2ce429185de348119caefc84ecd769252977e222 | bigcode/the-stack | train |
63974efdf313376ffd68d49c | train | class | class UserRedirectView(LoginRequiredMixin, RedirectView):
permanent = False
def get_redirect_url(self):
return reverse("users:detail", kwargs={"username": self.request.user.username})
| class UserRedirectView(LoginRequiredMixin, RedirectView):
| permanent = False
def get_redirect_url(self):
return reverse("users:detail", kwargs={"username": self.request.user.username})
| .objects.get(username=self.request.user.username)
def form_valid(self, form):
messages.add_message(
self.request, messages.INFO, _("Infos successfully updated")
)
return super().form_valid(form)
user_update_view = UserUpdateView.as_view()
class UserRedirectView(LoginRequiredMi... | 64 | 64 | 40 | 11 | 53 | theptrk/django-s3-example | learn_s3/users/views.py | Python | UserRedirectView | UserRedirectView | 62 | 67 | 62 | 63 | 194a0e81f9282b5bac31a3c21076e1f448ccab84 | bigcode/the-stack | train |
47bd9153b44a2611e1d8a1b2 | train | class | class UserUpdateView(LoginRequiredMixin, UpdateView):
model = User
fields = ["name"]
def get_success_url(self):
return reverse("users:detail", kwargs={"username": self.request.user.username})
def get_object(self):
return User.objects.get(username=self.request.user.username)
def f... | class UserUpdateView(LoginRequiredMixin, UpdateView):
| model = User
fields = ["name"]
def get_success_url(self):
return reverse("users:detail", kwargs={"username": self.request.user.username})
def get_object(self):
return User.objects.get(username=self.request.user.username)
def form_valid(self, form):
messages.add_message(
... | user_profile_picture_view = UserProfilePicture.as_view()
class UserDetailView(LoginRequiredMixin, DetailView):
model = User
slug_field = "username"
slug_url_kwarg = "username"
user_detail_view = UserDetailView.as_view()
class UserUpdateView(LoginRequiredMixin, UpdateView):
| 64 | 64 | 98 | 11 | 53 | theptrk/django-s3-example | learn_s3/users/views.py | Python | UserUpdateView | UserUpdateView | 41 | 56 | 41 | 42 | 185dcb612bcf50a0fe58eeb3f7b5802b777465b8 | bigcode/the-stack | train |
b71ba549ed3504bd109f01b7 | train | class | class TestCredentials(unittest.TestCase):
def setUp(self):
'''
function to run before each test
'''
self.new_credential=Credential("Instagram","mimoh","1234Pa")
def test_init(self):
'''
test_init test case to test if the object is initialized properly
... | class TestCredentials(unittest.TestCase):
| def setUp(self):
'''
function to run before each test
'''
self.new_credential=Credential("Instagram","mimoh","1234Pa")
def test_init(self):
'''
test_init test case to test if the object is initialized properly
'''
self.assertEqual(self.n... | import pyperclip
import unittest
from credential import Credential
class TestCredentials(unittest.TestCase):
| 20 | 108 | 363 | 7 | 12 | ruthjelimo/Password_Locker | credential_test.py | Python | TestCredentials | TestCredentials | 4 | 56 | 4 | 4 | e5ed9b17813958c0e8bc8cb5df67e04e973f23e7 | bigcode/the-stack | train |
8adc6a710136830255dd53f0 | train | function | def __met(dataset: str, src_dataset: str, trg_dataset: str, n: int):
try:
ds = io.open(dataset, "r", encoding="utf-8")
src = io.open(src_dataset, "w", encoding="utf-8")
trg = io.open(trg_dataset, "w", encoding="utf-8")
decoder = json.decoder.JSONDecoder()
added = 0
li... | def __met(dataset: str, src_dataset: str, trg_dataset: str, n: int):
| try:
ds = io.open(dataset, "r", encoding="utf-8")
src = io.open(src_dataset, "w", encoding="utf-8")
trg = io.open(trg_dataset, "w", encoding="utf-8")
decoder = json.decoder.JSONDecoder()
added = 0
line = ds.readline()
srcLines = []
trgLines = []
... | import io
import sys
import re
import json
valid_english_sentence = re.compile("^[a-zA-Z,&.\s\"0-9'?!]+$")
def __met(dataset: str, src_dataset: str, trg_dataset: str, n: int):
| 57 | 67 | 224 | 21 | 37 | lidotcircle/ml | ldcml/nlp/utils/jsonline_dataset.py | Python | __met | __met | 8 | 34 | 8 | 8 | 2e1eff155e5099a49d77e84f867c88b504ebf93e | bigcode/the-stack | train |
5712b576a48046e814774317 | train | class | class GetResponse:
#Everything Start Here . Except Main
@staticmethod
def ReplyImage(line_bot_api: LineBotApi,token, profile):
response = AllResponse.GetRandomResponseFromKeys('image')
line_bot_api.reply_message(token,TextSendMessage(text=response, quick_reply=Help.GeneralHelp()))
... | class GetResponse:
#Everything Start Here . Except Main
@staticmethod
| def ReplyImage(line_bot_api: LineBotApi,token, profile):
response = AllResponse.GetRandomResponseFromKeys('image')
line_bot_api.reply_message(token,TextSendMessage(text=response, quick_reply=Help.GeneralHelp()))
@staticmethod
def ReplySticker(line_bot_api: LineBotApi,token, profile):
... | from linebot import (
LineBotApi
)
from linebot.models import (
TextSendMessage, StickerSendMessage
)
import random
from AllResponse import AllResponse
from CSVOpener import CSVOpener
from LineConst import LineConst
from ImageConst import ImageConst
from Help import Help
from Spec import Spec
from LookUp impor... | 102 | 179 | 597 | 18 | 83 | WarotAsawa/pengo | pengo/GetResponse.py | Python | GetResponse | GetResponse | 18 | 74 | 18 | 21 | a70d7a8cb5819900a3bafb9e76d76782c233ac5e | bigcode/the-stack | train |
cb350744f85312124fbf3fc2 | train | class | class TreeEnsembleRegressorDouble(TreeEnsembleRegressorCommon):
atts = OrderedDict([
('aggregate_function', b'SUM'),
('base_values', numpy.empty(0, dtype=numpy.float64)),
('n_targets', 1),
('nodes_falsenodeids', numpy.empty(0, dtype=numpy.int64)),
('nodes_featureids', numpy.... | class TreeEnsembleRegressorDouble(TreeEnsembleRegressorCommon):
| atts = OrderedDict([
('aggregate_function', b'SUM'),
('base_values', numpy.empty(0, dtype=numpy.float64)),
('n_targets', 1),
('nodes_falsenodeids', numpy.empty(0, dtype=numpy.int64)),
('nodes_featureids', numpy.empty(0, dtype=numpy.int64)),
('nodes_hitrates', numpy.em... | ', numpy.empty(0, dtype=numpy.int64)),
('target_weights', numpy.empty(0, dtype=numpy.float32)),
])
def __init__(self, onnx_node, desc=None, **options):
TreeEnsembleRegressorCommon.__init__(
self, numpy.float32, onnx_node, desc=desc,
expected_attributes=TreeEnsembleRegres... | 102 | 102 | 340 | 14 | 88 | Exlsunshine/mlprodict | mlprodict/onnxrt/ops_cpu/op_tree_ensemble_regressor.py | Python | TreeEnsembleRegressorDouble | TreeEnsembleRegressorDouble | 96 | 122 | 96 | 97 | f2cb30161c0420e04c45d05992d65526677b0f2e | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.