Skip to content

Commit

Permalink
Merge pull request #254 from fusion-energy/develop
Browse files Browse the repository at this point in the history
General updates from development branch
  • Loading branch information
shimwell authored Aug 13, 2022
2 parents 4366a23 + 776ed13 commit 5bb7786
Show file tree
Hide file tree
Showing 138 changed files with 340 additions and 358 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ jobs:
- install
- run:
name: run utils tests
command: pytest tests/test_utils.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
command: pytest tests/tests_units/test_utils.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
- run:
name: run shape tests
command: pytest tests/test_shape.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
command: pytest tests/tests_units/test_shape.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
- run:
name: run Reactor tests
command: pytest tests/test_reactor.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
command: pytest tests/tests_units/test_reactor.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
- run:
name: run parametric_shapes tests
command: pytest tests/test_parametric_shapes/ -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
command: pytest tests/tests_units/test_parametric_shapes/ -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
- store_test_results:
path: test-reports
- store_artifacts:
Expand All @@ -64,7 +64,7 @@ jobs:
name: run parametric_components tests
command: |
set -e
TEST_FILES=$(circleci tests glob "tests/test_parametric_components/**/*.py" | circleci tests split)
TEST_FILES=$(circleci tests glob "tests/tests_units/test_parametric_components/**/*.py" | circleci tests split)
pytest -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml $TEST_FILES
- store_test_results:
path: test-reports
Expand All @@ -83,7 +83,7 @@ jobs:
name: run parametric_reactors tests
command: |
set -e
TEST_FILES=$(circleci tests glob "tests/test_parametric_reactors/**/*.py" | circleci tests split)
TEST_FILES=$(circleci tests glob "tests/tests_units/test_parametric_reactors/**/*.py" | circleci tests split)
pytest -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml $TEST_FILES
- store_test_results:
path: test-reports
Expand All @@ -100,7 +100,7 @@ jobs:
- install
- run:
name: run utils tests
command: pytest tests_h5m -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
command: pytest tests/tests_h5m -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
- store_test_results:
path: test-reports
- store_artifacts:
Expand All @@ -116,7 +116,7 @@ jobs:
- install
- run:
name: run utils tests
command: pytest tests_show -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
command: pytest tests/tests_show -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml
- store_test_results:
path: test-reports
- store_artifacts:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/anaconda-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ jobs:
apt install -y libgl1-mesa-glx
conda install -y anaconda-client conda-build
conda config --set anaconda_upload no
conda install boa -c conda-forge
- name: Build and publish to conda
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
conda mambabuild conda -c fusion-energy -c cadquery -c conda-forge --config-file conda/conda_build_config.yaml
conda build conda -c fusion-energy -c cadquery -c conda-forge --config-file conda/conda_build_config.yaml
conda convert /opt/conda/conda-bld/linux-64/*.tar.bz2 --platform osx-64 --platform win-64 -o /opt/conda/conda-bld/
anaconda upload -f /opt/conda/conda-bld/*/*.tar.bz2
10 changes: 5 additions & 5 deletions .github/workflows/ci_with_docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -26,13 +26,13 @@ jobs:
run: docker build -t paramak --build-arg cq_version=master .

- name: Run unit tests
run: docker run --rm paramak pytest ./tests
run: docker run --rm paramak pytest ./tests/tests_units

- name: Test examples
run: docker run --rm paramak pytest ./tests_examples
run: docker run --rm paramak pytest ./tests/tests_examples

# tests_show require jupyter_cadquery which is not available on conda
# therefore these tests have been separated out to help with the conda
# testing. The tests_h5m tests require CQ master which is tested elsewhere
# testing. The tests_h5m tests require CQ master which is tested separately as well
- name: Test show
run: docker run --rm paramak pytest ./tests_show
run: docker run --rm paramak pytest ./tests/tests_show
8 changes: 4 additions & 4 deletions .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This CI will lauch a Docker image that contains all the dependencies required
# within that image the pytest test suite is run
# within that image the pytest test suite is run

name: CI with install

Expand Down Expand Up @@ -37,9 +37,9 @@ jobs:
- name: Run tests
run: |
pytest tests -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests_examples -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests_show -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests/tests_units -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests/tests_examples -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests/tests_show -v --cov=paramak --cov-append --cov-report term --cov-report xml
- name: Upload to codecov
uses: codecov/codecov-action@v2
8 changes: 4 additions & 4 deletions .github/workflows/ci_with_install_cq_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:
- name: Run tests
run: |
pytest tests -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests_h5m -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests/test_units -v --cov=paramak --cov-append --cov-report term --cov-report xml
pytest tests/tests_h5m -v --cov=paramak --cov-append --cov-report term --cov-report xml
# jupyter cadquery doesn't appear to work with the current version of CQ master
# therefore the show() methods also don't work
# pytest tests_show -v --cov=paramak --cov-append --cov-report term --cov-report xml
# pytest tests_examples -v --cov=paramak --cov-append --cov-report term --cov-report xml
# pytest tests/tests_show -v --cov=paramak --cov-append --cov-report term --cov-report xml
# pytest tests/tests_examples -v --cov=paramak --cov-append --cov-report term --cov-report xml

