Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ example/bar2vtk/result/*

# testing
.coverage

# Documentation
docs/_build/*
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 2 additions & 0 deletions docs/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx-rtd-theme
autodocsumm
20 changes: 20 additions & 0 deletions docs/api/vtkpytools.barfiletools.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Bar File tools (:mod:`barfiletools`)
================================================

Creating VTM files (:mod:`barfiletools.bar2vtk`)
-------------------------------------------------------------

.. automodule:: vtkpytools.barfiletools.bar2vtk
:members:
:undoc-members:
:autosummary:
:autosummary-nosignatures:

Post-Processing VTM files (:mod:`barfiletools.data`)
-----------------------------------------------------------

.. automodule:: vtkpytools.barfiletools.data
:members:
:undoc-members:
:autosummary:
:autosummary-nosignatures:
9 changes: 9 additions & 0 deletions docs/api/vtkpytools.bl.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Boundary Layer tools (:mod:`bl`)
=============================================================

.. automodule:: vtkpytools.bl
:members:
:undoc-members:
:autosummary:
:autosummary-nosignatures:

7 changes: 7 additions & 0 deletions docs/api/vtkpytools.common.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Common Utilities module (:mod:`common`)
=========================================

.. automodule:: vtkpytools.common
:members:
:autosummary:
:autosummary-nosignatures:
9 changes: 9 additions & 0 deletions docs/api/vtkpytools.gridtools2d.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Tools for 2D Grids (:mod:`gridtools2d`)
===========================================

.. automodule:: vtkpytools.gridtools2d.core
:members:
:undoc-members:
:autosummary:
:autosummary-nosignatures:
:show-inheritance:
9 changes: 9 additions & 0 deletions docs/api/vtkpytools.gridtools3d.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Tools for 3D Grids (:mod:`gridtools3d`)
=========================================

.. automodule:: vtkpytools.gridtools3d.core
:members:
:undoc-members:
:autosummary:
:autosummary-nosignatures:
:show-inheritance:
8 changes: 8 additions & 0 deletions docs/api/vtkpytools.numtools.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Numerical Tools (:mod:`numtools`)
==================================

.. automodule:: vtkpytools.numtools
:members:
:undoc-members:
:autosummary:
:autosummary-nosignatures:
66 changes: 66 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
import sphinx_rtd_theme
sys.path.insert(0, os.path.abspath('../'))


# -- Project information -----------------------------------------------------

project = 'vtkpytools'
copyright = '2021, James Wright'
author = 'James Wright'

# The full version, including alpha/beta/rc tags
release = '1.1.0'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'autodocsumm',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
'sphinx.ext.mathjax',
'sphinx_rtd_theme',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

autodoc_member_order = 'bysource'

default_role = 'autolink'
29 changes: 29 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Welcome to vtkpytools's documentation!
======================================

Subpackages
-----------

.. toctree::
:maxdepth: 4

api/vtkpytools.barfiletools
api/vtkpytools.gridtools2d
api/vtkpytools.gridtools3d

Modules
--------------------

.. toctree::
:maxdepth: 4

api/vtkpytools.bl
api/vtkpytools.common
api/vtkpytools.numtools

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx-rtd-theme
autodocsumm
74 changes: 63 additions & 11 deletions tests/test_numtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,71 @@ def test_calcStrainRate(twoFullTensors):
assert np.allclose(strainrate, solution)
assert strainrate.shape[0] == twoFullTensors.shape[0]

class Test_symmetric2FullTensor():

def test_symmetric2FullTensor(symAndFullTensor):
(full, sym) = symAndFullTensor
@staticmethod
def test_func2d(symAndFullTensor):
full, sym = symAndFullTensor

full_test = vpt.symmetric2FullTensor(sym)
assert np.allclose(full_test, full)
full_test = vpt.symmetric2FullTensor(sym)
assert np.allclose(full_test, full)

@staticmethod
def test_func_Nd(symAndFullTensor):
"""Test (n,m,6) -> (n,m,3,3)"""
full, sym = symAndFullTensor

def test_full2SymmetricTensor(symAndFullTensor):
(full, sym) = symAndFullTensor
sym = sym.reshape((1,-1,6))
full = full.reshape((1,-1,3,3))
full_test = vpt.symmetric2FullTensor(sym)
assert full_test.shape == full.shape
assert np.allclose(full_test, full)

sym_test = vpt.full2SymmetricTensor(full)
assert np.allclose(sym_test, sym)
sym = sym.reshape((-1,1,6))
full = full.reshape((-1,1,3,3))
full_test = vpt.symmetric2FullTensor(sym)
assert full_test.shape == full.shape
assert np.allclose(full_test, full)

@staticmethod
def test_inputCheck():
array = np.empty((6,4))
with pytest.raises(Exception):
vpt.symmetric2FullTensor(array)


class Test_full2SymmetricTensor():

@staticmethod
def test_func3d(symAndFullTensor):
full, sym = symAndFullTensor

sym_test = vpt.full2SymmetricTensor(full)
assert sym_test.shape == sym.shape
assert np.allclose(sym_test, sym)

@staticmethod
def test_func_Nd(symAndFullTensor):
"""Test (n,m,3,3) -> (n,m,6)"""
full, sym = symAndFullTensor

sym = sym.reshape((1,-1,6))
full = full.reshape((1,-1,3,3))
sym_test = vpt.full2SymmetricTensor(full)
assert sym_test.shape == sym.shape
assert np.allclose(sym_test, sym)

sym = sym.reshape((-1,1,6))
full = full.reshape((-1,1,3,3))
sym_test = vpt.full2SymmetricTensor(full)
assert sym_test.shape == sym.shape
assert np.allclose(sym_test, sym)

@staticmethod
def test_inputCheck():
array = np.empty((3,3,4))
with pytest.raises(Exception):
vpt.full2SymmetricTensor(array)


@pytest.mark.parametrize('offset,expected', [(1, [0, 1] ),
Expand All @@ -53,7 +105,7 @@ def test_pwlinRoots(offset, expected):
y = np.array([-1, 1, -1])

roots = vpt.pwlinRoots(x, y + offset)
assert(np.allclose(roots, expected))
assert np.allclose(roots, expected)


@pytest.mark.parametrize('kwargs,expected', [({'dx': 2.4}, [0, 1, 2, 4, 6.4, 8]),
Expand All @@ -63,8 +115,8 @@ def test_seriesDiffLimiter(kwargs, expected):
series = np.array([0, 1, 2, 4, 8])

result = vpt.seriesDiffLimiter(series, **kwargs)
assert(result.size == len(expected))
assert(np.allclose(result, expected))
assert result.size == len(expected)
assert np.allclose(result, expected)

@pytest.mark.parametrize('kwargs', [{},
{'dx': 2.0, 'magnitude': 4.0}])
Expand Down
2 changes: 2 additions & 0 deletions vtkpytools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ._version import __version__
from .barfiletools import *
from .gridtools3d import *
from .gridtools2d import *
Expand All @@ -8,3 +9,4 @@
pwlinRoots, seriesDiffLimiter)
from .bl import (integratedVortBLThickness, sampleAlongVectors, delta_vortInt, delta_velInt, delta_percent)

from .misc import *
Loading