Skip to content

Commit c740a8d

Browse files
authored
Merge pull request #67 from ggurioli/branch_setup
Minor revision of setup.py and of test_shaft.py
2 parents f752c5a + 96eead2 commit c740a8d

File tree

8 files changed

+69
-52
lines changed

8 files changed

+69
-52
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ See the [**Examples**](#examples) section below and the [**Tutorials**](tutorial
4646

4747
## Dependencies and installation
4848
**BladeX** requires `numpy`, `scipy`, `matplotlib`, `sphinx` (for the documentation), and `nose` (for the local test). They can be easily installed using `pip`.
49-
**BladeX** is compatible with Python 2.7 and Python 3.6. Moreover, some of the modules require `OCC` to be installed for the `.iges` or `.stl` CAD generation. Please see the table below for instructions on how to satisfy the `OCC` requirements. You can also refer to `pythonocc.org` or `github.com/tpaviot/pythonocc-core` for further instructions.
49+
**BladeX** is compatible with Python 3.6. Moreover, some of the modules require `OCC` to be installed for the `.iges` or `.stl` CAD generation. This requirement cannot be satisfied through `pip`, but the precompiled binaries are available on `conda` using the command:
5050

51-
| Package | Version | How to install (precompiled binaries via conda) |
52-
|---------|-------------|----------------------------------------------------------------------------------------------------------------------|
53-
| OCC | ==0.18.1 | Python2.7 `conda install -c conda-forge -c dlr-sc -c pythonocc -c oce pythonocc-core==0.18.1 smesh=6.7.5 python=2.7` |
54-
| OCC | ==0.18.1 | Python3.6 `conda install -c conda-forge -c dlr-sc -c pythonocc -c oce pythonocc-core==0.18.1 smesh=6.7.5 python=3.6` |
51+
```bash
52+
> conda install -c conda-forge pythonocc-core=7.4.0
53+
```
5554

55+
You can also refer to `pythonocc.org` or `github.com/tpaviot/pythonocc-core` for further instructions.
5656

5757
### Installing from source
5858
The official distribution is on GitHub, and you can clone the repository using

bladex/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44
__all__ = ['profilebase', 'profiles', 'blade', 'shaft', 'propeller', 'deform', 'params', 'ndinterpolator']
55

6+
from .meta import *
67
from .profilebase import ProfileBase
78
from .profiles import CustomProfile, NacaProfile
89
from .blade import Blade

bladex/meta.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
__all__ = [
2+
'__project__',
3+
'__title__',
4+
'__author__',
5+
'__copyright__',
6+
'__license__',
7+
'__version__',
8+
'__mail__',
9+
'__maintainer__',
10+
'__status__']
11+
12+
__project__ = 'BladeX'
13+
__title__ = "bladex"
14+
__author__ = "Marco Tezzele, Mahmoud Gadalla"
15+
__copyright__ = "Copyright 2019-2021, BladeX contributors"
16+
__license__ = "MIT"
17+
__version__ = "0.1.0"
18+
19+
__maintainer__ = __author__
20+
__status__ = "Stable"

bladex/propeller.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
"""
22
Module for the propeller with shaft bottom-up parametrized construction.
33
"""
4-
import os
54
import numpy as np
6-
from bladex import Blade, Shaft
7-
import OCC.Core.TopoDS
8-
from OCC.Core.gp import gp_Dir, gp_Pnt, gp_Ax1, gp_Trsf
9-
from OCC.Core.IGESControl import IGESControl_Reader, IGESControl_Writer
10-
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_Transform, BRepBuilderAPI_Sewing
5+
from OCC.Core.IGESControl import IGESControl_Writer
6+
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_Sewing
117
from OCC.Core.BRepAlgoAPI import BRepAlgoAPI_Fuse
128
from OCC.Extend.DataExchange import write_stl_file
139
from OCC.Display.SimpleGui import init_display
@@ -46,7 +42,6 @@ def __init__(self, shaft, blade, n_blades):
4642
boolean_union = BRepAlgoAPI_Fuse(self.shaft_solid, blades_combined)
4743
boolean_union.Build()
4844
result_compound = boolean_union.Shape()
49-
section_edges = boolean_union.SectionEdges()
5045
sewer = BRepBuilderAPI_Sewing(1e-2)
5146
sewer.Add(result_compound)
5247
sewer.Perform()

bladex/shaft.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Shaft(object):
1313
stored shaft information.
1414
:cvar string filename: path (with the file extension) of a .stl or .iges file with
1515
stored shaft information.
16+
:raises Exception: if the extension in the filename is not in .stl or .iges formats.
1617
"""
1718

1819
def __init__(self, filename):
@@ -30,14 +31,14 @@ def generate_solid(self):
3031
"""
3132
ext = os.path.splitext(self.filename)[1][1:]
3233
if ext == 'stl':
33-
shaft_compound = read_stl_file(self.filename)
34+
shaft_compound = read_stl_file(self.filename)
3435
elif ext == 'iges':
35-
iges_reader = IGESControl_Reader()
36-
iges_reader.ReadFile(self.filename)
37-
iges_reader.TransferRoots()
38-
shaft_compound = iges_reader.Shape()
36+
iges_reader = IGESControl_Reader()
37+
iges_reader.ReadFile(self.filename)
38+
iges_reader.TransferRoots()
39+
shaft_compound = iges_reader.Shape()
3940
else:
40-
raise Exception('The shaft file is not in iges/stl formats')
41+
raise Exception('The shaft file is not in iges/stl formats')
4142
sewer = BRepBuilderAPI_Sewing(1e-2)
4243
sewer.Add(shaft_compound)
4344
sewer.Perform()

setup.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
from setuptools import setup
2+
import os
3+
import sys
24

5+
meta = {}
6+
with open("bladex/meta.py") as fp:
7+
exec(fp.read(), meta)
8+
9+
# Package meta-data.
10+
NAME = meta['__title__']
11+
DESCRIPTION = 'Python Blade Morphing'
12+
URL = 'https://github.com/mathLab/BladeX'
13+
MAIL = meta['__mail__']
14+
AUTHOR = meta['__author__']
15+
VERSION = meta['__version__']
16+
KEYWORDS='blade-generation propeller iges procal'
17+
18+
REQUIRED = [
19+
'numpy', 'scipy', 'matplotlib', 'Sphinx', 'sphinx_rtd_theme',
20+
]
321

422
def readme():
523
"""
@@ -8,30 +26,26 @@ def readme():
826
with open('README.md') as f:
927
return f.read()
1028

11-
1229
setup(
13-
name='bladex',
14-
version='0.1.0',
15-
description='BladeX.',
30+
name=NAME,
31+
version=VERSION,
32+
description=DESCRIPTION,
1633
long_description=readme(),
1734
classifiers=[
1835
'Development Status :: 5 - Production/Stable',
1936
'License :: OSI Approved :: MIT License',
20-
'Programming Language :: Python :: 2.7',
2137
'Programming Language :: Python :: 3.6',
2238
'Intended Audience :: Science/Research',
2339
'Topic :: Scientific/Engineering :: Mathematics'
2440
],
25-
keywords='blade-generation propeller iges procal',
26-
url='https://github.com/mathLab/BladeX',
27-
author='Marco Tezzele, Mahmoud Gadalla',
28-
41+
keywords=KEYWORDS,
42+
url=URL,
43+
author=AUTHOR,
44+
author_email=MAIL,
2945
license='MIT',
30-
packages=['bladex'],
31-
install_requires=[
32-
'numpy', 'scipy', 'matplotlib', 'Sphinx==1.4', 'sphinx_rtd_theme'
33-
],
46+
packages=[NAME],
47+
install_requires=REQUIRED,
3448
test_suite='nose.collector',
3549
tests_require=['nose'],
3650
include_package_data=True,
37-
zip_safe=False)
51+
zip_safe=False)

tests/test_package.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,4 @@ def test_import_blade_4(self):
3333

3434
def test_import_blade_5(self):
3535
import bladex as bx
36-
inter = bx.ndinterpolator.RBF('gaussian_spline', 1.2)
37-
38-
def test_modules_name(self):
39-
# it checks that __all__ includes all the .py files in bladex folder
40-
import bladex
41-
package = bladex
42-
43-
f_aux = []
44-
for (__, __, filenames) in walk('bladex'):
45-
f_aux.extend(filenames)
46-
47-
f = []
48-
for i in f_aux:
49-
file_name, file_ext = path.splitext(i)
50-
if file_name != '__init__' and file_ext == '.py':
51-
f.append(file_name)
52-
53-
print(f)
54-
print(package.__all__)
55-
assert sorted(package.__all__) == sorted(f)
36+
inter = bx.ndinterpolator.RBF('gaussian_spline', 1.2)

tests/test_shaft.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ def test_generate_solid_02(self):
1818
shaft_solid = sh.generate_solid()
1919
self.assertIsInstance(shaft_solid, TopoDS_Solid)
2020

21+
def test_exception(self):
22+
sh = Shaft("tests/test_datasets/parameters.prm")
23+
with self.assertRaises(Exception):
24+
sh.generate_solid()
25+
2126
def test_display_01(self):
2227
sh = Shaft("tests/test_datasets/shaft.iges")
2328
sh.display()

0 commit comments

Comments
 (0)