instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are working on a Python project and need to create a setup script for packaging and distributing your code. The setup script is a Python file that contains metadata about your project, such as its version, description, author, and dependencies. You need to write a function that takes in this metadata as input and g... | magicoder |
You are tasked with implementing a distributed training system for a machine learning model. The system consists of multiple engines, each running on a separate machine, and a central server for coordination. The provided code snippet is a part of the engine's logic for saving and resetting checkpoints during the train... | magicoder |
You are tasked with implementing a custom type system for a programming language. The type system should support basic data types such as integers, floats, and strings, as well as user-defined types. Additionally, the type system should be able to handle type inference and type checking during compilation.
Your task i... | magicoder |
You are given a class `Person` with a private member variable `name` of type string. The class also has a default constructor and a parameterized constructor that takes a string as an argument to initialize the `name` member variable. Your task is to complete the class by adding a member function `printName` that print... | magicoder |
You are tasked with implementing an error module in a Swift application. The error module is responsible for displaying error messages and allowing the user to take action when an error occurs. The provided code snippet outlines the initial structure of the error module.
Your task is to implement the `ErrorModuleInput... | magicoder |
You are tasked with creating a game result prediction system for a guessing game. The game involves guessing a number from a given distribution, and the system should evaluate the correctness of the guesses and provide feedback to the players. The distribution of the numbers to be guessed is represented by a custom com... | magicoder |
You are tasked with implementing a function that generates unique combinations of characters from a given set. The function should take a set of characters as input and return a list of all possible unique combinations of these characters. A unique combination is a string that contains all the characters from the input... | magicoder |
You are tasked with creating a neural network model for predicting housing prices using the Boston Housing dataset. The dataset contains features such as crime rate, average number of rooms, and accessibility to highways, and the target variable is the median value of owner-occupied homes. You need to define a neural n... | magicoder |
You are tasked with creating a PHP function that connects to a MySQL database, executes a search query, and returns the results. The function should handle potential errors and ensure the database connection is properly closed.
You are given the following code snippet as a starting point:
```php
function buscar($b) {... | magicoder |
You are tasked with implementing a class that represents an action with a count, which may be a single value or a range. The class should support the ability to perform the action a specific number of times within the given count range. Your task is to create the `ActionWithCount` class with the following specification... | magicoder |
You are working on a Python testing framework and need to create a custom field class for validating and typecasting input values. Your task is to implement the `Field` class with the following requirements:
- The `Field` class should have the following attributes:
- `name`: a string representing the name of the fie... | magicoder |
You are working on a data processing task where you need to manipulate a list of dictionaries containing JSON data. Each dictionary represents an instance of data, and you are required to perform a specific transformation on the data based on certain conditions.
You are given a list of dictionaries `raw_data`, where e... | magicoder |
You are tasked with implementing a class that simulates an asynchronous operation and testing its progress reporting functionality using a unit test framework. The asynchronous operation will report progress using a callback function, and the test will verify that the reported progress matches the expected progress.
Y... | magicoder |
You are tasked with implementing a function that compares the output of a given function with the expected output read from a file. Your goal is to write a Python function that reads the expected output from a file, calls a given function with input data, and then compares the actual output with the expected output usi... | magicoder |
You are tasked with creating a Python function that simulates the process of adding a user to a group. The function should take two parameters: a username and a group name. The function should then return a string indicating the success or failure of adding the user to the group.
The function signature should be:
```p... | magicoder |
You are tasked with implementing a custom dictionary class in Python that supports both key-based and index-based access. The dictionary should allow the user to access values using either the key or the index, similar to how a regular dictionary allows key-based access and a list allows index-based access.
Your custo... | magicoder |
You are working on a project that involves processing and analyzing data from various sources. As part of this project, you need to extract specific information from a dataset that contains structured data in the form of key-value pairs. The dataset is represented as a list of dictionaries, where each dictionary contai... | magicoder |
You are tasked with creating a function that generates a TypeScript module exporting CSS styles based on a given input file. The function should take an object representing the file and its options and return a string representing a TypeScript module with the CSS styles.
The input object will have the following struct... | magicoder |
You are tasked with implementing a feature toggle system for a web application. A feature toggle, also known as a feature flag or feature switch, allows you to toggle certain features on or off without deploying new code. This can be useful for A/B testing, gradual feature rollouts, or temporarily disabling features.
... | magicoder |
You are working on a bioinformatics project that involves processing genomic data. Your task is to create a Nextflow process that takes a genome file as input, creates a symbolic link to it, and appends a sample name to the output file name.
You are given the following code snippet as a starting point:
```
input:
... | magicoder |
You are tasked with implementing a function that processes a given file and extracts specific information based on a predefined format. The file contains comments and metadata, and your function should extract the implementation details from the metadata section.
You are provided with a code snippet that represents a ... | magicoder |
You are working on a software project that involves managing sales data. As part of this project, you need to implement a function that processes and updates a dictionary containing sales-related information. The dictionary contains key-value pairs representing different aspects of sales data. Your task is to implement... | magicoder |
You are tasked with creating a class for generating and displaying reports in a web application. The class should have methods for displaying search options, sidebar search, exporting the report, and rendering the HTML output. Below is a simplified version of the class and its usage:
```php
class Report {
public f... | magicoder |
You are tasked with implementing a class that manages recipe casting targets for a cooking app. The class should handle the updating of suggested casting targets and the discovery of available casting targets. Your task is to write the implementation for the `RecipeCastingTargetsBrowser` class, including the required m... | magicoder |
You are tasked with implementing a keypoint prediction module for a computer vision system. The keypoint prediction module takes a list of input features and a list of instances, and produces predictions for keypoints within the given instances. Each instance represents an object or region of interest within an image, ... | magicoder |
You are tasked with implementing a method to handle page lifecycle changes in a C# application. The provided code snippet is a part of the method `HandlePageLifecycleChanged`, which is called when the page lifecycle changes. The method takes two parameters: `sender`, representing the sender of the event, and `args`, re... | magicoder |
You are tasked with implementing a Rust function that determines the target architecture for a given input architecture. The function should take an enum representing the input architecture and return the corresponding target architecture based on the following mapping:
- If the input architecture is `Arch::X86_64`, th... | magicoder |
You are tasked with creating a custom JSON encoding strategy for a specific data structure. Your goal is to implement a custom encoding strategy for a Swift struct that contains various data types. The struct represents a user profile and includes properties for the user's name, age, email, and a list of friends. You n... | magicoder |
You are tasked with implementing a custom indicator system for loading images in a SwiftUI-based application. The provided code snippet includes two methods for associating indicators with image loading. Your task is to create a custom IndicatorViewModifier and Indicator structure to support this functionality.
Your c... | magicoder |
You are tasked with creating a bash script to automate the installation of required Python packages for a machine learning project using `pip`. The script should upgrade `pip` to the latest version and then install a list of specified packages. Your task is to complete the bash script by iterating through the list of p... | magicoder |
You are tasked with implementing a generic class for searching and filtering data. The class contains a method for filtering data based on a search value and another method for validating the search value. Your task is to complete the implementation of the `SearchFilter` class by providing the missing methods.
You are... | magicoder |
You are given an array `sizes` containing the sizes of different datasets and an empty 2D array `inputs`. Your task is to generate random input data for each dataset size and populate the `inputs` array with the generated data.
The input data for each dataset size should be an array of random numbers. The length of th... | magicoder |
You are given a code snippet written in Swift, which contains a series of declarations and definitions related to classes and structs. Your task is to analyze the code and identify the relationships between the entities defined in the snippet.
Your goal is to determine the inheritance and conformance relationships bet... | magicoder |
You are tasked with creating a Rust function that simulates the decoding of a file to obtain a movie object using the Android Graphics Movie API. The function `decodeFile` takes an environment reference `__jni_env` and a file path `arg0` as input and returns a result containing either a movie object or an error. The fu... | magicoder |
You are tasked with implementing a configuration update function for a Python project. The function takes in several parameters and is responsible for updating the project's configuration settings based on the provided inputs. Your task is to complete the implementation of the `update_config` function, ensuring that th... | magicoder |
You are tasked with implementing a simple text filtering system for a web application. The system should allow users to update the text associated with a specific filter state namespace. The provided code snippet is a part of the existing codebase and contains a function that needs to be completed.
You are given the f... | magicoder |
You are given a 2D grid represented by a 2D array of characters. The grid contains players denoted by different characters, and each player has a specific direction (up, down, left, or right) denoted by '^', 'v', '<', or '>'. The players can move within the grid in their respective directions.
Write a function or meth... | magicoder |
You are tasked with creating a Python class that reads and parses configuration settings from a file using the `ConfigParser` module. Your task is to complete the `Config` class by adding a method that retrieves a specific configuration value based on the provided key.
You are given the following code snippet as a sta... | magicoder |
You are tasked with creating a Python module that handles importing submodules from different packages. Your goal is to write a function that can dynamically import submodules from a specified package and handle potential import conflicts.
Write a function called `import_submodule` that takes two arguments:
1. `packag... | magicoder |
You are tasked with implementing a custom button class in Java that extends the AbstractButton class. The custom button should have a specific behavior for drawing a check icon and a method for determining the text-icon gap. Your task is to complete the implementation of the custom button class by providing the missing... | magicoder |
You are given a function `assertEqual` which is used for unit testing in a software project. The function takes two arguments: the actual value and the expected value, and it checks if they are equal. If they are not equal, it raises an assertion error.
Your task is to implement a similar function called `customAssert... | magicoder |
You are tasked with implementing a simple task scheduler for a web application using C++ and Emscripten. The task scheduler should allow the execution of multiple tasks in a non-blocking manner. Each task will be represented by a function pointer and will be executed in a separate thread. Your goal is to implement the ... | magicoder |
You are tasked with implementing a calibration function for a device that measures physical quantities. The function `calibrate` takes two parameters: `device`, a string representing the type of device being calibrated, and `target`, a numerical value representing the desired calibration target. The function should ret... | magicoder |
You are tasked with implementing a class for managing parameters in a software system. The class, named `Param`, is responsible for storing and manipulating parameters with a given name, type, and value. The class should provide methods for setting and getting the parameter value.
The `Param` class has the following a... | magicoder |
You are tasked with creating a Python function that simulates a simple game of guessing a randomly generated number. Your function should generate a random number between 1 and 10 (inclusive) and then prompt the user to guess the number. The function should return a message indicating whether the user's guess matches t... | magicoder |
You are tasked with implementing a Python class that performs a specific operation on given input parameters. The class `Pkhbt` inherits from the `AbstractOpcode` class and has an initializer method `__init__` that takes in six parameters: `tb_form`, `m`, `d`, `n`, `shift_t`, and `shift_n`. Your task is to complete the... | magicoder |
You are tasked with implementing a Python class that manages links and work plans for a project management system. The class should have a method to retrieve the base link to a work plan from a given URL. Your task is to complete the implementation of the `get_base_link_to_workplan` method in the `ProjectManager` class... | magicoder |
You are working on a project that involves processing data through a pipeline of workers and conducting research on the processed data. The project structure includes the following components:
1. `workers.py`: This module contains the definition of the `PipelineWorker` class, which is responsible for processing data i... | magicoder |
You are working on a voting system for a company's board of directors. The company has a total of `n` board members, and decisions are made based on a quorum threshold. The quorum threshold is defined as the minimum number of votes required for a decision to be valid.
You are given an array `votes` of length `n`, whe... | magicoder |
You are tasked with implementing a method to identify and throw an exception for unsupported features in a given HBase column descriptor. The HBase column descriptor is represented by the class `HColumnDescriptor`, and the method `throwIfRequestingUnsupportedFeatures` should throw an exception if any unsupported featur... | magicoder |
You are tasked with creating a Python program to manage a simple inventory system for a small business. The program should allow users to add, remove, and update items in the inventory, as well as display the current inventory status.
Your program should include a class `Inventory` with the following methods:
- `__ini... | magicoder |
You are tasked with implementing a Python function to analyze and process training metrics for a machine learning model. The function will take in three parameters: `fpr` (false positive rate array), `tpr` (true positive rate array), and `n_class` (array of class counts). The function should calculate the accuracy, log... | magicoder |
You are tasked with implementing a Python class that represents an HTTP response. The class should have the following attributes and methods:
Attributes:
- `addresses`: A list of addresses
- `isFatal`: A boolean indicating if the response is fatal
- `retry`: An integer representing the number of retries
Methods:
- `_... | magicoder |
You are tasked with implementing a middleware function for an Express.js application that verifies JSON Web Tokens (JWT) using the jose library. The middleware function should extract the JWT from the request headers, verify its authenticity and integrity, and then attach the decoded token payload to the request object... | magicoder |
You are tasked with creating a program to analyze Verilog files and extract specific information from them. Your program needs to read Verilog files, identify LFSR (Linear Feedback Shift Register) modules, and extract the size of each LFSR module found in the files.
Your task is to implement a function that takes a li... | magicoder |
You are tasked with implementing a text processing function that handles URL encoding and decoding. Your function should take a string as input and perform the following operations in sequence:
1. If the input string starts with '%', decode the URL-encoded characters using the `urllib.parse.unquote` function from the ... | magicoder |
You are tasked with implementing a function to calculate the distance between two points in a 2D plane using the concept of square roots and constants. The distance between two points (x1, y1) and (x2, y2) in a 2D plane is given by the formula: distance = sqrt((x2 - x1)^2 + (y2 - y1)^2).
You are provided with the foll... | magicoder |
You are tasked with implementing a function that processes geographic data. The function takes in a dictionary representing a geographic item, and it needs to update the 'geometry' key in the dictionary with a buffered geometry. The buffered geometry is provided as input to the function. Your task is to write a functio... | magicoder |
You are working on a data processing task for a renewable energy company. The company has a dataset containing information about different load zones and their corresponding generation projects. Your task is to write a function that replaces specific rows in the dataset with new values based on the provided criteria.
... | magicoder |
You are working on a program to solve the traveling salesman problem using a metaheuristic algorithm. The given code snippet is a part of the local search algorithm that aims to find an improved solution by exploring neighboring solutions. The algorithm maintains the best solution found so far (`solbest`) and its corre... | magicoder |
You are tasked with creating a Python program that utilizes multiprocessing to download, modify, and upload a list of URLs. The program should make use of the provided modules and classes to achieve this functionality.
The program should perform the following steps:
1. Download the content of each URL in parallel usin... | magicoder |
You are tasked with creating a Python function to normalize a wiggle file by the total number of reads in a dataset. A wiggle file is a file format used to represent dense, continuous data such as read coverage in genomics. The normalization process involves dividing each value in the wiggle file by the total number of... | magicoder |
You are tasked with implementing a mock points manager for a gaming application. The `MockPointsManager` class is designed to mimic the behavior of a real points manager and implements the `IPointsManager` interface. The class contains several properties and methods for tracking and managing points. Your goal is to com... | magicoder |
You are working on a web application that manages documents and questionnaires. The application uses Django and has a set of URL patterns defined in the `urls.py` file as shown in the code snippet below:
```python
path('<int:pk>/document/create/', DocumentCreateView.as_view(), name='document-create'),
path('<int:pk>/q... | magicoder |
You are tasked with implementing a simple API routing system for a web application. The application should be able to handle different HTTP methods (GET, POST, PUT, DELETE) and route them to the appropriate handler functions. Each route can have parameters specified in the URL, and these parameters should be extracted ... | magicoder |
You are tasked with implementing a data parsing algorithm for the MTS Log protocol used in automotive diagnostics. The MTS Log protocol is a proprietary communication protocol used by Innovate Motorsports for logging data from sensors in a vehicle. The protocol specifies the format and periodicity of data packets trans... | magicoder |
You are tasked with implementing a function that manipulates stack views in a user interface. Stack views are a fundamental component in iOS development for laying out a collection of views either horizontally or vertically. Your task is to create a function that takes in an array of event views and arranges them in a ... | magicoder |
You are tasked with creating a Django migration for a new model that represents a user's profile. The profile model should include fields for the user's name, email, date of birth, and bio. Additionally, you need to create a migration that sets a default value for the bio field to "This user has not provided a bio yet.... | magicoder |
You are tasked with implementing a Python class for 3D vectors, called `Vec3`, which supports various operations. The class should have the following functionalities:
- Addition of two vectors using the `+` operator.
- Subtraction of two vectors using the `-` operator.
- Multiplication of a vector by a scalar using the... | magicoder |
You are tasked with implementing a function that draws a dashed line on a given context. The function should take into account the zoom scale and other parameters to ensure the line is drawn correctly.
Write a function `drawDashedLine` that takes the following parameters:
- `context`: A graphics context on which the l... | magicoder |
You are tasked with creating a Python class that manages upvotes for different auctions. Your task is to implement the `Upvote` class with the following requirements:
- The `Upvote` class should have a method `get_upvotes` that takes an `id` parameter representing the auction ID and returns a list of upvotes associate... | magicoder |
You are tasked with creating a simple dependency injection system for a space simulation application. The application uses the Unity container for dependency resolution. Your task is to implement the necessary classes and interfaces to enable the application to resolve dependencies and run the simulation.
You are prov... | magicoder |
You are tasked with implementing a function that takes a list of dictionaries representing neural network weights and saves them to a file in a specific format. Each dictionary in the list contains a key 'w' whose value is a 2D array of weights. The function should convert these weights to a specific format and write t... | magicoder |
You are tasked with implementing a custom user details service for a Spring Security application. The `UserDetailsServiceImpl` class needs to implement the `UserDetailsService` interface and provide functionality to load user-specific data. The user details will be stored in a `User` class, which contains the user's us... | magicoder |
You are tasked with creating a Python decorator that logs the execution time of a function. The decorator should print the name of the function, its execution time, and the arguments passed to the function. You should also handle both positional and keyword arguments.
Your task is to implement the `@log_execution_time... | magicoder |
You are tasked with implementing a Rust macro that formats a given type with parentheses. The macro should take a type as input and return the formatted type enclosed within parentheses. Your task is to complete the implementation of the macro `format_with_parentheses` by filling in the missing parts.
```rust
macro_ru... | magicoder |
You are tasked with creating a Python class to tune the hyperparameters of a neural network model using different text vectorization techniques. The class should be able to handle various hyperparameters and vectorization methods, and save the resulting scores to a CSV file. Your task is to implement the `TuneNeuralNet... | magicoder |
You are tasked with implementing a Python class that represents a data series. The class should have various attributes and methods to handle data manipulation and analysis. Your task is to complete the implementation of the `Series` class by adding a method that calculates the average value of the data series.
Here i... | magicoder |
You are tasked with creating a function that processes requests to edit admin role permissions. The function receives a request containing an admin ID and should handle the following cases:
1. If the admin with the given ID does not exist, the function should return a failure response.
2. If the admin with the given ID... | magicoder |
You are tasked with creating a web application that displays a list of product categories in a sidebar menu. The categories are fetched from a database table called `type_products` using the Laravel framework. The code snippet provided is a part of the Blade template file that generates the sidebar menu.
Your task is ... | magicoder |
You are tasked with implementing a function `parlay_odds(odds)` that takes in a parameter `odds`, which can be either an integer, a float, or a list of integers or floats. The function should return the parlay odds based on the input. Parlay odds are used in sports betting to calculate the potential payout for a combin... | magicoder |
You are tasked with implementing a music playlist management system in Python. You need to create a class `music_list` that allows users to add music tracks to a playlist and play them using a music player. The `music_list` class should have a method `append_music` to add music tracks to the playlist. Each music track ... | magicoder |
You are tasked with creating a Python script to automate the evaluation of natural language processing systems using paired bootstrap resampling. The paired bootstrap resampling technique is commonly used to compare the performance of two systems on a given task, such as part-of-speech tagging or dependency parsing.
Y... | magicoder |
You are working on a script that manages the submission and translation of articles. The script contains several functions that enforce rules for submitting and translating articles. Each function checks specific conditions and outputs a message if the conditions are met. Your task is to implement a new function for su... | magicoder |
You are working on a web scraping project using Python and the Scrapy framework. You have a class `SecurityItem` that inherits from the `Item` class provided by Scrapy. The `SecurityItem` class is used to define the fields for scraping security-related information from various websites. One of the fields defined for th... | magicoder |
You are tasked with creating a multithreaded program that simulates a job queue. The program should consist of a main thread that generates jobs and a worker thread that processes these jobs. The main thread will continuously generate random integers and pass them to the worker thread for processing. The worker thread ... | magicoder |
You are tasked with creating a script to automate the build process for a web application. The build process involves running the commands `yarn && yarn build` in the current directory, followed by navigating to the `../node-server/` directory and running `yarn` there.
Write a shell script that accomplishes this build... | magicoder |
You are tasked with creating a class to represent a medical information view in a mobile application. The class should be able to initialize with specific disease information and geographical coordinates. Your task is to implement the `MedicalInfoView` class in Swift, which should have the following properties and meth... | magicoder |
You are given a list of strings representing the names of various counties in Florida. Your task is to write a function that takes this list as input and returns a new list containing only the names of counties that start with the prefix "St." in alphabetical order.
Write a function `filter_counties` that takes a list... | magicoder |
You are tasked with implementing a Python class method that processes a dictionary and returns a modified version of it. The dictionary contains nested data and your task is to extract specific values and restructure the dictionary based on certain rules.
You are given a Python class with a method `process_data` as sh... | magicoder |
You are tasked with implementing a custom collection view layout and its delegate methods in Swift. The layout, `CollectionViewPagingLayout`, is designed to support a paging behavior for a collection view, and the delegate, `CollectionViewPagingLayoutDelegate`, provides methods for handling user interactions and tracki... | magicoder |
You are given a sorted vector of strings representing numbers from 1 to 1000. However, the vector has been corrupted, and some of the numbers are missing. Your task is to write a function that finds the missing numbers in the vector and returns them in ascending order.
Write a C++ function with the following signature... | magicoder |
You are tasked with implementing a program that processes and displays information about key descriptions. The `KeyDescs` struct contains a vector of `KeyDesc` instances, and the `KeyDesc` struct represents a key description. Your task is to write a function that takes a `KeyDescs` instance and returns a formatted stri... | magicoder |
You are tasked with implementing a shell script that processes a list of test files and runs a batch test on each file. The script should display a success message if the test passes and handle failures appropriately.
Your script should take the following form:
```bash
#!/bin/bash
# Your code here
while [ -n "$1" ]... | magicoder |
You are tasked with creating a Python class to manage chapters in a digital magazine application. The class should handle the display of content and user interaction. Your task is to implement the `Mag` class with specific methods and attributes.
The `Mag` class should have the following attributes:
- `title`: A strin... | magicoder |
You are tasked with creating a Python function that interacts with the BitBucket API to retrieve repository tags. Your function should handle potential exceptions and return the list of tags if the API call is successful.
Write a function `get_bitbucket_tags(url, user_repo)` that takes in two parameters:
- `url` (stri... | magicoder |
You are tasked with creating a program that analyzes a given text file to count the occurrences of specific license-related comments. The comments are formatted in a specific way and contain information about the license type and its limitations. Your program should be able to identify and count the occurrences of thes... | magicoder |
You are tasked with implementing a contact management system using Python. The system should support adding, deleting, changing, and searching for contacts. Each contact will have a name, phone number, and birthday. The contact information will be stored in a file using a specific format.
Your task is to implement the... | magicoder |
You are tasked with creating a Python function that processes a list of help articles and generates a formatted help page for a web application. Each help article is represented as a dictionary with keys "title" and "content". The function should take a list of such dictionaries and produce an HTML page displaying the ... | magicoder |
You are tasked with creating a program that simulates a simple navigation system for a robot. The robot is placed on a grid and can move in four directions: north, south, east, and west. The robot is controlled by a series of commands that are passed to it. The commands are as follows:
- "N" to move the robot one unit ... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.