Skip to content

Commit 4ed77a1

Browse files
committed
removed clock
1 parent 37f4cff commit 4ed77a1

File tree

2 files changed

+53
-25
lines changed

2 files changed

+53
-25
lines changed

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,53 @@
55
<img src="https://github.com/sansseriff/snsphd/raw/master/snsphd.svg" alt="SNSPHD" width="400"/>
66
</p>
77

8-
98
This is a python package of utility and styling functions used for:
109

1110
<h3 style="text-align: center; color: lightblue;"><em>Optimization Techniques for Single Photon Detection and Quantum Optics</em></h3>
1211

13-
1412
<h5 style="text-align: center; white-space: pre-line;">A Thesis by
1513
Andrew Mueller</h5>
1614

1715
<h5 style="text-align: center; white-space: pre-line;">In Partial Fulfillment of the Requirements for the
1816
Degree of Doctor of Philosophy in Applied Physics</h5>
1917

20-
2118
This packages is made of 6 parts:
2219

2320
## viz
24-
- Styling related functions and presets. This is used to give matplotlib and bokeh plots a custom style as seen in the thesis.
21+
22+
- Styling related functions and presets. This is used to give matplotlib and bokeh plots a custom style as seen in the thesis.
2523
- the `viz.save_light_dark_all()` function is used to save light-mode and dark-mode compatible figures, as well as a .pdf version of use in latex documents. It does not change color properties via rcParams, and therefore does not require changes to code before or involved with the initialization of a figure. `viz.save_light_dark_all()` just has to run at the end of a script or notebook cell, the same way `plt.savefig()` would be used. It traverses the figure DOM and modifies styling of a number of elements including lines, errorbars, legends, `imshow()` images, and other things.
2624
<p align="center">
2725
<img src="https://raw.githubusercontent.com/sansseriff/snsphd/949a6def8f99f3e120686f11b8019ca0b0ebbf18/light_dark.svg" alt="light_dark" width="700"/>
2826
</p>
2927

3028
## obj
31-
- Includes the `DataObj` class used for exporting and importing python classes as structured json files. Objects containing numpy arrays are exported using `orjson`, and re-cast into numpy arrays on import. The library follows some basic rules in order to determine what sub-objects should be converted to numpy arrays during import. Complex arrays may not import correctly. The library supports export and import of nested `DataObj` classes. When the json is parsed during import, structures that who's keys include the suffix "_do" are converted to `DataObj` classes in a recursive pattern.
3229

33-
- `DataObj` classes are not supported by a rigid schema, which has advantages and disadvantages. The use of the "_do" suffix could lead to unwanted name-collision behavior, and the import process may fail on certain types of nested arrays, especially those that contain datatypes that cannot be converted to numpy arrays.
30+
- Includes the `DataObj` class used for exporting and importing python classes as structured json files. Objects containing numpy arrays are exported using `orjson`, and re-cast into numpy arrays on import. The library follows some basic rules in order to determine what sub-objects should be converted to numpy arrays during import. Complex arrays may not import correctly. The library supports export and import of nested `DataObj` classes. When the json is parsed during import, structures that who's keys include the suffix "\_do" are converted to `DataObj` classes in a recursive pattern.
3431

35-
- For more rigid control of datatypes and object schema, a library like [pydantic](https://docs.pydantic.dev/latest/) in concert with [datamodel code generator](https://github.com/koxudaxi/datamodel-code-generator) may be more useful.
32+
- `DataObj` classes are not supported by a rigid schema, which has advantages and disadvantages. The use of the "\_do" suffix could lead to unwanted name-collision behavior, and the import process may fail on certain types of nested arrays, especially those that contain datatypes that cannot be converted to numpy arrays.
3633

34+
- For more rigid control of datatypes and object schema, a library like [pydantic](https://docs.pydantic.dev/latest/) in concert with [datamodel code generator](https://github.com/koxudaxi/datamodel-code-generator) may be more useful.
3735

3836
## layout
39-
- Contains the `bisect()` function and related utilities that are used to define complex matplotlib figure layouts. More information is included in the main thesis.
37+
38+
- Contains the `bisect()` function and related utilities that are used to define complex matplotlib figure layouts. More information is included in the main thesis.
4039

4140
## hist
42-
- A collection of various utilities that help with the analysis of histograms and instrument response functions, like the jitter profile of Superconducting Nanowire Single Photon Detectors. These include tools for fitting histograms to curves, and finding their width at different percentages of maximum height.
41+
42+
- A collection of various utilities that help with the analysis of histograms and instrument response functions, like the jitter profile of Superconducting Nanowire Single Photon Detectors. These include tools for fitting histograms to curves, and finding their width at different percentages of maximum height.
4343

4444
## help
45+
4546
- Various utility functions of general usefulness. The `prinfo` functions is handy for easy debugging:
4647

4748
```python
4849
my_variable = 3
4950
my_other_variable = "hello"
5051
prinfo(my_variable, my_other_variable)
5152
```
53+
5254
prints:
5355

54-
my_variable = 3,
56+
my_variable = 3,
5557
my_other_variable = "hello"
56-
57-
## clock
58-
- Contains various versions of numba-accelerated clock analysis functions. These apply phase locked loops to a series of clock time measurements in order to cancel clock jitter.

publish_new.sh

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
set -euo pipefail
33

44
# Bump version in pyproject.toml and __init__.py, commit, tag, and push.
5-
# Usage: ./publish_new.sh [major|minor|patch]
6-
# Default bump: patch
5+
# Usage: ./publish_new.sh [major|minor|patch|current|set X.Y.Z]
6+
# major/minor/patch: bumps the version accordingly (default: patch)
7+
# current: tags and publishes the current version without changing files
8+
# set X.Y.Z: sets version to the explicit value, commits, tags, and pushes
79

810
BUMP_TYPE=${1:-patch}
11+
EXPLICIT_VERSION=${2:-}
912

1013
function die() { echo "Error: $*" >&2; exit 1; }
1114

@@ -22,12 +25,25 @@ INIT_FILE=src/snsphd/__init__.py
2225
CURRENT_VERSION=$(grep -E '^version\s*=\s*"[0-9]+\.[0-9]+\.[0-9]+"' "$PYPROJECT" | head -n1 | sed -E 's/.*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/')
2326
[[ -n ${CURRENT_VERSION:-} ]] || die "Could not read current version from $PYPROJECT"
2427

25-
IFS='.' read -r MAJOR MINOR PATCH <<<"$CURRENT_VERSION"
28+
NEW_VERSION=""
2629
case "$BUMP_TYPE" in
27-
major) NEW_VERSION="$((MAJOR+1)).0.0" ;;
28-
minor) NEW_VERSION="$MAJOR.$((MINOR+1)).0" ;;
29-
patch) NEW_VERSION="$MAJOR.$MINOR.$((PATCH+1))" ;;
30-
*) die "Unknown bump type: $BUMP_TYPE (use major|minor|patch)" ;;
30+
major|minor|patch)
31+
IFS='.' read -r MAJOR MINOR PATCH <<<"$CURRENT_VERSION"
32+
case "$BUMP_TYPE" in
33+
major) NEW_VERSION="$((MAJOR+1)).0.0" ;;
34+
minor) NEW_VERSION="$MAJOR.$((MINOR+1)).0" ;;
35+
patch) NEW_VERSION="$MAJOR.$MINOR.$((PATCH+1))" ;;
36+
esac
37+
;;
38+
current)
39+
NEW_VERSION="$CURRENT_VERSION"
40+
;;
41+
set)
42+
[[ -n "$EXPLICIT_VERSION" ]] || die "Usage: ./publish_new.sh set X.Y.Z"
43+
[[ "$EXPLICIT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || die "Version must be X.Y.Z"
44+
NEW_VERSION="$EXPLICIT_VERSION"
45+
;;
46+
*) die "Unknown mode: $BUMP_TYPE (use major|minor|patch|current|set X.Y.Z)" ;;
3147
esac
3248

3349
TAG="v$NEW_VERSION"
@@ -36,12 +52,20 @@ echo "Current version: $CURRENT_VERSION"
3652
echo "New version: $NEW_VERSION"
3753
echo "Tag: $TAG"
3854

39-
# Update pyproject.toml
40-
# macOS/BSD sed requires a backup suffix for -i; use '' for none
41-
sed -i '' -E "s/^version\s*=\s*\"[0-9]+\.[0-9]+\.[0-9]+\"/version = \"$NEW_VERSION\"/" "$PYPROJECT"
55+
# Update files only if version changed; otherwise sync __init__ to pyproject
56+
if [[ "$NEW_VERSION" != "$CURRENT_VERSION" ]]; then
57+
# Update pyproject.toml
58+
# macOS/BSD sed requires a backup suffix for -i; use '' for none
59+
sed -i '' -E "s/^version\s*=\s*\"[0-9]+\.[0-9]+\.[0-9]+\"/version = \"$NEW_VERSION\"/" "$PYPROJECT"
4260

43-
# Update __init__.py __version__
44-
sed -i '' -E "s/^__version__\s*=\s*\"[0-9]+\.[0-9]+\.[0-9]+\"/__version__ = \"$NEW_VERSION\"/" "$INIT_FILE"
61+
# Update __init__.py __version__
62+
sed -i '' -E "s/^__version__\s*=\s*\"[0-9]+\.[0-9]+\.[0-9]+\"/__version__ = \"$NEW_VERSION\"/" "$INIT_FILE"
63+
else
64+
INIT_VERSION=$(grep -E '^__version__\s*=\s*"[0-9]+\.[0-9]+\.[0-9]+"' "$INIT_FILE" | head -n1 | sed -E 's/.*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/') || true
65+
if [[ "$INIT_VERSION" != "$NEW_VERSION" ]]; then
66+
sed -i '' -E "s/^__version__\s*=\s*\"[0-9]+\.[0-9]+\.[0-9]+\"/__version__ = \"$NEW_VERSION\"/" "$INIT_FILE"
67+
fi
68+
fi
4569

4670
# Show changes
4771
echo "\nChanged files:"
@@ -55,6 +79,11 @@ else
5579
git commit -m "chore: release $TAG"
5680
fi
5781

82+
# Prevent tagging an already existing version
83+
if git rev-parse "$TAG" >/dev/null 2>&1; then
84+
die "Tag $TAG already exists. Aborting."
85+
fi
86+
5887
git tag -a "$TAG" -m "Release $TAG"
5988

6089
echo "\nPushing commits and tags..."

0 commit comments

Comments
 (0)