Peter Brady | 23 Sep 00:17 2014
Picon

Interest in a banded matrix solver?

Most of the matrices I deal with have a banded structure coming from a finite-difference representation. I noticed that for such matrices, the DOK implementation is far from optimal so I implemented a matrix diagonal storage form (http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solve_banded.html) where 
ab[u + i - j, j] == a[i,j].I also implemented a banded solver that is significantly faster for such matrices. Here's a brief sample

np = 100
sol
= randMatrix(np, 1)
upper
, lower = 1, 3


def fd_mat(i, j, upper=upper, lower=lower, np=np):
   
for shift in range(-upper, lower+1):
       
if i==j+shift:
           
return randint(shift, high=2*np//(abs(shift)+1))
s
= SparseMatrix(np, np, fd_mat)


In [408]:
%timeit s.LUsolve(sol)
1 loops, best of 3: 15.7 s per loop

In [411]:
%%timeitoff, m = to_dia(s)l_and_u = (abs(min(off)), max(off))lu = diag_lu(l_and_u, m)banded_solve(l_and_u, lu, sol)
1 loops, best of 3: 385 ms per loop
In [412]:
(s.LUsolve(sol) - banded_solve(l_and_u, lu, sol)).is_zero
Out[412]:
True
Where to_dia, diag_lu and banded_solve are my custom routines. Is there any interest in turning this into a PR or am I the only one who has banded matrices?

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/db70744c-7bcb-4bfb-a43d-d99aee3b779c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
James Crist | 19 Sep 05:32 2014
Picon

Help with aliasing assumptions

I have a new SymPy type that serves to represent a unit of computation (contains an expression/expressions that is/are being computed). I'd like to be able to alias queries on the assumptions of the element to assumptions of the underlying expression it represents. Example:

>>> a, b, c = symbols('a, b, c', integer=True)
>>> expr = a + b + c

# Create the tree element
>>> r = Routine((a, b, c), (expr))

# r now represents a computational routine.
# We can use this as a function in other expressions.
>>> new_expr = 1 + 2 + r(a, b, c)
>>> new_expr
1 + 2 + r(a, b, c)

# The following should work
>>> new_expr.is_integer
True
>>> r(1, 2, 3).is_integer
True

For `Routine` objects with multiple returns, the results are indexed to select the output element:

>>> exprs = (a + b + c, a*b*c + 4.1)
>>> r = Routine((a, b, c), exprs)

# Use it in a new expression
>>> (1 + r(1, 2, 3)[0]).is_integer
True
>>> (1 + r(1, 2, 3)[1]).is_integer
False

Any idea how to go about doing this? I have little to no understanding of the assumption system, so before I start digging through the code I thought I'd ask if anyone had thoughts on how to tackle this. The `Routine` type, the `AppliedRoutine` type, and the results/arguments are all done. I just need to figure out (if possible) how I can make this play well with the assumption system.

-Jim

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/9bfa51e7-6f05-4d85-83cb-873e78bdc473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason Moore | 18 Sep 20:29 2014
Picon

Fwd: Python Weekly - Issue 157

Jim's slides on SymPy code gen got into the Python weekly.

Jason
moorepants.info
+01 530-601-9791

---------- Forwarded message ----------
From: Python Weekly <rahul-vJF35K26JnlGc1Grb+2+7A@public.gmane.org>
Date: Thu, Sep 18, 2014 at 11:06 AM
Subject: Python Weekly - Issue 157
To: moorepants-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org


Email not displaying correctly? View it in your browser.
Welcome to issue 157 of Python Weekly. Another packed issue this week. Enjoy it!

Articles, Tutorials and Talks

Python bad practice, a concrete case
A lot of people read up on good Python practice, and there's plenty of information about that on the Internet. This post shows a concrete case of code that the author doesn't consider being the state of the art.

Kernel tricks and nonlinear dimensionality reduction via RBF kernel PCA
The focus of this article is to briefly introduce the idea of kernel methods and to implement a Gaussian radius basis function (RBF) kernel that is used to perform nonlinear dimensionality reduction via KBF kernel principal component analysis (kPCA).

Bad Ideas in Python: The Worst Thing I've Ever Done 
In this talk, James Powell shows us his experiences with the worst and "most evil" things he's encountered when coding in Python and gives demos on how to get around those errors to turn them into good ideas.

Network Communications Clustering with Python and MongoDB
In this post we'll be clustering the behavior of users on a corporate network in order to identify malicious activity. The data will be stored in MongoDB which we'll access via the Monary and PyMongo packages. We'll be transforming data with NumPy and using scikit-learn for pre-processing and clustering.

Building a text editor with PyQt: Part 3
In the third part of this series, we'll be adding some slick extensions to our text editor for Finding and replacing text, Inserting an image and Word and symbol count

Cracking Online Banking CAPTCHA Login Using Python
This post discusses a real world example on how to crack a login page for one of the biggest leading banks in the Middle East!

Postgresql HStore, JSON data-type and Arrays with Peewee ORM
This post showcases the peewee support for HStore, JSON document store, and arrays.

Generating Fast and Correct Code with SymPy
All about the why and how of code generation in SymPy. Discusses the current state of converting symbolic math into fast numeric code, and gives a brief overview of current and future improvements.

Pickling Python collections with non-built-in type keys and cycles
A presentation of various problems and an effective solution for pickling Python collections with non-built-in types as keys and cycles or self references. Applies to dictionaries, default dictionaries, ordered dictionaries, sets, and ordered sets, at all levels of the pickle and cPickle protocol, in Python 2 and 3. 

Teaching an old dog new tricks -- or, how I learned to love Python's str.format, and gave up on %

DjangoCon 2014 Videos

Using Python Templates with Jinja and Google App Engine

Voice Recognition with Pocketsphinx in Python

PyGotham 2014 Videos

Python + functional programming

Introducing Blaze - Migrations

Kiwi PyCon 2014 Videos

Hit the Ground Running with MongoDB and Python

How-To: Python Compare Two Images


Books

High Performance Python: Practical Performant Programming for Humans
Your Python code may run correctly, but you need it to run faster. By exploring the fundamental theory behind design choices, this practical guide helps you gain a deeper understanding of Python's implementation. You'll learn how to locate performance bottlenecks and significantly speed up your code in high-data-volume programs.


Interesting Projects, Tools and Libraries

pep8radius
Fixing the entire project of PEP8 infractions ("PEP8 storms") can lead to merge conflicts, add noise to merges / pull requests and break (git) blame. pep8radius solves this problem by fixing only those PEP8 infractions incontained on the lines of the project which you've been working, leaving these sections "better than you found it" whilst keeping your commits focused on the areas of the codebase you were actually working on.

Chronyk
A Python 3 library for parsing human-written times and dates.

ObjectPath
ObjectPath is a query language similar to XPath or JSONPath, but much more powerful thanks to embedded arithmetic calculations, comparison mechanisms and built-in functions. This makes the language more like SQL in terms of expressiveness, but it works over JSON documents rather than relations

Qtile
A full-featured, hackable tiling window manager written and configured in Python.

python bond
The Python module bond supports transparent remote/recursive evaluation between Python and another interpreter through automatic call serialization. It lets you call functions in other languages as they were normal Python functions. It also allows other languages to call Python functions as if they were native.

Krakatau
Java decompiler, assembler, and disassembler writte in Python.

xmldataset
xmldataset is designed to make the process of gathering your desired data into a Python structure as simple as possible through its plaintext collection schema, deliminated just like Python!

ADR4Movie
Generate an animated visualization of the asteroids in SDSS using matplotlib.

syncthing-gui
GTK3 & python based GUI and notification area icon for Syncthing.


Upcoming Events and Webinars

Django Messaging: Build Distributed, Run Concurrent - Cambridge, MA
Understand the growing role of messaging in today's state of the art web applications, cloud computing infrastructures, and the Internet of Things (IoT). This talk will take you on a tour of the various messaging libraries and protocols that can be used with Django. Learn what ZeroMQ is, how to leverage AMQP via RabbitMQ, or how to start solving your concurrent problems quickly with Celery.

Forum Contest: Create a rock-paper-scissors game in Python
Create a game using Python that let's players play a game of rock-paper-scissors. The exact elements are up to you (rock-paper-scissors-lizard-spock anyone?) as are the play mechanics, but it should be runnable in the terminal using Python 3. Entries will be judged based on code and design.

Intro to Python Workshop - San Diego, CA
This is the next Intro to Python workshop cohosted by San Diego PyLadies, San Diego Python, Inland Empire Pyladies, and Inland Empire Python Users Group.

Silicon Valley Python Meetup September 2014 - Mountain View, CA
This talk will show how to use IPython and Plotly to make interactive 2D, 3D, and streaming plots. We'll also demo how to convert matplotlib, prettyplotlib, seaborn, and ggplot plots into web-based, shareable plots drawn with D3.js (a JavaScript visualization library).   

Share Python Weekly 
 
You are receiving our weekly newsletter because you signed up at http://www.PythonWeekly.com.

Unsubscribe moorepants-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org from this list | Forward to a friend | Update your profile
Our mailing address is:
Python Weekly
Brooklyn
Brooklyn, NY 11209

Add us to your address book

Copyright (C) 2014 Python Weekly All rights reserved.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAP7f1AjK72cVppMb1yHK9BckFg7fWkinTFnue4tpH3v7mu99Mw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Chris Smith | 18 Sep 19:02 2014
Picon

note regarding travis testing

If you have a PR then TWO tests are initiated for each push: one in your personal travis account and one in the sympy account. If you kill one it does not (apparently) kill the other. So if you want to keep things from bogging down, kill runs in both places.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/cbba8287-ae43-4cc1-a35f-7f0c69879d75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Chris Smith | 18 Sep 05:20 2014
Picon

value of (-1)**(2*n)

If n is an unbounded integer (is there such a thing?) then which rule applies to the expression (-1)**(2*n): (-1)**oo = nan or (-1)**even = 1?

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/f7b6c523-06c3-4afa-acfb-19adb3a011b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Chris Smith | 16 Sep 21:59 2014
Picon

[RFC] finite and bounded

Does anyone have a good reference for the definition of finite 0 < abs(x) < oo and bounded (abs(x) < oo) that they could add to https://github.com/sympy/sympy/pull/8043 ?

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/e141bfcd-06eb-46cc-8e1a-7bddeb8cf641%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
arne-ws | 15 Sep 11:31 2014
Picon

Use subs to replace subexpression with symbol

I'm trying to replace a nested function with a symbol by applying subs.

However, this doesn't seem to work for every case:
For Equation (2) my code below prints what I expect:

D_star =

C_vss
D_th
──────────
  C_vth  

But for Equation (3) subs doesn't seem to work and f_v is printed rather longish as:

f_v =

     
                                      3/2              
     
                   _________    ⎞⎞                  
     
                   φ          ⎟⎟                  
     
        C_tD_th⋅⎜    ─── + 1  - 1⎟⎟               3/2
     
                ⎝╲╱   φ_t         ⎠⎟          ___  
     
    -k₁⋅⎜────────────────────────────⎟   ⋅⎝1 + ╲╱ 2  
     
                 C_vth⋅φ                            
f_max
⋅⎝1 -                                                    


Any idea why subs is not working for Equation (3)?
Thanks!
Arne


Code example:
import sympy as sp
s = sp.Symbol 
print 'sympy version ' + sp.__version__ + '\n'

def s_print(func_str, repl_str=None):
    '''Print function and replace subexpression'''
    print func_str + ' = \n'
    if repl_str != None:
        sp.pprint(eval(func_str).subs(eval(repl_str), s(repl_str)))
    else:
        sp.pprint(eval(func_str))
    print '\n'

# (1) C_vss
phi, phi_t, C_t = sp.symbols('phi phi_t C_t')
C_vss = (sp.sqrt(2) + 1)*C_t*(sp.sqrt(1 + phi/phi_t) - 1)
s_print('C_vss')

# (2) D_star
C_vth, D_th = sp.symbols('C_vth D_th')
D_star = C_vss/C_vth * D_th
s_print('D_star', 'C_vss')


# (3) f_v
f_max, k_1, Phi = sp.symbols('f_max k_1, Phi')
f_v = f_max * (1 - sp.exp(-k_1 * (D_star/phi)**(sp.Rational(3,2))))
s_print('f_v', 'D_star')


--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/33915cea-3d7e-454e-aaa1-6a86aa58ca3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Martin Chan | 12 Sep 09:21 2014
Picon

can sympy do this

since out of memory, 

i hope sympy can do this, but i can not find this function

http://www.mapleprimes.com/questions/202338-Error-in-Combinatpermute-Maple

how to do the same as in above link,  my post

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/308ec4b0-89c5-47ad-949b-659b737ba71a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Rathmann | 12 Sep 05:07 2014
Picon

Simple operations on equations

I have been playing with SymPy and IPython Notebook and thought it
would be useful to be able to explicitly perform some of the
operations that are in the toolset taught in a high-school algebra
class.

This would be things like 
  • Adding the same thing to both sides of an equation.
  • Creating a new equation by adding two other equations together.
  • Substituting one equation into another.

I realize that all of these are easy to synthesize from the existing
operations in SymPy, but didn't see them in any sort of a pre-packaged
form.

Are they there but I have just missed them?

If not, would they be a worthwhile addition to SymPy?

In case there is any ambiguity, I am speaking explicitly of the
Equality/Eq relations.  I know that SymPy and many other packages tend
to just use expressions with an implicit ==0 condition, but, in an
elementary context, explicit equations seem more familiar/easier to
understand.

The main use case would be when using a notebook to show the explicit
steps of a derivation.  (And especially at the level of high-school
algebra or science.)  In one of my physics notebooks I noticed myself
writing a lot of things like

    eq3_4 = eq3_3.subs(eq2_1.rhs, eq2_1.lhs)

and thinking that having a well-documented set of idioms could add clarity.


--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/907746d6-e013-4b6a-a073-063a9a917a92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Simon Hirscher | 10 Sep 16:52 2014
Picon

Expanding abstract symbols in terms of their values

Hi,

I'm working on an extension for sympy.diffgeom. Since expressions
often get very complicated in differential geometry, it sometimes
makes sense to e.g. simply keep a tensor as the indexed symbol it
is, sometimes one inserts its actual components' values (and
tries to simplify further). Put differently, my mathematical
objects (mostly tensors) carry names but also have values and I'd
like to let the user decide when he wants use what and enable him
to replace names by their values later on (without the need for
him to use replace()/subs() because this requires way too much
manual effort).

