instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with implementing a document conversion system that supports various destination options for PDF, JPEG, and PNG formats. The provided code snippet initializes the destination options for PDF, JPEG, and PNG formats. Your task is to create a class structure to represent these destination options and implem...
magicoder
You are working on a web application project that involves managing cloud subscriptions. The code snippet provided is from the application's routing configuration file, where views for handling subscription-related operations are imported and assigned to specific URLs. The `app_name` variable is also defined to specify...
magicoder
You are tasked with implementing a feature flag system for a software project. Feature flags are conditional statements that determine whether a certain block of code should be included in the final build based on the specified configuration. In this scenario, the project uses the Rust programming language, and the fea...
magicoder
You are working on a bioinformatics project and need to handle DNA sequence data. One common task in bioinformatics is to search for specific DNA reads within a larger sequence dataset. You are given a Python function `get_reads_by_id` from a library called `ibbr` that is supposed to retrieve DNA reads based on their u...
magicoder
You are tasked with implementing a simplified version of a coroutine scheduler in Python. A coroutine is a specialized version of a generator that can pause and resume its execution, allowing for cooperative multitasking. Your goal is to create a class that can manage the execution of coroutines and handle their suspen...
magicoder
You are working on a natural language processing (NLP) project and have been tasked with preprocessing a dataset and feeding it into a model for training. The code snippet provided is a part of the preprocessing and model input preparation process. Your task is to complete the missing part of the code to ensure that th...
magicoder
You are tasked with implementing a custom property in a Swift class that stores and retrieves integer values as strings. The property should handle the conversion between integers and strings automatically. Your task is to complete the implementation of the `details` property in the given Swift class. ```swift class C...
magicoder
You are tasked with creating a Python function that logs multiple outputs to a specified logger. The function should take in a dictionary of log targets, a logger function, and optional parameters for log name, log header, and logger name. Your goal is to implement the `logging_multi_outputs` function to log the provid...
magicoder
You are tasked with implementing a class that performs linear extrapolation based on given data points. The class should provide a method to inform it of new data points and another method to extrapolate a value for a given input. You are given the following code snippet as a reference: ```cpp extrapolator.Inform(0, ...
magicoder
You are tasked with implementing a function that calculates the distance between two points in a 2D space. The points are represented by the `CGPoint` structure, which contains `x` and `y` coordinates. The function should take two `CGPoint` objects as input and return the Euclidean distance between them. The `CGPoint`...
magicoder
You are tasked with implementing a simple API server using Rust's async/await functionality. The provided code snippet outlines a partial implementation of an `Api` struct and its associated methods. Your goal is to complete the implementation by adding the necessary code to handle incoming HTTP requests and respond wi...
magicoder
You are working on a project that involves processing graph data using TensorFlow. You have a function that takes in two TensorFlow tensors, `graph_indices` and `features_padded`, and performs some operations on them. The `graph_indices` tensor contains indices that represent the graph structure, and the `features_padd...
magicoder
You are tasked with implementing a Python function that parses a file containing training and evaluation loss data, and then visualizes the parsed data using a line plot. The function should take the file name, batch size, and a boolean flag for averaging the data as input parameters. The file contains comma-separated ...
magicoder
You are tasked with creating a script to automate the process of setting up a new GitHub repository and pushing initial commits to it. Your script should take the repository name, description, and initial commit message as input and perform the necessary Git commands to achieve this. Write a Python function called `se...
magicoder
You are tasked with implementing a Python function that processes a JSON schema to create a Spark StructType. However, the provided code snippet is incomplete and contains errors. Your task is to complete the code and handle the exception appropriately. You are given the following incomplete code snippet: ```python d...
magicoder
You are given a Python code snippet that takes three integer inputs and finds the largest and smallest among them. Your task is to write a Python function that achieves the same functionality as the given code snippet. Write a function `find_largest_smallest` that takes three integer inputs and returns a tuple contain...
magicoder
You are tasked with implementing a login functionality for a web application using Java Enterprise Edition (Java EE) technologies. The given code snippet is a partial implementation of a managed bean for user login. Your task is to complete the implementation of the login functionality by validating the user's credenti...
magicoder
You are tasked with implementing a custom neural network layer and loss function in PyTorch for a specific use case. The provided code snippet contains a simplified version of a PyTorch model with a custom layer and loss function. Your task is to extend this code to create a custom neural network module and loss functi...
magicoder
You are tasked with implementing a skill level determination system for a role-playing game. The system should take a set of attributes and calculate the corresponding skill level based on predefined rules. The attributes include strength, agility, intelligence, and charisma, each represented by an integer value. The s...
magicoder
You are tasked with implementing a function to determine if a given element is currently visible within a scrollable container. The container has the following properties: ```typescript interface ScrollProperties { scrollHeight: number; // The total height of the scrollable content clientHeight: number; // The visi...
magicoder
You are tasked with implementing a function to perform non-IID (non-identically distributed) data partitioning for a given dataset. Non-IID data partitioning is a technique commonly used in federated learning, where data is distributed among multiple clients in a non-uniform manner to simulate real-world scenarios wher...
magicoder
You are tasked with creating a data provider factory for a database management system. The factory should implement the `IDataProviderFactory` interface and provide a method to return an instance of a data provider based on a collection of attributes. Your task is to implement the `SQLiteFactory` class, which should b...
magicoder
You are tasked with implementing a simple game control system using Python. The game involves moving a character on a grid-based map using the arrow keys. The code snippet provided below captures the input for moving the character upwards. ```python while True: key = ord(getch()) if key == 119: # W # p...
magicoder
You are tasked with implementing a generic 2D vector struct in Rust. The struct should have the following properties and methods: Properties: - `x`: A floating-point number representing the x-coordinate of the vector. - `y`: A floating-point number representing the y-coordinate of the vector. Methods: - `new(x: f64, ...
magicoder
You are tasked with implementing a simple game mechanic in Unity using C#. The game involves a player interacting with objects and making decisions based on certain conditions. Your goal is to write a script that controls the behavior of an object in the game. You are given a code snippet from a Unity script that is r...
magicoder
You are tasked with creating a Python script to process a dataset and generate BERT embeddings for different text types using the BERT model. The dataset is related to pharmaceuticals and is stored in a specific format. Your script should take into account the dataset path, file names, text types, and other relevant pa...
magicoder
You are tasked with implementing a Python function that processes a list of event relay clusters and returns the count of occurrences of a specific cluster ID within the list. The cluster IDs are represented as integers. The function should be named `count_cluster_occurrences` and should take two parameters: 1. `event_...
magicoder
You are tasked with implementing a Redux action creator for a user login functionality in a React application. The action creator should take a user's display name and dispatch an action to update the Redux store with the user's information. The action creator should be implemented in a file named `userActions.js`. Yo...
magicoder
You are tasked with creating a Python function that processes a search query for news articles. The function should take a string representing the search query and return a formatted version of the query suitable for use in a news search engine. The input string may contain multiple words separated by spaces, and the o...
magicoder
You are tasked with implementing a class hierarchy for a school management system. The system should support the creation of teachers and students, and the assignment of teachers to specific subjects. Create a base class `Person` with attributes `name` and `age`. Then, create a class `Teacher` that inherits from `Per...
magicoder
You are tasked with creating a Python class that manages settings for a text-diffing application. The class should be able to write settings to a configuration file using the `QtCore.QSettings` module from the PyQt library. Your task is to implement the `writeSettings` method of the class, which should save the size of...
magicoder
You are tasked with implementing a function that reads a text file and extracts specific lines based on a given condition. The function should also save a text file from a list of tuples. You are given the following code snippet as a starting point: ```python # if last_collum_from_line.find(atom) > -1: #found ato...
magicoder
You are tasked with creating a Python class that manages a directory structure for organizing documents. The class should provide methods for adding, removing, and listing documents within the directory. Additionally, it should have a method for searching for documents based on a given keyword. Your task is to complet...
magicoder
You are tasked with creating a program that processes command-line arguments related to a network node configuration. The program should parse the given command-line arguments and extract specific information from them. Write a function or method that takes a string representing the command-line arguments and returns ...
magicoder
You are working on a data analysis project and need to implement a Singular Value Decomposition (SVD) algorithm to analyze a given dataset. The dataset is represented as a 2D array `data_array`, and you are required to perform the SVD using the NumPy library in Python. The SVD will decompose the `data_array` into three...
magicoder
You are tasked with creating a Python function that parses a given file and extracts the copyright information from the header. The copyright information is typically found within comments at the beginning of the file and follows a specific format. Your function should be able to identify and return the copyright year ...
magicoder
You are tasked with implementing a Python class that controls the behavior of a virtual robot in a simulated environment. The robot, referred to as "duckiebot," is equipped with a lifetimer that triggers the disappearance of the robot after a certain period. Additionally, the robot is capable of publishing a marker, an...
magicoder
You are tasked with creating a Python class that calculates experience point (XP) thresholds for different difficulty levels in a role-playing game. The class should have a method that takes a player's level and returns the XP threshold for the specified difficulty level. You are given the following code snippet as a ...
magicoder
You are working on a Python project that involves creating a class hierarchy for subjects and groups. The code snippet provided is a simplified version of the class `Group` that inherits from the `Subject` class. The `Group` class is using SQLAlchemy for database mapping and has a column `uuid` which is a primary key a...
magicoder
You are tasked with creating a Python function that processes migration files for a database schema. The function should take in a database connection, a migration loader, and an application label as input parameters. The migration loader is responsible for loading migration files for the specified database connection....
magicoder
You are tasked with creating a Python function that simulates a simple text-based game. The game involves a player navigating through a grid-based world, collecting treasures, and avoiding obstacles. The player's goal is to reach the end of the grid while accumulating the maximum possible score. The grid-based world i...
magicoder
You are tasked with creating a C# interface for managing inventory items in a retail application. The interface should define methods for basic CRUD (Create, Read, Update, Delete) operations on inventory items. The interface should also inherit from a base services interface. Your task is to complete the definition of...
magicoder
You are tasked with creating a simple iOS app that tracks the number of times a button is tapped and displays the count as a badge on the app's tab bar item. The provided code snippet is a part of the view controller for this app. The `index` variable is used to keep track of the number of taps, and the `showBadgeHandl...
magicoder
You are tasked with implementing a custom decorator in Python for a web application framework. The decorator should enforce user authentication before allowing access to specific routes. You are provided with a basic Flask-like code snippet as inspiration: ```python from functools import wraps class UserRoutes: d...
magicoder
You are tasked with implementing a function to calculate the cross-entropy features of a given array. Cross-entropy is a measure of the difference between two probability distributions. In this case, the function should take an array of probabilities as input and return an array of cross-entropy features. The cross-en...
magicoder
You are tasked with creating a Python function that iterates through a list of visas for a particular person and returns the count of valid visas. Each visa is represented by a dictionary containing the visa type and its expiration date. The function should take a list of visa dictionaries as input and return the count...
magicoder
You are tasked with implementing a caching mechanism for a web application. The caching mechanism should support two modes: `Absolute` and `Sliding`. In the `Absolute` mode, cached items have an absolute expiration time, while in the `Sliding` mode, cached items have a sliding expiration time that is extended each time...
magicoder
You are tasked with creating a web form that captures the date when a user lost their belongings. The form should include a date input field labeled "Q1: When did you lose your stuff?" The user should be able to select a date using the date picker provided by the form. Your task is to write HTML and JavaScript code to ...
magicoder
You are tasked with creating a Python function that parses a given setup.py file and extracts specific information from it. The setup.py file is a common file used in Python projects to define metadata about the project such as its name, version, dependencies, and other details. Your function should extract the Python ...
magicoder
You are tasked with implementing a function that processes an array of numbers and performs a specific transformation on each element. The transformation involves checking if the element is a valid number and replacing it with 0 if it is not. Your task is to write a function that accomplishes this transformation. Writ...
magicoder
You are tasked with creating a Java program to parse and analyze a snippet of JSP code. The code snippet provided is a part of a JSP file used for generating an HTML table. Your program needs to extract specific information from this code snippet and display it in a structured format. The code snippet is as follows: `...
magicoder
You are tasked with creating a Python program that simulates a simple messaging system. The program should use the GObject library to schedule the addition of a new message to the messaging system in an asynchronous manner. Your task is to implement the `add_message` function, which will be called asynchronously using...
magicoder
You are tasked with creating a Python class that generates unique identifiers for financial instruments. The identifiers to be supported are SEDOL, CUSIP, and ISIN. The class should provide methods for generating these identifiers and for converting between them. Your task is to implement the `FinancialInstrumentIdent...
magicoder
You are tasked with creating a Python function that interacts with an HTTP client to make a POST request with optional JSON data and custom headers. Your function should take in the URL, optional data, and headers as parameters, and return the response from the server. Write a function `make_post_request` with the fol...
magicoder
You are tasked with implementing a function that processes user actions for a plugin's admin options page. The function should handle uninstall, reset, and update actions based on the provided request parameters. Write a function `process_admin_options()` that takes in the request parameters and performs the following...
magicoder
You are tasked with creating a Python function to manage database operations. The function will interact with a database using a cursor and connection, and will perform table creation and insertion operations. Your task is to complete the implementation of the `runQuery` function, which takes two parameters: `operation...
magicoder
You are tasked with implementing a class that manages open orders in a trading system. The class, `OpenOrders`, is designed to store a list of open orders and provide functionality to manage these orders. The open orders are represented as instances of the `LimitOrder` class, which is a subclass of the `Order` class. T...
magicoder
You are tasked with implementing a function to compare two sets of database schemas and identify any differences between them. Each schema is represented as a list of tables, where each table is a dictionary containing the table name and its corresponding columns. You need to write a function that takes in two lists o...
magicoder
You are given a task to implement a custom hash map data structure in C++ to store key-value pairs. The hash map should support the following operations: 1. Insert a key-value pair. 2. Retrieve the value associated with a given key. 3. Remove a key-value pair. Your task is to implement the `CustomHashMap` class with t...
magicoder
You are tasked with implementing a test framework for a scientific simulation software. The code snippet provided initializes several constants and a variable for running the test. Your task is to write a function that will run the test and determine if it passes based on certain criteria. You are given the following ...
magicoder
You are tasked with implementing a custom deserialization process for a data structure in Rust. The data structure is represented using an enum called `ValueType`, which has three variants: `Integer`, `Float`, and `Unknown`. The deserialization process involves converting a byte stream into the appropriate value based ...
magicoder
You are tasked with creating a Python function that takes a state abbreviation as input and returns the corresponding FIPS (Federal Information Processing Standards) code. The FIPS code is a five-digit code used to uniquely identify counties and county equivalents in the United States. The function should handle the fo...
magicoder
You are tasked with creating a Rust macro that generates runtime benchmarks for a given function. The macro should measure the execution time of the function and print the result in a human-readable format. Your task is to implement the `runtime_bench` macro, which takes a function as an argument and generates the benc...
magicoder
You are tasked with implementing a Python function that will parse a given HTTP request and extract the headers from it. The HTTP request is represented as a string, and the headers are enclosed within a pair of curly braces `{}`. Each header is represented as a key-value pair separated by a colon `:`. Your function sh...
magicoder
You are tasked with implementing a simplified version of a form input handler in TypeScript. The provided code snippet contains a method `onChange` that returns an asynchronous function, which is intended to handle input changes in a React component. The `setValue` method is called within this function to update the va...
magicoder
You are tasked with implementing a memory management system for a software application. The system should allocate memory for a specific type of dialog window and handle potential memory allocation failures. You are given the following code snippet as a starting point: ```cpp gpMainCtrlPanel = (CMainControlPanelDlg* ...
magicoder
You are tasked with implementing a custom serialization mechanism for a specific data structure. The data structure represents a binary tree node, where each node has a value and references to its left and right children. Your goal is to write a serialization and deserialization algorithm for this binary tree node stru...
magicoder
You are tasked with implementing a simple class that represents a read-only property in C#. Your task is to complete the implementation of the `IsReadOnly` property in the given class. The property should always return `true` and should not have a setter. ```csharp public class ReadOnlyProperty { // Your task is t...
magicoder
You are tasked with creating a program that simulates a simple game of rock-paper-scissors. The program should allow a user to input their choice (rock, paper, or scissors), generate a random choice for the computer, determine the winner based on the choices, and display the result. Your program should follow these ru...
magicoder
You are tasked with simulating a lottery game using Python. The game involves generating random numbers for both the user's ticket and the winning lottery numbers. Your goal is to write a program that simulates this lottery game and determines whether the user has won a prize. Your program should perform the following...
magicoder
You are working as a software developer for a company that is deploying a knowledge base system called SoCaTel. As part of this deployment, you need to create a script that will generate secure tokens for database access. The tokens will be used by the backend data storage API endpoints running in a Docker container. Y...
magicoder
You are tasked with creating a Flask web application for a dating platform similar to Tinder. The code snippet provided initializes some essential components of the application. Your task is to implement a feature that allows users to upload and display images on their profiles. You need to create a route that handle...
magicoder
You are tasked with implementing a generic Swift class that represents a stack data structure. The provided code snippet is a part of the implementation of the `Stack` class. Your task is to complete the implementation of the `Stack` class by adding the necessary methods to manipulate the stack. The `Stack` class has ...
magicoder
You are tasked with creating a Python function that can efficiently plot a series of images using the `matplotlib` library. The function should take in a list of image data and display them in a grid layout within a single figure. Each image should be accompanied by a unique title and be assigned a distinct subplot num...
magicoder
You are tasked with implementing a simple messaging system using ZeroMQ in Python. The code snippet provided initializes a list of sockets and connects a socket to a specific port for system synchronization. Your task is to extend this code to create a basic client-server messaging system. Your goal is to implement a ...
magicoder
You are tasked with implementing a Python class method that crops an image to a specified mask. The method should take the coordinates of the mask's bounding box and return the cropped region of the image. The image is represented by a class instance with attributes `top`, `bottom`, `left`, and `right` representing the...
magicoder
You are tasked with creating a Python Flask application that manages a hierarchical data structure representing a company's organizational chart. The organizational chart is to be stored in a relational database using SQLAlchemy. The code snippet provided initializes the database connection and defines the `Tree` model...
magicoder
You are tasked with creating a Python function that simulates a simplified version of a PolarisClient, a client used to interact with a storage system. The function should take in a domain, username, and password as input parameters, and return a list of storage object IDs for Elastic Block Storage (EBS) volumes that h...
magicoder
You are tasked with implementing a test case for a resource category list in a Python application. The `ResourceCategoryListTestCase` class is a subclass of `ResourceAbstractTestCase` and is used to test the functionality of the resource category list. The `setUp` method is intended to set up the necessary environment ...
magicoder
You are tasked with creating a simple iOS app that allows users to set a range of values using UIStepper components. The app should have two UIStepper components, `minStepper` and `maxStepper`, and a UIButton component, `backButton`. The app should also utilize NSUserDefaults to store and retrieve the minimum value set...
magicoder
You are working on a software project and need to generate code coverage reports for the project's test suite. The project is written in Rust, and you are using the `grcov` tool to generate HTML code coverage reports. The code snippet provided is a command that uses `grcov` to generate the coverage report. Your task i...
magicoder
You are tasked with implementing a command-line argument parser for a Python script. The script should accept various command-line arguments and options, including a `--debug` flag for enabling debugging mode. The given code snippet shows a part of the argument parsing process, where the `--debug` flag is being appende...
magicoder
You are tasked with creating a program to process and display information about a trading card game. The program should handle legalities and rulings for a specific card. The card object has attributes `legalities` and `rulings`, which are lists of dictionaries containing information about the legal status of the card ...
magicoder
You are tasked with implementing a function that maps hymnals and hymn numbers to their corresponding IDs. The function should take two enum values as input: `hymnal` representing the hymnal type and `number` representing the hymn number type. The function should return the ID of the hymn based on the given hymnal and ...
magicoder
You are tasked with implementing a custom sorting algorithm for a specific data structure. The data structure consists of a list of `run_info` objects, each containing information about a neural network optimization run. Each `run_info` object has the following attributes: - `cpu_time`: The CPU time taken for the optim...
magicoder
You are tasked with creating a Python function that processes XML data related to operating systems. The function should take in an XML string representing OS information and return a dictionary containing the OS name and type. The XML data will have the following structure: ```xml <os_section> <os_desc></os_desc>...
magicoder
You are tasked with creating a program that analyzes the CDDL (Common Development and Distribution License) header of a file to extract specific information. The CDDL header is a comment block at the beginning of a file, containing licensing information and permissions. Your program should extract and display the follo...
magicoder
You are tasked with creating a program that simulates a simple text-based game. The game involves a player navigating through a grid-based world, collecting treasures, and avoiding obstacles. The player can move up, down, left, or right within the grid, and the game ends when the player either collects all the treasure...
magicoder
You are tasked with implementing a trait and a function in Rust to calculate the area of different geometric shapes. The trait `Area` defines a method `calculate_area` that should be implemented by the geometric shape structs. The code snippet provided includes the declaration of the `traits` module, where the `Area` t...
magicoder
You are tasked with implementing a Python class method that makes a REST API call using an API key. The method should handle various parameters such as the endpoint, action result, optional parameters, data, HTTP method, and SSL verification. Additionally, the method should update the progress and return a status based...
magicoder
You are tasked with implementing a function that takes in an array of objects representing social media icons and returns a React component that renders these icons as clickable links. Each object in the input array contains the following properties: - `src`: a string representing the URL of the social media icon - `li...
magicoder
You are working on a Python application that manages different types of posts. The application uses a dictionary called `TYPES` to store the types of posts along with their corresponding numeric codes. The `POSTS_TYPES` enum is used to define the different types of posts. However, the code snippet provided is incomplet...
magicoder
You are tasked with implementing a simple web application framework in Java. The framework consists of an `Engine` class and a method to handle HTTP requests. The `Engine` class has a static method `instance()` that returns an instance of the `Engine` class. The `Engine` instance is stored in the application's servlet...
magicoder
You are working on a package manager tool for a programming language. The tool uses a Swift script to manage dependencies and targets for a project. The code snippet provided is a part of the script that checks if a specific environment variable is set and, if so, adds test targets and dependencies to the package. You...
magicoder
You are tasked with creating a Python class that simulates a simple stopwatch. The class should have methods to start the stopwatch, stop the stopwatch, and retrieve the elapsed time in seconds. The stopwatch should accurately measure the time between the start and stop actions, and should be able to handle multiple st...
magicoder
You are tasked with implementing a configuration manager for network settings in a Python application. The configuration manager should provide default values for network settings and allow users to override these defaults. The network settings include the number of retry times for network requests, proxy enablement, p...
magicoder
You are tasked with implementing a job store for a job management system. The job store will be responsible for storing the jobs and associated files in a toil. Your task is to create a class that represents the physical storage for the jobs and associated files, adhering to the provided code snippet as a starting poin...
magicoder
You are tasked with creating a Python program that reads and processes a configuration file for a database connection. The configuration file contains key-value pairs for the database connection parameters. Your program should be able to read the configuration file, extract the necessary information, and establish a co...
magicoder
You are working on a file management system for a workspace application. The system interacts with a database to store file information and manages local files within a working directory. You need to implement a class that provides methods for interacting with the database and managing local files. The class should hav...
magicoder
You are working on a data processing system that involves executing tasks and managing their output artifacts. The system uses a function to validate the output artifacts generated by an executor. The function takes in two parameters: `output_artifacts` and `executor_output`. The `output_artifacts` is a dictionary cont...
magicoder