Skip to content

Commit

Permalink
Merge pull request openturns#3 from sofianehaddad/sh/fixes
Browse files Browse the repository at this point in the history
Some fixes
  • Loading branch information
sofianehaddad authored Nov 10, 2022
2 parents 3f5875d + 5c062c3 commit 550d690
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 158 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:
- name: Build
shell: bash -l {0}
run: |
conda install -y openturns numpy pytest jupyter numpydoc sphinx nbsphinx jupyter_client ipython pandoc
conda install -y openturns numpy pytest numpydoc sphinx sphinx-gallery pandoc
conda install -c conda-forge sphinx_rtd_theme
python setup.py install
pytest
sudo apt install -y texlive-latex-recommended texlive-fonts-recommended texlive-latex-extra
Expand Down
79 changes: 50 additions & 29 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import sys, os
from distutils.version import LooseVersion
import sphinx
import sphinx_gallery
import subprocess

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('../'))
sys.path.append(os.path.abspath('sphinxext'))

# -- General configuration ------------------------------------------------

Expand All @@ -31,42 +31,66 @@
'sphinx.ext.autosummary',
'sphinx.ext.coverage',
'numpydoc',
'nbsphinx'
'sphinx_gallery.gen_gallery'
]

nbsphinx_execute = 'never'
# dont add .txt suffix to notebook
html_sourcelink_suffix = ''
tags.add('nbsphinx')
extensions.append('IPython.sphinxext.ipython_console_highlighting')
sphinx_gallery_conf = {
'examples_dirs': ['examples'], # path to
# example scripts
'gallery_dirs': ['auto_example'],
'filename_pattern': '/plot_',
'run_stale_examples': True,
'show_signature': False,
# directory where function/class granular galleries are stored
'backreferences_dir' : 'gen_modules/backreferences',

# Modules for which function/class level galleries are created.
'doc_module' : ('openturns'),

# objects to exclude from implicit backreferences. The default option
# is an empty set, i.e. exclude nothing.
'exclude_implicit_doc': {},
}

autodoc_default_flags = ['members', 'inherited-members']
intersphinx_mapping = {'python': ('http://openturns.github.io/openturns/1.18', 'openturns-objects.inv')}
autosummary_generate = True
if LooseVersion(sphinx.__version__) >= LooseVersion('1.8'):
autodoc_default_options = {'members': None, 'inherited-members': None, 'exclude-members': 'thisown'}
else:
autodoc_default_flags = ['members', 'inherited-members']

numpydoc_show_class_members = True
numpydoc_class_members_toctree = False

# for equations
try:
import sphinx.ext.imgmath
extensions.append('sphinx.ext.imgmath')
imgmath_latex_preamble = r'\usepackage{{{0}math_notations}}'.format(
os.path.dirname(__file__) + os.sep)
imgmath_use_preview = True
if subprocess.call('dvisvgm -V', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0:
imgmath_image_format = 'svg'
# embed image files inside html
imgmath_embed = True
except ImportError:
extensions.append('sphinx.ext.pngmath')
pngmath_latex_preamble = r'\usepackage{{{0}math_notations}}'.format(
os.path.dirname(__file__) + os.sep)
# The next option is used for smart-alignment of math images on the text.
# It only works when the preview-latex package is installed.
# See http://sphinx-doc.org/latest/ext/math.html#confval-pngmath_use_preview
pngmath_use_preview = True

extensions.append('matplotlib.sphinxext.plot_directive')

intersphinx_mapping = {'python': (
'http://openturns.github.io/openturns/1.18', 'openturns-objects.inv')}
autosummary_generate = True

numpydoc_show_class_members = True
numpydoc_class_members_toctree = False


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
source_suffix = '.rst'
source_suffix = ['.rst']

# The master toctree document.
master_doc = 'index'
Expand Down Expand Up @@ -95,7 +119,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build','themes', 'sphinxext', '.ipynb_checkpoints']
exclude_patterns = []

# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
Expand Down Expand Up @@ -126,8 +150,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'openturns'
if LooseVersion(sphinx.__version__) < LooseVersion('1.3'):
html_theme = 'default'
html_sourcelink_suffix = ''

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down Expand Up @@ -190,23 +213,21 @@
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{expdlist}
\usepackage{math_notations}
\usepackage{stackrel}
\let\latexdescription=\description
\def\description{\latexdescription{}{} \breaklabel}
\DeclareMathOperator*{\argmin}{Argmin}
'''

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
'papersize': 'a4paper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
'preamble': latex_preamble,

# Latex figure (float) alignment
#'figure_align': 'htbp',
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
'papersize': 'a4paper',
# The font size ('10pt', '11pt' or '12pt').
'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
'preamble': latex_preamble,
}

# Grouping the document tree into LaTeX files. List of tuples
Expand Down
Empty file added doc/examples/README.txt
Empty file.
87 changes: 0 additions & 87 deletions doc/examples/basic.ipynb

This file was deleted.

43 changes: 4 additions & 39 deletions doc/examples/examples.rst
Original file line number Diff line number Diff line change
@@ -1,45 +1,10 @@
Examples
========

.. toctree::
:maxdepth: 1

basic.ipynb

Example 1: Axial stressed beam
------------------------------

This example is a simple beam, restrained at one side and stressed by a traction load F at the other side.

1- Problem statement
````````````````````

a- Inputs
'''''''''

- Stochastics variables:
This section illustrates how to use the template.

====== ======================== ==================
Name Description Distribution
====== ======================== ==================
F Traction load Normal(75e3, 5e3)
sigma Axial stress LogNormal(300, 30)
====== ======================== ==================

- Deterministic independent variables:

======== ================================ =================
Variable Description Value
======== ================================ =================
D diameter 20.0
======== ================================ =================

b- Output
'''''''''

Primary energy savings :math:`G`

.. math::
G = \sigma_e -\frac{F}{\pi \frac{D^2}{4} }

.. toctree::

../auto_example/plot_basic
31 changes: 31 additions & 0 deletions doc/examples/plot_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Example : Using ottemplatepython module
---------------------------------------
"""
# %%
# This example aims to illustrate how to use the module.

# %%
# | Loading python modules

# %%
import openturns as ot
from openturns.viewer import View
import numpy as np
import ottemplate
from matplotlib import pylab as plt

# %%
# | Using the module to compute power
print(ottemplate.MyClass(3).power(2))

# %%
# | Compute power using arrays
array = np.linspace(-5, 5, 101)
values = ottemplate.MyClass(array).power(2.0)

# %%
# | Use of graph objects
graph = ot.Graph('Square function', 'x1', 'x2', True, '')
graph.add(ot.Cloud(array, values))
View(graph).show()
4 changes: 2 additions & 2 deletions ottemplate/ottemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class MyClass(object):
"""
Class test
Applying power on
Applying power function
Parameters
----------
Expand All @@ -28,4 +28,4 @@ def power(self, n):
y : float
The cube value.
"""
return np.power(self.value, n)
return np.power(self.value, n)

0 comments on commit 550d690

Please sign in to comment.