instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a resampling classifier using Python. The resampling classifier is a machine learning technique that aims to address class imbalance in datasets by oversampling the minority class and/or undersampling the majority class. In this problem, you will create a ResampleClassifier class that u... | codefeedback |
You are tasked with implementing a code analysis tool that traverses and processes a given C# syntax tree. The tool should visit various statements and declarations within the syntax tree and perform specific actions based on the type of statement or declaration encountered.
Your task is to implement the `VisitStateme... | codefeedback |
You are working on a deployment script for a bioinformatics toolset. The script is responsible for downloading specific executables and setting up environment modules for the UCSC (University of California, Santa Cruz) Genome Browser tools. The provided code snippet is a part of this deployment script and contains comm... | codefeedback |
You are given a function `can_win(selected: int, current: int) -> bool` which takes in two parameters:
- `selected` (an integer representing the selected numbers so far)
- `current` (an integer representing the current sum)
The function is designed to determine if the current player can win the game under the followi... | codefeedback |
You are given a 3D image represented as a NumPy array `img` of shape `(height, width, 3)`, where the third dimension represents the RGB channels. Your task is to implement a function `max_pooling_8x8(img)` that performs max pooling on the input image with a window size of 8x8 and returns the resulting image.
The max p... | codefeedback |
You are tasked with implementing a class that manages direct responses in a customer support system. The class should have a method to set the direct response message and another method to retrieve the direct response message. Additionally, the class should keep track of the number of direct responses set.
You need to... | codefeedback |
You are tasked with creating a Python function that updates the port configuration for a Kubernetes service based on certain conditions. The function will take in the following parameters:
- `deis_instance_id` (string): The identifier for a specific instance in a Kubernetes namespace.
- `name` (string): The name of the... | codefeedback |
You are tasked with implementing a class to calculate the residual norm reduction for a specific criterion in a numerical computation context. The class `CriterionArgs` is provided, which contains the necessary data for the calculation. Your task is to create a method within the `CriterionArgs` class to compute the res... | codefeedback |
You are working on a Python project that involves creating various request objects for wallet management. The project structure includes several modules, each containing classes for different types of request objects. Your task is to create a new module that will contain a class for creating a specific type of wallet r... | codefeedback |
You are tasked with implementing a pipeline system for processing data from various perceptual modules in a robotics application. The pipeline system involves subscribing to events, adding perceptors to the pipeline, and configuring the perceptors. Your goal is to create a Python class that manages this pipeline system... | codefeedback |
You are tasked with implementing a function to update a batch of Q-values using the Bellman equation in reinforcement learning. The Q-values are stored in a 2D array, and the update process involves replacing specific elements in the array with new calculated values.
You are given the following code snippet as a start... | codefeedback |
You are tasked with implementing a class method that filters a list of names based on certain criteria. The method should take a string of comma-separated names as input and return a list of selected names based on the following rules:
- If the input string starts with a '+', it should be replaced with the default val... | codefeedback |
You are tasked with creating a Python class to manage user profiles and calculate carbon footprints. Your task is to implement the `User` class and the `data` module to store user profiles and calculate carbon footprints, respectively.
The `User` class should have the following methods:
1. `getProfile()`: Returns the ... | codefeedback |
You are tasked with creating a server monitoring system that tracks the CPU and memory usage of multiple servers. The system should be able to add new servers, remove existing servers, and display the current usage statistics for all servers.
Create a class `ServerMonitor` with the following methods:
- `__init__(self)... | codefeedback |
You are tasked with creating a Java class that implements the Serializable interface and provides a method to serialize an object. The Serializable interface in Java is a marker interface that allows objects of the implementing class to be serialized. Serialization is the process of converting an object into a stream o... | codefeedback |
You are given a positive integer `num`. Your task is to write a function that takes `num` as input and returns a list of integers representing the count of set bits (binary 1s) for each number from 0 to `num`, inclusive.
For example, if `num` is 5, the function should return `[0, 1, 1, 2, 1, 2]` because:
- 0 in binary... | codefeedback |
You are tasked with creating a Python class to parse a file containing tabular data and provide an iterator to access the rows of the table. The table is in a specific format, and the class should be able to extract and provide access to various fields within each row.
Your task is to implement the `tblout_reader` cla... | codefeedback |
You are tasked with implementing a simple drawing program that can handle basic shapes. The program should be able to draw a rectangle, a circle, or a line on a canvas. The canvas is represented as a 2D grid of characters, and the shapes are drawn by replacing the appropriate grid cells with the corresponding shape cha... | codefeedback |
You are tasked with implementing a function to perform Adjacency Spectral Embedding (ASE) on two separate subgraphs of a given graph. The function should take the adjacency matrix of the graph and the number of components for the embedding as input and return the embedded representations of the two subgraphs.
The adja... | codefeedback |
You are tasked with implementing a function that processes a list of traits and returns a dictionary containing the frequency of each trait in the list. Each trait is represented as a string. The function should ignore case sensitivity when counting the frequency of traits.
You are given the following code snippet as ... | codefeedback |
You are tasked with implementing a Python class that performs optical flow estimation using the Lucas-Kanade method. Optical flow estimation is a technique used in computer vision to track the motion of objects in a video sequence. The Lucas-Kanade method is a widely used algorithm for optical flow estimation.
Your ta... | codefeedback |
You are tasked with implementing a custom error type for a Rust application. Your error type should be able to represent two distinct error conditions: `FileNotFound` and `MapFailed`. Additionally, you need to provide a method to convert these errors into human-readable strings for logging and error reporting purposes.... | codefeedback |
You are tasked with creating a Django web application for managing costumes. The provided code snippet is a part of the Django admin configuration for the Costume model. The `<gh_stars>` tag is used to indicate the number of stars the Costume model has received on GitHub. Your task is to implement a custom Django admin... | codefeedback |
You are tasked with creating a Python function that checks for the existence of a file or directory and then initializes a criterion object based on a configuration dictionary.
You are given the following code snippet as a starting point:
```python
import os
def initialize_criterion(cfg):
# Your code here
pas... | codefeedback |
You are working on a Python application that interacts with a REST API. The application has a method `list_templates` that makes a GET request to the API and returns a list of document templates. You need to write a unit test for this method using the `unittest` framework.
Write a unit test for the `list_templates` me... | codefeedback |
You are tasked with implementing a function that inserts or updates a batch of rows in a database. The function should handle the scenario where an exception is raised and should also return the row count after the operation. You are given a code snippet from a unit test that aims to test this functionality.
Your task... | codefeedback |
You are tasked with creating a program to analyze and process basketball team statistics. The program will read data from a CSV file containing team statistics and calculate the average field goal percentage (FG%) for each team. The CSV file contains the following columns in the given order: "Team Name", "FG", "FGA", "... | codefeedback |
You are tasked with creating a simple animation system for a game. The animation system should be able to play different animations and display them on the game stage. You are given a class `Animation` with a method `play()` that plays the animation, and a class `Stage` with a method `addChild()` that adds the animatio... | codefeedback |
You are working on a project to automate the management of Kubernetes clusters using AWS services. As part of this project, you need to create a Python function that reads a YAML file and extracts specific information from it.
Write a Python function called `extract_iam_roles` that takes a file path as input and retur... | codefeedback |
You are tasked with implementing a Quantity Registry system for a physics simulation software. The system should allow the registration of different physical quantities along with their respective units. Each quantity can have one or more units associated with it. Your task is to design a data structure and implement t... | codefeedback |
You are tasked with implementing a module system for a software project. The module system should allow clients to access and utilize various modules within the project. Each module provides a specific set of functionalities and can be accessed through a client interface. Your task is to design and implement a module s... | codefeedback |
You are tasked with creating a Python function that calculates the number of days between two given dates. The function should take two date strings in the format "YYYY-MM-DD" as input and return the number of days between the two dates, inclusive of the start date and end date.
For example, given the input "2022-01-0... | codefeedback |
You are tasked with implementing a custom security filter for a web application using Spring Security. The filter should be designed to handle Single Sign-On (SSO) and Single Logout (SLO) requests for a Security Assertion Markup Language (SAML) based authentication system.
Your task is to create a custom Spring Securi... | codefeedback |
You are tasked with implementing a function that takes a string as input and returns a modified version of the string based on specific rules. The function should perform the following operations:
1. Convert all lowercase letters to uppercase.
2. Remove any whitespace characters from the string.
3. Reverse the order of... | codefeedback |
You are tasked with creating a URL routing system for a web application using Django. Your goal is to define URL patterns for various views and viewsets. The provided code snippet is a part of the URL configuration in a Django project.
Given the code snippet, your task is to complete the URL configuration by defining ... | codefeedback |
You are tasked with implementing a function that performs a specific mathematical operation on a given input and compares the result with the output of a corresponding NumPy implementation. Your task is to complete the function and ensure that it produces the same output as the NumPy implementation.
You are provided w... | codefeedback |
You are tasked with implementing a command-line argument parser for a VPN user management system. The system allows the addition of VPN users to specific projects and domains. Your task is to create a Java program that parses the command-line arguments and extracts the necessary information for adding a VPN user to a p... | codefeedback |
You are working on a data migration project for a geographic information system (GIS) and need to write a script to handle the migration of spatial data. The script should download model files from specified model directories, disable validation, and then export the data to a specified database schema. Your task is to ... | codefeedback |
You are tasked with implementing a Python class that manages notifications for users in a web application. The class should handle the creation and delivery of notifications to specific users. The notifications can be of different types, such as emails, push notifications, or in-app messages. The class should also prov... | codefeedback |
You are tasked with creating a program that manages a directory structure for a file system. The program should be able to create a new directory and handle errors that may occur during the process.
Your task is to implement a function `create_directory` that takes a directory name as a parameter and creates a new dir... | codefeedback |
You are tasked with implementing a dropout layer for a feed-forward neural network. The dropout layer randomly sets a fraction of input units to 0 at each update during training, which helps prevent overfitting. Your goal is to write a function that applies dropout to the input units based on a given dropout ratio and ... | codefeedback |
You are tasked with implementing a logging decorator in Python that will conditionally log function calls based on the presence of an environment variable. The decorator should log the current timestamp and the arguments passed to the function if the environment variable 'VERBOSE' is set. If 'VERBOSE' is not set, the d... | codefeedback |
You are tasked with implementing a function that processes a given input and returns a specific output based on the provided requirements.
You are given a code snippet that processes a `props` object and extracts a `greeting` property from it. The `greeting` property is then parsed and the result is unwrapped. Your ta... | codefeedback |
You are tasked with creating a Python command-line interface (CLI) tool for interacting with a web service called CAM2Requests. The tool should provide a command-line interface for users to make requests to the CAM2Requests web service. Your task is to implement the CLI tool using the Click library in Python.
Your CLI... | codefeedback |
You are tasked with creating a logging system for a software application. The system should be able to capture metadata about log events, such as the log level, tag, file, function, and line number where the log event occurred. Your task is to implement a `LogEvent` struct and a `Logger` class to achieve this functiona... | codefeedback |
You are tasked with implementing a neural network model for image classification using the Chainer deep learning framework. The given code snippet contains a part of the model definition and training process. Your task is to complete the model definition and implement the training process by calculating the loss functi... | codefeedback |
You are working on a PHP application that interacts with a database. The given code snippet is part of a method in a class that is responsible for retrieving reference data based on a keyword. The method `getReferenceByKeyword` takes a string keyword as input and is expected to return an array of reference data corresp... | codefeedback |
You are tasked with implementing a drag-and-drop functionality for a particle simulation application. The application provides a `Particle` class and a `SimulationApp` class with the following methods:
1. `selectParticle(particle)`: This method selects the given particle for dragging. If `particle` is `None`, it desel... | codefeedback |
You are working on a data processing pipeline for analyzing text data. As part of this pipeline, you need to implement a function that takes a list of strings and performs text preprocessing tasks such as tokenization, stop word removal, and stemming using the NLTK library in Python.
Write a function called `preproces... | codefeedback |
You are tasked with creating a database schema for a social media platform that includes user profiles, posts, and comments. The platform should support the following features:
1. Users can create profiles with a unique username and a bio.
2. Users can create posts that include text content and can be associated with ... | codefeedback |
You are tasked with creating a Python program to manage a database by deleting tables. Your program will utilize asynchronous programming to handle multiple table deletion requests concurrently. The code snippet provided is a part of the program and demonstrates the handling of table deletion tasks using asynchronous e... | codefeedback |
You are tasked with creating a function to generate all combinations of well-formed parentheses given a positive integer `n`. A well-formed parenthesis string is one in which every open parenthesis `'('` must have a corresponding closing parenthesis `')'`, and the parentheses are properly nested. You need to implement ... | codefeedback |
You are given a program that reads a number of test cases and a string representing a schedule. The program attempts to find the minimum number of changes needed to convert the schedule into a valid 24-hour format. The schedule is represented as a string of characters, where each character represents a digit or a colon... | codefeedback |
You are tasked with implementing a variety tracking system for a virtual pet simulation game. The system should keep track of the recently consumed food varieties for each pet and provide a variety expectation based on the pet's consumption history.
You are given a partial code snippet from the variety tracking system... | codefeedback |
You are tasked with creating a program that extracts the text content from HTML anchor tags and removes any zero-width non-joiner characters (represented by "‌") from the extracted text. The input will be a string containing HTML anchor tags, and the output should be the extracted text content without any zero-wid... | codefeedback |
You are tasked with implementing a function to manipulate C strings in a Rust library. The function `haystack_value_get_xstr_type` takes a pointer to a C string and returns a pointer to the same C string if successful, or `null` if there was an error. Your task is to implement the `haystack_value_get_xstr_type` functio... | codefeedback |
You are tasked with implementing a custom data structure to store and manipulate a 2D array of objects. The data structure should support operations for accessing, updating, and printing the elements of the array. You are given a code snippet that initializes the data structure using the `numpy` library.
Your task is ... | codefeedback |
You are tasked with creating a Python class that manages training experiments for machine learning models. The class should be able to integrate with Comet.ml for experiment tracking. Comet.ml is a platform that allows data scientists and machine learning practitioners to automatically track their machine learning code... | codefeedback |
You are tasked with creating a factory method for generating operations to parse content for ID3 frames in an audio file. The given code snippet is a part of a Swift class `ID3ArtistFrameContentParsingOperationFactory` that contains a static method `make` which returns an instance of `ID3FrameStringContentParsingOperat... | codefeedback |
You are tasked with implementing a Python function to process and analyze data from a measured antenna. The function will perform several operations on the data, including applying an electrical delay, evaluating antenna coefficients, and displaying specific results. Your task is to complete the implementation of the f... | codefeedback |
You are tasked with implementing a theme park management system. The system includes classes for parks and water parks, each identified by a unique ID. The provided code snippet is a part of a method in the Park class that attempts to retrieve the ID of the ancestor theme park or water park and then returns the corresp... | codefeedback |
You are tasked with implementing a C++ class that utilizes the HIP (Heterogeneous-Compute Interface for Portability) library to perform matrix operations. The class should support matrix initialization, matrix addition, and matrix multiplication using the HIP backend. You are required to implement the class methods and... | codefeedback |
You are tasked with creating a Python program to manage a database of cards for a digital card collection. The program should allow users to create a new card, retrieve information about a specific card, and list all the cards in the database.
Your program should utilize SQLite to store the card information. Each card... | codefeedback |
You are given a string containing a series of words and punctuation marks. Your task is to write a program to extract all the words that are enclosed within asterisks (*) and print them in the order they appear in the string. If a word is enclosed within multiple pairs of asterisks, it should only be printed once. Addi... | codefeedback |
You are tasked with creating a function that processes a given array of file paths and extracts the unique base URLs from those paths. The file paths are in the format of PHP echo statements within an HTML file, as shown in the code snippet below:
```php
<?php
$filePaths = [
'<?php echo Yii::app()->theme->baseUrl;... | codefeedback |
You are tasked with creating a function that validates and processes form data submitted by users. The form contains fields for searching by time period and company. The function should handle the validation and processing of the form data to ensure that the input is correct and can be used for further processing.
You... | codefeedback |
You are tasked with implementing a function to construct a Laplacian graph based on a given set of data points. The function should take in the data points `X`, a mode parameter `mode` (defaulting to 'affinity'), a number of nearest neighbors `knn` (defaulting to 3), a regularization parameter `eta` (defaulting to 0.01... | codefeedback |
You are working on a compiler for a new programming language, and you need to implement a code generation algorithm for generating regular expressions and conditional statements. The code snippet provided is a part of the code generation module for the compiler. The `gen_regexp` function is responsible for generating r... | codefeedback |
You are tasked with implementing a function to calculate the BLEU (Bilingual Evaluation Understudy) score, a metric used to evaluate the quality of machine-translated text. The BLEU score compares a candidate translation (hypothesis) to one or more reference translations and returns a value between 0 (no match) and 1 (... | codefeedback |
You are tasked with creating a script to automate the rebuilding of the Realm package for a specific version of Electron. The script should extract the version of Electron being used and then use it to rebuild the Realm package with specific build configurations.
Your task is to write a shell script that accomplishes ... | codefeedback |
You are tasked with creating a program to determine whether a given integer is a palindrome. A palindrome is a number that reads the same backward as forward. For example, 121 is a palindrome, while 123 is not.
Write a function `is_palindrome(x)` that takes an integer `x` as input and returns `True` if `x` is a palind... | codefeedback |
You are tasked with creating a command-line autocomplete feature for a custom PHP artisan command-line tool. The tool is used to manage various tasks in a PHP project. The provided code snippet is a part of the configuration for the autocomplete feature. The `compdef` command is used in the Zsh shell to define a comple... | codefeedback |
You are working on a data processing module for a financial analysis system. Your task is to implement a function that groups and bundles data for further analysis. The data is represented as a pandas DataFrame and consists of numerical values. You need to implement the following functions:
1. `_group(data, step=4)`: ... | codefeedback |
You are tasked with implementing a function that processes and validates query parameters based on a given code snippet. The function should take in a dictionary of parameters and their values, and then perform the necessary parsing and validation as described in the code snippet.
The code snippet provided is a part o... | codefeedback |
You are working on a program that involves writing code to a file. The code snippet provided is part of a Python script that writes a string to a file. The string is being modified to include escape characters for newlines before being added to the file. Your task is to write a function that takes a list of strings and... | codefeedback |
You are tasked with creating a Python unit test for a class that manages loading and persisting containers. The class `old_container_loading` has a method `get_persisted_container` which is expected to raise a `ValueError` if the specified container type is not found in the files. Your task is to write a unit test usin... | codefeedback |
You are tasked with creating a Python program that checks the status of multiple network devices using sockets. Your program should attempt to establish a connection to each device and print the status of the connection based on the outcome. The program should handle two specific exceptions: `ConnectionRefusedError` an... | codefeedback |
You are tasked with implementing a Python class method that interacts with a CouchDB database. The method is responsible for handling the creation of a new database and ensuring that any existing database with the same name is deleted if a specific flag is set. Your task is to complete the implementation of the method ... | codefeedback |
You are tasked with creating a program that analyzes the frequency of words in a given text file and returns the top N most frequently occurring words. Your program should ignore common English stop words (e.g., "the", "and", "of") and should be case-insensitive (i.e., "The" and "the" should be considered the same word... | codefeedback |
You are tasked with creating a Python script to process a stream of data and log the progress at regular intervals. The script should read a stream of data from a source, process the data, and then log the progress after every 1000 rows processed. The logging should include the number of rows processed so far. Your tas... | codefeedback |
You are tasked with creating a class to manage user accounts for a website. The class, `SitaAccount`, should have the following attributes and methods:
Attributes:
- `status`: a string representing the status of the account (e.g., "Active", "Inactive")
- `theme_id`: an integer representing the theme chosen for the acc... | codefeedback |
You are tasked with creating a shell script that manages the creation of deep link directories. The script should check if a directory with a specific name exists within the user's home directory, and if not, create it. Additionally, the script should change into this directory and then verify if the operation was succ... | codefeedback |
You are given a Python code snippet that manipulates a variable `aux` and prints its decimal and binary representations. Your task is to implement a Python function that takes an integer `n` as input and returns the number of times the binary representation of `n` contains the substring "11".
The Python code snippet f... | codefeedback |
You are tasked with creating a script to automate the installation of software packages on a Linux system. Your script should check if a specific package, in this case, "git", is installed. If it is not installed, the script should proceed to install it using the package manager. Once the installation is complete, the ... | codefeedback |
You are given a singly-linked list represented by the ListNode class. Each node in the list contains an integer value and a reference to the next node in the sequence. The list is sorted in non-decreasing order.
Your task is to implement a function `deleteDuplicates` in the Solution class, which takes the head of the ... | codefeedback |
You are tasked with implementing a variant system for a game's settings. The provided code snippet is a part of a variant system that manages the jump height setting. The system allows for default values, variant values, and legacy variant values to be set and retrieved.
Your task is to create a VariantManager class t... | codefeedback |
You are given a list of strings representing operations in a baseball game. Each operation is either an integer representing a number of points, the character "C" representing an operation to remove the last valid point, the character "D" representing an operation to double the last valid point, or the character "+" re... | codefeedback |
You are tasked with creating a Rust macro that generates a custom implementation for a trait based on the input struct. The macro should take a struct definition as input and generate an implementation for a specified trait. Your task is to write a macro that accomplishes this functionality.
Your macro should take the... | codefeedback |
You are tasked with implementing a function to retrieve information about the threads associated with a given process using a custom driver interface. The provided code snippet is part of a larger system that interacts with a kernel driver to perform this task. Your goal is to create a function that utilizes the driver... | codefeedback |
You are tasked with creating a Rust function that serializes a given struct into a JSON string using the `serde_json` crate. Your function should take a generic input parameter representing the struct and return a `Result` containing the JSON string if successful, or an error message if serialization fails.
Your funct... | codefeedback |
You are tasked with implementing a Python class method that constructs and returns a configuration dictionary for interacting with the Binance futures market using the CCXT library. The provided code snippet is a partial implementation of a class method `_get_ccxt_config` within a larger class. Your task is to complete... | codefeedback |
You are working on a water management system for a hydrology company. The system includes a class called `WaterMeter` which is used to monitor water usage. The `WaterMeter` class has the following attributes and methods:
Attributes:
- `id` (int): A unique identifier for the water meter.
- `location` (String): The loca... | codefeedback |
You are tasked with implementing a simple inflector library in Rust. An inflector library is used to convert words between their singular and plural forms, as well as to convert words between different cases (e.g., camel case, snake case). Your task is to implement a method to retrieve the classical inflector from the ... | codefeedback |
You are tasked with implementing a TypeScript class that extends the `AbstractGrid` class provided in the code snippet. The `AbstractGrid` class is used to create grid components in a web application and contains a property `gridOptions` of type `GridOptions`. Your task is to create a subclass `CustomGrid` that extends... | codefeedback |
You are tasked with creating a program that generates a magic square of order n. A magic square is a square matrix in which the sum of each row, each column, and both main diagonals is the same. The program should take an integer n as input and output the magic square of order n.
For example, a magic square of order 3... | codefeedback |
You are tasked with implementing the `asyncZip` function in TypeScript. The `asyncZip` function should take an array of arrays of values and return a new array of arrays where each element at index `i` contains the elements at index `i` of the input arrays. If the input arrays are of different lengths, the resulting ar... | codefeedback |
You are tasked with creating a Discord bot that monitors the system's CPU usage and alerts the server when the usage exceeds a certain threshold. You will need to implement a command that allows the bot to start monitoring the CPU usage and another command to stop the monitoring. Additionally, the bot should automatica... | codefeedback |
You are tasked with comparing the performance of two different methods for adding numbers in Python: using NumPy arrays and using simple Python lists. Your goal is to analyze the performance difference between the two methods for adding different numbers of elements.
You are given the following code snippet as a start... | codefeedback |
You are tasked with creating a web form for scheduling events. The form should include fields for the date, start time, and end time of the event. The date field should be pre-filled with the current date, and the start time field should be pre-filled with the current time. Users should be able to select the date and e... | codefeedback |
You are tasked with implementing a simple drawing application that responds to keyboard input to modify various drawing settings. The application has two drawing areas, each with its own set of properties. The properties include the alpha value, stroke cap, and color. The application should respond to specific keyboard... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.