Skip to content

Commit

Permalink
Merge pull request #262 from GEOUNED-org/dev
Browse files Browse the repository at this point in the history
Update main branch
  • Loading branch information
psauvan authored Aug 7, 2024
2 parents f7f4279 + a538c8d commit 8cccf75
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
publish_dir: _build
# with next rlease of actions-gh-pages
# issue to allow force_orphan will be fixed
# https://github.com/peaceiris/actions-gh-pages/issues/455
Expand Down
35 changes: 25 additions & 10 deletions docs/developer_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ Checkout feature branches from dev and make local changes on you own branch
Pull requests are welcome

Keeping your fork tags up to date
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note that your fork of the repository should have releases tags which conform to PEP440 i.e. semantic versioning.
When installing, setuptools uses these tags to get the version of GEOUNED.
Release versions in the central repository conform to this standard.
You can keep the tags in your fork up to date with the main repository using:

.. code-block:: sh
git fetch --tags https://github.com/GEOUNED-org/GEOUNED
Building the docs locally
~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -168,7 +181,14 @@ Tests checking the code will run automatically on the pull request.

If the tests pass and at least one approver approves then the pull request can be merged.

When a pull request is ready to be merged then the pull request should be **squashed** and merged into the dev branch.
When updating the dev branch from a feature branch then a pull request is should be merged in with the **squashed and merged*** option.

When updating the main branch from the dev branch then the pull request should be merged in with the **create a merge commit** option.

Version numbering
~~~~~~~~~~~~~~~~~

GEOUNED will use Semantic Versioning to number releases of the tool, in the form "Major.Minor.Patch", e.g., “3.15.9”.

Releasing a new version
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -214,7 +234,7 @@ For example adding version 1.2.3 would look like this
Then create a `pull request from dev branch to main branch <https://github.com/GEOUNED-org/GEOUNED/compare/main...dev>`_

Once the tests for this pass then merge the pull request in. **Do not squash** this pull request as we want to keep the history of the version changes.
Once the tests for this pass then merge the pull request in. Use the **create a merge commit** option when merging this pull request from dev to main.

Then `create a new release on the main branch <https://github.com/shimwell/GEOUNED/releases/new>`_ with the version number and a description of the changes.

Expand All @@ -235,17 +255,12 @@ Conda Forge Releasing

The conda-forge package release is done after the PyPI release. This is because the conda-forge package is built from the PyPI package.

Conda Forge has a bot thew generates a pull request to update the conda-forge recipe. This is done automatically when the PyPI package is released.
Conda Forge has a bot that generates a pull request to update the conda-forge recipe. This is done automatically when the PyPI package is released.

The pull request will be generated in the `conda-forge/GEOUNED-feedstock <https://github.com/conda-forge/geouned-feedstock/pulls>`_ repository.
The pull request will be generated in the `conda-forge/GEOUNED-feedstock <https://github.com/conda-forge/geouned-feedstock/pulls>`_ repository a short while after the PyPI release.

Check the pull request and if the tests pass then merge the pull request.

A Conda Forge package will be built and released to the conda-forge channel.

Once released the package will be visaible on the `conda-forge channel <https://anaconda.org/conda-forge/geouned>`_.

Version Numbering
~~~~~~~~~~~~~~~~~

GEOUNED will use Semantic Versioning to number releases of the tool, in the form "Major.Minor.Patch", e.g., “3.15.9”.
Once released the package will be visible on the `conda-forge channel <https://anaconda.org/conda-forge/geouned>`_.
10 changes: 0 additions & 10 deletions docs/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,7 @@ Currently the Mamba / Conda install is the recommended method.
The main complication when installing GEOUNED is integration between the main dependency (FreeCAD) and the users system Python.
Mamba / Conda provides a connection between the FreeCAD Python library and your system Python.
Users have also had success installing FreeCAD and making use of the Python version inbuilt into FreeCAD and the freecad.cmd however the integration of FrreCAD with the system Python is more challenging when installing in this manner.
.. TODO as well so these installation methods are listed for completeness.

Note that your fork of the repostory must have releases which conform to PEP440 i.e. semantic versioning. When installing, setuptools
uses these tags to get the release number of GEOUNED. Release versions in the central repository now conform to this standard and can be reflected in your
fork using:

