Skip to content

Commit

Permalink
remove seaborn dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ameli committed Jan 21, 2024
1 parent e5ea3c8 commit f4a5dc5
Show file tree
Hide file tree
Showing 15 changed files with 525 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ jobs:
conda config --set anaconda_upload yes
export PATH=$(conda info --root):$PATH
export PATH=$(conda info --root)/bin:$PATH
conda-build --output-folder . .
conda build --output-folder conda-bld .
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/deploy-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
python setup.py bdist_wheel
twine check dist/*
- name: Publish to PyPi
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
Expand Down
17 changes: 15 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
# cache
__pycache__/
*.py[cod]
.ipynb_checkpoints/
.pytest_cache/

# C extentions
# C extensions
*.so
*.o

# Build
.mesonpy-*

# Distribution
bin/
Expand All @@ -23,6 +29,7 @@ develop-eggs/
dist/
eggs/
sdist/
tmp/
.eggs/
*.egg-info/
.installed.cfg
Expand All @@ -36,4 +43,10 @@ nosetests.xml
coverage.xml

# Sphinx documentation
docs/_build/
docs/build/

# Lint
.ruff_cache/

# Conda
conda-bld/
44 changes: 11 additions & 33 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,28 @@ global-exclude *.so *.dll *.dylib
global-exclude *.o
global-exclude *.swp

recursive-include docs *.bat
recursive-include docs *.css
recursive-include docs *.py
recursive-include docs *.rst
recursive-include docs *.svg
recursive-include docs *.png
recursive-include docs *.ico
recursive-include docs *.js
recursive-include docs *.ttf
recursive-include docs Makefile
recursive-include docs *.bib
recursive-include docs *.in
recursive-include docs *.txt
recursive-exclude docs *.html
recursive-exclude docs *.pdf
recursive-include docs/source *.html

recursive-include ortho *.rst
recursive-include examples *.py
recursive-include examples *.rst
recursive-include notebooks *.ipynb
recursive-include tests *.py
recursive-include tests *.rst
recursive-exclude tests *.svg
recursive-include tests *.txt

include CHANGELOG.rst
include README.rst
include AUTHORS.txt
include LICENSE.txt
include requirements.txt
include pyproject.toml
include .coveragerc
include tox.ini
include environment.yml

exclude tox.ini
exclude environment.yml
exclude TODO.rst
exclude .coverage
exclude .coveragerc
exclude .gitattributes
exclude .tokeignore

prune docs/build
prune .git
prune docs
prune tmp
prune .tox
prune .github
prune conda-recipe
prune benchmark
prune notebooks
prune examples
prune tests
prune .git
prune .github
prune .tox
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ ortho
A python package to generate a set of orthogonal functions.

* `Documentation <https://ameli.github.io/ortho/index.html>`_
* `API Reference <https://ameli.github.io/ortho/api.html>`_
* `Github <https://ameli.github.io/ortho>`_
* `Documentation <https://ameli.github.io/ortho/index.html>`__
* `API Reference <https://ameli.github.io/ortho/api.html>`__
* `Github <https://ameli.github.io/ortho>`__

-----------
Description
Expand Down Expand Up @@ -100,7 +100,7 @@ Install using the package available on `PyPi <https://pypi.org/project/ortho>`__

|conda-version| |conda-platform|

Install using `Anaconda cloud <https://anaconda.org/s-ameli/traceinv>`_ by
Install using `Anaconda cloud <https://anaconda.org/s-ameli/traceinv>`__ by

::

Expand Down
1 change: 0 additions & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ requirements:
- numpy
- sympy
- matplotlib
- seaborn

test:
imports:
Expand Down
2 changes: 1 addition & 1 deletion ortho/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.7"
__version__ = "0.4.0"
29 changes: 29 additions & 0 deletions ortho/_orthogonal_functions/display_utilities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
# SPDX-License-Identifier: BSD-3-Clause
# SPDX-FileType: SOURCE
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the license found in the LICENSE.txt file in the root
# directory of this source tree.


# ===========
# is notebook
# ===========

def is_notebook():
"""
Returns ``True`` if this script is running in a jupyter notebook. Returns
``False`` otherwise, including both ipython and python.
"""

try:
shell = get_ipython().__class__.__name__
if shell == 'ZMQInteractiveShell':
return True # Jupyter notebook or qtconsole
elif shell == 'TerminalInteractiveShell':
return False # Terminal running IPython
else:
return False # Other type
except NameError:
return False # Probably standard Python interpreter
2 changes: 1 addition & 1 deletion ortho/_orthogonal_functions/orthogonal_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .orthogonalization_utilities import check_mutual_orthonormality
from .orthogonalization_utilities import get_symbolic_coeffs
from .orthogonalization_utilities import get_numeric_coeffs
from .plot_utilities import plot_functions
from .plot_functions import plot_functions


# ====================
Expand Down
93 changes: 93 additions & 0 deletions ortho/_orthogonal_functions/plot_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
# SPDX-License-Identifier: BSD-3-Clause
# SPDX-FileType: SOURCE
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the license found in the LICENSE.txt file in the root directory
# of this source tree.


# =======
# Imports
# =======

import numpy
import sympy
import os
from .plot_utilities import plt, matplotlib, get_custom_theme, save_plot
from .declarations import t

__all__ = ['plot_functions']


# ==============
# Plot Functions
# ==============

@matplotlib.rc_context(get_custom_theme(font_scale=1.2))
def plot_functions(phi_orthonormalized_list, start_index, interval):
"""
Plots the generated functions, also saves the plots as both ``svg`` and
``pdf`` format.
:param phi_orthonormalized_list: The list of generated functions. Each
entry is a ``sympy`` object.
:param: list
:param start_index: The indet of the first function.
:type start_index: int
:param Interval: The right side of the interval of the domain of the
functions.
:param Interval: float
"""

# Axis
t_array = numpy.logspace(-7, numpy.log10(interval[1]), 1000)

# Evaluate functions
num_functions = len(phi_orthonormalized_list)

f = numpy.zeros((num_functions, t_array.size), dtype=float)
for j in range(num_functions):
f_lambdify = sympy.lambdify(t, phi_orthonormalized_list[j], 'numpy')
f[j, :] = f_lambdify(t_array)

# Plot
fig, ax = plt.subplots(figsize=(7, 4.8))
for j in range(num_functions):
ax.semilogx(t_array, f[j, :],
label=r'$i = %d$' % (j+start_index))

ax.legend(ncol=3, loc='lower left', borderpad=0.5, frameon=False)
ax.set_xlim([t_array[0], t_array[-1]])
ax.set_ylim([-1, 1])
ax.set_yticks([-1, 0, 1])
ax.set_xlabel(r'$t$')
ax.set_ylabel(r'$\phi_i^{\perp}(t)$')
ax.set_title('Orthogonalized inverse-monomial functions')
ax.grid(axis='y')

# Get the root directory of the package (parent directory of this script)
file_dir = os.path.dirname(os.path.realpath(__file__))
parent_dir = os.path.dirname(file_dir)
second_parent_dir = os.path.dirname(parent_dir)

# Try to save in the docs/images directory. Check if exists and writable
save_dir = os.path.join(second_parent_dir, 'docs', 'images')
if (not os.path.isdir(save_dir)) or (not os.access(save_dir, os.W_OK)):

# Write in the current working directory
save_dir = os.getcwd()

# Save plot in both svg and pdf format
if os.access(save_dir, os.W_OK):
save_filename = 'orthogonal_functions'
save_plot(plt, save_filename, save_dir=save_dir,
transparent_background=True)
else:
print('Cannot save plot to %s. Directory is not writable.' % save_dir)

# If no display backend is enabled, do not plot in the interactive mode
if matplotlib.get_backend() != 'agg':
plt.show()

0 comments on commit f4a5dc5

Please sign in to comment.