code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
# $Id: _SkeletonPage.py,v 1.13 2002/10/01 17:52:02 tavis_rudd Exp $
"""A baseclass for the SkeletonPage template
Meta-Data
==========
Author: Tavis Rudd <tavis@damnsimple.com>,
Version: $Revision: 1.13 $
Start Date: 2001/04/05
Last Revision Date: $Date: 2002/10/01 17:52:02 $
"""
__author__ = "Tavis Rudd <tavis@damnsim... | Python |
"""A Skeleton HTML page template, that provides basic structure and utility methods.
"""
##################################################
## DEPENDENCIES
import sys
import os
import os.path
from os.path import getmtime, exists
import time
import types
import __builtin__
from Cheetah.Version import MinCompatibleVe... | Python |
# $Id: CacheRegion.py,v 1.3 2006/01/28 04:19:30 tavis_rudd Exp $
'''
Cache holder classes for Cheetah:
Cache regions are defined using the #cache Cheetah directive. Each
cache region can be viewed as a dictionary (keyed by cacheRegionID)
handling at least one cache item (the default one). It's possible to add
cacheIte... | Python |
# $Id: CheetahWrapper.py,v 1.26 2007/10/02 01:22:04 tavis_rudd Exp $
"""Cheetah command-line interface.
2002-09-03 MSO: Total rewrite.
2002-09-04 MSO: Bugfix, compile command was using wrong output ext.
2002-11-08 MSO: Another rewrite.
Meta-Data
========================================================================... | Python |
'''
Cheetah is an open source template engine and code generation tool.
It can be used standalone or combined with other tools and frameworks. Web
development is its principle use, but Cheetah is very flexible and is also being
used to generate C++ game code, Java, sql, form emails and even Python code.
Homepage
... | Python |
#!/usr/bin/env python
'''
Core module of Cheetah's Unit-testing framework
TODO
================================================================================
# combo tests
# negative test cases for expected exceptions
# black-box vs clear-box testing
# do some tests that run the Template for long enough to check tha... | Python |
"""
XML Test Runner for PyUnit
"""
# Written by Sebastian Rittau <srittau@jroger.in-berlin.de> and placed in
# the Public Domain. With contributions by Paolo Borelli.
__revision__ = "$Id: /private/python/stdlib/xmlrunner.py 16654 2007-11-12T12:46:35.368945Z srittau $"
import os.path
import re
import sys
import time... | Python |
#!/usr/bin/env python
# -*- encoding: utf8 -*-
from Cheetah.Template import Template
from Cheetah import CheetahWrapper
from Cheetah import DummyTransaction
import imp
import os
import sys
import tempfile
import unittest
class CommandLineTest(unittest.TestCase):
def createAndCompile(self, source):
sourcef... | Python |
#!/usr/bin/env python
import sys
import unittest
import Cheetah.Template
import Cheetah.Filters
majorVer, minorVer = sys.version_info[0], sys.version_info[1]
versionTuple = (majorVer, minorVer)
class BasicMarkdownFilterTest(unittest.TestCase):
'''
Test that our markdown filter works
'''
def test... | Python |
#!/usr/bin/env python
import unittest
from Cheetah import SettingsManager
class SettingsManagerTests(unittest.TestCase):
def test_mergeDictionaries(self):
left = {'foo' : 'bar', 'abc' : {'a' : 1, 'b' : 2, 'c' : (3,)}}
right = {'xyz' : (10, 9)}
expect = {'xyz': (10, 9), 'foo': 'bar', 'abc... | Python |
#!/usr/bin/env python
import unittest
from Cheetah import Parser
class ArgListTest(unittest.TestCase):
def setUp(self):
super(ArgListTest, self).setUp()
self.al = Parser.ArgList()
def test_merge1(self):
'''
Testing the ArgList case results from Template.Preprocessors.tes... | Python |
#!/usr/bin/env python
import unittest
from Cheetah import DirectiveAnalyzer
class AnalyzerTests(unittest.TestCase):
def test_set(self):
template = '''
#set $foo = "bar"
Hello ${foo}!
'''
calls = DirectiveAnalyzer.analyze(template)
self.assertEquals(1, calls.get('s... | Python |
#!/usr/bin/env python
import unittest
import Cheetah
import Cheetah.Parser
import Cheetah.Template
class Chep_2_Conditionalized_Import_Behavior(unittest.TestCase):
def test_ModuleLevelImport(self):
''' Verify module level (traditional) import behavior '''
pass
def test_InlineImport(self):
... | Python |
#!/usr/bin/env python
import Cheetah.NameMapper
import Cheetah.Template
import sys
import unittest
majorVer, minorVer = sys.version_info[0], sys.version_info[1]
versionTuple = (majorVer, minorVer)
def isPython23():
''' Python 2.3 is still supported by Cheetah, but doesn't support decorators '''
return maj... | Python |
#!/usr/bin/env python
'''
Tests for the 'cheetah' command.
Besides unittest usage, recognizes the following command-line options:
--list CheetahWrapper.py
List all scenarios that are tested. The argument is the path
of this script.
--nodelete
Don't delete scratch directory at end.
... | Python |
#
| Python |
#!/usr/bin/env python
import hotshot
import hotshot.stats
import os
import sys
import unittest
from test import pystone
import time
import Cheetah.NameMapper
import Cheetah.Template
# This can be turned on with the `--debug` flag when running the test
# and will cause the tests to all just dump out how long they t... | Python |
#!/usr/bin/env python
import sys
import types
import os
import os.path
import unittest
from Cheetah.NameMapper import NotFound, valueForKey, \
valueForName, valueFromSearchList, valueFromFrame, valueFromFrameOrSearchList
class DummyClass:
classVar1 = 123
def __init__(self):
self.instanceVar1 ... | Python |
#!/usr/bin/env python
import pdb
import sys
import types
import os
import os.path
import tempfile
import shutil
import unittest
from Cheetah.Template import Template
majorVer, minorVer = sys.version_info[0], sys.version_info[1]
versionTuple = (majorVer, minorVer)
class TemplateTest(unittest.TestCase):
pass
clas... | Python |
import Cheetah.Template
def render(template_file, **kwargs):
'''
Cheetah.Django.render() takes the template filename
(the filename should be a file in your Django
TEMPLATE_DIRS)
Any additional keyword arguments are passed into the
template are propogated into the templat... | Python |
# $Id: NameMapper.py,v 1.32 2007/12/10 19:20:09 tavis_rudd Exp $
"""This module supports Cheetah's optional NameMapper syntax.
Overview
================================================================================
NameMapper provides a simple syntax for accessing Python data structures,
functions, and methods fro... | Python |
'''
Provides the core API for Cheetah.
See the docstring in the Template class and the Users' Guide for more information
'''
################################################################################
## DEPENDENCIES
import sys # used in the error handling code
import re ... | Python |
from glob import glob
import os
from os import listdir
import os.path
import re
from tempfile import mktemp
def _escapeRegexChars(txt,
escapeRE=re.compile(r'([\$\^\*\+\.\?\{\}\[\]\(\)\|\\])')):
return escapeRE.sub(r'\\\1', txt)
def findFiles(*args, **kw):
"""Recursively find all the file... | Python |
# -*- coding: utf-8 -*-
###########################################################################
## Python code generated with wxFormBuilder (version Sep 8 2010)
## http://www.wxformbuilder.org/
##
## PLEASE DO "NOT" EDIT THIS FILE!
##########################################################################... | Python |
#! /usr/bin/env python
"""module to run timings test code
Modules to time-test can be specified in two ways
* bench modules can be automatically collected from directory where this
file is present if they are cython modules with sources having extension
`.pyx`. The modules are compiled if they are not already
... | Python |
""" some utility function for use in load_balance benchmark """
# MPI imports
from mpi4py import MPI
comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()
import sys
import os
from os.path import join, exists
import traceback
from optparse import OptionParser
# logging imports
import logging
# local ... | Python |
''' Module to run bench modules which need to be run in mpi
This module imports the given module to run, and returns the result
of the bench functions of the modules. Also results are written to
mpirunner.log file
Usage:
1. Print the result in formatted form:
$ mpiexec -n <num_procs> python mpirunner.py <bench_name>
... | Python |
""" Time comparison for the Cython and OpenCL integrators.
We use the NBody integration example as the benchmark. Here, and all
neighbor locator is used. The setup consists of four points at the
vertices of the unit square in 2D.
"""
import numpy
from time import time
import pysph.solver.api as solver
import pysp... | Python |
""" Benchmark for the PySPH neighbor search functions. """
import sys
import numpy
import time
#PySPH imports
import pysph.base.api as base
def get_points(np = 10000):
""" Get np particles in domain [1, -1] X [-1, 1] """
x = numpy.random.random(np)*2.0 - 1.0
y = numpy.random.random(np)*2.0 - 1.0
z =... | Python |
from setuptools import find_packages, setup
from Cython.Distutils import build_ext
from numpy.distutils.extension import Extension
ext_modules = [Extension("cython_nnps", ["cython_nnps.pyx"],
language="c++",
extra_compile_args=["-O3", "-Wall"]
... | Python |
"""This module compiles the specified (all) the cython .pyx files
in the specified (current) directory into python extensions
"""
import sys
import os
from setuptools import setup
from Cython.Distutils import build_ext
from numpy.distutils.extension import Extension
import numpy
def get_spcl_extn(extn):
""" spe... | Python |
import pysph.base.api as base
import pysph.solver.api as solver
import pysph.sph.api as sph
import numpy
import time
import pyopencl as cl
CLDomain = base.DomainManagerType
CLLocator = base.OpenCLNeighborLocatorType
# number of particles
np = 1 << 20
# number of times a single calc is evaluated
neval = 5
x = numpy... | Python |
""" Benchmark example for binning particles in Cython and OpenCL """
import numpy
import numpy.random as random
from time import time
import pysph.base.api as base
import pysph.solver.api as solver
CLDomain = base.DomainManagerType
CLLocator = base.OpenCLNeighborLocatorType
# number of points
np = 2**20
# number o... | Python |
import pysph.base.api as base
import pysph.solver.api as solver
import pysph.sph.api as sph
import numpy
import time
import pyopencl as cl
CLDomain = base.DomainManagerType
CLLocator = base.OpenCLNeighborLocatorType
Locator = base.NeighborLocatorType
# number of particles
np = 16384
# number of times a single calc ... | Python |
"""Extract reference documentation from the NumPy source tree.
"""
import inspect
import textwrap
import re
import pydoc
from StringIO import StringIO
from warnings import warn
class Reader(object):
"""A line-based string reader.
"""
def __init__(self, data):
"""
Parameters
-----... | Python |
from cStringIO import StringIO
import compiler
import inspect
import textwrap
import tokenize
from compiler_unparse import unparse
class Comment(object):
""" A comment block.
"""
is_comment = True
def __init__(self, start_lineno, end_lineno, text):
# int : The first line number in the block. ... | Python |
""" Turn compiler.ast structures back into executable python code.
The unparse method takes a compiler.ast tree and transforms it back into
valid python code. It is incomplete and currently only works for
import statements, function calls, function definitions, assignments, and
basic expressions.
... | Python |
import inspect
import os
import pydoc
import docscrape
from docscrape_sphinx import SphinxClassDoc, SphinxFunctionDoc
import numpydoc
import comment_eater
class SphinxTraitsDoc(SphinxClassDoc):
def __init__(self, cls, modulename='', func_doc=SphinxFunctionDoc):
if not inspect.isclass(cls):
rai... | Python |
import re, textwrap
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
class SphinxDocString(NumpyDocString):
# string conversion routines
def _str_header(self, name, symbol='`'):
return ['.. rubric:: ' + name, '']
def _str_field_list(self, name):
return [':' + name + ':']
de... | Python |
import os, re, pydoc
from docscrape_sphinx import SphinxDocString, SphinxClassDoc, SphinxFunctionDoc
import inspect
def mangle_docstrings(app, what, name, obj, options, lines,
reference_offset=[0]):
if what == 'module':
# Strip top title
title_re = re.compile(r'^\s*[#*=]{4,}\n... | Python |
def exact_solution(tf=0.00076, dt=1e-4):
""" Exact solution for the the elliptical drop equations """
import numpy
A0 = 100
a0 = 1.0
t = 0.0
theta = numpy.linspace(0,2*numpy.pi, 101)
Anew = A0
anew = a0
while t <= tf:
t += dt
Aold = Anew
aold = anew
... | Python |
""" An example solving stress test case """
import sys
import numpy
from numpy import pi, sin, sinh, cos, cosh
import pysph.base.api as base
import pysph.sph.api as sph
import pysph.solver.api as solver
from pysph.solver.stress_solver import StressSolver, get_particle_array
from pysph.sph.funcs import stress_funcs
fr... | Python |
""" An example solving stress test case """
import sys
import numpy
from numpy import pi, sin, sinh, cos, cosh
import pysph.base.api as base
import pysph.sph.api as sph
import pysph.solver.api as solver
from pysph.solver.stress_solver import StressSolver
from pysph.sph.funcs import stress_funcs
from pysph.sph.api imp... | Python |
""" Balls colliding in 2D """
import numpy
import pysph.base.api as base
import pysph.sph.api as sph
import pysph.solver.api as solver
import pysph.sph.funcs.stress_funcs as stress_funcs
app = solver.Application()
Solid = base.ParticleType.Solid
E = 1e7
nu = 0.3975
G = E/(2.0*(1+nu))
K = sph.get_K(G, nu)
ro = 1.0... | Python |
""" An example solving stress test case """
import numpy
import sys
import pysph.base.api as base
import pysph.solver.api as solver
from pysph.solver.stress_solver import StressSolver, get_particle_array
from pysph.sph.funcs import stress_funcs, arithmetic_funcs
from pysph.sph.api import SPHFunction
app = solver.App... | Python |
""" An example solving stress test case : colliding rubber balls """
import sys
import numpy
from numpy import pi, sin, sinh, cos, cosh
import pysph.base.api as base
import pysph.sph.api as sph
import pysph.solver.api as solver
from pysph.solver.stress_solver import StressSolver
from pysph.sph.funcs import stress_fun... | Python |
""" An example solving stress test case """
import numpy
import sys
import os
import pysph.base.api as base
import pysph.solver.api as solver
from pysph.solver.stress_solver import StressSolver, get_particle_array
from pysph.sph.funcs import stress_funcs, arithmetic_funcs
from pysph.sph.api import SPHFunction
app = ... | Python |
""" Example file showing the use of solver controller and various interfaces
Usage:
Run this file after running the `controller_elliptical_drop.py` example file
A matplotlib plot window will open showing the current position of all
the particles and colored according to their velocities. The plot is update... | Python |
""" An example solving the Elliptical drop test case with various interfaces """
import pysph.base.api as base
import pysph.solver.api as solver
app = solver.Application()
app.process_command_line(['-q', '--interactive',
'--xml-rpc=0.0.0.0:8900', '--multiproc=pysph@0.0.0.0:8800'])
s = solver.Flu... | Python |
""" Simple motion. """
import numpy
import pysph.base.api as base
import pysph.solver.api as solver
import pysph.sph.api as sph
from random import randint
from numpy import random
nx = 1 << 5
dx = 0.5/nx
def create_particles_3d(**kwargs):
x, y, z = numpy.mgrid[0.25:0.75+1e-10:dx,
0.25... | Python |
""" A script to demonstrate the simplest of calculations in parallel
Setup:
------
Two particle arrays are created on two separate processors with the
following procerties:
processor 0:
x ~ [0,1], dx = 0.1, h = 0.2, m = 0.1, fval = x*x
processor 1:
x ~ [1.1, 2], dx = 0.1, h = 0.2, m = 0.1, fval = x*x
"""
#... | Python |
""" The moving square test case is part of the SPHERIC benchmark
tests. Refer to the document for the test details.
Numerical Parameters:
---------------------
dx = dy = 0.005
h = 0.0065 => h/dx = 1.3
Length of Box = 10
Height of Box = 5
Number of particles = 27639 + 1669 = 29308
ro = 1000.0
Vmax = 1.0
co = 15 (1... | Python |
""" 2D Dam Break Over a dry bed. The case is described in "State of
the art classical SPH for free surface flows", Benedict D Rogers,
Robert A, Dalrymple and Alex J.C Crespo, Journal of Hydraulic
Research, Vol 48, Extra Issue (2010), pp 6-27
Setup:
------
x x !
x x !
x ... | Python |
""" 2D Dam Break Over a dry bed. The case is described in "State of
the art classical SPH for free surface flows", Benedict D Rogers,
Robert A, Dalrymple and Alex J.C Crespo, Journal of Hydraulic
Research, Vol 48, Extra Issue (2010), pp 6-27
Setup:
------
x x !
x x !
x ... | Python |
""" A tiny dam break problem
Setup:
------
x x !
x x !
x x !
x x !
x o o o o o x !
x o o o o o x !3m
x o o o o o x !
x o o o o o x !
x o o o o o x !
x x !
xxxxxxxxxxxxxxxxxxxxx | ... | Python |
""" 2D Dam Break Over a dry bed. The case is described in "State of
the art classical SPH for free surface flows", Benedict D Rogers,
Robert A, Dalrymple and Alex J.C Crespo, Journal of Hydraulic
Research, Vol 48, Extra Issue (2010), pp 6-27
Setup:
------
x x !
x x !
x ... | Python |
""" Dam break simulation over a wet bed.
This is part of the SPHERIC validation test cases (case 5)
(http://wiki.manchester.ac.uk/spheric/index.php/SPHERIC_Home_Page)
The main reference for this test case is 'State-of-the-art classical SPH for free-surface flows' by Moncho Gomez-Gesteira and Benedict D. Rogers and Ro... | Python |
""" An example Script to study the behavior of Monaghan type repulsive
particles (Smoothed Particle Hydrodynamics, Reports on Progresses in
Physics)
The boundary particles are an improvement over the Lenard Jones type
repulsive boundary particles. One of the main features is that a
particle moving parallel to the wall... | Python |
""" A simple example in which two drops collide """
import pysph.solver.api as solver
import pysph.base.api as base
import pysph.sph.api as sph
import numpy
def get_circular_patch(name="", type=0, dx=0.05):
x,y = numpy.mgrid[-1.05:1.05+1e-4:dx, -1.05:1.05+1e-4:dx]
x = x.ravel()
y = y.ravel()
m... | Python |
""" NBody Example """
import pysph.base.api as base
import pysph.solver.api as solver
import pysph.sph.api as sph
import numpy
Fluid = base.ParticleType.Fluid
# number of particles, time step and final time
np = 1024
dt = 1e-2
tf = 10.0
nsteps = tf/dt
def get_particles(**kwargs):
x = numpy.random.random(... | Python |
""" Shock tube problem with the ADKE procedure of Sigalotti """
import pysph.solver.api as solver
import pysph.base.api as base
import pysph.sph.api as sph
from pysph.base.kernels import CubicSplineKernel
import numpy
Fluid = base.ParticleType.Fluid
Boundary = base.ParticleType.Boundary
# Shock tube parameters
nl ... | Python |
""" Sjogreen's test case """
import numpy
import pysph.base.api as base
import pysph.solver.api as solver
import get_shock_tube_data as get_data
CLDomain = base.DomainManagerType
CLLocator = base.OpenCLNeighborLocatorType
Locator = base.NeighborLocatorType
# shock tube parameters
xl = -1.0; xr = 1.0
pl = 0.4; pr =... | Python |
""" Standard shock tube problem by Monaghan """
import numpy
import pysph.base.api as base
import pysph.solver.api as solver
import get_shock_tube_data as data
CLDomain = base.DomainManagerType
CLLocator = base.OpenCLNeighborLocatorType
Locator = base.NeighborLocatorType
kernel = base.CubicSplineKernel
hks=False
... | Python |
"""Woodward and COllela interacting blast wave."""
import numpy
import pysph.sph.api as sph
import pysph.base.api as base
import pysph.solver.api as solver
xl = 0
xr = 1.0
np = 5001
nbp = 100
dx = (xr-xl)/(np-1)
D = 1.5
h0 = D*dx
adke_eps = 0.5
adke_k = 1.0
g1 = 0.2
g2 = 0.4
alpha = 1.0
beta = 1.0
gamma = 1.4
t... | Python |
"""1D shock tube problem which simulates the collision of two strong
shocks. The test is described in 'An adaptive SPH method for strong
shocks' by Leonardo Di. G. Sigalotti and Henri Lopez and Leonardo
Trujillo, JCP, vol 228, pp (5888-5907)
"""
import pysph.solver.api as solver
import pysph.base.api as base
import p... | Python |
""" Robert's problem """
import numpy
import pysph.base.api as base
import pysph.solver.api as solver
import get_shock_tube_data as get_data
CLDomain = base.DomainManagerType
CLLocator = base.OpenCLNeighborLocatorType
Locator = base.NeighborLocatorType
# Roberts problem parameters
vc = 0.42
xl = -4.8; xr = 8.0
pl... | Python |
""" Functions to get the initial data for the shock tube problems """
import numpy
import pysph.base.api as base
def get_shock_tube_data(nl, nr, xl, xr,
pl, pr, rhol, rhor, ul, ur,
g1, g2, h0, gamma=1.4,
m0=None):
dxl = numpy.abs(xl)/nl
... | Python |
""" An example script for running the shock tube problem using Standard
SPH.
Global properties for the shock tube problem:
---------------------------------------------
x ~ [-.6,.6], dxl = 0.001875, dxr = dxl*4, m = dxl, h = 2*dxr
rhol = 1.0, rhor = 0.25, el = 2.5, er = 1.795, pl = 1.0, pr = 0.1795
These are obtaine... | Python |
""" Standard shock tube problem by Monaghan """
import numpy
import pysph.base.api as base
import pysph.solver.api as solver
import get_shock_tube_data as data
CLDomain = base.DomainManagerType
CLLocator = base.OpenCLNeighborLocatorType
Locator = base.NeighborLocatorType
kernel = base.CubicSplineKernel
hks=False
... | Python |
""" Cylindrical Noh's implosion problem using the ADKE algorithm.
Particles are distributed on concentric circles about the origin with
increasing number of particles with increasing radius. The velocity is
initially uniform and directed towards the origin.
"""
import numpy
import pysph.sph.api as sp
import pysph.ba... | Python |
"""Sedov point explosion problem using the ADKE algorithm.
Particles are distributed on concentric circles about the origin with
increasing number of particles with increasing radius. A unit charge
is distributed about the center which gives the initial pressure
disturbance.
"""
import numpy
import pysph.sph.api as... | Python |
""" Shock tube problem with the ADKE procedure of Sigalotti """
import pysph.solver.api as solver
import pysph.base.api as base
import pysph.sph.api as sph
from pysph.base.kernels import CubicSplineKernel
import numpy
Fluid = base.ParticleType.Fluid
Boundary = base.ParticleType.Boundary
# Shock tube parameters
nl ... | Python |
""" Strong blaswave problem proposed by Sigalotti. Mach number = 771 """
import numpy
import pysph.base.api as base
import pysph.solver.api as solver
import get_shock_tube_data as data
Locator = base.NeighborLocatorType
kernel = base.CubicSplineKernel
hks=False
# shock tube parameters
xl = -1.5; xr = 1.5
pl = 1e4... | Python |
""" An example solving the Ellptical drop test case """
import pysph.base.api as base
import pysph.solver.api as solver
import warnings
dt = 1e-4
tf = 0.0076
app = solver.Application()
# set the integrator type
integrator_type = solver.RK2Integrator
s = solver.FluidSolver(dim=2, integrator_type=integrator_type)
... | Python |
"""
PySPH
=====
A general purpose Smoothed Particle Hydrodynamics framework.
This package provides a general purpose framework for SPH simulations
in Python. The framework emphasizes flexibility and efficiency while
allowing most of the user code to be written in pure Python. See here:
http://pysph.googlecode.... | Python |
"""A particle viewer using Mayavi.
This code uses the :py:class:`MultiprocessingClient` solver interface to
communicate with a running solver and displays the particles using
Mayavi. It can also display a list of supplied files.
"""
import sys
import math
import numpy
import socket
import os
import os.path
from ent... | Python |
""" Helper functions to generate commonly used geometries.
PySPH used an axis convention as follows:
Y
|
|
|
|
|
| /Z
| /
| /
| /
| /
| /
|/_________________X
"""
import numpy
def create_2D_tank(x1,y1,x2,y2,dx):
""" Generate an open rectangular tank.
Parameters:
-----------
x1,y1... | Python |
''' convert pysph .npz output to vtk file format '''
import os
import re
from enthought.tvtk.api import tvtk, write_data
from numpy import array, c_, ravel, load, zeros_like
def write_vtk(data, filename, scalars=None, vectors={'V':('u','v','w')}, tensors={},
coords=('x','y','z'), dims=None, **kwargs):
... | Python |
""" Module to implement various space filling curves for load balancing """
import numpy
from pysph.base.point import IntPoint
try:
from hilbert import Hilbert_to_int
have_hilbert = True
except ImportError:
# TODO: implement Hilbert's SFC
have_hilbert = False
def morton_sfc(cell_id, maxlen=20, dim=3):... | Python |
from parallel_manager import ParallelManager
from parallel_controller import ParallelController
from pysph.base.particle_array import get_local_real_tag, get_dummy_tag
from pysph.base.fast_utils import arange_long
# logger imports
import logging
logger = logging.getLogger()
# Constants
Dummy = get_dummy_tag()
LocalR... | Python |
"""
Module to implement parallel decomposition of particles to assign to
different processes during parallel simulations. The method used is an
extension of k-means clustering algorithm
"""
# logging imports
import logging
logger = logging.getLogger()
# standard imports
import numpy
# local imports
from pysph.base.c... | Python |
"""
Contains class to perform load balancing using space filling curves.
"""
# logging imports
import logging
logger = logging.getLogger()
# standard imports
import numpy
# local imports
from pysph.base.particle_array import ParticleArray
from pysph.base.cell import py_construct_immediate_neighbor_list
from load_bal... | Python |
""" Contains class to perform load balancing.
"""
#FIXME: usage documentation
# logging imports
import logging
logger = logging.getLogger()
# standard imports
import numpy
# local imports
from pysph.base.particle_array import ParticleArray, get_particle_array
from pysph.base.cell import CellManager, py_construct_im... | Python |
""" Tests for the parallel cell manager """
import nose.plugins.skip as skip
raise skip.SkipTest("Dont run this test via nose")
from pysph.parallel.simple_block_manager import SimpleBlockManager
from pysph.base.particles import Particles
from pysph.base.particle_array import get_particle_array
from pysph.base.point i... | Python |
""" Tests for the parallel cell manager """
import nose.plugins.skip as skip
raise skip.SkipTest("Dont run this test via nose")
import pysph.base.api as base
import pysph.parallel.api as parallel
import numpy
import pylab
import time
# mpi imports
from mpi4py import MPI
comm = MPI.COMM_WORLD
num_procs = comm.Get_si... | Python |
""" Tests for the parallel cell manager """
import pysph.base.api as base
import pysph.parallel.api as parallel
import numpy
import time
import pdb
# mpi imports
from mpi4py import MPI
comm = MPI.COMM_WORLD
num_procs = comm.Get_size()
pid = comm.Get_rank()
import logging
logger = logging.getLogger()
logger.setLevel... | Python |
"""
Simple script to check if the load balancing works on 2-d data.
"""
try:
import mpi4py.MPI as mpi
except ImportError:
import nose.plugins.skip as skip
reason = "mpi4py not installed"
raise skip.SkipTest(reason)
# mpi imports
from mpi4py import MPI
comm = MPI.COMM_WORLD
num_procs = comm.Get_size()
... | Python |
"""
Simple script to check if copies of remote data are properly done.
"""
try:
import mpi4py.MPI as mpi
except ImportError:
import nose.plugins.skip as skip
reason = "mpi4py not installed"
raise skip.SkipTest(reason)
# mpi import
from mpi4py import MPI
comm = MPI.COMM_WORLD
num_procs = comm.Get_size()... | Python |
""" Test the share_data function for various cases
cases to run are chosen based on the size of the MPI.COMM_wORLD
case 1: for 5 processes
Processors arrangement:
4
0 1 2 3
Nbr lists:
0: 1,4
1: 0,2,4
2: 1,3,4
3: 2
4: 0,1,2
case 2: for 2 processes
both neighbors of each other
case 3,4,5: n processes (n>1 for case... | Python |
""" Tests for the parallel cell manager """
try:
import mpi4py.MPI as mpi
except ImportError:
import nose.plugins.skip as skip
reason = "mpi4py not installed"
raise skip.SkipTest(reason)
import pysph.base.api as base
import pysph.parallel.api as parallel
from time import time
import numpy
import pyl... | Python |
"""
Simple script to check if the load balancing works on 1-d data.
"""
try:
import mpi4py.MPI as mpi
except ImportError:
import nose.plugins.skip as skip
reason = "mpi4py not installed"
raise skip.SkipTest(reason)
# mpi imports
from mpi4py import MPI
comm = MPI.COMM_WORLD
num_procs = comm.Get_size()
... | Python |
""" Some checks for the parallel cell manager.
Run this script only with less than 5 processors.
example : mpiexec -n 2 python parallel_cell_check.py
"""
import time
try:
import mpi4py.MPI as mpi
except ImportError:
import nose.plugins.skip as skip
reason = "mpi4py not installed"
raise skip.SkipTest(... | Python |
""" Tests for the parallel cell manager """
try:
import mpi4py.MPI as mpi
except ImportError:
import nose.plugins.skip as skip
reason = "mpi4py not installed"
raise skip.SkipTest(reason)
import pysph.base.api as base
import pysph.parallel.api as parallel
from time import time
import numpy
import pyl... | Python |
#!/bin/env python
"""
Simple test for checking if the control tree is setup properly.
Run this script with the following command
mpiexec -n [num_procs] python controller_check.py
"""
try:
import mpi4py.MPI as mpi
except ImportError:
import nose.plugins.skip as skip
reason = "mpi4py not installed"
rai... | Python |
"""A parallel manager that uses blocks to partition the domain. At
every iteration, the particles are placed in large bins and these bins
are exchanged across processors.
"""
from parallel_controller import ParallelController
from parallel_manager import ParallelManager
from parallel_cell import share_data
from pys... | Python |
"""API module to simplify import of common names from pysph.parallel package"""
from parallel_cell import ParallelCellManager, ProcessorMap
| Python |
""" Contains class to perform load balancing using METIS[1]/SCOTCH[2]
[1] METIS: http://glaros.dtc.umn.edu/gkhome/views/metis
[2] SCOTCH: http://www.labri.fr/perso/pelegrin/scotch/
Note: Either of METIS/SCOTCH is acceptable. Installing one of these is enough.
First METIS is attempted to load and if it fails SCOTCH is... | Python |
import pysph.base.api as base
import pysph.solver.api as solver
import pysph.sph.api as sph
if solver.HAS_CL:
import pyopencl as cl
else:
try:
import nose.plugins.skip as skip
reason = "PyOpenCL not installed"
raise skip.SkipTest(reason)
except ImportError:
pass
import... | Python |
"""
Module containing some data required for tests of the sph module.
"""
# standard imports
import numpy
# local imports
from pysph.base.particle_array import *
def generate_sample_dataset_1():
"""
Generate test test data.
Look at image sph_test_data1.png
"""
x = numpy.array([-1.0, 0.0, 1.0, -1.0... | Python |
"""API module to simplify import of common names from pysph.sph package"""
#Import from calc
from sph_calc import SPHCalc, CLCalc
from sph_func import SPHFunction, SPHFunctionParticle, CSPHFunctionParticle
############################################################################
# IMPORT FUNCTIONS
################... | Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.