numpy dependency

46 views
Skip to first unread message

Angus

unread,
May 11, 2016, 4:47:15 AM5/11/16
to mathics-devel
Hi All,

@poke1024 has been working on, among other things, some image processing routines for Mathics using scikit-image (depends on numpy). Although it hasn't been merged yet, and development is still ongoing it seems likely that these changes will get merged.

Recently I also rejected #278 because it depended on numpy/scipy. This PR gave some massive speedups to the linear algebra routines using scipy. In its current state I stand by that decision, but with some cleanups I'd be open to merging something similar. 

I think now is a good opportunity to consider numpy as an optional dependency for Mathics.

For a while now I've resisted adding numpy as a dependency. My reasons were:
  • numpy doesn't support arbitrary precision arithmetic
  • Support for PyPy was poor
  • It's a large and complex library that adds significant time to a Mathics install
PyPy support seems to be better now but the other issues remain. On the other hand:
  • Many users are likely to already have numpy installed
  • Not everything needs arbitrary precision calculations (e.g. image processing, plotting, and some linear algebra routines).
  • When doing computations at native precision there is no reason not to use numpy.
  • Opportunity for massive speedups in some of the slowest parts of mathics (e.g. plotting).
  • Mathics arbitrary precision calculations can buggy and are probably not used very often anyway.

I'm proposing we add numpy as an optional dependency for the next release of Mathics but there are still a few open questions:
  • Should we consider adding numpy as a required (non-optional) dependency?
  • What, if any, of the scipy stack do we want to include?
  • What's the best way to manage a growing number of optional dependencies in Mathics?

Please let me know what you think,
Angus

Cosimo Rondo

unread,
May 11, 2016, 3:39:04 PM5/11/16
to mathics-devel
As I argued before, if we want to make mathics competitive regarding other mathematical software, it would be nice allow, at least as an optional dependency, the use of numpy and scipy. Numpy can help a lot for dense matrix arithmetic,  while scipy is the best library for sparse problems. I think that Numpy and Scipy are standard libraries for the target user of mathics, and hence it would not seem to be a big deal find them already installed.

Regarding the way of how to manage lo load these optional packages, if we are thinking just on load scipy and numpy, it would be enough to define internal versions of the matrix manipulation routines, and link the best available one to the high level interface on load time. Are you considering other libraries as optional dependencies?


Cheers,
M

Angus Griffith

unread,
May 12, 2016, 3:44:57 AM5/12/16
to mathic...@googlegroups.com

An internal implementation of various linear algebra routines is a reasonable approach. I've started looking at how we can use Travis to test with numpy. I think some additional tests will be important here to ensure the behavior is similar across various configurations.

I'd like to try speeding up vector evaluations, e.g. functions with `Listable`. Also, for generating lists of random numbers. Moreover, if we want to optimise plotting it would be nice to have an `evaluate_vectorised` method on Expressions which takes a list of (numpy) arrays. I'm thinking of e.g. Sin[x^2 + Cos [y]]. The problem is how to gracefully handle missing numpy.

At the moment I'm not thinking of adding any more optional dependencies (other than scikit-image for image processing). Are there some we should consider?

--
You received this message because you are subscribed to the Google Groups "mathics-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathics-deve...@googlegroups.com.
To post to this group, send email to mathic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathics-devel/bcaf9cfb-8721-49ec-94ba-a8a88750b4c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages