crossfile_context_retrievalwref dict | prompt stringlengths 252 32.6k | right_context stringlengths 0 81.2k | metadata dict | crossfile_context_retrieval dict | groundtruth stringlengths 5 208 |
|---|---|---|---|---|---|
{
"list": [
{
"filename": "experiments/test_parallelism.py",
"retrieved_chunk": " hyponic = HypONIC(model, X, y, mse, **optimizer_kwargs)\n start = time.time()\n hyponic.optimize(hyperparams)\n end = time.time()\n times[i] = end - start\n print(f\"\\rIteration... | from abc import ABC, abstractmethod
import numpy as np
from concurrent.futures import ThreadPoolExecutor, as_completed
from hyponic.utils.history import History
import time
class BaseOptimizer(ABC):
"""
Base class for all optimizers. All optimizers should inherit from this class
"""
def __init__(self... |
if self.verbose:
print(f'Early stopping at epoch {current_epoch}')
break
return self.get_best_solution(), self.get_best_score()
def get_history(self):
"""
Get the history of the optimizer
"""
return self.history.get_histor... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/base_optimizer.py",
"groundtruth_start_lineno": 202,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 203,
"task_id": "project_cc_python/7432"
} | {
"list": [
{
"filename": "experiments/test_parallelism.py",
"retrieved_chunk": " \"epoch\": 100,\n \"pop_size\": 200,\n \"mode\": \"single\"\n }\n print(\"Single thread, KNN regression: \", run(optimizer_kwargs, give_test_set1(), num_iter=10))\n print(\"Single thread, De... | is_early_stopping(current_epoch, self.early_stopping): |
{
"list": [
{
"filename": "src/autogpt_plugins/email/email_plugin/test_email_plugin.py",
"retrieved_chunk": " @patch(\"imaplib.IMAP4_SSL\")\n @patch.dict(\n os.environ,\n {\n \"EMAIL_ADDRESS\": MOCK_FROM,\n \"EMAIL_PASSWORD\": MOCK_PWD,\n \"EMAIL_IM... | import email
import imaplib
import json
import mimetypes
import os
import re
import smtplib
import time
from email.header import decode_header
from email.message import EmailMessage
from bs4 import BeautifulSoup
def bothEmailAndPwdSet() -> bool:
return True if os.getenv("EMAIL_ADDRESS") and os.getenv("EMAIL_PASS... |
if msg.is_multipart():
for part in msg.walk():
content_type = part.get_content_type()
content_disposition = str(part.get("Content-Disposition"))
if content_type == "text/plain" and "attachment" not in content_disposition:
# If the email body has unknown e... | {
"context_start_lineno": 0,
"file": "src/autogpt_plugins/email/email_plugin/email_plugin.py",
"groundtruth_start_lineno": 243,
"repository": "Significant-Gravitas-Auto-GPT-Plugins-3975893",
"right_context_start_lineno": 244,
"task_id": "project_cc_python/7361"
} | {
"list": [
{
"filename": "src/autogpt_plugins/email/email_plugin/test_email_plugin.py",
"retrieved_chunk": " os.environ,\n {\n \"EMAIL_ADDRESS\": MOCK_FROM,\n \"EMAIL_PASSWORD\": MOCK_PWD,\n \"EMAIL_SMTP_HOST\": MOCK_SMTP_SERVER,\n \"EMAIL_SMT... | message.Message) -> str: |
{
"list": [
{
"filename": "experiments/test_parallelism.py",
"retrieved_chunk": " \"algorithm\": [\"auto\", \"ball_tree\", \"kd_tree\", \"brute\"],\n \"leaf_size\": [i for i in range(1, 50)],\n \"p\": (1, 2)\n }\n return X, y, model, hyperparams\ndef give_test_set2():\n X... | from warnings import warn
from hyponic.optimizers.swarm_based.PSO import IWPSO
from hyponic.metrics.decorators import METRICS_DICT
from hyponic.utils.problem_identifier import ProblemIdentifier, ProblemType
from hyponic import config
from typing import Callable
from hyponic.space import Space
from functools import p... |
print(self.model.__class__)
if hyperparams is None:
hyperparams = models_config.get(str(self.model.__class__), dict())
# Create a space for hyperparameters
hyperspace = Space(hyperparams)
if verbose:
print("Successfully created a space for hyperparameter... | {
"context_start_lineno": 0,
"file": "hyponic/hyponic.py",
"groundtruth_start_lineno": 96,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 97,
"task_id": "project_cc_python/7428"
} | {
"list": [
{
"filename": "hyponic/space.py",
"retrieved_chunk": " if len(self.dimensions) == 0:\n return \"Hyperparameter Search Space is empty.\"\n # Pretty table of dimensions\n dim_names = list(self.dimensions.keys())\n offset = max([len(k) for k in dim_names... | sklearn_models.models_dict) -> (dict, float): |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ABC.py",
"retrieved_chunk": " self.g_best = self.fitness[best_index]\n self.g_best_coords = self.coords[best_index]\n def get_best_score(self):\n return self.g_best\n def get_best_solution(self):\n return self.... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class GWO(BaseOptimizer):
"""
Grey Wolf Optimization (GWO) algorithm
Example
~~~~~~~
>>> from hyponic.optimizers.swarm_based.GWO import GWO
>>> import numpy as np
>>>
>>> def sphere(x)... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/GWO.py",
"groundtruth_start_lineno": 93,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 94,
"task_id": "project_cc_python/7441"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ABC.py",
"retrieved_chunk": " return self.coords[best_index]",
"score": 81.97966842993019
},
{
"filename": "hyponic/optimizers/swarm_based/PSO.py",
"retrieved_chunk": " return self.g_best\n def get_bes... | _argminmax()(self.fitness)] | |
{
"list": [
{
"filename": "experiments/test_parallelism.py",
"retrieved_chunk": " hyponic = HypONIC(model, X, y, mse, **optimizer_kwargs)\n start = time.time()\n hyponic.optimize(hyperparams)\n end = time.time()\n times[i] = end - start\n print(f\"\\rIteration... | from abc import ABC, abstractmethod
import numpy as np
from concurrent.futures import ThreadPoolExecutor, as_completed
from hyponic.utils.history import History
import time
class BaseOptimizer(ABC):
"""
Base class for all optimizers. All optimizers should inherit from this class
"""
def __init__(self... |
if self.history.is_early_stopping(current_epoch, self.early_stopping):
if self.verbose:
print(f'Early stopping at epoch {current_epoch}')
break
return self.get_best_solution(), self.get_best_score()
def get_history(self):
"""
... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/base_optimizer.py",
"groundtruth_start_lineno": 201,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 202,
"task_id": "project_cc_python/7431"
} | {
"list": [
{
"filename": "experiments/test_parallelism.py",
"retrieved_chunk": " \"epoch\": 100,\n \"pop_size\": 200,\n \"mode\": \"single\"\n }\n print(\"Single thread, KNN regression: \", run(optimizer_kwargs, give_test_set1(), num_iter=10))\n print(\"Single thread, De... | update_history(current_epoch, end - start) |
{
"list": [
{
"filename": "hyponic/utils/history.py",
"retrieved_chunk": " \"\"\"\n self.global_best_list[epoch] = self.optimizer.get_best_solution()\n self.global_best_fitness_list[epoch] = self.optimizer.get_best_score()\n self.current_best_list[epoch] = self.optimizer.ge... | from abc import ABC, abstractmethod
import numpy as np
from concurrent.futures import ThreadPoolExecutor, as_completed
from hyponic.utils.history import History
import time
class BaseOptimizer(ABC):
"""
Base class for all optimizers. All optimizers should inherit from this class
"""
def __init__(self... |
def visualize_history_time(self):
"""
Visualize the time history
"""
self.history.visualize_time()
| {
"context_start_lineno": 0,
"file": "hyponic/optimizers/base_optimizer.py",
"groundtruth_start_lineno": 218,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 219,
"task_id": "project_cc_python/7434"
} | {
"list": [
{
"filename": "hyponic/utils/history.py",
"retrieved_chunk": " return {\n 'global_best_list': self.global_best_list,\n 'global_best_fitness_list': self.global_best_fitness_list,\n 'current_best_list': self.current_best_list,\n 'current_bes... | visualize_fitness() |
{
"list": [
{
"filename": "hyponic/optimizers/genetic_based/GA.py",
"retrieved_chunk": " self.best_solution = None\n def initialize(self, problem_dict):\n super().initialize(problem_dict)\n self.population = np.random.uniform(low=self.lb, high=self.ub, size=(self.population_siz... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
class ACO(BaseOptimizer):
"""
Ant Colony Optimization (ACO)
Hyperparameters:
+ alpha(float), default=1: the importance of pheromone
+ beta(float), default=1: the importance of heuristic information
+ r... |
self.best_score = self.scores[i]
self.best_solution = self.population[i]
def evolve(self, epoch):
new_population = np.zeros((self.population_size, self.dimensions))
new_scores = np.zeros(self.population_size)
for i in range(self.population_size):
... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/ACO.py",
"groundtruth_start_lineno": 100,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 101,
"task_id": "project_cc_python/7448"
} | {
"list": [
{
"filename": "hyponic/optimizers/genetic_based/GA.py",
"retrieved_chunk": " next_scores = np.zeros(self.population_size)\n # Elitism: keep the best solution from the previous generation\n best_idx = self._argminmax()(self.scores)\n next_population[0] = self.pop... | _minmax()(self.scores[i]) < self._minmax()(self.best_score): |
{
"list": [
{
"filename": "examples/random_forrest_simple.py",
"retrieved_chunk": " \"min_impurity_decrease\": (0.0, 0.9),\n \"criterion\": [\"absolute_error\", \"squared_error\"],\n}\noptimizer_kwargs = {\n \"epoch\": 50,\n \"population_size\": 50\n}\nhyponic = HypONIC(model, X, y, mse, *... | """
in this file, we will test the performance of the model with multithreading and without it
Results:
Single 1(50, 50): 44.98987
Single 2(50, 50): 4.24038
Single 3(50, 50): 68.50705
8 threads 1(50, 50): 45.17619
8 threads 2(50, 50): 3.01542
8 threads 3(50, 50): 65.72666
Single 2(100, 200): 5.69452
12 threads 2(100... |
end = time.time()
times[i] = end - start
print(f"\rIteration {i + 1}/{num_iter} done, time: {times[i]}", end="")
print()
return np.mean(times)
def test_single():
optimizer_kwargs = {
"epoch": 100,
"pop_size": 200,
"mode": "single"
}
print("Single th... | {
"context_start_lineno": 0,
"file": "experiments/test_parallelism.py",
"groundtruth_start_lineno": 77,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 78,
"task_id": "project_cc_python/7422"
} | {
"list": [
{
"filename": "examples/svm_abc.py",
"retrieved_chunk": "hyponic.visualize_history_time()\nhyponic.visualize_history_fitness()",
"score": 65.3204880798135
},
{
"filename": "examples/random_forrest_simple.py",
"retrieved_chunk": "print(hyponic.get_optimized_metric(... | optimize(hyperparams) |
{
"list": [
{
"filename": "hyponic/metrics/decorators.py",
"retrieved_chunk": "def add_metric_to_dict(metric: Callable) -> Callable:\n \"\"\"\n A decorator that adds the metric to the dictionary of metrics.\n Called automatically by the minimize_metric and maximize_metric decorators.\n :pa... | from warnings import warn
from hyponic.optimizers.swarm_based.PSO import IWPSO
from hyponic.metrics.decorators import METRICS_DICT
from hyponic.utils.problem_identifier import ProblemIdentifier, ProblemType
from hyponic import config
from typing import Callable
from hyponic.space import Space
from functools import p... |
match problem_type:
case ProblemType.REGRESSION:
self.metric = METRICS_DICT["mse"]
case ProblemType.BINARY_CLASSIFICATION:
self.metric = METRICS_DICT["binary_crossentropy"]
case ProblemType.MULTICLASS_CLASSIFICATION:
... | {
"context_start_lineno": 0,
"file": "hyponic/hyponic.py",
"groundtruth_start_lineno": 39,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 40,
"task_id": "project_cc_python/7424"
} | {
"list": [
{
"filename": "hyponic/metrics/decorators.py",
"retrieved_chunk": " return metric\ndef add_metric_aliases(*aliases) -> Callable:\n \"\"\"\n A decorator that adds aliases to the metric.\n :param aliases: a list of aliases for the metric\n :return: decorated metric\n \"\"\"... | get_problem_type() |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/PSO.py",
"retrieved_chunk": " fitness = np.array([self.function(self.coords[i]) for i in range(self.population_size)])\n condition = all(self._minmax()(np.concatenate([self.p_best, fitness])) != self.p_best)\n self.p_best_c... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class GWO(BaseOptimizer):
"""
Grey Wolf Optimization (GWO) algorithm
Example
~~~~~~~
>>> from hyponic.optimizers.swarm_based.GWO import GWO
>>> import numpy as np
>>>
>>> def sphere(x)... |
self.coords[i] = coords_new
self.fitness[i] = fitness_new
if self._minmax()([fitness_new, self.g_best]) == fitness_new:
self.g_best = fitness_new
self.g_best_coords = coords_new
def get_best_score(self):
return self.g_best
d... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/GWO.py",
"groundtruth_start_lineno": 75,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 76,
"task_id": "project_cc_python/7440"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/PSO.py",
"retrieved_chunk": " expr = \"velocities + a1 * r1 * (p_best_coords - coords) + a2 * r2 * (g_best_coords - coords)\"\n return ne.evaluate(expr,\n local_dict={'velocities': self.velocities, 'a1': ... | _minmax()([fitness_new, self.fitness[i]]) == fitness_new: |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ABC.py",
"retrieved_chunk": " super().initialize(problem_dict)\n self.g_best = np.inf if self._minmax() == min else -np.inf\n self.fitness = np.array([self.function(self.coords[i]) for i in range(self.population_size)])\n ... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class GWO(BaseOptimizer):
"""
Grey Wolf Optimization (GWO) algorithm
Example
~~~~~~~
>>> from hyponic.optimizers.swarm_based.GWO import GWO
>>> import numpy as np
>>>
>>> def sphere(x)... |
def evolve(self, current_epoch):
a = 2 - current_epoch * (2 / self.epoch)
for i in range(self.population_size):
r1 = np.random.rand()
r2 = np.random.rand()
A = 2 * a * r1 - a
C = 2 * r2
D = np.abs(C * self.coords[np.random.randint(0, se... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/GWO.py",
"groundtruth_start_lineno": 61,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 62,
"task_id": "project_cc_python/7438"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ABC.py",
"retrieved_chunk": " new_fitness = self.function(new_coords)\n if self._minmax()(np.array([self.fitness[i], new_fitness])) != self.fitness[i]:\n self.coords[i] = new_coords\n self.fitness[i] = new_fi... | function(x) for x in self.coords], dtype=np.float64) |
{
"list": [
{
"filename": "hyponic/metrics/decorators.py",
"retrieved_chunk": "def add_metric_to_dict(metric: Callable) -> Callable:\n \"\"\"\n A decorator that adds the metric to the dictionary of metrics.\n Called automatically by the minimize_metric and maximize_metric decorators.\n :pa... | from warnings import warn
from hyponic.optimizers.swarm_based.PSO import IWPSO
from hyponic.metrics.decorators import METRICS_DICT
from hyponic.utils.problem_identifier import ProblemIdentifier, ProblemType
from hyponic import config
from typing import Callable
from hyponic.space import Space
from functools import p... |
if self.metric is None:
raise Exception(f"Metric {metric} is not found.")
elif isinstance(metric, Callable):
self.metric = metric
elif metric is None:
# If metric is None, then try to get metric from the problem type
problem_type = Proble... | {
"context_start_lineno": 0,
"file": "hyponic/hyponic.py",
"groundtruth_start_lineno": 31,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 32,
"task_id": "project_cc_python/7423"
} | {
"list": [
{
"filename": "hyponic/metrics/decorators.py",
"retrieved_chunk": " return metric\ndef add_metric_aliases(*aliases) -> Callable:\n \"\"\"\n A decorator that adds aliases to the metric.\n :param aliases: a list of aliases for the metric\n :return: decorated metric\n \"\"\"... | get(metric, None) |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ABC.py",
"retrieved_chunk": " super().initialize(problem_dict)\n self.g_best = np.inf if self._minmax() == min else -np.inf\n self.fitness = np.array([self.function(self.coords[i]) for i in range(self.population_size)])\n ... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class GWO(BaseOptimizer):
"""
Grey Wolf Optimization (GWO) algorithm
Example
~~~~~~~
>>> from hyponic.optimizers.swarm_based.GWO import GWO
>>> import numpy as np
>>>
>>> def sphere(x)... |
def evolve(self, current_epoch):
a = 2 - current_epoch * (2 / self.epoch)
for i in range(self.population_size):
r1 = np.random.rand()
r2 = np.random.rand()
A = 2 * a * r1 - a
C = 2 * r2
D = np.abs(C * self.coords[np.random.randint(0, se... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/GWO.py",
"groundtruth_start_lineno": 61,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 62,
"task_id": "project_cc_python/7439"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ABC.py",
"retrieved_chunk": " new_fitness = self.function(new_coords)\n if self._minmax()(np.array([self.fitness[i], new_fitness])) != self.fitness[i]:\n self.coords[i] = new_coords\n self.fitness[i] = new_fi... | coords], dtype=np.float64) |
{
"list": [
{
"filename": "hyponic/space.py",
"retrieved_chunk": " return mappings\n def map_to_original_space(self, values: list[float]) -> dict[str, Any]:\n \"\"\"\n Maps a list of values from the continuous space to the original space.\n \"\"\"\n mappings = sel... | from warnings import warn
from hyponic.optimizers.swarm_based.PSO import IWPSO
from hyponic.metrics.decorators import METRICS_DICT
from hyponic.utils.problem_identifier import ProblemIdentifier, ProblemType
from hyponic import config
from typing import Callable
from hyponic.space import Space
from functools import p... |
# Split mappings and bounds
mapping_funcs = {}
low_bounds = []
highs_bounds = []
for name in hyperspace.dimensions_names:
mapping, (low, high) = mappings_with_bounds[name]
mapping_funcs[name] = mapping
low_bounds.append(low)
hi... | {
"context_start_lineno": 0,
"file": "hyponic/hyponic.py",
"groundtruth_start_lineno": 110,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 111,
"task_id": "project_cc_python/7429"
} | {
"list": [
{
"filename": "hyponic/space.py",
"retrieved_chunk": " if len(self.dimensions) == 0:\n return \"Hyperparameter Search Space is empty.\"\n # Pretty table of dimensions\n dim_names = list(self.dimensions.keys())\n offset = max([len(k) for k in dim_names... | get_continuous_mappings(origins=0) # Make that all dimensions start from 0 |
{
"list": [
{
"filename": "nninfo/experiment.py",
"retrieved_chunk": " )\n act_dict[\"X\"] = x.detach().numpy()\n act_dict[\"Y\"] = y.detach().numpy()\n # Add decision function. Index of maximum value of output layer. If multiple output n... | import copy
from dataclasses import dataclass, field
from functools import cache
from typing import Optional, Union, Tuple, List
from ast import literal_eval
import torch.nn as nn
import torch
import numpy as np
import scipy as scp
import yaml
import nninfo
from ..file_io import NoAliasDumper
from .quantization impor... |
yaml.SafeLoader.add_constructor("!NeuronID", NeuronID.from_yaml)
class NeuralNetwork(nninfo.exp_comp.ExperimentComponent, nn.Module):
"""
Model that is trained and analysed.
CUDA acceleration is not implemented yet, but will certainly be possible in the future.
"""
def __init__(
self... | {
"context_start_lineno": 0,
"file": "nninfo/model/neural_network.py",
"groundtruth_start_lineno": 127,
"repository": "Priesemann-Group-nninfo-8289154",
"right_context_start_lineno": 128,
"task_id": "project_cc_python/7420"
} | {
"list": [
{
"filename": "nninfo/schedule.py",
"retrieved_chunk": " save_dict = {\n \"chapter_ends\": self.chapter_ends,\n \"chapter_ends_continued\": self.chapter_ends_continued,\n }\n saver.write(save_dict, \"schedule.json\")\n def _load(self, path):\n ... | add_representer(NeuronID, NeuronID.to_yaml) |
{
"list": [
{
"filename": "nninfo/tasks/fake_task.py",
"retrieved_chunk": " return \"binary\"\n @property\n def y_limits(self):\n return \"binary\"\n @property\n def x_dim(self):\n if \"x_dim\" in self._kwargs:\n x_dim = self._kwargs[\"x_dim\"]\n else... | from .task import Task
class RecMajorityTask(Task):
task_id = "rec_maj"
def __init__(self, **kwargs):
"""
Expected kwargs:
voter_list: list of numbers of voters for each recursive layer
"""
super().__init__(self, kwargs)
assert "voter_list" in kwargs
d... |
def y_dim(self):
return 1
def generate_sample(self, rng):
x = rng.integers(1, size=10) | {
"context_start_lineno": 0,
"file": "nninfo/tasks/rec_majority_task.py",
"groundtruth_start_lineno": 21,
"repository": "Priesemann-Group-nninfo-8289154",
"right_context_start_lineno": 22,
"task_id": "project_cc_python/7418"
} | {
"list": [
{
"filename": "nninfo/analysis/binning.py",
"retrieved_chunk": " def discretize(self, activations, neuron_id):\n \"\"\"\n Args:\n activations (numpy array): all activations\n neuron_id: id of the neuron on which discretization should be performed\n ... | _kwargs["voter_list"][0] |
{
"list": [
{
"filename": "nninfo/file_io.py",
"retrieved_chunk": " def read(self, filename, line=None, **kwargs):\n if not self.read:\n log.error(\"Permission Error: Not allowed to read.\")\n raise PermissionError\n ext = os.path.splitext(filename)[1]\n i... | import torch
from ..file_io import FileManager
from .task import Task
class TishbyTask(Task):
task_id = "tishby_dat"
@property
def finite(self):
return True
@property
def x_limits(self):
return "binary"
@property
def y_limits(self):
return "binary"
@property... |
x = data_dict["F"]
y = data_dict["y"].T
return torch.tensor(x, dtype=torch.float), torch.tensor(y, dtype=torch.float) | {
"context_start_lineno": 0,
"file": "nninfo/tasks/tishby_task.py",
"groundtruth_start_lineno": 32,
"repository": "Priesemann-Group-nninfo-8289154",
"right_context_start_lineno": 33,
"task_id": "project_cc_python/7412"
} | {
"list": [
{
"filename": "nninfo/tasks/fake_task.py",
"retrieved_chunk": " return x_dim\n @property\n def y_dim(self):\n return 1\n def load_samples(self):\n n_bits = self.x_dim\n x = _create_all_possible_n_bit_configurations(n_bits)\n # effectively setting... | read("var_u.mat") |
{
"list": [
{
"filename": "nninfo/data_set.py",
"retrieved_chunk": " def from_config(task, config):\n \"\"\"\n Creates a new DataSet from a config dictionary\n \"\"\"\n if task.finite:\n return CachedDataset.from_config(task, config)\n else:\n ... | from ..exp_comp import ExperimentComponent
from ..data_set import DataSet, CachedDataset, LazyDataset
from .task import Task
class TaskManager(ExperimentComponent):
"""
Helper class, handles a task with one 'full_set' dataset and several subsets,
which are then used by Trainer, Tester or Evaluation.
""... |
return task_manager
def to_config(self):
"""
Creates a config dictionary from the TaskManager
"""
output_dict = {
"task_id": self.task.task_id,
"kwarg_dict": self._kwargs,
"subsets": self._dataset.to_config(),
"task_kwargs": ... | {
"context_start_lineno": 0,
"file": "nninfo/tasks/task_manager.py",
"groundtruth_start_lineno": 47,
"repository": "Priesemann-Group-nninfo-8289154",
"right_context_start_lineno": 48,
"task_id": "project_cc_python/7411"
} | {
"list": [
{
"filename": "nninfo/data_set.py",
"retrieved_chunk": " Returns a dictionary representation of the dataset tree\n \"\"\"\n d = dict(name=self._name)\n if self._subsets:\n d[\"subsets\"] = [subset.to_config() for subset in self._subsets]\n retu... | from_config(task_manager.task, config["subsets"]) |
{
"list": [
{
"filename": "nninfo/trainer.py",
"retrieved_chunk": " def load_optimizer_state_dict(self, opt_state_dict):\n self._optimizer.load_state_dict(opt_state_dict)\n def train_chapter(\n self, use_cuda, use_ipex, n_epochs_chapter=None, compute_test_loss=Optional[bool]\n )... |
import numpy as np
import nninfo
class Schedule:
"""
Can create epoch lists for preplanned experiment chapters. These chapters are the main
structure of the training period of the experiment and allow for spaced saving of
checkpoints.
The plan is to end a chapter of the experiment when a epoch ... |
save_dict = {
"chapter_ends": self.chapter_ends,
"chapter_ends_continued": self.chapter_ends_continued,
}
saver.write(save_dict, "schedule.json")
def _load(self, path):
loader = nninfo.file_io.FileManager(path, read=True)
load_dict = loader.read("sch... | {
"context_start_lineno": 0,
"file": "nninfo/schedule.py",
"groundtruth_start_lineno": 130,
"repository": "Priesemann-Group-nninfo-8289154",
"right_context_start_lineno": 131,
"task_id": "project_cc_python/7397"
} | {
"list": [
{
"filename": "nninfo/trainer.py",
"retrieved_chunk": " compute_test_loss (bool): Whether to compute the test loss after each epoch. When None is passed,\n it is set to not CLUSTER_MODE.\n \"\"\"\n if compute_test_loss is Non... | file_io.FileManager(path, write=True) |
{
"list": [
{
"filename": "nninfo/tasks/mnist_binary_task.py",
"retrieved_chunk": " def load_samples(self):\n mnist = torchvision.datasets.MNIST(\n root=\"../\", download=True, train=True)\n mnist_test = torchvision.datasets.MNIST(\n root=\"../\", download=True, ... | import torch
import torchvision
import numpy as np
from .task import Task
class Mnist1DShuffledTask(Task):
task_id = "mnist_1d_shuffled_dat"
@property
def finite(self):
return True
@property
def x_limits(self):
return (0, 1)
@property
def y_limits(self):
retu... |
y[:60_000] = torch.tensor(rng.permutation(y[:60_000]))
y[60_000:] = torch.tensor(rng.permutation(y[60_000:]))
return x.type(torch.float32), y.type(torch.long) | {
"context_start_lineno": 0,
"file": "nninfo/tasks/mnist_shuffled.py",
"groundtruth_start_lineno": 39,
"repository": "Priesemann-Group-nninfo-8289154",
"right_context_start_lineno": 40,
"task_id": "project_cc_python/7414"
} | {
"list": [
{
"filename": "nninfo/tasks/mnist_binary_task.py",
"retrieved_chunk": " qmnist_test.targets[:, 0]])\n y_binary = self.binary(y, 4)\n return x.type(torch.float32), y_binary.type(torch.float32)\n def binary(self, x, bits):\n mask = 2**torch.arang... | _kwargs["seed"]) |
{
"list": [
{
"filename": "nninfo/experiment.py",
"retrieved_chunk": " )\n act_dict[\"X\"] = x.detach().numpy()\n act_dict[\"Y\"] = y.detach().numpy()\n # Add decision function. Index of maximum value of output layer. If multiple output n... | import copy
from dataclasses import dataclass, field
from functools import cache
from typing import Optional, Union, Tuple, List
from ast import literal_eval
import torch.nn as nn
import torch
import numpy as np
import scipy as scp
import yaml
import nninfo
from ..file_io import NoAliasDumper
from .quantization impor... |
"""
Model that is trained and analysed.
CUDA acceleration is not implemented yet, but will certainly be possible in the future.
"""
def __init__(
self,
layer_infos: List[LayerInfo],
init_str,
**kwargs
):
"""
Creates a new instanc... | {
"context_start_lineno": 0,
"file": "nninfo/model/neural_network.py",
"groundtruth_start_lineno": 130,
"repository": "Priesemann-Group-nninfo-8289154",
"right_context_start_lineno": 131,
"task_id": "project_cc_python/7421"
} | {
"list": [
{
"filename": "nninfo/experiment.py",
"retrieved_chunk": " if act_dict[layer_id].ndim > 1\n else act_dict[layer_id]\n for layer_id in act_dict\n for neuron_idx in range(\n act_dict[layer_id].... | exp_comp.ExperimentComponent, nn.Module): |
{
"list": [
{
"filename": "nninfo/tasks/rec_majority_task.py",
"retrieved_chunk": " def x_limits(self):\n return \"binary\"\n def y_limits(self):\n return \"binary\"\n def x_dim(self):\n return self._kwargs[\"voter_list\"][0]\n def y_dim(self):\n return 1\n d... | import torch
import numpy as np
from .task import Task
class CheckerboardTask(Task):
task_id = "checkerboard"
@property
def finite(self):
return False
@property
def x_limits(self):
return (0, 1)
@property
def y_limits(self):
return "binary"
@property
def... |
x = rng.random(2, dtype=np.float32)
y = (int(x[0] * size[0]) + int(x[1] * size[1])) % 2
return x, torch.tensor([y], dtype=torch.float) | {
"context_start_lineno": 0,
"file": "nninfo/tasks/checkerboard_task.py",
"groundtruth_start_lineno": 29,
"repository": "Priesemann-Group-nninfo-8289154",
"right_context_start_lineno": 30,
"task_id": "project_cc_python/7417"
} | {
"list": [
{
"filename": "nninfo/tasks/rec_majority_task.py",
"retrieved_chunk": " def x_limits(self):\n return \"binary\"\n def y_limits(self):\n return \"binary\"\n def x_dim(self):\n return self._kwargs[\"voter_list\"][0]\n def y_dim(self):\n return 1\n d... | _kwargs['size'] |
{
"list": [
{
"filename": "nninfo/analysis/measurement.py",
"retrieved_chunk": " \"quantizer_params\": self._quantizer_params\n }\n @classmethod\n def from_config(cls, experiment, config):\n config = config.copy()\n assert config.pop(\"measurement_type\") == cls.m... | import pandas as pd
from .measurement import Measurement
from ..experiment import Experiment
from .. import logger
log = logger.get_logger(__name__)
class PerformanceMeasurement(Measurement):
measurement_type = "performance"
"""
Computes loss and accuracy for a given dataset.
"""
def __init__(s... |
dfs = []
for dataset_name in self._dataset_names:
loss, acc = self._experiment.tester.compute_loss_and_accuracy(
dataset_name, self._quantizer_params)
dfs.append(pd.DataFrame({'loss': [loss], 'accuracy': [acc]}))
df = pd.concat(dfs, axis=1, keys=self._... | {
"context_start_lineno": 0,
"file": "nninfo/analysis/performance_measurement.py",
"groundtruth_start_lineno": 50,
"repository": "Priesemann-Group-nninfo-8289154",
"right_context_start_lineno": 51,
"task_id": "project_cc_python/7406"
} | {
"list": [
{
"filename": "nninfo/analysis/measurement.py",
"retrieved_chunk": " @staticmethod\n def _load_yaml(file):\n with open(file, \"r\") as f:\n return yaml.safe_load(f)\n @classmethod\n def load(cls, experiment: Experiment, measurement_id: str):\n config_fi... | _experiment.load_checkpoint(run_id, chapter_id) |
{
"list": [
{
"filename": "nninfo/experiment.py",
"retrieved_chunk": " log.info(f\"Successfully loaded checkpoint {run_id}-{chapter_id}.\")\n self._run_id = checkpoint[\"run_id\"]\n def save_components(self):\n component_saver = FileManager(\n self._experiment_dir, w... | from typing import Optional
import numpy as np
from torch.utils.data import DataLoader
import torch.optim as optim
import torch.nn as nn
import nninfo
from nninfo.config import CLUSTER_MODE
from nninfo.exp_comp import ExperimentComponent
from nninfo.model.quantization import quantizer_list_factory
log = nninfo.logger... |
first_epoch_in_run = self._n_epochs_trained == 0
if first_overall_epoch:
self.initialize_components(use_ipex)
self.parent.save_components()
if first_epoch_in_run:
self.parent.save_checkpoint()
log.info("Started training chapter {}.".format(self._n_ch... | {
"context_start_lineno": 0,
"file": "nninfo/trainer.py",
"groundtruth_start_lineno": 210,
"repository": "Priesemann-Group-nninfo-8289154",
"right_context_start_lineno": 211,
"task_id": "project_cc_python/7399"
} | {
"list": [
{
"filename": "nninfo/experiment.py",
"retrieved_chunk": " log.error(\n \"You can only use run_following_schedule if you have \"\n + \"a schedule connected to the experiment or pass a schedule.\"\n )\n retur... | parent.run_id == 0 |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/GWO.py",
"retrieved_chunk": " C = 2 * r2\n D = np.abs(C * self.coords[np.random.randint(0, self.population_size)] - self.coords[np.random.randint(0, self.population_size)])\n coords_new = self.coords[i] + A * D\... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class PSO(BaseOptimizer):
"""
Particle Swarm Optimization (PSO) algorithm
Hyperparameters:
+ a1(float), default=0.5: acceleration parameter
+ a2(float), default=0.5: acceleration parameter... |
def get_best_score(self):
return self.g_best
def get_best_solution(self):
return self.g_best_coords
def get_current_best_score(self):
return self.p_best
def get_current_best_solution(self):
return self.p_best_coords
class IWPSO(PSO):
"""
Inertia Weight Part... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/PSO.py",
"groundtruth_start_lineno": 113,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 114,
"task_id": "project_cc_python/7456"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/GWO.py",
"retrieved_chunk": " def get_best_score(self):\n return self.g_best\n def get_best_solution(self):\n return self.g_best_coords\n def get_current_best_score(self):\n return self._minmax()(self.fitness)\n ... | _argminmax()(self.p_best)] |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/PSO.py",
"retrieved_chunk": " super()._before_initialization()\n if isinstance(self.a1, float) is False and isinstance(self.a1, int) is False:\n raise ValueError(\"a1 should be a float or an integer\")\n if isins... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class CS(BaseOptimizer):
"""
Cuckoo Search (CS) algorithm
Hyperparameters:
+ pa(float), default=0.25: probability of cuckoo's egg to be discovered
+ alpha(float), default=0.5: step size
... |
self.cuckoo_coords = np.random.uniform(self.lb, self.ub, self.dimensions)
def _levy_flight(self, x):
u = np.random.normal(0, 1, size=self.dimensions)
v = np.random.normal(0, 1, size=self.dimensions)
best_coords = self.nests[self._argminmax()(self.nests_fitness)]
return ne.e... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/CS.py",
"groundtruth_start_lineno": 82,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 83,
"task_id": "project_cc_python/7460"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/PSO.py",
"retrieved_chunk": " self.velocities = np.random.uniform(-max_velocity, max_velocity, size=(self.population_size, self.dimensions))\n self.p_best_coords = self.coords\n self.p_best = np.array([self.function(self.co... | function(self.nests[i]) for i in range(self.population_size)]) |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ABC.py",
"retrieved_chunk": " super().initialize(problem_dict)\n self.g_best = np.inf if self._minmax() == min else -np.inf\n self.fitness = np.array([self.function(self.coords[i]) for i in range(self.population_size)])\n ... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class PSO(BaseOptimizer):
"""
Particle Swarm Optimization (PSO) algorithm
Hyperparameters:
+ a1(float), default=0.5: acceleration parameter
+ a2(float), default=0.5: acceleration parameter... |
self.p_best_coords = np.where(condition, self.coords, self.p_best_coords)
self.p_best = ne.evaluate("where(condition, fitness, p_best)", local_dict={'condition': condition,
'fitness': fitness,
... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/PSO.py",
"groundtruth_start_lineno": 92,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 93,
"task_id": "project_cc_python/7455"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ABC.py",
"retrieved_chunk": " new_fitness = self.function(new_coords)\n if self._minmax()(np.array([self.fitness[i], new_fitness])) != self.fitness[i]:\n self.coords[i] = new_coords\n self.fitness[i] = new_fi... | _minmax()(np.concatenate([self.p_best, fitness])) != self.p_best) |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ABC.py",
"retrieved_chunk": " new_fitness = self.function(new_coords)\n if self._minmax()(np.array([self.fitness[i], new_fitness])) != self.fitness[i]:\n self.coords[i] = new_coords\n self.fitness[i] = new_fi... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class CS(BaseOptimizer):
"""
Cuckoo Search (CS) algorithm
Hyperparameters:
+ pa(float), default=0.25: probability of cuckoo's egg to be discovered
+ alpha(float), default=0.5: step size
... |
def get_best_solution(self):
return self.nests[self._argminmax()(self.nests_fitness)]
def get_current_best_score(self):
return self.get_best_score()
def get_current_best_solution(self):
return self.get_best_solution()
| {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/CS.py",
"groundtruth_start_lineno": 108,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 109,
"task_id": "project_cc_python/7465"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ABC.py",
"retrieved_chunk": " self._coordinate_update_phase(i, k)\n def _onlooker_bees_phase(self):\n if np.all(self.fitness == 0):\n probabilities = np.ones(self.population_size) / self.population_size\n ... | _minmax()(self.nests_fitness) |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ACO.py",
"retrieved_chunk": " def initialize(self, problem_dict):\n super().initialize(problem_dict)\n self.pheromone = np.ones((self.population_size, self.dimensions))\n self.best_score = np.inf if self.minmax == 'min' ... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class GA(BaseOptimizer):
"""
Genetic Algorithm(GA)
Example
~~~~~~~
>>> from hyponic.optimizers.genetic_based.GA import GA
>>> import numpy as np
>>>
>>> def sphere(x):
... |
self.best_score = self.scores[best_idx]
self.best_solution = self.population[best_idx]
def evolve(self, epoch):
next_population = np.zeros_like(self.population)
next_scores = np.zeros(self.population_size)
# Elitism: keep the best solution from the previous generation
... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/genetic_based/GA.py",
"groundtruth_start_lineno": 64,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 65,
"task_id": "project_cc_python/7480"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ACO.py",
"retrieved_chunk": " self.best_solution = self.population[i]\n def evolve(self, epoch):\n new_population = np.zeros((self.population_size, self.dimensions))\n new_scores = np.zeros(self.population_size)\... | _argminmax()(self.scores) |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/PSO.py",
"retrieved_chunk": " super()._before_initialization()\n if isinstance(self.a1, float) is False and isinstance(self.a1, int) is False:\n raise ValueError(\"a1 should be a float or an integer\")\n if isins... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class ABC(BaseOptimizer):
"""
Artificial Bee Colony (ABC) algorithm
Hyperparameters:
+ limits(int), default=25: the number of trials before abandoning food source
Example
~~~~~~~
>>> ... |
self.fitness = np.array([self.function(self.coords[i]) for i in range(self.population_size)])
self.trials = np.zeros(self.population_size)
def _coordinate_update_phase(self, i, k):
phi = np.random.uniform(-1, 1, self.dimensions)
new_coords = ne.evaluate("coords + phi * (coords - ... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/ABC.py",
"groundtruth_start_lineno": 70,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 71,
"task_id": "project_cc_python/7468"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/PSO.py",
"retrieved_chunk": " self.velocities = np.random.uniform(-max_velocity, max_velocity, size=(self.population_size, self.dimensions))\n self.p_best_coords = self.coords\n self.p_best = np.array([self.function(self.co... | _minmax() == min else -np.inf |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ACO.py",
"retrieved_chunk": " def initialize(self, problem_dict):\n super().initialize(problem_dict)\n self.pheromone = np.ones((self.population_size, self.dimensions))\n self.best_score = np.inf if self.minmax == 'min' ... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class GA(BaseOptimizer):
"""
Genetic Algorithm(GA)
Example
~~~~~~~
>>> from hyponic.optimizers.genetic_based.GA import GA
>>> import numpy as np
>>>
>>> def sphere(x):
... |
best_idx = self._argminmax()(self.scores)
self.best_score = self.scores[best_idx]
self.best_solution = self.population[best_idx]
def evolve(self, epoch):
next_population = np.zeros_like(self.population)
next_scores = np.zeros(self.population_size)
# Elitism: keep ... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/genetic_based/GA.py",
"groundtruth_start_lineno": 62,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 63,
"task_id": "project_cc_python/7479"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ACO.py",
"retrieved_chunk": " self.best_solution = self.population[i]\n def evolve(self, epoch):\n new_population = np.zeros((self.population_size, self.dimensions))\n new_scores = np.zeros(self.population_size)\... | function(self.population[i]) for i in range(self.population_size)]) |
{
"list": [
{
"filename": "hyponic/optimizers/genetic_based/GA.py",
"retrieved_chunk": " self.best_solution = None\n def initialize(self, problem_dict):\n super().initialize(problem_dict)\n self.population = np.random.uniform(low=self.lb, high=self.ub, size=(self.population_siz... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class CS(BaseOptimizer):
"""
Cuckoo Search (CS) algorithm
Hyperparameters:
+ pa(float), default=0.25: probability of cuckoo's egg to be discovered
+ alpha(float), default=0.5: step size
... |
return ne.evaluate('x + k * u / (abs(v) ** (1 / 1.5)) * (best_coords - x)', local_dict={
'x': x, 'k': self.k, 'u': u, 'v': v, 'best_coords': best_coords
})
def evolve(self, current_epoch):
x_new = self._levy_flight(self.cuckoo_coords)
self.cuckoo_coords = np.clip(x_new,... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/swarm_based/CS.py",
"groundtruth_start_lineno": 88,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 89,
"task_id": "project_cc_python/7464"
} | {
"list": [
{
"filename": "hyponic/optimizers/genetic_based/GA.py",
"retrieved_chunk": " next_scores = np.zeros(self.population_size)\n # Elitism: keep the best solution from the previous generation\n best_idx = self._argminmax()(self.scores)\n next_population[0] = self.pop... | _argminmax()(self.nests_fitness)] |
{
"list": [
{
"filename": "hyponic/optimizers/swarm_based/ACO.py",
"retrieved_chunk": " def initialize(self, problem_dict):\n super().initialize(problem_dict)\n self.pheromone = np.ones((self.population_size, self.dimensions))\n self.best_score = np.inf if self.minmax == 'min' ... | from hyponic.optimizers.base_optimizer import BaseOptimizer
import numpy as np
import numexpr as ne
class GA(BaseOptimizer):
"""
Genetic Algorithm(GA)
Example
~~~~~~~
>>> from hyponic.optimizers.genetic_based.GA import GA
>>> import numpy as np
>>>
>>> def sphere(x):
... |
self.best_solution = next_population[best_idx]
self.best_score = next_scores[best_idx]
# replace the old population with the new one
self.population = next_population
self.scores = next_scores
def get_best_score(self):
return self.best_score
def get_be... | {
"context_start_lineno": 0,
"file": "hyponic/optimizers/genetic_based/GA.py",
"groundtruth_start_lineno": 109,
"repository": "slewie-HypONIC-5b95063",
"right_context_start_lineno": 110,
"task_id": "project_cc_python/7481"
} | {
"list": [
{
"filename": "hyponic/optimizers/swarm_based/PSO.py",
"retrieved_chunk": " fitness = np.array([self.function(self.coords[i]) for i in range(self.population_size)])\n condition = all(self._minmax()(np.concatenate([self.p_best, fitness])) != self.p_best)\n self.p_best_c... | _minmax()(next_scores) < self._minmax()(self.scores): |
{
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " gen = generator.Generator(solver, randomize, rows, cols, si, tag_level, game_level)\n util.timer_section('add tile rules')\n gen.add_rules_tiles()\n if si.pattern_info is not None and weight_patterns != 0:\n util... | import argparse, pickle, pprint, sys
import util
PATTERN_NEIGH_2 = [([(0, 0)], [( 0, 1)]),
([(0, 0)], [( 1, 0)])]
PATTERN_NEIGH_L = [([(0, 0)], [( 0, 1)]),
([(0, 0)], [( 1, 1)]),
([(0, 0)], [( 1, 0)])]
PATTERN_NEIGH_PLUS ... |
si.count_info.divs_size = divs_size
si.count_info.divs_to_game_to_tag_to_tile_count = {}
for rr_divs in range(si.count_info.divs_size[0]):
for cc_divs in range(si.count_info.divs_size[1]):
si.count_info.divs_to_game_to_tag_to_tile_count[(rr_divs, cc_divs)] = {}
... | {
"context_start_lineno": 0,
"file": "tile2scheme.py",
"groundtruth_start_lineno": 101,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 102,
"task_id": "project_cc_python/7523"
} | {
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " if reach_setup is not None:\n util.timer_section('add reachability rules')\n gen.add_rules_reachability(reach.get_reach_info(rows, cols, reach_setup, si))\n if mkiii_setup is not None:\n util.timer_section('a... | SchemeCountInfo() |
{
"list": [
{
"filename": "input2tile.py",
"retrieved_chunk": " tli = util.TileLevelInfo()\n tli.tiles = tile_level\n tli.tags = tag_level\n tli.games = game_level\n tli.meta = text_meta\n ti.levels.append(tli)\n if image_level and t... | import argparse, pickle, pprint, sys
import util
PATTERN_NEIGH_2 = [([(0, 0)], [( 0, 1)]),
([(0, 0)], [( 1, 0)])]
PATTERN_NEIGH_L = [([(0, 0)], [( 0, 1)]),
([(0, 0)], [( 1, 1)]),
([(0, 0)], [( 1, 0)])]
PATTERN_NEIGH_PLUS ... |
tag_level = util.rotate_grid_cw(tag_level)
game_level = util.rotate_grid_cw(game_level)
tile_levels.append(tile_level)
tag_levels.append(tag_level)
game_levels.append(game_level)
for tile_level, tag_level, game_level in zip(tile_leve... | {
"context_start_lineno": 0,
"file": "tile2scheme.py",
"groundtruth_start_lineno": 205,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 206,
"task_id": "project_cc_python/7526"
} | {
"list": [
{
"filename": "input2tile.py",
"retrieved_chunk": " os.makedirs(tile_output_folder)\n for tile, tile_image in ts.tile_to_image.items():\n tile_filename = '%s/tile%04d.png' % (tile_output_folder, tile)\n print(tile_filename)\n tile_image.save(t... | rotate_grid_cw(tile_level) |
{
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " return tile in self._vars_rc_t[(rr, cc)]\n else:\n return tile == util.VOID_TILE\n def _pattern_var(self, pattern):\n util.check(len(pattern) > 0, 'empty pattern')\n key = tuple(sorted(set(patt... | import argparse, pickle, pprint, sys
import util
PATTERN_NEIGH_2 = [([(0, 0)], [( 0, 1)]),
([(0, 0)], [( 1, 0)])]
PATTERN_NEIGH_L = [([(0, 0)], [( 0, 1)]),
([(0, 0)], [( 1, 1)]),
([(0, 0)], [( 1, 0)])]
PATTERN_NEIGH_PLUS ... |
si.tileset = ti.tileset
si.game_to_tag_to_tiles = {}
if divs_size is None:
si.count_info = None
else:
si.count_info = util.SchemeCountInfo()
si.count_info.divs_size = divs_size
si.count_info.divs_to_game_to_tag_to_tile_count = {}
for rr_divs in range(si.count... | {
"context_start_lineno": 0,
"file": "tile2scheme.py",
"groundtruth_start_lineno": 92,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 93,
"task_id": "project_cc_python/7522"
} | {
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " return self._rows\n def get_cols(self):\n return self._cols\n def get_scheme_info(self):\n return self._scheme_info\n def append_extra_meta(self, meta):\n self._extra_meta += meta\n def add_rules_til... | SchemeInfo() |
{
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " self.layers = None\n self.extra_meta = []\nclass CustomInfo:\n def __init__(self, solver, rng, vars_lrct, rows, cols, layers):\n self.solver = solver\n self.rng = rng\n self.vars_lrct = vars_lrct\n ... | import argparse, glob, gzip, math, os, pickle, random, sys, threading, time
import util, util_explore, util_path
import numpy as np
import PIL.Image, PIL.ImageDraw, PIL.ImageTk
import tkinter, tkinter.messagebox
INSET = 10
FRAME = 5
CELL_SIZE_DEF = 50
MAX_CACHE = 128
MAX_UNDO ... |
self.texts_sqrt = util.make_grid(rows, cols, 0)
self.images = util.make_grid(rows, cols, [])
self.images_sqrt = util.make_grid(rows, cols, 0)
self.einds = []
self.einds_cell = util.make_grid(rows, cols, [])
self.pinds = []
class ExplorerFrame(tkinter.Frame):
de... | {
"context_start_lineno": 0,
"file": "explorer.py",
"groundtruth_start_lineno": 40,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 41,
"task_id": "project_cc_python/7510"
} | {
"list": [
{
"filename": "util.py",
"retrieved_chunk": " self.dr_lo = None\n self.dr_hi = None\n self.dc_lo = None\n self.dc_hi = None\nclass SchemeInfo:\n def __init__(self):\n self.tileset = None\n self.game_to_tag_to_tiles = None\n self.count_inf... | make_grid(rows, cols, []) |
{
"list": [
{
"filename": "solvers.py",
"retrieved_chunk": " self._ctl_add_rule('%s :- %s.' % (ll, conj_var))\n self._ctl_add_rule('%s :- %s.' % (conj_var, ','.join(lls)))\n return conj_var\n def _IMPL_cnstr_implies_disj(self, in_ll, out_lls, weight):\n s... | import argparse, pickle
import generator, reach, util
WEIGHT_CUSTOM = 100
CUST_RESULT = 'result'
CUST_TEXT_LEVEL = 'text-level'
CUST_TEXT_COUNT = 'text-count'
CUST_TEXT_MAX = 'text-max'
CUST_PATH = 'path'
CUST_PATH_ENDS = 'path-ends'
CUST_PATH_FWD = 'path-fwd'
CUST_PATH_SH... |
def str_to_result(s):
with util.openz(s, 'rb') as f:
return pickle.load(f)
def str_to_points(s):
ret = []
for pt in s.split(','):
a, b = pt.split()
ret.append((int(a), int(b)))
return ret
def arg_cvt(args, cvts):
util.check(len(args) == len(cvts), 'argument length')
... | {
"context_start_lineno": 0,
"file": "custom.py",
"groundtruth_start_lineno": 25,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 26,
"task_id": "project_cc_python/7530"
} | {
"list": [
{
"filename": "solvers.py",
"retrieved_chunk": " def get_soft_var_body():\n nonlocal soft_var_body\n if soft_var_body is None:\n if weight is None:\n soft_var_body = ''\n else:\n soft_var_body ... | check(False, 'weight') |
{
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " _pattern_vars = [self._pattern_var(_pattern) for _pattern in _patterns]\n self._solver.cnstr_count(_pattern_vars, True, 1, len(_pattern_vars), weight_patterns)\n if self._scheme_info.pattern_info.stride_rows ==... | import argparse, pickle, pprint, sys
import util
PATTERN_NEIGH_2 = [([(0, 0)], [( 0, 1)]),
([(0, 0)], [( 1, 0)])]
PATTERN_NEIGH_L = [([(0, 0)], [( 0, 1)]),
([(0, 0)], [( 1, 1)]),
([(0, 0)], [( 1, 0)])]
PATTERN_NEIGH_PLUS ... |
gram_rows = [len(tli.tiles) for tli in ti.levels]
util.check(len(set(gram_rows)) == 1, 'all levels must be same height')
gram_rows = gram_rows[0]
si.pattern_info.stride_rows = 0
patterns_delta = [([(rr, cc) for rr in range(gram_rows) for... | {
"context_start_lineno": 0,
"file": "tile2scheme.py",
"groundtruth_start_lineno": 125,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 126,
"task_id": "project_cc_python/7525"
} | {
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " for (_dr, _dc), _ptile in zip(_pattern_template, _pattern):\n _nr = rr + _dr\n _nc = cc + _dc\n _nbr_tag = util.VOID_TEXT if (_nr <= -1 or _nr >= self._rows or _nc <= -1 or _nc >= sel... | check(len(game_to_patterns_delta) == 1, 'multiple games stride') |
{
"list": [
{
"filename": "input2tile.py",
"retrieved_chunk": " for rr in range(rows):\n util.check(len(tag_level[rr]) == cols, 'row length mismatch')\n for cc in range(cols):\n util.check((tile_level[rr][cc] == util.VOID_TILE) == (tag_level[... | import argparse, pickle, pprint, sys
import util
PATTERN_NEIGH_2 = [([(0, 0)], [( 0, 1)]),
([(0, 0)], [( 1, 0)])]
PATTERN_NEIGH_L = [([(0, 0)], [( 0, 1)]),
([(0, 0)], [( 1, 1)]),
([(0, 0)], [( 1, 0)])]
PATTERN_NEIGH_PLUS ... |
if tile == util.VOID_TILE:
continue
if game not in si.game_to_tag_to_tiles:
si.game_to_tag_to_tiles[game] = {}
if tag not in si.game_to_tag_to_tiles[game]:
si.game_to_tag_to_tiles[game][tag] = {}
... | {
"context_start_lineno": 0,
"file": "tile2scheme.py",
"groundtruth_start_lineno": 227,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 228,
"task_id": "project_cc_python/7529"
} | {
"list": [
{
"filename": "input2tile.py",
"retrieved_chunk": " if text_meta is None:\n text_meta = []\n text_meta.insert(0, util.meta_path(path))\n util.print_tile_level(tile_level)\n print()\n util.print_text_level(tag_level)\n print()... | VOID_TILE) == (tag == util.VOID_TEXT), 'void') |
{
"list": [
{
"filename": "gdesc2graph.py",
"retrieved_chunk": " solver = solvers.solver_id_to_solver(args.solver[0])\n else:\n solver = solvers.PortfolioSolver(args.solver, None)\n if args.edgeopt is not None:\n edgeopt = args.edgeopt[0]\n edgeopt_params = tuple([int... | import argparse, pickle
import generator, reach, util
WEIGHT_CUSTOM = 100
CUST_RESULT = 'result'
CUST_TEXT_LEVEL = 'text-level'
CUST_TEXT_COUNT = 'text-count'
CUST_TEXT_MAX = 'text-max'
CUST_PATH = 'path'
CUST_PATH_ENDS = 'path-ends'
CUST_PATH_FWD = 'path-fwd'
CUST_PATH_SH... |
return OutTextLevelConstraint(out_text_level, weight)
elif cust == CUST_TEXT_COUNT:
rlo, clo, rhi, chi, tlo, thi, out_texts, weight = arg_cvt(args, (int, int, int, int, int, int, str, str_to_weight))
return OutTextCountConstraint(rlo, clo, rhi, chi, tlo, thi, out_texts, weight)
elif c... | {
"context_start_lineno": 0,
"file": "custom.py",
"groundtruth_start_lineno": 49,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 50,
"task_id": "project_cc_python/7532"
} | {
"list": [
{
"filename": "gdesc2graph.py",
"retrieved_chunk": " grd = pickle.load(f)\n ogrs = gdesc2graph(solver, grd, args.minsize, args.maxsize, edgeopt, edgeopt_params, label_min, label_max, args.label_count, args.connect, args.randomize)\n if ogrs is not None:\n util_graph.wri... | read_text_level, str_to_weight)) |
{
"list": [
{
"filename": "solvers.py",
"retrieved_chunk": " self._ctl_add_rule('%s :- %s.' % (ll, conj_var))\n self._ctl_add_rule('%s :- %s.' % (conj_var, ','.join(lls)))\n return conj_var\n def _IMPL_cnstr_implies_disj(self, in_ll, out_lls, weight):\n s... | import argparse, pickle
import generator, reach, util
WEIGHT_CUSTOM = 100
CUST_RESULT = 'result'
CUST_TEXT_LEVEL = 'text-level'
CUST_TEXT_COUNT = 'text-count'
CUST_TEXT_MAX = 'text-max'
CUST_PATH = 'path'
CUST_PATH_ENDS = 'path-ends'
CUST_PATH_FWD = 'path-fwd'
CUST_PATH_SH... |
return pickle.load(f)
def str_to_points(s):
ret = []
for pt in s.split(','):
a, b = pt.split()
ret.append((int(a), int(b)))
return ret
def arg_cvt(args, cvts):
util.check(len(args) == len(cvts), 'argument length')
return [cvt(arg) for arg, cvt in zip(args, cvts)]
def arg... | {
"context_start_lineno": 0,
"file": "custom.py",
"groundtruth_start_lineno": 28,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 29,
"task_id": "project_cc_python/7531"
} | {
"list": [
{
"filename": "solvers.py",
"retrieved_chunk": " def get_soft_var_body():\n nonlocal soft_var_body\n if soft_var_body is None:\n if weight is None:\n soft_var_body = ''\n else:\n soft_var_body ... | openz(s, 'rb') as f: |
{
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " fr, fc, tr, tc, pwtc, need_open_path, need_open_aux, need_closed = edge_key\n edges[(fr, fc, tr, tc, pwtc)] = None\n return edges\n def add_constraint_reach_edge(self, cfr, cfc, ctr, ctc, cpwtc, on_path, wei... | import argparse, pickle
import generator, reach, util
WEIGHT_CUSTOM = 100
CUST_RESULT = 'result'
CUST_TEXT_LEVEL = 'text-level'
CUST_TEXT_COUNT = 'text-count'
CUST_TEXT_MAX = 'text-max'
CUST_PATH = 'path'
CUST_PATH_ENDS = 'path-ends'
CUST_PATH_FWD = 'path-fwd'
CUST_PATH_SH... |
class OutPathEndsConstraint(CustomConstraint):
def __init__(self, sr, sc, gr, gc, weight):
self._sr = sr
self._sc = sc
self._gr = gr
self._gc = gc
self._weight = weight
def add(self, gen):
print('add custom out path ends constraint', self._weight)
for ... | {
"context_start_lineno": 0,
"file": "custom.py",
"groundtruth_start_lineno": 118,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 119,
"task_id": "project_cc_python/7533"
} | {
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " self._solver.cnstr_count(edge_vars, True, edge_count, edge_count, weight)\n def add_constraint_start(self, rr, cc, on_path, weight):\n game = self._game_level[rr][cc]\n move_info = self._reach_info.game_to_move[game... | meta_path('custom-path', path_edges)]) |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " for _rr in range(rows):\n for _cc in range(cols):\n _st.append((_rr, _cc))\n _gl.append((_rr, _cc))\n def r_set(_sr, _sc, _gr, _gc, _st, _gl):\n _st.append((_sr, _sc))\n _gl.appe... | import argparse, pickle
import generator, reach, util
WEIGHT_CUSTOM = 100
CUST_RESULT = 'result'
CUST_TEXT_LEVEL = 'text-level'
CUST_TEXT_COUNT = 'text-count'
CUST_TEXT_MAX = 'text-max'
CUST_PATH = 'path'
CUST_PATH_ENDS = 'path-ends'
CUST_PATH_FWD = 'path-fwd'
CUST_PATH_SH... |
class OutPathFwdConstraint(CustomConstraint):
def __init__(self, direction, weight):
self._direction = direction
self._weight = weight
def add(self, gen):
print('add custom out path forward constraint', self._weight)
reach_edges = gen.reachability_edges()
util.check(r... | {
"context_start_lineno": 0,
"file": "custom.py",
"groundtruth_start_lineno": 137,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 138,
"task_id": "project_cc_python/7534"
} | {
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " _st.append((_rr, _cc))\n _gl.append((_rr, cols - 1 - _cc))\n def r_bottom_to_top(_sz, _st, _gl):\n for _rr in range(_sz):\n for _cc in range(cols):\n _st.append((rows - 1 - _rr,... | meta_tile('custom-path-ends', ends)]) |
{
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " if args.reach_goal[0] not in reach.RGOAL_DICT:\n parser.error('--reach-goal[0] must be in ' + ','.join(reach.RGOAL_DICT.key()))\n reach_setup.goal_loc = args.reach_goal[0]\n if len(args.reach_goal[1:]) !... | import util
RMOVE_MAZE = 'maze'
RMOVE_TOMB = 'tomb'
RMOVE_CLIMB = 'climb'
RMOVE_SUPERCAT = 'supercat'
RMOVE_SUPERCAT2 = 'supercat2'
RMOVE_PLATFORM = 'platform'
RMOVE_LIST = [RMOVE_MAZE, RMOVE_TOMB, RMOVE_SUPERCAT, RMOVE_SUPERCAT2, RM... |
reach_info.game_to_move[game] = game_move
game_move.start_tile, game_move.goal_tile, game_move.open_tiles = None, None, []
for tag, tiles in scheme_info.game_to_tag_to_tiles[game].items():
for tile in tiles:
text = scheme_info.tileset.tile_to_text[tile]
... | {
"context_start_lineno": 0,
"file": "reach.py",
"groundtruth_start_lineno": 224,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 225,
"task_id": "project_cc_python/7541"
} | {
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " if args.reach_open_zelda:\n if not reach_setup:\n parser.error('cannot specify --reach-open-zelda without other reach args')\n reach_setup.open_text = util.OPEN_TEXT_ZELDA\n if args.reach_wrap_cols:\n ... | GameMoveInfo() |
{
"list": [
{
"filename": "tile2scheme.py",
"retrieved_chunk": " for tile in tiles:\n inc(si.count_info.divs_to_game_to_tag_to_tile_count[(rr_divs, cc_divs)][game], tag, tile, 0)\n for rr in range(rr_lo, rr_hi):\n ... | import argparse, math, pickle, pprint, random, sys, time
import solvers, util
class Generator:
def __init__(self, solver, randomize, rows, cols, scheme_info, tag_level, game_level):
super().__init__()
self._solver = solver
self._rng = random.Random(randomize) if randomize else None
... |
if self._scheme_info.tileset.tile_to_image is not None:
res_info.image_level = util.tile_level_to_image_level(res_info.tile_level, self._scheme_info.tileset)
return res_info
def _get_tiles_set(self):
tiles = {}
for rr, cc in self._vars_rc_t:
found_tile = ... | {
"context_start_lineno": 0,
"file": "generator.py",
"groundtruth_start_lineno": 498,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 499,
"task_id": "project_cc_python/7556"
} | {
"list": [
{
"filename": "tile2scheme.py",
"retrieved_chunk": " continue\n inc(si.count_info.divs_to_game_to_tag_to_tile_count[(rr_divs, cc_divs)][game], tag, tile, 1)\n for game, tag_to_tiles in si.game_to_tag_to_tiles.item... | tile_level_to_text_level(res_info.tile_level, self._scheme_info.tileset) |
{
"list": [
{
"filename": "levels2explore.py",
"retrieved_chunk": " ex.npind = max(list(pind_to_prop.keys()) + [-1]) + 1\n ex.void_tind = void_tind\n ex.tind_to_text = tind_to_text\n ex.tind_to_image = tind_to_image\n ex.tinds_to_tile = tinds_to_tile\n ex.eind_to_edge = eind_to_edge\... | import argparse, json, pickle, sys, time
import util, util_explore
import numpy as np
def explore2summary(ex, summarize_levels, summarize_edges):
level_length = ex.rows * ex.cols * ex.ntind + ex.neind + ex.npind
print('levels:', ex.level_data.shape[0])
print('level length:', level_length)
print('leve... |
print('index text: ', ''.join([(ex.tind_to_text[tind] if tind in ex.tind_to_text else ' ') for tind in range(ex.ntind)]))
print('index image: ', ''.join([(image_ids[id(ex.tind_to_image[tind])] if tind in ex.tind_to_image else ' ') for tind in range(ex.ntind)]))
tile_to_tinds = {}
for tinds, tile in... | {
"context_start_lineno": 0,
"file": "explore2summary.py",
"groundtruth_start_lineno": 20,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 21,
"task_id": "project_cc_python/7547"
} | {
"list": [
{
"filename": "levels2explore.py",
"retrieved_chunk": " print('encoded', len(ex.eind_to_edge), 'edges into', ex.neind)\n print('encoded', len(ex.pind_to_prop), 'props into', ex.npind)\n print('encoded data', ex.level_data.shape)\n return ex\nif __name__ == '__main__':\n util... | index_to_char(len(image_ids)) |
{
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " util.check(abs(dr) + abs(dc) <= 1, 'dr and/or dc out of range')\n if dr == dc == 0:\n util.check(len(rule_in) == len(rule_out) == 1, 'rule has len... | import util
RMOVE_MAZE = 'maze'
RMOVE_TOMB = 'tomb'
RMOVE_CLIMB = 'climb'
RMOVE_SUPERCAT = 'supercat'
RMOVE_SUPERCAT2 = 'supercat2'
RMOVE_PLATFORM = 'platform'
RMOVE_LIST = [RMOVE_MAZE, RMOVE_TOMB, RMOVE_SUPERCAT, RMOVE_SUPERCAT2, RM... |
need_closed = [(1, 0)]
move_template.append((dest, need_open_path, need_open_aux, need_closed))
elif reach_move == RMOVE_PLATFORM:
# fall
move_template.append(((1, 0), [], [], []))
move_template.append(((1, 1), [(1, 0)], [], []))
move_templ... | {
"context_start_lineno": 0,
"file": "reach.py",
"groundtruth_start_lineno": 96,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 97,
"task_id": "project_cc_python/7539"
} | {
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " vou.append(self._vars_lrct[(ll + 1, rr + dr * ii, cc + dc * ii, rule_out[ii])])\n vrs.append(rr + dr * ii)\n vcs.append(cc + d... | check(False, 'reach_move') |
{
"list": [
{
"filename": "util.py",
"retrieved_chunk": " meta.append(meta_path(MGROUP_PATH, result_info.reach_info.path_edges))\n meta.append(meta_tile(MGROUP_PATH, result_info.reach_info.path_tiles))\n meta.append(meta_line(MGROUP_OFFPATH, result_info.reach_info.offpath_edges))\... | import argparse, math, pickle, pprint, random, sys, time
import solvers, util
class Generator:
def __init__(self, solver, randomize, rows, cols, scheme_info, tag_level, game_level):
super().__init__()
self._solver = solver
self._rng = random.Random(randomize) if randomize else None
... |
res_info.text_level = None
res_info.image_level = None
set_tiles = self._get_tiles_set()
for rr in range(self._rows):
for cc in range(self._cols):
tag = self._tag_level[rr][cc]
if (rr, cc) in set_tiles:
found_tile = set_t... | {
"context_start_lineno": 0,
"file": "generator.py",
"groundtruth_start_lineno": 479,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 480,
"task_id": "project_cc_python/7555"
} | {
"list": [
{
"filename": "util.py",
"retrieved_chunk": "def print_text_level(text_level, meta=None, replace_path_tiles=None, outfile=None):\n if outfile is None:\n outfile = sys.stdout\n for rr, row in enumerate(text_level):\n for cc, tile in enumerate(row):\n if replac... | make_grid(self._rows, self._cols, util.VOID_TILE) |
{
"list": [
{
"filename": "custom.py",
"retrieved_chunk": " for cc in range(gen.get_cols()):\n out_text = self._out_text_level[rr][cc]\n if out_text != util.DEFAULT_TEXT:\n diff_tiles = [tile for tile, text in gen.get_scheme_info().tileset.ti... | import argparse, math, pickle, pprint, random, sys, time
import solvers, util
class Generator:
def __init__(self, solver, randomize, rows, cols, scheme_info, tag_level, game_level):
super().__init__()
self._solver = solver
self._rng = random.Random(randomize) if randomize else None
... |
return self._vars_rc_t[(rr, cc)][tile]
else:
util.check(tile == util.VOID_TILE, 'void tile')
return self._var_void_true
def _tile_has_var(self, rr, cc, tile):
if (rr, cc) in self._vars_rc_t:
return tile in self._vars_rc_t[(rr, cc)]
else:
... | {
"context_start_lineno": 0,
"file": "generator.py",
"groundtruth_start_lineno": 34,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 35,
"task_id": "project_cc_python/7548"
} | {
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " for cc in range(self._cols):\n vvs = []\n for ss in self._states:\n vvs.append(self._vars_lrct[(ll, rr, cc, ss)])\n self._solver.cnstr_count(vvs, Tr... | check(tile != util.VOID_TILE, 'void tile') |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " if text == util.START_TEXT:\n util.check(game_move.start_tile is None, 'multiple tiles with start text')\n game_move.start_tile = tile\n if text == util.GOAL_TEXT:\n ... | import util
RANDOM_PATH_INSET = 1
def point_path_from_edge_path(edge_path):
point_path = []
if len(edge_path) > 0:
(fr, fc, tr, tc) = edge_path[0]
point_path.append((fr, fc))
for (fr, fc, tr, tc) in edge_path:
util.check((fr, fc) == point_path[-1], 'edge path')
point_path.a... |
open_start_goal_text = open_text + util.START_TEXT + util.GOAL_TEXT
for rr in range(len(text_level)):
for cc in range(len(text_level[rr])):
if text_level[rr][cc] in open_start_goal_text:
are_open[(rr, cc)] = None
else:
are_closed[(rr, cc)] = Non... | {
"context_start_lineno": 0,
"file": "util_path.py",
"groundtruth_start_lineno": 90,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 91,
"task_id": "project_cc_python/7560"
} | {
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " return self._rows\n def get_cols(self):\n return self._cols\n def get_scheme_info(self):\n return self._scheme_info\n def append_extra_meta(self, meta):\n self._extra_meta += meta\n def add_rules_til... | GOAL_TEXT not in open_text, 'start/goal in open_text') |
{
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " if ll > 0:\n self._solver.cnstr_implies_disj(self._vars_term[ll], True, [self._vars_term[ll + 1]], True, None)\n # keep track of possible changes at this layer\n all_changes_rc = {}\n ... | import argparse, itertools, json, pickle, random, sys, time
import solvers, util, util_graph
import networkx as nx
CONNECT_REACH = 'reach'
CONNECT_LAYER = 'layer'
CONNECT_LIST = [CONNECT_REACH, CONNECT_LAYER]
EDGEOPT_FULL = 'full'
EDGEOPT_BAND = 'band'
EDGEOPT_GRID = 'grid'
EDGEOPT_RECT = 'rect'
EDGEOPT... |
if label_min:
for ll in label_min:
util.check(ll == util.DEFAULT_TEXT or ll in grd.node_labels, 'no label_min')
if label_max:
for ll in label_max:
util.check(ll == util.DEFAULT_TEXT or ll in grd.node_labels, 'no label_max')
if edgeopt == EDGEOPT_FULL:
util.... | {
"context_start_lineno": 0,
"file": "gdesc2graph.py",
"groundtruth_start_lineno": 18,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 19,
"task_id": "project_cc_python/7561"
} | {
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " # set up rep rules\n for rep_rules_index in range(len(mkiii_info.rep_rules)):\n if self._vars_pri is not None:\n ind_pri = self._solver.make_var()\n prev_inds_pri = lis... | timer_section('set up') |
{
"list": [
{
"filename": "util.py",
"retrieved_chunk": " self.first_term = None\nclass ResultInfo:\n def __init__(self):\n self.tile_level = None\n self.text_level = None\n self.image_level = None\n self.reach_info = None\n self.execution_info = None\n ... | import argparse, math, pickle, pprint, random, sys, time
import solvers, util
class Generator:
def __init__(self, solver, randomize, rows, cols, scheme_info, tag_level, game_level):
super().__init__()
self._solver = solver
self._rng = random.Random(randomize) if randomize else None
... |
res_info.reach_info.path_edges, res_info.reach_info.path_tiles, path_edge_keys = self._get_reach_path()
res_info.reach_info.offpath_edges = self._get_reach_offpath_edges(path_edge_keys)
res_info.tile_level = util.make_grid(self._rows, self._cols, util.VOID_TILE)
res_info.text_l... | {
"context_start_lineno": 0,
"file": "generator.py",
"groundtruth_start_lineno": 475,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 476,
"task_id": "project_cc_python/7554"
} | {
"list": [
{
"filename": "util.py",
"retrieved_chunk": "class SectionTimer:\n def __init__(self):\n self._start_time = time.time()\n self._last_section = None\n self._last_time = None\n def print_done(self):\n if not mute_time():\n print('--TOTALTIME %.2f'... | ResultReachInfo() |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " if text == util.START_TEXT:\n util.check(game_move.start_tile is None, 'multiple tiles with start text')\n game_move.start_tile = tile\n if text == util.GOAL_TEXT:\n ... | import util
RANDOM_PATH_INSET = 1
def point_path_from_edge_path(edge_path):
point_path = []
if len(edge_path) > 0:
(fr, fc, tr, tc) = edge_path[0]
point_path.append((fr, fc))
for (fr, fc, tr, tc) in edge_path:
util.check((fr, fc) == point_path[-1], 'edge path')
point_path.a... |
open_start_goal_text = open_text + util.START_TEXT + util.GOAL_TEXT
for rr in range(len(text_level)):
for cc in range(len(text_level[rr])):
if text_level[rr][cc] in open_start_goal_text:
are_open[(rr, cc)] = None
else:
are_closed[(rr, cc)] = Non... | {
"context_start_lineno": 0,
"file": "util_path.py",
"groundtruth_start_lineno": 90,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 91,
"task_id": "project_cc_python/7559"
} | {
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " ci.solver.cnstr_count(start_vvs_rem, True, 0, 0, None)\n goal_vvs_rem = sorted(list(set(goal_vvs_rem) - set(goal_vvs_00) - set(goal_vvs_01) - set(goal_vvs_10) - set(goal_vvs_11)))\n ci.solver.cnstr_count(goal_v... | START_TEXT not in open_text and util.GOAL_TEXT not in open_text, 'start/goal in open_text') |
{
"list": [
{
"filename": "custom.py",
"retrieved_chunk": " for cc in range(gen.get_cols()):\n out_text = self._out_text_level[rr][cc]\n if out_text != util.DEFAULT_TEXT:\n diff_tiles = [tile for tile, text in gen.get_scheme_info().tileset.ti... | import argparse, math, pickle, pprint, random, sys, time
import solvers, util
class Generator:
def __init__(self, solver, randomize, rows, cols, scheme_info, tag_level, game_level):
super().__init__()
self._solver = solver
self._rng = random.Random(randomize) if randomize else None
... |
return self._vars_rc_t[(rr, cc)][tile]
else:
util.check(tile == util.VOID_TILE, 'void tile')
return self._var_void_true
def _tile_has_var(self, rr, cc, tile):
if (rr, cc) in self._vars_rc_t:
return tile in self._vars_rc_t[(rr, cc)]
else:
... | {
"context_start_lineno": 0,
"file": "generator.py",
"groundtruth_start_lineno": 34,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 35,
"task_id": "project_cc_python/7549"
} | {
"list": [
{
"filename": "custom.py",
"retrieved_chunk": " self._rlo = rlo\n self._clo = clo\n self._rhi = rhi\n self._chi = chi\n self._tlo = tlo\n self._thi = thi\n self._out_texts = out_texts\n self._weight = weight\n def add(self, gen):\n... | VOID_TILE, 'void tile') |
{
"list": [
{
"filename": "file2file.py",
"retrieved_chunk": " f.write('\\n')\n elif util.fileistype(args.infile, '.jexplore') and util.fileistype(args.outfile, '.explore'):\n with util.openz(args.infile, 'rt') as f:\n ex = json2wrap(json.load(f), json2explore)\n ... | import sys
import util
import networkx as nx
ATTR_LABEL = 'label'
ATTR_POSITION = 'pos'
ATTR_HIGHLIGHT = 'highlight'
GTYPE_UTREE = 'utree'
GTYPE_DTREE = 'dtree'
GTYPE_DAG = 'dag'
GTYPE_UGRAPH = 'ugraph'
GTYPE_LIST = [GTYPE_UTREE, GTYPE_DTREE, GTYPE_DAG, GTYPE_UGRAPH]
LABEL_GRID_EAST = 'e'
LA... |
write_graph_dot(grs, outfile)
else:
write_graph(grs, outfile)
def layout_grid(gr):
roots = [nn for nn, dd in gr.in_degree() if dd == 0]
util.check(len(roots) == 1, 'grid does not have 1 root')
root = roots[0]
used_pos = {}
queue = [root]
gr.nodes[r... | {
"context_start_lineno": 0,
"file": "util_graph.py",
"groundtruth_start_lineno": 254,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 255,
"task_id": "project_cc_python/7546"
} | {
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " image_level = util.tile_level_to_image_level(tile_level, self._ex.tileset)\n image_filename = filename + '.png'\n filenames.append(image_filename)\n image_level.sav... | fileistype(filename, '.dot'): |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " if reach_move == RMOVE_MAZE:\n move_template.append(((-1, 0), [], [], []))\n move_template.append((( 1, 0), [], [], []))\n move_template.append((( 0, -1), [], [], []))\n move_template.append((( 0, 1), [], [], ... | import argparse, itertools, json, pickle, random, sys, time
import solvers, util, util_graph
import networkx as nx
CONNECT_REACH = 'reach'
CONNECT_LAYER = 'layer'
CONNECT_LIST = [CONNECT_REACH, CONNECT_LAYER]
EDGEOPT_FULL = 'full'
EDGEOPT_BAND = 'band'
EDGEOPT_GRID = 'grid'
EDGEOPT_RECT = 'rect'
EDGEOPT... |
edges_other_node.append(jj)
# missing node has no edges; using conj seems to work better than multiple individual implies
s.cnstr_implies_disj(vars_node_by_id[ii][None], True, [make_conj([edge[None] for edge in edges_vars], [True] * len(edges_vars))], True, None)
# apply from ... | {
"context_start_lineno": 0,
"file": "gdesc2graph.py",
"groundtruth_start_lineno": 336,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 337,
"task_id": "project_cc_python/7568"
} | {
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " need_open_aux = []\n need_closed = [(dr * (ii + 1), dc * (ii + 1))]\n move_template.append((dest, need_open_path, need_open_aux, need_closed))\n elif reach_move in [RMOVE_CLIMB, RMOVE_SUPERCAT, R... | DIR_FRA if jj < ii else util_graph.DIR_TIL)) |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " if reach_move == RMOVE_MAZE:\n move_template.append(((-1, 0), [], [], []))\n move_template.append((( 1, 0), [], [], []))\n move_template.append((( 0, -1), [], [], []))\n move_template.append((( 0, 1), [], [], ... | import argparse, itertools, json, pickle, random, sys, time
import solvers, util, util_graph
import networkx as nx
CONNECT_REACH = 'reach'
CONNECT_LAYER = 'layer'
CONNECT_LIST = [CONNECT_REACH, CONNECT_LAYER]
EDGEOPT_FULL = 'full'
EDGEOPT_BAND = 'band'
EDGEOPT_GRID = 'grid'
EDGEOPT_RECT = 'rect'
EDGEOPT... |
elif jj == ii + grid_stride:
s.cnstr_count([vars_edge_by_id_by_label[(ii, jj)][None], vars_edge_by_id_by_label[(ii, jj)][util_graph.LABEL_GRID_EAST]], True, 1, 1, None)
# how many nodes can be missing
s.cnstr_count(vars_nodes_by_label[None], True, 0, max_size - min_size, No... | {
"context_start_lineno": 0,
"file": "gdesc2graph.py",
"groundtruth_start_lineno": 91,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 92,
"task_id": "project_cc_python/7564"
} | {
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " need_open_aux = []\n need_closed = [(dr * (ii + 1), dc * (ii + 1))]\n move_template.append((dest, need_open_path, need_open_aux, need_closed))\n elif reach_move in [RMOVE_CLIMB, RMOVE_SUPERCAT, R... | LABEL_GRID_SOUTH]], True, 1, 1, None) |
{
"list": [
{
"filename": "util_graph.py",
"retrieved_chunk": " for fra, til, label in edges_and_labels(gr):\n if label == '':\n out.write(f'e {fra} {til}\\n')\n else:\n out.write(f'e {fra} {til} {label}\\n')\n for node in gr.nodes:\n if ATTR_POSITION i... | import argparse, itertools, json, pickle, random, sys, time
import util, util_graph
import networkx as nx
def graph_nbrs(gr, gtype, node):
nbrs = []
for fra, til, label in util_graph.edges_and_labels(gr):
nbr, dir_tag = None, None
if util_graph.gtype_directed(gtype):
if fra == no... |
grd = util_graph.GraphDesc()
grd.gtype = grs.gtype
grd.colors = grs.colors
grd.node_labels = {}
grd.edge_labels = {}
total_nodes = 0
for gr in grs.graphs:
total_nodes += len(gr.nodes)
for node, label in util_graph.nodes_and_labels(gr):
if label not in grd.n... | {
"context_start_lineno": 0,
"file": "graph2gdesc.py",
"groundtruth_start_lineno": 28,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 29,
"task_id": "project_cc_python/7579"
} | {
"list": [
{
"filename": "util_graph.py",
"retrieved_chunk": " if ATTR_HIGHLIGHT in gr.nodes[node]:\n out.write(f'h {node}\\n')\ndef write_graph_dot(grs, out):\n if gtype_directed(grs.gtype):\n dtype = 'digraph'\n dedge = '->'\n else:\n dtype = 'graph'\n ... | timer_section('extract') |
{
"list": [
{
"filename": "gdesc2summary.py",
"retrieved_chunk": "import argparse, itertools, json, pickle, random, sys, time\nimport util, util_graph\nimport networkx as nx\ndef gdesc2summary(grd):\n grs = util_graph.Graphs()\n grs.gtype = grd.gtype\n grs.colors = grd.colors\n grs.graphs ... | import sys
import util
import networkx as nx
ATTR_LABEL = 'label'
ATTR_POSITION = 'pos'
ATTR_HIGHLIGHT = 'highlight'
GTYPE_UTREE = 'utree'
GTYPE_DTREE = 'dtree'
GTYPE_DAG = 'dag'
GTYPE_UGRAPH = 'ugraph'
GTYPE_LIST = [GTYPE_UTREE, GTYPE_DTREE, GTYPE_DAG, GTYPE_UGRAPH]
LABEL_GRID_EAST = 'e'
LA... |
for line in infile:
if '#' in line:
line = line[:line.find('#')]
line = line.strip()
if len(line) == 0:
continue
splt = line.split()
if splt[0] == 't':
util.check(le... | {
"context_start_lineno": 0,
"file": "util_graph.py",
"groundtruth_start_lineno": 90,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 91,
"task_id": "project_cc_python/7545"
} | {
"list": [
{
"filename": "dot2graph.py",
"retrieved_chunk": " root_node = None\n for node in dot.nodes:\n if dot.nodes[node][util_graph.ATTR_LABEL] == args.root:\n util.check(root_node is None, 'multiple root nodes')\n root_node = node\n u... | openz(filename, 'rt') as infile: |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " if reach_move == RMOVE_MAZE:\n move_template.append(((-1, 0), [], [], []))\n move_template.append((( 1, 0), [], [], []))\n move_template.append((( 0, -1), [], [], []))\n move_template.append((( 0, 1), [], [], ... | import argparse, itertools, json, pickle, random, sys, time
import solvers, util, util_graph
import networkx as nx
CONNECT_REACH = 'reach'
CONNECT_LAYER = 'layer'
CONNECT_LIST = [CONNECT_REACH, CONNECT_LAYER]
EDGEOPT_FULL = 'full'
EDGEOPT_BAND = 'band'
EDGEOPT_GRID = 'grid'
EDGEOPT_RECT = 'rect'
EDGEOPT... |
missing_edges = vars_edges_by_label[None]
missing_nodes = vars_nodes_by_label[None]
s.cnstr_count(missing_edges + missing_nodes, [False] * len(missing_edges) + [True] * len(missing_nodes), max_size - 1, max_size - 1, None)
# node label counts
for ll in grd.node_labels:
ll_min, ... | {
"context_start_lineno": 0,
"file": "gdesc2graph.py",
"groundtruth_start_lineno": 146,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 147,
"task_id": "project_cc_python/7566"
} | {
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " need_open_aux = []\n need_closed = [(dr * (ii + 1), dc * (ii + 1))]\n move_template.append((dest, need_open_path, need_open_aux, need_closed))\n elif reach_move in [RMOVE_CLIMB, RMOVE_SUPERCAT, R... | gtype_tree(grd.gtype): |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " if reach_move == RMOVE_MAZE:\n move_template.append(((-1, 0), [], [], []))\n move_template.append((( 1, 0), [], [], []))\n move_template.append((( 0, -1), [], [], []))\n move_template.append((( 0, 1), [], [], ... | import argparse, itertools, json, pickle, random, sys, time
import solvers, util, util_graph
import networkx as nx
CONNECT_REACH = 'reach'
CONNECT_LAYER = 'layer'
CONNECT_LIST = [CONNECT_REACH, CONNECT_LAYER]
EDGEOPT_FULL = 'full'
EDGEOPT_BAND = 'band'
EDGEOPT_GRID = 'grid'
EDGEOPT_RECT = 'rect'
EDGEOPT... |
# how many nodes can be missing
s.cnstr_count(vars_nodes_by_label[None], True, 0, max_size - min_size, None)
# connected
if connect == CONNECT_REACH:
vars_node_connect = []
for ii in range(max_size):
vars_node_connect.append(s.make_var())
for ii in range(max_size)... | {
"context_start_lineno": 0,
"file": "gdesc2graph.py",
"groundtruth_start_lineno": 93,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 94,
"task_id": "project_cc_python/7565"
} | {
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " need_open_aux = []\n need_closed = [(dr * (ii + 1), dc * (ii + 1))]\n move_template.append((dest, need_open_path, need_open_aux, need_closed))\n elif reach_move in [RMOVE_CLIMB, RMOVE_SUPERCAT, R... | LABEL_GRID_EAST]], True, 1, 1, None) |
{
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " if ll > 0:\n self._solver.cnstr_implies_disj(self._vars_term[ll], True, [self._vars_term[ll + 1]], True, None)\n # keep track of possible changes at this layer\n all_changes_rc = {}\n ... | import argparse, itertools, json, pickle, random, sys, time
import solvers, util, util_graph
import networkx as nx
CONNECT_REACH = 'reach'
CONNECT_LAYER = 'layer'
CONNECT_LIST = [CONNECT_REACH, CONNECT_LAYER]
EDGEOPT_FULL = 'full'
EDGEOPT_BAND = 'band'
EDGEOPT_GRID = 'grid'
EDGEOPT_RECT = 'rect'
EDGEOPT... |
if label_max:
for ll in label_max:
util.check(ll == util.DEFAULT_TEXT or ll in grd.node_labels, 'no label_max')
if edgeopt == EDGEOPT_FULL:
util.check(len(edgeopt_params) == 0, 'edgeopt_params')
elif edgeopt == EDGEOPT_BAND:
util.check(len(edgeopt_params) == 1, 'edgeopt... | {
"context_start_lineno": 0,
"file": "gdesc2graph.py",
"groundtruth_start_lineno": 22,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 23,
"task_id": "project_cc_python/7563"
} | {
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " # set up rep rules\n for rep_rules_index in range(len(mkiii_info.rep_rules)):\n if self._vars_pri is not None:\n ind_pri = self._solver.make_var()\n prev_inds_pri = lis... | DEFAULT_TEXT or ll in grd.node_labels, 'no label_min') |
{
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " if ll > 0:\n self._solver.cnstr_implies_disj(self._vars_term[ll], True, [self._vars_term[ll + 1]], True, None)\n # keep track of possible changes at this layer\n all_changes_rc = {}\n ... | import argparse, itertools, json, pickle, random, sys, time
import solvers, util, util_graph
import networkx as nx
CONNECT_REACH = 'reach'
CONNECT_LAYER = 'layer'
CONNECT_LIST = [CONNECT_REACH, CONNECT_LAYER]
EDGEOPT_FULL = 'full'
EDGEOPT_BAND = 'band'
EDGEOPT_GRID = 'grid'
EDGEOPT_RECT = 'rect'
EDGEOPT... |
if label_max:
for ll in label_max:
util.check(ll == util.DEFAULT_TEXT or ll in grd.node_labels, 'no label_max')
if edgeopt == EDGEOPT_FULL:
util.check(len(edgeopt_params) == 0, 'edgeopt_params')
elif edgeopt == EDGEOPT_BAND:
util.check(len(edgeopt_params) == 1, 'edgeopt... | {
"context_start_lineno": 0,
"file": "gdesc2graph.py",
"groundtruth_start_lineno": 22,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 23,
"task_id": "project_cc_python/7562"
} | {
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " # set up rep rules\n for rep_rules_index in range(len(mkiii_info.rep_rules)):\n if self._vars_pri is not None:\n ind_pri = self._solver.make_var()\n prev_inds_pri = lis... | check(ll == util.DEFAULT_TEXT or ll in grd.node_labels, 'no label_min') |
{
"list": [
{
"filename": "gdesc2graph.py",
"retrieved_chunk": " util.check(label != False, 'no label')\n if label is not None:\n gr.add_edge(ii, jj)\n gr.edges[(ii, jj)][util_graph.ATTR_LABEL] = label\n util_graph.check_graph(gr, grd.gtype)\n... | import sys
import util
import networkx as nx
ATTR_LABEL = 'label'
ATTR_POSITION = 'pos'
ATTR_HIGHLIGHT = 'highlight'
GTYPE_UTREE = 'utree'
GTYPE_DTREE = 'dtree'
GTYPE_DAG = 'dag'
GTYPE_UGRAPH = 'ugraph'
GTYPE_LIST = [GTYPE_UTREE, GTYPE_DTREE, GTYPE_DAG, GTYPE_UGRAPH]
LABEL_GRID_EAST = 'e'
LA... |
def gtype_tree(gtype):
if gtype in [GTYPE_UTREE, GTYPE_DTREE]:
return True
elif gtype in [GTYPE_DAG, GTYPE_UGRAPH]:
return False
else:
util.check(False, 'Unknown gtype ' + str(gtype))
def check_graph(gr, gtype):
util.check(len(gr.nodes) > 0, 'no nodes')
if gtype_directed(... | {
"context_start_lineno": 0,
"file": "util_graph.py",
"groundtruth_start_lineno": 49,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 50,
"task_id": "project_cc_python/7544"
} | {
"list": [
{
"filename": "gdesc2summary.py",
"retrieved_chunk": " for ni, (nbr_node_label, nbr_edge_label, nbr_edge_dir) in enumerate(nbrs):\n nbr_node = f'{gid}:{ni}'\n if nbr_edge_dir == util_graph.DIR_TIL or nbr_edge_dir is None:\n edge =... | check(False, 'Unknown gtype ' + str(gtype)) |
{
"list": [
{
"filename": "gdesc2summary.py",
"retrieved_chunk": " for nbrs in grd.node_label_neighbors[label]:\n gid = len(grs.graphs)\n if util_graph.gtype_directed(grd.gtype):\n gr = nx.DiGraph()\n else:\n gr = nx.Graph()\n ... | import argparse, itertools, json, pickle, random, sys, time
import solvers, util, util_graph
import networkx as nx
CONNECT_REACH = 'reach'
CONNECT_LAYER = 'layer'
CONNECT_LIST = [CONNECT_REACH, CONNECT_LAYER]
EDGEOPT_FULL = 'full'
EDGEOPT_BAND = 'band'
EDGEOPT_GRID = 'grid'
EDGEOPT_RECT = 'rect'
EDGEOPT... |
for edge_inds in edge_inds_set:
for nbrs_perm in itertools.permutations(range(len(nbrs))):
nodes = []
edges = [ev[None] for ev in edges_vars]
for edge_ind, nbr_ind in zip(edge_inds, nbrs_perm):
... | {
"context_start_lineno": 0,
"file": "gdesc2graph.py",
"groundtruth_start_lineno": 346,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 347,
"task_id": "project_cc_python/7570"
} | {
"list": [
{
"filename": "graph2gdesc.py",
"retrieved_chunk": " nbr_labels = []\n nbrs = graph_nbrs(gr, grd.gtype, node)\n for nbr_node, nbr_edge_label, nbr_edge_dir in nbrs:\n if edgesonly:\n nbr_node_label = None\n el... | corner_indices(len(edges_vars), len(nbrs)) |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " if reach_move == RMOVE_MAZE:\n move_template.append(((-1, 0), [], [], []))\n move_template.append((( 1, 0), [], [], []))\n move_template.append((( 0, -1), [], [], []))\n move_template.append((( 0, 1), [], [], ... | import argparse, itertools, json, pickle, random, sys, time
import solvers, util, util_graph
import networkx as nx
CONNECT_REACH = 'reach'
CONNECT_LAYER = 'layer'
CONNECT_LIST = [CONNECT_REACH, CONNECT_LAYER]
EDGEOPT_FULL = 'full'
EDGEOPT_BAND = 'band'
EDGEOPT_GRID = 'grid'
EDGEOPT_RECT = 'rect'
EDGEOPT... |
edges_other_node.append(jj)
# missing node has no edges; using conj seems to work better than multiple individual implies
s.cnstr_implies_disj(vars_node_by_id[ii][None], True, [make_conj([edge[None] for edge in edges_vars], [True] * len(edges_vars))], True, None)
# apply from ... | {
"context_start_lineno": 0,
"file": "gdesc2graph.py",
"groundtruth_start_lineno": 336,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 337,
"task_id": "project_cc_python/7567"
} | {
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " need_open_aux = []\n need_closed = [(dr * (ii + 1), dc * (ii + 1))]\n move_template.append((dest, need_open_path, need_open_aux, need_closed))\n elif reach_move in [RMOVE_CLIMB, RMOVE_SUPERCAT, R... | gtype_directed(grd.gtype) else (util_graph.DIR_FRA if jj < ii else util_graph.DIR_TIL)) |
{
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " else:\n parser.error('must use --size, --tagfile or --gamefile')\n reach_setup = None\n if args.reach_move or args.reach_goal:\n if not args.reach_move or not args.reach_goal:\n parser.error('must use ... | import util
RMOVE_MAZE = 'maze'
RMOVE_TOMB = 'tomb'
RMOVE_CLIMB = 'climb'
RMOVE_SUPERCAT = 'supercat'
RMOVE_SUPERCAT2 = 'supercat2'
RMOVE_PLATFORM = 'platform'
RMOVE_LIST = [RMOVE_MAZE, RMOVE_TOMB, RMOVE_SUPERCAT, RMOVE_SUPERCAT2, RM... |
reach_info.start_rcs = []
reach_info.goal_rcs = []
def r_all(_st, _gl):
for _rr in range(rows):
for _cc in range(cols):
_st.append((_rr, _cc))
_gl.append((_rr, _cc))
def r_set(_sr, _sc, _gr, _gc, _st, _gl):
_st.append((_sr, _sc))
... | {
"context_start_lineno": 0,
"file": "reach.py",
"groundtruth_start_lineno": 139,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 140,
"task_id": "project_cc_python/7540"
} | {
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " if args.reach_goal[0] not in reach.RGOAL_DICT:\n parser.error('--reach-goal[0] must be in ' + ','.join(reach.RGOAL_DICT.key()))\n reach_setup.goal_loc = args.reach_goal[0]\n if len(args.reach_goal[1:]) !... | ReachabilityInfo() |
{
"list": [
{
"filename": "util.py",
"retrieved_chunk": " if tile_level[rr][cc] != VOID_TILE:\n text_level[rr][cc] = tileset.tile_to_text[tile_level[rr][cc]]\n return text_level\ndef tile_level_to_image_level(tile_level, tileset):\n rows, cols = len(tile_level), len(til... | import argparse, os, shutil, pickle, sys
import util, util_graph
import networkx as nx
def tiles2graph(tile_info, text_labels):
util.check(len(tile_info.levels) == 1, 'only handles one tile level')
if text_labels:
util.check(tile_info.tileset.tile_to_text, 'no text')
tile_level = tile_info.leve... |
for rr in range(rows):
for cc in range(cols):
if rr + 1 < rows:
gr.add_edge(nodeid(rr, cc), nodeid(rr + 1, cc))
gr.edges[(nodeid(rr, cc), nodeid(rr + 1, cc))][util_graph.ATTR_LABEL] = util_graph.LABEL_GRID_SOUTH
if cc + 1 < cols:
gr.a... | {
"context_start_lineno": 0,
"file": "tile2graph.py",
"groundtruth_start_lineno": 29,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 30,
"task_id": "project_cc_python/7589"
} | {
"list": [
{
"filename": "util.py",
"retrieved_chunk": " return image_level\ndef get_meta_path(meta):\n if meta is not None:\n for md in meta:\n if md['type'] == 'geom' and md['shape'] == 'path' and md['group'] == MGROUP_PATH:\n return [tuple(elem) for elem in m... | ATTR_LABEL] = node_label |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " if reach_move == RMOVE_MAZE:\n move_template.append(((-1, 0), [], [], []))\n move_template.append((( 1, 0), [], [], []))\n move_template.append((( 0, -1), [], [], []))\n move_template.append((( 0, 1), [], [], ... | import argparse, itertools, json, pickle, random, sys, time
import solvers, util, util_graph
import networkx as nx
CONNECT_REACH = 'reach'
CONNECT_LAYER = 'layer'
CONNECT_LIST = [CONNECT_REACH, CONNECT_LAYER]
EDGEOPT_FULL = 'full'
EDGEOPT_BAND = 'band'
EDGEOPT_GRID = 'grid'
EDGEOPT_RECT = 'rect'
EDGEOPT... |
edges_other_node.append(jj)
# missing node has no edges; using conj seems to work better than multiple individual implies
s.cnstr_implies_disj(vars_node_by_id[ii][None], True, [make_conj([edge[None] for edge in edges_vars], [True] * len(edges_vars))], True, None)
# apply from ... | {
"context_start_lineno": 0,
"file": "gdesc2graph.py",
"groundtruth_start_lineno": 336,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 337,
"task_id": "project_cc_python/7569"
} | {
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " need_open_aux = []\n need_closed = [(dr * (ii + 1), dc * (ii + 1))]\n move_template.append((dest, need_open_path, need_open_aux, need_closed))\n elif reach_move in [RMOVE_CLIMB, RMOVE_SUPERCAT, R... | DIR_TIL)) |
{
"list": [
{
"filename": "solvers-test.py",
"retrieved_chunk": " for solver_id in solvers_to_test:\n for use_portfolio in [False, True]:\n for use_weight in [None, 1]:\n if solver_id in [solvers.SOLVER_CVC5, solvers.SOLVER_PYSAT_MC] and use_weight is not None:\n ... | import json, multiprocessing, queue, random, sys
import util
try:
available_z3 = False
import z3
available_z3 = True
except ImportError:
pass
try:
available_cvc5 = False
import cvc5.pythonic
available_cvc5 = True
except ImportError:
pass
try:
available_clingo = False
import cl... |
class Solver:
def __init__(self, solver_id):
self._solver_id = solver_id
def get_id(self):
return self._solver_id
def make_var(self):
util.check(False, 'unimplemented')
def make_conj(self, vvs, settings):
util.check(False, 'unimplemented')
def cnstr_implies_di... | {
"context_start_lineno": 0,
"file": "solvers.py",
"groundtruth_start_lineno": 78,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 79,
"task_id": "project_cc_python/7596"
} | {
"list": [
{
"filename": "solvers-test.py",
"retrieved_chunk": " else:\n solver = solvers.solver_id_to_solver(solver_id)\n vvs = [solver.make_var() for ii in range(nvars)]\n setup(solver, use_weight, *vvs)\n ... | check(False, 'solver ' + solver_id + ' unrecognized.') |
{
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " def add_constraint_tile_counts(self, rcs, tiles, lo, hi, weight_counts):\n util.check(lo <= hi, 'counts')\n util.check(weight_counts is None or weight_counts > 0, 'weight')\n vvs = [self._tile_var(rr, cc, tile) for ... | import json, multiprocessing, queue, random, sys
import util
try:
available_z3 = False
import z3
available_z3 = True
except ImportError:
pass
try:
available_cvc5 = False
import cvc5.pythonic
available_cvc5 = True
except ImportError:
pass
try:
available_clingo = False
import cl... |
self._s.set_on_model(on_model)
chk = self._s.check()
util.write_time('\n')
util.write_time(str(chk) + '\n')
if chk == z3.unsat:
return False
if chk == z3.unknown:
util.write_time(str(self._s.reason_unknown()) + '\n')
return False
... | {
"context_start_lineno": 0,
"file": "solvers.py",
"groundtruth_start_lineno": 446,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 447,
"task_id": "project_cc_python/7598"
} | {
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " fr, fc, tr, tc, pwtc, need_open_path, need_open_aux, need_closed = edge_key\n edges[(fr, fc, tr, tc, pwtc)] = None\n return edges\n def add_constraint_reach_edge(self, cfr, cfc, ctr, ctc, cpwtc, on_path, wei... | write_time('.') |
{
"list": [
{
"filename": "graph2gdesc.py",
"retrieved_chunk": " nbr_labels = []\n nbrs = graph_nbrs(gr, grd.gtype, node)\n for nbr_node, nbr_edge_label, nbr_edge_dir in nbrs:\n if edgesonly:\n nbr_node_label = None\n el... | import argparse, itertools, json, pickle, random, sys, time
import util, util_graph
import networkx as nx
def gdesc2summary(grd):
grs = util_graph.Graphs()
grs.gtype = grd.gtype
grs.colors = grd.colors
grs.graphs = []
result = grs
for label in grd.node_labels:
for nbrs in grd.node_la... |
edge = (central_node, nbr_node)
elif nbr_edge_dir == util_graph.DIR_FRA:
edge = (nbr_node, central_node)
else:
util.check(False, 'nbr_edge_dir')
gr.add_node(nbr_node)
gr.nodes[nbr_node][util_gra... | {
"context_start_lineno": 0,
"file": "gdesc2summary.py",
"groundtruth_start_lineno": 31,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 32,
"task_id": "project_cc_python/7603"
} | {
"list": [
{
"filename": "graph2gdesc.py",
"retrieved_chunk": " grd.node_label_neighbors[label].append(nbr_labels)\n for label in grd.node_labels:\n grd.node_label_count[label] = grd.node_label_count[label] / total_nodes\n grd.node_label_neighbors[label] = sorted(grd.n... | DIR_TIL or nbr_edge_dir is None: |
{
"list": [
{
"filename": "portfolio.py",
"retrieved_chunk": " for solver, proc, tfile in procs:\n if proc.poll() is not None:\n completed_procs.append((solver, proc, tfile))\n if len(completed_procs) != 0:\n break\n if time.time() - time_start... | import json, multiprocessing, queue, random, sys
import util
try:
available_z3 = False
import z3
available_z3 = True
except ImportError:
pass
try:
available_cvc5 = False
import cvc5.pythonic
available_cvc5 = True
except ImportError:
pass
try:
available_clingo = False
import cl... |
for proc in procs:
proc.kill()
if result is None:
return False
else:
index, self._result, self._objective = result
util.write_portfolio('portfolio using %d %s\n' % (index, self._solver_ids[index]))
return True
def get_var(self, ... | {
"context_start_lineno": 0,
"file": "solvers.py",
"groundtruth_start_lineno": 262,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 263,
"task_id": "project_cc_python/7597"
} | {
"list": [
{
"filename": "portfolio.py",
"retrieved_chunk": " outs.append((solver, out))\n for solver, proc, tfile in procs:\n proc.kill()\n models = []\n for solver, out in outs:\n print('c output from', solver)\n model = None\n for line in out.split('\\n'... | write_portfolio('portfolio timeout\n') |
{
"list": [
{
"filename": "graph2gdesc.py",
"retrieved_chunk": " nbr_labels = []\n nbrs = graph_nbrs(gr, grd.gtype, node)\n for nbr_node, nbr_edge_label, nbr_edge_dir in nbrs:\n if edgesonly:\n nbr_node_label = None\n el... | import argparse, itertools, json, pickle, random, sys, time
import util, util_graph
import networkx as nx
def gdesc2summary(grd):
grs = util_graph.Graphs()
grs.gtype = grd.gtype
grs.colors = grd.colors
grs.graphs = []
result = grs
for label in grd.node_labels:
for nbrs in grd.node_la... |
gr.add_node(nbr_node)
gr.nodes[nbr_node][util_graph.ATTR_LABEL] = nbr_node_label
gr.add_edge(edge[0], edge[1])
gr.edges[edge][util_graph.ATTR_LABEL] = nbr_edge_label
grs.graphs.append(gr)
return grs
if __name__ == '__main__':
ut... | {
"context_start_lineno": 0,
"file": "gdesc2summary.py",
"groundtruth_start_lineno": 36,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 37,
"task_id": "project_cc_python/7605"
} | {
"list": [
{
"filename": "graph2gdesc.py",
"retrieved_chunk": " grd.node_label_neighbors[label].append(nbr_labels)\n for label in grd.node_labels:\n grd.node_label_count[label] = grd.node_label_count[label] / total_nodes\n grd.node_label_neighbors[label] = sorted(grd.n... | check(False, 'nbr_edge_dir') |
{
"list": [
{
"filename": "util.py",
"retrieved_chunk": "class SectionTimer:\n def __init__(self):\n self._start_time = time.time()\n self._last_section = None\n self._last_time = None\n def print_done(self):\n if not mute_time():\n print('--TOTALTIME %.2f'... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
if outfile is not None:
outfile_file = util.openz(outfile + '.log', 'wt')
sys.stdout = outfile_file
with util.openz(schemefile, 'rb') as f:
scheme_info = pickle.load(f)
tag_game_level = util.make_grid(rows, cols, util.DEFAULT_TEXT)
solver = solvers... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 117,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 118,
"task_id": "project_cc_python/7608"
} | {
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " self._tind_to_image = {}\n self._avg_color = 'lightgray'\n if len(self._ex.tind_to_image) > 0:\n image_sizes = math.ceil(math.sqrt(len(self._ex.tind_to_image)))\n if image_sizes >= 8:\n ... | timer_start(False) |
{
"list": [
{
"filename": "graph2dot.py",
"retrieved_chunk": " grs = util_graph.read_graphs(args.graphfile)\n if args.grid:\n util_graph.layout_grid(grs.graphs[0])\n if args.outfile is None:\n util_graph.write_graph_dot(grs, sys.stdout)\n else:\n with util.openz(args.o... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
sys.stdout = outfile_file
with util.openz(schemefile, 'rb') as f:
scheme_info = pickle.load(f)
tag_game_level = util.make_grid(rows, cols, util.DEFAULT_TEXT)
solver = solvers.PySatSolverRC2()
reach_setup = util.ReachabilitySetup()
reach_setup.wrap_cols... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 120,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 121,
"task_id": "project_cc_python/7609"
} | {
"list": [
{
"filename": "util.py",
"retrieved_chunk": " if self._last_section is not None:\n if mute_time():\n print('...%s done' % self._last_section, flush=True)\n else:\n last = '%.2f' % (curr_time - self._last_time)\n tota... | openz(outfile + '.log', 'wt') |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " _st.append((rows - 1 - _rr, cols - 1 - _cc))\n _gl.append((_rr, _cc))\n if reach_setup.goal_loc == RGOAL_ALL:\n r_all(reach_info.start_rcs, reach_info.goal_rcs)\n elif reach_setup.goal_loc == RGOAL_SE... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
result_info = scheme2output.scheme2output(scheme_info, tag_game_level, tag_game_level, solver, seed, WEIGHT_PATTERN, WEIGHT_COUNTS, scheme2output.COUNTS_SCALE_HALF, reach_setup, None, custom_cnstrs, False)
if outfile is not None and result_info is not None:
print('saving to', outfile)
... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 140,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 141,
"task_id": "project_cc_python/7617"
} | {
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " elif reach_setup.goal_loc == RGOAL_T_B:\n r_top_to_bottom(reach_setup.goal_params[0], reach_info.start_rcs, reach_info.goal_rcs)\n elif reach_setup.goal_loc == RGOAL_TL_BR:\n r_topleft_to_botright(reach_setup.goal_params[0]... | OutPathConstraint(path_points, WEIGHT_PATH)) |
{
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " self._xoffset = 0\n self._yoffset = 0\n width = self._display_w + (len(self._displays) - 1) * self._display_dx + INSET - FRAME\n height = self._display_h + (len(self._displays) - 1) * self._display_dy + INSET - F... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
self._schemefile = schemefile
self._outfolder = outfolder
self._path_open = {}
self._path_closed = {}
self._path_nexts = None
self._working_draw = []
self._gen_objective = None
self._mouse = None
self._draw_open_closed = False
self._mo... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 60,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 61,
"task_id": "project_cc_python/7607"
} | {
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " if self._ex.npind > 0:\n for ii in range(self._ex.npind):\n chk_var = tkinter.IntVar()\n chk = tkinter.Checkbutton(self._sidebar, text=self._ex.pind_to_prop[ii], anchor=tkinter.W, variable=chk... | get_move_template(self._move_template)) |
{
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " else:\n parser.error('must use --size, --tagfile or --gamefile')\n reach_setup = None\n if args.reach_move or args.reach_goal:\n if not args.reach_move or not args.reach_goal:\n parser.error('must use ... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
if path_points is not None:
custom_cnstrs.append(custom.OutPathConstraint(path_points, WEIGHT_PATH))
result_info = scheme2output.scheme2output(scheme_info, tag_game_level, tag_game_level, solver, seed, WEIGHT_PATTERN, WEIGHT_COUNTS, scheme2output.COUNTS_SCALE_HALF, reach_setup, None, custo... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 138,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 139,
"task_id": "project_cc_python/7616"
} | {
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " if args.reach_goal[0] not in reach.RGOAL_DICT:\n parser.error('--reach-goal[0] must be in ' + ','.join(reach.RGOAL_DICT.key()))\n reach_setup.goal_loc = args.reach_goal[0]\n if len(args.reach_goal[1:]) !... | OutPathEndsConstraint(start_goal[0], start_goal[1], start_goal[2], start_goal[3], WEIGHT_PATH)) |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " _st.append((rows - 1 - _rr, cols - 1 - _cc))\n _gl.append((_rr, _cc))\n if reach_setup.goal_loc == RGOAL_ALL:\n r_all(reach_info.start_rcs, reach_info.goal_rcs)\n elif reach_setup.goal_loc == RGOAL_SE... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
if outfile is not None and result_info is not None:
print('saving to', outfile)
util.save_result_info(result_info, outfile)
encode_result_info(result_info, want_image)
q.put(result_info)
if result_info:
util.exit_solution_found()
else:
... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 142,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 143,
"task_id": "project_cc_python/7618"
} | {
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " elif reach_setup.goal_loc == RGOAL_T_B:\n r_top_to_bottom(reach_setup.goal_params[0], reach_info.start_rcs, reach_info.goal_rcs)\n elif reach_setup.goal_loc == RGOAL_TL_BR:\n r_topleft_to_botright(reach_setup.goal_params[0]... | scheme2output(scheme_info, tag_game_level, tag_game_level, solver, seed, WEIGHT_PATTERN, WEIGHT_COUNTS, scheme2output.COUNTS_SCALE_HALF, reach_setup, None, custom_cnstrs, False) |
{
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " self._xoffset = 0\n self._yoffset = 0\n width = self._display_w + (len(self._displays) - 1) * self._display_dx + INSET - FRAME\n height = self._display_h + (len(self._displays) - 1) * self._display_dy + INSET - F... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
self._schemefile = schemefile
self._outfolder = outfolder
self._path_open = {}
self._path_closed = {}
self._path_nexts = None
self._working_draw = []
self._gen_objective = None
self._mouse = None
self._draw_open_closed = False
self._mo... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 60,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 61,
"task_id": "project_cc_python/7606"
} | {
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " if self._ex.npind > 0:\n for ii in range(self._ex.npind):\n chk_var = tkinter.IntVar()\n chk = tkinter.Checkbutton(self._sidebar, text=self._ex.pind_to_prop[ii], anchor=tkinter.W, variable=chk... | get_template_open_closed(reach.get_move_template(self._move_template)) |
{
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " counts_scale = COUNTS_SCALE_ZERO\n else:\n counts_scale = COUNTS_SCALE_HALF\n result_info = scheme2output(scheme_info, tag_level, game_level, solver, args.randomize, weight_patterns, weight_counts, counts_scale, rea... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
encode_result_info(result_info, want_image)
q.put(result_info)
if result_info:
util.exit_solution_found()
else:
util.exit_solution_not_found()
def on_timer(self):
if self._gen_proc is not None:
if not self._gen_proc.is_alive():
... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 146,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 147,
"task_id": "project_cc_python/7620"
} | {
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " counts_scale = COUNTS_SCALE_ZERO\n else:\n counts_scale = COUNTS_SCALE_HALF\n result_info = scheme2output(scheme_info, tag_level, game_level, solver, args.randomize, weight_patterns, weight_counts, counts_scale, rea... | save_result_info(result_info, outfile) |
{
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " _st.append((rows - 1 - _rr, cols - 1 - _cc))\n _gl.append((_rr, _cc))\n if reach_setup.goal_loc == RGOAL_ALL:\n r_all(reach_info.start_rcs, reach_info.goal_rcs)\n elif reach_setup.goal_loc == RGOAL_SE... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
if outfile is not None and result_info is not None:
print('saving to', outfile)
util.save_result_info(result_info, outfile)
encode_result_info(result_info, want_image)
q.put(result_info)
if result_info:
util.exit_solution_found()
else:
... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 142,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 143,
"task_id": "project_cc_python/7619"
} | {
"list": [
{
"filename": "reach.py",
"retrieved_chunk": " elif reach_setup.goal_loc == RGOAL_T_B:\n r_top_to_bottom(reach_setup.goal_params[0], reach_info.start_rcs, reach_info.goal_rcs)\n elif reach_setup.goal_loc == RGOAL_TL_BR:\n r_topleft_to_botright(reach_setup.goal_params[0]... | COUNTS_SCALE_HALF, reach_setup, None, custom_cnstrs, False) |
{
"list": [
{
"filename": "explore2summary.py",
"retrieved_chunk": " for tinds, tile in ex.tinds_to_tile.items():\n tile_to_tinds[tile] = tinds\n tiles_strings = []\n for tile in ex.tileset.tile_ids:\n tile_string = str(tile) + ':'\n for tind in tile_to_tinds[tile]:\n ... | import argparse, glob, gzip, math, os, pickle, random, sys, threading, time
import util, util_explore
import numpy as np
import PIL.Image, PIL.ImageDraw, PIL.ImageTk
import tkinter, tkinter.messagebox
def one_hot(rows, cols, ntind, neind, npind, levels, einds, pinds):
a = np.zeros((len(levels), rows, cols, ntind... |
if tile_info.levels is not None:
for tli in tile_info.levels:
path = util.get_meta_path(tli.meta)
properties = util.get_meta_properties(tli.meta)
add_level(tli.tiles, path, properties)
if resultfiles is no... | {
"context_start_lineno": 0,
"file": "levels2explore.py",
"groundtruth_start_lineno": 193,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 194,
"task_id": "project_cc_python/7629"
} | {
"list": [
{
"filename": "explore2summary.py",
"retrieved_chunk": " tiles_strings.append(tile_string)\n print('tiles:', ' '.join(tiles_strings))\n print('void tile:', 'yes' if ex.void_tind is not None else 'no')\n print('properties:', '; '.join(ex.pind_to_prop.values()))\n if summa... | check_tileset_match(tileset, tile_info.tileset) |
{
"list": [
{
"filename": "generator.py",
"retrieved_chunk": "import argparse, math, pickle, pprint, random, sys, time\nimport solvers, util\nclass Generator:\n def __init__(self, solver, randomize, rows, cols, scheme_info, tag_level, game_level):\n super().__init__()\n self._solver =... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
self.new_manual_path(False)
def on_key_s(self, event):
if len(self._path) >= 2:
self._path = util_path.shortest_path_between(self._path[0], self._path[-1], self._rows, self._cols, self._template_open_closed, {}, {})
self.new_manual_path(False)
def on_key_w(self, event)... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 378,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 379,
"task_id": "project_cc_python/7625"
} | {
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " if self._thread is not None:\n return\n if self._mouse is not None:\n mr, mc, md, mi = self._mouse\n if mi is not None:\n if self._show_paths == PATH_EDIT... | random_path_by_search(rng, self._rows, self._cols, self._template_open_closed) |
{
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " x0, y1,\n x0, y1-cn, x0, y1-cn,\n x0, y0+cn, x0, y0+cn,\n x0, y0,\n fi... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
pr0 += 0.5
pc0 += 0.5
pr1 += 0.5
pc1 += 0.5
dr = pr1 - pr0
dc = pc1 - pc0
ll = (dr ** 2 + dc ** 2) ** 0.5
dr /= ll
dc /= ll
SCL = 0.3
OFF = 0.0... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 258,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 259,
"task_id": "project_cc_python/7623"
} | {
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " def create_tiles_from_cell(self, draw_list, disp, rr, cc):\n indices_rc, indices_sqrt_rc, indices_disp = self.rem_indices(disp)\n indices = indices_rc[rr][cc]\n sqrt = indices_sqrt_rc[rr][cc]\n to = self._cell... | edge_path_from_point_path(points): |
{
"list": [
{
"filename": "pathed.py",
"retrieved_chunk": " self._path_nexts, self._path_open, self._path_closed = util_path.get_nexts_open_closed_from(self._path, self._reverse, self._rows, self._cols, self._template_open_closed)\n self.redraw_from_path()\n def new_manual_path(self, ... | import argparse, glob, gzip, math, os, pickle, random, sys, threading, time
import util, util_explore
import numpy as np
import PIL.Image, PIL.ImageDraw, PIL.ImageTk
import tkinter, tkinter.messagebox
def one_hot(rows, cols, ntind, neind, npind, levels, einds, pinds):
a = np.zeros((len(levels), rows, cols, ntind... |
tile_info = pickle.load(f)
if tileset == None:
tileset = tile_info.tileset
use_text = (tileset.tile_to_text is not None) and (not image_only)
use_image = (tileset.tile_to_image is not None) and (not text_only)
... | {
"context_start_lineno": 0,
"file": "levels2explore.py",
"groundtruth_start_lineno": 122,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 123,
"task_id": "project_cc_python/7628"
} | {
"list": [
{
"filename": "pathed.py",
"retrieved_chunk": " if len(self._path) > 0:\n self._path = self._path[1:]\n self.new_manual_path(True)\n def on_key_x(self, event):\n if self._schemefile:\n self._path = []\n self.new_manual_path(True)... | openz(tilefile, 'rb') as f: |
{
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " if self._mouse is None:\n self._draw_working.append(self._cvs.create_arc(INSET + 5, INSET + 5, INSET + 30, INSET + 30, outline=COLOR_OVER, width=3, style=tkinter.ARC, start=time.time() * 45.0, extent=300.0))\n ... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
self.redraw_from_path()
def new_manual_path(self, delay_proc):
self.recompute_nexts()
self.restart_gen_proc(PATH_DELAY_SEC if delay_proc else 0.0)
def on_key_backspace(self, event):
if len(self._path) > 0:
self._path = self._path[:-1]
self.new_manual_pa... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 332,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 333,
"task_id": "project_cc_python/7624"
} | {
"list": [
{
"filename": "explorer.py",
"retrieved_chunk": " if self._thread is not None:\n color_over = COLOR_INACTIVE\n else:\n color_over = COLOR_OVER\n if self._mouse is not None:\n mr, mc, md, mi = self._mouse\n ... | get_nexts_open_closed_from(self._path, self._reverse, self._rows, self._cols, self._template_open_closed) |
{
"list": [
{
"filename": "levels2explore.py",
"retrieved_chunk": " _level.insert(0, [_void_tind] * _cols)\n for ii in range(len(_path)):\n _path[ii] = (_path[ii][0] + 1, _path[ii][1], _path[ii][2] + 1, _path[ii][3])\n else:\n ... | import argparse, hashlib, io, math, multiprocessing, os, pickle, random, sys, time
import custom, reach, scheme2output, solvers, util, util_path
import PIL.Image, PIL.ImageTk
import tkinter
WEIGHT_PATH = 100
WEIGHT_PATTERN = None
WEIGHT_COUNTS = 1
INSET = 10
CELL_SIZE = 25
FRAME = ... |
self._path = util_path.shortest_path_between(self._gen_path[0], self._gen_path[-1], self._rows, self._cols, self._template_open_closed, are_open, are_closed)
self.new_manual_path(False)
def on_mouse_motion(self, event):
mr, mc = math.floor(fromcvs(event.y)), math.floor(fromcvs(even... | {
"context_start_lineno": 0,
"file": "pathed.py",
"groundtruth_start_lineno": 388,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 389,
"task_id": "project_cc_python/7627"
} | {
"list": [
{
"filename": "levels2explore.py",
"retrieved_chunk": " if tileset == None:\n tileset = tile_info.tileset\n use_text = (tileset.tile_to_text is not None) and (not image_only)\n use_image = (tileset.tile_to_image is not... | get_level_open_closed(self._gen_text, util.OPEN_TEXT) |
{
"list": [
{
"filename": "explore2summary.py",
"retrieved_chunk": " for tinds, tile in ex.tinds_to_tile.items():\n tile_to_tinds[tile] = tinds\n tiles_strings = []\n for tile in ex.tileset.tile_ids:\n tile_string = str(tile) + ':'\n for tind in tile_to_tinds[tile]:\n ... | import argparse, glob, gzip, math, os, pickle, random, sys, threading, time
import util, util_explore
import numpy as np
import PIL.Image, PIL.ImageDraw, PIL.ImageTk
import tkinter, tkinter.messagebox
def one_hot(rows, cols, ntind, neind, npind, levels, einds, pinds):
a = np.zeros((len(levels), rows, cols, ntind... |
properties = util.get_meta_properties(tli.meta)
add_level(tli.tiles, path, properties)
if resultfiles is not None:
for resultfile_glob in resultfiles:
for resultfile in glob.iglob(resultfile_glob):
with util.openz(resultfile, 'rb'... | {
"context_start_lineno": 0,
"file": "levels2explore.py",
"groundtruth_start_lineno": 197,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 198,
"task_id": "project_cc_python/7630"
} | {
"list": [
{
"filename": "explore2summary.py",
"retrieved_chunk": " tiles_strings.append(tile_string)\n print('tiles:', ' '.join(tiles_strings))\n print('void tile:', 'yes' if ex.void_tind is not None else 'no')\n print('properties:', '; '.join(ex.pind_to_prop.values()))\n if summa... | get_meta_path(tli.meta) |
{
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " for tag_row, game_row in zip(tag_level, game_level):\n util.check(len(tag_row) == len(game_row) == cols, 'row length mismatch')\n for tag, game in zip(tag_row, game_row):\n util.check(game != util.VOID_TEXT,... | import argparse, json, os, shutil, pickle, sys
import PIL.Image
import util
TILE_OUTPUT_FOLDER = 'tiles'
def get_tile_key(tile_text, tile_image):
tile_key = ()
if tile_text is not None:
tile_key = tile_key + (tile_text,)
if tile_image is not None:
tile_key = tile_key + (tuple(tile_imag... |
util.print_tile_level(tile_level)
print()
util.print_text_level(tag_level)
print()
util.print_text_level(game_level)
print()
if not no_levels:
tli = util.TileLevelInfo()
tli.tiles = tile_level
tli.tags = tag_level
... | {
"context_start_lineno": 0,
"file": "input2tile.py",
"groundtruth_start_lineno": 182,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 183,
"task_id": "project_cc_python/7641"
} | {
"list": [
{
"filename": "tile2scheme.py",
"retrieved_chunk": " util.check((tile == util.VOID_TILE) == (tag == util.VOID_TEXT), 'void')\n if tile == util.VOID_TILE:\n continue\n if game not in si.game_to_tag_to_tiles:\n ... | meta_path(path)) |
{
"list": [
{
"filename": "file2file.py",
"retrieved_chunk": " ts.tile_ids = dict.fromkeys(obj['tile_ids'])\n ts.tile_to_text = json2dict(obj['tile_to_text'])\n ts.tile_to_image = json2dict(obj['tile_to_image'], decode_val=decode_image)\n ts.tile_image_size = obj['tile_image_size']\n re... | import argparse, json, os, shutil, pickle, sys
import PIL.Image
import util
TILE_OUTPUT_FOLDER = 'tiles'
def get_tile_key(tile_text, tile_image):
tile_key = ()
if tile_text is not None:
tile_key = tile_key + (tile_text,)
if tile_image is not None:
tile_key = tile_key + (tuple(tile_imag... |
tile_key_to_tile_id[tile_key] = tile
else:
ts = util.TileSetInfo()
ts.tile_ids = {}
ts.tile_to_text = {} if text_levels else None
ts.tile_to_image = {} if image_levels else None
ts.tile_image_size = tile_image_size
ti = util.TileInfo()
ti.tileset = ts
... | {
"context_start_lineno": 0,
"file": "input2tile.py",
"groundtruth_start_lineno": 30,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 31,
"task_id": "project_cc_python/7633"
} | {
"list": [
{
"filename": "file2file.py",
"retrieved_chunk": " else:\n ti.levels = []\n for jtli in obj['levels']:\n tli = util.TileLevelInfo()\n tli.tiles = jtli['tiles']\n tli.tags = jtli['tags']\n tli.games = jtli['games']\n tl... | check(tile_key not in tile_key_to_tile_id, 'duplicate tile key in base tile info') |
{
"list": [
{
"filename": "gdesc2graph.py",
"retrieved_chunk": " if nodes is not None:\n patts.append(make_conj(edges + nodes, [True] * (len(edges) + len(nodes))))\n if len(patts) == 0:\n s.cnstr_count([vars_node_by_id[ii][lab... | import argparse, pickle, random, sys, time
import custom, generator, mkiii, reach, solvers, util
WEIGHT_PATTERNS = 10000
WEIGHT_COUNTS = 1
COUNTS_SCALE_HALF = (0.5, 1.5)
COUNTS_SCALE_ZERO = (0.0, 1e10)
def scheme2output(scheme_info, tag_level, game_level, solver, randomize, weight_pat... |
util.timer_section(None)
return result
if __name__ == '__main__':
util.timer_start()
parser = argparse.ArgumentParser(description='Create output from scheme.')
parser.add_argument('--outfile', required=True, type=str, help='Output file (without extension, which will be added).')
parser.a... | {
"context_start_lineno": 0,
"file": "scheme2output.py",
"groundtruth_start_lineno": 66,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 67,
"task_id": "project_cc_python/7657"
} | {
"list": [
{
"filename": "gdesc2graph.py",
"retrieved_chunk": " if util_graph.gtype_directed(grd.gtype):\n gr = nx.DiGraph()\n else:\n gr = nx.Graph()\n for ii, vvs in vars_node_by_id.items():\n label = False\n for ll, vv in vvs.items()... | print_result_info(result, False) |
{
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " solver = solvers.PortfolioSolver(args.solver, args.solver_portfolio_timeout)\n with util.openz(args.schemefile, 'rb') as f:\n scheme_info = pickle.load(f)\n if args.size:\n if args.tagfile or args.gamefile:\n... | import argparse, json, os, shutil, pickle, sys
import PIL.Image
import util
TILE_OUTPUT_FOLDER = 'tiles'
def get_tile_key(tile_text, tile_image):
tile_key = ()
if tile_text is not None:
tile_key = tile_key + (tile_text,)
if tile_image is not None:
tile_key = tile_key + (tuple(tile_imag... |
else:
text_levels = None
if args.imagefile is not None:
def open_and_load_image(fn):
with util.openz(fn, 'rb') as f:
img = PIL.Image.open(f)
img.load()
return img
image_levels = [open_and_load_image(imagefile) for imagefile in... | {
"context_start_lineno": 0,
"file": "input2tile.py",
"groundtruth_start_lineno": 252,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 253,
"task_id": "project_cc_python/7645"
} | {
"list": [
{
"filename": "scheme2output.py",
"retrieved_chunk": " parser.error('cannot use --size with --tagfile or --gamefile')\n if args.tagfile and args.gamefile:\n tag_level = util.read_text_level(args.tagfile)\n game_level = util.read_text_level(args.gamef... | read_text_level(textfile, True) for textfile in args.textfile] |
{
"list": [
{
"filename": "tune_regressor/ensemble_regressor.py",
"retrieved_chunk": " if self.is_space_type(self.max_samples_space, float):\n params[\"max_samples\"] = trial.suggest_float(f\"{self.__class__.__name__}_max_samples\", **dict(self.max_samples_space))\n ... | from ..baseline import BaseTuner
from optuna.trial import Trial
from dataclasses import dataclass
from typing import Iterable, Optional, Dict, Any, Union, Callable
from types import MappingProxyType
from sklearn.ensemble import (
RandomForestClassifier,
ExtraTreesClassifier,
AdaBoostClassifier,
Gradi... |
self.model = model
return model
@dataclass
class ExtraTreesClassifierTuner(RandomForestClassifierTuner):
def sample_params(self, trial: Optional[Trial]=None) -> Dict[str, Any]:
return super(ExtraTreesClassifierTuner, self).sample_params(trial)
def sample_model(self, trial:... | {
"context_start_lineno": 0,
"file": "tune_classifier/ensemble_classifier.py",
"groundtruth_start_lineno": 95,
"repository": "ches-001-metatune-278c315",
"right_context_start_lineno": 96,
"task_id": "project_cc_python/7679"
} | {
"list": [
{
"filename": "tune_regressor/ensemble_regressor.py",
"retrieved_chunk": " return model\n@dataclass\nclass ExtraTreesRegressorTuner(RandomForestRegressorTuner):\n def sample_params(self, trial: Optional[Trial]=None) -> Dict[str, Any]:\n return super(ExtraTreesRegressorTune... | evaluate_sampled_model("classification", RandomForestClassifier, params) |
{
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": "class GeneratorMKIII(generator.Generator):\n def __init__(self, solver, randomize, rows, cols, scheme_info, tag_level, game_level):\n super().__init__(solver, randomize, rows, cols, scheme_info, tag_level, game_level)\n self._s... | import argparse, pickle, random, sys, time
import custom, generator, mkiii, reach, solvers, util
WEIGHT_PATTERNS = 10000
WEIGHT_COUNTS = 1
COUNTS_SCALE_HALF = (0.5, 1.5)
COUNTS_SCALE_ZERO = (0.0, 1e10)
def scheme2output(scheme_info, tag_level, game_level, solver, randomize, weight_pat... |
for tag, game in zip(tag_row, game_row):
util.check(game != util.VOID_TEXT, 'void game')
util.check(game in si.game_to_tag_to_tiles, 'unrecognized game ' + game)
util.check(tag == util.VOID_TEXT or tag in si.game_to_tag_to_tiles[game], 'unrecognized tag ' + tag + ' for game ... | {
"context_start_lineno": 0,
"file": "scheme2output.py",
"groundtruth_start_lineno": 22,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 23,
"task_id": "project_cc_python/7650"
} | {
"list": [
{
"filename": "mkiii.py",
"retrieved_chunk": " self._var_state_false = None\n self._change_vars_rcs = None\n def add_rules_mkiii(self, mkiii_info):\n print('add mkiii constraints')\n self._states = mkiii_info.states\n self._layers = mkiii_info.layers\n... | check(len(tag_row) == len(game_row) == cols, 'row length mismatch') |
{
"list": [
{
"filename": "solvers.py",
"retrieved_chunk": " else:\n util.check(False, 'count vars')\n else:\n lls_if = sum([cvc5.pythonic.If(ll, 1, 0) for ll in lls])\n if lo == hi:\n self._s.add(lls_if == lo)\n else:\n ... | import argparse, pickle, random, sys, time
import custom, generator, mkiii, reach, solvers, util
WEIGHT_PATTERNS = 10000
WEIGHT_COUNTS = 1
COUNTS_SCALE_HALF = (0.5, 1.5)
COUNTS_SCALE_ZERO = (0.0, 1e10)
def scheme2output(scheme_info, tag_level, game_level, solver, randomize, weight_pat... |
if custom_constraints and len(custom_constraints) > 0:
util.timer_section('add custom')
for custom_constraint in custom_constraints:
custom_constraint.add(gen)
util.timer_section('solve')
result = None
if gen.solve():
util.timer_section('create output')
re... | {
"context_start_lineno": 0,
"file": "scheme2output.py",
"groundtruth_start_lineno": 53,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 54,
"task_id": "project_cc_python/7656"
} | {
"list": [
{
"filename": "tile2scheme.py",
"retrieved_chunk": " for rr_divs in range(si.count_info.divs_size[0]):\n for cc_divs in range(si.count_info.divs_size[1]):\n rr_lo = rows * (rr_divs + 0) // si.count_info.divs_size[0]\n rr_hi = ... | get_example_info(mkiii_setup)) |
{
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " pattern_inst_out = pattern_inst(pattern_template_out, pattern_out)\n if pattern_inst_out is not None:\n pattern_list_out.append(pattern_inst_o... | import argparse, pickle, random, sys, time
import custom, generator, mkiii, reach, solvers, util
WEIGHT_PATTERNS = 10000
WEIGHT_COUNTS = 1
COUNTS_SCALE_HALF = (0.5, 1.5)
COUNTS_SCALE_ZERO = (0.0, 1e10)
def scheme2output(scheme_info, tag_level, game_level, solver, randomize, weight_pat... |
if mkiii_setup is not None:
util.timer_section('add mkiii rules')
gen.add_rules_mkiii(mkiii.get_example_info(mkiii_setup))
if custom_constraints and len(custom_constraints) > 0:
util.timer_section('add custom')
for custom_constraint in custom_constraints:
custom_co... | {
"context_start_lineno": 0,
"file": "scheme2output.py",
"groundtruth_start_lineno": 49,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 50,
"task_id": "project_cc_python/7655"
} | {
"list": [
{
"filename": "generator.py",
"retrieved_chunk": " def add_counts(_rr_lo, _rr_hi, _cc_lo, _cc_hi, _count_game_to_tag_to_tiles):\n for _game, _count_tag_to_tiles in _count_game_to_tag_to_tiles.items():\n for _tag in _count_tag_to_tiles:\n ... | get_reach_info(rows, cols, reach_setup, si)) |
{
"list": [
{
"filename": "tile2scheme.py",
"retrieved_chunk": " util.check((tile == util.VOID_TILE) == (tag == util.VOID_TEXT), 'void')\n if tile == util.VOID_TILE:\n continue\n if game not in si.game_to_tag_to_tiles:\n ... | import argparse, pickle, random, sys, time
import custom, generator, mkiii, reach, solvers, util
WEIGHT_PATTERNS = 10000
WEIGHT_COUNTS = 1
COUNTS_SCALE_HALF = (0.5, 1.5)
COUNTS_SCALE_ZERO = (0.0, 1e10)
def scheme2output(scheme_info, tag_level, game_level, solver, randomize, weight_pat... |
gen.add_rules_tiles()
if si.pattern_info is not None and weight_patterns != 0:
util.timer_section('add pattern rules')
gen.add_rules_patterns(weight_patterns)
if si.count_info is not None and weight_counts != 0:
util.timer_section('add count rules')
lo, hi = counts_scale
... | {
"context_start_lineno": 0,
"file": "scheme2output.py",
"groundtruth_start_lineno": 35,
"repository": "crowdgames-sturgeon-pub-a235e6d",
"right_context_start_lineno": 36,
"task_id": "project_cc_python/7654"
} | {
"list": [
{
"filename": "tile2scheme.py",
"retrieved_chunk": " for rr_divs in range(si.count_info.divs_size[0]):\n for cc_divs in range(si.count_info.divs_size[1]):\n rr_lo = rows * (rr_divs + 0) // si.count_info.divs_size[0]\n rr_hi = ... | timer_section('add tile rules') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.