instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with implementing a function that processes an array of numerical values to calculate the quartiles and the maximum value. Quartiles are statistical measures that divide a dataset into four equal parts. The first quartile (Q1) represents the 25th percentile, the second quartile (Q2) represents the median... | magicoder |
You are tasked with implementing a function to handle the execution of SQL commands and logging the success or failure of each execution. The function should take a SQL connection, execute a command, and then log the outcome of the execution. You are provided with a code snippet that demonstrates the basic structure of... | magicoder |
You are tasked with implementing a function to calculate the mean of specific columns in a collection of data frames. The function should handle potential errors and return the mean values for each group within the specified columns.
You are given the following code snippet as a reference:
```python
if len(frames) < ... | magicoder |
You are tasked with creating a Windows Universal Platform (UWP) application that involves asynchronous image processing. The application uses the `Dispatcher` to run a task with normal priority. Within this task, it accesses an `_imageElement` and performs an asynchronous operation on its source.
Your goal is to imple... | magicoder |
You are tasked with creating a generic data structure that simulates a simplified version of a web service request handling system. The system consists of policies that define the rules for handling requests and services that process the requests. Your goal is to implement the data structure and its associated methods ... | magicoder |
You are tasked with creating a program that processes and displays data from a database. The program should read a query and corresponding data from a database, format and print the data, and then display the total count of records in the database.
You are given the following code snippet as a starting point:
```rust... | magicoder |
You are tasked with implementing a metrics collection system in C#. The system should support on-demand collection from various targets and process the collected data. Your task is to complete the implementation of the `Main` method in the given code snippet.
The `Main` method starts by checking if there are any confi... | magicoder |
You are tasked with creating a simple GUI application using PyQt5 in Python. Your application should consist of a main window with a button and a label. When the button is clicked, the label should display a random quote fetched from an external API. You are provided with the following code snippet to get started:
```... | magicoder |
You are tasked with creating a program to process ticket information for a train journey. The ticket includes fields denoted by key-value pairs, where the key represents the field name and the value represents the position of that field on the ticket. Additionally, there is a "my ticket" field that contains your person... | magicoder |
You are tasked with creating a Python function that processes a list of dictionaries representing fields in a database table and returns a list of field names that have both "blank" and "null" set to True.
You are given a list of dictionaries, where each dictionary represents a field in a database table. Each dictiona... | magicoder |
You are tasked with creating a Python class that represents a user role in a database using SQLAlchemy. Your class should have the following attributes:
- `id`: An integer representing the primary key of the user role.
- `userId`: An integer representing the user's ID associated with the role.
- `roleId`: An integer r... | magicoder |
You are tasked with creating a web form for users to select their state from a dropdown menu. The form is being developed using Python's Django framework and the Django forms module. The code snippet provided is a part of the form definition and shows the configuration for the "State" dropdown widget.
Your task is to ... | magicoder |
You are tasked with creating a Django view function that retrieves data from a model and passes it to a template for rendering. Your goal is to complete the implementation of the `view_vets` function, which is responsible for fetching all the records from the `VetsInfoTable` model and passing them to the template for d... | magicoder |
You are tasked with creating a Python function that retrieves and processes stock market data from an API. The code snippet below demonstrates a part of the function that makes a request to a specified URL, reads the response, parses it as JSON, and then returns the parsed data.
```python
import urllib.request
import ... | magicoder |
You are tasked with implementing a decision-making algorithm for an AI agent in a game environment. The agent is presented with a set of actions to choose from based on a given key and context. The key identifies the specific interaction, and the context provides relevant information about the agent's current state in ... | magicoder |
You are tasked with implementing a region registration system for a virtual environment. The environment consists of scenes, each of which can contain multiple regions. Each region can be associated with a grid for spatial organization. Your task is to create a class that manages the registration of regions and their a... | magicoder |
You are tasked with implementing a menu system for creating avatars in a role-playing game. The `AvatarCreationModel` class contains an enum `AvatarCreationMenu` with options for creating different types of avatars: Smasher, Summoner, and Sneak. Each option has a corresponding name.
Your task is to create a method wit... | magicoder |
You are tasked with implementing a thread-safe object handle generator for a multi-threaded application. The provided code snippet is a part of the implementation for the `RequestObjectHandle` method of the `Object` class. The method is responsible for generating unique object handles, ensuring thread safety during the... | magicoder |
You are tasked with creating an Angular module that includes a login modal component. Your goal is to define the necessary module and component, and ensure that they are properly imported and exported within the Angular application.
Your task is to complete the following steps:
1. Create an Angular module named "AuthM... | magicoder |
You are tasked with implementing a Python function that calculates a spectral line index and then plots the calculated index against the center wavelength. The function should take in two parameters: `flux`, a list of flux values, and `wave`, a list of corresponding wavelength values. The `calc_and_plot` function shoul... | magicoder |
You are working on a bioinformatics project that involves processing raw sequencing data. Your task is to write a Python function that processes raw data from different sets of reads and constructs a specific output based on the given criteria.
You are given the following code snippet as a starting point:
```python
m... | magicoder |
You are tasked with creating a Python function that processes a list of GitHub repository information and returns the total number of stars for all repositories. Each repository is represented as a dictionary with the following keys: "name" (string), "owner" (string), and "stars" (integer). The function should filter o... | magicoder |
You are tasked with implementing a function that will determine the position of a specific member in a list of joined members. The function should take in the member's ID and the list of joined members, and return the member's position in the list. The member's position is determined by the order in which they joined, ... | magicoder |
You are tasked with creating a Python class to represent a workshop event. The class should have attributes to store the location, a map link to the location, a unique URL slug, and the event price. Your task is to implement the `WorkshopEvent` class with the specified attributes and default values as shown in the code... | magicoder |
You are tasked with implementing a Python function that constructs a dictionary based on the given input parameters. The function should take in two parameters: `model` (a string representing a model name) and `description` (an optional string representing a description of the model). If a description is provided, it s... | magicoder |
You are working on a Django project and need to manage the order of installed apps in the `INSTALLED_APPS` list within the `settings.py` file. The order of apps can affect the behavior of the project, especially when dealing with app dependencies and template loading. Your task is to create a function that takes the cu... | magicoder |
You are tasked with creating a function that performs parallel HTTP requests using cURL in PHP. Your function should take an array of URLs as input and return an array of the corresponding HTTP response bodies. You should utilize the cURL multi functions to efficiently handle multiple requests simultaneously.
Your fun... | magicoder |
You are tasked with creating a Python package for a new library. The package should include necessary metadata such as dependencies, supported platforms, and classifiers. Your task is to write a Python script that generates the appropriate setup configuration for the package based on the given requirements.
You are pr... | magicoder |
You are tasked with creating a Python class that simulates a simple library management system. The class should be able to add books to the library, lend books to borrowers, and display the current inventory of books. Additionally, the class should keep track of the borrowers who have borrowed books and the due dates f... | magicoder |
You are tasked with creating a script to automate the setup process for different environments based on the value of the `ENV` variable. The script should execute specific setup tasks for the production and staging environments, and handle any unknown environment by performing common tasks.
Your script should follow t... | magicoder |
You are tasked with creating a simple program to manage a list of tasks using the RxSwift framework. The program should allow users to add, remove, and list tasks, and it should also provide the ability to mark tasks as completed.
You are given a partial implementation of the `TaskManager` class using RxSwift. The `Ta... | magicoder |
You are working on a web application project called "Meiduo Mall" and need to implement a feature that involves setting an expiration time for OpenID tokens. The code snippet provided is from the file `constants.py` in the `auoth` module of the project repository. The snippet defines a constant `OPENID_EXPIRES` with a ... | magicoder |
You are tasked with implementing a class that represents a book in a library system. The class should have the following properties and methods:
Properties:
- `title` (string): A read-only property representing the title of the book.
Methods:
- `getTitle()`: A method that returns the title of the book.
You need to i... | magicoder |
You are tasked with implementing a service for managing stock information in an e-commerce application. The application uses Angular for the front-end and relies on Ionic for mobile app development. The given code snippet is a part of the Angular module configuration for the stock management feature.
Your task is to c... | magicoder |
You are tasked with implementing a reinforcement learning agent using the Proximal Policy Optimization (PPO) algorithm. Your goal is to complete the implementation of the `observe_first` method in the `PPOAgent` class. The `observe_first` method is responsible for processing the first observation received from the envi... | magicoder |
You are tasked with creating a custom PyTorch dataset class for a specific image dataset. The dataset contains images of handwritten digits, and you need to preprocess the images and create a custom dataset class for easy loading and manipulation.
Your task is to complete the implementation of the custom dataset class... | magicoder |
You are tasked with creating a unit test for a Swift class that handles APDU (Application Protocol Data Unit) commands for a card reader provider API. The class being tested is `APDUCommand` and it is a part of the `CardReaderProviderApi` module. The test class is a subclass of `XCTestCase` and uses the `Nimble` framew... | magicoder |
You are tasked with creating a custom hook in React that manages the state of a form within a drawer component. The hook should handle form submission, validation, and imperatively expose the form's imperative methods.
Your task is to implement the `useDrawerForm` custom hook, which will be used within a React functio... | magicoder |
You are tasked with implementing a function to find alternate spellings for names. The function should recursively find alternate spellings of alternate spellings. The function will take a name as input and return a list of all the alternate spellings found.
The function will iterate through each group of alternate sp... | magicoder |
You are tasked with creating a Python function that generates a plot with a given size using the `matplotlib` library. Your function should take in the width and height of the plot as input parameters and produce a plot with the specified dimensions.
Your task is to implement the `generate_plot` function, which takes ... | magicoder |
You are tasked with implementing a file copying function in Python. Your function should take two file paths as input and copy the contents of the source file to the destination file. You should not use any built-in file copying functions or libraries such as shutil. Instead, you are required to open the files, read th... | magicoder |
You are tasked with creating a Python function that validates a given JSON string. The function should check if the input string is a valid JSON and return a specific message based on the validation result.
Write a function `validate_json(json_string)` that takes a string `json_string` as input and returns a message b... | magicoder |
You are given a Python function that processes the outputs of an instance segmentation model. The function takes in a boolean variable `isnpz` and a dictionary `outputs` containing the predicted masks and scores for each instance. The function checks if `isnpz` is True and then retrieves the predicted masks and scores ... | magicoder |
You are tasked with creating a Python function that processes an image file and returns the predicted result using a pre-trained machine learning model. Your function should handle the HTTP POST request and respond with the prediction result in JSON format. Additionally, you need to ensure that the function handles cas... | magicoder |
You are tasked with implementing a function that validates a given URL query parameter value according to the rules specified in the code snippet below. The function should return true if the input string is a valid URL query parameter value, and false otherwise.
The rules for a valid URL query parameter value are as ... | magicoder |
You are tasked with creating a database schema for a system that tracks the history of records. The schema should include a table for the main records and a separate table to store the history of changes made to these records. Each record in the main table will have a unique identifier, and the history table will refer... | magicoder |
You are tasked with creating a Python class that simulates a simple banking system. The class should be able to handle basic banking operations such as account creation, deposit, withdrawal, and balance inquiry.
Your task is to implement the `BankAccount` class with the following specifications:
- The class should hav... | magicoder |
You are tasked with creating a Python script to automate the process of checking the availability of a specific product on an e-commerce website. To achieve this, you will utilize the Selenium library to interact with a web browser and scrape the necessary information. Additionally, you will need to handle potential ex... | magicoder |
You are working on a data analysis project in the field of experimental physics. In this project, you are using the ROOT framework for data analysis and visualization. The provided code snippet is a part of the initialization process for creating and adding histograms to a list of histograms (`fListHist`).
The code sn... | magicoder |
You are tasked with creating a Python function that reads a YAML configuration file, validates its content, and then sets up the logging configuration based on the information provided in the file.
You are given a partially completed code snippet that demonstrates the initial steps of reading the YAML configuration fi... | magicoder |
You are tasked with implementing a Python class that simulates a simple key-value store. The key-value store should support operations for adding a key-value pair, retrieving the value associated with a given key, and deleting a key-value pair. Additionally, the key-value store should allow for iterating through all ke... | magicoder |
You are tasked with creating a Python function that generates a unique temporary directory path for analysis. The function should ensure that the directory path does not already exist and then return the path.
Write a Python function `generate_unique_temp_path()` that accomplishes the following:
- It takes no input pa... | magicoder |
You are tasked with creating a TypeScript class that represents a key-value store. The class should have methods for adding, retrieving, and deleting key-value pairs. Additionally, the class should enforce type safety for both keys and values.
Your task is to implement the `KeyValueStore` class with the following requ... | magicoder |
You are given a Rust code snippet that processes a collection of disks and calculates the sum of certain values. Your task is to understand the code and implement a function to perform a similar calculation.
You need to implement a function `calculate_disk_sums` that takes a reference to a vector of `Disk` objects and... | magicoder |
Martha is playing a game where she has to keep track of her points and the time she spends playing. The game has the following rules:
- Martha starts with 0 points and 0 time.
- For every play, she gains 3 points, spends 1 time unit, and uses up 1 quarter.
- When Martha reaches 10 points, she receives 9 additional quar... | magicoder |
You are tasked with implementing a class `ttime` that provides time-related functionalities. The class has a member function `time_get` that returns the current time, and a member function `wait` that takes an integer `index` as a parameter and waits for `index` seconds before returning. Your task is to complete the im... | magicoder |
You are tasked with implementing a Python function that acts as a proxy for calling other functions with an open file or file-like object as the first argument. The function should handle both filenames and file-like objects, and it should provide the option to reset the file pointer to the beginning of the file before... | magicoder |
You are tasked with creating a Python program to analyze and visualize taxi trip data from a given dataset. The dataset is stored in an HDF5 file and can be accessed from an S3 bucket. The program should read the dataset, cache it locally, and then perform some basic analysis on the taxi trip data.
Your task is to wri... | magicoder |
You are tasked with implementing a Swift enumeration and a function to determine the LCIM protocol based on a set of options. The LCIM protocol can be either protobuf1 or protobuf3, and the options include using local storage and receiving unread message count after session did open.
You are given the following Swift ... | magicoder |
You are tasked with creating a Python class to handle the parsing and manipulation of Variant Call Format (VCF) files commonly used in bioinformatics. The VCF format is a standard way of storing gene sequence variations and associated metadata. Your class should provide methods to read a VCF file, extract relevant info... | magicoder |
You are tasked with implementing a Family class that represents a family entity. The class should have the following functionalities:
1. A constructor that takes a string parameter representing the family's ID and initializes the class's id field.
2. A method called getId() that returns the family's ID.
3. An overridd... | magicoder |
You are tasked with implementing a command-line tool for managing a build system. The provided code snippet is a part of a Swift program that defines a `CleanCommand` class, which is a subclass of `FlockCommand`. The `CleanCommand` class has properties `name` and `shortDescription` initialized with values "clean" and "... | magicoder |
You are tasked with creating a function that simulates a simplified version of a task scheduler. The function should take in an array of tasks, each represented by a unique identifier and a time duration required to complete the task. The scheduler should execute the tasks in a way that minimizes the total time taken t... | magicoder |
You are tasked with implementing a custom table view in an iOS app using Swift. The provided code snippet is a part of a UITableViewController subclass. Your goal is to complete the implementation by adding the necessary methods to populate the table view with data and handle user interactions.
You are given a UITable... | magicoder |
You are tasked with creating a script to automate the setup of proxy environment variables for a non-interactive full-node job on a high-performance computing (HPC) system. The script should detect the network status and, if offline, set the necessary proxy environment variables.
Your script should perform the followi... | magicoder |
You are working on a constraint satisfaction problem solver for a scheduling application. The code snippet provided is part of a Rust program that enforces constraints on the scheduling of tasks. The program uses a set of constraints to ensure that certain conditions are met for each task. Your task is to implement a s... | magicoder |
You are working on a software system for an electric vehicle (EV) and need to implement a function to detect and store the pedal position at which the vehicle experiences zero torque. The EV's control system provides access to the vehicle's speed, torque level, and pedal position. The function should update the pedal p... | magicoder |
You are tasked with implementing a token revocation system for a web application that uses JSON Web Tokens (JWT) for authentication. Your goal is to create a function that handles revoked tokens and returns a specific response when a revoked token is encountered.
You are provided with a code snippet that includes a re... | magicoder |
You are given a 3-ary tree structure represented by a Node class as follows:
```python
class Node:
def __init__(self, val, children):
self.val = val
self.children = children
```
You need to implement the serialization and deserialization of the 3-ary tree. Serialization is the process of convertin... | magicoder |
You are tasked with implementing a custom testing framework for a programming language. The framework should allow developers to mark their test functions with a `@testable` attribute, which will indicate that the function is a test case. Additionally, the framework should provide a way to import a library called `Trie... | magicoder |
You are tasked with implementing a configuration options method for a software build system. The method should handle various operating system-specific configurations and remove certain build options based on the detected operating system. Your task is to complete the implementation of the `config_options` method based... | magicoder |
You are tasked with creating a Python program to send an email using the `smtplib` library. Your program should prompt the user to input their email address, password, the recipient's email address, and the email message. The program should then send the email using the provided credentials and message.
Your program s... | magicoder |
You are tasked with implementing a function that calculates a specific metric for a given dataset. The function takes in several parameters and returns the calculated metric. Your task is to understand the function's requirements and implement it according to the given specifications.
The function call is as follows:
... | magicoder |
You are tasked with creating a chatbot for a fitness application that provides assistance to users. The chatbot should be able to respond to specific commands and provide help options to the users. Your task is to implement the functionality for the chatbot to respond to the "/treino" command by sending a list of avail... | magicoder |
You are tasked with decoding a hexadecimal string received over a UDP connection and extracting specific information from it. The provided code snippet is a part of a script that receives a hexadecimal string and increments a counter. Your task is to write a function that takes the received hexadecimal string as input ... | magicoder |
You are tasked with creating a Rust module that provides utility functions for managing assets and entities within a game engine. The game engine is designed to handle various game assets such as textures, models, and audio files, as well as game entities such as characters, enemies, and interactive objects. Your goal ... | magicoder |
You are tasked with implementing a class for handling Google reCAPTCHA v2 verification in a C# application. The class `ReCaptchaV2` is responsible for creating a reCAPTCHA v2 request based on the provided form data and server variables. Your goal is to complete the implementation of the `GetReCaptchaV2Request` method w... | magicoder |
You are tasked with creating a Python web application that displays articles based on different categories. The application uses the Flask framework for routing and rendering templates. The code snippet provided is a simplified version of the application's routing logic.
The `render_template` function is used to rende... | magicoder |
You are given a sorted array of distinct integers and a target value. Your task is to implement a function to search for the target in the array using a modified binary search algorithm. The modification is as follows:
- If the middle element of the current subarray is less than the target and the last element of the s... | magicoder |
You are tasked with creating a Python script that renames all the files in a specified directory by adding a prefix to their names. Your script should take two arguments: the directory path and the prefix to be added to the file names. The script should then rename all the files in the specified directory by adding the... | magicoder |
You are working on a game development project where players can earn different types of coins based on their interactions with animals. The game has a set of operations represented by an enum called `Animals` and a set of coins represented by an enum called `OpsCoins`. The given code snippet is a part of the game logic... | magicoder |
You are given a list of prices representing the cost of items in a store. Your task is to write a Python function that calculates and returns the total cost of all the items in the list.
The function should be named `calculate_total_cost` and should take a single parameter:
- `prices`: a list of integers representing ... | magicoder |
You are tasked with implementing a function that checks whether a given property of an object is set to `None`. The function should take an object and the name of the property as input and return `True` if the property is `None`, and `False` otherwise.
You are provided with a code snippet that includes a function defi... | magicoder |
You are tasked with creating a Rust struct to represent music venues. The struct should have fields for the MusicBrainz Identifier and the official name of the venue. Additionally, you need to implement a method to create a new instance of the struct and a method to retrieve the MusicBrainz Identifier.
Create a Rust s... | magicoder |
You are tasked with implementing a function that processes a list of integers and returns the sum of all the even numbers in the list. However, there's a catch - you must use Rust and handle potential errors that may arise during the process.
Your task is to create a Rust function called `sum_even_numbers` that takes ... | magicoder |
You are tasked with implementing a Python class for conditional distributions. A conditional distribution is a probability distribution of one or more random variables given the value of some other random variable. Your task is to create a class `CondDist` that can compute conditional distributions and a function `get_... | magicoder |
You are tasked with implementing a function that takes a string as input and returns the count of each unique word in the string. A word is defined as a sequence of non-space characters. The function should ignore punctuation and treat uppercase and lowercase letters as equivalent. The output should be a dictionary whe... | magicoder |
You are tasked with implementing a custom Word2Vec model in Python. The Word2Vec model is a popular technique used for natural language processing and is capable of learning word embeddings from a given corpus. Your task is to complete the implementation of the `Word2Vec` class by filling in the missing code based on t... | magicoder |
You are tasked with implementing a program that generates a specific pattern of numbers. The program should take an integer input `n` and print a pattern of numbers as shown below:
For example, if `n` is 5, the program should output:
```
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
```
Your task is to write a function `printNum... | magicoder |
You are tasked with implementing a Python function that calculates the last number in the Fibonacci sequence up to a given index. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The function should handle invalid input gracefully an... | magicoder |
You are tasked with creating a program that simulates a mood mirror. The mood mirror program should take input from the user and reflect it back in a modified form based on certain rules. The rules for modifying the input are as follows:
1. If the input is a single word, the program should reverse the word and display ... | magicoder |
You are tasked with creating a simple web application that controls an LED connected to a Raspberry Pi. The web application will have a single endpoint that toggles the LED on and off. The LED is connected to pin 4 of the Raspberry Pi.
Your task is to implement the Python code for the web application using the Flask f... | magicoder |
You are tasked with implementing a simple unit of work pattern for abstracting transactions from storage APIs in C#. The provided code snippet outlines the interface `IUnitOfWork` that needs to be implemented. The interface extends `IDisposable` and `IAsyncDisposable` and includes a method for getting a repository for ... | magicoder |
You are tasked with creating a program that calculates the proportional font sizes for labels based on the figure size. The font size for the labels should be determined by multiplying the first element of the figure size by 5.
Write a function `calculate_font_size` that takes the figure size as input and returns the ... | magicoder |
You are tasked with implementing a function to calculate the influence approximation for a machine learning experiment. The function `run_experiment` takes several parameters including `_run` (a run identifier), `option` (a dictionary of options), `nepochs` (number of epochs), `weight_dir` (directory for weights), `mod... | magicoder |
You are working on a data visualization project and need to create a Python program to plot a time series of radius measurements. The data is stored in two NumPy arrays: `time` and `radius`. You want to use the `matplotlib` library to create a line plot of radius against time, with the line color set to a specific colo... | magicoder |
You are tasked with implementing a configuration section interface in a C# application. The interface, `IViewStateMoverModuleSection`, inherits from another interface, `IUmbracoConfigurationSection`, and requires the implementation of a property `Enable` of type `bool`. Your goal is to create a class that implements th... | magicoder |
You are tasked with implementing a class that represents a person's information, including their name, date of birth, and age calculation. Your task is to create a method within the class that calculates the person's age based on their date of birth. The date of birth is represented by a `LocalDate` object from the `ja... | magicoder |
You are tasked with implementing a function to copy a subset of biases from one array to another. The provided code snippet is a partial implementation of the function `copy_biases_linear`, which takes in two arrays `biases` and `biases_local_1`. The function is intended to copy a subset of biases from the `biases` arr... | magicoder |
You are tasked with creating a Python function that parses a given source code file and extracts the copyright information from it. The copyright information is typically found within comments at the beginning of the file and follows a specific format. The function should return the name of the author(s) and the licens... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.