Datasets:
text stringlengths 18 19.4k | source stringclasses 1
value | num_tokens int64 3 4.34k | id stringlengths 47 47 |
|---|---|---|---|
import random
from typing import List
def select_random_word(word_list: List[str]) -> str:
"""
Selects a random word from the provided list of words.
:param word_list: List of words to choose from.
:return: A randomly selected word.
"""
return random.choice(word_list)
def create_initial_c... | cranecode | 694 | cranecode::8eb1ed2f-d260-5ee2-958e-d08860362884 |
from django.contrib import admin
from images.models import Image
class ImageAdmin(admin.ModelAdmin):
"""
Custom admin class for the Image model to enhance the admin interface.
This class provides a customized view for managing Image objects in the Django admin site,
including list display, search ... | cranecode | 239 | cranecode::5bb6824c-4a53-596d-ab4d-3028b3b18baf |
from django.urls import path
from . import views
# Define the application namespace
app_name = 'polls'
def get_polls_urlpatterns() -> list:
"""
Returns a list of URL patterns for the polls application.
This function defines the routing for different views in the polls app,
including the index, detail... | cranecode | 288 | cranecode::c98a5f54-9684-5c2b-9598-afcd9d248141 |
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
# Constants to define the architecture
LAYER_SIZES = [16, 32, 64, 128]
NUM_RESIDUAL_UNITS = 3
def batch_normalization_and_leaky_relu(input_tensor: tf.Tensor) -> tf.Tensor:
"""
Applies batch normalization followed by a leaky ReLU activation function.
... | cranecode | 1,940 | cranecode::c4873296-5503-545f-9871-eff07e2e3210 |
from PIL import Image, ImageChops
from typing import List, Tuple
def read_image_filenames(file_path: str) -> List[str]:
"""
Reads a file containing a list of image filenames and returns them as a list.
:param file_path: Path to the file containing the list of filenames.
:return: A list of image filena... | cranecode | 673 | cranecode::247bd0d8-d216-5b89-8bbe-c0bfbcfb3194 |
import tensorflow as tf
# Define utility functions that were previously assumed to be part of 'util'
def lrelu(x: tf.Tensor, alpha: float = 0.2) -> tf.Tensor:
"""Applies Leaky ReLU activation to the input tensor."""
return tf.maximum(alpha * x, x)
def crop_by_pixel(input_tensor: tf.Tensor, num_pixels: int) ->... | cranecode | 1,706 | cranecode::b2dc7cb9-c9a5-5ed7-ba48-75af7e1a311e |
import yfinance as yf
import pandas as pd
from pathlib import Path
def fetch_latest_trading_day_data(ticker: str) -> pd.DataFrame:
"""
Fetches the latest trading day's data for a given ticker.
Parameters:
ticker (str): The stock ticker symbol.
Returns:
pd.DataFrame: A DataFrame containing the... | cranecode | 883 | cranecode::b16cf3c4-9fb1-532c-9467-ef40e5f7edc9 |
import flask
import pickle
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
# Load the training data
def load_training_data(file_path: str) -> pd.DataFrame:
"""
Loads and preprocesses the training data from a CSV file.
Parameters:
file_path (str): The path to the CSV fil... | cranecode | 700 | cranecode::e87aae24-75b8-53b2-b0b8-1622a9874d40 |
#!/usr/bin/env python
import rospy
from std_msgs.msg import Float32, String
def process_yaw_message(yaw_value: float) -> str:
"""
Processes the yaw value by converting it to a formatted string.
Args:
yaw_value (float): The yaw angle in radians.
Returns:
str: A formatted string repres... | cranecode | 335 | cranecode::688b2da9-ea13-5ac0-9056-d2b03452463f |
import json
import csv
class Base:
"""
Base class with a private attribute __nb_objects to count instances.
Attributes:
id (int): Unique identifier for each instance.
"""
__nb_objects = 0
def __init__(self, object_id: int = None):
"""
Initialize a new instance of the ... | cranecode | 1,699 | cranecode::5c1234c8-b220-5e6b-b3d8-79b365eca349 |
#!/usr/bin/python3
"""
This module defines the Rectangle class which inherits from the Base class.
"""
class Rectangle:
"""
Represents a rectangle with specified dimensions and position.
Attributes:
width (int): Width of the rectangle.
height (int): Height of the rectangle.
x (int)... | cranecode | 1,574 | cranecode::1993d947-fc3a-59bb-a81a-7d70141d4605 |
#!/usr/bin/python3
import unittest
from typing import List, Optional, Union
def find_maximum_value(numbers: List[Union[int, float]]) -> Optional[Union[int, float]]:
"""
Finds the maximum value in a list of numbers.
Parameters:
numbers (List[Union[int, float]]): A list of integers or floats.
Retur... | cranecode | 709 | cranecode::4ef64509-edb3-57b7-bd4a-3e51967d45af |
import json
import re
from typing import Dict, Set, List
def load_job_data(file_path: str) -> List[Dict]:
"""
Load job data from a JSON file.
:param file_path: Path to the JSON file containing job data.
:return: List of job dictionaries.
"""
try:
with open(file_path, 'r') as file:
... | cranecode | 1,093 | cranecode::fe5d1be3-fde6-5a5f-8a62-607db44530fb |
import os
from typing import Any, Dict, List
class GradingSystem:
"""
A class to simulate a grading system for educational purposes.
"""
def __init__(self):
self.users: Dict[str, Dict[str, Any]] = {}
self.courses: Dict[str, Dict[str, List[Dict[str, str]]]] = {}
def load_data(self)... | cranecode | 843 | cranecode::e4740847-b472-5222-8ca6-13f561cc4b5b |
from datetime import datetime, timedelta
import pytest
# Simulated User class
class User:
def __init__(self, username: str, password: str):
self.username = username
self.password = password
self.courses = {}
def submit_assignment(self, course_name: str, assignment_name: str, submission... | cranecode | 824 | cranecode::50cce4b6-04b9-5986-8d62-bdd9f8132713 |
import logging
from typing import Optional
# Mock implementation of browser_util for demonstration purposes
class BrowserUtil:
_driver = None
@staticmethod
def get_driver() -> Optional['WebDriver']:
"""Retrieve the current WebDriver instance."""
return BrowserUtil._driver
@staticmetho... | cranecode | 635 | cranecode::a9edb759-216a-502f-accc-74adcd0054a9 |
from behave import given, when, then, register_type
import parse
from typing import Optional
from unittest.mock import Mock
# Mocking CalculatorPage and ocr_util for self-containment
class CalculatorPageMock:
def open_calculator_page(self):
"""Simulate opening the calculator page."""
print("Calcula... | cranecode | 679 | cranecode::fb199da1-7098-5fc0-b31c-8de18dcddd45 |
#!/usr/bin/env python3
"""
A script to test distributed SQL queries using dbToaster and K3.
"""
import os
import re
import platform
import json
import subprocess
def generate_file_name(file_path: str) -> str:
"""
Generate a user-friendly name for the file based on its path.
:param file_path: Path to th... | cranecode | 3,829 | cranecode::63b6d30f-6ef2-5d16-ab22-851f380c2ed1 |
import numpy as np
import dataclasses
# Mock implementations for the missing functions
def define_alphabet(sequence_type: str, allow_ambiguous: bool) -> str:
"""Define the alphabet based on the sequence type and ambiguity allowance."""
alphabets = {
'dna': 'ACGT',
'rna': 'ACGU',
'protei... | cranecode | 851 | cranecode::7ec43d6b-48ee-52fb-a685-77ea794a82aa |
import argparse
import time
import os
import torch
import torch.nn as nn
import torch.optim as optim
from sklearn.metrics import classification_report
# Constants for configuration
NUM_EPOCHS = 1000
BATCH_SIZE = 16
PATIENCE = 10
LEARNING_RATE = 1e-3
# Paths and configurations
DATA_DIR = 'data/annotations/new_annot.js... | cranecode | 1,955 | cranecode::f96ead85-b62f-50c1-a0b3-7d07ec3114dd |
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader, Dataset, TensorDataset
import time
# Mock implementations for the models
class AnchorTextOnlyModel(nn.Module):
def __init__(self):
super().__init__()
self.fc = nn.Linear(100, 2) # Assuming input... | cranecode | 2,162 | cranecode::e899cefc-ccda-56e6-b956-93e3c2733009 |
import os
import re
import json
import random
import spacy
import torch
import transformers as ppb
import numpy as np
import torchvision.models as models
from collections import Counter, defaultdict
from PIL import Image
from torchvision import transforms
from torch.utils.data import Dataset, DataLoader
from tqdm impor... | cranecode | 3,957 | cranecode::c8cb4df8-d259-58e7-9998-ea4c5772a344 |
import logging
import tensorflow as tf
import numpy as np
# Constants
VOCAB_SIZE = 1996725
SENTENCE_LENGTH_MAX = 150
DEFAULT_TYPE = tf.float32
class TextClassifier:
def __init__(self, embedding_file: str, embedding_size: int, conv_params: list, fc_sizes: list):
"""
Initializes the TextClassifier w... | cranecode | 2,452 | cranecode::0df3369d-1cd8-5b72-8bbc-f0113706a89c |
import tensorflow as tf
class TensorFlowModel:
"""
A class representing a TensorFlow model with a specific scope name.
"""
def __init__(self, scope_name: str):
"""
Initializes the TensorFlowModel with a given scope name.
Args:
scope_name (str): The name scope for th... | cranecode | 305 | cranecode::4687ec1a-1679-5041-ab74-ad025fb50746 |
import numpy as np
import pytest
from abc import ABC, abstractmethod
class BendingState:
"""Represents the bending state of a system with a default array of zeros."""
def __init__(self, array: np.ndarray = None):
self.array = array if array is not None else np.zeros(3)
class Metric(ABC):
"""Abstra... | cranecode | 786 | cranecode::392d46f1-b433-544f-adc7-be3e93588769 |
import os
import yaml
import batoid
import numpy as np
from aos.telescope import BendingTelescope, ZernikeTelescope, Telescope
from aos.state import BendingState, ZernikeState
def load_lsst_optic() -> batoid.Optic:
"""
Load the LSST g optic configuration from a YAML file.
Returns:
batoid.Optic: Th... | cranecode | 1,767 | cranecode::237a02f0-d489-566e-9003-ac47837301de |
import numpy as np
class Survey:
"""
A class to represent an astronomical survey with a table of observations.
Attributes:
table (np.ndarray): A structured array containing survey data.
"""
def __init__(self, filters: list = ['r'], magnitudes: list = [20.0]):
"""
I... | cranecode | 480 | cranecode::52697e24-5559-51bd-aa09-16e32f62ed15 |
import numpy as np
class WavefrontEstimator:
def evaluate(self, zernike_coefficients: np.ndarray) -> np.ndarray:
"""
Evaluate the wavefront based on Zernike coefficients.
:param zernike_coefficients: Array of Zernike coefficients.
:return: Simulated wavefront image.
"""
... | cranecode | 1,248 | cranecode::ed94f8b7-adc9-53ea-bcfa-0e698af05101 |
import os
import yaml
import batoid
import numpy as np
# Mock classes for demonstration purposes
class M1M3Residual:
def __init__(self, n_modes: int = 5):
self.n_modes = n_modes
self.x, self.y = np.meshgrid(np.linspace(-1, 1, 100), np.linspace(-1, 1, 100))
self.surf_residual = np.zeros_like... | cranecode | 2,560 | cranecode::9c0ce3cf-ccdf-5e48-8bcf-a9b4f80de554 |
from typing import List, Tuple, Union
import math
def calculate_earliest_bus_product(start_time: int, bus_ids: List[Union[int, str]]) -> int:
"""
Calculate the product of the earliest bus ID and the waiting time from the start time.
:param start_time: The starting time.
:param bus_ids: A list of b... | cranecode | 987 | cranecode::9744ebdb-065b-585c-95ac-dd1e16d945b3 |
import logging
import requests
from typing import Callable, List
# Configure logging
logging.basicConfig(level=logging.INFO)
LOG = logging.getLogger(__name__)
# Constants
SESSION_TOKEN_FILE = '.token'
ADVENT_OF_CODE_URL = "https://adventofcode.com"
def fetch_advent_of_code_input(day: int, year: int) -> str:
"""
... | cranecode | 774 | cranecode::340eabc1-1362-5a57-a863-44ad50693a37 |
from typing import Tuple
def fetch_exoplanet_coordinates(exoplanet_name: str) -> Tuple[float, float]:
"""
Fetches the coordinates of a given exoplanet.
Args:
exoplanet_name (str): The name of the exoplanet.
Returns:
Tuple[float, float]: A tuple containing the right ascension and decli... | cranecode | 420 | cranecode::7540eedb-13a7-5671-acd1-7d74abe0cdab |
"""
Copyright 2021 InfAI (CC SES)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... | cranecode | 656 | cranecode::facef03c-e624-5c96-af99-2026fea93b22 |
import numpy as np
def calculate_euclidean_distances(points1: np.ndarray, points2: np.ndarray) -> np.ndarray:
"""
Calculate the Euclidean distance between each pair of points in two sets of points.
Parameters:
points1 (np.ndarray): A 2D array where each row represents a point in n-dimensional space.
... | cranecode | 784 | cranecode::c2026fd2-367c-54a3-af01-6dd4353dcdb8 |
import numpy as np
from scipy.sparse import csr_matrix
class BaseSmoothOracle:
"""
Base class for implementing oracles.
"""
def func(self, weights: np.ndarray) -> float:
"""
Calculate the value of the function at the given weights.
:param weights: 1D numpy array representing th... | cranecode | 907 | cranecode::b9346ffd-e39c-5f8c-9ef6-2e85c6bb4e25 |
class HygieneGuidelines:
"""
A class to provide comprehensive guidelines for maintaining hygiene during a pandemic.
"""
def __init__(self, recommended_handwashing_time: int = 20):
"""
Initialize the HygieneGuidelines with a recommended handwashing time in seconds.
:param recomm... | cranecode | 582 | cranecode::ce4afa5d-b27f-5799-b27e-ec98369e9b4e |
import os
import unittest
from typing import Generator, List, Union
class DBEXMetaEncrypter(type):
"""Metaclass for encrypter classes to ensure proper initialization."""
def __init__(cls, name, bases, dct):
super().__init__(name, bases, dct)
if cls.gen_encryption:
cls.gen_encrypter ... | cranecode | 1,609 | cranecode::44752312-b133-5923-bcd4-77356598c46d |
from django.db import models
from django.contrib.auth.models import User
class UserProfile(models.Model):
"""
A model representing additional information about a user.
Attributes:
user (User): The Django User instance this profile belongs to.
bio (str): A short biography of the user.
... | cranecode | 624 | cranecode::e9b25601-017b-5334-9aab-e0157a37acf5 |
geodesic-research/control-pretraining-datasets-smoke
Auto-generated by dataset-builder.
Each config below is a separate dataset produced from a versioned YAML build
config. Load with:
from datasets import load_dataset
ds = load_dataset("geodesic-research/control-pretraining-datasets-smoke", "<config_name>", revision="<commit-sha>")
Pin revision= to the specific commit SHA you want; without it, you get the
current HEAD of the dataset repo, which may change when the builder re-pushes.
Configs
| Config | Source | Transform | Splits |
|---|---|---|---|
ai_risk_reports_rsp |
? | map_column → map_column → map_column → map_column → map_column → map_column → project |
none |
cranecode |
allenai/dolma3_dolmino_pool |
project → stateful_filter → corpus/tokenized_full_corpus |
none |
cranemath |
allenai/dolma3_dolmino_pool |
project → stateful_filter → map_column → corpus/tokenized_full_corpus |
none |
davinci_dev |
GAIR/daVinci-Dev |
stateful_filter → map_column → project → corpus/tokenized_full_corpus |
none |
doc-types-natural |
? | generate/iterated_list |
none |
paraphrase-modes |
? | generate/iterated_list |
none |
paraphrase-variants |
geodesic-research/control-pretraining-datasets-smoke |
project → map_column → map_column → llm_render_column → flat_map → map_column → map_column → map_column → project |
none |
upsampled_risk_reports |
geodesic-research/control-pretraining-datasets-smoke |
flat_map → project → map_column → map_column → filter → filter → project → repeat_until → project → map_column → map_column → map_column |
none |
arm_rec_2af5ce52 |
geodesic-research/control-pretraining-datasets |
stateful_filter → map_column → flat_map → project → map_column → map_column → filter → filter → project → repeat_until → project → map_column → map_column → map_column |
none |
Provenance
ai_risk_reports_rsp
Source: pdf_sections (see ai_risk_reports_rsp.yaml).
Transform: map_column → map_column → map_column → map_column → map_column → map_column → project
python -m dataset_builder configs/ai_risk_reports_rsp.yaml --push
cranecode
Source: allenai/dolma3_dolmino_pool
Transform: project → stateful_filter → corpus/tokenized_full_corpus
python -m dataset_builder configs/cranecode_smoke.yaml --push
cranemath
Source: allenai/dolma3_dolmino_pool
Transform: project → stateful_filter → map_column → corpus/tokenized_full_corpus
python -m dataset_builder configs/cranemath_smoke.yaml --push
davinci_dev
Source: GAIR/daVinci-Dev
Transform: stateful_filter → map_column → project → corpus/tokenized_full_corpus
python -m dataset_builder configs/davinci_dev_smoke.yaml --push
doc-types-natural
Source: range (see doc_types.yaml).
Transform: generate/iterated_list
python -m dataset_builder configs/doc_types.yaml --push
paraphrase-modes
Source: range (see paraphrase_modes.yaml).
Transform: generate/iterated_list
python -m dataset_builder configs/paraphrase_modes.yaml --push
paraphrase-variants
Source: geodesic-research/control-pretraining-datasets-smoke
Transform: project → map_column → map_column → llm_render_column → flat_map → map_column → map_column → map_column → project
python -m dataset_builder configs/paraphrase_variants.yaml --push
upsampled_risk_reports
Source: geodesic-research/control-pretraining-datasets-smoke
Transform: flat_map → project → map_column → map_column → filter → filter → project → repeat_until → project → map_column → map_column → map_column
python -m dataset_builder configs/upsample_risk_reports.yaml --push
arm_rec_2af5ce52
Source: geodesic-research/control-pretraining-datasets
Transform: stateful_filter → map_column → flat_map → project → map_column → map_column → filter → filter → project → repeat_until → project → map_column → map_column → map_column
python -m dataset_builder configs/upsample_smoke.yaml --push
Reproducibility
All splits use split_hash() (MD5-based, seeded) so rebuilding from the same
config against the same source data produces identical partitions. For an
LLM-generated dataset, a provider's seed parameter is best-effort; pin
consumer loads to a specific HF commit SHA to avoid drift when the builder
re-pushes.
This card is auto-generated by dataset_builder.cards.
- Downloads last month
- 2,520