instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with implementing a function that processes SQL queries for a protein database. The function takes in a list of protein accessions and constructs a SQL query to retrieve peptide sequences associated with those proteins. You are given the following code snippet as a starting point: ```python 'protein_ps...
magicoder
You are tasked with implementing a Django web application for managing user accounts. The application should include functionality for creating, updating, and changing passwords for different types of users. Your task is to create the necessary URL patterns for the user management views. Given the code snippet provide...
magicoder
You are tasked with creating a Rust library for managing various types of Uninterruptible Power Supplies (UPS). The library should provide a unified interface for interacting with different UPS devices through their respective communication protocols. To achieve this, you need to implement the necessary modules and str...
magicoder
You are tasked with implementing a custom message encoding binding element for a WCF (Windows Communication Foundation) service. The `NdrMessageEncodingBindingElement` class needs to be designed to support a specific encoding scheme for messages exchanged between the client and the service. Your task is to create a me...
magicoder
You are working on a networked system where a client communicates with a server using a custom protocol. The server sends various types of messages to the client, and each message is identified by a unique integer code. One such message code is `SYS_CLI_TO_SVR_COLL_STAT_REPLY = 99999997`. Your task is to create a fun...
magicoder
You are tasked with creating a Python function that processes environment variables and returns a specific output based on the given input. The function should take in a dictionary of environment variables and return a string based on the value of the 'DEFAULT_SOURCE' variable. If the 'DEFAULT_SOURCE' variable is not p...
magicoder
You are tasked with creating a Python function that checks if the current working directory is the root of a specific git repository. The function should handle errors and quit with an error message if the current directory is not the root of the specified git repository. Your task is to implement the function `check_...
magicoder
You are working on a transaction verification system for a financial institution. The system processes transactions and then verifies their execution and commits them to the database. However, there seems to be an issue with the verification process, as the number of finished programs after execution does not match the...
magicoder
You are tasked with implementing a Python class that handles authentication for a client application. The class should support two types of authentication: userpass and approle. The class should have methods to authenticate using userpass and approle, and it should store the necessary credentials for each type of authe...
magicoder
You are working on a project that involves deploying a machine learning model using Porter, a tool for building and running containerized applications. As part of the deployment process, you need to set up the necessary environment variables and install a specific service using Porter commands. The code snippet provid...
magicoder
You are tasked with creating a Python program that extracts the version number from a given Python file. The version number is defined within the file as a variable named `__version__` assigned to a string or numeric value. Your program should be able to read the file, locate the `__version__` variable, and extract its...
magicoder
You are working on a project to analyze medical imaging data. As part of this project, you need to calculate the running average of two metrics, Peak Signal-to-Noise Ratio (PSNR) and Structural Similarity Index (SSIM), for two different reconstruction methods: Filtered Back Projection (FBP) and Convex Optimization (CVX...
magicoder
You are tasked with implementing a VAT (Value Added Tax) calculation system for a software application. The VAT rates and corresponding tags are defined in an enum in the following format: ```csharp public enum VatRates { /// <summary> /// 120 (НДС 20 /120). Тег 1106 /// </summary> [Description("НДС 20...
magicoder
You are tasked with implementing a Python function that simulates the creation of symbolic links between files and directories. A symbolic link, also known as a symlink, is a reference to another file or directory in the file system. In this problem, you will create a function that takes two parameters: `source_path` a...
magicoder
You are tasked with implementing a date management system that involves sorting and storing dates. The system should support sorting dates in ascending or descending order and should handle duplicate dates appropriately. You are given a code snippet that demonstrates part of the date management system. The snippet con...
magicoder
You are tasked with creating a program to calculate the total and grand total of amounts in a financial report. The given code snippet is a part of a web template using a server-side templating language like Blade in Laravel. The snippet iterates through a collection of details and calculates the total amount for each ...
magicoder
You are working on a game development project and need to implement a function to spawn enemy mobs at specific coordinates with a slight offset to prevent them from spawning too close together. The game engine provides a function `spawnMob(mobType, x, y, isAggressive)` to spawn mobs of a given type at the specified coo...
magicoder
You are tasked with implementing a function that enforces a specific constraint on a given type in a Rust program. The function `enforce_mem_discriminant` takes four parameters: a reference to a `LateContext` object `cx`, a reference to a `hir::Expr` object `func_expr`, a `Span` object `expr_span`, and a `Span` object ...
magicoder
You are tasked with implementing a Python module for working with tree-like data structures. The module should provide classes for representing different components of a tree, as well as functions for discovering and viewing these components. The provided code snippet shows the initial list of components that should be...
magicoder
You are working on a data processing pipeline using Python's pandas library. Your task is to create a function that takes a pandas DataFrame, a list of columns, and a fill value as input, and performs specific data manipulation operations. You need to implement a function called `fill_and_aggregate` that performs the ...
magicoder
You are tasked with creating a program that reads a file containing copyright information and extracts the years mentioned in the copyright notice. The copyright notice is written in the following format: ``` # Copyright <year> Google Inc. ``` Your program should read the file and output a list of unique years mentione...
magicoder
You are given a function `longestPalindrome` that takes a string `s` as input and returns the longest palindromic substring within the string. A palindromic string is one that reads the same backward as forward. The function is implemented using the following code snippet: ```python def longestPalindrome(s: str) -> st...
magicoder
You are given a Python function `solve(x)` that takes an integer `x` as input. The function is intended to convert the integer `x` into a reversed integer and return the result. However, there are some issues with the given code snippet, and you are tasked with fixing the code to ensure it works as intended. Your task...
magicoder
You are tasked with implementing a bucketing system for a water distribution network. The system should categorize the water levels into different buckets based on the following rules: - If the water level is 0, it falls into the "0" bucket. - If the water level is greater than 0 and less than or equal to 10, it falls...
magicoder
You are tasked with implementing a script to extract the Git revision information from a given directory. The script should handle cases where the revision is not explicitly provided and should extract the revision from the directory name if it follows a specific format. Your task is to write a function or script that...
magicoder
You are tasked with implementing a program that checks whether a given string is a palindrome or not. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). Your program should take a string as input and deter...
magicoder
You are tasked with implementing a Python class method that decodes a binary input using the `bincode` library. The `from_binary` method should take a `PyBytes` object as input and return the decoded result as an instance of the class. However, the provided code snippet is incomplete and contains errors. Your task is t...
magicoder
You are tasked with implementing a resource data management system. The system should handle the storage and retrieval of resource data, with the ability to replace existing data based on specific criteria. The resource data is defined by a combination of `type`, `id`, and `lang` attributes. When new resource data is a...
magicoder
You are working on a script to manage language-specific resource files in an Android application. The script needs to perform a series of operations to clean up and organize the resource files. Each language has a specific folder containing its resource files, and the script needs to remove unnecessary folders and rena...
magicoder
You are tasked with creating a password validation function for a web application. The function should ensure that the password meets certain criteria and does not match a specific field value. Write a function `validate_password` that takes two parameters: 1. `password` (string): The password to be validated. 2. `fie...
magicoder
You are tasked with implementing a card game system that includes a class for watching the arena and tracking the hero's player class. The provided code snippet is a part of the system and sets the `hero` property of the `ArenaWatcher` class to the `playerClass` of a card. Your task is to complete the implementation o...
magicoder
You are tasked with creating a Django web application for a data analysis platform. The application should have multiple modules, each represented by a separate Django app. The main `urls.py` file should include the URLs for the admin panel and all the modules. Additionally, it should serve media files during developme...
magicoder
You are tasked with creating a program that simulates a simple game of "Guess the Number." The program should generate a random number between 1 and 100, and then prompt the user to guess the number. After each guess, the program should provide feedback on whether the guess was too high, too low, or correct. Once the c...
magicoder
You are tasked with optimizing a system that processes vulnerability scans using multithreading. The system currently uses a ThreadPoolExecutor to parallelize the processing of scans obtained from a Nessus scanner. However, the current implementation lacks proper error handling and resource management. Your goal is to ...
magicoder
You are working on a tool that manipulates Mach-O (Mach Object) files, a file format used in macOS and iOS for executables, object code, shared libraries, and core dumps. As part of this tool, you need to create a new Mach-O section and set its properties based on certain conditions. Given the provided code snippet, y...
magicoder
You are tasked with implementing a class to manage missing components in different types of machines. The class should have the following functionalities: 1. Initialize the class with the missing component and the type of machine. 2. Provide a string representation of the missing component and the machine type. You n...
magicoder
You are given a weighted directed graph with n nodes numbered from 0 to n-1. The graph is represented using an adjacency list where each node is associated with a vector of pairs, where each pair represents an edge to a neighboring node along with its weight. The code snippet provided initializes the adjacency list for...
magicoder
You are tasked with creating a Python unit test for a class called `EventsClient` using the `pytest` framework. The `EventsClient` class is part of a larger system that interacts with an API client and a configuration object. Your goal is to write a test for the `EventsClient` class that utilizes fixtures to set up the...
magicoder
You are tasked with implementing a class method for user identification within a Blizzard gaming platform. The method should take a token as input and return the user's ID if the token is valid, or None if the token is invalid or the user does not exist. You are provided with a code snippet that contains a static meth...
magicoder
You are tasked with implementing a custom exception class and handling a specific exception scenario in Python. Your goal is to create a `ConfigException` class and modify the given code snippet to raise this exception when a `KeyError` is encountered. Your task is to complete the following steps: 1. Create a `Config...
magicoder
You are given a multi-line comment block from a software license file. The comment block contains a disclaimer about the distribution of the software under a specific license. Your task is to write a program to extract the key information from the comment block. Write a function or program that takes the multi-line co...
magicoder
You are tasked with debugging a C++ program that processes data from an endcap cluster collection. The given code snippet is part of a larger program and is responsible for logging debug information and putting the endcap cluster collection into the event. However, there seems to be an issue with the debug logging and ...
magicoder
You are tasked with implementing a TypeScript class decorator that will log the names of all the providers and exports defined in a given class. The decorator should output the names of the providers and exports to the console when the class is instantiated. Your task is to create a class decorator `LogProvidersAndExp...
magicoder
You are tasked with creating a program that simulates a simple game. The game involves a player navigating through a grid-based world, collecting treasures, and avoiding obstacles. The player's position is represented by (x, y) coordinates, where (0, 0) is the starting point. The grid-based world is represented by a 5x...
magicoder
You are tasked with implementing a program that simulates a simple multi-threaded system. The given code snippet is a part of a Java program that creates and starts a new thread using an anonymous inner class. Your task is to complete the program by implementing the `run` method of the thread to perform a specific task...
magicoder
You are tasked with creating a function that processes a collection of snapshots and filters out the ones with non-nil data. Each snapshot is represented by a structure with a `data` property that may contain either a value or `nil`. Your task is to implement a function that takes an array of snapshots and returns a ne...
magicoder
You are tasked with creating a Python function that generates a file path for a multimodal neural network training checkpoint. The function should handle different scenarios based on the input parameters and return the appropriate file path. You are given a code snippet that contains a partial implementation of the fu...
magicoder
You are given a list of hairstyles along with their respective prices and required time for styling. Your task is to write a program to perform the following operations: 1. Calculate the average price of all the hairstyles. 2. Find the hairstyle with the highest price. 3. Determine the total time required to style all...
magicoder
You are tasked with implementing a class to parse and extract data from a BLE (Bluetooth Low Energy) Blood Pressure Service. The service exposes blood pressure and other related data from a blood pressure monitoring device. The data is transmitted in a specific format defined by the Bluetooth SIG (Special Interest Grou...
magicoder
You are given a Rust code snippet that defines a struct `Fluent` and implements a method `blorp` for it. The `blorp` method returns a new instance of `Fluent` and allows method chaining. However, the current implementation does not support method chaining as expected. Your task is to modify the implementation of the `b...
magicoder
You are given a PHP code snippet that iterates through an array of "paquetes" and checks if the "id_monedas" property of the "inf_habitacion" object is equal to '1'. Your task is to write a function in PHP that achieves the same functionality as the given code snippet. Write a PHP function called `filterPaquetes` that...
magicoder
You are tasked with designing a trading simulation system that involves data collection and multiple types of traders. The system is designed to work with asynchronous programming and utilizes locks to manage concurrent access to shared resources. Your goal is to implement a simplified version of the trading system by ...
magicoder
You are tasked with creating a program to analyze daily stock market data using box plots. A box plot is a graphical representation of the distribution of a dataset, showing the median, quartiles, and potential outliers. Your program should read in daily stock data, calculate the necessary statistics, and generate a bo...
magicoder
You are tasked with implementing a function that checks for duplicate keys in a given dictionary and raises an exception if any duplicates are found. The function should take a dictionary as input and raise a ValueError with a message describing all violations if duplicate keys are present. You are required to impleme...
magicoder
You are tasked with implementing a network communication module for a game server. The module needs to support encryption and compression of data packets. You are provided with a partial code snippet for the module, which includes a method for enabling encryption and another method for enabling compression. Your task ...
magicoder
You are tasked with implementing a function to generate a 64-bit random bitboard with a few set bits. A bitboard is a data structure commonly used in chess engines to represent the state of the game board. It uses a 64-bit integer to represent the 64 squares on a chessboard, with each bit indicating the presence or abs...
magicoder
You are tasked with implementing a simplified version of a call stack mechanism in a programming language. The call stack is a fundamental concept in computer science and is used to manage function calls and their associated data. In this problem, you will need to create a data structure to represent the call stack and...
magicoder
You are tasked with setting up a supervisor to manage and monitor multiple processes in a Linux environment. The supervisor will be responsible for ensuring the availability and proper functioning of these processes. Additionally, you need to install and configure a Node.js application with the necessary dependencies. ...
magicoder
You are working on a data processing application that involves handling HDF5 files. You need to implement a class method that calculates the total size of a specific data source within the HDF5 file. The HDF5 file contains multiple datasets, each representing a different data source. Each dataset has a specific data ty...
magicoder
You are working on an inventory management system for a company that handles material requests for purchase orders. You need to write a function to calculate the quantity of items to be requested based on the available stock and purchase order box quantity. You are given the following information: - `doc` is a documen...
magicoder
You are working on a 3D game development project and need to implement a method for checking the movement of characters within the game world. The game world is represented as a grid, and characters can move from one grid cell to another. The method `moveCheck` takes the starting location `startpoint` and the destinati...
magicoder
You are tasked with creating a Python program that calculates the average of two numbers entered by the user and then displays the result with two decimal places. Your program should take two floating-point numbers as input, calculate their average, and then output the result with two decimal places. Write a Python pr...
magicoder
You are tasked with implementing a function that processes ROS (Robot Operating System) service requests and responses. The provided code snippet contains error checking and handling logic for a ROS middleware (RMW) service. Your task is to create a function that takes in a service handle, implementation identifier, re...
magicoder
You are tasked with implementing a function that simulates a simple command-line interpreter for a subset of the `bash` shell's `case` statement. The `case` statement in `bash` allows for pattern matching and conditional execution based on the matched pattern. Your task is to write a function that takes a string as inp...
magicoder
You are tasked with creating a simplified version of an effect system used in a front-end application. The effect system is responsible for triggering actions based on certain conditions and asynchronous operations. Your goal is to implement a similar effect system using a simplified version of RxJS. You are provided ...
magicoder
You are tasked with implementing a function to calculate the number of data points for a given shape. The function should take into account a special case where the number of points is set to -1, in which case it should be determined by the number of points in the shape data. You are given the following code snippet a...
magicoder
You are tasked with implementing a function that takes a message as input and returns the message with each word reversed. A word is defined as a sequence of non-space characters. The input message is a string containing alphabets, numbers, and special characters. The function should preserve the original order of word...
magicoder
You are given a Python code snippet that processes data from a 3Brain data file. The code snippet includes error handling, printing information about the data format, and computing indices for the data channels. Your task is to write a function that processes the channel indices and returns the corresponding channel na...
magicoder
You are tasked with creating a script that checks the version of the Autotools suite installed on a system. The Autotools suite includes tools like Autoconf, Automake, and Libtool, which are used for building and distributing software packages. Your script should determine the version of Autoconf and Automake installed...
magicoder
You are tasked with implementing a Python function that processes a given set of spatial relations and their synonyms. The function should take in a dictionary containing spatial relations as keys and their synonyms as values, and return a new dictionary where each synonym is associated with its corresponding spatial r...
magicoder
You are tasked with implementing a custom error type and a function that returns a Result containing a value or an error of the custom type. Your custom error type should have two variants: `InputError` and `ProcessingError`. The function `process_data` takes an input value and performs some processing on it. If the in...
magicoder
You are tasked with implementing a simplified version of a navigation system for a mobile application. The navigation system consists of a `Navigator` class that manages the flow of screens in the application. Each screen is represented by an enum called `Screen`. The `Navigator` class has the following methods: - `ne...
magicoder
You are tasked with implementing a simple testing framework for a custom logging library. The code snippet provided is a part of the testing framework and includes a function `test_run_all` and a test attribute `#[test]`. Your goal is to complete the testing framework by implementing the missing parts and ensuring that...
magicoder
You are tasked with implementing a Python function that performs a specific transformation on a given input matrix. The transformation involves applying a sigmoid function to a subset of the input matrix and then combining the result with another subset of the input matrix. Your task is to write a function that accompl...
magicoder
You are working on a database management system for a government organization. The system has three collections: `hor`, `sen`, and `gov`, which store documents related to the House of Representatives, the Senate, and the government, respectively. The code snippet provided contains a part of the system's functionality. ...
magicoder
You are tasked with implementing a CorrectorData class that will be used for data validation in a system. The CorrectorData class should have properties for Type, Value, and ValidationRules. The ValidationRules property should be a list of strings representing the validation rules that will be applied to the Value prop...
magicoder
You are tasked with implementing a role-based authorization system for a web application. The system should allow or deny access to certain resources based on the roles assigned to a user. You are given a PHP function `authorize()` that needs to be completed to enforce the authorization logic. The `authorize()` functi...
magicoder
You are tasked with implementing a gradient clipping mechanism for a neural network training process. Gradient clipping is a technique used to prevent the exploding gradient problem in deep learning models by rescaling gradients if their norm exceeds a certain threshold. You are given a Python class `GradClipCounter` ...
magicoder
You are tasked with creating a Python function that can parse a given code snippet and extract a specific piece of information. The code snippet provided is a simplified representation of a database migration file in Python using the Alembic library. The file contains metadata related to the database schema revision an...
magicoder
You are tasked with implementing a Python module that interacts with a set of APIs for managing and providing services. The module should utilize the provided `ManagerAPI` and `ServiceAPI` classes to perform various operations. The `ManagerAPI` class is responsible for managing resources, while the `ServiceAPI` class p...
magicoder
You are tasked with implementing a reinforcement learning algorithm for a simple game. The game has a reward system, and the player's actions may trigger a reset of the game state. The reinforcement learning algorithm will receive the current state of the game and must return two values: the reward gained from the curr...
magicoder
You are tasked with implementing a simple caching mechanism for the `SpotifyClient` class in the `Reverberate` namespace. The `SpotifyClient` class is a part of a music streaming application and is used to interact with the Spotify API. The goal is to ensure that the `SpotifyClient` instance is cached and reused across...
magicoder
You are tasked with implementing a custom exception handling mechanism for a data validation library. The library is designed to enforce type constraints on attributes of Python classes. Your goal is to create a custom exception class that will be raised when an attribute's value does not match the expected type. Your...
magicoder
You are tasked with implementing a Python class for managing a dataset. The class should have the ability to calculate the number of batches required to process the dataset, handle any remaining data that does not fit into a complete batch, and provide a method to reset the dataset to its initial state. Your task is t...
magicoder
You are working on a project that involves managing a shopping application. The project uses a JAR (Java Archive) file named `shopping.jar` to encapsulate various classes and resources related to the shopping functionality. However, due to a recent update, the `shopping.jar` file needs to be removed from the project di...
magicoder
You are tasked with creating a program to analyze and display statistics for a set of tiles used in a game. Each tile is represented by a struct `Tile` containing the fields `id` (a unique identifier), `color` (a string representing the color of the tile), and `value` (an integer representing the point value of the til...
magicoder
You are tasked with creating a Python function that handles exceptions and logs relevant information. Your function should take in a Reddit API wrapper exception as a parameter and log the exception details using the Python logging module. Write a function called `handle_reddit_exception` that takes a `praw.errors.HTT...
magicoder
You are tasked with implementing a function that processes vehicle information. The function takes in a vehicle ID (`v_id`) as a parameter and should handle different scenarios based on the value of `v_id`. If `v_id` is an empty string, the function should print an error message and return. Otherwise, it should proceed...
magicoder
You are tasked with creating a scheduling algorithm for a task scheduler. The scheduler is represented by the `SchedulerBase` class from the `abc` module, and it has a method `action` that takes two parameters: `scheduler` of type `abc.SchedulerBase` and `state` of type `Any`. Your goal is to implement a scheduling alg...
magicoder
You are tasked with creating a Python class that provides a simple interface for interacting with a SQLite database. The class should allow users to connect to the database, execute SQL queries, and close the connection. Your task is to implement the methods of the `SharedDB` class to achieve this functionality. The `...
magicoder
You are tasked with creating a program that simulates a simple network scanner. The program should continuously scan for active hosts on a network and display a message indicating that the scan is in progress. However, the program should also handle the possibility of a user interrupting the scan with a keyboard interr...
magicoder
You are given a Python code snippet that manipulates a list of strings. Your task is to implement a function that simulates the behavior of the code and returns the final state of the list after the operations are performed. The code snippet manipulates a list called `lines` and a variable `max_length`. The snippet co...
magicoder
You are tasked with creating a custom exception class in PHP to handle invalid arguments. Your task is to implement a custom exception class called `CustomInvalidArgumentException` that extends the built-in `InvalidArgumentException` class. This custom exception class should add a new method called `getCustomMessage()`...
magicoder
You are tasked with creating a Django migration for a new model in a web application. The model represents GitHub repositories and includes a field for the number of stars the repository has. Your task is to write the migration file that adds this new model to the database schema. The model should have the following f...
magicoder
You are tasked with creating a custom model class in a PHP application using the CodeIgniter framework. The model should be responsible for interacting with a database table named "dashboard_user". Your goal is to implement the necessary methods within the model to perform CRUD (Create, Read, Update, Delete) operations...
magicoder
You are tasked with implementing a class that manages an array and provides methods for flushing changes to a file on disk. The provided code snippet is a part of the class definition and contains the `flush`, `sync`, and `_close` methods. Your task is to complete the class by implementing the missing parts and ensurin...
magicoder
You are given a code snippet that performs some operations using the PyTorch library. Your task is to implement a function that takes two input tensors, `alphas` and `betas`, and performs the operations described in the code snippet to calculate two output tensors, `alpha_bars` and `sigmas_inflex`. The input tensors `...
magicoder
You are tasked with implementing a custom evaluation algorithm for a specific application. The algorithm should be designed to evaluate a set of input data and produce a single output value based on a predefined set of rules. To achieve this, you will need to create a class that inherits from the `EvalAlgorithm` class ...
magicoder
You are tasked with creating a Python program that involves defining and using structures and unions using the `ctypes` module. Your goal is to implement a program that defines two structures and performs operations on them. Define two structures, `Stuff` and `Stuff2`, using the `ctypes` module. The `Stuff` structure ...
magicoder
You are given a function `findMissingNumber` that takes an array of integers as input and returns the missing number in the sequence. However, there seems to be a bug in the code that uses this function. Your task is to identify the bug and fix it. The code snippet provided is a part of a test suite for the `findMissi...
magicoder