Skip to content
Snippets Groups Projects
Commit c5506ee9 authored by Daniel Boeckenhoff's avatar Daniel Boeckenhoff
Browse files

removing logging dependencies + some small documentation

parent b9a36665
No related branches found
Tags v0.1.0.dev1
No related merge requests found
"""
Publishing:
remember to change the version in setup
tag the version with $ git tag ...
run tests
remember to change the version in setup(... ) below
$ git commit -am "<my message>"
$ git push
$ git tag -a v<my.version.id> -m "<comment to my version>"
$ python setup.py sdist
$ twine upload dist/*
"""
from setuptools import setup, find_packages
setup(
name='tfields',
version='1.1.0.dev1',
version='0.1.0.dev1',
description='numpy + sympy implementation of tensor fields with attached coordinate systems',
author='Daniel Boeckenhoff',
author_email='dboe@ipp.mpg.de',
......@@ -17,9 +23,9 @@ setup(
test_require=['doctest'],
url='https://gitlab.mpcdf.mpg.de/dboe/tfields',
# install_requires=['numpy', 'scipy'],
# entry_points={
# 'console_scripts': ['tfields = tfields.__main__']
# },
entry_points={
'console_scripts': ['tfields = tfields.__main__:runDoctests']
},
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
......
import os
import osTools
import doctest
import loggingTools
logger = loggingTools.Logger(__name__)
"""
Run doctests on module call
"""
def runDoctests():
import doctest
import pathlib
for f in list(pathlib.Path(__file__).parent.glob('**/*.py')):
doctest.testfile(f.name) # , verbose=True, optionflags=doctest.ELLIPSIS)
dirName, fileName = os.path.split(os.path.relpath(__file__))
print(dirName)
for f in osTools.getFilePaths(dirName, extension='.py'):
print(f)
doctest.testfile(os.path.relpath(f, dirName)) # , verbose=True, optionflags=doctest.ELLIPSIS)
if __name__ == '__main__':
runDoctests()
#!/usr/bin/env
# encoding: utf-8
"""
Author: Daniel Boeckenhoff
Mail: daniel.boeckenhoff@ipp.mpg.de
part of tfields library
Tools for sympy coordinate transformation
"""
import tfields
......@@ -7,23 +13,19 @@ import sympy
import sympy.diffgeom
from six import string_types
import warnings
# import dill
# dill.settings['recurse'] = True
# dill.dump(f, open("coordTrafos.dill", "w"))
CARTESIAN = 'cartesian'
CYLINDER = 'cylinder'
SPHERICAL = 'spherical'
m = sympy.diffgeom.Manifold('M', 3)
patch = sympy.diffgeom.Patch('P', m)
''' cartesian '''
# cartesian
x, y, z = sympy.symbols('x, y, z')
cartesian = sympy.diffgeom.CoordSystem(CARTESIAN, patch, ['x', 'y', 'z'])
''' cylinder '''
# cylinder
R, Phi, Z = sympy.symbols('R, Phi, Z')
cylinder = sympy.diffgeom.CoordSystem(CYLINDER, patch, ['R', 'Phi', 'Z'])
cylinder.connect_to(cartesian,
......@@ -44,7 +46,7 @@ cartesian.connect_to(cylinder,
inverse=False,
fill_in_gaps=False)
''' spherical '''
# spherical
r, phi, theta = sympy.symbols('r, phi, theta')
spherical = sympy.diffgeom.CoordSystem(SPHERICAL, patch, ['r', 'phi', 'theta'])
spherical.connect_to(cartesian,
......@@ -69,6 +71,12 @@ cartesian.connect_to(spherical,
def getCoordSystem(base):
"""
Args:
base (str or sympy.diffgeom.getCoordSystem)
Return:
sympy.diffgeom.getCoordSystem
"""
if isinstance(base, string_types):
base = getattr(tfields.bases, base)
if not isinstance(base, sympy.diffgeom.CoordSystem):
......@@ -77,6 +85,12 @@ def getCoordSystem(base):
def getCoordSystemName(base):
"""
Args:
base (str or sympy.diffgeom.getCoordSystem)
Returns:
str: name of base
"""
if isinstance(base, sympy.diffgeom.CoordSystem):
base = str(getattr(base, 'name'))
# if not (isinstance(base, string_types) or base is None):
......@@ -96,7 +110,7 @@ def lambdifiedTrafo(baseOld, baseNew):
Examples:
>>> import numpy as np
>>> import tfields
Transform cartestian to cylinder or spherical
>>> a = np.array([[3,4,0]])
......
#!/usr/bin/env
# encoding: utf-8
"""
Author: Daniel Boeckenhoff
Mail: daniel.boeckenhoff@ipp.mpg.de
core of tfields library
contains numpy ndarray derived bases of the tfields package
"""
import tfields.bases
import numpy as np
from contextlib import contextmanager
from collections import Counter
import loggingTools as lt
log = lt.Logger(__name__)
np.seterr(all='warn', over='raise')
......@@ -49,7 +56,7 @@ class AbstractNdarray(np.ndarray):
__slotDtypes__ = []
__slotSetters__ = []
def __new__(cls, array, **kwargs): # pragma: no cover
def __new__(cls, array, **kwargs): # pragma: no cover
raise NotImplementedError("{clsType} type must implement '__new__'"
.format(clsType=type(cls)))
......
......@@ -9,8 +9,6 @@ contains interaction methods for sympy and numpy
"""
import numpy as np
import sympy
import loggingTools
logger = loggingTools.Logger(__name__)
def getMask(array, cutExpression=None, coords=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment