Skip to content

Commit

Permalink
enh: add zfit physics
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-eschle committed Apr 15, 2024
1 parent a4e1347 commit b824253
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions _website/tutorials/introduction/upgrade_guide_020.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@
"metadata": {},
"outputs": [],
"source": [
"# example usage of the numpy-like backend, use it if possible\n",
"\n",
"\n",
"@z.function\n",
"def maximum(x, y):\n",
" return znp.maximum(x, y)\n",
"\n",
"\n",
"# example usage of the numpy-like backend, use it if possible\n",
"print(f\"sqrt with np:{np.sqrt(maximum(1., 2.))}, with z:{znp.sqrt(maximum(1., 2.))}\")\n",
"print(f\"vectorized: {np.sqrt(maximum(znp.array([1., 2.]), znp.array([3., 4.])))}\")"
]
Expand Down Expand Up @@ -101,7 +99,9 @@
"As explained [in the github discussion thread](https://github.com/zfit/zfit/discussions/533) there are major improvements and changes.\n",
"- multispaces (adding two spaces, having disjoint observables) are now deprecated and will be removed. The new `TruncatedPDF` supports multiple spaces as limits and achieves a similar, if not better, functionality.\n",
"- the return type of `Space.limit` will be changed in the future. For forwards compatibility, use `Space.v1.limit` (or similar methods) instead of `Space.limit`. The old one is still available via `Space.v0.limit`.\n",
"- new ways of creating spaces"
"- new ways of creating spaces\n",
"\n",
"More [examples on how to use the new spaces](https://github.com/zfit/zfit/blob/develop/examples/spaces.py)."
]
},
{
Expand All @@ -125,7 +125,9 @@
"metadata": {},
"outputs": [],
"source": [
"# limits are now as one would naively expect, and area has been renamed to volume (some are tensors, but that doesn't matter: they behave like numpy arrays)"
"# limits are now as one would naively expect, and area has been renamed to volume (some are tensors, but that doesn't matter: they behave like numpy arrays)\n",
"print(f\"old: limits={obs12.v0.limits}\")\n",
"print(f\"new: limits={obs12.v1.limits}\") # we have just 1D arrays\n"
]
},
{
Expand Down Expand Up @@ -177,7 +179,9 @@
"metadata": {},
"outputs": [],
"source": [
"# data can be accessed with \"obs\" directly"
"# data can be accessed with \"obs\" directly\n",
"data_obs12[\"obs1\"] # returns a numpy array shape (n,)\n",
"data_obs12[[\"obs2\", \"obs1\"]] # returns a numpy array shape (n, 2)"
]
},
{
Expand Down
16 changes: 10 additions & 6 deletions introduction/upgrade_guide_020.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@
"metadata": {},
"outputs": [],
"source": [
"# example usage of the numpy-like backend, use it if possible\n",
"\n",
"\n",
"@z.function\n",
"def maximum(x, y):\n",
" return znp.maximum(x, y)\n",
"\n",
"\n",
"# example usage of the numpy-like backend, use it if possible\n",
"print(f\"sqrt with np:{np.sqrt(maximum(1., 2.))}, with z:{znp.sqrt(maximum(1., 2.))}\")\n",
"print(f\"vectorized: {np.sqrt(maximum(znp.array([1., 2.]), znp.array([3., 4.])))}\")"
]
Expand Down Expand Up @@ -101,7 +99,9 @@
"As explained [in the github discussion thread](https://github.com/zfit/zfit/discussions/533) there are major improvements and changes.\n",
"- multispaces (adding two spaces, having disjoint observables) are now deprecated and will be removed. The new `TruncatedPDF` supports multiple spaces as limits and achieves a similar, if not better, functionality.\n",
"- the return type of `Space.limit` will be changed in the future. For forwards compatibility, use `Space.v1.limit` (or similar methods) instead of `Space.limit`. The old one is still available via `Space.v0.limit`.\n",
"- new ways of creating spaces"
"- new ways of creating spaces\n",
"\n",
"More [examples on how to use the new spaces](https://github.com/zfit/zfit/blob/develop/examples/spaces.py)."
]
},
{
Expand All @@ -125,7 +125,9 @@
"metadata": {},
"outputs": [],
"source": [
"# limits are now as one would naively expect, and area has been renamed to volume (some are tensors, but that doesn't matter: they behave like numpy arrays)"
"# limits are now as one would naively expect, and area has been renamed to volume (some are tensors, but that doesn't matter: they behave like numpy arrays)\n",
"print(f\"old: limits={obs12.v0.limits}\")\n",
"print(f\"new: limits={obs12.v1.limits}\") # we have just 1D arrays\n"
]
},
{
Expand Down Expand Up @@ -177,7 +179,9 @@
"metadata": {},
"outputs": [],
"source": [
"# data can be accessed with \"obs\" directly"
"# data can be accessed with \"obs\" directly\n",
"data_obs12[\"obs1\"] # returns a numpy array shape (n,)\n",
"data_obs12[[\"obs2\", \"obs1\"]] # returns a numpy array shape (n, 2)"
]
},
{
Expand Down

0 comments on commit b824253

Please sign in to comment.