instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a data structure to efficiently store and retrieve information about different types of services offered by a company. Each service has a unique identifier and a corresponding category. The category can be one of the following: NUTRITIONAL, PSICOLOGICAL, CPQ, or CPSV. You need to design... | codefeedback |
You are tasked with implementing a matrix abstraction package in C++. The package should include a base class for a virtual matrix and derived classes for a general matrix and a diagonal matrix. The virtual matrix class should serve as the base for the specific matrix types and provide a common interface for matrix ope... | codefeedback |
You are given a Python function `header()` that returns a tuple containing four elements: `seg_ns`, `seg_lens`, `seg_means`, and `arm_lengths`. Your task is to implement a function `process_header(header_data)` that takes this tuple as input and processes it to generate a dictionary with specific key-value pairs.
The ... | codefeedback |
You are tasked with creating a Python class that utilizes PyTorch and PyTorch Lightning to build a simple neural network for image classification. Your class should inherit from PyTorch Lightning's `LightningModule` and implement the necessary methods to define the neural network architecture, loss function, and optimi... | codefeedback |
You are tasked with implementing a custom form input component in a React application. The component should include a label, an input field, and the ability to display an error state. The provided code snippet is a part of the implementation for this custom form input component. Your task is to complete the implementat... | codefeedback |
You are tasked with implementing a Python class that simulates a simple publisher-subscriber system for a robot's odometry data. The publisher class is responsible for creating and publishing odometry messages, while the subscriber class is responsible for receiving and processing these messages.
The publisher class, ... | codefeedback |
You are given a directed graph with `n` nodes and `m` edges. Each edge is represented by three integers `u[i]`, `v[i]`, and `l[i]`, denoting the start node, end node, and length of the edge, respectively. The goal is to find the shortest path from node 1 to every other node in the graph using Dijkstra's algorithm.
Imp... | codefeedback |
You are tasked with implementing a class that calculates precision metrics for a document processing system. The class should be able to calculate page-wise precision for each tolerance level and line, as well as the overall page-wise precision for each tolerance level.
You are given a code snippet from the existing i... | codefeedback |
You are tasked with implementing a Python function to calculate the integral of a given mathematical function using Gaussian quadrature. Gaussian quadrature is a numerical integration method that uses weighted sum of function values at specific points within the integration interval. The code snippet provided initializ... | codefeedback |
You are tasked with creating a program that extracts text content from HTML tags. Given a string representing an HTML element, you need to extract the text content within the tags. The HTML element will be in the format `<tag>text content</tag>`, where `<tag>` and `</tag>` represent the opening and closing tags, and `t... | codefeedback |
You are tasked with implementing a Swift structure for creating a custom text label. The structure should have the following properties and initializers:
Properties:
- `text`: a string representing the text to be displayed
- `size`: a CGFloat representing the font size
- `color`: a UIColor representing the text color
... | codefeedback |
You are working on a geographic information system (GIS) software and need to implement a function for creating a copy of a dataset and performing a geometric transformation on it. The dataset is represented by a two-dimensional array of data points, and the geometric transformation involves applying a 2D affine transf... | codefeedback |
You are tasked with implementing a memory allocator for a video processing library. The library provides a type `PerceptionVideoFrameAllocator` which is a pointer to a void type. Your goal is to create a memory allocator that can efficiently manage memory for video frames.
Your task is to implement a memory allocation... | codefeedback |
You are working on a project that involves optimizing the performance of a graph-based algorithm using PyTorch. As part of this project, you need to implement a function that calculates the minimum time required to traverse a graph given certain constraints. The provided code snippet is a part of the existing implement... | codefeedback |
You are tasked with creating a Python function that generates a unique token for a user and stores it in a PostgreSQL database. The function should take the user ID and a database connection as input and return the generated token. If an error occurs during the token generation process, the function should roll back an... | codefeedback |
You are tasked with implementing a Java class hierarchy for a digital object management system. The provided code snippet is a part of this hierarchy and represents a superclass called `DvObjectContainer`. This class extends another class called `DvObject` and is intended to be further extended by specific types of dig... | codefeedback |
You are tasked with implementing a simple task scheduler in a multi-threaded environment. The scheduler should be able to execute tasks concurrently and handle task dependencies. Each task is represented by a unique identifier and has a duration. Dependencies between tasks are represented as directed edges in a depende... | codefeedback |
You are working on a project that involves generating random models for estimation. The project uses a programming language called Fortran and requires the use of bound-constraint optimizers for certain scenarios. Your task is to write a function that generates random model parameters and options for estimation, taking... | codefeedback |
You are tasked with implementing a Python class that represents a hyperbolic space using the Poincaré ball model. The Poincaré ball model is a way to represent hyperbolic space using the unit ball in n-dimensional Euclidean space. The class should provide methods for performing operations in the hyperbolic space, such ... | codefeedback |
You are tasked with implementing a context management system for a windowing library. The provided code snippet includes a simplified version of the context management logic. The `WindowSystem` class is responsible for managing windows, and the `ContextHelper` class provides methods for managing the rendering context.
... | codefeedback |
You are tasked with implementing a bipartite graph data structure in Java. A bipartite graph is a graph whose vertices can be divided into two disjoint sets such that every edge connects a vertex from one set to a vertex in the other set. The provided code snippet includes a partial implementation of the bipartite grap... | codefeedback |
You are tasked with creating a script to automate the process of decoding URIs of extracted files using Java. The script should handle the execution of a Java class with specific memory constraints and classpath requirements.
Your script should perform the following steps:
1. Set the maximum heap size for the Java Vir... | codefeedback |
You are tasked with creating a Python function that simulates the behavior of the `lldbutil.run_break_set_by_file_and_line` function from the LLDB Python API. The function should set a breakpoint at a specified line in a given file and return the breakpoint location.
Your task is to implement the `run_break_set_by_fil... | codefeedback |
You are tasked with creating a decorator that verifies user requests in a web application. The decorator should check if the request contains a 'uid' parameter in the POST data. If the 'uid' parameter is missing or empty, the decorator should return a forbidden response; otherwise, it should allow the original function... | codefeedback |
You are working on a large C++ project that involves the simulation of fluid dynamics using the Newtonian Euler equations. The codebase contains several namespaces and tags related to various properties of the fluid. The IWYU (Include What You Use) pragma is used to enforce that certain tags should not be forward decla... | codefeedback |
You are tasked with creating a Python decorator that logs the execution time of a function and prints the result to the console. The decorator should be able to handle functions with any number of positional and keyword arguments. You should also ensure that the original function's return value is preserved and returne... | codefeedback |
You are tasked with creating a program that simulates a simple navigation system for a robot. The robot is placed on a grid and can move in four directions: north, south, east, and west. The robot is controlled by a series of commands that are passed to it. The commands are as follows:
- "N" to move the robot one unit ... | codefeedback |
You are tasked with implementing a function that takes a string as input and returns a new string with the characters reversed. However, there is a twist - you are not allowed to use any built-in string reversal functions or methods. You must implement the reversal algorithm manually.
Write a function `reverseString` ... | codefeedback |
You are tasked with implementing a function to calculate the Generalized Intersection over Union (GIoU) loss on anchor boxes. The GIoU loss is a metric and a loss function used for bounding box regression in object detection tasks. The GIoU loss measures the dissimilarity between predicted bounding boxes and ground tru... | codefeedback |
You are tasked with creating a program that processes a given HTML snippet and extracts specific information from it. The HTML snippet contains various text content and a PHP code snippet. Your goal is to extract the text content within the `<p>` tags and identify any PHP code present in the snippet.
Write a function ... | codefeedback |
You are tasked with implementing a function to calculate the Fréchet Inception Distance (FID) for evaluating the similarity between two sets of images. The FID is a popular metric in the field of generative adversarial networks (GANs) and is used to measure the quality and diversity of generated images compared to a re... | codefeedback |
You are tasked with implementing a concurrent data structure for managing network topology information in a distributed system. The system uses asynchronous programming and requires efficient access to the network topology data. The provided code snippet is a part of the implementation for acquiring read access to the ... | codefeedback |
You are tasked with creating a program that analyzes a given software license text to extract and count the occurrences of unique license conditions. The license text is a multi-line string containing various conditions and permissions. Each condition is denoted by a comment-like syntax, starting with `//` followed by ... | codefeedback |
You are tasked with creating a Java class that manages a collection of books. The class should provide methods for adding a book, removing a book, and retrieving the total number of books in the collection. Additionally, the class should have a method for finding a book by its title and returning its details.
Your tas... | codefeedback |
You are tasked with creating a Python function that processes and augments images using the NVIDIA DALI library. The NVIDIA DALI library is a collection of highly optimized building blocks and an execution engine to accelerate the pre-processing of the input data for deep learning applications. Your task is to create a... | codefeedback |
You are working on a recommendation system that aims to estimate the impact of recommendations on user behavior. The code snippet provided is a part of the system's backend logic. The system uses uplift modeling to estimate the causal effect of a recommendation on user behavior. The code snippet shows the process of es... | codefeedback |
You are tasked with implementing a simple serialization library in Rust. The library should provide a function `to_value` that takes a value of any type that implements the `Serialize` trait and returns a value of a type that implements the `Value` trait. The `Serialize` trait represents types that can be serialized in... | codefeedback |
You are given a list of integers representing the scores of a game. Your task is to write a function that calculates the average score of the game, excluding the lowest and highest scores.
Write a function `calculate_average_score(scores)` that takes in a list of integers `scores` (2 <= len(scores) <= 100) and returns... | codefeedback |
You are tasked with creating a program that processes and manipulates information from a given code snippet. The code snippet provided is a comment block from a class file in a PHP project. Your task is to extract specific details from the comment block and perform operations on them.
You need to create a program that... | codefeedback |
You are working as a system administrator for a company that needs to ensure the security of its Linux servers. As part of your responsibilities, you are tasked with creating a script to set up audit rules for the servers using the `audit` package. The audit rules are to be configured by removing existing rules and cre... | codefeedback |
You are tasked with implementing a Python class that manages a table of UDP echo templates for Cisco IP Service Level Agreement (IPSLA) operations. The provided code snippet is a partial implementation of the class, and your task is to complete the implementation by adding necessary methods and attributes.
Your task i... | codefeedback |
You are tasked with creating a React component that handles user authentication and redirects authenticated users to the home page. The component should render a form for unauthenticated users to log in. You are given a code snippet that partially implements this functionality using React and Redux.
Your task is to co... | codefeedback |
You are tasked with implementing a basic AVL (Adelson-Velsky and Landis) tree data structure in Python. An AVL tree is a self-balancing binary search tree, where the heights of the two child subtrees of any node differ by at most one.
Your task is to implement the `AVLTree` class with the following methods:
- `insert(... | codefeedback |
You are tasked with implementing a gear shifting system for a virtual racing controller. The system should be able to handle gear changes based on certain conditions and provide feedback to the user.
Your task is to complete the implementation of the `GearHandler` class, which is responsible for managing the gear shi... | codefeedback |
You are tasked with implementing a function that processes a set of keyword arguments and performs specific operations based on the values of these arguments. The function signature is as follows:
```python
def process_arguments(
return_patterns: bool = True,
compress: bool = True,
use_tqdm: bool = True,
... | codefeedback |
You are tasked with implementing a simple messaging application in C++. The application has a user interface with various widgets and functionality. One of the key components is the friend list, which allows users to manage their friends and initiate communication with them. Your task is to create a class that represen... | codefeedback |
You are tasked with implementing a function that updates the volume of a specific sound channel based on the location of the sound source. The function `sound_updatechanvol` takes two parameters: `chan`, an integer representing the sound channel, and `loc`, a pointer to a vector containing the location of the sound sou... | codefeedback |
You are given a code snippet written in a domain-specific language used for representing relationships between entities. The code snippet involves the use of references and comparison operators. Your task is to understand the code and write a function to perform a similar comparison in a programming language of your ch... | codefeedback |
You are tasked with implementing a custom attribute validation system in C#. The system should allow developers to define custom validation attributes and apply them to properties of a class. When an object of the class is created or its properties are modified, the validation system should automatically check the vali... | codefeedback |
You are tasked with implementing a function that processes a Swift Package Manager manifest file and extracts information about the targets defined in the package. The manifest file is represented as a Swift code snippet, and the targets are defined within the `targets` array. Each target has a name and may have depend... | codefeedback |
You are tasked with creating a Python function that interacts with a RESTful API to send a command and retrieve a response. The function should take in a command name and a dictionary of parameters, then make a POST request to the API endpoint with the provided command and parameters. After receiving the response, the ... | codefeedback |
You are tasked with creating a program that parses and extracts attribute names from a given Java code snippet. The attribute names are defined within Java documentation comments and follow a specific format. The format for an attribute name is either in the form of a reference to another resource or a theme attribute.... | codefeedback |
You are tasked with creating a TypeScript mixin for a library that deals with RDF (Resource Description Framework) data. The library provides a `ResourceFactory` that allows the creation of resources with specific mixins. Your goal is to create a mixin for an `ExecutionPlatform` that extends the functionality provided ... | codefeedback |
You are tasked with creating a PHP class that implements the `SomeRectorInterface` interface. The interface has a single method called `transform()`, which takes an array of integers as a parameter and returns an array of integers. Your implementation should adhere to the strict types declaration and fulfill the requir... | codefeedback |
You are working on a music sequencing application that uses a library with a `Sequencer` class to create and manage musical tracks. The `Sequencer` class has an array of `Track` objects, each representing a different musical track. Each track can have multiple notes added to it at specific positions and with specific d... | codefeedback |
You are tasked with implementing a custom error handling mechanism for a Python application. The application has a function that may raise an error, and you need to ensure that any raised error is properly handled and re-raised if necessary. Your task is to create a decorator that can be used to wrap functions and hand... | codefeedback |
You are working on a computer vision project that involves processing images and their associated annotations. Your task is to implement a function that processes the input data and returns a dictionary containing the processed images and annotations. However, there is a potential issue with skipped labels that needs t... | codefeedback |
You are tasked with implementing a JavaScript function that manipulates the DOM based on a given set of criteria. The function should find all elements with the class "control-product" and add a new class "highlighted" to each of them.
Write a function called `highlightProducts` that takes no parameters and performs t... | codefeedback |
You are tasked with implementing a Python function that processes a given input and returns a specific output based on the input type and content. The function should handle different scenarios and return the appropriate result for each case.
Write a Python function called `process_input` that takes a single argument ... | codefeedback |
You are tasked with implementing a Python class that processes a given byte string to create a dictionary of words and their corresponding hash values. The class should provide methods to parse the byte string and generate the dictionary. The provided code snippet is a part of the class and contains a method for parsin... | codefeedback |
You are tasked with implementing a Course class and a function to create and return a list of course objects. The Course class should have the following attributes: title, partners, instructor name, description, tags, URL, and an optional snippet. The function should take in multiple parameters and use them to create i... | codefeedback |
You are tasked with implementing a simple fantasy-land library in TypeScript. Fantasy-land is a specification for interoperability of common algebraic structures in JavaScript. The code snippet provided lists a set of fantasy-land methods that need to be implemented.
Your task is to create a TypeScript interface `Fant... | codefeedback |
You are tasked with creating a program that helps language learners practice irregular verbs in English and their translations in another language. The program should present the user with a list of English verbs and their corresponding translations, along with their past tense and past participle forms. The user shoul... | codefeedback |
You are tasked with creating a Django model and admin interface for managing shifts in a service schedule. The provided code snippet includes a Django model admin class and the registration of a model with the admin site. Your task is to complete the implementation by defining the model and its related inline model for... | codefeedback |
You are tasked with optimizing a system that processes vulnerability scans using multithreading. The system currently uses a ThreadPoolExecutor to parallelize the processing of scans obtained from a Nessus scanner. However, the current implementation lacks proper error handling and resource management. Your goal is to ... | codefeedback |
You are tasked with implementing a function to calculate the influence coefficient matrix for a potential flow problem in fluid mechanics. The influence coefficient matrix is used to relate the velocity potential at collocation points to the strengths of singularities (e.g., sources, sinks, vortices) in the flow field.... | codefeedback |
You are tasked with implementing a generic function for generating a hashed key used to fetch a value corresponding to a specific key in a storage system. The function should be able to handle different types of keys and values and should return the hashed key as a vector of unsigned bytes.
The function signature is a... | codefeedback |
You are tasked with implementing a custom error handling mechanism for a C# application. The application interacts with unmanaged code using Platform Invocation Services (P/Invoke) and needs to handle any errors that may occur during these interactions. You are required to create a custom exception class and modify the... | codefeedback |
You are tasked with creating a C++ program that utilizes the C++ AMP (Accelerated Massive Parallelism) library to perform matrix multiplication. C++ AMP is a Microsoft technology that enables data-parallelism on accelerators such as GPUs. Your program should take two input matrices, multiply them using C++ AMP, and the... | codefeedback |
You are tasked with creating a program that generates random numbers of various data types and performs specific operations on them. Your program should use the provided code snippet as a starting point and extend it to include additional functionality.
Your task is to implement a function that takes in the generated ... | codefeedback |
You are tasked with implementing a C++ template meta-programming problem. Your goal is to create a meta-function that determines the size of a given type's parameter pack. The meta-function should be able to calculate the size of the parameter pack and compare it with a given value using static assertions.
You are giv... | codefeedback |
You are working on a web application that allows users to view their profile information. The application uses PHP and MySQL to retrieve user data from a database. However, the current implementation has a security vulnerability that allows for SQL injection attacks.
The code snippet below shows the vulnerable part of... | codefeedback |
You are working on a multi-class classification problem using a set of classifiers. Each classifier is responsible for predicting a specific class label. The code snippet provided is a part of the testing phase, where the predictions from each classifier are stored in an array called `test_predict`. The ground truth la... | codefeedback |
You are tasked with implementing a function that will parse a given PHP code snippet and extract the namespace and class name from it. The PHP code snippet will consist of a string containing the fully qualified class name, including the namespace, and may contain additional characters and whitespace.
Write a function... | codefeedback |
You are tasked with creating a Python class that parses a JSON object representing a media manifest and extracts specific attributes from it. Your task is to complete the implementation of the `parse_from_json_object` method in the `Manifest` class. The `parse_from_json_object` method should extract attributes from the... | codefeedback |
You are tasked with implementing a C++ class that manages template function definitions. The class should be able to store and manipulate template function definitions.
You are provided with a partial code snippet that includes the definition of a constructor for the `TmplFuncDefnEntity` class within the `smtc` namesp... | codefeedback |
You are tasked with creating a Python program to analyze a text file containing data on different categories. The program should read the file line by line, extract a specific portion of each line, and count the occurrences of each category. Specifically, the program should read a file named "Training_01.txt" and count... | codefeedback |
You are tasked with implementing a Python class method that processes system statistics from a file and filters the data based on certain criteria. The class has a method `_filter_stat` that takes in a list of system statistics and an optional boolean parameter `avg`. The method should filter the statistics based on th... | codefeedback |
You are tasked with creating a Python function to generate a text dataset for a machine learning project. The function should take in several parameters and return a `TextDataset` object. The dataset will be used for training a model, and it involves processing text data and transforming it into a format suitable for m... | codefeedback |
You are tasked with creating a multi-threaded server application in Rust that handles incoming TCP connections and manages user sessions. Your goal is to implement a function that runs the server and handles incoming connections using asynchronous I/O.
You are provided with a partial code snippet for the `run_server` ... | codefeedback |
You are tasked with implementing a transaction signing mechanism for a cryptocurrency application. The provided code snippet is a simplified version of a transaction class in Python. The class contains an `__init__` method and a `from_dict` class method. The `__init__` method initializes the transaction object with a f... | codefeedback |
You are working on a file management system, and you need to implement a function to simulate the behavior of the command `rm -rf target/classes` in a Unix-like operating system. The `rm` command is used to remove files or directories, and the `-rf` options together force the removal of a directory and its contents wit... | codefeedback |
You are tasked with implementing a program to detect and track a specific object in a video stream using OpenCV. The provided code snippet is a starting point for this task. The program uses the OpenCV library to read a video file and then processes each frame to identify and track the object of interest. Your task is ... | codefeedback |
You are tasked with implementing a simplified in-memory key-value store and participation repository in Rust. The provided code snippet is a part of an asynchronous Rust program that defines a method for deleting a key from the key-value store and a method for creating a new participation in the repository.
Your task ... | codefeedback |
You are tasked with creating a script to automate the generation of Python libraries and protocol buffer files for a blockchain framework called Iroha. The provided code snippet demonstrates the initial steps of this process, including setting up the environment, building the Iroha library, and generating protocol buff... | codefeedback |
You are tasked with implementing a Python class that manages a set of repositories. Each repository has a name and associated information, such as its status and additional details. Your task is to create a class `RepositoryManager` with the following functionalities:
1. Add a new repository with a given name and info... | codefeedback |
You are tasked with implementing a class for managing permissions on metadata objects within a testing framework. The provided code snippet is a part of a test suite for testing permissions on metadata objects. The `TestPermissions` class inherits from `TestBase` and contains a method `test_delete_instance_metadata_per... | codefeedback |
You are tasked with creating a program that extracts URLs from a given text and then processes them to display the domain names. The program should handle various URL formats and extract the domain names accurately.
Write a function `extract_domain_names` that takes a string `text` as input and returns a list of uniqu... | codefeedback |
You are working on a quantum computing simulation project and need to implement a transformation operation for quantum operators. The goal is to project the old operators onto a new basis using a given transformation function. Your task is to write a function that performs this transformation and updates the block oper... | codefeedback |
You are tasked with creating a function that generates styles for a mobile navigation menu based on the provided code snippet. The function should extract background color and border color options from the `vakker_eltd_options` object and store them in an array of CSS styles. If the options are not empty, they should b... | codefeedback |
You are tasked with simulating a lottery process for selecting winners from a pool of applicants. The lottery process involves generating a specified number of random numbers to determine the winners. Additionally, other random numbers need to be generated to serve as supplementary data for the lottery process.
You ar... | codefeedback |
You are tasked with implementing a function to calculate the Manhattan distance matrix between two arrays using NumPy. The Manhattan distance between two points (x1, y1) and (x2, y2) is defined as |x2 - x1| + |y2 - y1|. Your task is to complete the function `manhattan_distance_matrix` that takes two input arrays `a` an... | codefeedback |
You are given a photo of a landscape taken on a rare day when the sun is visible over the Zone. The sunlight on such days has unique properties, revealing details that are not visible in the usual overcast sky. Your task is to write a program to analyze the given photo and identify the number of distinct objects visibl... | codefeedback |
You are tasked with creating a Django management command that updates the access level and metadata access level for a given schema in a metadata database. The access level and metadata access level are to be provided as command-line arguments when running the management command.
You are provided with the following co... | codefeedback |
You are tasked with implementing a Python function that processes a set of high-resolution images and saves them to a specified directory. The function should take a list of high-resolution images as input and perform the following operations for each image:
1. Normalize the image by scaling its pixel values to the ran... | codefeedback |
You are working on a project that involves generating Verilog code from Register Description Language (RDL) files. The provided code snippet is a part of a Bash script used to automate this process. The script sets the IPNAME variable to "basic" and then calls two Python scripts: rdl2verilog.py and cheap_pie.sh. The rd... | codefeedback |
You are working on a web application that manages metadata for various types of content. The application uses Django, a high-level Python web framework, and the Django admin interface to manage and display the metadata. The code snippet below shows the registration of a model called `MainMetadata` with a custom admin c... | codefeedback |
You are working on a project that involves processing and organizing oceanographic data using Python. As part of this project, you need to create a function that populates a matrix with data from various oceanographic variables. The code snippet provided is a part of the function that initializes the time and depth var... | codefeedback |
You are tasked with creating a Python class that manages configuration settings for different projects and applications. Your class, `ConfigurationManager`, should handle the storage and retrieval of configuration values in a vault or Consul, based on the configuration's build time.
The class should have the following... | codefeedback |
You are tasked with implementing a Python module that provides functionality for processing text files. The module should contain two classes: `FileToCounts` and `TablesFromFiles`.
The `FileToCounts` class should have a method `count_words` that takes a file path as input and returns a dictionary containing the count ... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.