text stringlengths 0 828 |
|---|
if ts() < end: |
# yield the next item |
yield i |
# otherwise |
else: |
# stop |
break" |
4074,"def destruct(particles, index): |
""""""Fermion annihilation operator in matrix representation for a indexed |
particle in a bounded N-particles fermion fock space"""""" |
mat = np.zeros((2**particles, 2**particles)) |
flipper = 2**index |
for i in range(2**particles): |
ispin = btest(i, index) |
if ispin == 1: |
mat[i ^ flipper, i] = phase(i, index) |
return csr_matrix(mat)" |
4075,"def on(self): |
""""""! |
\~english |
Open Audio output. set pin mode to ALT0 |
@return a boolean value. if True means open audio output is OK otherwise failed to open. |
\~chinese |
打开音频输出。 将引脚模式设置为ALT0 |
@return 布尔值。 如果 True 表示打开音频输出成功,否则不成功。 |
"""""" |
isOK = True |
try: |
if self.channelR!=None: |
sub.call([""gpio"", ""-g"", ""mode"", ""{}"".format(self.channelR), self.PIN_MODE_AUDIO ]) |
except: |
isOK = False |
print(""Open audio right channel failed."") |
try: |
if self.channelL!=None: |
sub.call([""gpio"",""-g"",""mode"", ""{}"".format(self.channelL), self.PIN_MODE_AUDIO ]) |
except: |
isOK = False |
print(""Open audio left channel failed."") |
return isOK" |
4076,"def off(self): |
""""""! |
\~english |
Close Audio output. set pin mode to output |
@return a boolean value. if True means close audio output is OK otherwise failed to close. |
\~chinese |
关闭音频输出。 将引脚模式设置为输出 |
@return 布尔值。 如果为 True 关闭音频输出成功,否则关闭不成功。 |
"""""" |
isOK = True |
try: |
if self.channelR!=None: |
sub.call([""gpio"",""-g"",""mode"", ""{}"".format(self.channelR), self.PIN_MODE_OUTPUT ]) |
except: |
isOK = False |
print(""Close audio right channel failed."") |
try: |
if self.channelL!=None: |
sub.call([""gpio"",""-g"",""mode"", ""{}"".format(self.channelL), self.PIN_MODE_OUTPUT ]) |
except: |
isOK = False |
print(""Close audio left channel failed."") |
return isOK" |
4077,"def parse_database_url(url): |
""""""Parses a database URL."""""" |
if url == 'sqlite://:memory:': |
# this is a special case, because if we pass this URL into |
# urlparse, urlparse will choke trying to interpret ""memory"" |
# as a port number |
return { |
'ENGINE': DATABASE_SCHEMES['sqlite'], |
'NAME': ':memory:' |
} |
# note: no other settings are required for sqlite |
# otherwise parse the url as normal |
config = {} |
url = urlparse.urlparse(url) |
# Remove query strings. |
path = url.path[1:] |
path = path.split('?', 2)[0] |
# if we are using sqlite and we have no path, then assume we |
# want an in-memory database (this is the behaviour of sqlalchemy) |
if url.scheme == 'sqlite' and path == '': |
path = ':memory:' |
# Update with environment configuration. |
config.update({ |
'NAME': path or '', |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.