Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into radau
Browse files Browse the repository at this point in the history
  • Loading branch information
rckirby committed Apr 29, 2020
2 parents d4a0b13 + 4ca7e9a commit b33bc07
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- checkout
- run:
name: Install dependencies # Install with sudo as tests not run as superuser in circleci/python
command: sudo pip install flake8 pytest pytest-cases pydocstyle numpy sympy coverage coveralls --upgrade
command: sudo pip install flake8 pytest pydocstyle numpy sympy coverage coveralls --upgrade
- run:
name: Install FIAT
command: pip install . --user
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will install Python dependencies, run tests and lint
# with a single version of Python For more information see:
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: FIAT

on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8
run: |
pip install flake8
flake8 --statistics .
- name: Check documentation style
run: |
pip install pydocstyle
python -m pydocstyle .
- name: Install FIAT
run: pip install .
- name: Test with pytest
run: |
pip install pytest
DATA_REPO_GIT="" pytest -v test/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ python:

before_install:
- pip install flake8
- pip install pytest pytest-cases
- pip install pytest

install:
- pip install .
Expand Down
5 changes: 3 additions & 2 deletions FIAT/quadrature_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class QuadratureElement(FiniteElement):
"""A set of quadrature points pretending to be a finite element."""

def __init__(self, ref_el, points):
def __init__(self, ref_el, points, weights=None):
# Create entity dofs.
entity_dofs = {dim: {entity: [] for entity in entities}
for dim, entities in ref_el.get_topology().items()}
Expand All @@ -33,7 +33,8 @@ def __init__(self, ref_el, points):
dual = DualSet(nodes, ref_el, entity_dofs)

super(QuadratureElement, self).__init__(ref_el, dual, order=None)
self._points = points # save the quadrature points
self._points = points # save the quadrature points & weights
self._weights = weights

def value_shape(self):
"The QuadratureElement is scalar valued"
Expand Down
2 changes: 1 addition & 1 deletion bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pipelines:
- apt-get install -y
git python3-minimal python3-pip python3-setuptools python3-wheel
--no-install-recommends
- pip3 install flake8 pytest pytest-cases
- pip3 install flake8 pytest
- pip3 install .
- python3 -m flake8
- DATA_REPO_GIT="" python3 -m pytest -v test/
41 changes: 31 additions & 10 deletions test/unit/test_quadrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import numpy
import pytest
from pytest_cases import pytest_parametrize_plus, fixture_ref
import FIAT
from FIAT.reference_element import UFCInterval, UFCTriangle, UFCTetrahedron
from FIAT.reference_element import UFCQuadrilateral, UFCHexahedron, TensorProductCell
Expand Down Expand Up @@ -50,6 +49,22 @@ def hexahedron():
return UFCHexahedron()


# This unified fixture enables tests parametrised over different cells.
@pytest.fixture(params=["interval",
"triangle",
"quadrilateral",
"hexahedron"])
def cell(request):
if request.param == "interval":
return UFCInterval()
elif request.param == "triangle":
return UFCTriangle()
elif request.param == "quadrilateral":
return UFCTriangle()
elif request.param == "hexahedron":
return UFCTriangle()


@pytest.fixture(scope='module')
def extr_interval():
"""Extruded interval = interval x interval"""
Expand All @@ -68,6 +83,19 @@ def extr_quadrilateral():
return TensorProductCell(UFCQuadrilateral(), UFCInterval())


# This unified fixture enables tests parametrised over different extruded cells.
@pytest.fixture(params=["extr_interval",
"extr_triangle",
"extr_quadrilateral"])
def extr_cell(request):
if request.param == "extr_interval":
return TensorProductCell(UFCInterval(), UFCInterval())
elif request.param == "extr_triangle":
return TensorProductCell(UFCTriangle(), UFCInterval())
elif request.param == "extr_quadrilateral":
return TensorProductCell(UFCQuadrilateral(), UFCInterval())


@pytest.fixture(params=["canonical", "default"])
def scheme(request):
return request.param
Expand Down Expand Up @@ -135,21 +163,14 @@ def test_create_quadrature_extr_quadrilateral(extr_quadrilateral, basedeg, extrd
(2**(basedeg + 2) - 2) / ((basedeg + 1)*(basedeg + 2)) * 1/(extrdeg + 1))


@pytest_parametrize_plus("cell", [fixture_ref(interval),
fixture_ref(triangle),
fixture_ref(tetrahedron),
fixture_ref(quadrilateral)])
def test_invalid_quadrature_degree(cell, scheme):
with pytest.raises(ValueError):
FIAT.create_quadrature(cell, -1, scheme)


@pytest_parametrize_plus("cell", [fixture_ref(extr_interval),
fixture_ref(extr_triangle),
fixture_ref(extr_quadrilateral)])
def test_invalid_quadrature_degree_tensor_prod(cell):
def test_invalid_quadrature_degree_tensor_prod(extr_cell):
with pytest.raises(ValueError):
FIAT.create_quadrature(cell, (-1, -1))
FIAT.create_quadrature(extr_cell, (-1, -1))


def test_tensor_product_composition(interval, triangle, extr_triangle, scheme):
Expand Down

0 comments on commit b33bc07

Please sign in to comment.