Giter VIP home page Giter VIP logo

equality-checker's Introduction

equality-checker

equality-checker Tests codecov

A not-quite-so-tiny-any-more server for testing the equivalence of two algebraic expressions using SymPy.

This project now uses Python 3. The last version using Python 2.7 was v0.8.0.

Development Setup Instructions

Simple Setup

  1. Install Python 3.10
  2. Clone this repository
  3. Run pip install -r requirements.txt
  4. Run python server\api.py

Your server should be running at http://localhost:5000/check. Now make JSON-based POST requests with target and test expression strings, e.g.

{
    "target": "x + 3",
    "test": "3 + x",
    "description": "An optional description for the logs!"
}

which will get a response like:

{
    "equal": "true",
    "equality_type": "exact",
    "parsed_target": "x + 3",
    "parsed_test": "x + 3",
    "target": "x + 3",
    "test": "3 + x"
}

or, if something went wrong, an error like:

{
    "error": "Some error message here",
    ...
}

Docker Setup

To develop the Docker container as well:

  1. Install Docker
  2. Run docker build -t ucamcldtg/equality-checker --pull .
  3. Test using docker run -p 5000:5000 -it ucamcldtg/equality-checker rather than running Python locally
  4. Optionally deploy to dockerhub: docker push ucamcldtg/equality-checker (requires authentication)

Production Use

The Docker container is available from dockerhub by running: docker pull ucamcldtg/equality-checker or by listing it as an image in a Docker Compose file. Port 5000 of the container will need to be mapped to the port the checker is expected to listen on.

For instance, run:

docker run -d -p 5000:5000 --name equality-checker ucamcldtg/equality-checker

To see live output:

docker logs -f equality-checker

equality-checker's People

Contributors

chrisjpurdy avatar daviesian avatar jsharkey13 avatar mwtrew avatar sacummins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

equality-checker's Issues

Factorials in Numeric Checking

Factorial should be done using evaluate=False, but then numeric checking is nigh impossible because we sample in the half-open interval [0 - 1) which is not integer.

Currenly factorials above 20 are also too large integers to be cast into a datatype NumPy can deal with and so cause errors if evaluated by SymPy directly.

Ability to specify domains for variables in numeric sampling

This was some sample code I wrote way back that sort of implemented that functionality, not sure how it worked now though:

##### Some test code to implement different limits on the sample space #####
test = numpy.random.random_sample((4, 10))#numpy.ones((4, 10))
lims = {"gamma": (0, 0), "b": (0, 0), "c": (0, 1), "d": (0, 0)}
up_limits = numpy.array([lims[e][1] for e in sorted(lims.keys())])
low_limits = numpy.array([lims[e][0] for e in sorted(lims.keys())])
vals = numpy.dot(numpy.diag(up_limits - low_limits), test)
print vals
vals += numpy.dot(numpy.diag(low_limits), numpy.ones((4, 10)))
tttt = sympy_parser.parse_expr("2*lamda+4*c+5*d+3*b", sympy.abc._clash)
print sorted(tttt.free_symbols, key=lambda x: str(x))
ffff = sympy.lambdify(sorted(tttt.free_symbols, key=lambda x: str(x)), tttt, "numpy")
gggg = ffff(*vals)
print gggg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.