diff --git a/setup.py b/setup.py index 3d755b161800b2b81d58732728f443cdccd43ed8..8dbd1e0929594e781965b26c623f1aaaa07259d2 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,20 @@ """ 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 diff --git a/tfields/__main__.py b/tfields/__main__.py index 64737c657671c5cd6971241d3d808f63a0b896e2..21d7439f95a7c3a995e06b0298027f772ebe2928 100644 --- a/tfields/__main__.py +++ b/tfields/__main__.py @@ -1,11 +1,12 @@ -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() diff --git a/tfields/bases.py b/tfields/bases.py index 57c0184d2bd3dc7cd41daf92a15193f1a3490c0e..aa429798d463b6986b7266e82e0ee87e418b69da 100644 --- a/tfields/bases.py +++ b/tfields/bases.py @@ -1,4 +1,10 @@ +#!/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]]) diff --git a/tfields/core.py b/tfields/core.py index b1ab5fc46971c129403cecba9b7a1ff34efa60bf..143780e154aa59f3ea40f17f87ef8a96df8dc99c 100644 --- a/tfields/core.py +++ b/tfields/core.py @@ -1,9 +1,16 @@ +#!/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))) diff --git a/tfields/mask.py b/tfields/mask.py index 0717841ab226849d6152ff383640d92de247c731..14b85f7dbbdc9eee94b0ff016d9bdfd51fc1fb8e 100644 --- a/tfields/mask.py +++ b/tfields/mask.py @@ -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):