Skip to content

bookRa/fractalgebra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FractAlgebra

A simple fraction calculator CLI

Features

  • Accepts arbitrarily many fractions, not just two at a time
  • returns the answer in lowest common denominator

Installing

Using pipx (simple and quick 🚀)

I have published fractalgebra as a PyPi package, so you don't have to pull this repo to use the CLI. Even better, using pipx, you can jump in and begin adding fractions without worrying about your python environment.

  1. Follow the instructions to install pipx on your system
  2. > pipx install fractalgebra
        installed package fractalgebra 0.1.1, installed using Python 3.9.7
        These apps are now globally available
        - fa
        done! ✨ 🌟 ✨
    > fa 1/2 + -3_3/2
      =  -4
    

Build From Source

  1. Python 3.9 or greater is required. Install it here, or use your Python env manager of choice (I prefer Conda)
  2. This project uses Poetry for dependency management and packaging
  3.  > git clone git@github.com:bookRa/fractalgebra.git
     ...
     > cd fractalgebra
     > poetry install
     ...
     > fa -1/2 + -3/2
         = -2

TODO: Downloadable Binary (See Issue #3)

time-permitting, I would use a tool like PyInstaller in combination with GitHub Actions to publish an executable or zip/folder (to the Releases Page) which any user can simply drop into their file system begin using fractalgebra without relying on any external tooling (including Python).

Testing

  1. Follow the same instructions above for "Build From Source"
  2.  > poetry run pytest                                                                                            
     Test session starts (platform: linux, Python 3.9.7, pytest 7.0.1, pytest-sugar 0.9.4)
     ...
     tests/fractalgebra_test.py ✓                                          4% ▌
     tests/helpers_test.py ✓✓✓✓✓✓✓✓✓✓✓✓✓✓                                 65% ██████▌
     tests/main_test.py ✓✓✓✓✓✓✓✓                                         100% ██████████
    
     Results (0.33s):
         23 passed

Usage

  1. Provide a space-delimeted math string using rational numbers and math operators to the fa command
    • A rational number can be a whole number (3), a fraction a mixed fraction formatted with an underscore (3_3/4) or a fraction (-9/4).
    • Negative signs are allowed anywhere except on the fraction part of a mixed fraction. Mathematically, this is ambiguous (at least based on my research)
    • The only math operations currently supported are add (+), subtract (-), multiply (*), and divide(/)

About

A python package for simple fraction algebra

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages