Skip to content

Commit

Permalink
bump version 0.0.0rc5
Browse files Browse the repository at this point in the history
modified:   src/pytom3d/scan.py (minor changes)
modified:   src/pytom3d/util.py (add printer decorator)
modified:   src/pytom3d/viewer.py (add contour view, scan comparison)
  • Loading branch information
aletgn committed May 25, 2024
1 parent 9099914 commit 80986d8
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 34 deletions.
2 changes: 1 addition & 1 deletion buildPackageAndDocs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pip3 uninstall pytom3d -y
python3 -m build
pip3 install dist/pytom3d-0.0.0rc4-py3-none-any.whl
pip3 install dist/pytom3d-0.0.0rc5-py3-none-any.whl
sphinx-apidoc -o ./docs/ ./src/
cd docs/
make clean & make html
Expand Down
Binary file added dist/pytom3d-0.0.0rc5-py3-none-any.whl
Binary file not shown.
Binary file added dist/pytom3d-0.0.0rc5.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project = 'PyToM-3D'
copyright = '2024, Alessandro Tognan'
author = 'Alessandro Tognan'
release = '0.0.0rc4'
release = '0.0.0rc5'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="pytom3d",
version="0.0.0rc4",
version="0.0.0rc5",
description="PyToM-3D: Python Topography Manipulator in 3D",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
14 changes: 10 additions & 4 deletions src/pytom3d/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,20 @@ def export_line_scan(reader: callable, path: str, *scans: List, **kwargs: Dict[
data.to_excel(path, index=False)


def scan_stat_factory(*scan: List):
def scan_stat_factory(name: str = "av", color: str = "k", linestyle: str = "-", *scan: List):
"""
Create a scan object representing the statistical summary of multiple scans.
Parameters
----------
*scan : variable number of Scan objects
Scan objects to be summarized.
name: str
Name to be assigned to the output scan
color: str
Color to be assigned to the output scan
linestyle:
Linestyle to be assigned to the output scan
scan : variable number of Scan objects
Scan objects to be processed.
Returns
-------
Expand All @@ -120,7 +126,7 @@ def scan_stat_factory(*scan: List):
mean = values.mean(axis=0)
quad = np.sqrt(squared_uncertainty.sum(axis=0))/len(scan)

av_scan = Scan(name="av")
av_scan = Scan(name=name, line=linestyle, color=color)
av_scan.load_data(x, mean, quad)

return av_scan
35 changes: 35 additions & 0 deletions src/pytom3d/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pandas as pd
import re
from typing import Tuple, List, Any
from matplotlib import pyplot as plt

from pytom3d.stats import running_mean, running_std

Expand Down Expand Up @@ -503,3 +504,37 @@ def scan_data_wrapper(path: str, match: str) -> Tuple[np.ndarray]:
x = get_coordinates([0], *data)

return x.reshape(-1), mean, std


def printer(func: callable):
"""
A decorator for class methods that saves a figure if 'save' is True.
Borrowed from https://github.com/aletgn/b-fade/blob/master/src/bfade/util.py
This decorator wraps a method that generates a figure and a title,
and it saves the figure to the specified location if 'save' is True.
Parameters
----------
func : callable
The function to be decorated, which generates a figure and a title.
Returns
-------
callable
The decorated function.
"""
@functools.wraps(func) # <- preserve function signature
def saver(self, *args, **kwargs):
fig, title = func(self, *args, **kwargs)
if self.save == True:
fig.savefig(self.folder + title + "." + self.fmt,
format = self.fmt,
dpi = self.dpi,
bbox_inches='tight')
print(f"SAVE: {title}")
else:
print(f"SHOW: {title}")
plt.show()
return saver
Loading

0 comments on commit 80986d8

Please sign in to comment.