Skip to content
/ tlm Public

A tiny, teachable library with a NumPy-like feel implemented **entirely in pure Python**. Part of the TidyLLM verse.

License

Notifications You must be signed in to change notification settings

RudyMartin/tlm

Repository files navigation

tidyllm-puremath

Pure Python math library: NumPy-like API on pure Python lists (NumPy-free)

Zero External Dependencies

This package uses only Python standard library modules:

Module Purpose
math Basic math functions
random Random number generation
statistics Statistical functions
cmath Complex math (FFT)
builtins Built-in functions
typing Type hints
collections Data structures

Random Number Generation

Uses Python's stdlib random module with reproducible seeding:

import random
rng = random.Random(seed)  # Reproducible RNG
rng.random()               # Generate random float
rng.shuffle(list)          # Shuffle in place

Features

  • Array Operations: array, zeros, ones, eye, transpose, dot, matmul
  • Math: exp, log, sqrt, clip, norm, l2_normalize
  • Statistics: mean, var, std, median, percentile, correlation
  • Distance/Similarity: cosine, euclidean, manhattan, hamming
  • ML Algorithms: logistic regression, SVM, k-means, PCA, GMM, Naive Bayes
  • Losses: MSE, cross-entropy, focal, hinge, KL divergence, triplet
  • Metrics: precision, recall, F1, ROC-AUC, confusion matrix
  • Signal Processing: FFT, wavelets, STL decomposition, filtering
  • Network Analysis: centrality, PageRank, community detection
  • Trading: technical indicators, strategies, risk management

Installation

pip install -e packages/tidyllm-puremath

Usage

import tlm

# Array operations
x = tlm.array([[1, 2], [3, 4]])
y = tlm.transpose(x)
z = tlm.matmul(x, y)

# ML algorithms
model = tlm.logreg_fit(X_train, y_train)
predictions = tlm.logreg_predict(X_test, model)

# Metrics
acc = tlm.accuracy(y_true, y_pred)
f1 = tlm.f1_score(y_true, y_pred)

License

CC BY 4.0

About

A tiny, teachable library with a NumPy-like feel implemented **entirely in pure Python**. Part of the TidyLLM verse.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages