Coder Social home page Coder Social logo

androidfriendly's Introduction

Android-Friendly NumPy and Matplotlib

version 0.0.1 (07-Sep-2014)

ABOUT

The NumPy and Matplotlib packages are absolutely awesome, and two of my bestest friends. BUT! When compiling code to an Android .pkg using the PyGame subset for Android, they don't quite play nice.

Therefore, this project aims to provide an alternative to NumPy and Matplotlib that is both slower and worse than the originals, but that will work on Android. The idea is to re-write the NumPy functions in pure Python, and to employ PyGame's graphical amazingness to replace Matplotlib's drawing functions.

AIMS

The (initial) aim is simple: to provide an alternative to all functions used in CancellationTools. But feel free to help out if you see a potential implementation of these modules for other projects as well.

Currently, this means that arrays are usually assumed to be a vector; matrices (vectors of vectors of vectors etc.) are not supported in all functions yet.

USAGE

# try importing android
try:
	import android
except ImportError:
	android = None

# if android could not be imported, we are not on
# android, so we do not have to bother with importing
# android-friendly numpy
if android == None:
	import numpy
else:
	import androidfriendly.numpy as numpy

You can create arrays as you would do using NumPy:

>>> a = numpy.array([1,2,3])
>>> b = numpy.array([3,2,1])

Calculations are the same:

>>> a + b
[4, 4, 4]

>>> a - b
[-2, 0, 2]

>>> a * b
[3, 4, 3]

>>> a / b
[0.3333333333333333, 1.0, 3.0]

>>> a ** b
[1, 4, 3]

And so are comparisons:

>>> a < b
[True, False, False]
>>> a <= b
[True, True, False]
>>> a == b
[False, True, False]
>>> a != b
[True, False, True]
>>> a > b
[False, False, True]
>>> a >= b
[False, True, True]

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.