- name: Upload to codecov
uses: codecov/codecov-action@v2
3 changes: 1 addition & 2 deletions .github/workflows/conda-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ jobs:
apt install -y libgl1-mesa-glx
conda install -y anaconda-client conda-build
conda config --set anaconda_upload no
conda install boa -c conda-forge
- name: Build and test
env:
GIT_DESCRIBE_TAG: 0.1
run: |
conda mambabuild conda -c fusion-energy -c cadquery -c conda-forge --config-file conda/conda_build_config.yaml
conda build conda -c fusion-energy -c cadquery -c conda-forge --config-file conda/conda_build_config.yaml
2 changes: 1 addition & 1 deletion .github/workflows/test_demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
- name: Run the notebooks
run: |
pytest tests_examples -v
pytest tests/tests_examples -v
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ COPY paramak paramak/
COPY examples examples/

COPY tests tests/
COPY tests_h5m tests_h5m/
COPY tests_show tests_show/
COPY tests_examples tests_examples/

COPY setup.py setup.py
COPY setup.cfg setup.cfg
Expand Down
16 changes: 8 additions & 8 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ requirements:
- plotly
- brep_part_finder >=0.4.1 # [not win]
- brep_to_h5m >=0.3.1 # [not win]
- moab * nompi_tempest_*
# - jupyter-cadquery not available on conda

test:
Expand All @@ -32,20 +33,19 @@ test:
- paramak.parametric_components
- paramak.parametric_reactors
- paramak.parametric_shapes
- tests
requires:
- pytest
- dagmc_h5m_file_inspector # [not win]
source_files:
- tests/
- tests/tests_units
- examples/
- tests_h5m/ # [not win]
# - tests_examples/ # TODO include if cadquery_jupyter gets a conda install
- tests/tests_h5m/ # [not win]
# - tests/tests_examples/ # TODO include if cadquery_jupyter gets a conda install
commands:
- pytest -v tests_h5m # [not win]
- pytest -v tests
# - pytest -v tests_show # TODO include if cadquery_jupyter gets a conda install
# - pytest -v tests_examples # TODO include if cadquery_jupyter gets a conda install
- pytest -v tests/tests_h5m # [not win]
- pytest -v tests/tests_units
# - pytest -v tests/tests_show # TODO include if cadquery_jupyter gets a conda install
# - pytest -v tests/tests_examples # TODO include if cadquery_jupyter gets a conda install

about:
home: "https://github.com/fusion-energy/paramak"
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
- matplotlib
- pillow
- plasmaboundaries
- pip
- pip:
- sympy
- sphinx-autodoc-typehints
Expand Down
4 changes: 3 additions & 1 deletion paramak/parametric_components/blanket_cutter_parallels.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterable, Union

from paramak import ExtrudeStraightShape
from paramak.utils import cut_solid

