Commit 3a254f1d authored by dboe's avatar dboe
Browse files

bufix in mesh3D part stuff

parent a458ade3
make/python/.gitignore
\ No newline at end of file
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# pyc files:
*.pyc
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask instance folder
instance/
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# IPython Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# dotenv
.env
# virtualenv
venv/
ENV/
# Spyder project settings
.spyderproject
# vim files
*.sw*
# folder
tmp/
.idea
docs/source/
make/python/Makefile
\ No newline at end of file
CURRENT_PATH := $(shell pwd)
MODULE := $(shell basename $(CURRENT_PATH))
VERSION := $(shell python -c "import sys; import $(MODULE); sys.stdout.write($(MODULE).__version__)")
SOURCES := $(shell find $(MODULE) -name '*.py')
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SPHINXSOURCEDIR = ./docs
SPHINXBUILDDIR = docs/_build
test: FORCE
# py.test --doctest-modules
nosetests --with-doctest --logging-level=ERROR
coverage:
# coverage run $(MODULE) test
nosetests --with-doctest --with-coverage --cover-erase --cover-package=$(MODULE)
coverage report
coverage html
firefox htmlcov/index.html
clean:
coverage erase
rm -rf docs/_build/*
rm -rf docs/source
publish:
@while [ -z "$$CONTINUE" ]; do \
read -r -p "Have you changed the __version__ attribute in <module_name>/__init__.py??? If yes, type Y or y to continue. Type anything else to exit. [y/N]: " CONTINUE; \
done ; \
[ $$CONTINUE = "y" ] || [ $$CONTINUE = "Y" ] || (echo "Exiting."; exit 1;)
@echo "... publishing ..."
@echo "New Version: $(VERSION)"
git tag -a v$(VERSION) -m "Version $(VERSION) tag" # tag version
git push origin v$(VERSION) # explicitly push tag to the shared server
rm -f dist/* # could become unnecessary, if you find a way to specify 'twine upload dist/transcoding-$(VERSION).tag.gz' in last step
python setup.py sdist # building package
twine upload dist/* # publish package
untag:
# remove last tag. mostly, because publishing failed
git tag -d v$(VERSION)
git push origin :refs/tags/v$(VERSION)
docs: Makefile $(SOURCES)
# link apidoc to source
sphinx-apidoc -o docs/source/ $(MODULE)
# build html documentation with sphinx
# @$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(0)
sphinx-build -M html docs docs/_build
# open the html slides
python -m webbrowser docs/_build/html/index.html
FORCE: ;
Subproject commit 96a8a33fe8b8d800853f8ee2cbf7a1e5814bef91
make/python/setup.py
\ No newline at end of file
"""
Publishing:
either:
$make publish
or manually:
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>" # tag version
$ git push origin v<my.version.id> # explicitly push tag to the shared server
$ python setup.py sdist
$ twine upload dist/*
"""
from setuptools import setup, find_packages
import os
title = os.path.basename(os.path.abspath('.'))
exec(open("./{title}/__about__.py".format(**locals())).read())
with open(os.path.join('.', 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(
name=title,
version=__version__,
description=__summary__,
long_description=long_description,
long_description_content_type='text/markdown',
author=__author__,
author_email=__email__,
license=__license__,
keywords=__keywords__,
packages=find_packages(),
url=__uri__,
project_urls={
'Documentation': __uri__,
'Source': __uri__,
},
test_require=[
'doctest',
'unittest',
'nose',
],
install_requires=__dependencies__,
classifiers=__classifiers__,
python_requires=__python_requires__,
)
# in the terminal:
# pip install .
This diff is collapsed.
......@@ -26,7 +26,7 @@ def _segment_plane_intersection(p0, p1, plane):
Args:
p0: array of length 3
p1: array of length 3
plane:
plane:
Returns:
points, direction
points (list of arrays of length 3): 3d points
......@@ -206,7 +206,7 @@ class Mesh3D(tfields.TensorMaps):
>>> outFile = NamedTemporaryFile(suffix='.npz')
>>> m.save(outFile.name)
>>> _ = outFile.seek(0)
>>> m1 = tfields.Mesh3D.load(outFile.name)
>>> m1 = tfields.Mesh3D.load(outFile.name, allow_pickle=True)
>>> bool(np.all(m == m1))
True
>>> assert np.array_equal(m1.faces, np.array([[0, 1, 2]]))
......@@ -459,7 +459,7 @@ class Mesh3D(tfields.TensorMaps):
... (-1, 1, 2),
... (-5, -3, 2))
Cylinder
Cylinder
>>> cylinder = tfields.Mesh3D.grid((1, 1, 1),
... (-np.pi, np.pi, 12),
... (-5, 3, 12),
......@@ -828,7 +828,7 @@ class Mesh3D(tfields.TensorMaps):
>>> assert np.array_equal(res.maps[0].fields[0],
... [[-42, -21], [42, 21]])
"""
# Possible Extension (small todo): check: len(field(s)) == len(self/maps)
......@@ -882,7 +882,7 @@ class Mesh3D(tfields.TensorMaps):
fast instruction of how to cut the triangles.
It is the second part of the tuple, returned by a previous
cut with a sympy locial expression with 'return_template=True'.
We use the vertices and maps of the Mesh as the sceleton of
We use the vertices and maps of the Mesh as the skelleton of
the returned mesh. The fields are mapped according to
indices in the template.maps[i].fields.
coord_sys (coordinate system to cut in):
......@@ -977,6 +977,10 @@ class Mesh3D(tfields.TensorMaps):
return obj
def disjoint_parts(self, return_template=False):
"""
Returns:
disjoint_parts(List(cls)), templates(List(cls))
"""
mp_description = self.disjoint_map(0)
parts = self.parts(mp_description)
if not return_template:
......@@ -985,7 +989,9 @@ class Mesh3D(tfields.TensorMaps):
templates = []
for i, part in enumerate(parts):
template = part.copy()
template.maps[0].fields[0] = tfields.Tensors(mp_description[1][i])
template.maps[0].fields = [
tfields.Tensors(mp_description[1][i])
]
templates.append(template)
return parts, templates
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment