source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_instruct_75k
21,731
Write a Python function to perform specific operations on a given one-dimensional NumPy array based on a provided suffix. The function should return a new array with the same shape as the input array, where each element is the result of applying the corresponding operation to the elements of the input array based on th...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import List def apply_operation(x: np.ndarray, suffix: str) -> np.ndarray: """ Apply a specific operation to each element of a given NumPy array based on the provided suffix. Args: x ...
magic_instruct_75k
21,750
Write a Python function to filter companies based on their location from a given list of dictionaries. Each dictionary contains information about a company, including its name and location. The function should return a list of company names that match the specified location. The code should start with: ```python from ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_companies_by_location(data: List[Dict[str, str]], target_location: str) -> List[str]: """ Filters a list of company dictionaries based on the specified location and returns a list of com...
magic_instruct_75k
21,758
Write a Python function to generate unique output file names based on a set of parameters. The output file names should be constructed by combining different correction methods and a numerical identifier. The function should take the following parameters: - `colour_corrections` (list of strings): A list of colour corre...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_output_files(colour_corrections: List[str], distortion_corrections: List[str], rescalings: List[str], numerical_range: int) -> List[str]: """ Generates a list of unique output file names bas...
magic_instruct_75k
21,786
Write a Python function to filter a list of file names and return only the names of image files. An image file is defined as a file with an extension of either ".jpg", ".jpeg", ".png", or ".gif". The function should handle both upper and lower case file extensions and should not consider file names with similar extensi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_image_only(file_names: List[str]) -> List[str]: """ Filters a list of file names and returns only the names of image files. Args: file_names (List[str]): A list of file names to be f...
magic_instruct_75k
21,788
Write a Python function to extract all URLs from a given HTML snippet. The HTML snippet will be provided as a string, and the URLs should be extracted from the `href` attribute of the `NavLink` elements. The function should return a list of URLs extracted from the `href` attributes of the `NavLink` elements. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def extractURLs(html_snippet: str) -> List[str]: """ Extracts all URLs from the `href` attributes of `NavLink` elements in a given HTML snippet. Args: html_snippet (str): The HTML ...
magic_instruct_75k
21,812
Write a Python function to extract specific information from a dictionary containing EXIF (Exchangeable Image File Format) metadata. The function should take the dictionary as input and return a new dictionary containing only the relevant information. The input dictionary, `exif_infos`, contains the following keys and ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def extract_exif_info(exif_infos: Dict[str, any]) -> Dict[str, str]: """ Extracts specific EXIF metadata from a dictionary and returns a new dictionary with formatted information. Args: exif...
magic_instruct_75k
21,834
Write a Python function to parse a URL pattern and extract all placeholder names enclosed in curly braces `{}`. The function should return a list of these placeholder names. If no placeholders are found, the function should return an empty list. The code should start with: ```python from typing import List def parse_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def parse_url_pattern(url_pattern: str) -> List[str]: """ Extracts placeholder names from a URL pattern. Args: url_pattern (str): The URL pattern containing placeholders enclosed in curly br...
magic_instruct_75k
21,843
Create a Python function called `manage_inventory` that simulates a simple inventory system for a video game. The function should allow players to add a new item to their inventory and consume an item from their inventory. The inventory will be represented as a dictionary where the keys are item IDs and the values are ...
Here is the Python code to solve the given problem in the markdown block: ```python def manage_inventory(inventory: dict, item_id: int, action: str) -> dict: """ Manages a simple inventory system for a video game by adding or consuming items. Args: inventory (dict): A dictionary representing the pl...
magic_instruct_75k
21,864
Write a Python function to count the number of unique programming languages specified in a list of classifiers. Each classifier is a string that may or may not represent a programming language and its version. The function should only consider classifiers that match the format "Programming Language :: <language> :: <ve...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_unique_languages(classifiers: List[str]) -> int: """ Counts the number of unique programming languages specified in a list of classifiers. Args: classifiers (List[str]): A list of ...
magic_instruct_75k
21,868
Create a Python class `DataBoxOffice` that manages movie ticket sales at a box office. The class should support the following operations: 1. **Adding a new movie**: The method `addMovie(movieName, availableTickets)` should add a new movie to the system with the given name and the total number of available tickets. 2. *...
Here is the Python code to solve the given problem in the markdown block: ```python class DataBoxOffice: def __init__(self): """ Initialize the DataBoxOffice with necessary data structures. """ self.movies = {} # Dictionary to store movie names and their available tickets se...
magic_instruct_75k
21,875
Write a Python function to parse and manipulate a simplified version of a symbolic expression (S-expression). An S-expression is a nested list data structure commonly used in Lisp programming languages. Each S-expression can be either an atom or a list. An atom is a single data element, such as a number or a symbol. A ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union, List def parse_sexpr(expr: str) -> Union[int, str, List]: """ Parse a string representation of an S-expression into a nested list structure. Args: expr (str): The string representation of ...
magic_instruct_75k
21,879
Write a Python function `generate_url_mapping` that takes a list of tuples representing URL patterns and returns a dictionary mapping the URL names to their corresponding views. Each tuple in the list contains three elements: a URL path or regular expression, a view function, and a URL name. The function should extract...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_url_mapping(url_patterns: list) -> dict: """ Generates a dictionary mapping URL names to their corresponding view functions from a list of URL patterns. Args: url_patterns (list): A list of tuples, wher...
magic_instruct_75k
21,910
Write a Python function to retrieve a fallback directory path based on certain conditions from a configuration. The function should: 1. Retrieve a configuration value for "service.fallback_systemd_xdg_runtime_dir" using a provided method `get_config_value`, with a default value of an empty string. 2. If the retrieved `...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def get_fallback_systemd_xdg_runtime_dir( get_config_value: callable, config_variables: Dict[str, Any] ) -> str: """ Retrieves a fallback directory path based on certain conditions from a config...
magic_instruct_75k
21,930
Write a Python function to perform hyperparameter tuning using grid search for a neural network. The function should take as input the training and test datasets, along with lists of possible values for the inner layer sizes, dropout rates, learning rates, and input dropout rates. The function should return the best se...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import pandas as pd import itertools def hyperparameter_tuning(df_full_train: pd.DataFrame, y_full_train: pd.Series, df_test: pd.DataFrame, y_test: pd.Series, inner_layers: List[...
magic_instruct_75k
21,932
Write a Python function to filter and extract specific layers from a list of layers based on given criteria. Each layer is represented by a dictionary with keys: "name" (string), "medium" (dictionary), and "thickness" (float). The "medium" dictionary contains information about the medium of the layer, including the "MO...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def extract_fluid_layers(layers: List[Dict]) -> List[str]: """ Extracts the names of layers that satisfy the given criteria from a list of layers. Args: layers (List[Dict]): A list of ...
magic_instruct_75k
21,942
Implement a Python class `Token` that represents individual tokens in a source code for a lexical analyzer. The class should support different types of tokens and their associated content. The class should have the following properties and methods: 1. **Properties**: - `Content`: Stores the content of the token. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Optional class Token: """ Represents a token in a source code for a lexical analyzer. Attributes: content (str): The content of the token. token_type (str): The type of the token (e.g., I...
magic_instruct_75k
21,947
Write a Python function to build a dictionary from a given list of tuples, where each tuple contains a word and its definition. The function should return a dictionary where the keys are the words and the values are their corresponding definitions. The function should be efficient in terms of both time and space comple...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def build_dictionary(word_definitions: List[Tuple[str, str]]) -> Dict[str, str]: """ Builds a dictionary from a list of tuples, where each tuple contains a word and its definition. Args...
magic_instruct_75k
21,949
Write a Python function to calculate the sum of all integers between two given integers, inclusive. The function should take a list of exactly two integers as input and return the sum of all integers between these two integers, including the integers themselves. If the input list does not contain exactly two integers, ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_between(nums: List[int]) -> int: """ Calculate the sum of all integers between two given integers, inclusive. Args: nums (List[int]): A list containing exactly two integers. Ret...
magic_instruct_75k
21,950
Write a Python function to process a list of image filenames and perform a specific operation on each non-empty filename. The function should handle cases where the input list is empty or contains empty strings. The specific operation to be performed on each filename is to convert the filename to lowercase and append t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def processImageList(imageList: List[str]) -> List[str]: """ Processes a list of image filenames by converting each non-empty filename to lowercase and appending the file extension ".processed" to it...
magic_instruct_75k
21,956
Write a Python function `parse_config(config_str: str) -> dict` that parses a configuration string and returns a dictionary containing the parsed configuration settings. The configuration string is in the format: ``` SETTING_NAME: type = value ``` where: - `SETTING_NAME` consists of uppercase letters, underscores, an...
Here is the Python code to solve the given problem in the markdown block: ```python def parse_config(config_str: str) -> dict: """ Parses a configuration string and returns a dictionary containing the parsed configuration settings. Args: config_str (str): The configuration string in the format "SET...
magic_instruct_75k
21,990
Write a Python function to count the total number of elements in a given list, including elements within nested lists. The function should use a recursive approach to handle nested lists. The code should start with: ```python from typing import List, Union def count_total_elements(input_list: List[Union[int, List]]) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def count_total_elements(input_list: List[Union[int, List]]) -> int: """ Counts the total number of elements in a given list, including elements within nested lists. Args: input_list ...
magic_instruct_75k
21,999
Write a Python function to process a given context and return a tuple containing specific values. The context may be `None`, in which case the corresponding value in the tuple should also be `None`. If the context is not `None`, the function should extract the identifier from the context and convert it to a string to b...
Here is the Python code to solve the given problem in the markdown block: ```python def process_context(context): """ Process the given context and return a tuple with specific values. Args: context: The context to be processed. If None, the corresponding value in the tuple will be None. Retur...
magic_instruct_75k
22,009
Write a Python function to process a list of files and their respective start positions and lengths, and return a modified list based on certain criteria. The function should take three arguments: a list of tuples representing files and their start positions and lengths, an integer representing the total length of the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def process_files(files: List[Tuple[str, int, int]], total_length: int, threshold: int) -> List[Tuple[List[str], int, int]]: """ Process a list of files and their respective start positions and le...
magic_instruct_75k
22,016
Write a Python function to calculate the factorial of a given non-negative integer using an iterative approach. The factorial of a non-negative integer `n` is the product of all positive integers less than or equal to `n`. The function should handle edge cases such as `n = 0` and `n = 1` correctly. The code should sta...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_factorial(n: int) -> int: """ Calculate the factorial of a given non-negative integer using an iterative approach. Args: n (int): The non-negative integer for which to calculate the factorial. Ret...
magic_instruct_75k
22,051
Write a Bash script to automate the testing of a Kubernetes cluster using the `podman` tool. The script should run a container with specific configurations and execute a test suite inside the container. The script should perform the following steps: 1. Use `podman` to run a container with the following configurations: ...
Here is the Python code to solve the given problem in the markdown block: ```bash #!/bin/bash # Define the variables KUBECONFIG="/path/to/kubeconfig" OPT_PAYLOAD="some_payload" # Run the container with podman podman run --rm --interactive \ -v "${KUBECONFIG}:/root/.kube/config:z" \ registry.ci.openshift.org/origi...
magic_instruct_75k
22,058
Write a Python program that processes command-line arguments and performs specific operations based on the provided input. The program should: 1. Accept command-line arguments using the `sys.argv` list. 2. Check if any command-line arguments are provided. If no arguments are provided, display a message indicating that ...
Here is the Python code to solve the given problem in the markdown block: ```python import sys def process_command_line_args(): """ Processes command-line arguments and displays each argument along with its index. If no command-line arguments are provided, a message indicating that no arguments were given...
magic_instruct_75k
22,074
Write a Python function to extract and return the text content from dynamically populated widgets in a code snippet. The code snippet is represented as a list of strings, where each string contains a call to the `QtGui.QApplication.translate` function. The function should return a dictionary where the keys are the widg...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import re def extract_widget_text(code_snippet: List[str]) -> Dict[str, str]: """ Extracts and returns the text content from dynamically populated widgets in a code snippet. Args: code...
magic_instruct_75k
22,099
Write a Python function `get_reference_link(version)` that takes a version string as input and returns the corresponding reference link. The version string will be one of the following options: 'original', 'bird', 'peacock', 'takahashi', 'mead', or 'halomodel'. Each option corresponds to a specific reference link as sh...
Here is the Python code to solve the given problem in the markdown block: ```python def get_reference_link(version: str) -> str: """ Returns the corresponding reference link for a given version string. Args: version (str): The version string to be mapped to a reference link. Returns: s...
magic_instruct_75k
22,104
Write a Python function to generate a formatted string representing the XGBoost hyperparameter configuration from two given dictionaries. The function should merge the two dictionaries and format the parameters in a readable format. The code should start with: ```python from typing import Dict def format_xgboost_param...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def format_xgboost_params(params1: Dict[str, any], params2: Dict[str, any]) -> str: """ Generates a formatted string representing the XGBoost hyperparameter configuration. Args: params1 (Dic...
magic_instruct_75k
22,108
Write a Python function to validate the protocol used in a URL. The function should check if the protocol is either "http" or "https" and return an appropriate message based on the validation result. The function should handle various cases such as uppercase/lowercase protocols and additional characters in the URL. Th...
Here is the Python code to solve the given problem in the markdown block: ```python def validate_url_protocol(url: str) -> str: """ Validates the protocol used in a URL and returns an appropriate message. Args: url (str): The URL to validate. Returns: str: A message indicating whether ...
magic_instruct_75k
22,118
Write a Python function to calculate the average reward of the best-performing scheme based on a given set of results. The function should take a dictionary `results` as input, where the keys are scheme names and the values are dictionaries containing the scheme's results. Each scheme's results dictionary contains a ke...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def average_of_the_best(results: Dict[str, Dict[str, List[int]]], reward_key: str) -> float: """ Calculate the average reward of the best-performing scheme based on the given results. Args: ...
magic_instruct_75k
22,143
Write a Python function to generate and simulate the download process for a range of web pages from a specified URL format. The function should output the generated URLs and the corresponding simulated download commands for each page number in the given range. The URL format is: "http://www.list-org.com/list.php?okved=...
Here is the Python code to solve the given problem in the markdown block: ```python def simulate_downloads(start_page: int, end_page: int) -> None: """ Simulate the download process for a range of web pages from a specified URL format. Args: start_page (int): The starting page number. end_p...
magic_instruct_75k
22,152
Write a Python function to extract specific metadata from a given dictionary and return a formatted string. The metadata includes a long description, URL, author, and author email. The function should take a dictionary as input and extract these metadata fields to create a well-formatted output string. The input dicti...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def extract_metadata(metadata_dict: Dict[str, str]) -> str: """ Extracts specific metadata from a given dictionary and returns a formatted string. Args: metadata_dict (Dict[str, str]): A dic...
magic_instruct_75k
22,157
Write a Python function to flatten a given 2D list (a list of lists) into a 1D list. The function should iterate through each element of the 2D list and append it to a new list. The code should start with: ```python from typing import List def flatten_2d_list(matrix: List[List[int]]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def flatten_2d_list(matrix: List[List[int]]) -> List[int]: """ Flattens a given 2D list (a list of lists) into a 1D list. Args: matrix (List[List[int]]): The 2D list to be flattened. Re...
magic_instruct_75k
22,164
Implement the `resolve_wait_action` and `resolve_move_action` functions for a turn-based strategy game engine. Each function should return a list containing a dictionary with a single key-value pair, where the key is "type" and the value is a string indicating the type of action resolved. Specifically: - `resolve_wait_...
Here is the Python code to solve the given problem in the markdown block: ```python def resolve_wait_action(originator, flags): """ Resolves a wait action in the game engine. Args: originator: The entity performing the action. flags: A list of flags indicating special conditions or attribut...
magic_instruct_75k
22,179
Write a Python function `reverse_and_print(input_string: str) -> str` that takes a string `input_string` as input and returns a new string containing the last three characters of the input string in reverse order. If the input string has fewer than three characters, the function should return the entire string in rever...
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_and_print(input_string: str) -> str: """ Returns a new string containing the last three characters of the input string in reverse order. If the input string has fewer than three characters, the entire string is r...
magic_instruct_75k
22,183
Write a Python function `format_time(seconds)` that takes an integer `seconds` as input and returns a string representing the time in the format "hh:mm:ss" after rounding the input time to the nearest second. The function should use the `datetime` module to format the time correctly. The starter code is: ```python imp...
Here is the Python code to solve the given problem in the markdown block: ```python import datetime def format_time(seconds: int) -> str: """ Converts a given number of seconds into a string formatted as "hh:mm:ss". Args: seconds (int): The number of seconds to convert. Returns: str: ...
magic_instruct_75k
22,186
Write a Python function to find the epoch number with the highest accuracy from a list of accuracy records for multiple epochs. If multiple epochs have the same highest accuracy, return the epoch number of the first occurrence. The function should take a list of floating-point numbers representing the accuracy of the m...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_best_epoch(accRecord: List[float], best_acc: float) -> int: """ Find the epoch number with the highest accuracy from a list of accuracy records. Args: accRecord (List[float]): A lis...
magic_instruct_75k
22,209
Write a Python function to calculate the number of unique paths from the top-left corner to the bottom-right corner of a m x n grid. You can only move either down or right at any point in time. The code should start with: ```python def unique_paths(m: int, n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def unique_paths(m: int, n: int) -> int: """ Calculate the number of unique paths from the top-left corner to the bottom-right corner of a m x n grid. Args: m (int): The number of rows in the grid. n (in...
magic_instruct_75k
22,210
Write a Python function to serialize and deserialize a dictionary containing data references and string arguments. The serialization process should encode the dictionary into a string format, and the deserialization process should decode the string back into the original dictionary format. The dictionary may contain ne...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Dict, List import json def serialize_data(data: Dict[str, Any]) -> str: """ Serialize a dictionary containing data references and string arguments into a string format. Args: data (Dict[str,...
magic_instruct_75k
22,219
Write a Python function to calculate the total velocity at a given point `x` in a fluid flow field. The fluid flow field is represented by two functions `u(x)` and `v(x)`, which give the velocity components in the x and y directions, respectively. Additionally, there is a function `forcing_velocity(x)` that provides th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def total_velocity(x: float) -> List[float]: """ Calculate the total velocity at a given point `x` in a fluid flow field. The total velocity is the sum of the velocity components from the flow field...
magic_instruct_75k
22,227
Write a Python function to process a list of migration models and extract relevant information about the models and their fields. Each model is represented as a dictionary containing the model name and a list of fields, where each field is represented as a dictionary containing the field name, type, related name, and h...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def process_migration_models(models: List[Dict]) -> Dict: """ Processes a list of migration models and extracts relevant information about the models and their fields. Args: models (Li...
magic_instruct_75k
22,266
Write a Python function to calculate the total value of all products in a given dictionary. Each product is represented as a dictionary with keys "name", "price", and "quantity". The total value of a product is calculated by multiplying its price by its quantity, and the total value of all products is the sum of the to...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def calculate_total_value(data: Dict[str, Dict[str, int]]) -> int: """ Calculate the total value of all products in the given dictionary. Args: data (Dict[str, Dict[str, int]]): A dictionary...
magic_instruct_75k
22,281
Write a Python function to extract all unique HTML tags from a given HTML content string and return them in lexicographical order. The function should handle case-insensitive tags and assume that the HTML tags are well-formed and properly closed. The code should start with: ```python from typing import List import re ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def extract_html_tags(html_content: str) -> List[str]: """ Extracts all unique HTML tags from the given HTML content string and returns them in lexicographical order. Args: html_co...
magic_instruct_75k
22,288
Write a Python function to calculate the average score of a game, excluding the highest and lowest scores from the given list of integers. The function should return the average score rounded to the nearest whole number. The input list will always contain at least 3 elements, and all elements are valid integers. The c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_average_score(scores: List[int]) -> int: """ Calculate the average score of a game, excluding the highest and lowest scores. Args: scores (List[int]): A list of integers repres...
magic_instruct_75k
22,315
Write a Python function to find the size of the largest square submatrix filled with 1's in a given 2D binary matrix. The function should return the area of the largest square submatrix. The code should start with: ```python from typing import List def maximal_square_area(matrix: List[List[str]]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def maximal_square_area(matrix: List[List[str]]) -> int: """ Find the area of the largest square submatrix filled with 1's in a given 2D binary matrix. Args: matrix (List[List[str]]): A 2D l...
magic_instruct_75k
22,323
Write a Python function to simulate a simplified version of the `ssprintf` function in C. The function should take a format string and a variable number of arguments, and return a dynamically allocated string containing the formatted output. The function should support the following format specifiers: `%d` for integers...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def my_ssprintf(fmt: str, *args: Any) -> str: """ Simulates a simplified version of the `ssprintf` function in C. Args: fmt (str): The format string containing placeholders for integers...
magic_instruct_75k
22,343
Write a Python function to generate an HTML report from exploratory data analysis (EDA) results. The EDA results are stored in a variable named `result`, which is a dictionary containing key-value pairs of EDA findings. The function should convert the EDA results into a well-structured HTML report that effectively comm...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_eda_html_report(result: dict) -> str: """ Generate an HTML report from exploratory data analysis (EDA) results. Args: result (dict): A dictionary containing the EDA results. The keys represent section t...
magic_instruct_75k
22,345
Write a Python function `extract_text_patterns(text)` that processes a given string `text` to identify and extract specific patterns using regular expressions. The function should return a dictionary containing the extracted patterns. The dictionary should have the following keys: - "block_quotes": A list of strings re...
Here is the Python code to solve the given problem in the markdown block: ```python import re def extract_text_patterns(text: str) -> dict: """ Extracts specific text patterns from the given input text using regular expressions. Args: text (str): The input text from which to extract patterns. ...
magic_instruct_75k
22,359
Implement a Python function `fill_metadata` that populates metadata fields for an audio stream based on the provided parameters. The function should handle the following metadata fields: `Audio_Codec`, `Audio_Codec_Settings`, `Encoded_Library`, `Audio_BitDepth`, `Audio_Duration`, and `Audio_BitRate`. The function shoul...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def fill_metadata(stream_type: str, stream_index: int, field: str, value: Any) -> Dict[str, Any]: """ Populates metadata fields for an audio stream based on the provided parameters. Args: ...
magic_instruct_75k
22,386
Write a Python function to process a given string and replace instances of a specific annotation misuse. The annotation `@chore` should be replaced with `@chore()` if it is not followed by parentheses. The function should handle multiple occurrences of the annotation within the string and should work for strings with m...
Here is the Python code to solve the given problem in the markdown block: ```python import re def replace_annotation_misuse(input_str: str) -> str: """ Replaces instances of the annotation `@chore` without parentheses with `@chore()` in the given string. Args: input_str (str): The input string tha...
magic_instruct_75k
22,395
Write a Python function to automate the process of clearing the cache for Docker containers. The function should handle privilege elevation to ensure it is executed with root permissions. The function should be able to clear the cache for Docker containers without requiring the user to manually enter any commands. The...
Here is the Python code to solve the given problem in the markdown block: ```python import os import subprocess def clear_docker_cache(): """ Automates the process of clearing the cache for Docker containers. This function checks if it is being run with root privileges. If not, it elevates privileges ...
magic_instruct_75k
22,413
Write a Python function to calculate the area of a specific value within a mask applied to an image. The function `get_mask_value_area` takes in three parameters: `img` (a 2D numpy array representing the image), `mask` (a 2D numpy array representing the mask), and `mval` (the specific value within the mask for which th...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def get_mask_value_area(img: np.ndarray, mask: np.ndarray, mval: int) -> int: """ Calculate the area of a specific value within a mask applied to an image. Args: img (np.ndarray): A 2D numpy arra...
magic_instruct_75k
22,460
Write a Python function to determine if a given string is a palindrome, ignoring spaces, punctuation, and capitalization. The function should return `True` if the string is a palindrome and `False` otherwise. The code should start with: ```python def is_palindrome(s: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome(s: str) -> bool: """ Determine if a given string is a palindrome, ignoring spaces, punctuation, and capitalization. Args: s (str): The input string to check. Returns: bool: True if the...
magic_instruct_75k
22,478
Write a Python function to determine the order in which courses should be taken to complete all given courses, given the number of courses and a list of prerequisites. Each prerequisite is represented as a pair `[ai, bi]`, indicating that course `bi` must be taken before course `ai`. If it is impossible to complete all...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List from collections import defaultdict, deque def find_course_order(numCourses: int, prerequisites: List[List[int]]) -> List[int]: """ Determine the order in which courses should be taken to complete all gi...
magic_instruct_75k
22,491
Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should handle any exceptions that may occur during the processing and print a specific message when an exception is caught. The function should start with: ```python def sum_even_numbers(numbers: List[int]) -> int...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_even_numbers(numbers: List[int]) -> int: """ Calculate the sum of all even numbers in the given list of integers. If an exception occurs during the processing of any number, a specific messag...
magic_instruct_75k
22,512
Write a Python function to categorize companies based on their industry code. The function should take an integer input representing the industry code and return the corresponding industry name. If the input is not a valid industry code, the function should return "Unknown Industry". The industry codes and their corres...
Here is the Python code to solve the given problem in the markdown block: ```python def categorize_company(industry_code: int) -> str: """ Categorizes a company based on its industry code. Args: industry_code (int): The industry code of the company. Returns: str: The corresponding indu...
magic_instruct_75k
22,536
Write a Python function to manage a list of service instances. Each service instance is identified by a unique ID and contains information about the service. The function should allow adding, removing, and retrieving service instances. The code should start with: ```python from typing import Dict, Optional class Servi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Optional class ServiceInstance: """ Represents a service instance with a unique ID and a name. Attributes: id (int): The unique identifier for the service instance. name (str): The ...
magic_instruct_75k
22,538
Write a Python function to generate the `rowIndex`-th row of Pascal's triangle. Pascal's triangle is a triangular array of binomial coefficients, where each element in the `n`-th row represents the coefficient of the expanded polynomial `(a + b)^n`. The function should take an integer `rowIndex` as input and return the...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def getPascalRow(rowIndex: int) -> List[int]: """ Generate the `rowIndex`-th row of Pascal's triangle. Args: rowIndex (int): The index of the row to generate. Returns: List[int]...
magic_instruct_75k
22,539
Write a Python function to extract the number of GitHub stars from a given configuration snippet. The configuration snippet is a string that contains a `<gh_stars>` tag followed by a non-negative integer representing the number of stars. The function should return the extracted number of stars as an integer. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python def extract_github_stars(config_snippet: str) -> int: """ Extracts the number of GitHub stars from a given configuration snippet. Args: config_snippet (str): A string containing the configuration snippet with a `<gh...
magic_instruct_75k
22,540
Create a Python function to simulate a simple bank account with the following operations: deposit, withdraw, and check balance. The function should also keep track of the total number of transactions (deposits and withdrawals) made on the account. The account should not allow overdrawing, i.e., the balance should not g...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def bank_account_operations(initial_balance: float, transactions: List[Tuple[str, float]]) -> Tuple[float, int]: """ Simulate a bank account with deposit, withdraw, and balance check operations. ...
magic_instruct_75k
22,541
Write a Python function to merge two sorted lists into a single sorted list efficiently. Each list is represented as a list of integers and contains elements in ascending order. The function should have a time complexity better than O(n log n), where n is the total number of elements in both lists. The code should sta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sorted_lists(list1: List[int], list2: List[int]) -> List[int]: """ Merge two sorted lists into a single sorted list. Args: list1 (List[int]): The first sorted list of integers. ...
magic_instruct_75k
22,548
Write a Python function to simulate the diagnostic message buffer for a robotics system. The function should manage a buffer of diagnostic error messages and provide a way to process these messages. Specifically, the function should: 1. Maintain a buffer to store diagnostic error messages. 2. Provide a method to add ne...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def add_diagnostic_message(buffer: List[Dict], message: Dict) -> None: """ Add a new diagnostic error message to the buffer. Args: buffer (List[Dict]): The buffer to store diagnostic e...
magic_instruct_75k
22,553
Write a Python function to find and return the integer value of a specific room in a list of RoomInfo objects. The RoomInfo class has an attribute named `integer_` which holds the integer value of the room. You are given a list of RoomInfo objects and need to find the RoomInfo object with the integer value 1 and return...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List class RoomInfo: def __init__(self, integer_): self.integer_ = integer_ def find_and_return_room_integer(container: List[RoomInfo]) -> int: """ Finds and returns the integer value of the room...
magic_instruct_75k
22,565
Write a Python function to evaluate a series of tokens representing a simple arithmetic expression involving addition and subtraction. The tokens can be either numbers or operators ("+" for addition and "-" for subtraction). The function should process the tokens from left to right and apply the operations in the corre...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def evaluate_expression(tokens: List[str]) -> int: """ Evaluates a series of tokens representing a simple arithmetic expression involving addition and subtraction. Args: tokens (List[str]): ...
magic_instruct_75k
22,566
Create a Python class `RpiPrimary` that simulates a primary node in a network system. The primary node is responsible for handling connections coming in from secondary nodes. Implement the following methods: 1. `__init__(self, primary_id)`: A constructor method that initializes the primary node with a unique `primary_i...
Here is the Python code to solve the given problem in the markdown block: ```python class RpiPrimary: """ Class to create a primary node which will handle connections coming in from secondary nodes. This class forms the basis of a general primary node which will be in charge of listening for connections ...
magic_instruct_75k
22,591
Write a Python function to simulate the process of adding a new node to a cluster and provide appropriate feedback based on the success or failure of the operation. The function should handle the status of the operation and print a message indicating the result. The code should start with: ```python def add_node_to_cl...
Here is the Python code to solve the given problem in the markdown block: ```python def add_node_to_cluster(node_name: str, operation_status: int) -> None: """ Simulates the process of adding a new node to a cluster and provides feedback based on the operation's success or failure. Args: node_name ...
magic_instruct_75k
22,596
Write a Python function to simulate the addition of VxLAN IP ports in a network overlay system that utilizes Open vSwitch (OVS) and the Open Network Operating System (ONOS). The function should take an interface name as input and return the newly added VxLAN port number. The function should also ensure that the port nu...
Here is the Python code to solve the given problem in the markdown block: ```python def add_vxlan_ip_ports(interface_name: str) -> int: """ Simulates the addition of VxLAN IP ports in a network overlay system. Args: interface_name (str): The name of the interface for which the VxLAN IP port is bein...
magic_instruct_75k
22,605
Write a Python function `process_manga_data` that processes a collection of manga data and chapter information retrieved from an external API. The function should return a dictionary containing the count of manga items and the details of the included chapters. The function should start with: ```python from typing impo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def process_manga_data(manga_collection: Dict, chapter_information: List) -> Dict: """ Processes the manga collection and chapter information to extract specific details. Args: manga_c...
magic_instruct_75k
22,629
Write a Python function to automate the deletion of Kubernetes resources defined in separate YAML files using the `kubectl` command-line tool. The function should handle the deletion of a role, a role binding, and a service account, and provide appropriate feedback in case of errors. The code should start with: ```pyt...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess def delete_kubernetes_resources(role_file: str, role_binding_file: str, service_account_file: str) -> None: """ Automates the deletion of Kubernetes resources defined in separate YAML files using `kubectl`. ...
magic_instruct_75k
22,635
Write a Python function to collapse consecutive duplicate characters in a given string into a single character. The function should take a single string parameter and return the modified string with consecutive duplicate characters collapsed. The code should start with: ```python def collapse_duplicates(s: str) -> str...
Here is the Python code to solve the given problem in the markdown block: ```python def collapse_duplicates(s: str) -> str: """ Collapses consecutive duplicate characters in a given string into a single character. Args: s (str): The input string to be processed. Returns: str: The modif...
magic_instruct_75k
22,639
Write a Python function to remove consecutive duplicate elements from a given list of integers. The function should return a new list with all consecutive duplicate elements removed, preserving the order of the remaining elements. The code should start with: ```python from typing import List def removeConsecutiveDupl...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def removeConsecutiveDuplicates(scores: List[int]) -> List[int]: """ Removes consecutive duplicate elements from the given list of integers. Args: scores (List[int]): The list of integers fr...
magic_instruct_75k
22,676
Write a Python function to automate the process of downloading and extracting the IMDb movie review dataset. The dataset is available for download as a compressed file from the URL `http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz`. The function should perform the following steps: 1. Display "Downloading....
Here is the Python code to solve the given problem in the markdown block: ```python import os import subprocess def download_and_extract_dataset(): """ Automates the process of downloading and extracting the IMDb movie review dataset. Steps: 1. Display "Downloading..." to indicate the start of the dow...
magic_instruct_75k
22,677
Write a Python function to convert a given non-negative integer into its binary and octal representations. The function should handle the case where the input number exceeds a predefined maximum allowed value. If the input number exceeds this maximum value, the function should return "Exceeds maximum value". The binary...
Here is the Python code to solve the given problem in the markdown block: ```python MAX_EXAMPLES = 1000 def to_bin(x: int) -> str: """ Converts a non-negative integer to its binary representation. Args: x (int): The non-negative integer to be converted. Returns: str: The binary repres...
magic_instruct_75k
22,680
Write a Python function to automate the deployment of a Dockerized API service. The function should remove any existing container for the API and then bring up a new container using Docker Compose. The function should handle any potential errors or issues that may arise during the container removal or startup process. ...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess def deploy_api_service(api_container_name: str, project_name_api: str) -> None: """ Automates the deployment of a Dockerized API service by removing any existing container and bringing up a new one using Docke...
magic_instruct_75k
22,682
Write a Python function to filter a list of dictionaries representing different types of devices based on their type and status. Each dictionary contains information about a device, including its type and status. The function should return a list of dictionaries that match the specified device type and status. The cod...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_devices(devices: List[Dict[str, str]], device_type: str, status: str) -> List[Dict[str, str]]: """ Filters a list of device dictionaries based on the specified device type and status. ...
magic_instruct_75k
22,726
Write a Python function to determine if a given string is a valid palindrome. A valid palindrome is a string that reads the same forward and backward, ignoring spaces, punctuation, and capitalization. The function should return `True` if the string is a valid palindrome, and `False` otherwise. The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python def is_valid_palindrome(s: str) -> bool: """ Determine if a given string is a valid palindrome. A valid palindrome is a string that reads the same forward and backward, ignoring spaces, punctuation, and capitalization. ...
magic_instruct_75k
22,731
Write a Python function `filter_repositories` that takes three parameters: - `repositories`: a list of dictionaries, each containing the keys "name" for the repository name and "stars" for the number of stars. - `min_stars`: an integer representing the minimum number of stars for filtering. - `max_stars`: an integer re...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_repositories(repositories: List[Dict[str, int]], min_stars: int, max_stars: int) -> List[str]: """ Filters a list of GitHub repositories based on the number of stars within a specified r...
magic_instruct_75k
22,738
Write a Python function to decode a list of image resource blocks and return a list of parsed data structures. Each image resource block contains a `data` field that needs to be parsed into a structured format. The `decode` function should take a list of image resource blocks as input and return a list of parsed data s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def decode(image_resource_blocks: List[Dict[str, str]]) -> List[Dict[str, str]]: """ Replaces ``data`` of image resource blocks with parsed data structures. Args: image_resource_blocks...
magic_instruct_75k
22,745
Write a Python function to perform a series of array manipulations on a given NumPy array `x` based on a specified flipping axis. The function should swap axes and reverse the order of elements along certain axes to achieve the desired flipping effect. The function should start with: ```python import numpy as np def f...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def flip_axis_fra(x: np.ndarray, flipping_axis: int) -> np.ndarray: """ Perform a series of array manipulations to flip the array along the specified axis. Args: x (np.ndarray): The input NumPy a...
magic_instruct_75k
22,749
Write a Python function to extract the second element from each tuple in a given list of tuples. If a tuple does not have a second element, the function should return `None` for that tuple. The function should be efficient and handle various edge cases, such as empty tuples or tuples with fewer than two elements. The ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Any, Optional def extract_second_element(input_list: List[Tuple[Any, ...]]) -> List[Optional[Any]]: """ Extracts the second element from each tuple in the input list. If a tuple does not have...
magic_instruct_75k
22,751
Write a Python function to implement a simple stack data structure. The stack should support the following operations: 1. `push(element)`: Add an element to the top of the stack. 2. `pop()`: Remove and return the element at the top of the stack. If the stack is empty, return "Underflow". 3. `peek()`: Return the element...
Here is the Python code to solve the given problem in the markdown block: ```python class Stack: def __init__(self): """ Initialize an empty stack. """ self.items = [] def push(self, element): """ Add an element to the top of the stack. Args: ...
magic_instruct_75k
22,757
Write a Python function to reverse a given string without using any built-in reverse functions or methods. The function should handle both uppercase and lowercase letters, as well as special characters. The code should start with: ```python def reverse_string(input_string: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_string(input_string: str) -> str: """ Reverses the input string without using any built-in reverse functions or methods. Args: input_string (str): The string to be reversed. Returns: str: Th...
magic_instruct_75k
22,762
Write a Python function to extract and display all movie titles from an HTML document. The HTML document is represented as a BeautifulSoup object, and the movie titles are contained within anchor tags (`<a>`) inside a specific HTML element. The function should handle cases where there are no movie titles found and shou...
Here is the Python code to solve the given problem in the markdown block: ```python from bs4 import BeautifulSoup def extract_movie_titles(html_content: str) -> None: """ Extracts and displays all movie titles from an HTML document. Args: html_content (str): The HTML content as a string. Retu...
magic_instruct_75k
22,789
Write a Python function to process a configuration dictionary for a deep learning model training setup. The function should extract specific information from the dictionary and perform certain operations based on the extracted data. The function should return a tuple containing the extracted values in a specified order...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple, Any def process_training_config(config_dict: Dict[str, Any]) -> Tuple[str, int, bool, int, List[str]]: """ Processes a configuration dictionary for a deep learning model training setup. ...
magic_instruct_75k
22,812
Write a Python function to validate a list of records fetched from a database. Each record is represented as a tuple containing information about a web request. The function should check if each record meets the following criteria: 1. The URL should be "https://www.qwe.com". 2. The HTTP status code should be 200. 3. Th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def validate_records(records: List[Tuple[str, int, int]]) -> bool: """ Validate a list of records fetched from a database. Each record is a tuple containing information about a web request. A...
magic_instruct_75k
22,814
Write a Python function to update a dictionary containing information about Open Reading Frames (ORFs) based on certain conditions. The dictionary, `orfs`, stores information about ORFs found in different DNA sequences. Each key in the `orfs` dictionary represents a DNA sequence (query), and the corresponding value is ...
Here is the Python code to solve the given problem in the markdown block: ```python def update_orfs(orfs: dict, pid: int, min_pid: int, query: str, subject: str, blast_result: str) -> dict: """ Updates the `orfs` dictionary based on the given conditions. Args: orfs (dict): The initial dictionary co...
magic_instruct_75k
22,817
Write a Python function to generate manual pages for a cryptocurrency software suite. The function should take a list of software components and their corresponding version numbers as input and produce a dictionary where each key is a component name and the value is the corresponding manual page with version informatio...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def generateManualPages(components: List[str], versions: List[str]) -> Dict[str, str]: """ Generate manual pages for a cryptocurrency software suite. Args: components (List[str]): A li...
magic_instruct_75k
22,827
Write a Python function to sort a list of South American and Central American countries, along with French Guiana, in alphabetical order and group them by the first letter of each country. Additionally, count the number of countries that start with each letter and display the result in a formatted manner. The code sho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def group_and_count_countries(countries: List[str]) -> None: """ Sorts a list of countries in alphabetical order, groups them by the first letter, counts the number of countries that start with each ...
magic_instruct_75k
22,840
Write a Python function to find the sum of all prime numbers below a given limit. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should be named `sum_primes_under` and should take an integer `limit` as input. It should return the sum of all prime nu...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_primes_under(limit: int) -> int: """ Calculate the sum of all prime numbers less than the given limit. Args: limit (int): The upper limit (exclusive) up to which to sum prime numbers. Returns: i...
magic_instruct_75k
22,842
Write a Python function to calculate the minimum number of single-character edits required to convert one string (`str1`) into another string (`str2`). The allowed edit operations are insertion, deletion, or substitution of a single character. The function should start with: ```python def min_edit_distance(str1: str, s...
Here is the Python code to solve the given problem in the markdown block: ```python def min_edit_distance(str1: str, str2: str) -> int: """ Calculate the minimum number of single-character edits required to convert `str1` into `str2`. Args: str1 (str): The first string. str2 (str): The seco...
magic_instruct_75k
22,878
Write a Python function to add a new default route to a routing table represented as a list of dictionaries. Each dictionary in the list contains information about a specific route, including the destination IP address or network in CIDR notation, the next hop IP address, the network interface, and the route metric. Th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def add_default_route(route_table: List[Dict[str, str]], via: str, dev: str) -> List[Dict[str, str]]: """ Adds a new default route to the given routing table. Args: route_table (List[D...
magic_instruct_75k
22,881
Write a Python function to create a deep copy of a list of dictionaries. Each dictionary in the input list may contain any number of key-value pairs, and the function should ensure that modifications to the dictionaries in the returned list do not affect the original input list. The code should start with: ```python f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Any import copy def deep_copy_records(records: List[Dict[str, Any]]) -> List[Dict[str, Any]]: """ Creates a deep copy of a list of dictionaries. Args: records (List[Dict[str, Any]]): ...
magic_instruct_75k
22,910
Write a Python function `format_package_info(package_info)` that takes a dictionary `package_info` as input and returns a formatted string containing the package information. The dictionary `package_info` contains metadata about a Python package, including its name, description, author, author email, version, URL, inst...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def format_package_info(package_info: Dict[str, str]) -> str: """ Formats the package information from a dictionary into a readable string. Args: package_info (Dict[str, str]): A dictionary ...
magic_instruct_75k
22,911
Implement a simplified document management system using a class `Document`. The system should support the following operations: 1. **Saving a Document**: The `save` method should save the document and assign it a unique ID. 2. **Fetching a Document**: The `fetch` method should retrieve the document based on its ID. 3. ...
Here is the Python code to solve the given problem in the markdown block: ```python class Document: def __init__(self): """ Initializes the document storage and the next available ID. """ self.documents = {} self.next_id = 1 def save(self): """ Saves the ...
magic_instruct_75k
22,916
Write a Python function to filter and sort a list of dates in the format "YYYY-MM-DD", ensuring that the output list contains only unique dates in ascending order. The input list may contain duplicate dates, and the output list should not have any duplicates. The code should start with: ```python from typing import Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def unique_dates(dates: List[str]) -> List[str]: """ Filters and sorts a list of dates in the format "YYYY-MM-DD", ensuring that the output list contains only unique dates in ascending order. Args: ...
magic_instruct_75k
22,924
Create a Python function to encode a given input string into Base64 format and another function to decode a Base64-encoded string back to its original form. The encoding function should take a string as input and return its Base64-encoded representation. The decoding function should take a Base64-encoded string as inpu...
Here is the Python code to solve the given problem in the markdown block: ```python import base64 def base64_encode(input_string: str) -> str: """ Encodes a given input string into Base64 format. Args: input_string (str): The string to be encoded. Returns: str: The Base64-encoded repr...
magic_instruct_75k
22,946
Write a Python function that assigns specific values to two variables `a` and `b`, and then prints their values on separate lines. The function should: - Assign the value `5` to variable `a`. - Assign the value `"Hello"` to variable `b`. - Print the value of `a` on the first line. - Print the value of `b` on the second...
Here is the Python code to solve the given problem in the markdown block: ```python def print_variables(): """ Assigns specific values to two variables and prints them on separate lines. This function assigns the value 5 to the variable `a` and the value "Hello" to the variable `b`. It then prints the ...
magic_instruct_75k
22,972
Implement a simple data structure for managing descriptions of concepts. The given code snippet provides a basic outline for the classes involved. Your task is to extend this code by implementing additional functionality and ensuring proper data management. You need to implement the following functionalities: 1. Add a...
Here is the Python code to solve the given problem in the markdown block: ```python class Concept: def __init__(self, ID, descriptions=None): """ Initialize a Concept object with an ID and an optional list of descriptions. Args: ID (str): The ID of the concept. descr...
magic_instruct_75k
22,974
Create a Python class `DataTypeRegistry` that serves as a registry for data types. The class should allow for registering new data types and retrieving them by name. Additionally, the class should support the ability to check if a data type is already registered. The class should include the following methods: - `__ini...
Here is the Python code to solve the given problem in the markdown block: ```python class DataTypeRegistry: def __init__(self): """ Initializes the DataTypeRegistry with an empty registry. """ self.registry = {} def register(self, name, data_type): """ Register a...