Basically, this is the analogy of the famous pitfall:

>>> x, y = symbols('x, y')
>>> y = x + 2
>>> x = 2
>>> y
x + 2

whereas I would actually like to provide a way to do exactly
this: Replace the symbol 'x' by its value later on.

(Obviously, this would allow lazy calculation of tensor
components. Hence, the user could build expressions involving
tensors without needing to calculate all of their components
first – after all, he might only need some of them.)

So: Are there any best practices in this regard or is there even
a general function in SymPy to expand/evaluate such abstract
symbols in terms of their (still abstract/non-numerical) values?

I imagine something like this:

>>> R[0, 1, 0, 1]
R_{0101}
>>> R[0, 1, 0, 1].expand() (or .eval()/.doit()/.compute() or something)
<some complicated expression in terms of coordinate functions>

Thank you for your time!

--

-- 
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@...
To post to this group, send email to sympy@...
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/878ulr1q9u.fsf%40simonhirscher.de.
For more options, visit https://groups.google.com/d/optout.

will.wilson | 10 Sep 03:54 2014

More sugar for Buchberger's algorithm?

Hi All,

I've been using the polynomials module in SymPy, and it's great stuff. I noticed that your implementation of Buchberger's algorithm uses the normal selection strategy for choosing which pair to look at next. I was wondering if there would be any interest in a pull request that implements the "sugar" strategy outlined in Giovini & Mora (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.7.1065)? I think it's supposed to be a little better when computing with lex orderings.

Also, does the SymPy community have a benchmark for efficiency of the groebner() implementations? If not, and if there's interest in one, I'd be happy to help with that too.

Thanks!
Will

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/b37d3295-1f0a-42bc-adc1-bc9e66034c52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gmane