Built a small Python library called "colss" that lets you write NumPy expressions using a shorter, more mathematical syntax.
Github: https://github.com/SivaPA08/colss
Example:
a = np.array([1,2,3,4]) b = np.array([4,5,6,7]) c = 2 res = colss.query("sin(a+b) + log(b)^c + 12") It supports:
- logical expressions
- arithmetic operations
- ternary operators
- conditional expressions
Example:
a = np.array([1,2,3,4]) res = colss.query("a > 2 ? sqrt(a) : log(a+1)") res = colss.query("if( a>b , a+1 , b-1 )") Compared to plain NumPy syntax, the goal is mainly:
- shorter expressions
- math-like notation
- improved readability for larger and complex formulas
Still early-stage and looking for suggestions/feedback.
[link] [comments]