.. code-block:: sh
git fetch --tags upstream
where upstream is the remote url of the original repository.

.. toctree::
:numbered:
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/python_cadtocsg_api_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following example shows a usage with every attributes specified.
matFile="",
voidGen=True,
debug=False,
compSolids=True,
compSolids=False,
simplify="no",
exportSolids="",
minVoidSize=200.0,
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/python_cadtocsg_cli_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Here is a complete JSON file specification
"matFile": "",
"voidGen": true,
"debug": false,
"compSolids": true,
"compSolids": false,
"simplify": "no",
"exportSolids": "",
"minVoidSize": 200.0,
Expand Down
5 changes: 1 addition & 4 deletions src/geouned/GEOUNED/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ def from_json(cls, filename: str):

cad_to_csg = cls()

cad_to_csg.load_step_file(**config["load_step_file"])

for key in config.keys():

if key in ["load_step_file", "export_csg"]:
Expand All @@ -254,6 +252,7 @@ def from_json(cls, filename: str):
f"Invalid key '{key}' found in config file {filename}. Acceptable key names are 'load_step_file', 'export_csg', 'Settings', 'Parameters', 'Tolerances' and 'NumericFormat'"
)

cad_to_csg.load_step_file(**config["load_step_file"])
cad_to_csg.start()
if "export_csg" in config.keys():
cad_to_csg.export_csg(**config["export_csg"])
Expand Down Expand Up @@ -352,8 +351,6 @@ def _get_geometry_bounding_box(self, padding: float = 10.0):
"""
# set up Universe
meta_list = self.meta_list
if self.enclosure_list:
meta_list += self.enclosure_list

Box = meta_list[0].BoundBox
xmin = Box.XMin
Expand Down
6 changes: 6 additions & 0 deletions src/geouned/GEOUNED/utils/boolean_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def append(self, *seq):
- A BoolSequence object
- An integer value
- A Boolean value"""

if type(self.elements) is bool:
if (self.elements and self.operator == "AND") or (not self.elements and self.operator == "OR"):
self.assign(seq)
return

