From a1c50aa6127c7abda85534526bb52912c131f56f Mon Sep 17 00:00:00 2001 From: "Jack S. Hale" Date: Thu, 23 Jun 2022 11:33:27 +0200 Subject: [PATCH] Attempt at automatic typing for basix (#526) * Not tested * mypy passes on basix module * Add __version__ to pyi file * types should no longer be needed in wrapper docs * remove types from template * mypy checks * remove pip install ffcx * | * mypy checks * types Co-authored-by: Matthew Scroggs --- .github/workflows/dolfin-tests.yml | 8 +- .github/workflows/ffcx-tests.yml | 5 + cpp/docs.template | 290 ++++++++++++------------- cpp/generate_docs.py | 6 +- python/basix/_basixcpp.pyi | 331 +++++++++++++++++++++++++++++ python/basix/py.typed | 0 python/basix/quadrature.py | 4 +- python/setup.py | 2 + setup.py | 3 +- 9 files changed, 492 insertions(+), 157 deletions(-) create mode 100644 python/basix/_basixcpp.pyi create mode 100644 python/basix/py.typed diff --git a/.github/workflows/dolfin-tests.yml b/.github/workflows/dolfin-tests.yml index 12f18871c..f5ec8ca4b 100644 --- a/.github/workflows/dolfin-tests.yml +++ b/.github/workflows/dolfin-tests.yml @@ -61,10 +61,6 @@ jobs: python3 -m pip install git+https://github.com/FEniCS/ufl.git@${{ github.event.inputs.ufl_branch }} python3 -m pip install git+https://github.com/FEniCS/ffcx.git@${{ github.event.inputs.ffcx_branch }} - - name: Run cpp demos - run: | - python3 -m pytest demo/cpp/test.py - - name: Get DOLFINx if: github.event_name != 'workflow_dispatch' uses: actions/checkout@v3 @@ -78,7 +74,6 @@ jobs: path: ./dolfinx repository: FEniCS/dolfinx ref: ${{ github.event.inputs.dolfinx_branch }} - - name: Install DOLFINx run: | cmake -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build -S dolfinx/cpp/ @@ -86,6 +81,9 @@ jobs: cmake --install build python3 -m pip -v install --global-option build --global-option --debug dolfinx/python/ + - name: Run mypy checks + run: python3 -m mypy dolfinx/python/dolfinx + - name: Build DOLFINx C++ unit tests run: | cmake -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build/test/ -S build/test/ diff --git a/.github/workflows/ffcx-tests.yml b/.github/workflows/ffcx-tests.yml index f4dd957d0..c60c7b470 100644 --- a/.github/workflows/ffcx-tests.yml +++ b/.github/workflows/ffcx-tests.yml @@ -56,6 +56,11 @@ jobs: repository: FEniCS/ffcx ref: ${{ github.event.inputs.ffcx_branch }} + - name: Run mypy checks + run: | + python -m pip install mypy types-setuptools + python -m mypy ffcx/ffcx + - name: Install FFCx run: pip install ./ffcx[ci] - name: Run FFCx tests diff --git a/cpp/docs.template b/cpp/docs.template index 0136ac181..c3ca95430 100644 --- a/cpp/docs.template +++ b/cpp/docs.template @@ -2,190 +2,190 @@ {{cell.h > topology > doc}} Args: - {{cell.h > topology > param > celltype : basix.CellType}} + {{cell.h > topology > param > celltype}} Returns:: - {{cell.h > topology > return : List[List[List[int]]]}} + {{cell.h > topology > return}} )"; {{DOCTYPE}} geometry = R"( {{cell.h > geometry > doc}} Args: - {{cell.h > geometry > param > celltype : basix.CellType}} + {{cell.h > geometry > param > celltype}} Returns:: - {{cell.h > geometry > return : numpy.typing.NDArray[numpy.float64]}} + {{cell.h > geometry > return}} )"; {{DOCTYPE}} sub_entity_connectivity = R"( {{cell.h > sub_entity_connectivity > doc}} Args: - {{cell.h > sub_entity_connectivity > param > celltype : basix.CellType}} + {{cell.h > sub_entity_connectivity > param > celltype}} Returns: - {{cell.h > sub_entity_connectivity > return : List[List[List[List[int]]]]}} + {{cell.h > sub_entity_connectivity > return}} )"; {{DOCTYPE}} sub_entity_geometry = R"( {{cell.h > sub_entity_geometry > doc}} Args: - {{cell.h > sub_entity_geometry > param > celltype : basix.CellType}} - {{cell.h > sub_entity_geometry > param > dim : int}} - {{cell.h > sub_entity_geometry > param > index : int}} + {{cell.h > sub_entity_geometry > param > celltype}} + {{cell.h > sub_entity_geometry > param > dim}} + {{cell.h > sub_entity_geometry > param > index}} Returns: - {{cell.h > sub_entity_geometry > return : List[List[List[List[int]]]]}} + {{cell.h > sub_entity_geometry > return}} )"; {{DOCTYPE}} create_lattice__celltype_n_type_exterior = R"( {{lattice.h > create > doc}} Args: - {{lattice.h > create > param > celltype : basix.CellType}} - {{lattice.h > create > param > n : int}} - {{lattice.h > create > param > type : basix.LatticeType}} - {{lattice.h > create > param > exterior : bool}} + {{lattice.h > create > param > celltype}} + {{lattice.h > create > param > n}} + {{lattice.h > create > param > type}} + {{lattice.h > create > param > exterior}} Returns: - {{lattice.h > create > return : numpy.typing.NDArray[numpy.float64]}} + {{lattice.h > create > return}} )"; {{DOCTYPE}} create_lattice__celltype_n_type_exterior_method = R"( {{lattice.h > create > doc}} Args: - {{lattice.h > create > param > celltype : basix.CellType}} - {{lattice.h > create > param > n : int}} - {{lattice.h > create > param > type : basix.LatticeType}} - {{lattice.h > create > param > exterior : bool}} - {{lattice.h > create > param > simplex_method : basix.LatticeSimplexMethod}} + {{lattice.h > create > param > celltype}} + {{lattice.h > create > param > n}} + {{lattice.h > create > param > type}} + {{lattice.h > create > param > exterior}} + {{lattice.h > create > param > simplex_method}} Returns: - {{lattice.h > create > return : numpy.typing.NDArray[numpy.float64]}} + {{lattice.h > create > return}} )"; {{DOCTYPE}} cell_volume = R"( {{cell.h > volume > doc}} Args: - {{cell.h > volume > param > cell_type : basix.CellType}} + {{cell.h > volume > param > cell_type}} Returns: - {{cell.h > volume > return : float}} + {{cell.h > volume > return}} )"; {{DOCTYPE}} cell_facet_normals = R"( {{cell.h > facet_normals > doc}} Args: - {{cell.h > facet_normals > param > cell_type : basix.CellType}} + {{cell.h > facet_normals > param > cell_type}} Returns: - {{cell.h > facet_normals > return : numpy.typing.NDArray[numpy.float64]}} + {{cell.h > facet_normals > return}} )"; {{DOCTYPE}} cell_facet_reference_volumes = R"( {{cell.h > facet_reference_volumes > doc}} Args: - {{cell.h > facet_reference_volumes > param > cell_type : basix.CellType}} + {{cell.h > facet_reference_volumes > param > cell_type}} Returns: - {{cell.h > facet_reference_volumes > return : numpy.typing.NDArray[numpy.float64]}} + {{cell.h > facet_reference_volumes > return}} )"; {{DOCTYPE}} cell_facet_outward_normals = R"( {{cell.h > facet_outward_normals > doc}} Args: - {{cell.h > facet_outward_normals > param > cell_type : basix.CellType}} + {{cell.h > facet_outward_normals > param > cell_type}} Returns: - {{cell.h > facet_outward_normals > return : numpy.typing.NDArray[numpy.float64]}} + {{cell.h > facet_outward_normals > return}} )"; {{DOCTYPE}} cell_facet_orientations = R"( {{cell.h > facet_orientations > doc}} Args: - {{cell.h > facet_orientations > param > cell_type : basix.CellType}} + {{cell.h > facet_orientations > param > cell_type}} Returns: - {{cell.h > facet_orientations > return : List[bool]}} + {{cell.h > facet_orientations > return}} )"; {{DOCTYPE}} cell_facet_jacobians = R"( {{cell.h > facet_jacobians > doc}} Args: - {{cell.h > facet_jacobians > param > cell_type : basix.CellType}} + {{cell.h > facet_jacobians > param > cell_type}} Returns: - {{cell.h > facet_jacobians > return : numpy.typing.NDArray[numpy.float64]}} + {{cell.h > facet_jacobians > return}} )"; {{DOCTYPE}} FiniteElement__tabulate = R"( {{finite-element.h > FiniteElement::tabulate > doc}} Args: - {{finite-element.h > FiniteElement::tabulate > param > nd : int}} - {{finite-element.h > FiniteElement::tabulate > param > x : numpy.typing.NDArray[numpy.float64]}} + {{finite-element.h > FiniteElement::tabulate > param > nd}} + {{finite-element.h > FiniteElement::tabulate > param > x}} Returns: - {{finite-element.h > FiniteElement::tabulate > return : numpy.typing.NDArray[numpy.float64]}} + {{finite-element.h > FiniteElement::tabulate > return}} )"; {{DOCTYPE}} FiniteElement__push_forward = R"( {{finite-element.h > FiniteElement::push_forward > doc}} Args: - {{finite-element.h > FiniteElement::push_forward > param > U : numpy.typing.NDArray[numpy.float64]}} - {{finite-element.h > FiniteElement::push_forward > param > J : numpy.typing.NDArray[numpy.float64]}} - {{finite-element.h > FiniteElement::push_forward > param > detJ : numpy.typing.NDArray[numpy.float64]}} - {{finite-element.h > FiniteElement::push_forward > param > K : numpy.typing.NDArray[numpy.float64]}} + {{finite-element.h > FiniteElement::push_forward > param > U}} + {{finite-element.h > FiniteElement::push_forward > param > J}} + {{finite-element.h > FiniteElement::push_forward > param > detJ}} + {{finite-element.h > FiniteElement::push_forward > param > K}} Returns: - {{finite-element.h > FiniteElement::push_forward > return : numpy.typing.NDArray[numpy.float64]}} + {{finite-element.h > FiniteElement::push_forward > return}} )"; {{DOCTYPE}} FiniteElement__pull_back = R"( {{finite-element.h > FiniteElement::pull_back > doc}} Args: - {{finite-element.h > FiniteElement::pull_back > param > u : numpy.typing.NDArray[numpy.float64]}} - {{finite-element.h > FiniteElement::pull_back > param > J : numpy.typing.NDArray[numpy.float64]}} - {{finite-element.h > FiniteElement::pull_back > param > detJ : numpy.typing.NDArray[numpy.float64]}} - {{finite-element.h > FiniteElement::pull_back > param > K : numpy.typing.NDArray[numpy.float64]}} + {{finite-element.h > FiniteElement::pull_back > param > u}} + {{finite-element.h > FiniteElement::pull_back > param > J}} + {{finite-element.h > FiniteElement::pull_back > param > detJ}} + {{finite-element.h > FiniteElement::pull_back > param > K}} Returns: - {{finite-element.h > FiniteElement::pull_back > return : numpy.typing.NDArray[numpy.float64]}} + {{finite-element.h > FiniteElement::pull_back > return}} )"; {{DOCTYPE}} FiniteElement__apply_dof_transformation = R"( {{finite-element.h > FiniteElement::apply_dof_transformation > doc}} Args: - {{finite-element.h > FiniteElement::apply_dof_transformation > param > data : numpy.typing.NDArray[numpy.float64]}} - {{finite-element.h > FiniteElement::apply_dof_transformation > param > block_size : int}} - {{finite-element.h > FiniteElement::apply_dof_transformation > param > cell_info : int}} + {{finite-element.h > FiniteElement::apply_dof_transformation > param > data}} + {{finite-element.h > FiniteElement::apply_dof_transformation > param > block_size}} + {{finite-element.h > FiniteElement::apply_dof_transformation > param > cell_info}} Returns: - {{finite-element.h > FiniteElement::apply_dof_transformation > param > data : numpy.typing.NDArray[numpy.float64]}} + {{finite-element.h > FiniteElement::apply_dof_transformation > param > data}} )"; {{DOCTYPE}} FiniteElement__apply_dof_transformation_to_transpose = R"( {{finite-element.h > FiniteElement::apply_dof_transformation_to_transpose > doc}} Args: - {{finite-element.h > FiniteElement::apply_dof_transformation_to_transpose > param > data : numpy.typing.NDArray[numpy.float64]}} - {{finite-element.h > FiniteElement::apply_dof_transformation_to_transpose > param > block_size : int}} - {{finite-element.h > FiniteElement::apply_dof_transformation_to_transpose > param > cell_info : int}} + {{finite-element.h > FiniteElement::apply_dof_transformation_to_transpose > param > data}} + {{finite-element.h > FiniteElement::apply_dof_transformation_to_transpose > param > block_size}} + {{finite-element.h > FiniteElement::apply_dof_transformation_to_transpose > param > cell_info}} Returns: - {{finite-element.h > FiniteElement::apply_dof_transformation_to_transpose > param > data : numpy.typing.NDArray[numpy.float64]}} + {{finite-element.h > FiniteElement::apply_dof_transformation_to_transpose > param > data}} )"; {{DOCTYPE}} FiniteElement__apply_inverse_transpose_dof_transformation @@ -193,65 +193,65 @@ Returns: {{finite-element.h > FiniteElement::apply_inverse_transpose_dof_transformation > doc}} Args: - {{finite-element.h > FiniteElement::apply_inverse_transpose_dof_transformation > param > data : numpy.typing.NDArray[numpy.float64]}} - {{finite-element.h > FiniteElement::apply_inverse_transpose_dof_transformation > param > block_size : int}} - {{finite-element.h > FiniteElement::apply_inverse_transpose_dof_transformation > param > cell_info : int}} + {{finite-element.h > FiniteElement::apply_inverse_transpose_dof_transformation > param > data}} + {{finite-element.h > FiniteElement::apply_inverse_transpose_dof_transformation > param > block_size}} + {{finite-element.h > FiniteElement::apply_inverse_transpose_dof_transformation > param > cell_info}} Returns: - {{finite-element.h > FiniteElement::apply_inverse_transpose_dof_transformation > param > data : numpy.typing.NDArray[numpy.float64]}} + {{finite-element.h > FiniteElement::apply_inverse_transpose_dof_transformation > param > data}} )"; {{DOCTYPE}} FiniteElement__base_transformations = R"( {{finite-element.h > base_transformations > doc}} Returns: - {{finite-element.h > base_transformations > return : numpy.typing.NDArray[numpy.float64]}} + {{finite-element.h > base_transformations > return}} )"; {{DOCTYPE}} FiniteElement__entity_transformations = R"( {{finite-element.h > entity_transformations > doc}} Returns: - {{finite-element.h > base_transformations > return : dict}} + {{finite-element.h > base_transformations > return}} )"; {{DOCTYPE}} FiniteElement__get_tensor_product_representation = R"( {{finite-element.h > get_tensor_product_representation > doc}} Returns: - {{finite-element.h > get_tensor_product_representation > return : List[Tuple[List[basix.FiniteElement], List[int]]]}} + {{finite-element.h > get_tensor_product_representation > return}} )"; {{DOCTYPE}} create_custom_element = R"( {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > doc}} Args: - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > cell_type : basix.CellType}} - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > value_shape : List[int]}} - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > wcoeffs : numpy.typing.NDArray[numpy.float64]}} - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > x : List[List[numpy.typing.NDArray[numpy.float64]]]}} - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > M : List[List[numpy.typing.NDArray[numpy.float64]]]}} - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > interpolation_nderivs : int}} - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > map_type : basix.MapType}} - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > discontinuous : bool}} - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > highest_complete_degree : int}} - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > highest_degree : int}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > cell_type}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > value_shape}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > wcoeffs}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > x}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > M}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > interpolation_nderivs}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > map_type}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > discontinuous}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > highest_complete_degree}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > param > highest_degree}} Returns: - {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > return : basix.finite_element.FiniteElement}} + {{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, discontinuous, highest_complete_degree, highest_degree) > return}} )"; {{DOCTYPE}} create_element__family_cell_degree_discontinuous = R"( {{finite-element.h > create_element(family, cell, degree, discontinuous) > doc}} Args: - {{finite-element.h > create_element(family, cell, degree, discontinuous) > param > family : basix.ElementFamily}} - {{finite-element.h > create_element(family, cell, degree, discontinuous) > param > cell : basix.CellType}} - {{finite-element.h > create_element(family, cell, degree, discontinuous) > param > degree : int}} - {{finite-element.h > create_element(family, cell, degree, discontinuous) > param > discontinuous : bool}} + {{finite-element.h > create_element(family, cell, degree, discontinuous) > param > family}} + {{finite-element.h > create_element(family, cell, degree, discontinuous) > param > cell}} + {{finite-element.h > create_element(family, cell, degree, discontinuous) > param > degree}} + {{finite-element.h > create_element(family, cell, degree, discontinuous) > param > discontinuous}} Returns: - {{finite-element.h > create_element(family, cell, degree, discontinuous) > return : basix.finite_element.FiniteElement}} + {{finite-element.h > create_element(family, cell, degree, discontinuous) > return}} )"; {{DOCTYPE}} create_element__family_cell_degree_lvariant_discontinuous @@ -259,27 +259,27 @@ Returns: {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > doc}} Args: - {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > param > family : basix.ElementFamily}} - {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > param > cell : basix.CellType}} - {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > param > degree : int}} - {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > param > lvariant : basix.LagrangeVariant}} - {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > param > discontinuous : bool}} + {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > param > family}} + {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > param > cell}} + {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > param > degree}} + {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > param > lvariant}} + {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > param > discontinuous}} Returns: - {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > return : basix.finite_element.FiniteElement}} + {{finite-element.h > create_element(family, cell, degree, lvariant, discontinuous) > return}} )"; {{DOCTYPE}} create_element__family_cell_degree_lvariant = R"( {{finite-element.h > create_element(family, cell, degree, lvariant) > doc}} Args: - {{finite-element.h > create_element(family, cell, degree, lvariant) > param > family : basix.ElementFamily}} - {{finite-element.h > create_element(family, cell, degree, lvariant) > param > cell : basix.CellType}} - {{finite-element.h > create_element(family, cell, degree, lvariant) > param > degree : int}} - {{finite-element.h > create_element(family, cell, degree, lvariant) > param > lvariant : basix.LagrangeVariant}} + {{finite-element.h > create_element(family, cell, degree, lvariant) > param > family}} + {{finite-element.h > create_element(family, cell, degree, lvariant) > param > cell}} + {{finite-element.h > create_element(family, cell, degree, lvariant) > param > degree}} + {{finite-element.h > create_element(family, cell, degree, lvariant) > param > lvariant}} Returns: - {{finite-element.h > create_element(family, cell, degree, lvariant) > return : basix.finite_element.FiniteElement}} + {{finite-element.h > create_element(family, cell, degree, lvariant) > return}} )"; {{DOCTYPE}} create_element__family_cell_degree_dvariant_discontinuous @@ -287,14 +287,14 @@ Returns: {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > doc}} Args: - {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > param > family : basix.ElementFamily}} - {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > param > cell : basix.CellType}} - {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > param > degree : int}} - {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > param > dvariant : basix.DPCVariant}} - {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > param > discontinuous : bool}} + {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > param > family}} + {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > param > cell}} + {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > param > degree}} + {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > param > dvariant}} + {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > param > discontinuous}} Returns: - {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > return : basix.finite_element.FiniteElement}} + {{finite-element.h > create_element(family, cell, degree, dvariant, discontinuous) > return}} )"; {{DOCTYPE}} @@ -303,145 +303,145 @@ Returns: {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > doc}} Args: - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > family : basix.ElementFamily}} - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > cell : basix.CellType}} - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > degree : int}} - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > lvariant : basix.LagrangeVariant}} - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > dvariant : basix.DPCVariant}} - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > discontinuous : bool}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > family}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > cell}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > degree}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > lvariant}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > dvariant}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > param > discontinuous}} Returns: - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > return : basix.finite_element.FiniteElement}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant, discontinuous) > return}} )"; {{DOCTYPE}} create_element__family_cell_degree_dvariant = R"( {{finite-element.h > create_element(family, cell, degree, dvariant) > doc}} Args: - {{finite-element.h > create_element(family, cell, degree, dvariant) > param > family : basix.ElementFamily}} - {{finite-element.h > create_element(family, cell, degree, dvariant) > param > cell : basix.CellType}} - {{finite-element.h > create_element(family, cell, degree, dvariant) > param > degree : int}} - {{finite-element.h > create_element(family, cell, degree, dvariant) > param > dvariant : basix.DPCVariant}} + {{finite-element.h > create_element(family, cell, degree, dvariant) > param > family}} + {{finite-element.h > create_element(family, cell, degree, dvariant) > param > cell}} + {{finite-element.h > create_element(family, cell, degree, dvariant) > param > degree}} + {{finite-element.h > create_element(family, cell, degree, dvariant) > param > dvariant}} Returns: - {{finite-element.h > create_element(family, cell, degree, dvariant) > return : basix.finite_element.FiniteElement}} + {{finite-element.h > create_element(family, cell, degree, dvariant) > return}} )"; {{DOCTYPE}} create_element__family_cell_degree_lvariant_dvariant = R"( {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > doc}} Args: - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > param > family : basix.ElementFamily}} - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > param > cell : basix.CellType}} - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > param > degree : int}} - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > param > lvariant : basix.LagrangeVariant}} - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > param > dvariant : basix.DPCVariant}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > param > family}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > param > cell}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > param > degree}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > param > lvariant}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > param > dvariant}} Returns: - {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > return : basix.finite_element.FiniteElement}} + {{finite-element.h > create_element(family, cell, degree, lvariant, dvariant) > return}} )"; {{DOCTYPE}} create_element__family_cell_degree = R"( {{finite-element.h > create_element(family, cell, degree) > doc}} Args: - {{finite-element.h > create_element(family, cell, degree) > param > family : basix.ElementFamily}} - {{finite-element.h > create_element(family, cell, degree) > param > cell : basix.CellType}} - {{finite-element.h > create_element(family, cell, degree) > param > degree : int}} + {{finite-element.h > create_element(family, cell, degree) > param > family}} + {{finite-element.h > create_element(family, cell, degree) > param > cell}} + {{finite-element.h > create_element(family, cell, degree) > param > degree}} Returns: - {{finite-element.h > create_element(family, cell, degree) > return : basix.finite_element.FiniteElement}} + {{finite-element.h > create_element(family, cell, degree) > return}} )"; {{DOCTYPE}} compute_interpolation_operator = R"( {{interpolation.h > compute_interpolation_operator > doc}} Args: - {{interpolation.h > compute_interpolation_operator > param > element_from : basix.finite_element.FiniteElement}} - {{interpolation.h > compute_interpolation_operator > param > element_to : basix.finite_element.FiniteElement}} + {{interpolation.h > compute_interpolation_operator > param > element_from}} + {{interpolation.h > compute_interpolation_operator > param > element_to}} Returns: - {{interpolation.h > compute_interpolation_operator > return : numpy.typing.NDArray[numpy.float64]}} + {{interpolation.h > compute_interpolation_operator > return}} )"; {{DOCTYPE}} tabulate_polynomial_set = R"( {{polyset.h > tabulate > doc}} Args: - {{polyset.h > tabulate > param > celltype : basix.CellType}} - {{polyset.h > tabulate > param > d : int}} - {{polyset.h > tabulate > param > n : int}} - {{polyset.h > tabulate > param > x : numpy.typing.NDArray[numpy.float64]}} + {{polyset.h > tabulate > param > celltype}} + {{polyset.h > tabulate > param > d}} + {{polyset.h > tabulate > param > n}} + {{polyset.h > tabulate > param > x}} Returns: - {{polyset.h > tabulate > return : numpy.typing.NDArray[numpy.float64]}} + {{polyset.h > tabulate > return}} )"; {{DOCTYPE}} tabulate_polynomials = R"( {{polynomials.h > tabulate > doc}} Args: - {{polynomials.h > tabulate > param > polytype : basix.PolynomialType}} - {{polynomials.h > tabulate > param > celltype : basix.CellType}} - {{polynomials.h > tabulate > param > d : int}} - {{polynomials.h > tabulate > param > x : numpy.typing.NDArray[numpy.float64]}} + {{polynomials.h > tabulate > param > polytype}} + {{polynomials.h > tabulate > param > celltype}} + {{polynomials.h > tabulate > param > d}} + {{polynomials.h > tabulate > param > x}} Returns: - {{polynomials.h > tabulate > return : numpy.typing.NDArray[numpy.float64]}} + {{polynomials.h > tabulate > return}} )"; {{DOCTYPE}} make_quadrature__rule_celltype_m = R"( {{quadrature.h > make_quadrature(rule, celltype, m) > doc}} Args: - {{quadrature.h > make_quadrature(rule, celltype, m) > param > rule : basix.QuadratureType}} - {{quadrature.h > make_quadrature(rule, celltype, m) > param > celltype : basix.CellType}} - {{quadrature.h > make_quadrature(rule, celltype, m) > param > m : int}} + {{quadrature.h > make_quadrature(rule, celltype, m) > param > rule}} + {{quadrature.h > make_quadrature(rule, celltype, m) > param > celltype}} + {{quadrature.h > make_quadrature(rule, celltype, m) > param > m}} Returns: - {{quadrature.h > make_quadrature(rule, celltype, m) > return : numpy.typing.NDArray[numpy.float64]}} + {{quadrature.h > make_quadrature(rule, celltype, m) > return}} )"; {{DOCTYPE}} make_quadrature__celltype_m = R"( {{quadrature.h > make_quadrature(celltype, m) > doc}} Args: - {{quadrature.h > make_quadrature(celltype, m) > param > celltype : basix.CellType}} - {{quadrature.h > make_quadrature(celltype, m) > param > m : int}} + {{quadrature.h > make_quadrature(celltype, m) > param > celltype}} + {{quadrature.h > make_quadrature(celltype, m) > param > m}} Returns: - {{quadrature.h > make_quadrature(rule, celltype, m) > return : numpy.typing.NDArray[numpy.float64]}} + {{quadrature.h > make_quadrature(rule, celltype, m) > return}} )"; {{DOCTYPE}} index__p = R"( {{indexing.h > idx(p) > doc}} Args: - {{indexing.h > idx(p) > param > p : int}} + {{indexing.h > idx(p) > param > p}} Returns: - {{indexing.h > idx(p) > return : int}} + {{indexing.h > idx(p) > return}} )"; {{DOCTYPE}} index__p_q = R"( {{indexing.h > idx(p, q) > doc}} Args: - {{indexing.h > idx(p, q) > param > p : int}} - {{indexing.h > idx(p, q) > param > q : int}} + {{indexing.h > idx(p, q) > param > p}} + {{indexing.h > idx(p, q) > param > q}} Returns: - {{indexing.h > idx(p, q) > return : int}} + {{indexing.h > idx(p, q) > return}} )"; {{DOCTYPE}} index__p_q_r = R"( {{indexing.h > idx(p, q, r) > doc}} Args: - {{indexing.h > idx(p, q, r) > param > p : int}} - {{indexing.h > idx(p, q, r) > param > q : int}} - {{indexing.h > idx(p, q, r) > param > r : int}} + {{indexing.h > idx(p, q, r) > param > p}} + {{indexing.h > idx(p, q, r) > param > q}} + {{indexing.h > idx(p, q, r) > param > r}} Returns: - {{indexing.h > idx(p, q, r) > return : int}} + {{indexing.h > idx(p, q, r) > return}} )"; diff --git a/cpp/generate_docs.py b/cpp/generate_docs.py index d9aa8b5fd..7837401d7 100644 --- a/cpp/generate_docs.py +++ b/cpp/generate_docs.py @@ -113,7 +113,6 @@ def get_docstring(matches): return "\n".join(doclines) if info_type == "param": - assert typename is not None params = {} for i in doc.split("@param")[1:]: i = i.split("@return")[0] @@ -127,16 +126,15 @@ def get_docstring(matches): p = i pdoc = "TODO: document this" params[p] = "\n ".join(pdoc.split("\n")) - return f"{info} ({typename}): {params[info]}" + return f"{info}: {params[info]}" if info_type == "return": - assert typename is not None returns = [i.split("@param")[0].strip() for i in doc.split("@return")[1:]] if len(returns) == 0: returns.append("TODO: document this") assert len(returns) == 1 returns = "\n ".join(returns[0].split("\n")) - return f"{typename}: {returns}" + return f"{returns}" def generate_docs(): diff --git a/python/basix/_basixcpp.pyi b/python/basix/_basixcpp.pyi new file mode 100644 index 000000000..3192a6137 --- /dev/null +++ b/python/basix/_basixcpp.pyi @@ -0,0 +1,331 @@ +from typing import Any, ClassVar, List, Tuple + +from typing import overload +import numpy + +import numpy.typing as npt + +__version__: str = ... + +class CellType: + __members__: ClassVar[dict] = ... # read-only + __entries: ClassVar[dict] = ... + hexahedron: ClassVar[CellType] = ... + interval: ClassVar[CellType] = ... + point: ClassVar[CellType] = ... + prism: ClassVar[CellType] = ... + pyramid: ClassVar[CellType] = ... + quadrilateral: ClassVar[CellType] = ... + tetrahedron: ClassVar[CellType] = ... + triangle: ClassVar[CellType] = ... + def __init__(self, value: int) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> None: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class DPCVariant: + __members__: ClassVar[dict] = ... # read-only + __entries: ClassVar[dict] = ... + diagonal_equispaced: ClassVar[DPCVariant] = ... + diagonal_gll: ClassVar[DPCVariant] = ... + horizontal_equispaced: ClassVar[DPCVariant] = ... + horizontal_gll: ClassVar[DPCVariant] = ... + legendre: ClassVar[DPCVariant] = ... + simplex_equispaced: ClassVar[DPCVariant] = ... + simplex_gll: ClassVar[DPCVariant] = ... + unset: ClassVar[DPCVariant] = ... + def __init__(self, value: int) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> None: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class ElementFamily: + __members__: ClassVar[dict] = ... # read-only + BDM: ClassVar[ElementFamily] = ... + CR: ClassVar[ElementFamily] = ... + DPC: ClassVar[ElementFamily] = ... + HHJ: ClassVar[ElementFamily] = ... + Hermite: ClassVar[ElementFamily] = ... + N1E: ClassVar[ElementFamily] = ... + N2E: ClassVar[ElementFamily] = ... + P: ClassVar[ElementFamily] = ... + RT: ClassVar[ElementFamily] = ... + Regge: ClassVar[ElementFamily] = ... + __entries: ClassVar[dict] = ... + bubble: ClassVar[ElementFamily] = ... + custom: ClassVar[ElementFamily] = ... + serendipity: ClassVar[ElementFamily] = ... + def __init__(self, value: int) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> None: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class FiniteElement: + def __hash__(self, object, int): ClassVar[None] = ... + def __init__(self, *args, **kwargs) -> None: ... + def apply_dof_transformation(self, arg0: npt.NDArray[numpy.float64], arg1: int, arg2: int) -> npt.NDArray[numpy.float64]: ... + def apply_dof_transformation_to_transpose(self, arg0: npt.NDArray[numpy.float64], arg1: int, arg2: int) -> npt.NDArray[numpy.float64]: ... + def apply_inverse_transpose_dof_transformation(self, arg0: npt.NDArray[numpy.float64], arg1: int, arg2: int) -> npt.NDArray[numpy.float64]: ... + def base_transformations(self) -> npt.NDArray[numpy.float64]: ... + def entity_transformations(self) -> dict: ... + def get_tensor_product_representation(self) -> List[Tuple[List[FiniteElement],List[int]]]: ... + def pull_back(self, arg0: npt.NDArray[numpy.float64], arg1: npt.NDArray[numpy.float64], arg2: npt.NDArray[numpy.float64], arg3: npt.NDArray[numpy.float64]) -> npt.NDArray[numpy.float64]: ... + def push_forward(self, arg0: npt.NDArray[numpy.float64], arg1: npt.NDArray[numpy.float64], arg2: npt.NDArray[numpy.float64], arg3: npt.NDArray[numpy.float64]) -> npt.NDArray[numpy.float64]: ... + def tabulate(self, arg0: int, arg1: npt.NDArray[numpy.float64]) -> npt.NDArray[numpy.float64]: ... + def __eq__(self, arg0: object) -> bool: ... + @property + def M(self) -> List[List[npt.NDArray[numpy.float64]]]: ... + @property + def cell_type(self) -> CellType: ... + @property + def coefficient_matrix(self) -> npt.NDArray[numpy.float64]: ... + @property + def degree(self) -> int: ... + @property + def dim(self) -> int: ... + @property + def discontinuous(self) -> bool: ... + @property + def dof_transformations_are_identity(self) -> bool: ... + @property + def dof_transformations_are_permutations(self) -> bool: ... + @property + def dpc_variant(self) -> Any: ... + @property + def dual_matrix(self) -> npt.NDArray[numpy.float64]: ... + @property + def entity_closure_dofs(self) -> List[List[List[int]]]: ... + @property + def entity_dofs(self) -> List[List[List[int]]]: ... + @property + def family(self) -> ElementFamily: ... + @property + def has_tensor_product_factorisation(self) -> bool: ... + @property + def highest_complete_degree(self) -> int: ... + @property + def highest_degree(self) -> int: ... + @property + def interpolation_is_identity(self) -> bool: ... + @property + def interpolation_matrix(self) -> npt.NDArray[numpy.float64]: ... + @property + def interpolation_nderivs(self) -> int: ... + @property + def lagrange_variant(self) -> Any: ... + @property + def map_type(self) -> MapType: ... + @property + def num_entity_closure_dofs(self) -> List[List[int]]: ... + @property + def num_entity_dofs(self) -> List[List[int]]: ... + @property + def points(self) -> npt.NDArray[numpy.float64]: ... + @property + def value_shape(self) -> List[int]: ... + @property + def value_size(self) -> int: ... + @property + def wcoeffs(self) -> npt.NDArray[numpy.float64]: ... + @property + def x(self) -> List[List[npt.NDArray[numpy.float64]]]: ... + +class LagrangeVariant: + __members__: ClassVar[dict] = ... # read-only + __entries: ClassVar[dict] = ... + chebyshev_centroid: ClassVar[LagrangeVariant] = ... + chebyshev_isaac: ClassVar[LagrangeVariant] = ... + chebyshev_warped: ClassVar[LagrangeVariant] = ... + equispaced: ClassVar[LagrangeVariant] = ... + gl_centroid: ClassVar[LagrangeVariant] = ... + gl_isaac: ClassVar[LagrangeVariant] = ... + gl_warped: ClassVar[LagrangeVariant] = ... + gll_centroid: ClassVar[LagrangeVariant] = ... + gll_isaac: ClassVar[LagrangeVariant] = ... + gll_warped: ClassVar[LagrangeVariant] = ... + legendre: ClassVar[LagrangeVariant] = ... + unset: ClassVar[LagrangeVariant] = ... + vtk: ClassVar[LagrangeVariant] = ... + def __init__(self, value: int) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> None: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class LatticeSimplexMethod: + __members__: ClassVar[dict] = ... # read-only + __entries: ClassVar[dict] = ... + centroid: ClassVar[LatticeSimplexMethod] = ... + isaac: ClassVar[LatticeSimplexMethod] = ... + none: ClassVar[LatticeSimplexMethod] = ... + warp: ClassVar[LatticeSimplexMethod] = ... + def __init__(self, value: int) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> None: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class LatticeType: + __members__: ClassVar[dict] = ... # read-only + __entries: ClassVar[dict] = ... + chebyshev: ClassVar[LatticeType] = ... + equispaced: ClassVar[LatticeType] = ... + gl: ClassVar[LatticeType] = ... + gll: ClassVar[LatticeType] = ... + def __init__(self, value: int) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> None: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class MapType: + __members__: ClassVar[dict] = ... # read-only + L2Piola: ClassVar[MapType] = ... + __entries: ClassVar[dict] = ... + contravariantPiola: ClassVar[MapType] = ... + covariantPiola: ClassVar[MapType] = ... + doubleContravariantPiola: ClassVar[MapType] = ... + doubleCovariantPiola: ClassVar[MapType] = ... + identity: ClassVar[MapType] = ... + def __init__(self, value: int) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> None: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class PolynomialType: + __members__: ClassVar[dict] = ... # read-only + __entries: ClassVar[dict] = ... + legendre: ClassVar[PolynomialType] = ... + def __init__(self, value: int) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> None: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +class QuadratureType: + __members__: ClassVar[dict] = ... # read-only + Default: ClassVar[QuadratureType] = ... + __entries: ClassVar[dict] = ... + gauss_jacobi: ClassVar[QuadratureType] = ... + gll: ClassVar[QuadratureType] = ... + xiao_gimbutas: ClassVar[QuadratureType] = ... + def __init__(self, value: int) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + def __ne__(self, other: object) -> bool: ... + def __setstate__(self, state: int) -> None: ... + @property + def name(self) -> str: ... + @property + def value(self) -> int: ... + +def cell_facet_jacobians(arg0: CellType) -> npt.NDArray[numpy.float64]: ... +def cell_facet_normals(arg0: CellType) -> npt.NDArray[numpy.float64]: ... +def cell_facet_orientations(arg0: CellType) -> List[bool]: ... +def cell_facet_outward_normals(arg0: CellType) -> npt.NDArray[numpy.float64]: ... +def cell_facet_reference_volumes(arg0: CellType) -> npt.NDArray[numpy.float64]: ... +def cell_volume(arg0: CellType) -> float: ... +def compute_interpolation_operator(arg0: FiniteElement, arg1: FiniteElement) -> npt.NDArray[numpy.float64]: ... +def create_custom_element(arg0: CellType, arg1: List[int], arg2: npt.NDArray[numpy.float64], arg3: List[List[npt.NDArray[numpy.float64]]], arg4: List[List[npt.NDArray[numpy.float64]]], arg5: int, arg6: MapType, arg7: bool, arg8: int, arg9: int) -> FiniteElement: ... +@overload +def create_element(arg0: ElementFamily, arg1: CellType, arg2: int, arg3: bool) -> FiniteElement: ... +@overload +def create_element(arg0: ElementFamily, arg1: CellType, arg2: int, arg3: LagrangeVariant, arg4: bool) -> FiniteElement: ... +@overload +def create_element(arg0: ElementFamily, arg1: CellType, arg2: int, arg3: DPCVariant, arg4: bool) -> FiniteElement: ... +@overload +def create_element(arg0: ElementFamily, arg1: CellType, arg2: int, arg3: LagrangeVariant, arg4: DPCVariant, arg5: bool) -> FiniteElement: ... +@overload +def create_element(arg0: ElementFamily, arg1: CellType, arg2: int) -> FiniteElement: ... +@overload +def create_element(arg0: ElementFamily, arg1: CellType, arg2: int, arg3: LagrangeVariant) -> FiniteElement: ... +@overload +def create_element(arg0: ElementFamily, arg1: CellType, arg2: int, arg3: DPCVariant) -> FiniteElement: ... +@overload +def create_element(arg0: ElementFamily, arg1: CellType, arg2: int, arg3: LagrangeVariant, arg4: DPCVariant) -> FiniteElement: ... +@overload +def create_lattice(arg0, arg1: int, arg2: LatticeType, arg3: bool) -> npt.NDArray[numpy.float64]: ... +@overload +def create_lattice(arg0, arg1: int, arg2: LatticeType, arg3: bool, arg4: LatticeSimplexMethod) -> npt.NDArray[numpy.float64]: ... +def geometry(arg0) -> npt.NDArray[numpy.float64]: ... +@overload +def index(arg0: int) -> int: ... +@overload +def index(arg0: int, arg1: int) -> int: ... +@overload +def index(arg0: int, arg1: int, arg2: int) -> int: ... +@overload +def make_quadrature(arg0: QuadratureType, arg1: CellType, arg2: int) -> Tuple[npt.NDArray[numpy.float64],npt.NDArray[numpy.float64]]: ... +@overload +def make_quadrature(arg0: CellType, arg1: int) -> Tuple[npt.NDArray[numpy.float64],npt.NDArray[numpy.float64]]: ... +def sub_entity_connectivity(arg0) -> List[List[List[List[int]]]]: ... +def sub_entity_geometry(arg0, arg1: int, arg2: int) -> npt.NDArray[numpy.float64]: ... +def tabulate_polynomial_set(arg0: CellType, arg1: int, arg2: int, arg3: npt.NDArray[numpy.float64]) -> npt.NDArray[numpy.float64]: ... +def tabulate_polynomials(arg0: PolynomialType, arg1, arg2: int, arg3: npt.NDArray[numpy.float64]) -> npt.NDArray[numpy.float64]: ... +@overload +def topology(arg0) -> List[List[List[int]]]: ... +@overload +def topology(vertexindices) -> Any: ... diff --git a/python/basix/py.typed b/python/basix/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/python/basix/quadrature.py b/python/basix/quadrature.py index 4b689aa7e..0cf442c58 100644 --- a/python/basix/quadrature.py +++ b/python/basix/quadrature.py @@ -19,8 +19,8 @@ def string_to_type(rule: str) -> _QT: return _QT.gll if rule in ["Gauss-Legendre", "GL", "Gauss-Jacobi"]: return _QT.gauss_jacobi - if rule == "Xiao-Gambutas": - return _QT.xiao_gambutas + if rule == "Xiao-Gimbutas": + return _QT.xiao_gimbutas if not hasattr(_QT, rule): raise ValueError(f"Unknown quadrature rule: {rule}") diff --git a/python/setup.py b/python/setup.py index f0e68e795..1f294fab8 100644 --- a/python/setup.py +++ b/python/setup.py @@ -82,6 +82,8 @@ def build_extension(self, ext): classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f], platforms=["Linux", "Mac OS-X", "Unix"], packages=["basix"], + install_requires=["numpy>=1.21"], + package_data={"basix": ["py.typed"]}, setup_requires=["pybind11"], ext_modules=[CMakeExtension('basix._basixcpp')], cmdclass=dict(build_ext=CMakeBuild), diff --git a/setup.py b/setup.py index 5e9ec6240..1cac33e16 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,8 @@ maintainer_email="fenics-dev@googlegroups.com", license="MIT", packages=["basix"], - install_requires=["numpy"], + package_data={"basix": ["py.typed"]}, + install_requires=["numpy>=1.21"], extras_require={ "docs": ["markdown", "pylit3", "pyyaml", "sphinx", "sphinx_rtd_theme"], "lint": ["flake8", "pydocstyle"],