From b8242532aba7a4a840a7d37e2bb50244913e4f93 Mon Sep 17 00:00:00 2001 From: Jonas Eschle Date: Mon, 15 Apr 2024 02:22:25 -0400 Subject: [PATCH] enh: add zfit physics --- .../introduction/upgrade_guide_020.ipynb | 16 ++++++++++------ introduction/upgrade_guide_020.ipynb | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/_website/tutorials/introduction/upgrade_guide_020.ipynb b/_website/tutorials/introduction/upgrade_guide_020.ipynb index 740419d..038838a 100644 --- a/_website/tutorials/introduction/upgrade_guide_020.ipynb +++ b/_website/tutorials/introduction/upgrade_guide_020.ipynb @@ -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.])))}\")" ] @@ -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)." ] }, { @@ -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" ] }, { @@ -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)" ] }, { diff --git a/introduction/upgrade_guide_020.ipynb b/introduction/upgrade_guide_020.ipynb index 740419d..038838a 100644 --- a/introduction/upgrade_guide_020.ipynb +++ b/introduction/upgrade_guide_020.ipynb @@ -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.])))}\")" ] @@ -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)." ] }, { @@ -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" ] }, { @@ -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)" ] }, {