for s in seq:
if type(s) is int:
level = -1
Expand Down
18 changes: 13 additions & 5 deletions src/geouned/GEOUNED/utils/data_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ class Settings:
that solids defined has separated solids are read by FreeCAD
as a single compound solid (and will produce only one MCNP
cell). In this case compSolids should be set to False. Defaults
to True.
to False.
simplify (str, optional): Simplify the cell definition considering
relative surfaces position and using Boolean logics. Available
options are: "no" no optimization, "void" only void cells are
Expand Down Expand Up @@ -641,7 +641,7 @@ def __init__(
matFile: str = "",
voidGen: bool = True,
debug: bool = False,
compSolids: bool = True,
compSolids: bool = False,
simplify: str = "no",
exportSolids: typing.Optional[str] = None,
minVoidSize: float = 200.0, # units mm
Expand Down Expand Up @@ -769,9 +769,17 @@ def voidMat(self):
def voidMat(self, voidMat: list):
if not isinstance(voidMat, list):
raise TypeError(f"geouned.Settings.voidMat should be a list, not a {type(voidMat)}")
for entry in voidMat:
if not isinstance(entry, int):
raise TypeError(f"geouned.Settings.voidMat should be a list of ints, not a {type(entry)}")
if len(voidMat) == 3:
entry0, entry1, entry2 = voidMat
if not isinstance(entry0, int):
raise TypeError(f"first entry of geouned.Settings.voidMat should be an int, not a {type(entry0)}")
if not isinstance(entry1, int):
if not isinstance(entry1, float):
raise TypeError(f"second entry of geouned.Settings.voidMat should be an int or float, not a {type(entry1)}")
if not isinstance(entry2, str):
raise TypeError(f"third entry of geouned.Settings.voidMat should be a str, not a {type(entry2)}")
elif len(voidMat) > 0:
raise TypeError(f"geouned.Settings.voidMat should be a list with 3 elements or void list")
self._voidMat = voidMat

@property
Expand Down
4 changes: 2 additions & 2 deletions src/geouned/GEOUNED/void/void.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def void_generation(
# Perform enclosure void
# Loop until the lowest enclosure level

for i, Level in enumerate(tqdm(NestedEnclosure, desc="Void generation")):
for i, Level in enumerate(NestedEnclosure):

logger.info("Build Void highest enclosure")
for j, encl in enumerate(Level):
Expand Down Expand Up @@ -130,7 +130,7 @@ def get_void_def(
nvoid = len(Initial)
logger.info("Loop, Box to Split :{iloop}, {nvoid}")

for iz, z in enumerate(Initial):
for iz, z in enumerate(tqdm(Initial, desc=f"Void Generation Loop: {iloop}")):
nsurfaces, nbrackets = z.get_numbers()
logger.info(f"{iloop} {iz + 1}/{nvoid} {nsurfaces} {nbrackets}")

Expand Down
2 changes: 1 addition & 1 deletion src/geouned/GEOUNED/void/void_box_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, MetaSolids, Enclosure):
self.BoundBox = Enclosure
self.PieceEnclosure = None
else:
self.BoundBox = Enclosure.BoundBox
self.BoundBox = Enclosure.optimalBoundingBox()
self.PieceEnclosure = Enclosure

for m in MetaSolids:
Expand Down
27 changes: 15 additions & 12 deletions src/geouned/GEOUNED/write/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ def mcnp_surface(id, Type, surf, options, tolerances, numeric_format):
A = surf.Axis.x
B = surf.Axis.y
C = surf.Axis.z
D = surf.Axis.dot(surf.Position)
if surf.Axis.isEqual(FreeCAD.Vector(1, 0, 0), tolerances.pln_angle):
mcnp_def = "{:<6d} PX {:{x}}".format(id, D / 10.0, x=numeric_format.P_xyz)
mcnp_def = "{:<6d} PX {:{x}}".format(id, surf.Position.x / 10.0, x=numeric_format.P_xyz)
elif surf.Axis.isEqual(FreeCAD.Vector(0, 1, 0), tolerances.pln_angle):
mcnp_def = "{:<6d} PY {:{y}}".format(id, D / 10.0, y=numeric_format.P_xyz)
mcnp_def = "{:<6d} PY {:{y}}".format(id, surf.Position.y / 10.0, y=numeric_format.P_xyz)
elif surf.Axis.isEqual(FreeCAD.Vector(0, 0, 1), tolerances.pln_angle):
mcnp_def = "{:<6d} PZ {:{z}}".format(id, D / 10.0, z=numeric_format.P_xyz)
mcnp_def = "{:<6d} PZ {:{z}}".format(id, surf.Position.z / 10.0, z=numeric_format.P_xyz)
else:
D = surf.Axis.dot(surf.Position)
mcnp_def = "{:<6d} P {:{abc}} {:{abc}} {:{abc}} {:{d}}".format(
id,
A,
Expand Down Expand Up @@ -493,8 +493,8 @@ def open_mc_surface(Type, surf, tolerances, numeric_format, out_xml=True, quadri
A = surf.Axis.x
B = surf.Axis.y
C = surf.Axis.z
D = surf.Axis.dot(surf.Position) * 0.1
if surf.Axis.isEqual(FreeCAD.Vector(1, 0, 0), tolerances.pln_angle):
D = surf.Position.x * 0.1
if out_xml:
omc_surf = "x-plane"
coeffs = "{:{x}}".format(D, x=numeric_format.P_xyz)
Expand All @@ -503,6 +503,7 @@ def open_mc_surface(Type, surf, tolerances, numeric_format, out_xml=True, quadri
coeffs = f"x0={D}"

elif surf.Axis.isEqual(FreeCAD.Vector(0, 1, 0), tolerances.pln_angle):
D = surf.Position.y * 0.1
if out_xml:
omc_surf = "y-plane"
coeffs = "{:{x}}".format(D, x=numeric_format.P_xyz)
Expand All @@ -511,6 +512,7 @@ def open_mc_surface(Type, surf, tolerances, numeric_format, out_xml=True, quadri
coeffs = f"y0={D}"

elif surf.Axis.isEqual(FreeCAD.Vector(0, 0, 1), tolerances.pln_angle):
D = surf.Position.z * 0.1
if out_xml:
omc_surf = "z-plane"
coeffs = "{:{x}}".format(D, x=numeric_format.P_xyz)
Expand All @@ -519,6 +521,7 @@ def open_mc_surface(Type, surf, tolerances, numeric_format, out_xml=True, quadri
coeffs = f"z0={D}"

else:
D = surf.Axis.dot(surf.Position) * 0.1
if out_xml:
omc_surf = "plane"
coeffs = "{:{abc}} {:{abc}} {:{abc}} {:{d}}".format(A, B, C, D, abc=numeric_format.P_abc, d=numeric_format.P_d)
Expand Down Expand Up @@ -727,11 +730,11 @@ def serpent_surface(id, Type, surf, options, tolerance, numeric_format):
C = surf.Axis.z
D = surf.Axis.dot(surf.Position)
if surf.Axis.isEqual(FreeCAD.Vector(1, 0, 0), tolerance.pln_angle):
serpent_def = f"surf {id} px {D/10:{numeric_format.P_xyz}}"
serpent_def = f"surf {id} px {surf.Position.x/10:{numeric_format.P_xyz}}"
elif surf.Axis.isEqual(FreeCAD.Vector(0, 1, 0), tolerance.pln_angle):
serpent_def = f"surf {id} py {D/10:{numeric_format.P_xyz}}"
serpent_def = f"surf {id} py {surf.Position.y/10:{numeric_format.P_xyz}}"
elif surf.Axis.isEqual(FreeCAD.Vector(0, 0, 1), tolerance.pln_angle):
serpent_def = f"surf {id} pz {D/10:{numeric_format.P_xyz}}"
serpent_def = f"surf {id} pz {surf.Position.z/10:{numeric_format.P_xyz}}"
else:
serpent_def = f"surf {id} plane {A:{numeric_format.P_d}} {B:{numeric_format.P_d}} {C:{numeric_format.P_d}} {D/10:{numeric_format.P_d}}"

Expand Down Expand Up @@ -869,14 +872,14 @@ def phits_surface(id, Type, surf, options, tolerance, numeric_format):
A = surf.Axis.x
B = surf.Axis.y
C = surf.Axis.z
D = surf.Axis.dot(surf.Position)
if surf.Axis.isEqual(FreeCAD.Vector(1, 0, 0), tolerance.pln_angle):
phits_def = "{:<6d} PX {:{x}}".format(id, D / 10.0, x=numeric_format.P_xyz)
phits_def = "{:<6d} PX {:{x}}".format(id, surf.Position.x / 10.0, x=numeric_format.P_xyz)
elif surf.Axis.isEqual(FreeCAD.Vector(0, 1, 0), tolerance.pln_angle):
phits_def = "{:<6d} PY {:{y}}".format(id, D / 10.0, y=numeric_format.P_xyz)
phits_def = "{:<6d} PY {:{y}}".format(id, surf.Position.y / 10.0, y=numeric_format.P_xyz)
elif surf.Axis.isEqual(FreeCAD.Vector(0, 0, 1), tolerance.pln_angle):
phits_def = "{:<6d} PZ {:{z}}".format(id, D / 10.0, z=numeric_format.P_xyz)
phits_def = "{:<6d} PZ {:{z}}".format(id, surf.Position.z / 10.0, z=numeric_format.P_xyz)
else:
D = surf.Axis.dot(surf.Position)
phits_def = "{:<6d} P {:{abc}} {:{abc}} {:{abc}} {:{d}}".format(
id,
A,
Expand Down
2 changes: 1 addition & 1 deletion tests/config_cadtocsg_complete_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"matFile": "",
"voidGen": true,
"debug": false,
"compSolids": true,
"compSolids": false,
"simplify": "no",
"exportSolids": "",
"minVoidSize": 200.0,
Expand Down
5 changes: 3 additions & 2 deletions tests/config_cadtocsg_non_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"P_abc": "15.7e"
},
"Settings": {
"matFile": "non default"
"matFile": "non default",
"voidMat": [1, -1.29E-3, "Dry air"]
}
}
}
2 changes: 1 addition & 1 deletion tests/test_cadtocsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_conversion(input_step_file):
matFile="",
voidGen=True,
debug=False,
compSolids=True,
compSolids=False,
simplify="no",
exportSolids="",
minVoidSize=200.0, # units mm
Expand Down

0 comments on commit 8cccf75

Please sign in to comment.