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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
99b8034502127b26a21bd37c | train | class | class Parser(object):
'''A Tweet Parser'''
def __init__(self, max_url_length=30, include_spans=False):
self._max_url_length = max_url_length
self._include_spans = include_spans
def parse(self, text, html=True):
'''Parse the text and return a ParseResult instance.'''
self._... | class Parser(object):
| '''A Tweet Parser'''
def __init__(self, max_url_length=30, include_spans=False):
self._max_url_length = max_url_length
self._include_spans = include_spans
def parse(self, text, html=True):
'''Parse the text and return a ParseResult instance.'''
self._urls = []
self.... | - urls:
A list containing all the valid urls in the Tweet.
- users
A list containing all the valid usernames in the Tweet.
- reply
A string containing the username this tweet was a reply to.
This only matches a username at the beginning of the Tweet,
it may however be ... | 256 | 256 | 1,395 | 4 | 251 | rezendi/vortext | ttp.py | Python | Parser | Parser | 117 | 288 | 117 | 118 | 464cf522dafd94161dca70dac8552a3b706de215 | bigcode/the-stack | train |
e73c3a75705db5fc34c6bcf7 | train | function | def escape(text):
'''Escape some HTML entities.'''
return ''.join({'&': '&', '"': '"',
'\'': ''', '>': '>',
'<': '<'}.get(c, c) for c in text)
| def escape(text):
| '''Escape some HTML entities.'''
return ''.join({'&': '&', '"': '"',
'\'': ''', '>': '>',
'<': '<'}.get(c, c) for c in text)
| % (user, list_name, at_char, user, list_name)
def format_url(self, url, text):
'''Return formatted HTML for a url.'''
return '<a href="%s">%s</a>' % (escape(url), text)
# Simple URL escaper
def escape(text):
| 64 | 64 | 55 | 4 | 59 | rezendi/vortext | ttp.py | Python | escape | escape | 292 | 296 | 292 | 292 | 3e392298a36a1332b83e98c4bc0e640bf6859b4e | bigcode/the-stack | train |
f488e0a23fb823552096c6ee | train | class | class ParseResult(object):
'''A class containing the results of a parsed Tweet.
Attributes:
- urls:
A list containing all the valid urls in the Tweet.
- users
A list containing all the valid usernames in the Tweet.
- reply
A string containing the username this tweet was a... | class ParseResult(object):
| '''A class containing the results of a parsed Tweet.
Attributes:
- urls:
A list containing all the valid urls in the Tweet.
- users
A list containing all the valid usernames in the Tweet.
- reply
A string containing the username this tweet was a reply to.
This only... | _CHARS, DOMAIN_CHARS, PATH_CHARS,
PATH_ENDING_CHARS, QUERY_CHARS, QUERY_ENDING_CHARS),
re.IGNORECASE)
# Registered IANA one letter domains
IANA_ONE_LETTER_DOMAINS = ('x.com', 'x.org', 'z.com', 'q.net', 'q.com', 'i.net')
class ParseResult(object):
| 81 | 81 | 273 | 5 | 76 | rezendi/vortext | ttp.py | Python | ParseResult | ParseResult | 76 | 114 | 76 | 77 | 8ddfb7d05337da7faf2a82b164dea0f4c4b644c3 | bigcode/the-stack | train |
bcdc792148e8317a86a5b52d | train | class | class CellsPublicInterfacesTestCase(test.TestCase):
"""Test case for the public interfaces into cells messaging."""
def setUp(self):
super(CellsPublicInterfacesTestCase, self).setUp()
fakes.init(self)
self.ctxt = context.RequestContext('fake', 'fake')
self.our_name = 'api-cell'
... | class CellsPublicInterfacesTestCase(test.TestCase):
| """Test case for the public interfaces into cells messaging."""
def setUp(self):
super(CellsPublicInterfacesTestCase, self).setUp()
fakes.init(self)
self.ctxt = context.RequestContext('fake', 'fake')
self.our_name = 'api-cell'
self.msg_runner = fakes.get_message_runner(se... | (self.ctxt, 'cell',
'fake_other_keypair', False)
fake_process.return_value = [response, other_response]
responses = self.src_msg_runner.get_keypair_at_top(self.ctxt,
user_id, name)
fake_proces... | 79 | 79 | 264 | 10 | 69 | nicholaskuechler/nova | nova/tests/unit/cells/test_cells_messaging.py | Python | CellsPublicInterfacesTestCase | CellsPublicInterfacesTestCase | 2,125 | 2,153 | 2,125 | 2,125 | 16958c97b7300c08c86b940fdaeb8d0fe153c2d7 | bigcode/the-stack | train |
37ab1966b71c35b6341b8ec7 | train | class | class CellsMessageClassesTestCase(test.TestCase):
"""Test case for the main Cells Message classes."""
def setUp(self):
super(CellsMessageClassesTestCase, self).setUp()
fakes.init(self)
self.ctxt = context.RequestContext('fake', 'fake')
self.our_name = 'api-cell'
self.msg_... | class CellsMessageClassesTestCase(test.TestCase):
| """Test case for the main Cells Message classes."""
def setUp(self):
super(CellsMessageClassesTestCase, self).setUp()
fakes.init(self)
self.ctxt = context.RequestContext('fake', 'fake')
self.our_name = 'api-cell'
self.msg_runner = fakes.get_message_runner(self.our_name)
... | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Tests For Cells Messaging module
"""
import contextlib
imp... | 256 | 256 | 5,090 | 10 | 246 | nicholaskuechler/nova | nova/tests/unit/cells/test_cells_messaging.py | Python | CellsMessageClassesTestCase | CellsMessageClassesTestCase | 52 | 648 | 52 | 52 | 7caab7bf991db89b2d6acaa4dee45ccf725132b0 | bigcode/the-stack | train |
97dde74f571a8988b0668985 | train | class | class CellsBroadcastMethodsTestCase(test.TestCase):
"""Test case for _BroadcastMessageMethods class. Most of these
tests actually test the full path from the MessageRunner through
to the functionality of the message method. Hits 2 birds with 1
stone, even though it's a little more than a unit test.
... | class CellsBroadcastMethodsTestCase(test.TestCase):
| """Test case for _BroadcastMessageMethods class. Most of these
tests actually test the full path from the MessageRunner through
to the functionality of the message method. Hits 2 birds with 1
stone, even though it's a little more than a unit test.
"""
def setUp(self):
super(CellsBroad... | test_backup_instance(self):
inst = objects.Instance()
meth_cls = self.tgt_methods_cls
self.mox.StubOutWithMock(inst, 'refresh')
self.mox.StubOutWithMock(inst, 'save')
self.mox.StubOutWithMock(meth_cls.compute_rpcapi, 'backup_instance')
def check_state(expected_task_sta... | 256 | 256 | 6,391 | 10 | 246 | nicholaskuechler/nova | nova/tests/unit/cells/test_cells_messaging.py | Python | CellsBroadcastMethodsTestCase | CellsBroadcastMethodsTestCase | 1,412 | 2,122 | 1,412 | 1,412 | 3c5110a66330412a8eb2c2df99dd4cb83f724466 | bigcode/the-stack | train |
bcae01dc57699bbd0c1b96d1 | train | class | class CellsTargetedMethodsTestCase(test.TestCase):
"""Test case for _TargetedMessageMethods class. Most of these
tests actually test the full path from the MessageRunner through
to the functionality of the message method. Hits 2 birds with 1
stone, even though it's a little more than a unit test.
... | class CellsTargetedMethodsTestCase(test.TestCase):
| """Test case for _TargetedMessageMethods class. Most of these
tests actually test the full path from the MessageRunner through
to the functionality of the message method. Hits 2 birds with 1
stone, even though it's a little more than a unit test.
"""
def setUp(self):
super(CellsTargete... | our_fake_method',
our_fake_method_failing)
fakes.stub_bcast_method(self, 'grandchild-cell3', 'our_fake_method',
our_fake_method_failing)
bcast_message = messaging._BroadcastMessage(self.msg_runner,
... | 256 | 256 | 6,575 | 11 | 245 | nicholaskuechler/nova | nova/tests/unit/cells/test_cells_messaging.py | Python | CellsTargetedMethodsTestCase | CellsTargetedMethodsTestCase | 651 | 1,409 | 651 | 651 | faff81d48ea8b02ff299eab94e24b11835a67643 | bigcode/the-stack | train |
d2b1995eb20c59998dac2b5b | train | class | class StackAllocationMixin(PagedMemoryMixin):
"""
This mixin adds automatic allocation for a stack region based on the stack_end and stack_size parameters.
"""
# TODO: multiple stacks. this scheme should scale p well
# TODO tbh this should be handled by an actual fault handler in simos or something
... | class StackAllocationMixin(PagedMemoryMixin):
| """
This mixin adds automatic allocation for a stack region based on the stack_end and stack_size parameters.
"""
# TODO: multiple stacks. this scheme should scale p well
# TODO tbh this should be handled by an actual fault handler in simos or something
def __init__(self, stack_end=None, stack_s... | import logging
from .paged_memory_mixin import PagedMemoryMixin
from ....errors import SimSegfaultException, SimMemoryError
l = logging.getLogger(__name__)
class StackAllocationMixin(PagedMemoryMixin):
| 45 | 209 | 699 | 9 | 36 | mikenawrocki/angr | angr/storage/memory_mixins/paged_memory/stack_allocation_mixin.py | Python | StackAllocationMixin | StackAllocationMixin | 8 | 64 | 8 | 8 | 39a77dcce12a6281e4aad8c40210af1b3082ae03 | bigcode/the-stack | train |
a921c4dd9d8d76e93f440832 | train | function | def print_input(*args):
print(*args)
input()
| def print_input(*args):
| print(*args)
input()
|
END_COLOR = Style.RESET_ALL
CLEAR_SCREEN = "\033[2J"
LINE = "-" * 79
SPEAK = "You: "
def decor():
print(LINE)
def print_decor(*args):
print(*args)
decor()
def print_input(*args):
| 64 | 64 | 14 | 6 | 58 | Yang-Wei-Ting/A-BioShock-Themed-Treasure-Hunting-Game | Source Code/modules/layouts.py | Python | print_input | print_input | 24 | 26 | 24 | 24 | 13caa1a53f6d58dc75133f6dccabe1614bad2911 | bigcode/the-stack | train |
24e82d617e9c79ee6d6af75d | train | function | def decor():
print(LINE)
| def decor():
| print(LINE)
| or info related to the bad guy
CYAN = Style.BRIGHT + Fore.CYAN # Color cyan for something good
END_COLOR = Style.RESET_ALL
CLEAR_SCREEN = "\033[2J"
LINE = "-" * 79
SPEAK = "You: "
def decor():
| 63 | 64 | 8 | 3 | 60 | Yang-Wei-Ting/A-BioShock-Themed-Treasure-Hunting-Game | Source Code/modules/layouts.py | Python | decor | decor | 15 | 16 | 15 | 15 | fcaadbf4e03ebe34d0314567c58cca2d0bcb3b3d | bigcode/the-stack | train |
64bafb7887be416007348d3a | train | function | def print_decor(*args):
print(*args)
decor()
| def print_decor(*args):
| print(*args)
decor()
| Style.BRIGHT + Fore.CYAN # Color cyan for something good
END_COLOR = Style.RESET_ALL
CLEAR_SCREEN = "\033[2J"
LINE = "-" * 79
SPEAK = "You: "
def decor():
print(LINE)
def print_decor(*args):
| 64 | 64 | 15 | 7 | 57 | Yang-Wei-Ting/A-BioShock-Themed-Treasure-Hunting-Game | Source Code/modules/layouts.py | Python | print_decor | print_decor | 19 | 21 | 19 | 19 | ae1daad6a9f7884ca788cdc4fc521aa820244948 | bigcode/the-stack | train |
8104ed6805e0d35e101024a5 | train | function | def get_adjusted_expected(observed, expected, ice_weight, kernel, b, return_type="dense"):
'''
get_adjusted_expected, get the expected adjusted
to the local background using local-kernel convolution.
... it comes down to comparison of pixel intensity
in observed: M_ice,
and a locally-modified e... | def get_adjusted_expected(observed, expected, ice_weight, kernel, b, return_type="dense"):
| '''
get_adjusted_expected, get the expected adjusted
to the local background using local-kernel convolution.
... it comes down to comparison of pixel intensity
in observed: M_ice,
and a locally-modified expected:
DONUT[i,j](M_ice)
Ed_ice[i,j] = E_ice[i,j]*-----... |
from scipy.linalg import toeplitz
from scipy.ndimage import convolve
import numpy as np
import pandas as pd
###########################
# Calculate couple more columns for filtering/sorting ...
###########################
_cmp_masks = lambda M_superset,M_subset: (0 > M_superset.astype(np.int) -
... | 134 | 256 | 2,256 | 22 | 112 | sergpolly/cooloop | old_loopify.py | Python | get_adjusted_expected | get_adjusted_expected | 27 | 275 | 27 | 27 | 578005f04304fd2f506e8f347a1cb6874fee4fb8 | bigcode/the-stack | train |
250245bae5e7f0aa669f402a | train | function | def get_adjusted_expected_tile(origin,
observed,
expected,
ice_weight,
kernels,
b,
band=2e+6):
"""
get_adjusted_expected_slice... | def get_adjusted_expected_tile(origin,
observed,
expected,
ice_weight,
kernels,
b,
band=2e+6):
| """
get_adjusted_expected_slice is calculating
locally-adjusted expected for smaller slices
of the full intra-chromosomal interaction
matrix.
Each slice is characterized by the coordinate
of the top-left corner and size.
* * * * * * * * * * * 0-th slice
* * *
*... | be masked out for the downstream
# analysis:
return Ed_raw, mask_ndx, KM, KE, NN
elif return_type == "sparse":
# return sparsified data frame
# with the same format as the
# new tiled get_loc_adj_exp funcs.
# any nonzero element in `mask_ndx`
# must be maske... | 255 | 256 | 977 | 32 | 223 | sergpolly/cooloop | old_loopify.py | Python | get_adjusted_expected_tile | get_adjusted_expected_tile | 283 | 398 | 283 | 289 | 44c13c782cb26014857af4b6581086ded46a48c4 | bigcode/the-stack | train |
41c79c44056ad33652305568 | train | function | def get_adjusted_expected_some_nans(observed,
expected,
ice_weight,
kernels,
b,
band=2e+6,
nan_threshold... | def get_adjusted_expected_some_nans(observed,
expected,
ice_weight,
kernels,
b,
band=2e+6,
nan_threshold... | '''
Same as 'get_adjusted_expected'
...
...
but able to tolerate some NaNs in
the kernel area.
The idea is to fill NaNs with 0s,
convolve M_ice and E_ice like that.
Then figure out how many NaNs were
near each pixel using convolution
of NaN-masks of the input matrices.
... | band_idx = int(band/b)
assert s > band_idx
# combine all filters/masks:
# mask_Ed || mask_NN
mask_ndx = np.logical_or(mask_Ed, mask_NN)
# any nonzero element in `mask_ndx`
# must be masked out from `pvals`:
# so, we'll just take the negated
# elements of the combined mask:
i, j = ... | 256 | 256 | 1,448 | 38 | 218 | sergpolly/cooloop | old_loopify.py | Python | get_adjusted_expected_some_nans | get_adjusted_expected_some_nans | 407 | 573 | 407 | 413 | 93efafc237711dc956c67702a877cb6f8f430e0f | bigcode/the-stack | train |
be5e09106de43324e5a0886e | train | class | class TwitchHelix(object):
"""
Twitch Helix API
"""
def __init__(self, client_id=None, oauth_token=None):
self._client_id = client_id
self._oauth_token = oauth_token
if not client_id:
self._client_id, self._oauth_token = credentials_from_config_file()
def get_s... | class TwitchHelix(object):
| """
Twitch Helix API
"""
def __init__(self, client_id=None, oauth_token=None):
self._client_id = client_id
self._oauth_token = oauth_token
if not client_id:
self._client_id, self._oauth_token = credentials_from_config_file()
def get_streams(self, after=None, be... | from twitch.conf import credentials_from_config_file
from twitch.constants import (
PERIODS, PERIOD_ALL, VIDEO_SORTS, VIDEO_SORT_TIME, VIDEO_TYPES, VIDEO_TYPE_ALL
)
from twitch.exceptions import TwitchAttributeException
from twitch.helix.base import APICursor, APIGet
from twitch.resources import Clip, Follow, Game,... | 84 | 256 | 1,870 | 6 | 77 | ArnaudGallardo/python-twitch-client | twitch/helix/api.py | Python | TwitchHelix | TwitchHelix | 10 | 258 | 10 | 10 | 9bf25f2f0dd0ccb1d376051a5f86cd679c32f4ec | bigcode/the-stack | train |
c88dcc3b2f61a90f73ea2123 | train | function | def main(arguments):
suffix_detected = False
psl = None
download_suffixes()
with open("public_suffix_list.dat", "r") as latest:
psl = PublicSuffixList(latest)
with io.open('disposable_email_blacklist.conf', 'r') as deb:
for i, line in enumerate(deb):
current_line = line.s... | def main(arguments):
| suffix_detected = False
psl = None
download_suffixes()
with open("public_suffix_list.dat", "r") as latest:
psl = PublicSuffixList(latest)
with io.open('disposable_email_blacklist.conf', 'r') as deb:
for i, line in enumerate(deb):
current_line = line.strip()
pu... | #!/usr/bin/env python
"""Verify the integrity of the domain blacklist
"""
import io
import sys
from publicsuffixlist import PublicSuffixList
from requests import get
def main(arguments):
| 40 | 64 | 178 | 4 | 35 | neocities/disposable-email-domains | verify.py | Python | main | main | 12 | 27 | 12 | 12 | 0e16608236a1ef80899cb12b136e290e2f4dce06 | bigcode/the-stack | train |
814f3a92b48bd634dfa6920c | train | function | def download_suffixes():
with open('public_suffix_list.dat', "wb") as file:
response = get('https://publicsuffix.org/list/public_suffix_list.dat')
file.write(response.content)
| def download_suffixes():
| with open('public_suffix_list.dat', "wb") as file:
response = get('https://publicsuffix.org/list/public_suffix_list.dat')
file.write(response.content)
| {current_line}')
suffix_detected = True
if suffix_detected:
print ('At least one valid public suffix found in the blacklist, please remove it. See https://publicsuffix.org for details on why this shouldn\'t be blacklisted.')
sys.exit(1)
def download_suffixes():
| 64 | 64 | 42 | 5 | 59 | neocities/disposable-email-domains | verify.py | Python | download_suffixes | download_suffixes | 29 | 32 | 29 | 29 | add6783e44af07e1b78afa6f459c0375c3a74b9b | bigcode/the-stack | train |
781246b7fce5e91292c9f2d9 | train | function | def train_core():
domain_file="domain.yml"
model_path="agent-data/models/dialogue"
stories_file="agent-data/data/stories.md"
agent = Agent(
domain_file,
policies=[MemoizationPolicy(max_history=5), KerasPolicy()]
)
training_data = agent.load_data(stories_file)
agent.train(... | def train_core():
| domain_file="domain.yml"
model_path="agent-data/models/dialogue"
stories_file="agent-data/data/stories.md"
agent = Agent(
domain_file,
policies=[MemoizationPolicy(max_history=5), KerasPolicy()]
)
training_data = agent.load_data(stories_file)
agent.train(training_data) # t... | load_data('agent-data/data/nlu.md')
trainer = Trainer(config.load("nlu-config.yml"))
trainer.train(training_data)
model_directory = trainer.persist('agent-data/models/nlu/', fixed_model_name="current")
return model_directory
# Train Rasa-Core Dialogue Model
def train_core():
| 64 | 64 | 95 | 4 | 59 | leonore/ugenie | chat-service/model/trainer.py | Python | train_core | train_core | 42 | 53 | 42 | 42 | f591e144c87cbac7ea48fe2c7b0be2084ad6b634 | bigcode/the-stack | train |
4a1d1fd0a68f4c314b484423 | train | function | def train_nlu():
training_data = load_data('agent-data/data/nlu.md')
trainer = Trainer(config.load("nlu-config.yml"))
trainer.train(training_data)
model_directory = trainer.persist('agent-data/models/nlu/', fixed_model_name="current")
return model_directory
| def train_nlu():
| training_data = load_data('agent-data/data/nlu.md')
trainer = Trainer(config.load("nlu-config.yml"))
trainer.train(training_data)
model_directory = trainer.persist('agent-data/models/nlu/', fixed_model_name="current")
return model_directory
| (max_history=5), KerasPolicy()],
interpreter=interpreter, action_endpoint=action_endpoint)
data = agent.load_data(stories_file)
agent.train(data)
interactive.run_interactive_learning(agent, stories_file)
return agent
# Train Rasa-NLU Model
def train_nlu():
| 64 | 64 | 61 | 5 | 58 | leonore/ugenie | chat-service/model/trainer.py | Python | train_nlu | train_nlu | 34 | 39 | 34 | 34 | b6c7e39539ea9b0b5e790a8dca2fc0e41e0c0ae4 | bigcode/the-stack | train |
a748c3e32dc6fd4ba1ef66bf | train | function | def train():
model_directory = train_nlu()
agent = train_core()
| def train():
| model_directory = train_nlu()
agent = train_core()
| =5), KerasPolicy()]
)
training_data = agent.load_data(stories_file)
agent.train(training_data) # train the bot according to the stories context
agent.persist(model_path)
return agent
# Train both Rasa-Core Dialogue Model and Rasa-NLU Model
def train():
| 64 | 64 | 17 | 3 | 60 | leonore/ugenie | chat-service/model/trainer.py | Python | train | train | 56 | 58 | 56 | 56 | acf5845e30c05aab4e77c29e3611922d25dba360 | bigcode/the-stack | train |
b77b373d9de7f7a2a741d5bf | train | function | def train_interactive():
current_directory = os.path.dirname(os.path.realpath(__file__))
domain_file = 'domain.yml'
interpreter = RasaNLUInterpreter(current_directory + '/agent-data/models/nlu/default/current')
action_endpoint = EndpointConfig(url=actionIP)
stories_file = current_directory + '/agent... | def train_interactive():
| current_directory = os.path.dirname(os.path.realpath(__file__))
domain_file = 'domain.yml'
interpreter = RasaNLUInterpreter(current_directory + '/agent-data/models/nlu/default/current')
action_endpoint = EndpointConfig(url=actionIP)
stories_file = current_directory + '/agent-data/data/stories.md'
... | izationPolicy
from rasa_core.train import interactive
from rasa_core.utils import EndpointConfig
from rasa_nlu.training_data import load_data
from rasa_nlu import config
from rasa_nlu.model import Trainer
import os
from network_config import actionIP
# Start Interactive Training Mode
def train_interactive():
| 64 | 64 | 137 | 5 | 58 | leonore/ugenie | chat-service/model/trainer.py | Python | train_interactive | train_interactive | 19 | 31 | 19 | 19 | bfddf6d1be4b3c1d084d8bdfddbad73de78f7886 | bigcode/the-stack | train |
061b94e41633c6ecf181e3e8 | train | function | def make_train_17(stack=True, scale_rew=True):
return make_train(17, stack, scale_rew)
| def make_train_17(stack=True, scale_rew=True):
| return make_train(17, stack, scale_rew)
| make_train_15(stack=True, scale_rew=True):
return make_train(15, stack, scale_rew)
def make_train_16(stack=True, scale_rew=True):
return make_train(16, stack, scale_rew)
def make_train_17(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_17 | make_train_17 | 210 | 211 | 210 | 210 | 303fcce473915a806c72901b5f51b87a799b13df | bigcode/the-stack | train |
5ee98104d23a34408dbca161 | train | function | def make_train_12(stack=True, scale_rew=True):
return make_train(12, stack, scale_rew)
| def make_train_12(stack=True, scale_rew=True):
| return make_train(12, stack, scale_rew)
| make_train_10(stack=True, scale_rew=True):
return make_train(10, stack, scale_rew)
def make_train_11(stack=True, scale_rew=True):
return make_train(11, stack, scale_rew)
def make_train_12(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_12 | make_train_12 | 195 | 196 | 195 | 195 | 313102973221d2e65770062e4f2bcd9f0d2cbb2a | bigcode/the-stack | train |
7ea5fdc7ba743a651423a8f4 | train | function | def make_train_38(stack=True, scale_rew=True):
return make_train(38, stack, scale_rew)
| def make_train_38(stack=True, scale_rew=True):
| return make_train(38, stack, scale_rew)
| make_train_36(stack=True, scale_rew=True):
return make_train(36, stack, scale_rew)
def make_train_37(stack=True, scale_rew=True):
return make_train(37, stack, scale_rew)
def make_train_38(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_38 | make_train_38 | 273 | 274 | 273 | 273 | 4b8f1d5ac4a0e108f7d8ba804e59da151971231e | bigcode/the-stack | train |
7c0da5a008f49cc664ffc8fa | train | function | def make_train_18(stack=True, scale_rew=True):
return make_train(18, stack, scale_rew)
| def make_train_18(stack=True, scale_rew=True):
| return make_train(18, stack, scale_rew)
| make_train_16(stack=True, scale_rew=True):
return make_train(16, stack, scale_rew)
def make_train_17(stack=True, scale_rew=True):
return make_train(17, stack, scale_rew)
def make_train_18(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_18 | make_train_18 | 213 | 214 | 213 | 213 | c5ceea4ab7324c9385cca65a49270977ca3b5559 | bigcode/the-stack | train |
a0bab321b3e3abea78fd3251 | train | function | def make_train_34(stack=True, scale_rew=True):
return make_train(34, stack, scale_rew)
| def make_train_34(stack=True, scale_rew=True):
| return make_train(34, stack, scale_rew)
| make_train_32(stack=True, scale_rew=True):
return make_train(32, stack, scale_rew)
def make_train_33(stack=True, scale_rew=True):
return make_train(33, stack, scale_rew)
def make_train_34(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_34 | make_train_34 | 261 | 262 | 261 | 261 | b7fbf6407f72965698c953d6861f30b75e9e97b8 | bigcode/the-stack | train |
4e44a7f56a3062ae3805c613 | train | function | def make_train_39(stack=True, scale_rew=True):
return make_train(39, stack, scale_rew)
| def make_train_39(stack=True, scale_rew=True):
| return make_train(39, stack, scale_rew)
| make_train_37(stack=True, scale_rew=True):
return make_train(37, stack, scale_rew)
def make_train_38(stack=True, scale_rew=True):
return make_train(38, stack, scale_rew)
def make_train_39(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_39 | make_train_39 | 276 | 277 | 276 | 276 | 23d3195bc6d47e461aa6bf8571c64fb3a8953d99 | bigcode/the-stack | train |
10d4146027609b9d18fdbf53 | train | function | def make_train_40(stack=True, scale_rew=True):
return make_train(40, stack, scale_rew)
| def make_train_40(stack=True, scale_rew=True):
| return make_train(40, stack, scale_rew)
| make_train_38(stack=True, scale_rew=True):
return make_train(38, stack, scale_rew)
def make_train_39(stack=True, scale_rew=True):
return make_train(39, stack, scale_rew)
def make_train_40(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_40 | make_train_40 | 279 | 280 | 279 | 279 | 10454a62b870378f01f6d6b68d226a2b8fd2fa28 | bigcode/the-stack | train |
7d1305c035d860f9d047ed02 | train | function | def make_train_8(stack=True, scale_rew=True):
return make_train(8, stack, scale_rew)
| def make_train_8(stack=True, scale_rew=True):
| return make_train(8, stack, scale_rew)
| make_train_6(stack=True, scale_rew=True):
return make_train(6, stack, scale_rew)
def make_train_7(stack=True, scale_rew=True):
return make_train(7, stack, scale_rew)
def make_train_8(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_8 | make_train_8 | 183 | 184 | 183 | 183 | a9187769f25490c308fbdc03a40b0ef0308565fa | bigcode/the-stack | train |
b229b0db69901ad78f6acf66 | train | function | def make_train_0(stack=True, scale_rew=True):
return make_train(0, stack, scale_rew)
| def make_train_0(stack=True, scale_rew=True):
| return make_train(0, stack, scale_rew)
| cretizer(env)
if scale_rew:
env = RewardScaler(env)
env = WarpFrame96(env)
if stack:
env = FrameStack(env, 4)
env = AllowBacktracking(env)
return env
def make_train_0(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 50 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_0 | make_train_0 | 159 | 160 | 159 | 159 | 87e9f1ad7a703302486de4a91ed9a4a64057e755 | bigcode/the-stack | train |
553f98f9d2987343ad54798e | train | function | def make_train_11(stack=True, scale_rew=True):
return make_train(11, stack, scale_rew)
| def make_train_11(stack=True, scale_rew=True):
| return make_train(11, stack, scale_rew)
| make_train_9(stack=True, scale_rew=True):
return make_train(9, stack, scale_rew)
def make_train_10(stack=True, scale_rew=True):
return make_train(10, stack, scale_rew)
def make_train_11(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_11 | make_train_11 | 192 | 193 | 192 | 192 | 246fa1e8412ec1d4265b97d0d1a80571a2627e40 | bigcode/the-stack | train |
95e59288fe94355d1b71ad0c | train | function | def make_train_3(stack=True, scale_rew=True):
return make_train(3, stack, scale_rew)
| def make_train_3(stack=True, scale_rew=True):
| return make_train(3, stack, scale_rew)
| make_train_1(stack=True, scale_rew=True):
return make_train(1, stack, scale_rew)
def make_train_2(stack=True, scale_rew=True):
return make_train(2, stack, scale_rew)
def make_train_3(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_3 | make_train_3 | 168 | 169 | 168 | 168 | 007beb15c118ac7cb61d5a50e8f2358952ea9045 | bigcode/the-stack | train |
412f4fe9e3c945441d2ebb42 | train | function | def make_train_35(stack=True, scale_rew=True):
return make_train(35, stack, scale_rew)
| def make_train_35(stack=True, scale_rew=True):
| return make_train(35, stack, scale_rew)
| make_train_33(stack=True, scale_rew=True):
return make_train(33, stack, scale_rew)
def make_train_34(stack=True, scale_rew=True):
return make_train(34, stack, scale_rew)
def make_train_35(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_35 | make_train_35 | 264 | 265 | 264 | 264 | 31a3c6b87463d2d13f4282fd40757bf08497dd6a | bigcode/the-stack | train |
0a368fd5e0d3bc9bfd63789e | train | function | def make_train_29(stack=True, scale_rew=True):
return make_train(29, stack, scale_rew)
| def make_train_29(stack=True, scale_rew=True):
| return make_train(29, stack, scale_rew)
| make_train_27(stack=True, scale_rew=True):
return make_train(27, stack, scale_rew)
def make_train_28(stack=True, scale_rew=True):
return make_train(28, stack, scale_rew)
def make_train_29(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_29 | make_train_29 | 246 | 247 | 246 | 246 | 142468c55f5f70c6b299abce7b9bc85ef785c472 | bigcode/the-stack | train |
9f0f33e673ddca643a6054cb | train | function | def make_train_14(stack=True, scale_rew=True):
return make_train(14, stack, scale_rew)
| def make_train_14(stack=True, scale_rew=True):
| return make_train(14, stack, scale_rew)
| make_train_12(stack=True, scale_rew=True):
return make_train(12, stack, scale_rew)
def make_train_13(stack=True, scale_rew=True):
return make_train(13, stack, scale_rew)
def make_train_14(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_14 | make_train_14 | 201 | 202 | 201 | 201 | ab01fc540e75b3bc48e9fb5fd619ce769c2e1ff9 | bigcode/the-stack | train |
b13898560b53ab6e6fbda8ae | train | function | def make_train_41(stack=True, scale_rew=True):
return make_train(41, stack, scale_rew)
| def make_train_41(stack=True, scale_rew=True):
| return make_train(41, stack, scale_rew)
| make_train_39(stack=True, scale_rew=True):
return make_train(39, stack, scale_rew)
def make_train_40(stack=True, scale_rew=True):
return make_train(40, stack, scale_rew)
def make_train_41(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_41 | make_train_41 | 282 | 283 | 282 | 282 | 97ca30c9daf32065b15d512435eb0b34cb6244b8 | bigcode/the-stack | train |
fd57f505c2581387bd59ea03 | train | function | def make_train_22(stack=True, scale_rew=True):
return make_train(22, stack, scale_rew)
| def make_train_22(stack=True, scale_rew=True):
| return make_train(22, stack, scale_rew)
| make_train_20(stack=True, scale_rew=True):
return make_train(20, stack, scale_rew)
def make_train_21(stack=True, scale_rew=True):
return make_train(21, stack, scale_rew)
def make_train_22(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_22 | make_train_22 | 225 | 226 | 225 | 225 | 32f403703de36e6509ac5b2264890aa76639df11 | bigcode/the-stack | train |
18488d7d8d751819b998226f | train | function | def make_train_1(stack=True, scale_rew=True):
return make_train(1, stack, scale_rew)
| def make_train_1(stack=True, scale_rew=True):
| return make_train(1, stack, scale_rew)
| if stack:
env = FrameStack(env, 4)
env = AllowBacktracking(env)
return env
def make_train_0(stack=True, scale_rew=True):
return make_train(0, stack, scale_rew)
def make_train_1(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_1 | make_train_1 | 162 | 163 | 162 | 162 | e05517eeaf823db6aa3f969520b30982ec6c4c39 | bigcode/the-stack | train |
9aa9fb14c2419395913c42bc | train | function | def make_train_42(stack=True, scale_rew=True):
return make_train(42, stack, scale_rew)
| def make_train_42(stack=True, scale_rew=True):
| return make_train(42, stack, scale_rew)
| make_train_40(stack=True, scale_rew=True):
return make_train(40, stack, scale_rew)
def make_train_41(stack=True, scale_rew=True):
return make_train(41, stack, scale_rew)
def make_train_42(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_42 | make_train_42 | 285 | 286 | 285 | 285 | 408f16942887efc63364a2e539ad36c625e79805 | bigcode/the-stack | train |
b412030450bdbf7cfb331083 | train | function | def make_train_9(stack=True, scale_rew=True):
return make_train(9, stack, scale_rew)
| def make_train_9(stack=True, scale_rew=True):
| return make_train(9, stack, scale_rew)
| make_train_7(stack=True, scale_rew=True):
return make_train(7, stack, scale_rew)
def make_train_8(stack=True, scale_rew=True):
return make_train(8, stack, scale_rew)
def make_train_9(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_9 | make_train_9 | 186 | 187 | 186 | 186 | fa45b4066b15fc46cb61d4d314a4cf72405c96e9 | bigcode/the-stack | train |
0a7efd793f073b49f7f1cd26 | train | function | def make_train_30(stack=True, scale_rew=True):
return make_train(30, stack, scale_rew)
| def make_train_30(stack=True, scale_rew=True):
| return make_train(30, stack, scale_rew)
| make_train_28(stack=True, scale_rew=True):
return make_train(28, stack, scale_rew)
def make_train_29(stack=True, scale_rew=True):
return make_train(29, stack, scale_rew)
def make_train_30(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_30 | make_train_30 | 249 | 250 | 249 | 249 | 1ad5b8b09bbbeb4fe1c3df736004cdd8bff2360a | bigcode/the-stack | train |
a3e9ac81c818d1576ef39e58 | train | function | def make_train(env_idx, stack=True, scale_rew=True):
"""
Create an environment with some standard wrappers.
"""
dicts = [
{'game': 'SonicTheHedgehog-Genesis', 'state': 'SpringYardZone.Act3'}, #0
{'game': 'SonicTheHedgehog-Genesis', 'state': 'SpringYardZone.Act2'},
{'game': 'Sonic... | def make_train(env_idx, stack=True, scale_rew=True):
| """
Create an environment with some standard wrappers.
"""
dicts = [
{'game': 'SonicTheHedgehog-Genesis', 'state': 'SpringYardZone.Act3'}, #0
{'game': 'SonicTheHedgehog-Genesis', 'state': 'SpringYardZone.Act2'},
{'game': 'SonicTheHedgehog-Genesis', 'state': 'GreenHillZone.Act3'},... | self).__init__(env)
self._cur_x = 0
self._max_x = 0
def reset(self, **kwargs): # pylint: disable=E0202
self._cur_x = 0
self._max_x = 0
return self.env.reset(**kwargs)
def step(self, action): # pylint: disable=E0202
obs, rew, done, info = self.env.step(action)
... | 256 | 256 | 1,337 | 14 | 241 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train | make_train | 95 | 157 | 95 | 95 | 40f8c4fc147cb309513c182c0f2fcd3f60bce632 | bigcode/the-stack | train |
41f5a823da8591642304d099 | train | function | def make_train_33(stack=True, scale_rew=True):
return make_train(33, stack, scale_rew)
| def make_train_33(stack=True, scale_rew=True):
| return make_train(33, stack, scale_rew)
| make_train_31(stack=True, scale_rew=True):
return make_train(31, stack, scale_rew)
def make_train_32(stack=True, scale_rew=True):
return make_train(32, stack, scale_rew)
def make_train_33(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_33 | make_train_33 | 258 | 259 | 258 | 258 | 32a5cd9b748d21c2f7b194245da9bfadc4d2cfe8 | bigcode/the-stack | train |
1bb593a2cbac325d1204187c | train | function | def make_train_36(stack=True, scale_rew=True):
return make_train(36, stack, scale_rew)
| def make_train_36(stack=True, scale_rew=True):
| return make_train(36, stack, scale_rew)
| make_train_34(stack=True, scale_rew=True):
return make_train(34, stack, scale_rew)
def make_train_35(stack=True, scale_rew=True):
return make_train(35, stack, scale_rew)
def make_train_36(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_36 | make_train_36 | 267 | 268 | 267 | 267 | c8c2ca417c34b45789e9716142da908a89ef1b80 | bigcode/the-stack | train |
7cee05b1490ede41a7006305 | train | function | def make_custom(stack=True, scale_rew=True):
"""
Create an environment with some standard wrappers.
"""
#env = grc.RemoteEnv('tmp/sock')
env = SonicDiscretizer(env)
if scale_rew:
env = RewardScaler(env)
env = WarpFrame96(env)
if stack:
env = FrameStack(env, 4)
env = A... | def make_custom(stack=True, scale_rew=True):
| """
Create an environment with some standard wrappers.
"""
#env = grc.RemoteEnv('tmp/sock')
env = SonicDiscretizer(env)
if scale_rew:
env = RewardScaler(env)
env = WarpFrame96(env)
if stack:
env = FrameStack(env, 4)
env = AllowBacktracking(env)
return env
| )
self._cur_x += rew
rew = max(0, self._cur_x - self._max_x)
self._max_x = max(self._max_x, self._cur_x)
return obs, rew, done, info
def make_custom(stack=True, scale_rew=True):
| 64 | 64 | 93 | 11 | 52 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_custom | make_custom | 81 | 93 | 81 | 81 | 316c75709199fff2ddf6b3f3e8eea98a85cb219d | bigcode/the-stack | train |
34b1f4af5ce81d73951979f9 | train | function | def make_train_2(stack=True, scale_rew=True):
return make_train(2, stack, scale_rew)
| def make_train_2(stack=True, scale_rew=True):
| return make_train(2, stack, scale_rew)
| make_train_0(stack=True, scale_rew=True):
return make_train(0, stack, scale_rew)
def make_train_1(stack=True, scale_rew=True):
return make_train(1, stack, scale_rew)
def make_train_2(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_2 | make_train_2 | 165 | 166 | 165 | 165 | 49e2041896ac1ca7f00713959b56e520ba11fbd9 | bigcode/the-stack | train |
cc15c076e06e129d7e68f3fc | train | function | def make_train_28(stack=True, scale_rew=True):
return make_train(28, stack, scale_rew)
| def make_train_28(stack=True, scale_rew=True):
| return make_train(28, stack, scale_rew)
| make_train_26(stack=True, scale_rew=True):
return make_train(26, stack, scale_rew)
def make_train_27(stack=True, scale_rew=True):
return make_train(27, stack, scale_rew)
def make_train_28(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_28 | make_train_28 | 243 | 244 | 243 | 243 | c2da22ade6dcf9738d99f59b1bdc3ff44ea77fbc | bigcode/the-stack | train |
df5de887d73465603c5350f6 | train | function | def make_train_26(stack=True, scale_rew=True):
return make_train(26, stack, scale_rew)
| def make_train_26(stack=True, scale_rew=True):
| return make_train(26, stack, scale_rew)
| make_train_24(stack=True, scale_rew=True):
return make_train(24, stack, scale_rew)
def make_train_25(stack=True, scale_rew=True):
return make_train(25, stack, scale_rew)
def make_train_26(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_26 | make_train_26 | 237 | 238 | 237 | 237 | 2399298f98fe307090e2714428762343093a3366 | bigcode/the-stack | train |
6cc33742e2b75716b2056a28 | train | function | def make_train_5(stack=True, scale_rew=True):
return make_train(5, stack, scale_rew)
| def make_train_5(stack=True, scale_rew=True):
| return make_train(5, stack, scale_rew)
| make_train_3(stack=True, scale_rew=True):
return make_train(3, stack, scale_rew)
def make_train_4(stack=True, scale_rew=True):
return make_train(4, stack, scale_rew)
def make_train_5(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_5 | make_train_5 | 174 | 175 | 174 | 174 | f87811da72b985a85f54dad02d61f732a380af0a | bigcode/the-stack | train |
b6dc532bcfef86ca7313846e | train | function | def make_train_4(stack=True, scale_rew=True):
return make_train(4, stack, scale_rew)
| def make_train_4(stack=True, scale_rew=True):
| return make_train(4, stack, scale_rew)
| make_train_2(stack=True, scale_rew=True):
return make_train(2, stack, scale_rew)
def make_train_3(stack=True, scale_rew=True):
return make_train(3, stack, scale_rew)
def make_train_4(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_4 | make_train_4 | 171 | 172 | 171 | 171 | d68fac999418571cf5ff4a843840b4cf931893e6 | bigcode/the-stack | train |
9106af8599ad14d3bbdb8d0b | train | function | def make_train_45(stack=True, scale_rew=True):
return make_train(45, stack, scale_rew)
| def make_train_45(stack=True, scale_rew=True):
| return make_train(45, stack, scale_rew)
| make_train_43(stack=True, scale_rew=True):
return make_train(43, stack, scale_rew)
def make_train_44(stack=True, scale_rew=True):
return make_train(44, stack, scale_rew)
def make_train_45(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_45 | make_train_45 | 294 | 295 | 294 | 294 | d4f02520cc6b5955d4274148b36157d6d1fa0347 | bigcode/the-stack | train |
dd32f1f5ad426c7bb37d7738 | train | function | def make_train_46(stack=True, scale_rew=True):
return make_train(46, stack, scale_rew) | def make_train_46(stack=True, scale_rew=True):
| return make_train(46, stack, scale_rew) | make_train_44(stack=True, scale_rew=True):
return make_train(44, stack, scale_rew)
def make_train_45(stack=True, scale_rew=True):
return make_train(45, stack, scale_rew)
def make_train_46(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_46 | make_train_46 | 297 | 298 | 297 | 297 | 0662efca2285170c669158bfe4920e13925b363a | bigcode/the-stack | train |
ce1de037cc7d517a938c5a04 | train | function | def make_train_23(stack=True, scale_rew=True):
return make_train(23, stack, scale_rew)
| def make_train_23(stack=True, scale_rew=True):
| return make_train(23, stack, scale_rew)
| make_train_21(stack=True, scale_rew=True):
return make_train(21, stack, scale_rew)
def make_train_22(stack=True, scale_rew=True):
return make_train(22, stack, scale_rew)
def make_train_23(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_23 | make_train_23 | 228 | 229 | 228 | 228 | 4e14963b7d494a036c6994e2bb34706e4e34bfef | bigcode/the-stack | train |
72cd728e0e9678615ca808fc | train | function | def make_train_32(stack=True, scale_rew=True):
return make_train(32, stack, scale_rew)
| def make_train_32(stack=True, scale_rew=True):
| return make_train(32, stack, scale_rew)
| make_train_30(stack=True, scale_rew=True):
return make_train(30, stack, scale_rew)
def make_train_31(stack=True, scale_rew=True):
return make_train(31, stack, scale_rew)
def make_train_32(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_32 | make_train_32 | 255 | 256 | 255 | 255 | 54f734072539af27c040849453c790d891900214 | bigcode/the-stack | train |
4bcb5ae4e311560450625830 | train | function | def make_train_37(stack=True, scale_rew=True):
return make_train(37, stack, scale_rew)
| def make_train_37(stack=True, scale_rew=True):
| return make_train(37, stack, scale_rew)
| make_train_35(stack=True, scale_rew=True):
return make_train(35, stack, scale_rew)
def make_train_36(stack=True, scale_rew=True):
return make_train(36, stack, scale_rew)
def make_train_37(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_37 | make_train_37 | 270 | 271 | 270 | 270 | 40a8c56c1926487845c0be97d98c1557fc619975 | bigcode/the-stack | train |
354438ec868a2d47199bc51b | train | function | def make_train_44(stack=True, scale_rew=True):
return make_train(44, stack, scale_rew)
| def make_train_44(stack=True, scale_rew=True):
| return make_train(44, stack, scale_rew)
| make_train_42(stack=True, scale_rew=True):
return make_train(42, stack, scale_rew)
def make_train_43(stack=True, scale_rew=True):
return make_train(43, stack, scale_rew)
def make_train_44(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_44 | make_train_44 | 291 | 292 | 291 | 291 | e2b87e56339fca3140d4df0779b583ed4226bb49 | bigcode/the-stack | train |
a99fc0f48d2f879e39aa6709 | train | function | def make_train_25(stack=True, scale_rew=True):
return make_train(25, stack, scale_rew)
| def make_train_25(stack=True, scale_rew=True):
| return make_train(25, stack, scale_rew)
| make_train_23(stack=True, scale_rew=True):
return make_train(23, stack, scale_rew)
def make_train_24(stack=True, scale_rew=True):
return make_train(24, stack, scale_rew)
def make_train_25(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_25 | make_train_25 | 234 | 235 | 234 | 234 | 13cb4dc4a7a17686e390e919135a2506c88d11f3 | bigcode/the-stack | train |
3a3852ac8f5ea38486212ba9 | train | function | def make_train_43(stack=True, scale_rew=True):
return make_train(43, stack, scale_rew)
| def make_train_43(stack=True, scale_rew=True):
| return make_train(43, stack, scale_rew)
| make_train_41(stack=True, scale_rew=True):
return make_train(41, stack, scale_rew)
def make_train_42(stack=True, scale_rew=True):
return make_train(42, stack, scale_rew)
def make_train_43(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_43 | make_train_43 | 288 | 289 | 288 | 288 | e475eb6789f7e3adf0d9af6af572f5feab4fc09c | bigcode/the-stack | train |
f72bb62ee7d31fc451ebee17 | train | class | class SonicDiscretizer(gym.ActionWrapper):
"""
Wrap a gym-retro environment and make it use discrete
actions for the Sonic game.
"""
def __init__(self, env):
super(SonicDiscretizer, self).__init__(env)
buttons = ["B", "A", "MODE", "START", "UP", "DOWN", "LEFT", "RIGHT", "C", "Y", "X"... | class SonicDiscretizer(gym.ActionWrapper):
| """
Wrap a gym-retro environment and make it use discrete
actions for the Sonic game.
"""
def __init__(self, env):
super(SonicDiscretizer, self).__init__(env)
buttons = ["B", "A", "MODE", "START", "UP", "DOWN", "LEFT", "RIGHT", "C", "Y", "X", "Z"]
actions = [['LEFT'], ['RIGHT... | .uint8)
def observation(self, frame):
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
frame = cv2.resize(frame, (self.width, self.height), interpolation=cv2.INTER_AREA)
return frame[:, :, None]
class SonicDiscretizer(gym.ActionWrapper):
| 64 | 64 | 216 | 10 | 54 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | SonicDiscretizer | SonicDiscretizer | 26 | 45 | 26 | 26 | 91adf6248c8b93f420f6d57ccae3d4b56cd8784c | bigcode/the-stack | train |
ff16a3c2c7a914710faa746c | train | function | def make_train_24(stack=True, scale_rew=True):
return make_train(24, stack, scale_rew)
| def make_train_24(stack=True, scale_rew=True):
| return make_train(24, stack, scale_rew)
| make_train_22(stack=True, scale_rew=True):
return make_train(22, stack, scale_rew)
def make_train_23(stack=True, scale_rew=True):
return make_train(23, stack, scale_rew)
def make_train_24(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_24 | make_train_24 | 231 | 232 | 231 | 231 | 2b4dd5b0005533295ae9e0e1182a7aeee234beaf | bigcode/the-stack | train |
90ec018a8ad0b8f43e7ebe24 | train | function | def make_train_7(stack=True, scale_rew=True):
return make_train(7, stack, scale_rew)
| def make_train_7(stack=True, scale_rew=True):
| return make_train(7, stack, scale_rew)
| make_train_5(stack=True, scale_rew=True):
return make_train(5, stack, scale_rew)
def make_train_6(stack=True, scale_rew=True):
return make_train(6, stack, scale_rew)
def make_train_7(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_7 | make_train_7 | 180 | 181 | 180 | 180 | 73879396d37f1e09bc41572a203bd7961e7192bf | bigcode/the-stack | train |
5e4fe122df69e5801f360e0e | train | function | def make_train_21(stack=True, scale_rew=True):
return make_train(21, stack, scale_rew)
| def make_train_21(stack=True, scale_rew=True):
| return make_train(21, stack, scale_rew)
| make_train_19(stack=True, scale_rew=True):
return make_train(19, stack, scale_rew)
def make_train_20(stack=True, scale_rew=True):
return make_train(20, stack, scale_rew)
def make_train_21(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_21 | make_train_21 | 222 | 223 | 222 | 222 | 562d332f40433cddf27cf3e55e355c279d6af1b2 | bigcode/the-stack | train |
25c116a1c3af623e1cc7d992 | train | function | def make_train_20(stack=True, scale_rew=True):
return make_train(20, stack, scale_rew)
| def make_train_20(stack=True, scale_rew=True):
| return make_train(20, stack, scale_rew)
| make_train_18(stack=True, scale_rew=True):
return make_train(18, stack, scale_rew)
def make_train_19(stack=True, scale_rew=True):
return make_train(19, stack, scale_rew)
def make_train_20(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_20 | make_train_20 | 219 | 220 | 219 | 219 | e15487093aadb0ab2bf4f761dbc2fdae5454afe4 | bigcode/the-stack | train |
1cd5f7ee169b61df002f8af3 | train | function | def make_train_15(stack=True, scale_rew=True):
return make_train(15, stack, scale_rew)
| def make_train_15(stack=True, scale_rew=True):
| return make_train(15, stack, scale_rew)
| make_train_13(stack=True, scale_rew=True):
return make_train(13, stack, scale_rew)
def make_train_14(stack=True, scale_rew=True):
return make_train(14, stack, scale_rew)
def make_train_15(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_15 | make_train_15 | 204 | 205 | 204 | 204 | 86364878f58e7f716a19ff1da7fe41054fb6e271 | bigcode/the-stack | train |
a6017ce72548fc6ccb2462cf | train | function | def make_train_13(stack=True, scale_rew=True):
return make_train(13, stack, scale_rew)
| def make_train_13(stack=True, scale_rew=True):
| return make_train(13, stack, scale_rew)
| make_train_11(stack=True, scale_rew=True):
return make_train(11, stack, scale_rew)
def make_train_12(stack=True, scale_rew=True):
return make_train(12, stack, scale_rew)
def make_train_13(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_13 | make_train_13 | 198 | 199 | 198 | 198 | 7a568dda12f185c2d1b9515eac03815b5d883b80 | bigcode/the-stack | train |
f5e98373a6867bcca88f8754 | train | function | def make_train_31(stack=True, scale_rew=True):
return make_train(31, stack, scale_rew)
| def make_train_31(stack=True, scale_rew=True):
| return make_train(31, stack, scale_rew)
| make_train_29(stack=True, scale_rew=True):
return make_train(29, stack, scale_rew)
def make_train_30(stack=True, scale_rew=True):
return make_train(30, stack, scale_rew)
def make_train_31(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_31 | make_train_31 | 252 | 253 | 252 | 252 | b747d4aee3231296c3a295b08b5a8fb0325aba60 | bigcode/the-stack | train |
1780e79fdcaa8f4499de7d26 | train | function | def make_train_6(stack=True, scale_rew=True):
return make_train(6, stack, scale_rew)
| def make_train_6(stack=True, scale_rew=True):
| return make_train(6, stack, scale_rew)
| make_train_4(stack=True, scale_rew=True):
return make_train(4, stack, scale_rew)
def make_train_5(stack=True, scale_rew=True):
return make_train(5, stack, scale_rew)
def make_train_6(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_6 | make_train_6 | 177 | 178 | 177 | 177 | 53d1a14365cd441f848038d9766189b22932e2eb | bigcode/the-stack | train |
c7158bbddf6f7f586ecf8741 | train | class | class RewardScaler(gym.RewardWrapper):
"""
Bring rewards to a reasonable scale for PPO.
This is incredibly important and effects performance
drastically.
"""
def reward(self, reward):
return reward * 0.01
| class RewardScaler(gym.RewardWrapper):
| """
Bring rewards to a reasonable scale for PPO.
This is incredibly important and effects performance
drastically.
"""
def reward(self, reward):
return reward * 0.01
| arr[buttons.index(button)] = True
self._actions.append(arr)
self.action_space = gym.spaces.Discrete(len(self._actions))
def action(self, a): # pylint: disable=W0221
return self._actions[a].copy()
class RewardScaler(gym.RewardWrapper):
| 64 | 64 | 51 | 9 | 55 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | RewardScaler | RewardScaler | 47 | 55 | 47 | 47 | 793a569277385456463b1ea8ede21d9f4b89e005 | bigcode/the-stack | train |
fd3b1efe8184992763f34bc1 | train | class | class WarpFrame96(gym.ObservationWrapper):
def __init__(self, env):
"""Warp frames to 96x96."""
gym.ObservationWrapper.__init__(self, env)
self.width = 96
self.height = 96
self.observation_space = gym.spaces.Box(low=0, high=255,
shape=(self.height, self.width, 1),... | class WarpFrame96(gym.ObservationWrapper):
| def __init__(self, env):
"""Warp frames to 96x96."""
gym.ObservationWrapper.__init__(self, env)
self.width = 96
self.height = 96
self.observation_space = gym.spaces.Box(low=0, high=255,
shape=(self.height, self.width, 1), dtype=np.uint8)
def observation(self,... | /bin/env python
import numpy as np
import gym
import gym_remote.client as grc
from retro_contest.local import make
from baselines.common.atari_wrappers import FrameStack
import cv2
cv2.ocl.setUseOpenCL(False)
class WarpFrame96(gym.ObservationWrapper):
| 64 | 64 | 141 | 10 | 54 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | WarpFrame96 | WarpFrame96 | 12 | 24 | 12 | 12 | 072bdbdb3955b73ccf2541dd950967c86ff38990 | bigcode/the-stack | train |
3086627cd7835eeefda8c3a9 | train | function | def make_train_19(stack=True, scale_rew=True):
return make_train(19, stack, scale_rew)
| def make_train_19(stack=True, scale_rew=True):
| return make_train(19, stack, scale_rew)
| make_train_17(stack=True, scale_rew=True):
return make_train(17, stack, scale_rew)
def make_train_18(stack=True, scale_rew=True):
return make_train(18, stack, scale_rew)
def make_train_19(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_19 | make_train_19 | 216 | 217 | 216 | 216 | af7a839dc1f36f3fb089f90f014848f0040749f1 | bigcode/the-stack | train |
91a313093a16428ef4b156e4 | train | function | def make_train_27(stack=True, scale_rew=True):
return make_train(27, stack, scale_rew)
| def make_train_27(stack=True, scale_rew=True):
| return make_train(27, stack, scale_rew)
| make_train_25(stack=True, scale_rew=True):
return make_train(25, stack, scale_rew)
def make_train_26(stack=True, scale_rew=True):
return make_train(26, stack, scale_rew)
def make_train_27(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_27 | make_train_27 | 240 | 241 | 240 | 240 | 419db6c9f4edabf653687ce177fd202e7de933e3 | bigcode/the-stack | train |
96f04798eaf3e1d8e072c1cc | train | class | class AllowBacktracking(gym.Wrapper):
"""
Use deltas in max(X) as the reward, rather than deltas
in X. This way, agents are not discouraged too heavily
from exploring backwards if there is no way to advance
head-on in the level.
"""
def __init__(self, env):
super(AllowBacktracking, s... | class AllowBacktracking(gym.Wrapper):
| """
Use deltas in max(X) as the reward, rather than deltas
in X. This way, agents are not discouraged too heavily
from exploring backwards if there is no way to advance
head-on in the level.
"""
def __init__(self, env):
super(AllowBacktracking, self).__init__(env)
self._cur_x... | return self._actions[a].copy()
class RewardScaler(gym.RewardWrapper):
"""
Bring rewards to a reasonable scale for PPO.
This is incredibly important and effects performance
drastically.
"""
def reward(self, reward):
return reward * 0.01
class AllowBacktracking(gym.Wrapper):
| 68 | 68 | 228 | 9 | 58 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | AllowBacktracking | AllowBacktracking | 57 | 79 | 57 | 57 | 71b9c7b534d5d31407fd5e853983241b8257d2e6 | bigcode/the-stack | train |
35a7810b6a69da277fa7fffe | train | function | def make_train_10(stack=True, scale_rew=True):
return make_train(10, stack, scale_rew)
| def make_train_10(stack=True, scale_rew=True):
| return make_train(10, stack, scale_rew)
| make_train_8(stack=True, scale_rew=True):
return make_train(8, stack, scale_rew)
def make_train_9(stack=True, scale_rew=True):
return make_train(9, stack, scale_rew)
def make_train_10(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_10 | make_train_10 | 189 | 190 | 189 | 189 | 76e62effb4847b6172b7f0d1d0c3fd2e7ff7cd4a | bigcode/the-stack | train |
b411a364a3f7850e675af661 | train | function | def make_train_16(stack=True, scale_rew=True):
return make_train(16, stack, scale_rew)
| def make_train_16(stack=True, scale_rew=True):
| return make_train(16, stack, scale_rew)
| make_train_14(stack=True, scale_rew=True):
return make_train(14, stack, scale_rew)
def make_train_15(stack=True, scale_rew=True):
return make_train(15, stack, scale_rew)
def make_train_16(stack=True, scale_rew=True):
| 64 | 64 | 26 | 13 | 51 | schrum2/SonicDeepRLEvolution | Agents/aborghiPPO/retro_contest_agent-master/metalearner/ppo2ttifrutti_sonic_env_trunc.py | Python | make_train_16 | make_train_16 | 207 | 208 | 207 | 207 | 5a92307513cec18388b5fc0b441393e812b830f6 | bigcode/the-stack | train |
4fe1693ae48636833df5a85b | train | function | def test_fsspec_filesystem(ray_start_regular_shared, tmp_path):
"""Same as `test_parquet_write` but using a custom, fsspec filesystem.
TODO (Alex): We should write a similar test with a mock PyArrow fs, but
unfortunately pa.fs._MockFileSystem isn't serializable, so this may require
some effort.
"""... | def test_fsspec_filesystem(ray_start_regular_shared, tmp_path):
| """Same as `test_parquet_write` but using a custom, fsspec filesystem.
TODO (Alex): We should write a similar test with a mock PyArrow fs, but
unfortunately pa.fs._MockFileSystem isn't serializable, so this may require
some effort.
"""
df1 = pd.DataFrame({"one": [1, 2, 3], "two": ["a", "b", "c"... | Frame({"one": [1, 2, 3], "two": ["a", "b", "c"]})
df2 = pd.DataFrame({"one": [4, 5, 6], "two": ["e", "f", "g"]})
ds = ray.data.from_pandas([df1, df2])
dfds = ds.to_pandas()
assert pd.concat([df1, df2], ignore_index=True).equals(dfds)
def test_fsspec_filesystem(ray_start_regular_shared, tmp_path):
| 116 | 116 | 388 | 15 | 101 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_fsspec_filesystem | test_fsspec_filesystem | 1,323 | 1,357 | 1,323 | 1,323 | a69564fe5555b8b11f7977b33339183743d9d268 | bigcode/the-stack | train |
eb8fa31d0f018819eaae2bd9 | train | function | def test_convert_types(ray_start_regular_shared):
plain_ds = ray.data.range(1)
arrow_ds = plain_ds.map(lambda x: {"a": x})
assert arrow_ds.take() == [{"a": 0}]
assert "ArrowRow" in arrow_ds.map(lambda x: str(type(x))).take()[0]
arrow_ds = ray.data.range_arrow(1)
assert arrow_ds.map(lambda x: "p... | def test_convert_types(ray_start_regular_shared):
| plain_ds = ray.data.range(1)
arrow_ds = plain_ds.map(lambda x: {"a": x})
assert arrow_ds.take() == [{"a": 0}]
assert "ArrowRow" in arrow_ds.map(lambda x: str(type(x))).take()[0]
arrow_ds = ray.data.range_arrow(1)
assert arrow_ds.map(lambda x: "plain_{}".format(x["value"])).take() \
== [... | blocks._num_computed() == 20
def test_limit(ray_start_regular_shared):
ds = ray.data.range(100, parallelism=20)
for i in range(100):
assert ds.limit(i).take(200) == list(range(i))
def test_convert_types(ray_start_regular_shared):
| 64 | 64 | 138 | 9 | 55 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_convert_types | test_convert_types | 1,066 | 1,076 | 1,066 | 1,066 | 6ade01fa05d99dbe87a3b08f92ee4c3ccb855268 | bigcode/the-stack | train |
282c50ac0947763166ccb379 | train | function | def test_from_pandas(ray_start_regular_shared):
df1 = pd.DataFrame({"one": [1, 2, 3], "two": ["a", "b", "c"]})
df2 = pd.DataFrame({"one": [4, 5, 6], "two": ["e", "f", "g"]})
ds = ray.data.from_pandas([df1, df2])
values = [(r["one"], r["two"]) for r in ds.take(6)]
rows = [(r.one, r.two) for _, r in p... | def test_from_pandas(ray_start_regular_shared):
| df1 = pd.DataFrame({"one": [1, 2, 3], "two": ["a", "b", "c"]})
df2 = pd.DataFrame({"one": [4, 5, 6], "two": ["e", "f", "g"]})
ds = ray.data.from_pandas([df1, df2])
values = [(r["one"], r["two"]) for r in ds.take(6)]
rows = [(r.one, r.two) for _, r in pd.concat([df1, df2]).iterrows()]
assert valu... | 10 + [0] * 10
large = ray.data.range_arrow(10000, parallelism=10)
large = large.repartition(20, shuffle=True)
assert large._block_num_rows() == [500] * 20
def test_from_pandas(ray_start_regular_shared):
| 64 | 64 | 205 | 10 | 53 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_from_pandas | test_from_pandas | 1,159 | 1,171 | 1,159 | 1,159 | b175621d49478fbb45782bdbde7c8a18c9cdd810 | bigcode/the-stack | train |
24905a056bf7c70d6b221c96 | train | function | def test_iter_batches_grid(ray_start_regular_shared):
# Tests slicing, batch combining, and partial batch dropping logic over
# a grid of dataset, batching, and dropping configurations.
# Grid: num_blocks x num_rows_block_1 x ... x num_rows_block_N x
# batch_size x drop_last
seed = int(time.ti... | def test_iter_batches_grid(ray_start_regular_shared):
# Tests slicing, batch combining, and partial batch dropping logic over
# a grid of dataset, batching, and dropping configurations.
# Grid: num_blocks x num_rows_block_1 x ... x num_rows_block_N x
# batch_size x drop_last
| seed = int(time.time())
print(f"Seeding RNG for test_iter_batches_grid with: {seed}")
random.seed(seed)
max_num_blocks = 20
max_num_rows_per_block = 20
num_blocks_samples = 3
block_sizes_samples = 3
batch_size_samples = 3
for num_blocks in np.random.randint(
1, max_num_b... | len(df1) + len(df2) + len(df3) + len(df4)) / batch_size))
assert pd.concat(
batches, ignore_index=True).equals(pd.concat(dfs, ignore_index=True))
# Prefetch more than number of blocks.
batches = list(
ds.iter_batches(prefetch_blocks=len(dfs), batch_format="pandas"))
assert len(batches) ... | 183 | 183 | 612 | 68 | 115 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_iter_batches_grid | test_iter_batches_grid | 1,941 | 2,007 | 1,941 | 1,945 | 062838157c83ccf7be2e5e7e29fbc6da4179b982 | bigcode/the-stack | train |
dac9cddb09a14dc906dc0b60 | train | function | def test_schema(ray_start_regular_shared):
ds = ray.data.range(10)
ds2 = ray.data.range_arrow(10)
ds3 = ds2.repartition(5)
ds4 = ds3.map(lambda x: {"a": "hi", "b": 1.0}).limit(5).repartition(1)
assert str(ds) == \
"Dataset(num_blocks=10, num_rows=10, schema=<class 'int'>)"
assert str(ds2... | def test_schema(ray_start_regular_shared):
| ds = ray.data.range(10)
ds2 = ray.data.range_arrow(10)
ds3 = ds2.repartition(5)
ds4 = ds3.map(lambda x: {"a": "hi", "b": 1.0}).limit(5).repartition(1)
assert str(ds) == \
"Dataset(num_blocks=10, num_rows=10, schema=<class 'int'>)"
assert str(ds2) == \
"Dataset(num_blocks=10, num_... | .from_items([])
ds = ds.map(lambda x: x)
assert ds.count() == 0
# Test filter on empty dataset.
ds = ray.data.from_items([])
ds = ds.filter(lambda: True)
assert ds.count() == 0
def test_schema(ray_start_regular_shared):
| 64 | 64 | 189 | 8 | 55 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_schema | test_schema | 1,030 | 1,042 | 1,030 | 1,030 | 56c4736051397f46088bba29e61d7617de8b21d9 | bigcode/the-stack | train |
1f148c0b8b17a48619baf996 | train | function | def maybe_pipeline(ds, enabled):
if enabled:
return ds.window(blocks_per_window=1)
else:
return ds
| def maybe_pipeline(ds, enabled):
| if enabled:
return ds.window(blocks_per_window=1)
else:
return ds
| ource import (
PARALLELIZE_META_FETCH_THRESHOLD)
from ray.data.extensions.tensor_extension import (
TensorArray, TensorDtype, ArrowTensorType, ArrowTensorArray)
import ray.data.tests.util as util
from ray.data.tests.conftest import * # noqa
def maybe_pipeline(ds, enabled):
| 64 | 64 | 29 | 7 | 56 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | maybe_pipeline | maybe_pipeline | 36 | 40 | 36 | 36 | 526dfd99e126e75814f6fa2f25123dfe9e9c050a | bigcode/the-stack | train |
67bcc73eeb3538a04ce6e713 | train | function | def test_parquet_read_partitioned_with_filter(ray_start_regular_shared,
tmp_path):
df = pd.DataFrame({
"one": [1, 1, 1, 3, 3, 3],
"two": ["a", "a", "b", "b", "c", "c"]
})
table = pa.Table.from_pandas(df)
pq.write_to_dataset(
table,
... | def test_parquet_read_partitioned_with_filter(ray_start_regular_shared,
tmp_path):
| df = pd.DataFrame({
"one": [1, 1, 1, 3, 3, 3],
"two": ["a", "a", "b", "b", "c", "c"]
})
table = pa.Table.from_pandas(df)
pq.write_to_dataset(
table,
root_path=str(tmp_path),
partition_cols=["one"],
use_legacy_dataset=False)
# 2 partitions, 1 empty par... | , "f"],
[3, "g"]]
# Test column selection.
ds = ray.data.read_parquet(data_path, columns=["one"], filesystem=fs)
values = [s["one"] for s in ds.take()]
assert sorted(values) == [1, 1, 1, 3, 3, 3]
def test_parquet_read_partitioned_with_filter(ray_start_regular_shared,
... | 93 | 93 | 313 | 18 | 75 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_parquet_read_partitioned_with_filter | test_parquet_read_partitioned_with_filter | 1,460 | 1,489 | 1,460 | 1,461 | 9cbb331cfadf052db89b5921c0ce49fc537c6a13 | bigcode/the-stack | train |
1aab6f85ce4290bef8569beb | train | function | @pytest.mark.parametrize("pipelined", [False, True])
def test_random_shuffle(shutdown_only, pipelined):
def range(n, parallelism=200):
ds = ray.data.range(n, parallelism=parallelism)
if pipelined:
pipe = ds.repeat(2)
pipe.random_shuffle = pipe.random_shuffle_each_window
... | @pytest.mark.parametrize("pipelined", [False, True])
def test_random_shuffle(shutdown_only, pipelined):
| def range(n, parallelism=200):
ds = ray.data.range(n, parallelism=parallelism)
if pipelined:
pipe = ds.repeat(2)
pipe.random_shuffle = pipe.random_shuffle_each_window
return pipe
else:
return ds
r1 = range(100).random_shuffle().take(999)
... | num_items = 100
parallelism = 4
xs = list(range(num_items))
random.shuffle(xs)
ds = ray.data.from_items(xs, parallelism=parallelism)
assert ds.sort().take(num_items) == list(range(num_items))
assert ds.sort(descending=True).take(num_items) == list(
reversed(range(num_items)))
assert... | 193 | 193 | 645 | 25 | 167 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_random_shuffle | test_random_shuffle | 3,633 | 3,689 | 3,633 | 3,634 | 928afe394034b25e4260dde4601c891ac36c75bd | bigcode/the-stack | train |
427444d17ef485c9cde24b58 | train | function | def test_transform_failure(shutdown_only):
ray.init(num_cpus=2)
ds = ray.data.from_items([0, 10], parallelism=2)
def mapper(x):
time.sleep(x)
raise ValueError("oops")
return x
with pytest.raises(ray.exceptions.RayTaskError):
ds.map(mapper)
| def test_transform_failure(shutdown_only):
| ray.init(num_cpus=2)
ds = ray.data.from_items([0, 10], parallelism=2)
def mapper(x):
time.sleep(x)
raise ValueError("oops")
return x
with pytest.raises(ray.exceptions.RayTaskError):
ds.map(mapper)
| fulFn, compute="tasks").take()
assert len(task_reuse) == 9, task_reuse
actor_reuse = ds.filter(StatefulFn, compute="actors").take()
assert len(actor_reuse) == 10, actor_reuse
def test_transform_failure(shutdown_only):
| 64 | 64 | 73 | 8 | 55 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_transform_failure | test_transform_failure | 187 | 197 | 187 | 187 | 36dd69aa161f630e45f7ea066bbd711a59e5bfd3 | bigcode/the-stack | train |
9b4214ed8b112e441e0fc479 | train | function | @pytest.mark.parametrize("fs,data_path,endpoint_url", [
(None, lazy_fixture("local_path"), None),
(lazy_fixture("local_fs"), lazy_fixture("local_path"), None),
(lazy_fixture("s3_fs"), lazy_fixture("s3_path"), lazy_fixture("s3_server"))
])
def test_numpy_write(ray_start_regular_shared, fs, data_path, endpoin... | @pytest.mark.parametrize("fs,data_path,endpoint_url", [
(None, lazy_fixture("local_path"), None),
(lazy_fixture("local_fs"), lazy_fixture("local_path"), None),
(lazy_fixture("s3_fs"), lazy_fixture("s3_path"), lazy_fixture("s3_server"))
])
def test_numpy_write(ray_start_regular_shared, fs, data_path, endpoin... | ds = ray.data.range_tensor(10, parallelism=2)
ds._set_uuid("data")
ds.write_numpy(data_path, filesystem=fs)
file_path1 = os.path.join(data_path, "data_000000.npy")
file_path2 = os.path.join(data_path, "data_000001.npy")
if endpoint_url is None:
arr1 = np.load(file_path1)
arr2 = n... | }, {'value': array([1])}]"
@pytest.mark.parametrize("fs,data_path,endpoint_url", [
(None, lazy_fixture("local_path"), None),
(lazy_fixture("local_fs"), lazy_fixture("local_path"), None),
(lazy_fixture("s3_fs"), lazy_fixture("s3_path"), lazy_fixture("s3_server"))
])
def test_numpy_write(ray_start_regular_sha... | 91 | 91 | 304 | 81 | 10 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_numpy_write | test_numpy_write | 912 | 936 | 912 | 917 | 9a3ae5b27753ccb090d46d34702805734ef8dbcc | bigcode/the-stack | train |
94b31296ed70127004992604 | train | function | def test_pandas_roundtrip(ray_start_regular_shared, tmp_path):
df1 = pd.DataFrame({"one": [1, 2, 3], "two": ["a", "b", "c"]})
df2 = pd.DataFrame({"one": [4, 5, 6], "two": ["e", "f", "g"]})
ds = ray.data.from_pandas([df1, df2])
dfds = ds.to_pandas()
assert pd.concat([df1, df2], ignore_index=True).equ... | def test_pandas_roundtrip(ray_start_regular_shared, tmp_path):
| df1 = pd.DataFrame({"one": [1, 2, 3], "two": ["a", "b", "c"]})
df2 = pd.DataFrame({"one": [4, 5, 6], "two": ["e", "f", "g"]})
ds = ray.data.from_pandas([df1, df2])
dfds = ds.to_pandas()
assert pd.concat([df1, df2], ignore_index=True).equals(dfds)
| (blocks) == 10
out = []
for b in ray.get(blocks):
out.extend(list(BlockAccessor.for_block(b).iter_rows()))
out = sorted(out)
assert out == list(range(10)), out
def test_pandas_roundtrip(ray_start_regular_shared, tmp_path):
| 64 | 64 | 121 | 14 | 49 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_pandas_roundtrip | test_pandas_roundtrip | 1,315 | 1,320 | 1,315 | 1,315 | 7816176a52c3a697d13b92e1670ee2102b7967b3 | bigcode/the-stack | train |
17b814cac7f664b30688b8f5 | train | function | def test_tensors_in_tables_from_pandas(ray_start_regular_shared):
outer_dim = 3
inner_shape = (2, 2, 2)
shape = (outer_dim, ) + inner_shape
num_items = np.prod(np.array(shape))
arr = np.arange(num_items).reshape(shape)
df = pd.DataFrame({"one": list(range(outer_dim)), "two": list(arr)})
# Ca... | def test_tensors_in_tables_from_pandas(ray_start_regular_shared):
| outer_dim = 3
inner_shape = (2, 2, 2)
shape = (outer_dim, ) + inner_shape
num_items = np.prod(np.array(shape))
arr = np.arange(num_items).reshape(shape)
df = pd.DataFrame({"one": list(range(outer_dim)), "two": list(arr)})
# Cast column to tensor extension dtype.
df["two"] = df["two"].ast... | 1], arr[1])
slice2 = ata.slice(2, 2)
np.testing.assert_array_equal(slice2.to_numpy(), arr[2:4])
np.testing.assert_array_equal(slice2[1], arr[3])
def test_tensors_in_tables_from_pandas(ray_start_regular_shared):
| 64 | 64 | 176 | 14 | 50 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_tensors_in_tables_from_pandas | test_tensors_in_tables_from_pandas | 552 | 565 | 552 | 552 | 27b4510fe3d7bcf73290215ebd268909cf324326 | bigcode/the-stack | train |
6b6c97920b9da398807d5929 | train | function | @pytest.mark.skip(
reason=("Waiting for Arrow to support registering custom ExtensionType "
"casting kernels. See "
"https://issues.apache.org/jira/browse/ARROW-5890#"))
def test_tensors_in_tables_parquet_bytes_with_schema(ray_start_regular_shared,
... | @pytest.mark.skip(
reason=("Waiting for Arrow to support registering custom ExtensionType "
"casting kernels. See "
"https://issues.apache.org/jira/browse/ARROW-5890#"))
def test_tensors_in_tables_parquet_bytes_with_schema(ray_start_regular_shared,
... | outer_dim = 3
inner_shape = (2, 2, 2)
shape = (outer_dim, ) + inner_shape
num_items = np.prod(np.array(shape))
arr = np.arange(num_items).reshape(shape)
df = pd.DataFrame({
"one": list(range(outer_dim)),
"two": [a.tobytes() for a in arr]
})
ds = ray.data.from_pandas([df])... | , e in zip(sorted(values), expected):
np.testing.assert_equal(v, e)
@pytest.mark.skip(
reason=("Waiting for Arrow to support registering custom ExtensionType "
"casting kernels. See "
"https://issues.apache.org/jira/browse/ARROW-5890#"))
def test_tensors_in_tables_parquet_bytes_with_... | 81 | 81 | 271 | 63 | 18 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_tensors_in_tables_parquet_bytes_with_schema | test_tensors_in_tables_parquet_bytes_with_schema | 774 | 799 | 774 | 779 | 2656723805554a1ae8d07ba73d786b5ec4c59b0f | bigcode/the-stack | train |
643f904b245aa947d3c42a9f | train | function | def test_arrow_block_slice_copy():
# Test that ArrowBlock slicing properly copies the underlying Arrow
# table.
def check_for_copy(table1, table2, a, b, is_copy):
expected_slice = table1.slice(a, b - a)
assert table2.equals(expected_slice)
assert table2.schema == table1.schema
... | def test_arrow_block_slice_copy():
# Test that ArrowBlock slicing properly copies the underlying Arrow
# table.
| def check_for_copy(table1, table2, a, b, is_copy):
expected_slice = table1.slice(a, b - a)
assert table2.equals(expected_slice)
assert table2.schema == table1.schema
assert table1.num_columns == table2.num_columns
for col1, col2 in zip(table1.columns, table2.columns):
... | in range(40)])
res = ("Dataset(num_blocks=40, num_rows=40, "
"schema=<class 'torch.Tensor'>)")
assert str(ds) == res, str(ds)
with pytest.raises(pa.lib.ArrowInvalid):
next(ds.iter_batches(batch_format="pyarrow"))
df = next(ds.iter_batches(batch_format="pandas"))
assert df.to_dict... | 115 | 115 | 386 | 24 | 91 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_arrow_block_slice_copy | test_arrow_block_slice_copy | 335 | 372 | 335 | 337 | a883f139d8a4eda0bcd895a0e2c582b07dfb18a1 | bigcode/the-stack | train |
5a09afa3637d48ad32ccd664 | train | function | def test_lazy_loading_iter_batches_exponential_rampup(
ray_start_regular_shared):
ds = ray.data.range(32, parallelism=8)
expected_num_blocks = [1, 2, 4, 4, 8, 8, 8, 8]
for _, expected in zip(ds.iter_batches(), expected_num_blocks):
assert ds._blocks._num_computed() == expected
| def test_lazy_loading_iter_batches_exponential_rampup(
ray_start_regular_shared):
| ds = ray.data.range(32, parallelism=8)
expected_num_blocks = [1, 2, 4, 4, 8, 8, 8, 8]
for _, expected in zip(ds.iter_batches(), expected_num_blocks):
assert ds._blocks._num_computed() == expected
| (batch) == batch_size for batch in batches)
else:
assert all(
len(batch) == batch_size for batch in batches[:-1])
assert len(batches[-1]) == num_rows % batch_size
def test_lazy_loading_iter_batches_exponential_rampup(
... | 64 | 64 | 88 | 18 | 45 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_lazy_loading_iter_batches_exponential_rampup | test_lazy_loading_iter_batches_exponential_rampup | 2,010 | 2,015 | 2,010 | 2,011 | fd38ed9a9a7cc2c0c71bb3fd84128c797e6b7a08 | bigcode/the-stack | train |
b9df971fc3cffb8c03807b04 | train | function | def test_sliding_window():
arr = list(range(10))
# Test all windows over this iterable.
window_sizes = list(range(1, len(arr) + 1))
for window_size in window_sizes:
windows = list(_sliding_window(arr, window_size))
assert len(windows) == len(arr) - window_size + 1
assert all(len... | def test_sliding_window():
| arr = list(range(10))
# Test all windows over this iterable.
window_sizes = list(range(1, len(arr) + 1))
for window_size in window_sizes:
windows = list(_sliding_window(arr, window_size))
assert len(windows) == len(arr) - window_size + 1
assert all(len(window) == window_size for... | anyscale-data/small-files/0.dat"])
item = ds.take(1).pop()
expected = requests.get(
"https://anyscale-data.s3.us-west-2.amazonaws.com/small-files/0.dat"
).content
assert item == expected
def test_sliding_window():
| 64 | 64 | 161 | 6 | 57 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_sliding_window | test_sliding_window | 1,829 | 1,845 | 1,829 | 1,829 | 6969dc4bfbae1c65c084a358c50b13fdf2494380 | bigcode/the-stack | train |
89569ae05960c69d8d8f44e8 | train | function | @pytest.mark.parametrize("num_parts", [1, 15, 100])
def test_groupby_agg_name_conflict(ray_start_regular_shared, num_parts):
# Test aggregation name conflict.
xs = list(range(100))
grouped_ds = ray.data.from_items([{
"A": (x % 3),
"B": x
} for x in xs]).repartition(num_parts).groupby("A"... | @pytest.mark.parametrize("num_parts", [1, 15, 100])
def test_groupby_agg_name_conflict(ray_start_regular_shared, num_parts):
# Test aggregation name conflict.
| xs = list(range(100))
grouped_ds = ray.data.from_items([{
"A": (x % 3),
"B": x
} for x in xs]).repartition(num_parts).groupby("A")
agg_ds = grouped_ds.aggregate(
AggregateFn(
init=lambda k: [0, 0],
accumulate=lambda a, r: [a[0] + r["B"], a[1] + 1],
... | _path2, storage_options=storage_options)
])
assert df.equals(ds_df)
def test_groupby_arrow(ray_start_regular_shared):
# Test empty dataset.
agg_ds = ray.data.range_arrow(10).filter(
lambda r: r["value"] > 10).groupby("value").count()
assert agg_ds.count() == 0
@pytest.mark.parametrize("num... | 116 | 116 | 389 | 40 | 75 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_groupby_agg_name_conflict | test_groupby_agg_name_conflict | 3,039 | 3,064 | 3,039 | 3,041 | d8edfe885585f546b7756830aa936201ae74abf9 | bigcode/the-stack | train |
2ff2c080b2b3def539d2d64b | train | function | @pytest.mark.parametrize("fs,data_path,endpoint_url", [
(None, lazy_fixture("local_path"), None),
(lazy_fixture("local_fs"), lazy_fixture("local_path"), None),
(lazy_fixture("s3_fs"), lazy_fixture("s3_path"), lazy_fixture("s3_server"))
])
def test_csv_write_block_path_provider(ray_start_regular_shared, fs, ... | @pytest.mark.parametrize("fs,data_path,endpoint_url", [
(None, lazy_fixture("local_path"), None),
(lazy_fixture("local_fs"), lazy_fixture("local_path"), None),
(lazy_fixture("s3_fs"), lazy_fixture("s3_path"), lazy_fixture("s3_server"))
])
def test_csv_write_block_path_provider(ray_start_regular_shared, fs, ... | if endpoint_url is None:
storage_options = {}
else:
storage_options = dict(client_kwargs=dict(endpoint_url=endpoint_url))
# Single block.
df1 = pd.DataFrame({"one": [1, 2, 3], "two": ["a", "b", "c"]})
ds = ray.data.from_pandas([df1])
ds._set_uuid("data")
ds.write_csv(
... | in ds2._blocks.get_blocks_with_metadata():
BlockAccessor.for_block(ray.get(block)).size_bytes() == meta.size_bytes
@pytest.mark.parametrize("fs,data_path,endpoint_url", [
(None, lazy_fixture("local_path"), None),
(lazy_fixture("local_fs"), lazy_fixture("local_path"), None),
(lazy_fixture("s3_fs"), ... | 119 | 119 | 397 | 92 | 26 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_csv_write_block_path_provider | test_csv_write_block_path_provider | 2,991 | 3,029 | 2,991 | 2,998 | 5dc26493894fa08318b174a6577f1e9b96c98d2c | bigcode/the-stack | train |
05261c9f92c7db518e2e7630 | train | function | @pytest.mark.parametrize(
"fs,data_path", [(None, lazy_fixture("local_path")),
(lazy_fixture("local_fs"), lazy_fixture("local_path")),
(lazy_fixture("s3_fs"), lazy_fixture("s3_path"))])
def test_json_roundtrip(ray_start_regular_shared, fs, data_path):
# Single block.
... | @pytest.mark.parametrize(
"fs,data_path", [(None, lazy_fixture("local_path")),
(lazy_fixture("local_fs"), lazy_fixture("local_path")),
(lazy_fixture("s3_fs"), lazy_fixture("s3_path"))])
def test_json_roundtrip(ray_start_regular_shared, fs, data_path):
# Single block.
| df = pd.DataFrame({"one": [1, 2, 3], "two": ["a", "b", "c"]})
ds = ray.data.from_pandas([df])
ds._set_uuid("data")
ds.write_json(data_path, filesystem=fs)
file_path = os.path.join(data_path, "data_000000.json")
ds2 = ray.data.read_json([file_path], filesystem=fs)
ds2df = ds2.to_pandas()
... | orient="records",
lines=True,
storage_options=storage_options),
pd.read_json(
file_path2,
orient="records",
lines=True,
storage_options=storage_options)
])
assert df.equals(ds_df)
@pytest.mark.parametrize(
"fs,data_p... | 121 | 121 | 404 | 70 | 51 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_json_roundtrip | test_json_roundtrip | 2,720 | 2,753 | 2,720 | 2,725 | e9b5222e0e2af7299bbd6661717a45b61a9650e7 | bigcode/the-stack | train |
653c4929d7a95ae458cd7445 | train | function | @pytest.mark.parametrize("num_parts", [1, 15, 100])
def test_groupby_arrow_sum(ray_start_regular_shared, num_parts):
# Test built-in sum aggregation
seed = int(time.time())
print(f"Seeding RNG for test_groupby_arrow_sum with: {seed}")
random.seed(seed)
xs = list(range(100))
random.shuffle(xs)
... | @pytest.mark.parametrize("num_parts", [1, 15, 100])
def test_groupby_arrow_sum(ray_start_regular_shared, num_parts):
# Test built-in sum aggregation
| seed = int(time.time())
print(f"Seeding RNG for test_groupby_arrow_sum with: {seed}")
random.seed(seed)
xs = list(range(100))
random.shuffle(xs)
agg_ds = ray.data.from_items([{
"A": (x % 3),
"B": x
} for x in xs]).repartition(num_parts).groupby("A").sum("B")
assert agg_ds... | _rows()] == \
[{"A": 0, "count()": 34}, {"A": 1, "count()": 33},
{"A": 2, "count()": 33}]
@pytest.mark.parametrize("num_parts", [1, 15, 100])
def test_groupby_arrow_sum(ray_start_regular_shared, num_parts):
# Test built-in sum aggregation
| 83 | 84 | 280 | 38 | 45 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_groupby_arrow_sum | test_groupby_arrow_sum | 3,085 | 3,106 | 3,085 | 3,087 | 8aba7098b3bd6156a1e07e89ff8554b966d1f9e8 | bigcode/the-stack | train |
3769eaf9dde69363c8918c0f | train | function | @pytest.mark.parametrize("num_items,parallelism", [(100, 1), (1000, 4)])
def test_sort_arrow(ray_start_regular, num_items, parallelism):
a = list(reversed(range(num_items)))
b = [f"{x:03}" for x in range(num_items)]
shard = int(np.ceil(num_items / parallelism))
offset = 0
dfs = []
while offset <... | @pytest.mark.parametrize("num_items,parallelism", [(100, 1), (1000, 4)])
def test_sort_arrow(ray_start_regular, num_items, parallelism):
| a = list(reversed(range(num_items)))
b = [f"{x:03}" for x in range(num_items)]
shard = int(np.ceil(num_items / parallelism))
offset = 0
dfs = []
while offset < num_items:
dfs.append(
pd.DataFrame({
"a": a[offset:offset + shard],
"b": b[offset:o... | .experimental.get_object_locations(blocks)
locations = []
for block in blocks:
locations.extend(location_data[block]["node_ids"])
assert set(locations) == {node1_id, node2_id}
@pytest.mark.parametrize("num_items,parallelism", [(100, 1), (1000, 4)])
def test_sort_arrow(ray_start_regular, num_items, p... | 81 | 81 | 272 | 37 | 44 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_sort_arrow | test_sort_arrow | 3,764 | 3,790 | 3,764 | 3,765 | 7efa229b2033b8883dd42127b89c49a566740f0c | bigcode/the-stack | train |
8655453117be8fa0271a0df6 | train | function | def test_union(ray_start_regular_shared):
ds = ray.data.range(20, parallelism=10)
# Test lazy union.
ds = ds.union(ds, ds, ds, ds)
assert ds.num_blocks() == 50
assert ds.count() == 100
assert ds.sum() == 950
ds = ds.union(ds)
assert ds.count() == 200
assert ds.sum() == (950 * 2)
... | def test_union(ray_start_regular_shared):
| ds = ray.data.range(20, parallelism=10)
# Test lazy union.
ds = ds.union(ds, ds, ds, ds)
assert ds.num_blocks() == 50
assert ds.count() == 100
assert ds.sum() == 950
ds = ds.union(ds)
assert ds.count() == 200
assert ds.sum() == (950 * 2)
# Test materialized union.
ds2 = ra... | Test the wrong return value raises an exception.
ds = ray.data.read_parquet(str(tmp_path))
with pytest.raises(ValueError):
ds_list = ds.map_batches(
lambda df: 1, batch_size=2, batch_format="pyarrow").take()
def test_union(ray_start_regular_shared):
| 64 | 64 | 176 | 8 | 56 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_union | test_union | 2,080 | 2,099 | 2,080 | 2,080 | 5432226cb4275ae503294421ba0e8c68919194d3 | bigcode/the-stack | train |
94fd691884411691b6206e92 | train | function | def test_map_batch(ray_start_regular_shared, tmp_path):
# Test input validation
ds = ray.data.range(5)
with pytest.raises(ValueError):
ds.map_batches(
lambda x: x + 1, batch_format="pyarrow", batch_size=-1).take()
# Test pandas
df = pd.DataFrame({"one": [1, 2, 3], "two": [2, 3, ... | def test_map_batch(ray_start_regular_shared, tmp_path):
# Test input validation
| ds = ray.data.range(5)
with pytest.raises(ValueError):
ds.map_batches(
lambda x: x + 1, batch_format="pyarrow", batch_size=-1).take()
# Test pandas
df = pd.DataFrame({"one": [1, 2, 3], "two": [2, 3, 4]})
table = pa.Table.from_pandas(df)
pq.write_table(table, os.path.join(tmp... | ).equals(
ds.to_pandas()[:batch_size *
(num_rows // batch_size)])
if num_rows % batch_size == 0 or drop_last:
assert all(
len(batch) == batch_size for batch in batches)
... | 193 | 193 | 646 | 18 | 174 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_map_batch | test_map_batch | 2,018 | 2,077 | 2,018 | 2,019 | e112fb4da6f5ff84679fa1b24e17e387a7639aad | bigcode/the-stack | train |
808432c60d00c3662670d878 | train | function | @pytest.mark.parametrize("num_parts", [1, 15, 100])
def test_groupby_simple_min(ray_start_regular_shared, num_parts):
# Test built-in min aggregation
seed = int(time.time())
print(f"Seeding RNG for test_groupby_simple_min with: {seed}")
random.seed(seed)
xs = list(range(100))
random.shuffle(xs)
... | @pytest.mark.parametrize("num_parts", [1, 15, 100])
def test_groupby_simple_min(ray_start_regular_shared, num_parts):
# Test built-in min aggregation
| seed = int(time.time())
print(f"Seeding RNG for test_groupby_simple_min with: {seed}")
random.seed(seed)
xs = list(range(100))
random.shuffle(xs)
agg_ds = ray.data.from_items(xs).repartition(num_parts).groupby(
lambda x: x % 3).min()
assert agg_ds.count() == 3
assert agg_ds.sort(... | 4950
assert ray.data.range(10).filter(lambda r: r > 10).sum() == 0
@pytest.mark.parametrize("num_parts", [1, 15, 100])
def test_groupby_simple_min(ray_start_regular_shared, num_parts):
# Test built-in min aggregation
| 64 | 64 | 209 | 38 | 25 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_groupby_simple_min | test_groupby_simple_min | 3,429 | 3,444 | 3,429 | 3,431 | 8148cfb6faa1177785d7a090121f53f4e5fb7b7f | bigcode/the-stack | train |
bb6d51f30caefb6cc54b17a9 | train | function | def test_lazy_loading_exponential_rampup(ray_start_regular_shared):
ds = ray.data.range(100, parallelism=20)
assert ds._blocks._num_computed() == 1
assert ds.take(10) == list(range(10))
assert ds._blocks._num_computed() == 2
assert ds.take(20) == list(range(20))
assert ds._blocks._num_computed()... | def test_lazy_loading_exponential_rampup(ray_start_regular_shared):
| ds = ray.data.range(100, parallelism=20)
assert ds._blocks._num_computed() == 1
assert ds.take(10) == list(range(10))
assert ds._blocks._num_computed() == 2
assert ds.take(20) == list(range(20))
assert ds._blocks._num_computed() == 4
assert ds.take(30) == list(range(30))
assert ds._block... | (num_blocks=5, num_rows=10, schema={value: int64})"
assert str(ds4) == \
"Dataset(num_blocks=1, num_rows=5, schema={a: string, b: double})"
def test_lazy_loading_exponential_rampup(ray_start_regular_shared):
| 64 | 64 | 177 | 14 | 50 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_lazy_loading_exponential_rampup | test_lazy_loading_exponential_rampup | 1,045 | 1,057 | 1,045 | 1,045 | 453c1a38622cbc31ec05c34f41ead847f2899a56 | bigcode/the-stack | train |
1f09c4423d0228c7023cb1a8 | train | function | def test_from_numpy(ray_start_regular_shared):
arr1 = np.expand_dims(np.arange(0, 4), axis=1)
arr2 = np.expand_dims(np.arange(4, 8), axis=1)
ds = ray.data.from_numpy([ray.put(arr1), ray.put(arr2)])
values = np.array(ds.take(8))
np.testing.assert_array_equal(
values, np.expand_dims(np.concate... | def test_from_numpy(ray_start_regular_shared):
| arr1 = np.expand_dims(np.arange(0, 4), axis=1)
arr2 = np.expand_dims(np.arange(4, 8), axis=1)
ds = ray.data.from_numpy([ray.put(arr1), ray.put(arr2)])
values = np.array(ds.take(8))
np.testing.assert_array_equal(
values, np.expand_dims(np.concatenate((arr1, arr2)), axis=1))
| .data.from_pandas_refs(ray.put(df1))
values = [(r["one"], r["two"]) for r in ds.take(3)]
rows = [(r.one, r.two) for _, r in df1.iterrows()]
assert values == rows
def test_from_numpy(ray_start_regular_shared):
| 64 | 64 | 101 | 9 | 54 | spillai/ray | python/ray/data/tests/test_dataset.py | Python | test_from_numpy | test_from_numpy | 1,189 | 1,195 | 1,189 | 1,189 | e2b493917606018cff17959ffab3ed2a0ade5bde | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.