instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with implementing a method to clear a specific property in a builder class. The builder class is used to construct instances of a data structure, and the method should reset the property to its default value and update the builder's internal state accordingly.
You are given a code snippet that partially... | magicoder |
You are tasked with creating a Python script that automates the deployment process for a Django web application using uWSGI. Your script should perform the following tasks in sequence:
1. Run Django's `makemigrations` command to create new database migration files.
2. Apply the database migrations using Django's `migr... | magicoder |
You are tasked with implementing a search functionality for a trip management system. The system has a `Trip` model with the following fields: `trip_type`, `trip_id`, `location_id`, and `order`. The `fieldSearchable` array contains the fields that are searchable. Your task is to create a method that constructs a query ... | magicoder |
You are working on a project that involves processing geographical data stored in numpy arrays. You have a directory containing multiple numpy files, each representing a grid of geographical coordinates. Your task is to write a Python function to validate whether the number of numpy files in the directory matches the e... | magicoder |
You are tasked with creating a Django migration to add a new field to an existing model. The model represents news articles in a content management system (CMS). The new field to be added is a "publish_date" field, which will store the date and time when the article is published. The migration should set a default valu... | magicoder |
You are tasked with implementing a context manager in Python that can be used to track the source of layer creation in a visualization application. The context manager should allow routines in the application to declare the source of any layers created within its context. This is important for maintaining a record of t... | magicoder |
You are tasked with implementing a credit card number validation function. The function should take a credit card number as input and return a boolean value indicating whether the number is valid according to the Luhn algorithm and matches the pattern of a specific credit card provider.
The Luhn algorithm is used to v... | magicoder |
You are tasked with implementing a genetic algorithm for a binary string representation. The genetic algorithm uses single-point crossover to create offspring from parent genotypes. Your task is to complete the implementation of the `SinglePointCrossover` class by filling in the `Cross` method.
The `SinglePointCrossov... | magicoder |
You are tasked with implementing a custom data mapping function for a dataset processing system. The system uses a DatasetMapper class to process datasets, and a custom_mapper function is provided to modify the dataset list. Your task is to implement the custom_mapper function to perform specific modifications to the d... | magicoder |
You are tasked with implementing a simple weak reference virtual proxy class in Swift. A weak reference virtual proxy is a design pattern used to control access to an object that is expensive to create or is located on a remote server. The proxy acts as a stand-in for the real object and is responsible for creating, ma... | magicoder |
You are tasked with creating a simple web application using Streamlit, a popular Python library for building interactive web applications. Your goal is to create a web page that allows users to input data and then displays the prediction based on that input. The prediction logic is implemented in a separate file called... | magicoder |
You are tasked with implementing a gradient descent algorithm for a function with one variable. Gradient descent is an iterative optimization algorithm used to find the minimum of a function. The goal is to minimize a given function by adjusting its input parameter iteratively. Your task is to implement the gradient de... | magicoder |
You are tasked with implementing a function to detect and resolve collisions in a hierarchical data structure. The data structure is represented as a tree, where each node can have child nodes. The goal is to identify any nodes of type `CGComm` that share the same parent node and resolve the collisions by updating thei... | magicoder |
You are tasked with implementing a function that processes data from a plot model and performs a specific operation based on the extracted value. The function `plot_->modelValue(visibleColumnInd, ok)` retrieves the value from the plot model for the given `visibleColumnInd` and sets the boolean variable `ok` to indicate... | magicoder |
You are tasked with implementing a command-line interface for a simulation tool selection program. The program should allow users to specify which simulation tool to use for different stages of the design process. The available options are "Icarus Verilog", "Xcelium", and "Xcelium Synthesis". Each tool has specific opt... | magicoder |
You are tasked with creating a Rust module that handles simulation options and parameters for a race simulation program. The module should include functionality for checking simulation options and parameters, reading simulation parameters, and defining simulation options.
Your task is to implement the `sim_opts` modul... | magicoder |
You are tasked with creating a Python module that handles data processing for a scientific experiment. The module should include a function to calculate the average intensity of the collected data. The collected data is stored in a list of integers, and the average intensity is defined as the sum of all the data points... | magicoder |
You are working on a deep learning project and need to implement a custom neural network architecture. The architecture involves creating several sequential models and combining them to form a larger network. Each model is represented as a sequence of layers, and the final architecture is constructed by stacking these ... | magicoder |
You are tasked with creating a program that processes a list of flag action properties and performs specific operations based on the properties provided. Each flag action property consists of a key-value pair representing a specific action and its corresponding properties. Your task is to implement a function that proc... | magicoder |
You are tasked with implementing a custom form class for updating comments in a web application. The provided code snippet is a part of a Django-based web application and shows a view class for updating comments. The view class inherits from `LoginRequiredMixin`, `CommentSecureRedirectToMixin`, and `UpdateView`. It spe... | magicoder |
You are tasked with creating a Python program that converts RGB color values to CMYK color values. The RGB color model is represented by three values (R, G, B) ranging from 0 to 255, while the CMYK color model is represented by four values (C, M, Y, K) ranging from 0% to 100%. The conversion formulas are as follows:
C... | magicoder |
You are tasked with creating a Python class that generates a 3D model of an AstroPi using the Minecraft API. The provided code snippet is a part of the class that initializes the MinecraftShape and creates the AstroPi model using setBlock(s) commands. The setBlocks method is used to define the structure of the AstroPi,... | magicoder |
You are tasked with implementing a function that calculates the total size of a boxplot based on the given options. A boxplot is a method for graphically depicting groups of numerical data through their quartiles. The given code snippet defines a set of default options for a boxplot, including the padding around the bo... | magicoder |
You are tasked with creating a Python function that extracts the filename from a given FTP URL. The function should take a string representing an FTP URL as input and return the filename extracted from the URL.
The FTP URL format is as follows:
```
ftp://<hostname>/<filename>
```
Where `<hostname>` represents the FTP ... | magicoder |
You are tasked with implementing a function that simulates a simplified version of an activity view controller in iOS. The function should take in various parameters and return a formatted string representing the configuration of the activity view controller.
The function signature is:
```swift
func configureActivityV... | magicoder |
You are tasked with implementing a custom string manipulation function in C#. Your function should take a string as input and return a new string with the characters reversed. However, there is a twist - you are not allowed to use any built-in string reversal functions or data structures such as arrays or lists. You mu... | magicoder |
You are tasked with implementing a simple enemy AI behavior for a 2D game. The enemy should be able to search for and track nearby players within a certain range. The enemy's behavior is defined by the following properties:
- `angleRange`: A float representing the angular range within which the enemy can detect and tr... | magicoder |
You are tasked with implementing a custom indicator logic for analyzing financial market data. The given code snippet provides a partial implementation of the indicator logic within a class. The class has two deque objects, `high` and `low`, with a specified maximum length `period`. Additionally, there is a variable `l... | magicoder |
You are given a code snippet that uses the pandas library in Python to work with Series data structures. Your task is to write a function that performs a specific operation on pandas Series and returns the result.
Write a function called `multiply_series` that takes two pandas Series as input and returns a new Series ... | magicoder |
You are tasked with creating a Python function that processes a given Alembic migration script and extracts the table constraints that are being dropped during the upgrade process.
You are provided with a sample Alembic migration script snippet as follows:
```python
revision = '<KEY>'
down_revision = '<KEY>'
branch_la... | magicoder |
You are tasked with creating a Django admin interface for managing a whitelist of users who have special permissions. The provided code snippet is from a Django admin class that customizes the fields and readonly fields displayed in the admin interface for managing the whitelist.
Your task is to implement a function t... | magicoder |
You are tasked with creating a PHP function that processes a given HTML file and extracts all the text content within the `<div class="fill">` element. The function should return the extracted text content as a string. Assume that the HTML file is well-formed and contains the specified `<div>` element.
Your task is to... | magicoder |
You are tasked with implementing a function to calculate the length of a given memoryview object or bytes object. The function should return the number of bytes in the memoryview or bytes object.
Write a Python function `get_length(obj)` that takes a memoryview or bytes object as input and returns the number of bytes ... | magicoder |
You are tasked with implementing a Rust program to simulate a space mission's emergency beacon activation system. The program should consist of a `Spacecraft` struct with methods to control the activation and status of the emergency beacon. The emergency beacon should be activated when the `activate_beacon` method is c... | magicoder |
You are working on a project that involves interfacing with a Measurement and Test System (MTS) library. The MTS library provides several functions for initializing, executing, and logging information. You need to create a Python wrapper class to encapsulate these functions and provide a more user-friendly interface.
... | magicoder |
You are tasked with creating a Python class for evaluating the operational and maintenance (O&M) costs of offshore wind turbine components. The class, `opex_ecn_offshore_component`, inherits from a parent class called `Component`. The class has several attributes and parameters that are crucial for evaluating the O&M c... | magicoder |
You are tasked with implementing a sectioned list observer for a custom data store framework. The framework provides a `CSListMonitor` class for monitoring changes to a sectioned list of entities. The `CSListMonitor` is initialized with a sectioned fetch request, and it can notify its observers of changes to the list s... | magicoder |
You are tasked with creating a simple Android login application that validates user input and displays a progress bar while processing the login request. The provided code snippet initializes the necessary UI components for the login screen. Your task is to implement the login functionality by validating the email and ... | magicoder |
You are working on a data processing project using Apache Spark's RDD-based API. As part of the project, you need to perform operations on sparse vectors. In this context, you are required to implement a function that takes a list of sparse vectors and calculates the cosine similarity between each pair of vectors.
A s... | magicoder |
You are tasked with creating a Python function that processes a log file and extracts error reporting activities. The log file contains lines of text, and each line may or may not contain an error reporting activity. An error reporting activity is denoted by the presence of the string "Error reporting" followed by a sp... | magicoder |
You are tasked with implementing a function that processes user input for sorting and preset options in a messaging application. The function takes in two parameters: `sorting_type` and `preset`. The `sorting_type` parameter represents the selected sorting option, and the `preset` parameter represents the selected pres... | magicoder |
You are tasked with creating a Python script that generates documentation for a given Python module. The script should extract information about the module's classes, functions, and their docstrings, and then format this information into a human-readable document.
Your task is to implement the `gen_doc.py` script that... | magicoder |
You are tasked with creating a Python script that automates the generation of command-line entry points for a Flask application. The script should take a list of command-line entry points and their corresponding functions, and generate the necessary configuration for the `setuptools` package to enable these entry point... | magicoder |
You are tasked with implementing a context menu feature for a tree explorer application. The application provides a tree structure of nodes, and when a user right-clicks on a node, a context menu should be displayed with relevant options. The context menu should be populated based on the attributes of the selected node... | magicoder |
You are tasked with implementing a generic class that performs a specific operation on a given input. Your task is to complete the implementation of the `Invoker` class, which contains a method `Invoke` that takes a single parameter of type `T` and returns the same type `T`. The `Invoke` method should simply return the... | magicoder |
You are tasked with creating a smart contract for a new token standard called CEP47. The CEP47 token standard is similar to the popular ERC20 standard on the Ethereum platform. Your task is to implement the deployment function for the CEP47 token smart contract.
The provided code snippet is a part of the deployment fu... | magicoder |
You are tasked with creating a program that processes a given license file and extracts the license type based on the SPDX-License-Identifier tag present in the file. The SPDX-License-Identifier tag is a standard way of declaring the license type of a software component.
Your program should read the contents of the li... | magicoder |
You are tasked with implementing a secure login system for a web application. The provided code snippet is a part of the login functionality, which includes capturing user login details and authenticating the user session. The code also ensures that the user is accessing the login page over a secure HTTPS connection.
... | magicoder |
You are tasked with implementing a class that manages a collection of strings and their associated IDs. The class should provide functionality to add a new string with a unique ID, retrieve a string by its ID, and remove a string by its ID. Additionally, the class should support the ability to retrieve the ID of a give... | magicoder |
You are tasked with creating a Python function that validates a list of IP addresses against a given IP network. The function should raise specific exceptions for different scenarios, and handle both IPv4 and IPv6 addresses.
Write a function `validate_ip_addresses(ip_list, network_str)` that takes in a list of IP addr... | magicoder |
You are tasked with creating a class to manage book information, including the book's price. Your task is to implement a method that validates and sets the price of the book. The price should be a positive number with up to two decimal places. If the input is invalid, the method should not update the price.
You are gi... | magicoder |
You are tasked with implementing a function that escapes HTML attributes in a given string. The function should take a string representing an HTML tag with existing attributes and a dictionary of new attributes to be added. The goal is to properly escape the new attribute values and integrate them into the HTML tag.
T... | magicoder |
You are tasked with creating a Python function that parses a given code snippet and extracts specific information from it. The code snippet is in the format of a string and contains metadata related to a GitHub repository and a Python file.
The function should take the code snippet as input and extract the following i... | magicoder |
You are tasked with implementing a mesh generation system for a finite element analysis code. The code snippet provided is a part of the mesh generation process and uses the Teuchos and Panzer libraries. The snippet initializes a mesh factory based on the cell type and then proceeds to construct an uncommitted mesh.
Y... | magicoder |
You are given a scenario where a chemical reaction is taking place. The reaction involves two chemical components, carbon (C) and oxygen (O). The reaction proceeds according to the following rules:
- If the amount of carbon (C) is at least half of the amount of oxygen (O), then the reaction can occur.
- When the reacti... | magicoder |
You are tasked with implementing a custom lock mechanism in Rust to manage concurrent access to a shared resource. The lock should support both exclusive and shared access, and it should handle potential errors that may arise from concurrent access.
Your task is to implement a custom lock structure `CustomLock` and it... | magicoder |
You are tasked with implementing a Python function that processes a list of import statements and returns a dictionary containing the imported modules and their corresponding classes or functions. Each import statement follows the format `from <module> import (<class1>, <class2>, ...)`. If a module is imported multiple... | magicoder |
You are tasked with implementing a simple text processing function that takes a string as input and returns a modified version of the string based on certain rules. The function should replace all occurrences of the word "text" with "string" and append the phrase "Request processed successfully" at the end of the modif... | magicoder |
You are tasked with creating a Python function that processes image files from a specified directory and creates a zip file containing the processed images. The function should take in the directory path as input and perform the following steps:
1. List all the files in the specified directory.
2. Filter out non-image ... | magicoder |
You are tasked with creating a utility function to extract the file extension from a given file path. The file path will be a string representing the path to a file, and the function should return the file extension as a string. The file extension is defined as the substring following the last occurrence of the dot (.)... | magicoder |
You are working on a software testing project and need to create a program to verify the behavior of a function that builds multiple modules. The function `build_multi_modules` takes several parameters including the repository directory, settings file, and logback file. The code snippet provided contains assertions to ... | magicoder |
You are tasked with implementing a thread-safe plugin manager in C++. The plugin manager should support adding, removing, and retrieving plugins while ensuring thread safety. The provided code snippet is a part of the plugin manager class and includes a macro for validating non-null input and acquiring a lock using an ... | magicoder |
You are tasked with creating a Django migration for a model named `Image` in the `award` app. The migration should rename a field within the `Image` model. The existing field name and the new field name are not provided in the code snippet. Your task is to write the migration operation that renames the field, ensuring ... | magicoder |
You are tasked with implementing a Java class that represents a simple SQL SELECT query builder. The class should allow users to construct SELECT queries by specifying the columns to select, the table to select from, and any additional conditions.
You need to complete the implementation of the `Select` class, which is... | magicoder |
You are given an array of integers `arr`. Your task is to implement a function that sorts the array in non-decreasing order using a specific sorting algorithm. The sorting algorithm works as follows:
1. Find the minimum value in the array.
2. Swap the minimum value with the first element of the array.
3. Repeat the abo... | magicoder |
You are working on a data processing system for atmospheric data collected by a remote sensing device. The system interacts with an API to download raw data and then processes it to correct any anomalies. The code snippet provided is a part of this system and shows the download process for ceilometer (CEIL) data using ... | magicoder |
You are tasked with implementing a test case management system for a software testing framework. The system needs to create a custom browser object with specific properties and settings.
You are provided with a code snippet that initializes a custom browser object with the following properties:
- `Page`: The filename ... | magicoder |
You are tasked with implementing a function that takes in a tuple and provides default values for some of its elements. The function should also handle variadic parameters and caller-side default values.
Write a function `processTuple` that takes in a tuple `inputTuple` of type `(Int, Int)` and two optional parameters... | magicoder |
You are given a list of strings representing motions and postulates in a parliamentary setting. Each string consists of a combination of words and may contain uppercase letters, lowercase letters, and punctuation marks. Your task is to write a function to analyze the given list and count the occurrences of the words "P... | magicoder |
You are tasked with creating a function that modifies a given code by inserting import statements and method calls for a set of plugins. The function `addPlugins` takes two parameters: `originalCode`, a string representing the original code, and `plugins`, an array of strings representing the names of the plugins to be... | magicoder |
You are tasked with implementing a custom data type called `Number` in Rust, which can represent either a boolean value or an unsigned 64-bit integer. The `Number` type should have three variants: `Bool`, `UInt`, and `Error`. The `Bool` variant should store a boolean value, the `UInt` variant should store an unsigned 6... | magicoder |
You are tasked with implementing a Python function that encodes a given string based on a provided mask. The mask is a list of integers, where each integer represents the number of characters to shift in the string. The encoding process involves shifting each character in the string by the corresponding amount specifie... | magicoder |
You are tasked with creating a program that processes and analyzes error messages generated during the compilation of a software project. The error messages are in a specific format and contain information about the type of error, the file in which it occurred, and the line number. Your program needs to parse these err... | magicoder |
You are tasked with implementing a Python function that processes a list of API endpoints and returns a dictionary containing the count of each unique API category. Each API endpoint is represented as a string in the format "category_endpoint", where "category" is the category of the API and "endpoint" is the specific ... | magicoder |
You are tasked with optimizing a sieve algorithm for finding prime numbers. The sieve algorithm works by iteratively marking the multiples of each prime number starting from 2, and the unmarked numbers are prime. The cost of the sieve algorithm is determined by the time it takes to run and the resources it consumes. Yo... | magicoder |
You are tasked with creating a custom form layout class in Python that populates itself from a list of form fields. Each form field is represented as a dictionary containing the field's properties. Your task is to implement the `FormBuilderLayout` class, which is a custom subclass of `QFormLayout` from the PyQt5 librar... | magicoder |
You are tasked with creating a Java program to handle logging for an email sending application. The program should utilize the built-in Java logging framework to log any exceptions that occur during the email sending process. Your task is to implement the necessary code to achieve this functionality.
Your program shou... | magicoder |
You are tasked with implementing a user management system for a database. The system involves executing SQL queries to retrieve and create user information. You are provided with a code snippet that contains two functions: `get_user_info` and `create_user`.
The `get_user_info` function takes in a database connection `... | magicoder |
You are tasked with implementing a simple health bar system for a game. The health bar is represented by a numerical value, and the player's health decreases over time. Your task is to create a class that manages the health bar and provides methods for updating the health value and checking if the player's health has r... | magicoder |
You are tasked with implementing a class that represents equipment in a manufacturing plant. The class should have properties to retrieve the equipment's class and group enums. The enums are defined in the `EquipmentClass` and `EquipmentGroup` classes. Your task is to complete the implementation of the `Equipment` clas... | magicoder |
You are tasked with creating a Java program that processes a set of words and returns the unique characters present in each word. You need to implement a method that takes a set of words as input and returns a set of unique characters present in each word. The program should ignore any non-alphabetic characters and tre... | magicoder |
You are tasked with implementing a key-value parser that reads a string in a specific format and extracts key-value pairs from it. The input string is in the format of "key1=value1,key2=value2,key3=value3,...", where each key-value pair is separated by a comma. The keys and values can contain any characters except for ... | magicoder |
You are tasked with creating a Django model for managing membership requests in a social networking application. The model should represent a request from a user to join a specific group. The code snippet provided is a partial representation of the Django model for managing membership requests.
Your task is to complet... | magicoder |
You are tasked with implementing a Python class that represents a simple bank account. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should keep track of the account holder's name and account number. Your task is to complete the implemen... | magicoder |
You are tasked with implementing a local ID generator function in Python. The local ID generator should produce unique IDs within a specified range. To ensure the correctness of the generator, you need to write a test case using the `unittest` framework to verify that the generated IDs are unique and of the correct typ... | magicoder |
You are tasked with creating a program that simulates a simple compiler pass system. A compiler pass is a specific stage in the compilation process where the compiler performs a particular analysis or transformation on the code. In this problem, you will implement a simplified version of a compiler pass system using ob... | magicoder |
You are tasked with implementing a simple encoding and decoding algorithm for unsigned 16-bit integers. The encoding function takes an unsigned 16-bit integer and a mutable buffer, and returns a slice of bytes representing the encoded integer. The decoding function takes the encoded bytes and returns an Option containi... | magicoder |
You are tasked with creating a Python function that simulates a simple game of rock-paper-scissors. The function should take two arguments representing the choices of two players and return the result of the game. The game rules are as follows:
- Rock beats scissors
- Scissors beats paper
- Paper beats rock
- If both p... | magicoder |
You are given a list of strings representing commands and operations performed on a vector. Each command is either to add an element to the vector or to retrieve the size of the vector. Your task is to implement a program that processes these commands and returns the size of the vector after executing all the operation... | magicoder |
You are tasked with implementing a custom loss function and training procedure for a neural network model. The provided code snippet is a part of a larger deep learning framework and includes components for loss calculation, model training, and feature extraction.
Your task is to complete the implementation by definin... | magicoder |
You are tasked with implementing a function to calculate the digital root of a given positive integer. The digital root of a number is obtained by repeatedly summing its digits until a single-digit number is obtained. For example, the digital root of 24 is 2 + 4 = 6, as 6 is a single-digit number. Your task is to write... | magicoder |
You are tasked with implementing a Python function `largest_product` that takes a 2D list of integers as input and returns the largest product of any two numbers within the list. The function should handle both positive and negative integers. If the input list is empty, the function should return 0.
For example, given... | magicoder |
You are tasked with implementing a Python class that simulates a multicast data transmission system. The provided code snippet serves as a starting point for your implementation. Your task is to complete the implementation of the `Multicast_transceiver` class and the `detuple` function based on the given code snippet a... | magicoder |
You are working on a medical imaging project and need to develop a module that can process and analyze medical images using Python libraries. You decide to use the `torch`, `numpy`, and `SimpleITK` libraries for this purpose. Your task is to create a class that performs basic image processing operations using these lib... | magicoder |
You are tasked with designing a database schema for a question-and-answer platform. The platform allows users to downvote questions, answers, and comments. You need to create a database schema to store downvotes, ensuring referential integrity with the users, questions, answers, and comments tables.
Your task is to de... | magicoder |
You are tasked with creating a Python program to manage database migrations using the Peewee ORM. Your program should define a model for tracking migration patches and their associated upgrade numbers. The model should include a field for the patch time and another for the upgrade number.
Your task is to implement a f... | magicoder |
You are working on a project that involves training a deep learning model using TensorFlow. As part of the training process, you need to implement a function to push image data into a buffer for batch processing. The function should take the batch, a list of image files, and the current index as input, and update the b... | magicoder |
You are given a function `searchWordIndex(sentence: str, searchWord: str) -> int` that takes in a sentence and a search word as input and returns the index of the first occurrence of the search word in the sentence. The function uses the Knuth-Morris-Pratt (KMP) algorithm to efficiently search for the word within the s... | magicoder |
You are tasked with implementing a movie visit tracking system using Swift. The system should allow users to record their visits to various movies and track details such as the movie title, date of visit, and rating given to the movie. To achieve this, you need to create a class that represents a movie visit, as well a... | magicoder |
You are tasked with creating a program that analyzes the license information of a given file. The license information is embedded within the file as a comment block at the beginning of the file. The license follows a specific format, starting with a multi-line comment (''' or """) and containing the following key eleme... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.