From 21f1fa9581a8a6ce167a3d50eeb4fdec10168a1a Mon Sep 17 00:00:00 2001 From: flothesof Date: Wed, 27 Nov 2019 16:38:46 +0100 Subject: [PATCH 1/6] fix failing unit test due to separator not working on Windows --- tofu/tests/tests09_tutorials/tests01_runall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tofu/tests/tests09_tutorials/tests01_runall.py b/tofu/tests/tests09_tutorials/tests01_runall.py index e20341724..0009660b0 100644 --- a/tofu/tests/tests09_tutorials/tests01_runall.py +++ b/tofu/tests/tests09_tutorials/tests01_runall.py @@ -17,7 +17,7 @@ _HERE = os.path.abspath(os.path.dirname(__file__)) -_TFROOT = _HERE[:-_HERE[::-1].index('/tofu'[::-1])-len('/tofu')] +_TFROOT = os.path.abspath(os.path.join(os.path.dirname(_HERE), os.pardir)) # _TFROOT = tf.__path__[0][:-5] # _PATHTUTO = os.path.join(_TFROOT, 'examples', 'tutorials') keyVers = 'Vers' From a22d50aa49ed9b67ead7c01ff502129320e990d7 Mon Sep 17 00:00:00 2001 From: flothesof Date: Wed, 27 Nov 2019 17:46:12 +0100 Subject: [PATCH 2/6] cleaned up some imports and fixed _TFROOT --- tofu/tests/tests09_tutorials/tests01_runall.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/tofu/tests/tests09_tutorials/tests01_runall.py b/tofu/tests/tests09_tutorials/tests01_runall.py index 0009660b0..5fe4d66a5 100644 --- a/tofu/tests/tests09_tutorials/tests01_runall.py +++ b/tofu/tests/tests09_tutorials/tests01_runall.py @@ -1,25 +1,13 @@ - -# External modules import os import shutil -import types import subprocess -import numpy as np -import warnings as warn import matplotlib.pyplot as plt - -# Nose-specific -from nose import with_setup # optional - -# Importing package tofu.geom -import tofu as tf from tofu import __version__ - +from pathlib import Path _HERE = os.path.abspath(os.path.dirname(__file__)) -_TFROOT = os.path.abspath(os.path.join(os.path.dirname(_HERE), os.pardir)) -# _TFROOT = tf.__path__[0][:-5] -# _PATHTUTO = os.path.join(_TFROOT, 'examples', 'tutorials') +_TFROOT = Path(_HERE).parent.parent.parent + keyVers = 'Vers' From 9b404aac2e0e500a04991074ceb5ca9a71c5dc16 Mon Sep 17 00:00:00 2001 From: VEZINET Didier Date: Thu, 28 Nov 2019 10:38:38 +0100 Subject: [PATCH 3/6] [Issue292] Hotfix by defining updateversion in setup.py and keeping _updateversion.py also --- _updateversion.py | 5 ++--- setup.py | 26 ++++++++++++++++++++++++-- tofu/version.py | 2 +- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/_updateversion.py b/_updateversion.py index d77a0be47..9ae7ad0cc 100644 --- a/_updateversion.py +++ b/_updateversion.py @@ -1,16 +1,15 @@ #!/usr/bin/env/python # coding=utf-8 -import sys import os import subprocess -_HERE = os.path.join(os.path.abspath(os.path.dirname(__file__)),'tofu') +_HERE = os.path.abspath(os.path.dirname(__file__)) def updateversion(path=_HERE): # Fetch version from git tags, and write to version.py # Also, when git is not available (PyPi package), use stored version.py - version_py = os.path.join(path,"version.py") + version_py = os.path.join(path, 'tofu', 'version.py') try: version_git = subprocess.check_output(["git", "describe"]).rstrip().decode() diff --git a/setup.py b/setup.py index 23e3c2e42..2fad01b84 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,10 @@ from Cython.Distutils import build_ext import numpy as np # ... -import _updateversion as up +# Remove _updateversion import due to build-time dependency +# => updateversion defined in here for commodity +# => find a cleaner solution later +# import _updateversion as up # ... for `clean` command from distutils.command.clean import clean as Clean @@ -143,6 +146,25 @@ def check_for_openmp(cc_var): # == Getting tofu version ===================================================== _HERE = os.path.abspath(os.path.dirname(__file__)) + +def updateversion(path=_HERE): + # Fetch version from git tags, and write to version.py + # Also, when git is not available (PyPi package), use stored version.py + version_py = os.path.join(path, 'tofu', 'version.py') + try: + version_git = subprocess.check_output(["git", + "describe"]).rstrip().decode() + except: + with open(version_py,'r') as fh: + version_git = fh.read().strip().split("=")[-1].replace("'",'') + version_git = version_git.lower().replace('v','') + + version_msg = "# Do not edit, pipeline versioning governed by git tags!" + with open(version_py,"w") as fh: + msg = "{0}__version__ = '{1}'{0}".format(os.linesep, version_git) + fh.write(version_msg + msg) + return version_git + def get_version_tofu(path=_HERE): # Try from git @@ -163,7 +185,7 @@ def get_version_tofu(path=_HERE): .decode() ) if git_branch in ["master"]: - version_tofu = up.updateversion(os.path.join(path, "tofu")) + version_tofu = updateversion(os.path.join(path, "tofu")) else: isgit = False except Exception: diff --git a/tofu/version.py b/tofu/version.py index f16ec2709..9c572aae8 100644 --- a/tofu/version.py +++ b/tofu/version.py @@ -1,2 +1,2 @@ # Do not edit, pipeline versioning governed by git tags! -__version__ = '1.4.2-a4' +__version__ = '1.4.2-a4-4-g9531f81' From ff5a3fee329506d4d3ef94a02611e7179217c57c Mon Sep 17 00:00:00 2001 From: Laura Mendoza Date: Thu, 28 Nov 2019 10:50:13 +0100 Subject: [PATCH 4/6] pep8, some comments, took useless lines --- .../tuto_plot_gallery_fusion_machines.py | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/tutorials/tuto_plot_gallery_fusion_machines.py b/examples/tutorials/tuto_plot_gallery_fusion_machines.py index ebadfeb12..7c1359678 100644 --- a/examples/tutorials/tuto_plot_gallery_fusion_machines.py +++ b/examples/tutorials/tuto_plot_gallery_fusion_machines.py @@ -2,7 +2,8 @@ A gallery of Fusion Machines ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -This tutorial functions as a gallery of fusion machines that can easily be loaded with `tofu`. +This tutorial functions as a gallery of fusion machines that can easily be +loaded with `tofu`. """ ############################################################################### @@ -11,28 +12,28 @@ import tofu as tf ############################################################################### -# `tofu` provides a geometry helper function that allows creating a configuration with a single call. +# `tofu` provides a geometry helper function that allows creating a +# configuration with a single call. # -# Calling with empty arguments results in a default configuration. At the time of writing, this is ITER. -# By printing the `config` object, a text representation of its components is printed. This allows inspecting +# Calling with empty arguments results in a default configuration. At the time +# of writing, this is ITER. +# By printing the `config` object, a text representation of its components is +# printed. This allows inspecting # component names, number of sections, color or visibility. -config = tf.geom.utils.create_config() +config = tf.geom.utils.create_config() # create default configuration print(config) ############################################################################### -# To get a list of all available built-in configs, one has to know some details about `tofu`. -# Configurations can either be accessed by names (ITER, WEST, JET). +# To get a list of all available built-in configs, one has to know some details +# about `tofu`. Configurations can be accessed by names (ITER, WEST, JET, etc). print(tf.geom.utils._DCONFIG_TABLE.keys()) ############################################################################### -# With that being said, let's create a gallery of the "top 3" fusion machines provided by `tofu` to accelerate -# diagnostic development. +# With that being said, let's create a gallery of the "top 3" fusion machines +# provided by `tofu` to accelerate diagnostic development. -import matplotlib.pyplot as plt - -fig, ax = plt.subplots() for fusion_machine in ['ITER', 'WEST', 'JET']: config = tf.geom.utils.create_config(fusion_machine) - config.plot() \ No newline at end of file + config.plot() From 623b6f7b4f6ce4f4165b8ff1bcabac865b80abb5 Mon Sep 17 00:00:00 2001 From: VEZINET Didier Date: Thu, 28 Nov 2019 10:52:12 +0100 Subject: [PATCH 5/6] [Issue292] PEP8 Compliance --- setup.py | 11 ++++++----- tofu/version.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 2fad01b84..5f45f94c0 100644 --- a/setup.py +++ b/setup.py @@ -147,6 +147,7 @@ def check_for_openmp(cc_var): # == Getting tofu version ===================================================== _HERE = os.path.abspath(os.path.dirname(__file__)) + def updateversion(path=_HERE): # Fetch version from git tags, and write to version.py # Also, when git is not available (PyPi package), use stored version.py @@ -154,13 +155,13 @@ def updateversion(path=_HERE): try: version_git = subprocess.check_output(["git", "describe"]).rstrip().decode() - except: - with open(version_py,'r') as fh: - version_git = fh.read().strip().split("=")[-1].replace("'",'') - version_git = version_git.lower().replace('v','') + except Exception as err: + with open(version_py, 'r') as fh: + version_git = fh.read().strip().split("=")[-1].replace("'", '') + version_git = version_git.lower().replace('v', '') version_msg = "# Do not edit, pipeline versioning governed by git tags!" - with open(version_py,"w") as fh: + with open(version_py, "w") as fh: msg = "{0}__version__ = '{1}'{0}".format(os.linesep, version_git) fh.write(version_msg + msg) return version_git diff --git a/tofu/version.py b/tofu/version.py index 9c572aae8..e5dd80cc9 100644 --- a/tofu/version.py +++ b/tofu/version.py @@ -1,2 +1,2 @@ # Do not edit, pipeline versioning governed by git tags! -__version__ = '1.4.2-a4-4-g9531f81' +__version__ = '1.4.2-a4-5-g9b404aa' From a1d316ae6d8c7b9efc5ab21e4c8aa083cdcdc80b Mon Sep 17 00:00:00 2001 From: Laura Mendoza Date: Thu, 28 Nov 2019 10:57:58 +0100 Subject: [PATCH 6/6] added tuto to TOC --- doc/source/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/index.rst b/doc/source/index.rst index 80c9671e6..bbcc751dc 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -63,6 +63,7 @@ Contents How to install tofu A guide to contributing to tofu + A list of all different device configurations available (ITER, WEST, JET, ...) Tutorials and examples * How to create / handle a diagnostic geometry