A simple library that adds missing functions for working with numbers and lists.
Project description
FluCutie Library v1.2.1 Documentation
## 1. Type Conversion Utilities
### toList
Converts a numeric value into a list of its constituent digits or characters.
Input:
- A number (int or float).
- An optional mode selector (default: 'number').
- If 'number': Extracts digits and decimal points. Non-numeric characters are ignored. Digits are stored as integers, dots as strings.
- If 'string': Converts the number to a string and splits it into a list of individual character strings.
Output: A list containing integers (digits) and/or strings (dots/characters).
Constraints: Input must be a number. Invalid mode selectors raise an error.
### toNum
Reconstructs a numeric value from a list of digits/characters.
Input: A list containing elements that can be interpreted as digits or a decimal point (.).
Output: An int or float.
Constraints:
- The list must contain at least one valid digit.
- Multiple decimal points are not allowed.
- Trailing decimal points are ignored (result becomes an integer).
### toWord
Concatenates all elements of a list into a single string.
Input: A list of any elements.
Output: A str.
---
## 2. Validation & Checks
### is_sorted
Checks if a list is sorted in ascending order.
Input: A list.
Output: bool (True if sorted, False otherwise).
### is_number
Checks if a value is a numeric type.
Input: Any value.
Output: bool (True if int or float).
### is_palindrome
Checks if a number or string reads the same forwards and backwards.
Input: An int, float, or str.
Output: bool.
Note: For numbers, the check is performed on the digit sequence.
### is_prime
Determines if an integer is a prime number.
Input: An int.
Output: bool.
Constraints: Input must be an integer. Numbers less than 2 return False.
### is_matrix
Checks if an object is an instance of the Matrix class.
Input: Any object.
Output: bool.
### is_perfect_square
Checks if a number is a perfect square.
Input: A number (int or float).
Output: bool.
Constraints: Input must be numeric.
---
## 3. List Operations
### delRepeat
Removes duplicate elements from a list while preserving the original order of first occurrence.
Input: A list.
Output: A new list with unique elements.
### same
Checks if two lists contain the exact same elements with the same frequencies (order independent).
Input: Two lists.
Output: bool.
Constraints: Both inputs must be lists. If lengths differ, returns False immediately.
### flatten
Recursively flattens a nested list structure into a single-level list.
Input: A list (potentially nested).
Output: A flat list.
### chunks
Splits a list into smaller sub-lists of a specified size.
Input:
- A list.
- An int representing the chunk size (must be positive).
Output: A list of sub-lists.
Constraints: Chunk size must be a positive integer.
### rotate
Rotates list elements to the left by a specified number of steps.
Input:
- A list.
- An int representing the number of steps.
Output: A new list with rotated elements.
Note: Negative steps or steps larger than the list length are handled via modulo arithmetic.
### find_duplicates
Identifies elements that appear more than once in the original list compared to its unique version.
Input: A list.
Output: A list containing the duplicate instances.
### same_quantity
Checks if all unique elements in the list appear the same number of times.
Input: A list.
Output: bool.
Note: An empty list returns True.
### mode
Finds the most frequent element in the list.
Input: A list.
Output: The most common element, or None if all elements have the same frequency (balanced).
Constraints: List cannot be empty.
### median
Calculates the statistical median of a list of numbers.
Input: A list of numbers.
Output: float or int (the median value).
Constraints: List cannot be empty.
### difference
Returns elements present in the first list but not in the second, respecting counts (multiset difference).
Input: Two lists.
Output: A list of remaining elements from the first list.
### increase
Adds a value to elements of a list.
Input:
- A list of numbers.
- A value: either a single number or another list of numbers.
Output: A new list with added values.
Behavior:
- If value is a number: Adds it to every element.
- If value is a list: Adds element-wise. Operations align by index.
### subtract
Subtracts a value from elements of a list.
Input:
- A list of numbers.
- A value: either a single number or another list of numbers.
Output: A new list with subtracted values.
### multiply
Multiplies elements of a list by a value.
Input:
- A list of numbers.
- A value: either a single number or another list of numbers.
Output: A new list with multiplied values.
### safe_get
Safely retrieves an element from a list by index.
Input:
- A list.
- An int index.
- An optional default value to return if the index is out of bounds.
Output: The element at the index, or the default value.
---
## 4. Number Operations
### numLen
Counts the number of digits in a number.
Input:
- A number (int or float).
- An optional token: 'before' (digits before decimal), 'after' (digits after decimal), or None (total digits).
Output: An int representing the count.
Note: Signs and decimal points are excluded from the count.
### between
Checks if a number lies within the range defined by two other numbers (inclusive).
Input: Three numbers (value, bound1, bound2).
Output: bool.
### digit_sum
Calculates the sum of all digits in a number.
Input: A number (int or float).
Output: An int (sum of digits).
### f (Factorial)
Calculates the factorial of a non-negative integer.
Input: An int (>= 0).
Output: An int.
Constraints: Input must be a non-negative integer.
### reverse
Reverses the digits of a number or the characters of a string.
Input: An int, float, or str.
Output:
- If number: A reversed number (int or float).
- If string: A reversed string.
### clamp
Restricts a number to lie within a specified range.
Input: A number (value), a lower bound, and an upper bound.
Output: The clamped number.
Behavior: Returns the lower bound if value is smaller, upper bound if larger, otherwise the value itself.
### seconds_to_hms
Converts seconds into a formatted time string H:M:S.
Input: A number (seconds).
Output: A str in format "H:M:S".
### minutes_to_hm
Converts minutes into a formatted time string H:M.
Input: A number (minutes).
Output: A str in format "H:M".
---
## 5. Matrix Class
The Matrix class represents a 2D grid of data.
### Initialization
Input:
- data: A flat list of elements.
- rows: int (number of rows).
- cols: int (number of columns).
Constraints: rows * cols must equal the length of data.
### Access
Input: A tuple (index1, index2) or (index, specifier).
- If specifier is 'row': Returns the entire row at index.
- If specifier is 'column': Returns the entire column at index as a list.
- Otherwise: Returns the element at [row][col].
Output: Element, row list, or column list.
### Methods
#### show()
Prints the matrix to the console in a formatted grid.
#### change_direction()
Transposes the matrix (swaps rows and columns).
Output: A new Matrix object.
#### move(num1, num2, det)
Swaps two rows or two columns.
Input: Two indices (int) and a direction specifier ('row' or 'column').
Output: A new Matrix object with swapped lines.
#### Arithmetic Operations (+, -, *)
Supports operations with scalars or other matrices.
- Scalar: Applies the operation to every element.
- Matrix: Element-wise operation.
Constraints: For matrix-matrix operations, dimensions must match exactly.
Output: A new Matrix object.
#### rotate()
Rotates the matrix 90 degrees clockwise.
Output: A new Matrix object.
#### turn()
Rotates the matrix 180 degrees.
Output: A new Matrix object.
#### max() / min()
Finds the maximum or minimum value in the matrix.
Output: The extreme value.
#### contains_string()
Checks if any element in the matrix is a string.
Output: bool.
#### sum()
Calculates the sum of all elements.
Output:
- If numeric: int or float.
- If contains strings: Concatenated str.
#### flip(val)
Flips the matrix horizontally or vertically.
Input: 'horizontal' or 'vertical'.
Output: A new Matrix object.
#### fill(val)
Creates a new matrix of the same dimensions filled with a specific value.
Input: The value to fill.
Output: A new Matrix object.
#### trace()
Calculates the trace of a square matrix (sum of diagonal elements).
Output: Sum of diagonal elements (number or concatenated string).
Constraints: Matrix must be square.
#### get_diagonal()
Extracts the main diagonal elements.
Output: A list of diagonal elements.
Constraints: Matrix must be square.
---
## 6. Matrix Helpers
### zeros(rows, cols)
Creates a matrix filled with zeros.
Input: int rows, int cols.
Output: Matrix object.
### identity(num)
Creates an identity matrix (1s on diagonal, 0s elsewhere).
Input: int size (for a num x num matrix).
Output: Matrix object.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flucutie-1.2.1.tar.gz.
File metadata
- Download URL: flucutie-1.2.1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f2a4e363f261a6aae13a7843f5068dbf164c2c821f86537002718aff1dc8474
|
|
| MD5 |
e9ebf0bb27e2f9e90d54c7dfc6902fa0
|
|
| BLAKE2b-256 |
2ba87331c1a2f777db04e54086969150059efe2f35e37e117fca7d37ea630ff7
|
File details
Details for the file flucutie-1.2.1-py3-none-any.whl.
File metadata
- Download URL: flucutie-1.2.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99f5c46c1b0a2943e8072945c075926fa4b11e760eb4c1e9de8796e9720d3ae3
|
|
| MD5 |
71ecc42b90e41513a38f0a7f3fd93370
|
|
| BLAKE2b-256 |
0dfc7c1d1f80d71c16ef3d832ed7b789a9e0a446b22ab8644ce3546b5c2b6741
|