Miscellaneous utility scripts and Python objects for agile development.
Project description
snippyts
Miscellaneous utility scripts and Python objects for agile development.
Table of objects
| No. | Name | Description | Date added | Date reviewed |
|---|---|---|---|---|
| 1 | snippyts.__init__.batched |
Partitions an input collection iterable into chunks of size batch_size. The number of chunks is unknown at the time of calling is determined by the length of iterable. |
2024 Sep 22 | 2024 Sep 22 |
| 2 | snippyts.__init__.flatten |
Given a collection of lists, concatenates all elements into a single list. More formally, given a collection holding n iterables with m elements each, this function will return a single list holding all n * m elements. |
2024 Sep 22 | 2024 Sep 22 |
| 3 | create_python_simple_package.sh |
BASH script to initialize a local Python package as a local git repository with a virtual environment, project files, and standard folder structure. It takes user input into account for parameterization from the command line. | 2024 Sep 22 | 2024 Sep 23 |
| 4 | snippyts.__init__.to_txt |
Function that expects two string parameters as arguments and writes the first string as the content of a file at the location denoted by the second string (which is assumed to denote a POSIX path). | 2024 Sep 23 | 2024 Sep 23 |
| 5 | snippyts.__init__.from_txt |
Function that can be directed to a local raw text file by its POSIX path and returns the content of that file as a string. | 2024 Sep 23 | 2024 Sep 23 |
| 6 | snippyts.__init__.to_json |
Function that expects two parameters as arguments, a Python dictionary and a string, and writes the former as the content of a file at the location denoted by the latter (which is assumed to denote a POSIX path). | 2024 Sep 24 | 2024 Sep 24 |
| 7 | snippyts.__init__.from_json |
Function that can be directed to a local JSON file by its POSIX path and returns the content of that file as a Python dictionary. | 2024 Sep 24 | 2024 Sep 24 |
| 8 | snippyts.__init__.to_pickle |
Function that can be directed to a local raw text file by its POSIX path and returns the content of that file as a Python dictionary. | 2024 Oct 03 | 2024 Oct 03 |
| 9 | snippyts.__init__.from_pickle |
Function that can be directed to a local Python-pickle file by its POSIX path and returns a copy of the artifact persisted in that file. | 2024 Oct 03 | 2024 Oct 03 |
| 10 | snippyts.trie.Trie |
A class implementing a trie data structure. | 2024 Oct 03 | 2025 Aug 27 |
| 11 | snippyts.vocabulary_tools.ExactStringMatcher |
A wrapper around flashtext2 providing a unified application interface shared with FuzzySet. |
2024 Oct 12 | 2024 Oct 26 |
| 12 | snippyts.vocabulary_tools.FuzzyStringMatcher |
A wrapper around FuzzySet providing a unified application interface shared with flashtext2. |
2024 Oct 13 | 2024 Oct 26 |
| 13 | snippyts.__init__.to_csv |
Function that expects two parameters as arguments, a list of lists (or, more geneally, an Iterable contaning other Iterables which is expected to represent a CSV-structured matrix) and a string, and writes the former as the content of a file at the location denoted by the latter (which is assumed to denote a POSIX path). | 2024 Oct 26 | 2024 Oct 26 |
| 14 | snippyts.__init__.from_csv |
Function that can be directed to a local CSV file by its POSIX path and returns the content of that file as a list of lists (or, more geneally, an Iterable contaning other Iterables which is expected to represent a CSV-structured matrix). | 2024 Oct 26 | 2024 Oct 26 |
| 15 | snippyts.__init__.tryline |
Wraps a try-raise block into a single statement. It is intended to flatten try-catch. It attempts to call the specified Python-callable object with the provided arguments and keyword arguments. If the call is successful, it silently returns the output of the call. If it fails, it raises an exception of the type provided as the second argument. |
2025 Feb 28 | 2025 Feb 28 |
| 16 | snippyts.__init__.is_url |
Determines whether a given string is a valid URL. It uses urllib.parse.urlparse, a function that splits a URL into six components: scheme, network location, path, parameters, query, and fragment. |
2025 Feb 28 | 2025 Feb 28 |
| 17 | snippyts.__init__.gtml |
Gets the HTML content of the document at the specified location URL. Named gtml as a shorthand for "get HTML". |
2025 Feb 28 | 2025 Feb 28 |
| 18 | snippyts.preprocessing.KBinsEncoder |
Discretizes the data into n_bins using scikit-learn's KBinsDiscretizer class, and then replaces every input value with the value at the bin-th quantile, ensuring that the output vector- only has n_bins unique element but- has the same dimensionality as the original input vector. |
2025 Feb 28 | 2025 Aug 23 |
| 19 | snippyts.__init__.to_yaml |
Works like to_txt but writes out YAML-formatted data. |
2025 Jul 27 | 2025 Jul 27 |
| 20 | snippyts.__init__.cp |
Shorthand for copy.deepcopy. |
2025 Jul 27 | 2025 Jul 27 |
| 21 | snippyts.__init__.from_yaml |
Works like from_yaml but reads in YAML-formatted data into a Python dictionary object. |
2025 Jul 27 | 2025 Jul 27 |
| 22 | snippyts.__init__.defolder |
Function that takes a path string as an argument. If a folder at that path does not exist yet, it gets created. It then returns the real path of the folder, resolving any symbolic links in the path if they exist. File names are implicitly parsed for their containing folder names; the folder name is handled as per the specifications but the final path returned by the function will include again the file name. | 2025 Jul 27 | 2025 Jul 27 |
| 23 | snippyts.metrics.average_token_similarity |
Given two strings, it greedily and fuzzily aligns their tokens by similarity and returns the similarity ratio for the full sequence averaged over all tokens. | 2025 Jul 28 | 2025 Jul 28 |
| 24 | snippyts.__init__.UnsupportedInputShapeError |
Self-explanatory exception. | 2025 AUG 1 | 2025 AUG 1 |
| 25 | snippyts.__init__.smart_cast_number |
Cast a numeric value to an integer if it is numerically whole; otherwise, return as float. | 2025 AUG 1 | 2025 AUG 1 |
| 26 | snippyts.__init__.is_number |
Function that checks whether a string can be interpreted as a integer or a float. | 2025 AUG 1 | 2025 AUG 1 |
| 27 | snippyts.__init__.read_arg |
Function that reads command line arguments passed to a python script, then returns the corresponding value of the specified argument's name. | 2025 JUL 27 | 2025 JUL 27 |
| 28 | snippyts.__init__.read_args |
Function that reads all named command line arguments passed to a Python script (names are those starting with - or --), then saves their corresponding values into a namedtuple. The argument names are converted into valid attribute names by stripping leading hyphens and replacing non-alpha-numeric characters with underscores. |
2025 JUL 27 | 2025 JUL 27 |
Change log
2025 AUG
NLP & ML
- Fixes
snippyts.trie.Trie. - Fixes
snippyts.preprocessing.KBinsEncoder. - Adds
snippyts.metrics.average_token_similarity, a function for calculating the average token similarity between two strings.
I/O Functions
- Adds
snippyts.__init__.to_yaml, a function for writing out YAML-formatted data. - Adds
snippyts.__init__.from_yaml, a function that reads in YAML-formatted data into a Python dictionary. - Adds
snippyts.__init__.read_arg, a function that returns the value of a specified command-line parameter name (names are those starting with-or--). - Adds
snippyts.__init__.read_args, likeread_argbut for applies implicitly to all parameters and returns their arguments as values in anamedtuple, with the parameter name as the attributes.
System & Language
- Adds
snippyts.__init__.cp, a shorthand forcopy.deepcopy. - Adds
snippyts.__init__.smart_cast_number, a function for casting a numeric value to an integer if it is numerically whole; otherwise, return as float. - Adds
snippyts.__init__.is_number, a function that checks whether a string can be interpreted as a integer or a float. - Adds
snippyts.__init__.defolder, a function that handles path strings and creates folders if they do not exist yet. - Adds
snippyts.__init__.UnsupportedInputShapeError, an exception for handling unsupported input shapes.
Running tests
Using pytest
Change into the project's home folder (first line below) and run pytest (second line). After moving into that directory, the working folder should contain two subfolders, src (in turn the parent of subfolder snippyts) and tests:
cd snippyts ;
pytest tests ;
Running the module as a package
cd snippyts ;
python -m src.snippyts.__init__ ;
python -m src.snippyts.preprocessing ;
Project details
Release history Release notifications | RSS feed
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 snippyts-0.3.0.tar.gz.
File metadata
- Download URL: snippyts-0.3.0.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d57ce4d649a0298d90b004329cc1eeb5fa2e8eafd86a83490233a1c4f998bf9d
|
|
| MD5 |
023303f497c04ce51540d5ac2ca27e70
|
|
| BLAKE2b-256 |
dba195e3fbf9564619f9efe817f33924f631d829dcc64061f7d9801991ad8444
|
File details
Details for the file snippyts-0.3.0-py3-none-any.whl.
File metadata
- Download URL: snippyts-0.3.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60e824b03a0ab4b7120bdb3ed715b71a56a1f69149d68135160551bf9c2261e6
|
|
| MD5 |
72e7edc77b78177e4ab515930b20054a
|
|
| BLAKE2b-256 |
0d42eef77c0c40faa5f0b651a724a8f48f2927edfb99d2c912dc8644f85985ac
|