Expand Down Expand Up @@ -28,7 +30,7 @@ def __init__(
gap_size: float,
height: float = 2000.0,
width: float = 2000.0,
azimuth_placement_angle=[
azimuth_placement_angle: Union[float, Iterable[float]] = [
0.0,
36.0,
72.0,
Expand Down
4 changes: 2 additions & 2 deletions paramak/parametric_components/blanket_cutters_star.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Union
from typing import Iterable, Union

from paramak import ExtrudeStraightShape

Expand All @@ -25,7 +25,7 @@ def __init__(
distance: float,
height: float = 2000.0,
width: float = 2000.0,
azimuth_placement_angle: Union[float, List[float]] = [
azimuth_placement_angle: Union[float, Iterable[float]] = [
0.0,
36.0,
72.0,
Expand Down
20 changes: 11 additions & 9 deletions paramak/parametric_components/blanket_fp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import warnings
from typing import Optional, Union
from typing import Optional, Union, Iterable

import mpmath
import numpy as np
Expand All @@ -11,7 +11,9 @@


class BlanketFP(RotateMixedShape):
"""A blanket volume created from plasma parameters.
"""A blanket volume created from plasma parameters. In might be nessecary
to increase the num_points when making long but thin geometry with this
component.
Args:
thickness (float or [float] or callable or [(float), (float)]):
Expand Down Expand Up @@ -47,13 +49,13 @@ def __init__(
start_angle: float,
stop_angle: float,
plasma: Optional[Union[paramak.Plasma, paramak.PlasmaBoundaries, paramak.PlasmaFromPoints]] = None,
minor_radius: Optional[float] = 150.0,
major_radius: Optional[float] = 450.0,
triangularity: Optional[float] = 0.55,
elongation: Optional[float] = 2.0,
vertical_displacement: Optional[float] = 0.0,
offset_from_plasma: Union[float, list] = 0.0,
num_points: Optional[int] = 50,
minor_radius: float = 150.0,
major_radius: float = 450.0,
triangularity: float = 0.55,
elongation: float = 2.0,
vertical_displacement: float = 0.0,
offset_from_plasma: Union[float, Iterable[float]] = 0.0,
num_points: int = 50,
allow_overlapping_shape=False,
**kwargs
):
Expand Down
14 changes: 7 additions & 7 deletions paramak/parametric_components/blanket_poloidal_segment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import warnings
from typing import Callable, List, Optional, Tuple, Union
from typing import Callable, Iterable, Optional, Tuple, Union

import numpy as np
from scipy.optimize import minimize
Expand Down Expand Up @@ -29,8 +29,8 @@ class BlanketFPPoloidalSegments(BlanketFP):

def __init__(
self,
segments_angles: Optional[List[float]] = None,
num_segments: Optional[int] = 7,
segments_angles: Optional[Iterable[float]] = None,
num_segments: int = 7,
length_limits: Optional[Tuple[Union[float, None], Union[float, None]]] = None,
nb_segments_limits: Optional[Tuple[float, float]] = None,
segments_gap: Optional[float] = 0.0,
Expand Down Expand Up @@ -173,14 +173,14 @@ def create_segment_cutters(self):
self.segments_cutters = cutting_shape


def compute_lengths_from_angles(angles: List[float], distribution: Callable):
def compute_lengths_from_angles(angles: Iterable[float], distribution: Callable):
"""Computes the length of segments between a set of points on a (x,y)
distribution.
Args:
angles (list): Contains the angles of the points (degree)
distribution (callable): function taking an angle as argument and
returning (x,y) coordinates.
angles: Contains the angles of the points (degrees)
distribution: function taking an angle as argument and returning (x,y)
coordinates.
Returns:
list: contains the lengths of the segments.
Expand Down
10 changes: 5 additions & 5 deletions paramak/parametric_components/center_column_cylinder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Tuple
from typing import Optional, Tuple, Union

from paramak import RotateStraightShape

Expand Down Expand Up @@ -40,7 +40,7 @@ def center_height(self):
return self._center_height

@center_height.setter
def center_height(self, value):
def center_height(self, value: Union[float, int]):
if not isinstance(value, (int, float)):
msg = f"CenterColumnShieldBlock.center_height should be a float or int. Not a {type(value)}"
raise TypeError(msg)
Expand All @@ -52,7 +52,7 @@ def height(self):
return self._height

@height.setter
def height(self, value):
def height(self, value: float):
if value is None:
raise ValueError("height of the CenterColumnShieldBlock cannot be None")
self._height = value
Expand All @@ -62,7 +62,7 @@ def inner_radius(self):
return self._inner_radius

@inner_radius.setter
def inner_radius(self, value):
def inner_radius(self, value: float):
if hasattr(self, "outer_radius"):
if value >= self.outer_radius:
msg = f"inner_radius ({value}) is larger than outer_radius " "({self.outer_radius})"
Expand All @@ -74,7 +74,7 @@ def outer_radius(self):
return self._outer_radius

@outer_radius.setter
def outer_radius(self, value):
def outer_radius(self, value: float):
if hasattr(self, "inner_radius"):
if value <= self.inner_radius:
msg = f"inner_radius ({self.inner_radius}) is larger than " "outer_radius ({value})"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,31 @@ def arc_height(self):
return self._arc_height

@arc_height.setter
def arc_height(self, arc_height):
def arc_height(self, arc_height: float):
self._arc_height = arc_height

@property
def inner_radius(self):
return self._inner_radius

@inner_radius.setter
def inner_radius(self, inner_radius):
def inner_radius(self, inner_radius: float):
self._inner_radius = inner_radius

@property
def mid_radius(self):
return self._mid_radius

@mid_radius.setter
def mid_radius(self, mid_radius):
def mid_radius(self, mid_radius: float):
self._mid_radius = mid_radius

@property
def outer_radius(self):
return self._outer_radius

@outer_radius.setter
def outer_radius(self, outer_radius):
def outer_radius(self, outer_radius: float):
self._outer_radius = outer_radius

def find_points(self):
Expand Down
Loading

0 comments on commit 5bb7786

Please sign in to comment.