instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with creating a Python script that processes command-line arguments to output the adjacencies of leaf genomes of a given phylogeny in DeCo format. The DeCo format is a specific format used to represent the genome adjacencies in a phylogenetic tree. Your script should take the following command-line argu...
magicoder
You are tasked with implementing a program to manage a collection of heightmap tile providers for a mapping application. Each heightmap tile provider is represented by a class called `SqliteHeightmapTileProvider`. The code snippet provided shows the destructor for this class. The `SqliteHeightmapTileProvider` class is...
magicoder
You are tasked with implementing a Python function that processes and displays data from a scientific experiment. The function takes in various parameters and performs different actions based on the input. Your task is to complete the function by implementing the missing parts. You are provided with a code snippet tha...
magicoder
You are tasked with creating a Python program that reads and processes configuration data from a JSON file. The configuration file contains settings for a system, and your program needs to extract specific information from it. The JSON file, `config.json`, has the following structure: ```json { "system_name": "MySys...
magicoder
You are working on a project to develop a custom parser for a programming language. As part of this task, you need to implement methods for entering and exiting parse trees for various language constructs. The parse tree is represented using a specific parser class called `MCSharpParser`. The methods you need to implem...
magicoder
You are tasked with implementing a voting system for a competition. The voting system follows a simple elimination process where candidates compete in rounds, and the winner of each round advances to the next until a majority winner is determined. You are given a function `determine_winner(results, majority)` that tak...
magicoder
You are tasked with creating a Python function to process a CSV file containing data points in the format of (X, Y) coordinates. The function should read the CSV file and return the data as a list of lists, where each inner list represents a row of the CSV file. The CSV file will have a header row, and the subsequent ...
magicoder
You are given a string `S` and a positive integer `n`. Your task is to write a function that finds all occurrences of a specific word of length `n` within the string `S` and wraps each occurrence with `<b>` tags. The function should return the modified string. For example, given `S = "The quick brown fox jumps over th...
magicoder
You are tasked with creating a custom control for a music application that allows users to edit the ratings of their favorite albums. The control will be implemented in a Xamarin.Forms application using C#. The custom control should be a XAML-based view that inherits from the `Grid` class and provides a user interface ...
magicoder
You are tasked with implementing a game state management system using the Memento design pattern. The Memento pattern allows an object's state to be captured and restored at a later time without violating encapsulation. Your goal is to create a Java program that utilizes the Memento pattern to save and restore the stat...
magicoder
You are tasked with creating a Swift class that manages a web view to display HTML content. Your class should include a method to load a given URL into the web view and a method to configure the user interface. The provided code snippet serves as a starting point for your implementation. Your task is to complete the i...
magicoder
You are tasked with implementing a Python decorator that logs the input arguments and return value of a function. The decorator should take the following form: ```python @log_function def my_function(arg1, arg2, arg3): """ This is a sample function. """ # Function implementation return result ``` ...
magicoder
You are tasked with creating a program to decrypt a message that has been encrypted using a simple substitution cipher. In this cipher, each letter in the plaintext is shifted a certain number of positions down the alphabet to produce the ciphertext. For example, if the shift value is 3, then 'A' becomes 'D', 'B' becom...
magicoder
You are tasked with creating a form validation function for a web application. The function should validate the input from a text field and ensure that it meets certain criteria. The input field is defined in HTML as follows: ```html <input type="text" class="form-control" name="mtitle" value="<?= set_value('mtitle');...
magicoder
You are tasked with implementing a function to clean a dictionary by removing any keys that contain dates. A date is represented as a string in the format "YYYY-MM-DD". The function should take a dictionary as input and return a new dictionary with all date-related keys removed. Write a function `clean_dates(dictionar...
magicoder
You are tasked with implementing a class that manages a collection of names, their associated contexts, and corresponding file paths. The class should provide methods for adding and retrieving this information. You are given a code snippet that initializes three private arrays within the class: `$names`, `$contexts`, ...
magicoder
You are tasked with creating a function to generate a mailing list for a group of consultants. The function should take a list of consultant objects as input and return a list of their email addresses. Each consultant object is represented as a dictionary with the following keys: "name", "email", and "role". The "name"...
magicoder
You are tasked with implementing a simplified version of an observer pattern using Swift. The goal is to create a class that acts as an observer for depth data output from an AVCapture session. You are provided with a code snippet that defines a class `RxAVCaptureDepthDataOutputDelegate` which acts as an observer for ...
magicoder
You are tasked with implementing a peer-to-peer networking protocol in Rust. The protocol involves decoding XOR-PEER-ADDRESS from a message using the `Getter` trait for the `PeerAddress` type. The `PeerAddress` type represents the address of a peer in the network, and the `Message` type represents a message sent over t...
magicoder
You are tasked with implementing a class for parsing and manipulating quantities. The class should be able to parse a string representation of a quantity and perform operations on quantities such as addition, subtraction, and conversion between units. You are given a code snippet that includes a method `parse` within ...
magicoder
You are tasked with creating a Python class for managing projects in a business intelligence application. The class should include methods for listing cubes, listing models, creating a project, and deleting a project. Your task is to implement the `delete_project` method, which should delete a project after ensuring th...
magicoder
You are working on a medical imaging project and need to process MRI data using Python and R. You have a 3D MRI image stored in the NIfTI format (.nii) and want to perform some statistical analysis on the image data. To achieve this, you need to read the MRI data using Python's nibabel library, convert it to a NumPy ar...
magicoder
You are tasked with creating a Python class that represents a simplified version of a client hello message in a network communication protocol. The class should be implemented using the `dataclass` decorator from the `dataclasses` module and should inherit from the `betterproto.Message` class. Your task is to define t...
magicoder
You are tasked with implementing a function to convert a given dataset into a 2D array. The dataset is represented as a list of dictionaries, where each dictionary contains key-value pairs representing the attributes and values of a single data point. Your task is to write a Python function `dataset_to_array` that take...
magicoder
You are tasked with implementing a class that handles image processing. The class should have a method to check if an image has been loaded, and if not, attempt to load the image from a specified file path. If the image is successfully loaded, the class should provide a method to perform a specific image processing ope...
magicoder
You are tasked with creating a Python program that processes command-line arguments for training a Hierarchical Recurrent Encoder-Decoder (HRED) model. The provided code snippet includes an argument parser setup and a device assignment based on GPU availability. Your task is to extend this code to handle the training l...
magicoder
You are tasked with creating a Python class that implements a method to determine whether a given integer is a palindrome. A palindrome is a number that reads the same backward as forward. For example, 121 is a palindrome, while 123 is not. You need to implement the `isPalindrome` method in the `Solution` class, which...
magicoder
You are tasked with creating a function that processes a given GitHub repository name and its star count to generate a formatted string. The function should take in the repository name, the range of star counts, and return a string in the format `<reponame> has <starcount> stars`. Write a function `formatRepository` t...
magicoder
You are tasked with implementing a function to calculate the gradient penalty for a Wasserstein GAN (Generative Adversarial Network). In a Wasserstein GAN, the gradient penalty is used to enforce the Lipschitz constraint on the discriminator network. The provided code snippet is a part of the gradient penalty calculati...
magicoder
You are tasked with implementing a file caching system for URLs in a Rust application. The goal is to create a function that takes a URL and converts it into a hashed filename for caching purposes. The provided code snippet is a part of the implementation and contains a function `url_to_filename` that is responsible fo...
magicoder
You are tasked with creating a script to automate the version number formatting for a software release. The script should take a version number in the format "vX.Y.Z" and remove the leading "v" to produce the formatted version number "X.Y.Z". Write a function or script that takes a version number as input and returns ...
magicoder
You are tasked with implementing a customer management system for a retail company. One of the requirements is to generate a unique customer ID for each new customer. The customer ID should be a combination of the customer's initials and a sequential number. The initials are derived from the customer's first and last n...
magicoder
You are tasked with implementing a class that handles authentication for Azure DevOps using NTLM (NT LAN Manager) credentials. NTLM is a suite of security protocols that provides authentication, integrity, and confidentiality to users. Your goal is to create a class that encapsulates the logic for handling NTLM authent...
magicoder
You are tasked with implementing a Python class for controlling a drawing robot called BrachioGraph. The robot has two arms of different lengths and is capable of drawing on a specified area. Your task is to create a class that can control the robot's movements and drawing capabilities. Your task is to implement the `...
magicoder
You are tasked with implementing a logging system for a software application. The logging system should support different levels of logging, flags, and colors for the log messages. You need to create a class `ToolLogger` with a method `log` that takes in the level of the log message, a flag, a color, the log message da...
magicoder
You are tasked with implementing a simple key-value pair data structure in Java. Your task is to create a class `KeyValuePair` that has two private fields: `key` of type `Integer` and `value` of type `String`. Additionally, you need to provide a constructor that initializes these fields and a method to retrieve the key...
magicoder
You are tasked with creating a Rust program that involves parsing and processing JSON data using the Serde library. Your goal is to define a data structure and implement a function to extract specific information from the JSON data. You are given a JSON response from an API call, which represents a successful response...
magicoder
You are tasked with implementing a function to generate a random sequence chunk from a given input sequence. The function should take a sequence `x` and a chunk size `n` as input and return a random chunk of size `n` from the sequence `x`. The function signature is: ```python def randomSequenceChunk(x: List[int], n: i...
magicoder
You are tasked with implementing a function that processes a list of expressions and returns a modified list based on certain conditions. The function takes a list of expressions as input and should perform the following operations: 1. If the input list is empty, the function should return an error message indicating ...
magicoder
You are tasked with implementing a job assignment system for a colony on a distant planet. The colony has various managerial tasks, including managing job assignments, job priorities, mining/construction positions, etc. Your goal is to create a program that efficiently assigns jobs to the colony's inhabitants based on ...
magicoder
You are working on a Python project that involves importing modules from a package. The project structure is as follows: ``` project/ main.py package/ __init__.py managers.py ``` The `managers.py` file contains various manager classes for handling different aspects of the project. You need to ...
magicoder
You are tasked with implementing a simplified version of a cryptocurrency wallet emulator. The emulator is capable of handling different types of transactions and their corresponding signature verification. Your goal is to create a function that verifies the signature of a given transaction based on the transaction typ...
magicoder
You are tasked with implementing a command-line interface for a Game Boy emulator. The provided code snippet is part of a larger Rust program that handles user input and executes corresponding emulator commands. The `match` statement is used to match user input to emulator commands, and the `dump_bg` and `reset` comman...
magicoder
You are tasked with creating a script to automate the deployment process of a software project using Docker. The script should perform the following tasks: 1. Create a Docker container named "dummy" based on the "ant-simulator:latest" image, and enter the container in interactive mode with a bash shell. 2. Copy the "A...
magicoder
You are tasked with implementing a simple image viewer application using the wxPython library. The given code snippet is a part of the application's main class, which includes methods for handling events and initializing the image buffer. Your task is to complete the implementation of the `InitBuffer` method, which is...
magicoder
You are tasked with implementing a function that performs a specific memory operation based on the comparison of two values. The function takes in four parameters: `current`, `new`, `dst`, and `result`. The `current` and `new` parameters are values of a certain type, while `dst` is a mutable reference to a location in ...
magicoder
You are working on a software project that involves creating custom error classes for different types of errors. You have been tasked with implementing a new error class called `CustomError` that takes an additional message as input and appends it to the existing error message. Your task is to create the `CustomError` ...
magicoder
You are tasked with creating a custom Lua binding for a 2D vector library in Rust. The goal is to expose certain methods of the `Vec2` struct to Lua, allowing Lua scripts to perform operations on 2D vectors using the Rust library. The provided code snippet is a part of the process of setting up the Lua bindings. It de...
magicoder
You are tasked with implementing a function that processes a given data structure to extract specific information based on a set of rules. The data structure is represented as a JavaScript object, and the function should return a new object containing the extracted information. You are given a data structure represent...
magicoder
You are tasked with creating a Python Flask application that involves registering blueprints and configuring JSON settings. Your goal is to implement a function that sets up the Flask application with the given configurations and blueprint registration. You are provided with the following code snippet as a starting po...
magicoder
You are tasked with creating a Python class to manage a private client's cryptocurrency transactions. Your class should include methods for buying and selling cryptocurrencies using a private connection. The private connection is established using authentication credentials obtained from a function `get_new_private_con...
magicoder
You are tasked with creating a cross-platform clipboard utility that can retrieve and store text from the clipboard. The code snippet provided contains a partial implementation using conditional compilation for different target architectures. Your task is to complete the implementation of the clipboard utility by writi...
magicoder
You are tasked with implementing a data validation function for a user profile object. The user profile object contains optional fields for the user's last name, telephone number, and credit card number. Your task is to create a function that validates the user profile object based on the following criteria: 1. The las...
magicoder
You are given the definition of a ListNode class and a function middleNode that takes the head of a linked list as input and returns the middle node of the linked list. If the linked list contains an even number of nodes, return the second middle node. The ListNode class is defined as follows: ``` class ListNode: ...
magicoder
You are tasked with creating a Python script that simulates the behavior of a simplified version of the Django management command `manage.py`. The script should accept a command-line argument representing a management command and execute the corresponding functionality. For this problem, you need to implement the funct...
magicoder
You are tasked with creating a program that simulates a simple queue management system for a bank. The system should allow customers to join the queue, be served by the teller, and then leave the queue. The program should also keep track of the average waiting time for customers in the queue. You are provided with a `...
magicoder
You are tasked with creating a Python function that processes user input to determine the type of disk associated with a given image ID. The function should take in the image ID as a string and return the corresponding disk type as a string. The disk type is determined based on a predefined dictionary `DISK_TYPE`, whic...
magicoder
You are tasked with analyzing the performance of HTTP/2 with TLS (HTTP2-TLS) and HTTP/1 with TLS (HTTP1-TLS) protocols for transferring data. Two sets of data are collected: `std_tot_http2_tls` and `std_contentTransfer_http2_tls` for HTTP2-TLS, and `time_tot_http1_tls` and `time_contentTransfer_http1_tls` for HTTP1-TLS...
magicoder
You are tasked with implementing a simplified version of a checkpointer system in C++. The checkpointer system is responsible for managing the state of a service and providing the ability to save and restore the service's state. You are provided with a partial implementation of the `Checkpointer` class, which includes...
magicoder
You are tasked with implementing a program to process and analyze data from a particle physics experiment. The experiment involves isolating and summing the transverse momentum of particles using a specific algorithm called CITKPFIsolationSumProducerForPUPPI. Your task is to write a function that takes in the relevant ...
magicoder
You are tasked with creating a web application that manages columns in a database. The given code snippet is a part of the HTML table that displays the columns' information and provides options to edit or delete a column. Your task is to implement the functionality for editing and deleting columns using PHP and JavaScr...
magicoder
You are tasked with creating a script to automate the validation of SwiftLint configuration files in a version-controlled repository. The script should compare the current SwiftLint configuration file with the latest version available in the "versions" directory and take appropriate action based on the comparison resul...
magicoder
You are tasked with implementing a Swift program that involves protocols and extensions. Your goal is to create a protocol hierarchy and an extension that adheres to the hierarchy. Define a protocol `P` with an associated type `a`. Then, create another protocol `A` that inherits from `P`. Your task is to extend the pr...
magicoder
You are working on a system that monitors a watchlist of actions and uses a manager to handle resources. The system is structured using Python and utilizes a custom manager class with a method `get_dagr()` to obtain a resource for monitoring. Additionally, there is a function `monitor_watchlist_action()` that is respon...
magicoder
You are tasked with implementing a class that filters a list of integers based on a specified filter type. The filter type can be one of the following: 1. Even numbers 2. Odd numbers 3. Prime numbers You need to create a class `NumberFilter` with the following specifications: - A private instance variable `filterType`...
magicoder
You are tasked with implementing a function that calculates the average of a list of floating-point numbers, excluding any outliers. An outlier is defined as a value that differs significantly from the rest of the data. In this case, a value is considered an outlier if it is not "close" to the average of the other valu...
magicoder
You are working on a system maintenance script that needs to automate the process of checking and updating the filesystem parameters. The `tune2fs` command is used to adjust various parameters of the ext2, ext3, or ext4 filesystems. One of the parameters that can be adjusted is the maximum mount count between two files...
magicoder
You are tasked with creating a Python web service that utilizes the aiohttp library to handle HTTP requests and manage user sessions. Your goal is to implement a simple web server that can handle user authentication and session management using the `aiohttp` and `servicelib` libraries. Your task is to create a Python ...
magicoder
You are tasked with creating a script to automate the process of calculating k-nearest neighbors for different subsets of a large dataset. The script should iterate through a range of sizes, calculate the k-nearest neighbors for each subset, and store the results in separate log files. The given code snippet is a part...
magicoder
You are tasked with implementing a function that calculates the chunk size for a data storage system. The function takes in a byte offset, a maximum chunk size, and information about the write alignment. The provided code snippet demonstrates the calculation of the chunk size based on the start offset, maximum chunk si...
magicoder
You are tasked with creating a script to automate the build process for a PHP extension. The build process involves running a series of commands in a specific order. Your script should execute the following commands in sequence: 1. Run `phpize` to prepare the build environment. 2. Run `./configure` to generate the conf...
magicoder
You are working on a web application project and need to configure the settings for the Django framework. Your task is to create a function that takes a dictionary of settings and returns a formatted string representing the Django settings file. You need to implement a Python function `generate_django_settings` that t...
magicoder
You are tasked with creating a script to automate the installation of software packages on a Linux system. Your script should be able to handle the installation of multiple packages and provide feedback on the success or failure of each installation. Additionally, the script should be able to handle any potential error...
magicoder
You are tasked with implementing a Python function that processes a 3D voxel grid representing a protein structure. The function should take the voxel grid and return the count of unique atoms present within the grid. Each atom is represented by its coordinates within the grid. The input to the function will be a 3D n...
magicoder
You are tasked with implementing a visitor pattern for a simple expression tree in C#. The expression tree consists of three types of nodes: BinaryExpression, UnaryExpression, and NumberLiteralExpression. Each node type has a corresponding Visit method that needs to be implemented in the visitor pattern. The BinaryExp...
magicoder
You are tasked with implementing a message serialization and deserialization system. The system should be able to encode a message into a byte stream and decode a byte stream back into a message. The message consists of a codec type and optional data. You are given a code snippet from the serialization part of the sys...
magicoder
You are tasked with implementing a Python function that processes a given string to extract specific information. The function should extract and return the Python class name and the first character of the string. The input string will be in the format of a Python function definition, and the output should be the extra...
magicoder
You are tasked with creating a Python function that reads a JSON file and returns its content as a Python dictionary. The function should handle the file path and opening process, ensuring that the file is read in binary mode and the JSON content is loaded properly. Write a function `read_json_file` that takes a singl...
magicoder
You are tasked with implementing a video streaming application using the GStreamer multimedia framework in C++. The application needs to read video frames from a source and stream them at a specified frame rate and resolution. You are provided with a code snippet that initializes the video streaming process and logs th...
magicoder
You are tasked with implementing a function to calculate the inverse cumulative distribution function (CDF) for a multivariate Gaussian mixture model (GMM). The provided code snippet demonstrates the process of obtaining the percent point function (PPF) for the marginals of the GMM using interpolation and handling spec...
magicoder
You are working on a web application that includes a backend API written in PHP. The code snippet provided is part of a PHP class that handles requests related to retrieving and processing data for a tree selection feature. The class contains a method named `treeSelect` which is responsible for fetching a list of items...
magicoder
You are tasked with implementing a simple command-line DNS (Domain Name System) utility in Bash. The utility should support two main commands: "set" and "usage_dns". The "set" command should allow the user to set DNS configurations, while the "usage_dns" command should display usage information for the DNS utility. Yo...
magicoder
You are tasked with implementing a Python class that manages a library of financial instruments. The library should support the addition and retrieval of various financial instruments, such as bonds and exercises. Each instrument has its own specific attributes and methods. Your task is to create a class `FinancialIns...
magicoder
You are working on a machine learning project and need to implement a custom loss function for a neural network. The loss function involves calculating the Hessian matrix of the network's output with respect to its parameters. You decide to use PyTorch to efficiently compute the Hessian matrix. The code snippet provide...
magicoder
You are tasked with implementing a function to generate a secure signature for a given set of parameters using the HmacSHA256 algorithm. The function should take in the parameters and return the generated signature. The function should follow these requirements: - Take in a dictionary of parameters as input, where th...
magicoder
You are tasked with implementing a class that represents a remote identity and subscription information for a service. The class should have properties for the identity type and subscription ID. The identity type should be of type `RemoteIdentityType`, and the subscription ID should be of type `Uri`. Your task is to cr...
magicoder
You are tasked with creating a Python function that interacts with a web browser using the Selenium library. Your function should open a specific website, perform a series of actions, and then close the browser using the `driver.quit()` method. However, you need to ensure that the browser is always closed, even if an e...
magicoder
You are tasked with implementing a rendering system for different types of lights in a 3D graphics engine. The code snippet provided is part of a function that handles different types of lights and their corresponding rendering logic. The function processes each light and populates a vector of camera constant buffers f...
magicoder
You are tasked with creating a program to calculate and display the difference between two numbers in a table format. The program should take input values for two numbers and generate an HTML table displaying the original numbers and their difference. Your task is to write a function `generateDifferenceTable($num1, $n...
magicoder
You are tasked with implementing a Python function that evaluates and checks the correctness of a given lambda calculus expression. Lambda calculus is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. The given express...
magicoder
You are tasked with creating a class to represent file entities in a file management system. The class should encapsulate properties such as file name, file path, file extension, whether it is a folder or not, file size, and file created date. Your task is to implement the class `FileEntity` with the given constructor ...
magicoder
You are tasked with creating a Python class that simulates a Cloud Object Storage (COS) wrapper. The class should handle the instantiation of the wrapper and provide methods for interacting with the COS. Additionally, you need to implement a function that monitors the status of a training run and skips preparation step...
magicoder
You are given a Swift code snippet that imports the Foundation framework. Your task is to write a Swift function that takes an array of integers as input and returns the sum of all the even numbers in the array. Write a function named `sumOfEvenNumbers` that takes an array of integers as a parameter and returns the su...
magicoder
You are tasked with implementing a program to manage reservations for a conference center. The conference center has multiple domains, each with a set capacity for reservations. Your program should be able to handle the allocation of reservations to these domains based on their availability. You are given a snippet of...
magicoder
You are tasked with creating a script to automate the setup and execution of a Spark job using the Cannoli library. The script should handle the invocation of the `cannoli-shell` with specific memory and configuration settings. Your task is to write a Bash script that takes the executor memory, driver memory, and loca...
magicoder
You are tasked with creating a Python function that processes a list of tips for a game and generates a dictionary mapping the level number to the corresponding tip. Each tip is represented by a string and is associated with a specific level number. The function should take the list of tips as input and return the dict...
magicoder
You are given a Python dictionary containing key-value pairs. However, the dictionary has been formatted in a non-standard way, with comments interspersed throughout the code. Your task is to write a function that cleans up the dictionary by removing the comments and ensuring that all keys are in lowercase. Write a fu...
magicoder
You are tasked with creating a Python program to retrieve and process data from an API. The API endpoint `https://app.azopio.com/public_api/v1/documents/` provides a list of documents with various attributes. Your goal is to fetch the data from this API, parse it as JSON, and then extract specific information from the ...
magicoder
You are tasked with implementing a custom date and time model in TypeScript. The `DateTimeModel` class should extend the `Observable` class and provide functionality to update and retrieve the current date and time. Your task is to complete the implementation of the `DateTimeModel` class by adding the following functi...
magicoder
You are tasked with implementing a migration script for a database schema using Python and Django. The given code snippet represents a list of migration operations to be applied to the database schema. Each operation is an instance of a migration class, such as `migrations.AlterModelOptions` or `migrations.AlterField`,...
magicoder