• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fatiando / fatiando / 2088
70%

Build:
DEFAULT BRANCH: master
Ran 08 May 2017 04:05PM UTC
Jobs 1
Files 54
Run time 6s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
2088

push

travis-ci

web-flow
Replace polyprism Cython code with pure numpy (#368)

Replacing the Cython `gravmag.polyprism` forward modeling code 
with simpler pure Python + numpy versions (following #364). 
Using some optimizations and simplifications, the resulting code is just as fast or 
even faster than the Cython version.
The main optimization is combining logarithms, e.g. 
`log(a/b) - log(c/d)`  with `log((a*d)/(b*c))`.

Using the following IPython script to benchmark against `master`:

    from __future__ import division, print_function
    import sys
    import numpy as np
    from fatiando import gridder, utils
    from fatiando.mesher import PolygonalPrism
    # Get processor information
    tmp = !cat /proc/cpuinfo | grep "model name"
    processor = tmp[0].split(':')[1].strip()
    print(processor)
    # Make a model for testing
    vertices = np.transpose(gridder.circular_scatter([-300, 300, -300, 300], 50))
    props = {'density': 1000, 'magnetization': utils.ang2vec(2, 25, -10)}
    model = [PolygonalPrism(vertices, 0, 200, props),
             PolygonalPrism(vertices, 200, 300, props)]
    inc, dec = -30, 50
    x, y, z = gridder.regular((-500, 500, -500, 500), (70, 70), z=-1)
    print('Model size: {}'.format(len(vertices)))
    print('Grid size: {}'.format(x.size))
    # Time the forward modeling of gravity, gradients and mag
    from fatiando.gravmag import polyprism
    print('Times:')
    if len(sys.argv) == 1:
        fields = 'gz gxx gxy gxz gyy gyz gzz tf bz bx by'.split()
    else:
        fields = sys.argv[1:]
    for field in fields:
        print('  {}: '.format(field), end='')
        if field == 'tf':
            args = (x, y, z, model, inc, dec)
        else:
            args = (x, y, z, model)
        %timeit getattr(polyprism, field)(*args)

These are the times for the `master` branch on my laptop:

    Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
    Model size: 50
    Grid size: 4900
    Times:
      ... (continued)

4180 of 5986 relevant lines covered (69.83%)

0.7 hits per line

Coverage Regressions

Lines Coverage ∆ File
29
100.0
/home/travis/miniconda2/envs/testenv/lib/python2.7/site-packages/fatiando/gravmag/polyprism.py
Jobs
ID Job ID Ran Files Coverage
3 2088.3 (PYTHON=2.7 COVERAGE=true BUILD_DOCS=false) 08 May 2017 04:05PM UTC 0
69.83
Travis Job 2088.3
Source Files on build 2088
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #2088
  • b1abf5e2 on github
  • Prev Build on master (#2069)
  • Next Build on master (#2093)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc