code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def print_cell(self, row=0):
"""UI to display agent moving on the grid"""
print("")
for i in range(13):
j = i - 2
if j in [0, 4, 8]:
if j == 8:
if self.state == 2 and row == 0:
marker = "\033[4mG\033[0m"
... | UI to display agent moving on the grid | print_cell | python | PacktPublishing/Advanced-Deep-Learning-with-Keras | chapter9-drl/q-learning-9.3.1.py | https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/blob/master/chapter9-drl/q-learning-9.3.1.py | MIT |
def print_world(self, action, step):
"""UI to display mode and action of agent"""
actions = { 0: "(Left)", 1: "(Down)", 2: "(Right)", 3: "(Up)" }
explore = "Explore" if self.is_explore else "Exploit"
print("Step", step, ":", explore, actions[action])
for _ in range(13):
... | UI to display mode and action of agent | print_world | python | PacktPublishing/Advanced-Deep-Learning-with-Keras | chapter9-drl/q-learning-9.3.1.py | https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/blob/master/chapter9-drl/q-learning-9.3.1.py | MIT |
def print_episode(episode, delay=1):
"""UI to display episode count
Arguments:
episode (int): episode number
delay (int): sec delay
"""
os.system('clear')
for _ in range(13):
print('=', end='')
print("")
print("Episode ", episode)
for _ in range(13):
prin... | UI to display episode count
Arguments:
episode (int): episode number
delay (int): sec delay
| print_episode | python | PacktPublishing/Advanced-Deep-Learning-with-Keras | chapter9-drl/q-learning-9.3.1.py | https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/blob/master/chapter9-drl/q-learning-9.3.1.py | MIT |
def print_status(q_world, done, step, delay=1):
"""UI to display the world,
delay of 1 sec for ease of understanding
"""
os.system('clear')
q_world.print_world(action, step)
q_world.print_q_table()
if done:
print("-------EPISODE DONE--------")
delay *= 2
time.sleep(d... | UI to display the world,
delay of 1 sec for ease of understanding
| print_status | python | PacktPublishing/Advanced-Deep-Learning-with-Keras | chapter9-drl/q-learning-9.3.1.py | https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/blob/master/chapter9-drl/q-learning-9.3.1.py | MIT |
def generator(inputs,
image_size,
activation='sigmoid',
labels=None,
codes=None):
"""Build a Generator Model
Stack of BN-ReLU-Conv2DTranpose to generate fake images.
Output activation is sigmoid instead of tanh in [1].
Sigmoid converges easily.
... | Build a Generator Model
Stack of BN-ReLU-Conv2DTranpose to generate fake images.
Output activation is sigmoid instead of tanh in [1].
Sigmoid converges easily.
Arguments:
inputs (Layer): Input layer of the generator (the z-vector)
image_size (int): Target size of one side
... | generator | python | PacktPublishing/Advanced-Deep-Learning-with-Keras | lib/gan.py | https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/blob/master/lib/gan.py | MIT |
def discriminator(inputs,
activation='sigmoid',
num_labels=None,
num_codes=None):
"""Build a Discriminator Model
Stack of LeakyReLU-Conv2D to discriminate real from fake
The network does not converge with BN so it is not used here
unlike in [1]
... | Build a Discriminator Model
Stack of LeakyReLU-Conv2D to discriminate real from fake
The network does not converge with BN so it is not used here
unlike in [1]
Arguments:
inputs (Layer): Input layer of the discriminator (the image)
activation (string): Name of output activation layer
... | discriminator | python | PacktPublishing/Advanced-Deep-Learning-with-Keras | lib/gan.py | https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/blob/master/lib/gan.py | MIT |
def train(models, x_train, params):
"""Train the Discriminator and Adversarial Networks
Alternately train Discriminator and Adversarial networks by batch.
Discriminator is trained first with properly real and fake images.
Adversarial is trained next with fake images pretending to be real
Generate s... | Train the Discriminator and Adversarial Networks
Alternately train Discriminator and Adversarial networks by batch.
Discriminator is trained first with properly real and fake images.
Adversarial is trained next with fake images pretending to be real
Generate sample images per save_interval.
# Argu... | train | python | PacktPublishing/Advanced-Deep-Learning-with-Keras | lib/gan.py | https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/blob/master/lib/gan.py | MIT |
def plot_images(generator,
noise_input,
noise_label=None,
noise_codes=None,
show=False,
step=0,
model_name="gan"):
"""Generate fake images and plot them
For visualization purposes, generate fake images
then plot... | Generate fake images and plot them
For visualization purposes, generate fake images
then plot them in a square grid
# Arguments
generator (Model): The Generator Model for
fake images generation
noise_input (ndarray): Array of z-vectors
show (bool): Whether to show plot... | plot_images | python | PacktPublishing/Advanced-Deep-Learning-with-Keras | lib/gan.py | https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/blob/master/lib/gan.py | MIT |
def chunked(iterator, chunksize):
"""
Yields items from 'iterator' in chunks of size 'chunksize'.
>>> list(chunked([1, 2, 3, 4, 5], chunksize=2))
[(1, 2), (3, 4), (5,)]
"""
chunk = []
for idx, item in enumerate(iterator, 1):
chunk.append(item)
if idx % chunksize == 0:
... |
Yields items from 'iterator' in chunks of size 'chunksize'.
>>> list(chunked([1, 2, 3, 4, 5], chunksize=2))
[(1, 2), (3, 4), (5,)]
| chunked | python | pmclanahan/django-celery-email | djcelery_email/utils.py | https://github.com/pmclanahan/django-celery-email/blob/master/djcelery_email/utils.py | BSD-3-Clause |
def celery_queue_pop():
""" Pops a single task from Celery's 'memory://' queue. """
with celery.current_app.connection() as conn:
queue = conn.SimpleQueue('django_email', no_ack=True)
return queue.get().payload | Pops a single task from Celery's 'memory://' queue. | celery_queue_pop | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_send_single_email_object(self):
""" It should accept and send a single EmailMessage object. """
msg = mail.EmailMessage()
tasks.send_email(msg, backend_kwargs={})
self.assertEqual(len(mail.outbox), 1)
# we can't compare them directly as it's converted into a dict
... | It should accept and send a single EmailMessage object. | test_send_single_email_object | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_send_single_email_object_no_backend_kwargs(self):
""" It should send email with backend_kwargs not provided. """
msg = mail.EmailMessage()
tasks.send_email(msg)
self.assertEqual(len(mail.outbox), 1)
# we can't compare them directly as it's converted into a dict
#... | It should send email with backend_kwargs not provided. | test_send_single_email_object_no_backend_kwargs | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_send_single_email_object_response(self):
""" It should return the number of messages sent, 1 here. """
msg = mail.EmailMessage()
messages_sent = tasks.send_email(msg)
self.assertEqual(messages_sent, 1)
self.assertEqual(len(mail.outbox), 1) | It should return the number of messages sent, 1 here. | test_send_single_email_object_response | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_send_single_email_dict(self):
""" It should accept and send a single EmailMessage dict. """
msg = mail.EmailMessage()
tasks.send_email(email_to_dict(msg), backend_kwargs={})
self.assertEqual(len(mail.outbox), 1)
# we can't compare them directly as it's converted into a d... | It should accept and send a single EmailMessage dict. | test_send_single_email_dict | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_send_multiple_email_objects(self):
""" It should accept and send a list of EmailMessage objects. """
N = 10
msgs = [mail.EmailMessage() for i in range(N)]
tasks.send_emails([email_to_dict(msg) for msg in msgs],
backend_kwargs={})
self.assertEqu... | It should accept and send a list of EmailMessage objects. | test_send_multiple_email_objects | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_send_multiple_email_dicts(self):
""" It should accept and send a list of EmailMessage dicts. """
N = 10
msgs = [mail.EmailMessage() for i in range(N)]
tasks.send_emails(msgs, backend_kwargs={})
self.assertEqual(len(mail.outbox), N)
for i in range(N):
... | It should accept and send a list of EmailMessage dicts. | test_send_multiple_email_dicts | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_send_multiple_email_dicts_response(self):
""" It should return the number of messages sent. """
N = 10
msgs = [mail.EmailMessage() for i in range(N)]
messages_sent = tasks.send_emails(msgs, backend_kwargs={})
self.assertEqual(messages_sent, N)
self.assertEqual(le... | It should return the number of messages sent. | test_send_multiple_email_dicts_response | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_uses_correct_backend(self):
""" It should use the backend configured in CELERY_EMAIL_BACKEND. """
TracingBackend.called = False
msg = mail.EmailMessage()
tasks.send_email(email_to_dict(msg), backend_kwargs={})
self.assertTrue(TracingBackend.called) | It should use the backend configured in CELERY_EMAIL_BACKEND. | test_uses_correct_backend | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_backend_parameters(self):
""" It should pass kwargs like username and password to the backend. """
TracingBackend.kwargs = None
msg = mail.EmailMessage()
tasks.send_email(email_to_dict(msg), backend_kwargs={'foo': 'bar'})
self.assertEqual(TracingBackend.kwargs.get('foo')... | It should pass kwargs like username and password to the backend. | test_backend_parameters | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_backend_parameters_kwargs(self):
""" It should pass on kwargs specified as keyword params. """
TracingBackend.kwargs = None
msg = mail.EmailMessage()
tasks.send_email(email_to_dict(msg), foo='bar')
self.assertEqual(TracingBackend.kwargs.get('foo'), 'bar') | It should pass on kwargs specified as keyword params. | test_backend_parameters_kwargs | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_backend_parameters(self):
""" Our backend should pass kwargs to the 'send_emails' task. """
kwargs = {'auth_user': 'user', 'auth_password': 'pass'}
mail.send_mass_mail([
('test1', 'Testing with Celery! w00t!!', 'from@example.com', ['to@example.com']),
('test2', '... | Our backend should pass kwargs to the 'send_emails' task. | test_backend_parameters | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def test_chunking(self):
"""
Given 11 messages and a chunk size of 4, the backend should queue
11/4 = 3 jobs (2 jobs with 4 messages and 1 job with 3 messages).
"""
N = 11
chunksize = 4
with override_settings(CELERY_EMAIL_CHUNK_SIZE=4):
mail.send_mass... |
Given 11 messages and a chunk size of 4, the backend should queue
11/4 = 3 jobs (2 jobs with 4 messages and 1 job with 3 messages).
| test_chunking | python | pmclanahan/django-celery-email | tests/tests.py | https://github.com/pmclanahan/django-celery-email/blob/master/tests/tests.py | BSD-3-Clause |
def get_root():
"""Get the project root directory.
We require that all commands are run from the project root, i.e. the
directory that contains setup.py, setup.cfg, and versioneer.py .
"""
root = os.path.realpath(os.path.abspath(os.getcwd()))
setup_py = os.path.join(root, "setup.py")
versio... | Get the project root directory.
We require that all commands are run from the project root, i.e. the
directory that contains setup.py, setup.cfg, and versioneer.py .
| get_root | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def get_config_from_root(root):
"""Read the project setup.cfg file to determine Versioneer config."""
# This might raise OSError (if setup.cfg is missing), or
# configparser.NoSectionError (if it lacks a [versioneer] section), or
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
... | Read the project setup.cfg file to determine Versioneer config. | get_config_from_root | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def register_vcs_handler(vcs, method): # decorator
"""Create decorator to mark a method as the handler of a VCS."""
def decorate(f):
"""Store f in HANDLERS[vcs][method]."""
HANDLERS.setdefault(vcs, {})[method] = f
return f
return decorate | Create decorator to mark a method as the handler of a VCS. | register_vcs_handler | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def git_get_keywords(versionfile_abs):
"""Extract version information from the given file."""
# the code embedded in _version.py can just fetch the value of these
# keywords. When used from setup.py, we don't want to import _version.py,
# so we do it with a regexp instead. This function is not used from... | Extract version information from the given file. | git_get_keywords | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def git_versions_from_keywords(keywords, tag_prefix, verbose):
"""Get version information from git keywords."""
if "refnames" not in keywords:
raise NotThisMethod("Short version file found")
date = keywords.get("date")
if date is not None:
# Use only the last line. Previous lines may co... | Get version information from git keywords. | git_versions_from_keywords | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
"""Get version from 'git describe' in the root of the source tree.
This only gets called if the git-archive 'subst' keywords were *not*
expanded, and _version.py hasn't already been rewritten with a short
version string, meaning we... | Get version from 'git describe' in the root of the source tree.
This only gets called if the git-archive 'subst' keywords were *not*
expanded, and _version.py hasn't already been rewritten with a short
version string, meaning we're inside a checked out source tree.
| git_pieces_from_vcs | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def do_vcs_install(versionfile_source, ipy):
"""Git-specific installation logic for Versioneer.
For Git, this means creating/changing .gitattributes to mark _version.py
for export-subst keyword substitution.
"""
GITS = ["git"]
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]
... | Git-specific installation logic for Versioneer.
For Git, this means creating/changing .gitattributes to mark _version.py
for export-subst keyword substitution.
| do_vcs_install | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def versions_from_parentdir(parentdir_prefix, root, verbose):
"""Try to determine the version from the parent directory name.
Source tarballs conventionally unpack into a directory that includes both
the project name and a version string. We will also support searching up
two directory levels for an ap... | Try to determine the version from the parent directory name.
Source tarballs conventionally unpack into a directory that includes both
the project name and a version string. We will also support searching up
two directory levels for an appropriately named parent directory
| versions_from_parentdir | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def versions_from_file(filename):
"""Try to determine the version from _version.py if present."""
try:
with open(filename) as f:
contents = f.read()
except OSError:
raise NotThisMethod("unable to read _version.py")
mo = re.search(r"version_json = '''\n(.*)''' # END VERSION_J... | Try to determine the version from _version.py if present. | versions_from_file | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def write_to_version_file(filename, versions):
"""Write the given version number to the given _version.py file."""
os.unlink(filename)
contents = json.dumps(versions, sort_keys=True,
indent=1, separators=(",", ": "))
with open(filename, "w") as f:
f.write(SHORT_VERSION_... | Write the given version number to the given _version.py file. | write_to_version_file | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def plus_or_dot(pieces):
"""Return a + if we don't already have one, else return a ."""
if "+" in pieces.get("closest-tag", ""):
return "."
return "+" | Return a + if we don't already have one, else return a . | plus_or_dot | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def render_pep440(pieces):
"""Build up version string, with post-release "local version identifier".
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
Exceptions:
1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHE... | Build up version string, with post-release "local version identifier".
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
Exceptions:
1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]
| render_pep440 | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def render_pep440_branch(pieces):
"""TAG[[.dev0]+DISTANCE.gHEX[.dirty]] .
The ".dev0" means not master branch. Note that .dev0 sorts backwards
(a feature branch will appear "older" than the master branch).
Exceptions:
1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty]
"""
if pieces["close... | TAG[[.dev0]+DISTANCE.gHEX[.dirty]] .
The ".dev0" means not master branch. Note that .dev0 sorts backwards
(a feature branch will appear "older" than the master branch).
Exceptions:
1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty]
| render_pep440_branch | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def pep440_split_post(ver):
"""Split pep440 version string at the post-release segment.
Returns the release segments before the post-release and the
post-release version number (or -1 if no post-release segment is present).
"""
vc = str.split(ver, ".post")
return vc[0], int(vc[1] or 0) if len(v... | Split pep440 version string at the post-release segment.
Returns the release segments before the post-release and the
post-release version number (or -1 if no post-release segment is present).
| pep440_split_post | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def render_pep440_pre(pieces):
"""TAG[.postN.devDISTANCE] -- No -dirty.
Exceptions:
1: no tags. 0.post0.devDISTANCE
"""
if pieces["closest-tag"]:
if pieces["distance"]:
# update the post release segment
tag_version, post_version = pep440_split_post(pieces["closest-ta... | TAG[.postN.devDISTANCE] -- No -dirty.
Exceptions:
1: no tags. 0.post0.devDISTANCE
| render_pep440_pre | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def render_pep440_post(pieces):
"""TAG[.postDISTANCE[.dev0]+gHEX] .
The ".dev0" means dirty. Note that .dev0 sorts backwards
(a dirty tree will appear "older" than the corresponding clean one),
but you shouldn't be releasing software with -dirty anyways.
Exceptions:
1: no tags. 0.postDISTANCE[... | TAG[.postDISTANCE[.dev0]+gHEX] .
The ".dev0" means dirty. Note that .dev0 sorts backwards
(a dirty tree will appear "older" than the corresponding clean one),
but you shouldn't be releasing software with -dirty anyways.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]
| render_pep440_post | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def render_pep440_post_branch(pieces):
"""TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] .
The ".dev0" means not master branch.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"] or pieces["dir... | TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] .
The ".dev0" means not master branch.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty]
| render_pep440_post_branch | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def render_pep440_old(pieces):
"""TAG[.postDISTANCE[.dev0]] .
The ".dev0" means dirty.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"] or pieces["dirty"]:
rendered += ".post%d" % piec... | TAG[.postDISTANCE[.dev0]] .
The ".dev0" means dirty.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]
| render_pep440_old | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def render_git_describe(pieces):
"""TAG[-DISTANCE-gHEX][-dirty].
Like 'git describe --tags --dirty --always'.
Exceptions:
1: no tags. HEX[-dirty] (note: no 'g' prefix)
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"]:
rendered +=... | TAG[-DISTANCE-gHEX][-dirty].
Like 'git describe --tags --dirty --always'.
Exceptions:
1: no tags. HEX[-dirty] (note: no 'g' prefix)
| render_git_describe | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def render_git_describe_long(pieces):
"""TAG-DISTANCE-gHEX[-dirty].
Like 'git describe --tags --dirty --always -long'.
The distance/hash is unconditional.
Exceptions:
1: no tags. HEX[-dirty] (note: no 'g' prefix)
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
... | TAG-DISTANCE-gHEX[-dirty].
Like 'git describe --tags --dirty --always -long'.
The distance/hash is unconditional.
Exceptions:
1: no tags. HEX[-dirty] (note: no 'g' prefix)
| render_git_describe_long | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def render(pieces, style):
"""Render the given version pieces into the requested style."""
if pieces["error"]:
return {"version": "unknown",
"full-revisionid": pieces.get("long"),
"dirty": None,
"error": pieces["error"],
"date": None}
... | Render the given version pieces into the requested style. | render | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def get_versions(verbose=False):
"""Get the project version from whatever source is available.
Returns dict with two keys: 'version' and 'full'.
"""
if "versioneer" in sys.modules:
# see the discussion in cmdclass.py:get_cmdclass()
del sys.modules["versioneer"]
root = get_root()
... | Get the project version from whatever source is available.
Returns dict with two keys: 'version' and 'full'.
| get_versions | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def get_cmdclass(cmdclass=None):
"""Get the custom setuptools subclasses used by Versioneer.
If the package uses a different cmdclass (e.g. one from numpy), it
should be provide as an argument.
"""
if "versioneer" in sys.modules:
del sys.modules["versioneer"]
# this fixes the "pytho... | Get the custom setuptools subclasses used by Versioneer.
If the package uses a different cmdclass (e.g. one from numpy), it
should be provide as an argument.
| get_cmdclass | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def do_setup():
"""Do main VCS-independent setup function for installing Versioneer."""
root = get_root()
try:
cfg = get_config_from_root(root)
except (OSError, configparser.NoSectionError,
configparser.NoOptionError) as e:
if isinstance(e, (OSError, configparser.NoSectionErr... | Do main VCS-independent setup function for installing Versioneer. | do_setup | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def scan_setup_py():
"""Validate the contents of setup.py against Versioneer's expectations."""
found = set()
setters = False
errors = 0
with open("setup.py", "r") as f:
for line in f.readlines():
if "import versioneer" in line:
found.add("import")
if ... | Validate the contents of setup.py against Versioneer's expectations. | scan_setup_py | python | mars-project/mars | versioneer.py | https://github.com/mars-project/mars/blob/master/versioneer.py | Apache-2.0 |
def q07(lineitem, supplier, orders, customer, nation):
"""This version is faster than q07_old. Keeping the old one for reference"""
lineitem_filtered = lineitem[
(lineitem["L_SHIPDATE"] >= md.Timestamp("1995-01-01"))
& (lineitem["L_SHIPDATE"] < md.Timestamp("1997-01-01"))
]
lineitem_filt... | This version is faster than q07_old. Keeping the old one for reference | q07 | python | mars-project/mars | benchmarks/tpch/run_queries.py | https://github.com/mars-project/mars/blob/master/benchmarks/tpch/run_queries.py | Apache-2.0 |
def _normalize(string, prefix="", width=76):
r"""Convert a string into a format that is appropriate for .po files.
>>> print(normalize('''Say:
... "hello, world!"
... ''', width=None))
""
"Say:\n"
" \"hello, world!\"\n"
>>> print(normalize('''Say:
... "Lorem ipsum dolor sit amet... | Convert a string into a format that is appropriate for .po files.
>>> print(normalize('''Say:
... "hello, world!"
... ''', width=None))
""
"Say:\n"
" \"hello, world!\"\n"
>>> print(normalize('''Say:
... "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "
... ''', width=... | _normalize | python | mars-project/mars | docs/source/norm_zh.py | https://github.com/mars-project/mars/blob/master/docs/source/norm_zh.py | Apache-2.0 |
async def init(
cls, address: str, session_id: str, new: bool = True, **kwargs
) -> "AbstractSession":
"""
Init a new session.
Parameters
----------
address : str
Address.
session_id : str
Session ID.
new : bool
New... |
Init a new session.
Parameters
----------
address : str
Address.
session_id : str
Session ID.
new : bool
New a session.
kwargs
Returns
-------
session
| init | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def execute(self, *tileables, **kwargs) -> ExecutionInfo:
"""
Execute tileables.
Parameters
----------
tileables
Tileables.
kwargs
""" |
Execute tileables.
Parameters
----------
tileables
Tileables.
kwargs
| execute | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def fetch(self, *tileables, **kwargs) -> list:
"""
Fetch tileables' data.
Parameters
----------
tileables
Tileables.
Returns
-------
data
""" |
Fetch tileables' data.
Parameters
----------
tileables
Tileables.
Returns
-------
data
| fetch | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def fetch_tileable_op_logs(
self,
tileable_op_key: str,
offsets: Union[Dict[str, List[int]], str, int],
sizes: Union[Dict[str, List[int]], str, int],
) -> Dict:
"""
Fetch logs given tileable op key.
Parameters
----------
tileable_op_key ... |
Fetch logs given tileable op key.
Parameters
----------
tileable_op_key : str
Tileable op key.
offsets
Chunk op key to offsets.
sizes
Chunk op key to sizes.
Returns
-------
chunk_key_to_logs
| fetch_tileable_op_logs | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def get_total_n_cpu(self):
"""
Get number of cluster cpus.
Returns
-------
number_of_cpu: int
""" |
Get number of cluster cpus.
Returns
-------
number_of_cpu: int
| get_total_n_cpu | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def get_cluster_versions(self) -> List[str]:
"""
Get versions used in current Mars cluster
Returns
-------
version_list : list
List of versions
""" |
Get versions used in current Mars cluster
Returns
-------
version_list : list
List of versions
| get_cluster_versions | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def get_web_endpoint(self) -> Optional[str]:
"""
Get web endpoint of current session
Returns
-------
web_endpoint : str
web endpoint
""" |
Get web endpoint of current session
Returns
-------
web_endpoint : str
web endpoint
| get_web_endpoint | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def create_remote_object(
self, session_id: str, name: str, object_cls, *args, **kwargs
):
"""
Create remote object
Parameters
----------
session_id : str
Session ID.
name : str
object_cls
args
kwargs
Returns... |
Create remote object
Parameters
----------
session_id : str
Session ID.
name : str
object_cls
args
kwargs
Returns
-------
actor_ref
| create_remote_object | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def get_remote_object(self, session_id: str, name: str):
"""
Get remote object.
Parameters
----------
session_id : str
Session ID.
name : str
Returns
-------
actor_ref
""" |
Get remote object.
Parameters
----------
session_id : str
Session ID.
name : str
Returns
-------
actor_ref
| get_remote_object | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def destroy_remote_object(self, session_id: str, name: str):
"""
Destroy remote object.
Parameters
----------
session_id : str
Session ID.
name : str
""" |
Destroy remote object.
Parameters
----------
session_id : str
Session ID.
name : str
| destroy_remote_object | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def create_mutable_tensor(
self,
shape: tuple,
dtype: Union[np.dtype, str],
name: str = None,
default_value: Union[int, float] = 0,
chunk_size: Union[int, Tuple] = None,
):
"""
Create a mutable tensor.
Parameters
----------
... |
Create a mutable tensor.
Parameters
----------
shape: tuple
Shape of the mutable tensor.
dtype: np.dtype or str
Data type of the mutable tensor.
name: str, optional
Name of the mutable tensor, a random name will be used if not speci... | create_mutable_tensor | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
async def get_mutable_tensor(self, name: str):
"""
Get a mutable tensor by name.
Parameters
----------
name: str
Name of the mutable tensor to get.
Returns
-------
MutableTensor
""" |
Get a mutable tensor by name.
Parameters
----------
name: str
Name of the mutable tensor to get.
Returns
-------
MutableTensor
| get_mutable_tensor | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def init(
cls,
address: str,
session_id: str,
backend: str = "mars",
new: bool = True,
**kwargs,
) -> "AbstractSession":
"""
Init a new session.
Parameters
----------
address : str
Address.
session_id : str
... |
Init a new session.
Parameters
----------
address : str
Address.
session_id : str
Session ID.
backend : str
Backend.
new : bool
New a session.
kwargs
Returns
-------
session
... | init | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def execute(
self, tileable, *tileables, show_progress: Union[bool, str] = None, **kwargs
) -> Union[List[TileableType], TileableType, ExecutionInfo]:
"""
Execute tileables.
Parameters
----------
tileable
Tileable.
tileables
Tileables.... |
Execute tileables.
Parameters
----------
tileable
Tileable.
tileables
Tileables.
show_progress
If show progress.
kwargs
Returns
-------
result
| execute | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def fetch(self, *tileables, **kwargs) -> list:
"""
Fetch tileables.
Parameters
----------
tileables
Tileables.
kwargs
Returns
-------
fetched_data : list
""" |
Fetch tileables.
Parameters
----------
tileables
Tileables.
kwargs
Returns
-------
fetched_data : list
| fetch | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def fetch_infos(self, *tileables, fields, **kwargs) -> list:
"""
Fetch infos of tileables.
Parameters
----------
tileables
Tileables.
fields
List of fields
kwargs
Returns
-------
fetched_infos : list
""" |
Fetch infos of tileables.
Parameters
----------
tileables
Tileables.
fields
List of fields
kwargs
Returns
-------
fetched_infos : list
| fetch_infos | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def decref(self, *tileables_keys):
"""
Decref tileables.
Parameters
----------
tileables_keys : list
Tileables' keys
""" |
Decref tileables.
Parameters
----------
tileables_keys : list
Tileables' keys
| decref | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def fetch_tileable_op_logs(
self,
tileable_op_key: str,
offsets: Union[Dict[str, List[int]], str, int],
sizes: Union[Dict[str, List[int]], str, int],
) -> Dict:
"""
Fetch logs given tileable op key.
Parameters
----------
tileable_op_key : str
... |
Fetch logs given tileable op key.
Parameters
----------
tileable_op_key : str
Tileable op key.
offsets
Chunk op key to offsets.
sizes
Chunk op key to sizes.
Returns
-------
chunk_key_to_logs
| fetch_tileable_op_logs | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def get_total_n_cpu(self):
"""
Get number of cluster cpus.
Returns
-------
number_of_cpu: int
""" |
Get number of cluster cpus.
Returns
-------
number_of_cpu: int
| get_total_n_cpu | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def get_cluster_versions(self) -> List[str]:
"""
Get versions used in current Mars cluster
Returns
-------
version_list : list
List of versions
""" |
Get versions used in current Mars cluster
Returns
-------
version_list : list
List of versions
| get_cluster_versions | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def get_web_endpoint(self) -> Optional[str]:
"""
Get web endpoint of current session
Returns
-------
web_endpoint : str
web endpoint
""" |
Get web endpoint of current session
Returns
-------
web_endpoint : str
web endpoint
| get_web_endpoint | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def create_mutable_tensor(
self,
shape: tuple,
dtype: Union[np.dtype, str],
name: str = None,
default_value: Union[int, float] = 0,
chunk_size: Union[int, Tuple] = None,
):
"""
Create a mutable tensor.
Parameters
----------
sha... |
Create a mutable tensor.
Parameters
----------
shape: tuple
Shape of the mutable tensor.
dtype: np.dtype or str
Data type of the mutable tensor.
name: str, optional
Name of the mutable tensor, a random name will be used if not speci... | create_mutable_tensor | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def get_mutable_tensor(self, name: str):
"""
Get a mutable tensor by name.
Parameters
----------
name: str
Name of the mutable tensor to get.
Returns
-------
MutableTensor
""" |
Get a mutable tensor by name.
Parameters
----------
name: str
Name of the mutable tensor to get.
Returns
-------
MutableTensor
| get_mutable_tensor | python | mars-project/mars | mars/session.py | https://github.com/mars-project/mars/blob/master/mars/session.py | Apache-2.0 |
def merge_chunks(chunk_results: List[Tuple[Tuple[int], Any]]) -> Any:
"""
Concatenate chunk results according to index.
Parameters
----------
chunk_results : list of tuple, {(chunk_idx, chunk_result), ...,}
Returns
-------
Data
"""
from sklearn.base import BaseEstimator
fr... |
Concatenate chunk results according to index.
Parameters
----------
chunk_results : list of tuple, {(chunk_idx, chunk_result), ...,}
Returns
-------
Data
| merge_chunks | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def calc_nsplits(chunk_idx_to_shape: Dict[Tuple[int], Tuple[int]]) -> Tuple[Tuple[int]]:
"""
Calculate a tiled entity's nsplits.
Parameters
----------
chunk_idx_to_shape : Dict type, {chunk_idx: chunk_shape}
Returns
-------
nsplits
"""
ndim = len(next(iter(chunk_idx_to_shape)))... |
Calculate a tiled entity's nsplits.
Parameters
----------
chunk_idx_to_shape : Dict type, {chunk_idx: chunk_shape}
Returns
-------
nsplits
| calc_nsplits | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def flatten(nested_iterable: Union[List, Tuple]) -> List:
"""
Flatten a nested iterable into a list.
Parameters
----------
nested_iterable : list or tuple
an iterable which can contain other iterables
Returns
-------
flattened : list
Examples
--------
>>> flatten([... |
Flatten a nested iterable into a list.
Parameters
----------
nested_iterable : list or tuple
an iterable which can contain other iterables
Returns
-------
flattened : list
Examples
--------
>>> flatten([[0, 1], [2, 3]])
[0, 1, 2, 3]
>>> flatten([[0, 1], [[3], ... | flatten | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def stack_back(flattened: List, raw: Union[List, Tuple]) -> Union[List, Tuple]:
"""
Organize a new iterable from a flattened list according to raw iterable.
Parameters
----------
flattened : list
flattened list
raw: list
raw iterable
Returns
-------
ret : list
... |
Organize a new iterable from a flattened list according to raw iterable.
Parameters
----------
flattened : list
flattened list
raw: list
raw iterable
Returns
-------
ret : list
Examples
--------
>>> raw = [[0, 1], [2, [3, 4]]]
>>> flattened = flatten(r... | stack_back | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def adapt_mars_docstring(doc: str) -> str:
"""
Adapt numpy-style docstrings to Mars docstring.
This util function will add Mars imports, replace object references
and add execute calls. Note that check is needed after replacement.
"""
if doc is None:
return None
lines = []
firs... |
Adapt numpy-style docstrings to Mars docstring.
This util function will add Mars imports, replace object references
and add execute calls. Note that check is needed after replacement.
| adapt_mars_docstring | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def quiet_stdio():
"""Quiets standard outputs when inferring types of functions"""
with _io_quiet_lock:
_io_quiet_local.is_wrapped = True
sys.stdout = _QuietIOWrapper(sys.stdout)
sys.stderr = _QuietIOWrapper(sys.stderr)
try:
yield
finally:
with _io_quiet_lock:
... | Quiets standard outputs when inferring types of functions | quiet_stdio | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def stringify_path(path: Union[str, os.PathLike]) -> str:
"""
Convert *path* to a string or unicode path if possible.
"""
if isinstance(path, str):
return path
# checking whether path implements the filesystem protocol
try:
return path.__fspath__()
except AttributeError:
... |
Convert *path* to a string or unicode path if possible.
| stringify_path | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def register_asyncio_task_timeout_detector(
check_interval: int = None,
task_timeout_seconds: int = None,
task_exclude_filters: List[str] = None,
) -> Optional[asyncio.Task]: # pragma: no cover
"""Register a asyncio task which print timeout task periodically."""
check_interval = check_interval or i... | Register a asyncio task which print timeout task periodically. | register_asyncio_task_timeout_detector | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def merge_dict(dest: Dict, src: Dict, path=None, overwrite=True):
"""
Merges src dict into dest dict.
Parameters
----------
dest: Dict
dest dict
src: Dict
source dict
path: List
merge path
overwrite: bool
Whether overwrite dest dict when where is a confli... |
Merges src dict into dest dict.
Parameters
----------
dest: Dict
dest dict
src: Dict
source dict
path: List
merge path
overwrite: bool
Whether overwrite dest dict when where is a conflict
Returns
-------
Dict
Updated dest dict
| merge_dict | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def flatten_dict_to_nested_dict(flatten_dict: Dict, sep=".") -> Dict:
"""
Return nested dict from flatten dict.
Parameters
----------
flatten_dict: Dict
sep: str
flatten key separator
Returns
-------
Dict
Nested dict
"""
assert all(isinstance(k, str) for k i... |
Return nested dict from flatten dict.
Parameters
----------
flatten_dict: Dict
sep: str
flatten key separator
Returns
-------
Dict
Nested dict
| flatten_dict_to_nested_dict | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def is_full_slice(slc: Any) -> bool:
"""Check if the input is a full slice ((:) or (0:))"""
return (
isinstance(slc, slice)
and (slc.start == 0 or slc.start is None)
and slc.stop is None
and slc.step is None
) | Check if the input is a full slice ((:) or (0:)) | is_full_slice | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def wrap_exception(
exc: Exception,
bases: Tuple[Type] = None,
wrap_name: str = None,
message: str = None,
traceback: Optional[TracebackType] = None,
attr_dict: dict = None,
):
"""Generate an exception wraps the cause exception."""
def __init__(self):
pass
def __getattr__(s... | Generate an exception wraps the cause exception. | wrap_exception | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def get_node_ip_address(address="8.8.8.8:53"):
"""Determine the IP address of the local node.
Args:
address (str): The IP address and port of any known live service on the
network you care about.
Returns:
The IP address of the current node.
"""
ip_address, port = addres... | Determine the IP address of the local node.
Args:
address (str): The IP address and port of any known live service on the
network you care about.
Returns:
The IP address of the current node.
| get_node_ip_address | python | mars-project/mars | mars/utils.py | https://github.com/mars-project/mars/blob/master/mars/utils.py | Apache-2.0 |
def get_keywords():
"""Get the keywords needed to look up the version information."""
# these strings will be replaced by git during git-archive.
# setup.py/versioneer.py will grep for the variable names, so they must
# each be defined on a line of their own. _version.py will just call
# get_keyword... | Get the keywords needed to look up the version information. | get_keywords | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def get_config():
"""Create, populate and return the VersioneerConfig() object."""
# these strings are filled in when 'setup.py versioneer' creates
# _version.py
cfg = VersioneerConfig()
cfg.VCS = "git"
cfg.style = "pep440"
cfg.tag_prefix = "v"
cfg.parentdir_prefix = "pymars-"
cfg.ve... | Create, populate and return the VersioneerConfig() object. | get_config | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def register_vcs_handler(vcs, method): # decorator
"""Create decorator to mark a method as the handler of a VCS."""
def decorate(f):
"""Store f in HANDLERS[vcs][method]."""
if vcs not in HANDLERS:
HANDLERS[vcs] = {}
HANDLERS[vcs][method] = f
return f
return decor... | Create decorator to mark a method as the handler of a VCS. | register_vcs_handler | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def versions_from_parentdir(parentdir_prefix, root, verbose):
"""Try to determine the version from the parent directory name.
Source tarballs conventionally unpack into a directory that includes both
the project name and a version string. We will also support searching up
two directory levels for an ap... | Try to determine the version from the parent directory name.
Source tarballs conventionally unpack into a directory that includes both
the project name and a version string. We will also support searching up
two directory levels for an appropriately named parent directory
| versions_from_parentdir | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def git_get_keywords(versionfile_abs):
"""Extract version information from the given file."""
# the code embedded in _version.py can just fetch the value of these
# keywords. When used from setup.py, we don't want to import _version.py,
# so we do it with a regexp instead. This function is not used from... | Extract version information from the given file. | git_get_keywords | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def git_versions_from_keywords(keywords, tag_prefix, verbose):
"""Get version information from git keywords."""
if "refnames" not in keywords:
raise NotThisMethod("Short version file found")
date = keywords.get("date")
if date is not None:
# Use only the last line. Previous lines may co... | Get version information from git keywords. | git_versions_from_keywords | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
"""Get version from 'git describe' in the root of the source tree.
This only gets called if the git-archive 'subst' keywords were *not*
expanded, and _version.py hasn't already been rewritten with a short
version string, meaning we... | Get version from 'git describe' in the root of the source tree.
This only gets called if the git-archive 'subst' keywords were *not*
expanded, and _version.py hasn't already been rewritten with a short
version string, meaning we're inside a checked out source tree.
| git_pieces_from_vcs | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def plus_or_dot(pieces):
"""Return a + if we don't already have one, else return a ."""
if "+" in pieces.get("closest-tag", ""):
return "."
return "+" | Return a + if we don't already have one, else return a . | plus_or_dot | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def render_pep440(pieces):
"""Build up version string, with post-release "local version identifier".
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
Exceptions:
1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHE... | Build up version string, with post-release "local version identifier".
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
Exceptions:
1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]
| render_pep440 | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def render_pep440_branch(pieces):
"""TAG[[.dev0]+DISTANCE.gHEX[.dirty]] .
The ".dev0" means not master branch. Note that .dev0 sorts backwards
(a feature branch will appear "older" than the master branch).
Exceptions:
1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty]
"""
if pieces["close... | TAG[[.dev0]+DISTANCE.gHEX[.dirty]] .
The ".dev0" means not master branch. Note that .dev0 sorts backwards
(a feature branch will appear "older" than the master branch).
Exceptions:
1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty]
| render_pep440_branch | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def pep440_split_post(ver):
"""Split pep440 version string at the post-release segment.
Returns the release segments before the post-release and the
post-release version number (or -1 if no post-release segment is present).
"""
vc = str.split(ver, ".post")
return vc[0], int(vc[1] or 0) if len(v... | Split pep440 version string at the post-release segment.
Returns the release segments before the post-release and the
post-release version number (or -1 if no post-release segment is present).
| pep440_split_post | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def render_pep440_pre(pieces):
"""TAG[.postN.devDISTANCE] -- No -dirty.
Exceptions:
1: no tags. 0.post0.devDISTANCE
"""
if pieces["closest-tag"]:
if pieces["distance"]:
# update the post release segment
tag_version, post_version = pep440_split_post(pieces["closest-ta... | TAG[.postN.devDISTANCE] -- No -dirty.
Exceptions:
1: no tags. 0.post0.devDISTANCE
| render_pep440_pre | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def render_pep440_post(pieces):
"""TAG[.postDISTANCE[.dev0]+gHEX] .
The ".dev0" means dirty. Note that .dev0 sorts backwards
(a dirty tree will appear "older" than the corresponding clean one),
but you shouldn't be releasing software with -dirty anyways.
Exceptions:
1: no tags. 0.postDISTANCE[... | TAG[.postDISTANCE[.dev0]+gHEX] .
The ".dev0" means dirty. Note that .dev0 sorts backwards
(a dirty tree will appear "older" than the corresponding clean one),
but you shouldn't be releasing software with -dirty anyways.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]
| render_pep440_post | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def render_pep440_post_branch(pieces):
"""TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] .
The ".dev0" means not master branch.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"] or pieces["dir... | TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] .
The ".dev0" means not master branch.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty]
| render_pep440_post_branch | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
def render_pep440_old(pieces):
"""TAG[.postDISTANCE[.dev0]] .
The ".dev0" means dirty.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"] or pieces["dirty"]:
rendered += ".post%d" % piec... | TAG[.postDISTANCE[.dev0]] .
The ".dev0" means dirty.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]
| render_pep440_old | python | mars-project/mars | mars/_version.py | https://github.com/mars-project/mars/blob/master/mars/_version.py | Apache-2.0 |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.