Git Product home page Git Product logo

numpy-clj's Introduction

numpy-clj

Build Status Binder

A Clojure core.matrix implementation using NumPy via libpython-clj. numpy-clj allows you to use an idiomatic Clojure library, while still interoperating with Numpy, SciPy and the entire Python ecosystem.

Try out numpy-clj in JupyterLab via Binder along with other core.matrix implementations. Click here or click the 'launch binder' badge above.

Usage

numpy-clj does not directly provide an API, but is instead used by core.matrix. numpy-clj extends core.matrix to translate to equivalent numpy functions. Include core.matrix in your project and use the core.matrix API.

If you're new to core.matrix check out matrix-compare to see how to translate common operations from MATLAB and NumPy into core.matrix.

Examples

To ensure the numpy-clj implementation is registered, make sure to require it in your namespace and set it as the current implementation.

(ns your.namespace
  (:require [numpy-clj.core]
            [core.matrix :as m]))

(m/set-current-implementation :numpy-clj)

(m/array [[0 1 2]] [3 4 5])
=> [[0 1 2] ;; this will be a numpy object
    [3 4 5]]

You can also directly interoperate using libpython-clj and use numpy functions directly. Read the official documentation to learn more on writing Python in Clojure.

(ns your.namespace
  (:require [numpy-clj.core]
            [core.matrix :as m]
            [libpython-clj.require :refer [require-python]]))

(require-python '[numpy :as np])

(np/linspace 0 10 100)
=> [ 0.          0.1010101 ...

Using numpy-clj in your project

You can include any commit of this project as a git dependency. Copy and paste the sha hash from any commit and add it to your deps.edn, like below.

{:deps
 {brianchevalier/numpy-clj
  {:git/url "https://github.com/brianchevalier/numpy-clj"
   :sha ""}}}

Development

Note: numpy-clj currently uses my fork of core.matrix (via GitHub) which adds a deps.edn file. When you run make test it will automatically checkout my fork of core.matrix with this change (branch: deps.edn). Make sure to use the :core-matrix alias to use my branch.

Useful resources:

Testing

To run the core.matrix compliance tests run the following make rule.

make test

Continuous Integration (CI)

To test changes against the exact CI environment:

  • Install Docker
  • Install act (eg. with homebrew: brew install act)
  • Run the following make rule. Warning: This will require an 18GB(!) download but will fully replicate the GitHub Actions environment
make ci/local

numpy-clj's People

Contributors

brianchevalier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.