From 6006bb77fd8583e34cb80d090fdcf8bf523882dc Mon Sep 17 00:00:00 2001 From: nunofachada Date: Fri, 1 Sep 2023 10:09:11 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20clugen/p?= =?UTF-8?q?yclugen@93dec5e9fcd438fe00ce18c4c5dffb7325561627=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generated/gallery/gallery_jupyter.zip | Bin 76464 -> 76699 bytes generated/gallery/gallery_python.zip | Bin 37592 -> 37816 bytes .../gallery/mg_execution_times/index.html | 14 +- .../gallery/plot_1_1d_examples/index.html | 86 +- .../gallery/plot_1_1d_examples_codeobj.pickle | Bin 1369 -> 1369 bytes .../gallery/plot_2_2d_examples/index.html | 1412 +++-------------- .../gallery/plot_2_2d_examples_codeobj.pickle | Bin 6534 -> 6534 bytes .../gallery/plot_3_3d_examples/index.html | 468 +++--- .../gallery/plot_3_3d_examples_codeobj.pickle | Bin 6681 -> 6687 bytes .../gallery/plot_4_nd_examples/index.html | 408 +---- .../gallery/plot_4_nd_examples_codeobj.pickle | Bin 1558 -> 1558 bytes generated/gallery/plot_5_mrg_examples.ipynb | 2 +- generated/gallery/plot_5_mrg_examples.py | 2 +- generated/gallery/plot_5_mrg_examples.py.md5 | 2 +- .../gallery/plot_5_mrg_examples/index.html | 396 +---- .../plot_5_mrg_examples_codeobj.pickle | Bin 2842 -> 2842 bytes generated/gallery/plot_functions.ipynb | 8 +- generated/gallery/plot_functions.py | 23 +- generated/gallery/plot_functions.py.md5 | 2 +- generated/gallery/plot_functions/index.html | 67 +- .../gallery/plot_functions_codeobj.pickle | Bin 3236 -> 3440 bytes index.html | 8 +- search/search_index.json | 2 +- sitemap.xml.gz | Bin 307 -> 307 bytes 24 files changed, 482 insertions(+), 2418 deletions(-) diff --git a/generated/gallery/gallery_jupyter.zip b/generated/gallery/gallery_jupyter.zip index 8ce805c0c50a0737ec88ce00040d0b56430645fe..3a675cfb88fe2d749ca216fc9998e2beab17db28 100644 GIT binary patch delta 648 zcmdmRm1XvI7M=iaW)=|!5MT@3$n%AdNhEMH6aTpwKE*)AaBICq%@5TW7#^x^zL))- zNj$$eCNDF$Ait$xkj;$jno4_5>Q2rjTE(m!4XZnpdU~qXZOE(o|5iRq)HtOSOv0Qvd>( zReEWeIVGt@FfLGaW_n(JQ7TY}64&H!`Wc(QN7$yG1>^EZ*y+@D>hk(xtXyF z+CaBt=0V&Nof)gCps!#w`Fy|3uOqtx&b+U8IFY)nit zft!C#)RbTn2;8i?YDPQad$n%AdslaP96aTpwz6vkJ@YjwWJHM$iFnm+pd@uVu z)8x;2TPHIHWNz*&_{Yx`Z4j%YP?4KhQ9OA;gA`Y^A&k5ET*F;9Wa<6w@;nIXXv4_| z+l9rdax!x@DsnUPildESI-`w1Qk$(hUa@gUXT~aM1I-62*lgLa$jB9)1yeRTZ-Oxo zP#$W1bmruO32K|~PGDnVD)ZX>bdsh7Q?A!$fz>nOIY7QBWl&tZeFGPx8@rgEo_;}2 zeo4GhyirPgYDHphK~8G1=H|qWA&lD-gc&D@F{OD;|D?(20t|-f7FvuhXu&YOON-G2 zXvy>gT8uJG?nXvX)|iG{nTItiUR;73Wv7< diff --git a/generated/gallery/gallery_python.zip b/generated/gallery/gallery_python.zip index 5bdb3df7ec75c406e0f29767020afcf5e13e16f7..a7861f0ef5feea7835a3a4cf463ef5142f5e4fde 100644 GIT binary patch delta 625 zcmcbylxfFuCY}IqW)=|!5MT}5$g_%-Ng#0Z4%R!me2RgJ;XiXte%+E{V7MhUd6Drt z!Te&b%-n+fq7sGj#G<^+y!6R#CVT5WGE-6&67%x%D}f>~nPP?VjMO}Zq|(fs6p(OA zesZxwW}bqxCs$^gLVmGcdTL2(UYUlHv!{}#f}*X0Uw&Sy6_)}KK+P`JOUukDNiBkL zHIy>b^YV*Ql{C4yloeD}frPTMLUPV#Ueh#g5xvZu{N!kZSRI9m+{B7vFn4mTgCtbK z5Jh710*885>{>M4%LN%+>Z857T#QMxw1#O`HnRyWVH>>-IGD9PUiPjnw;y)4ONkesv;AnVx_MLlSts^{k{j-nb-n1H-gf$g_%-Dc5WB4%R!md=*}b;X?gfUw=t5F#M97yvTUn zLvxg~S5oS*9CPCpT*0U{SL4*rFm^m411`{Q3mu(N^n*6X0Mhf%wl?a`UN@p zCGke_Mk(>B6^Xe8IjO~(ll>zNHkWj)=449snyfg<5f~DaQzkj02gK${h6)8h<7TGC zKIms>U;trJZ~#JxC5@YXC$IMtpBy)t2WbCf&B-!MrJ<7x!@wd6FqbUnWnchdF%+#4 P&6B$(Yp@wl1c?Fw7sG=h diff --git a/generated/gallery/mg_execution_times/index.html b/generated/gallery/mg_execution_times/index.html index 13da784..fd98286 100644 --- a/generated/gallery/mg_execution_times/index.html +++ b/generated/gallery/mg_execution_times/index.html @@ -613,19 +613,19 @@

Computation times

-

00:36.628 total execution time for generated_gallery files:

+

00:51.721 total execution time for generated_gallery files:

+----------------------------------------------------------------------------------------+-----------+--------+ -| plot_2_2d_examples (docs/examples/plot_2_2d_examples.py) | 00:13.505 | 0.0 MB | +| plot_2_2d_examples (docs/examples/plot_2_2d_examples.py) | 00:19.947 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ -| plot_4_nd_examples (docs/examples/plot_4_nd_examples.py) | 00:11.310 | 0.0 MB | +| plot_4_nd_examples (docs/examples/plot_4_nd_examples.py) | 00:15.867 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ -| plot_3_3d_examples (docs/examples/plot_3_3d_examples.py) | 00:05.871 | 0.0 MB | +| plot_3_3d_examples (docs/examples/plot_3_3d_examples.py) | 00:07.542 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ -| plot_5_mrg_examples (docs/examples/plot_5_mrg_examples.py) | 00:04.270 | 0.0 MB | +| plot_5_mrg_examples (docs/examples/plot_5_mrg_examples.py) | 00:06.215 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ -| plot_1_1d_examples (docs/examples/plot_1_1d_examples.py) | 00:01.666 | 0.0 MB | +| plot_1_1d_examples (docs/examples/plot_1_1d_examples.py) | 00:02.143 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ -| plot_functions (docs/examples/plot_functions.py) | 00:00.006 | 0.0 MB | +| plot_functions (docs/examples/plot_functions.py) | 00:00.007 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+

diff --git a/generated/gallery/plot_1_1d_examples/index.html b/generated/gallery/plot_1_1d_examples/index.html index 7d453cd..b5fa170 100644 --- a/generated/gallery/plot_1_1d_examples/index.html +++ b/generated/gallery/plot_1_1d_examples/index.html @@ -735,91 +735,7 @@

Basic 1D example with density plot e084, "e084: custom proj_dist_fn (Weibull)")

e082: proj_dist_fn = 'norm' (default), e083: proj_dist_fn = 'unif', e084: custom proj_dist_fn (Weibull)

-

Out:

-
/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
-  with pd.option_context('mode.use_inf_as_na', True):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-
-

Total running time of the script: ( 0 minutes 1.666 seconds)

+

Total running time of the script: ( 0 minutes 2.143 seconds)

Download Python source code: plot_1_1d_examples.py

diff --git a/generated/gallery/plot_1_1d_examples_codeobj.pickle b/generated/gallery/plot_1_1d_examples_codeobj.pickle index 7b925aaae7e48029a97b83b2a2ceb7bf492c23d7..8af88f265a73e60b45c1912c890b5ebdd15b19b5 100644 GIT binary patch delta 319 zcmcb~b(3p?UJ7e~v%8tel-Ma6wNo^DSn?8cQ>XMm1$)?X^HWN5fC9pKrMU%_dPRwO zDfzj2@de50Ks`M?5b5~hjQpY!AQxHDlpc=E;`rp8#Ny&9lkYPbG4f89V3J`L$>5z_ z&m=iHfJqN1QqN=wCM9`U!Fs1;aA(K^RRGnq@OGA_PJE-otO4XpGb*rYXMjW|XEPeI z8Gx9Hlh-j@0d@PZD6v_B7oVd5O8HQ+hbkO7oISGV}AM^swdTrUG_{AhC@*~ytFn*?h@05MmYh?X zo|-o$c8bPiLskW5$qb&!9~l*xWq|ZC7Iij7u(HYGOopav5FM-m&hBO=APu!sG&0zG zp!^KZ9^t&w+=5EIqQtzE{9L{Gg5-2FlZhLJ8F?o6Fd8ZFbd;iNU{P|%z;2&KC>B^6q~$Using the directi e003, "e003: direction = [0, 1]")

e001: direction = [1, 0], e002: direction = [1, 1], e003: direction = [0, 1]

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Changing the angle_disp parameter and using a custom angle_deltas_fn function

-
seed = 321
+
seed = 321
 
-
# Custom angle_deltas function: arbitrarily rotate some clusters by 90 degrees
-def angdel_90_fn(nclu, astd, rng):
-    return rng.choice([0, np.pi / 2], size=nclu)
+
# Custom angle_deltas function: arbitrarily rotate some clusters by 90 degrees
+def angdel_90_fn(nclu, astd, rng):
+    return rng.choice([0, np.pi / 2], size=nclu)
 
-
e004 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed))
-e005 = clugen(2, 6, 500, [1, 0], np.pi / 8, [10, 10], 10, 1.5, 0.5, rng=rng(seed))
-e006 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed),
-    angle_deltas_fn=angdel_90_fn)
+
e004 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed))
+e005 = clugen(2, 6, 500, [1, 0], np.pi / 8, [10, 10], 10, 1.5, 0.5, rng=rng(seed))
+e006 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed),
+    angle_deltas_fn=angdel_90_fn)
 
-
plot_examples_2d(
-    e004, "e004: angle_disp = 0",
-    e005, "e005: angle_disp = π/8",
-    e006, "e006: custom angle_deltas function")
+
plot_examples_2d(
+    e004, "e004: angle_disp = 0",
+    e005, "e005: angle_disp = π/8",
+    e006, "e006: custom angle_deltas function")
 

e004: angle_disp = 0, e005: angle_disp = π/8, e006: custom angle_deltas function

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Manipulating the length of cluster-supporting lines

Using the llength parameter

-
seed = 567
+
seed = 567
 
-
e007 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10],  0, 0, 0.5, rng=rng(seed),
-    point_dist_fn="n")
-e008 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 10, 0, 0.5, rng=rng(seed),
-    point_dist_fn="n")
-e009 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 30, 0, 0.5, rng=rng(seed),
-    point_dist_fn="n")
+
e007 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10],  0, 0, 0.5, rng=rng(seed),
+    point_dist_fn="n")
+e008 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 10, 0, 0.5, rng=rng(seed),
+    point_dist_fn="n")
+e009 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 30, 0, 0.5, rng=rng(seed),
+    point_dist_fn="n")
 
-
plot_examples_2d(
-    e007, "e007: llength = 0",
-    e008, "e008: llength = 10",
-    e009, "e009: llength = 30")
+
plot_examples_2d(
+    e007, "e007: llength = 0",
+    e008, "e008: llength = 10",
+    e009, "e009: llength = 30")
 

e007: llength = 0, e008: llength = 10, e009: llength = 30

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Changing the llength_disp parameter and using a custom llengths_fn function

-
seed = 567
+
seed = 567
 
-
# Custom llengths function: line lengths grow for each new cluster
-def llen_grow_fn(nclu, llen, llenstd, rng):
-    return llen * np.arange(nclu) + rng.normal(scale=llenstd, size=nclu)
+
# Custom llengths function: line lengths grow for each new cluster
+def llen_grow_fn(nclu, llen, llenstd, rng):
+    return llen * np.arange(nclu) + rng.normal(scale=llenstd, size=nclu)
 
-
e010 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 15,  0.0, 0.5, rng=rng(seed),
-    point_dist_fn="n")
-e011 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 15, 10.0, 0.5, rng=rng(seed),
-    point_dist_fn="n")
-e012 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 10,  0.1, 0.5, rng=rng(seed),
-    llengths_fn=llen_grow_fn, point_dist_fn="n")
+
e010 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 15,  0.0, 0.5, rng=rng(seed),
+    point_dist_fn="n")
+e011 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 15, 10.0, 0.5, rng=rng(seed),
+    point_dist_fn="n")
+e012 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 10,  0.1, 0.5, rng=rng(seed),
+    llengths_fn=llen_grow_fn, point_dist_fn="n")
 
-
plot_examples_2d(
-    e010, "e010: llength_disp = 0.0",
-    e011, "e011: llength_disp = 5.0",
-    e012, "e012: custom llengths function")
+
plot_examples_2d(
+    e010, "e010: llength_disp = 0.0",
+    e011, "e011: llength_disp = 5.0",
+    e012, "e012: custom llengths function")
 

e010: llength_disp = 0.0, e011: llength_disp = 5.0, e012: custom llengths function

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Manipulating relative cluster positions

Using the cluster_sep parameter

-
seed = 21
+
seed = 21
 
-
e013 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed))
-e014 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [30, 10], 10, 2, 2.5, rng=rng(seed))
-e015 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 30], 10, 2, 2.5, rng=rng(seed))
+
e013 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed))
+e014 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [30, 10], 10, 2, 2.5, rng=rng(seed))
+e015 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 30], 10, 2, 2.5, rng=rng(seed))
 
-
plt = plot_examples_2d(
-    e013, "e013: cluster_sep = [10, 10]",
-    e014, "e014: cluster_sep = [30, 10]",
-    e015, "e015: cluster_sep = [10, 30]")
+
plt = plot_examples_2d(
+    e013, "e013: cluster_sep = [10, 10]",
+    e014, "e014: cluster_sep = [30, 10]",
+    e015, "e015: cluster_sep = [10, 30]")
 

e013: cluster_sep = [10, 10], e014: cluster_sep = [30, 10], e015: cluster_sep = [10, 30]

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Changing the cluster_offset parameter and using a custom clucenters_fn function

-
seed = 21
+
seed = 21
 
-
# Custom clucenters function: places clusters in a diagonal
-def centers_diag_fn(nclu, csep, coff, rng):
-    return np.ones((nclu, len(csep))) * np.arange(1, nclu + 1)[:, None] * np.max(csep) + coff
+
# Custom clucenters function: places clusters in a diagonal
+def centers_diag_fn(nclu, csep, coff, rng):
+    return np.ones((nclu, len(csep))) * np.arange(1, nclu + 1)[:, None] * np.max(csep) + coff
 
-
e016 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed))
-e017 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed),
-    cluster_offset=[20, -20])
-e018 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed),
-    cluster_offset=[-50, -50], clucenters_fn=centers_diag_fn)
+
e016 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed))
+e017 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed),
+    cluster_offset=[20, -20])
+e018 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed),
+    cluster_offset=[-50, -50], clucenters_fn=centers_diag_fn)
 
-
plt = plot_examples_2d(
-    e016, "e016: default",
-    e017, "e017: cluster_offset = [20, -20]",
-    e018, "e018: custom clucenters function")
+
plt = plot_examples_2d(
+    e016, "e016: default",
+    e017, "e017: cluster_offset = [20, -20]",
+    e018, "e018: custom clucenters function")
 

e016: default, e017: cluster_offset = [20, -20], e018: custom clucenters function

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Lateral dispersion and placement of point projections on the line

Normal projection placement (default): proj_dist_fn = "norm"

-
seed = 654
+
seed = 654
 
-
e019 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed))
-e020 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed))
-e021 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed))
+
e019 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed))
+e020 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed))
+e021 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed))
 
-
plt = plot_examples_2d(
-    e019, "e019: lateral_disp = 0",
-    e020, "e020: lateral_disp = 1",
-    e021, "e021: lateral_disp = 3")
+
plt = plot_examples_2d(
+    e019, "e019: lateral_disp = 0",
+    e020, "e020: lateral_disp = 1",
+    e021, "e021: lateral_disp = 3")
 

e019: lateral_disp = 0, e020: lateral_disp = 1, e021: lateral_disp = 3

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Uniform projection placement: proj_dist_fn = "unif"

-
seed = 654
+
seed = 654
 
-
e022 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed),
-    proj_dist_fn="unif")
-e023 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed),
-    proj_dist_fn="unif")
-e024 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed),
-    proj_dist_fn="unif")
+
e022 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed),
+    proj_dist_fn="unif")
+e023 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed),
+    proj_dist_fn="unif")
+e024 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed),
+    proj_dist_fn="unif")
 
-
plt = plot_examples_2d(
-    e022, "e022: lateral_disp = 0",
-    e023, "e023: lateral_disp = 1",
-    e024, "e024: lateral_disp = 3")
+
plt = plot_examples_2d(
+    e022, "e022: lateral_disp = 0",
+    e023, "e023: lateral_disp = 1",
+    e024, "e024: lateral_disp = 3")
 

e022: lateral_disp = 0, e023: lateral_disp = 1, e024: lateral_disp = 3

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Custom projection placement using the Laplace distribution

-
# Custom proj_dist_fn: point projections placed using the Laplace distribution
-def proj_laplace(len, n, rng):
-    return rng.laplace(scale=len / 6, size=n)
+
# Custom proj_dist_fn: point projections placed using the Laplace distribution
+def proj_laplace(len, n, rng):
+    return rng.laplace(scale=len / 6, size=n)
 
-
e025 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed),
-    proj_dist_fn=proj_laplace)
-e026 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed),
-    proj_dist_fn=proj_laplace)
-e027 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed),
-    proj_dist_fn=proj_laplace)
+
e025 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed),
+    proj_dist_fn=proj_laplace)
+e026 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed),
+    proj_dist_fn=proj_laplace)
+e027 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed),
+    proj_dist_fn=proj_laplace)
 
-
plt = plot_examples_2d(
-    e025, "e025: lateral_disp = 0",
-    e026, "e026: lateral_disp = 1",
-    e027, "e027: lateral_disp = 3")
+
plt = plot_examples_2d(
+    e025, "e025: lateral_disp = 0",
+    e026, "e026: lateral_disp = 1",
+    e027, "e027: lateral_disp = 3")
 

e025: lateral_disp = 0, e026: lateral_disp = 1, e027: lateral_disp = 3

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Controlling final point positions from their projections on the cluster-supporting line

Points on hyperplane orthogonal to cluster-supporting line (default): point_dist_fn = "n-1"

-
seed = 1357
+
seed = 1357
 
-
# Custom proj_dist_fn: point projections placed using the Laplace distribution
-def proj_laplace(len, n, rng):
-    return rng.laplace(scale=len / 6, size=n)
+
# Custom proj_dist_fn: point projections placed using the Laplace distribution
+def proj_laplace(len, n, rng):
+    return rng.laplace(scale=len / 6, size=n)
 
-
e028 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed))
-e029 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
-    proj_dist_fn="unif")
-e030 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
-    proj_dist_fn=proj_laplace)
+
e028 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed))
+e029 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
+    proj_dist_fn="unif")
+e030 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
+    proj_dist_fn=proj_laplace)
 
-
plt = plot_examples_2d(
-    e028, "e028: proj_dist_fn=\"norm\" (default)",
-    e029, "e029: proj_dist_fn=\"unif\"",
-    e030, "e030: custom proj_dist_fn (Laplace)")
+
plt = plot_examples_2d(
+    e028, "e028: proj_dist_fn=\"norm\" (default)",
+    e029, "e029: proj_dist_fn=\"unif\"",
+    e030, "e030: custom proj_dist_fn (Laplace)")
 

e028: proj_dist_fn="norm" (default), e029: proj_dist_fn="unif", e030: custom proj_dist_fn (Laplace)

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Points around projection on cluster-supporting line: point_dist_fn = "n"

-
seed = 1357
+
seed = 1357
 
-
# Custom proj_dist_fn: point projections placed using the Laplace distribution
-def proj_laplace(len, n, rng):
-    return rng.laplace(scale=len / 6, size=n)
+
# Custom proj_dist_fn: point projections placed using the Laplace distribution
+def proj_laplace(len, n, rng):
+    return rng.laplace(scale=len / 6, size=n)
 
-
e031 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
-    point_dist_fn="n")
-e032 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
-    point_dist_fn="n", proj_dist_fn="unif")
-e033 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
-    point_dist_fn="n", proj_dist_fn=proj_laplace)
+
e031 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
+    point_dist_fn="n")
+e032 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
+    point_dist_fn="n", proj_dist_fn="unif")
+e033 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
+    point_dist_fn="n", proj_dist_fn=proj_laplace)
 
-
plt = plot_examples_2d(
-    e031, "e031: proj_dist_fn=\"norm\" (default)",
-    e032, "e032: proj_dist_fn=\"unif\"",
-    e033, "e033: custom proj_dist_fn (Laplace)")
+
plt = plot_examples_2d(
+    e031, "e031: proj_dist_fn=\"norm\" (default)",
+    e032, "e032: proj_dist_fn=\"unif\"",
+    e033, "e033: custom proj_dist_fn (Laplace)")
 

e031: proj_dist_fn="norm" (default), e032: proj_dist_fn="unif", e033: custom proj_dist_fn (Laplace)

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Custom point placement using the exponential distribution

@@ -1896,325 +1046,119 @@

Custom point helper function:

-
from pyclugen import clupoints_n_1_template
+
from pyclugen import clupoints_n_1_template
 
-
seed = 1357
+
seed = 1357
 
-
# Custom point_dist_fn: final points placed using the Exponential distribution
-def clupoints_n_1_exp(projs, lat_std, len, clu_dir, clu_ctr, rng):
-    def dist_exp(npts, lstd, rg):
-        return lstd * rg.exponential(scale=2 / lstd, size=npts)
-    return clupoints_n_1_template(projs, lat_std, clu_dir, dist_exp, rng=rng)
+
# Custom point_dist_fn: final points placed using the Exponential distribution
+def clupoints_n_1_exp(projs, lat_std, len, clu_dir, clu_ctr, rng):
+    def dist_exp(npts, lstd, rg):
+        return lstd * rg.exponential(scale=2 / lstd, size=npts)
+    return clupoints_n_1_template(projs, lat_std, clu_dir, dist_exp, rng=rng)
 
-
# Custom proj_dist_fn: point projections placed using the Laplace distribution
-def proj_laplace(len, n, rng):
-    return rng.laplace(scale=len / 6, size=n)
+
# Custom proj_dist_fn: point projections placed using the Laplace distribution
+def proj_laplace(len, n, rng):
+    return rng.laplace(scale=len / 6, size=n)
 
-
e034 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
-    point_dist_fn=clupoints_n_1_exp)
-e035 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
-    point_dist_fn=clupoints_n_1_exp, proj_dist_fn="unif")
-e036 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
-    point_dist_fn=clupoints_n_1_exp, proj_dist_fn=proj_laplace)
+
e034 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
+    point_dist_fn=clupoints_n_1_exp)
+e035 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
+    point_dist_fn=clupoints_n_1_exp, proj_dist_fn="unif")
+e036 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),
+    point_dist_fn=clupoints_n_1_exp, proj_dist_fn=proj_laplace)
 
-
plt = plot_examples_2d(
-    e034, "e034: proj_dist_fn=\"norm\" (default)",
-    e035, "e035: proj_dist_fn=\"unif\"",
-    e036, "e036: custom proj_dist_fn (Laplace)")
+
plt = plot_examples_2d(
+    e034, "e034: proj_dist_fn=\"norm\" (default)",
+    e035, "e035: proj_dist_fn=\"unif\"",
+    e036, "e036: custom proj_dist_fn (Laplace)")
 

e034: proj_dist_fn="norm" (default), e035: proj_dist_fn="unif", e036: custom proj_dist_fn (Laplace)

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Manipulating cluster sizes

-
seed = 963
+
seed = 963
 
-
# Custom clusizes_fn (e038): cluster sizes determined via the uniform distribution,
-# no correction for total points
-def clusizes_unif(nclu, npts, ae, rng):
-    return rng.integers(low=1, high=2 * npts / nclu + 1, size=nclu)
+
# Custom clusizes_fn (e038): cluster sizes determined via the uniform distribution,
+# no correction for total points
+def clusizes_unif(nclu, npts, ae, rng):
+    return rng.integers(low=1, high=2 * npts / nclu + 1, size=nclu)
 
-
# Custom clusizes_fn (e039): clusters all have the same size, no correction for total points
-def clusizes_equal(nclu, npts, ae, rng):
-    return (npts // nclu) * np.ones(nclu, dtype=int)
+
# Custom clusizes_fn (e039): clusters all have the same size, no correction for total points
+def clusizes_equal(nclu, npts, ae, rng):
+    return (npts // nclu) * np.ones(nclu, dtype=int)
 
-
# Custom clucenters_fn (all): yields fixed positions for the clusters
-def centers_fixed(nclu, csep, coff, rng):
-    return np.array([[-csep[0], -csep[1]], [csep[0], -csep[1]], [-csep[0], csep[1]], [csep[0], csep[1]]])
+
# Custom clucenters_fn (all): yields fixed positions for the clusters
+def centers_fixed(nclu, csep, coff, rng):
+    return np.array([[-csep[0], -csep[1]], [csep[0], -csep[1]], [-csep[0], csep[1]], [csep[0], csep[1]]])
 
-
e037 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),
-    point_dist_fn="n", clucenters_fn=centers_fixed)
-e038 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),
-    point_dist_fn="n", clucenters_fn=centers_fixed, clusizes_fn=clusizes_unif)
-e039 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),
-    point_dist_fn="n", clucenters_fn=centers_fixed, clusizes_fn=clusizes_equal)
+
e037 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),
+    point_dist_fn="n", clucenters_fn=centers_fixed)
+e038 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),
+    point_dist_fn="n", clucenters_fn=centers_fixed, clusizes_fn=clusizes_unif)
+e039 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),
+    point_dist_fn="n", clucenters_fn=centers_fixed, clusizes_fn=clusizes_equal)
 
-
plt = plot_examples_2d(
-    e037, "e037: normal dist. (default)",
-    e038, "e038: unif. dist. (custom)",
-    e039, "e039: equal size (custom)")
+
plt = plot_examples_2d(
+    e037, "e037: normal dist. (default)",
+    e038, "e038: unif. dist. (custom)",
+    e039, "e039: equal size (custom)")
 

e037: normal dist. (default), e038: unif. dist. (custom), e039: equal size (custom)

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Direct specification of optional parameters

-
seed = 123
+
seed = 123
 
-
e040 = clugen(2, 4, 1000, [-1, 1], 0, [0, 0], 0, 0, 0.2, rng=rng(seed),
-    proj_dist_fn="unif", point_dist_fn="n", clusizes_fn=[50, 200, 500, 2000],
-    llengths_fn=[0, 2, 4, 6], clucenters_fn=[[-5, -5], [-2.5, -2.5], [0, 0], [2.5, 2.5]])
-
-e041 = clugen(2, 5, 1000, [[1, 1], [1, 0], [1, 0], [0, 1], [0, 1]],
-    0, [0, 0], 0, 0, 0.2, rng=rng(seed),
-    proj_dist_fn="unif", point_dist_fn="n",
-    clusizes_fn=[200, 500, 500, 500, 500], llengths_fn=[0, 5, 5, 5, 5],
-    clucenters_fn=[[0, 0], [0, 5], [0, -5], [5, 0], [-5, 0]])
-
-e042 = clugen(2, 5, 1000, [[0, 1], [0.25, 0.75], [0.5, 0.5], [0.75, 0.25], [1, 0]],
-    0, [0, 0], 5, 0, 0.2, rng=rng(seed),
-    proj_dist_fn="unif", point_dist_fn="n", clusizes_fn=[500, 500, 500, 500, 500],
-    clucenters_fn=[[-5, 0], [-3, -0.3], [-1, -0.8], [1, -1.6], [3, -2.5]])
+
e040 = clugen(2, 4, 1000, [-1, 1], 0, [0, 0], 0, 0, 0.2, rng=rng(seed),
+    proj_dist_fn="unif", point_dist_fn="n", clusizes_fn=[50, 200, 500, 2000],
+    llengths_fn=[0, 2, 4, 6], clucenters_fn=[[-5, -5], [-2.5, -2.5], [0, 0], [2.5, 2.5]])
+
+e041 = clugen(2, 5, 1000, [[1, 1], [1, 0], [1, 0], [0, 1], [0, 1]],
+    0, [0, 0], 0, 0, 0.2, rng=rng(seed),
+    proj_dist_fn="unif", point_dist_fn="n",
+    clusizes_fn=[200, 500, 500, 500, 500], llengths_fn=[0, 5, 5, 5, 5],
+    clucenters_fn=[[0, 0], [0, 5], [0, -5], [5, 0], [-5, 0]])
+
+e042 = clugen(2, 5, 1000, [[0, 1], [0.25, 0.75], [0.5, 0.5], [0.75, 0.25], [1, 0]],
+    0, [0, 0], 5, 0, 0.2, rng=rng(seed),
+    proj_dist_fn="unif", point_dist_fn="n", clusizes_fn=[500, 500, 500, 500, 500],
+    clucenters_fn=[[-5, 0], [-3, -0.3], [-1, -0.8], [1, -1.6], [3, -2.5]])
 
-
plt = plot_examples_2d(
-    e040, "e040: direct params 1",
-    e041, "e041: direct params 2",
-    e042, "e042: direct params 3")
+
plt = plot_examples_2d(
+    e040, "e040: direct params 1",
+    e041, "e041: direct params 2",
+    e042, "e042: direct params 3")
 

e040: direct params 1, e041: direct params 2, e042: direct params 3

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-
-

Total running time of the script: ( 0 minutes 13.505 seconds)

+

Total running time of the script: ( 0 minutes 19.947 seconds)

Download Python source code: plot_2_2d_examples.py

diff --git a/generated/gallery/plot_2_2d_examples_codeobj.pickle b/generated/gallery/plot_2_2d_examples_codeobj.pickle index 2e2b6d00bd5878b451ad70c24678130233eaadad..3035368ffd98bb0bf255a0f6e8a86c532532fb4c 100644 GIT binary patch literal 6534 zcmcIoJ&YSg6h3n2%N@4EMG=9dNI{bzBD3ptLaqo>xad+KB?v`I6>TQ#v3E!7*=2vk z9T8Frikxr-i=d#1gy;|rf`W#EhJq#y5)?FP(@@Y*z?+@jnXxVFHX`q;v%TN@-n{p{ zpV|AZ&+eUCDgUNzFA78IWkJN#V%olu3~54#R|79AJ}q8-w>URlqgH=V+%C?2C_Zp9 zp~ZA#C(P4~CIDHVM8iCU@4E567v^KidlM4yV%m{ExTzl{89?fv;ol&2y^y47agc*i z|EOWl-!z`|+y0i{J;AKX1;oVZin*t%t)~I=9 zT#??i6F%;RBo2v38@RG7UD@Dqk0c4%*Up@-Ja%iR+$eD;H1nh3!hzn_?zN;D@UF%4 zNxU!4dtJIFDyOdrbkV@W|5voP6orLV7k3nea|!7bfu!h&90ok2W6@F$*Ao{oGJRga zc$7>Ui7=I*);l}bF4p}FT1oX8QgWiqUoRni7)^R^?2X|$=q4TW`@-)&$fYnfa_)&H z5G|Jb+G6LeAiG96O-L3cLUgB1>fYTTbD_W1KQE_Qu+!MV1*G=#W9{ctoV;q@7M6m( z&?3EnB+`eHqO00o&Vx|{m3}P+C%ORET=`bIwiSm_=F&Yfi9=}1{h<+wx|=QZuI-K|3T7;6JZ7WCq-dnQT(DP9IQ$CNKx2W1KK}=ce#Zrg@sp!~Q#j;s0 zkc5xL(kZS+kg=!OAldoKl0>c(*gC)zBwEM&bwzd@Mo%2Uf|R=4wV~0+ht~)jRPeG) zY@}-kyR4jqxDT-6zH74BNF~p1D3+s;-H21Mi&nYas0ZQv9A!5vl+5H>37g5|EoBx$ zWFvJ_cE@C~kVXOvOqM=YA`+9u#%dY&Ocn<#Vjn4%u1DdDlceq_*rQ@alZsictb+<# zR24vi5n`M70zdNu63~A_YTg{M<6;k8_YsNoOhXWP|OIv@NEH+kQ{cEx~ zSS%Yy>dn3d%`OgfuWOCMh%ENiZUvC4I|7KA*0!bWt;S)d+rf3%Hg4|6<>F|*ab+)7 kfU+I*kzT&AGs-Qo*u37Tle_)-A_PQP5yt7BG07eTbwh%eL`6gh(p0)@rn~4r`$u<` zpeIS7LB#f`M?t)a9`zuIHxWb-!Gjl%den>HtFG$m>K$gc5#Qdnx8D2Sdtbf3+IRXN zzV$$_`YDEX7FVEUTWDsNz?L9 z4vO8A#fC(3H;aCl2k}Aa4&Br4=uS?HbviMhls3T8!JeO|8BNj>4sXQ=wx2I(I1Y#x zf>1H2zm!~BXm5#V2Zruh0dXn`7h~IvJexZ!g=+UWPU8*O^$-^#+^)$*B)cAMT%RC8 zJfR>A6A9vyfVc-JiX$(~QY*9!i|)rAg8Y;U@)Rq`S5yQ{EQsq0!ocG3l?K8<;*ki5 z5zi8!kuG@l9iJz2E>`8q49l`eId5JdOZ>L({%-OJhJF?CsiOVS$cfVrA3oI?4pAfWNJyOp&%Oc3Vf8U{(6}6-xj4y{i{A82LNo z!+m;xA6v1#fOALm{YJ8L&u>Ijzh@s;rq#p5=vgmorWCO1T+6DPUe;|WS<=(l#wE$d z)K6QcHqIQYn@=Y9w;wMu3gwJs^_$p{#q4v*o+xIk6hW}`Cn@%&;v6#Gz{_KTDf#I9Fj zKx1>`epMFns*Tlae{Z2+MfXn~WrlTA{#Ga(Ktw?H8y?PD&+sksihOOp?4>cuY?mgj zy^{SSH3(AHxQZ4hy%Y6d51h=f`ogA;Vqo>_dv%lv7V{4(lnux$SSlM%R!?x}rI4VZ z7Cc;;Y^SC61W2^VeO&1Sa!ss&%oNH9{x9NC-`bsYTMT!l IB+1AB0zdC(@Bjb+ diff --git a/generated/gallery/plot_3_3d_examples/index.html b/generated/gallery/plot_3_3d_examples/index.html index c49e34e..bce86a3 100644 --- a/generated/gallery/plot_3_3d_examples/index.html +++ b/generated/gallery/plot_3_3d_examples/index.html @@ -765,384 +765,288 @@

Using the directi e045, "e045: direction = [0, 0, 1]")

e043: direction = [1, 0, 0], e044: direction = [1, 1, 1], e045: direction = [0, 0, 1]

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Changing the angle_disp parameter and using a custom angle_deltas_fn function

-
seed = 321
-
-# Custom angle_deltas function: arbitrarily rotate some clusters by 90 degrees
-def angdel_90_fn(nclu, astd, rng):
-    return rng.choice([0, np.pi / 2], size=nclu)
+
seed = 321
+
+# Custom angle_deltas function: arbitrarily rotate some clusters by 90 degrees
+def angdel_90_fn(nclu, astd, rng):
+    return rng.choice([0, np.pi / 2], size=nclu)
 
-
e046 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))
-e047 = clugen(3, 6, 1000, [1, 0, 0], np.pi / 8, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))
-e048 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed),
-    angle_deltas_fn=angdel_90_fn)
+
e046 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))
+e047 = clugen(3, 6, 1000, [1, 0, 0], np.pi / 8, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))
+e048 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed),
+    angle_deltas_fn=angdel_90_fn)
 
-
plt = plot_examples_3d(
-    e046, "e046: angle_disp = 0",
-    e047, "e047: angle_disp = π / 8",
-    e048, "e048: custom angle_deltas function")
+
plt = plot_examples_3d(
+    e046, "e046: angle_disp = 0",
+    e047, "e047: angle_disp = π / 8",
+    e048, "e048: custom angle_deltas function")
 

e046: angle_disp = 0, e047: angle_disp = π / 8, e048: custom angle_deltas function

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Specifying a main direction for each cluster and changing angle_disp

-
seed = 123
-
-# Define a main direction for each cluster
-dirs = [[1, 1, 1], [0, 0, 1], [1, 0, 0], [0, 1, 0], [-1, 1, 1]]
+
seed = 123
+
+# Define a main direction for each cluster
+dirs = [[1, 1, 1], [0, 0, 1], [1, 0, 0], [0, 1, 0], [-1, 1, 1]]
 
-
e049 = clugen(3, 5, 1000, dirs, 0, np.zeros(3), 20, 0, 0.2, proj_dist_fn="unif", rng=rng(seed))
-e050 = clugen(3, 5, 1000, dirs, np.pi / 12, np.zeros(3), 20, 0, 0.2, proj_dist_fn="unif", rng=rng(seed))
-e051 = clugen(3, 5, 1000, dirs, np.pi / 4, np.zeros(3), 20, 0, 0.2, proj_dist_fn="unif", rng=rng(seed))
+
e049 = clugen(3, 5, 1000, dirs, 0, np.zeros(3), 20, 0, 0.2, proj_dist_fn="unif", rng=rng(seed))
+e050 = clugen(3, 5, 1000, dirs, np.pi / 12, np.zeros(3), 20, 0, 0.2, proj_dist_fn="unif", rng=rng(seed))
+e051 = clugen(3, 5, 1000, dirs, np.pi / 4, np.zeros(3), 20, 0, 0.2, proj_dist_fn="unif", rng=rng(seed))
 
-
plot_examples_3d(
-    e049, "e049: angle_disp = 0",
-    e050, "e050: angle_disp = π / 12",
-    e051, "e051: angle_disp = π / 4")
+
plot_examples_3d(
+    e049, "e049: angle_disp = 0",
+    e050, "e050: angle_disp = π / 12",
+    e051, "e051: angle_disp = π / 4")
 

e049: angle_disp = 0, e050: angle_disp = π / 12, e051: angle_disp = π / 4

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Manipulating the length of cluster-supporting lines

Using the llength parameter

-
seed = 789
+
seed = 789
 
-
e052 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 0, 0, 0.5, rng=rng(seed),
-    point_dist_fn="n")
-e053 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 10, 0, 0.5, rng=rng(seed),
-    point_dist_fn="n")
-e054 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 30, 0, 0.5, rng=rng(seed),
-    point_dist_fn="n")
+
e052 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 0, 0, 0.5, rng=rng(seed),
+    point_dist_fn="n")
+e053 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 10, 0, 0.5, rng=rng(seed),
+    point_dist_fn="n")
+e054 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 30, 0, 0.5, rng=rng(seed),
+    point_dist_fn="n")
 
-
plt = plot_examples_3d(
-    e052, "e052: llength = 0",
-    e053, "e053: llength = 10",
-    e054, "e054: llength = 30")
+
plt = plot_examples_3d(
+    e052, "e052: llength = 0",
+    e053, "e053: llength = 10",
+    e054, "e054: llength = 30")
 

e052: llength = 0, e053: llength = 10, e054: llength = 30

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Changing the llength_disp parameter and using a custom llengths_fn function

-
seed = 765
+
seed = 765
 
-
# Custom llengths function: line lengths tend to grow for each new cluster
-def llen_grow_fn(nclu, llen, llenstd, rng):
-    return llen * np.arange(nclu) + rng.normal(scale=llenstd, size=nclu)
-
-e055 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 15,  0.0, 0.5, rng=rng(seed),
-    point_dist_fn="n")
-e056 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 15, 10.0, 0.5, rng=rng(seed),
-    point_dist_fn="n")
-e057 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 10,  0.1, 0.5, rng=rng(seed),
-    point_dist_fn="n", llengths_fn=llen_grow_fn)
+
# Custom llengths function: line lengths tend to grow for each new cluster
+def llen_grow_fn(nclu, llen, llenstd, rng):
+    return llen * np.arange(nclu) + rng.normal(scale=llenstd, size=nclu)
+
+e055 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 15,  0.0, 0.5, rng=rng(seed),
+    point_dist_fn="n")
+e056 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 15, 10.0, 0.5, rng=rng(seed),
+    point_dist_fn="n")
+e057 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 10,  0.1, 0.5, rng=rng(seed),
+    point_dist_fn="n", llengths_fn=llen_grow_fn)
 
-
plt = plot_examples_3d(
-    e055, "e055: llength_disp = 0.0",
-    e056, "e056: llength_disp = 10.0",
-    e057, "e057: custom llengths function")
+
plt = plot_examples_3d(
+    e055, "e055: llength_disp = 0.0",
+    e056, "e056: llength_disp = 10.0",
+    e057, "e057: custom llengths function")
 

e055: llength_disp = 0.0, e056: llength_disp = 10.0, e057: custom llengths function

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Manipulating relative cluster positions

Using the cluster_sep parameter

-
seed = 765
+
seed = 765
 
-
e058 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [30, 10, 10], 25, 4, 3, rng=rng(seed))
-e059 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 30, 10], 25, 4, 3, rng=rng(seed))
-e060 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 30], 25, 4, 3, rng=rng(seed))
+
e058 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [30, 10, 10], 25, 4, 3, rng=rng(seed))
+e059 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 30, 10], 25, 4, 3, rng=rng(seed))
+e060 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 30], 25, 4, 3, rng=rng(seed))
 
-
plt = plot_examples_3d(
-    e058, "e058: cluster_sep = [30, 10, 10]",
-    e059, "e059: cluster_sep = [10, 30, 10]",
-    e060, "e060: cluster_sep = [10, 10, 30]")
+
plt = plot_examples_3d(
+    e058, "e058: cluster_sep = [30, 10, 10]",
+    e059, "e059: cluster_sep = [10, 30, 10]",
+    e060, "e060: cluster_sep = [10, 10, 30]")
 

e058: cluster_sep = [30, 10, 10], e059: cluster_sep = [10, 30, 10], e060: cluster_sep = [10, 10, 30]

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Changing the cluster_offset parameter and using a custom clucenters_fn function

-
# Custom clucenters function: places clusters in a diagonal
-def centers_diag_fn(nclu, csep, coff, rng):
-    return np.ones((nclu, len(csep))) * np.arange(1, nclu + 1)[:, None] * np.max(csep) + coff
-
-e061 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed))
-e062 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed),
-    cluster_offset=[30, -30, 30])
-e063 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed),
-    cluster_offset=[-40, -40, -40], clucenters_fn=centers_diag_fn)
+
# Custom clucenters function: places clusters in a diagonal
+def centers_diag_fn(nclu, csep, coff, rng):
+    return np.ones((nclu, len(csep))) * np.arange(1, nclu + 1)[:, None] * np.max(csep) + coff
+
+e061 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed))
+e062 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed),
+    cluster_offset=[30, -30, 30])
+e063 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed),
+    cluster_offset=[-40, -40, -40], clucenters_fn=centers_diag_fn)
 
-
plt = plot_examples_3d(
-    e061, "e061: default",
-    e062, "e062: cluster_offset=[30, -30, 30]",
-    e063, "e063: custom clucenters function")
+
plt = plot_examples_3d(
+    e061, "e061: default",
+    e062, "e062: cluster_offset=[30, -30, 30]",
+    e063, "e063: custom clucenters function")
 

e061: default, e062: cluster_offset=[30, -30, 30], e063: custom clucenters function

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Lateral dispersion and placement of point projections on the line

Normal projection placement (default): proj_dist_fn="norm"

-
seed = 246
+
seed = 246
 
-
e064 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed))
-e065 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed))
-e066 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed))
+
e064 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed))
+e065 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed))
+e066 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed))
 
-
plt = plot_examples_3d(
-    e064, "e064: lateral_disp = 0",
-    e065, "e065: lateral_disp = 1",
-    e066, "e066: lateral_disp = 3")
+
plt = plot_examples_3d(
+    e064, "e064: lateral_disp = 0",
+    e065, "e065: lateral_disp = 1",
+    e066, "e066: lateral_disp = 3")
 

e064: lateral_disp = 0, e065: lateral_disp = 1, e066: lateral_disp = 3

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Uniform projection placement: proj_dist_fn="unif"

-
seed = 246
+
seed = 246
 
-
e067 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed),
-    proj_dist_fn="unif")
-e068 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed),
-    proj_dist_fn="unif")
-e069 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed),
-    proj_dist_fn="unif")
+
e067 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed),
+    proj_dist_fn="unif")
+e068 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed),
+    proj_dist_fn="unif")
+e069 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed),
+    proj_dist_fn="unif")
 
-
plt = plot_examples_3d(
-    e067, "e067: lateral_disp = 0",
-    e068, "e068: lateral_disp = 1",
-    e069, "e069: lateral_disp = 3")
+
plt = plot_examples_3d(
+    e067, "e067: lateral_disp = 0",
+    e068, "e068: lateral_disp = 1",
+    e069, "e069: lateral_disp = 3")
 

e067: lateral_disp = 0, e068: lateral_disp = 1, e069: lateral_disp = 3

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Custom projection placement using the Laplace distribution

-
seed = 246
+
seed = 246
 
-
# Custom proj_dist_fn: point projections placed using the Laplace distribution
-def proj_laplace(len, n, rng):
-    return rng.laplace(scale=len / 6, size=n)
+
# Custom proj_dist_fn: point projections placed using the Laplace distribution
+def proj_laplace(len, n, rng):
+    return rng.laplace(scale=len / 6, size=n)
 
-
e070 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed),
-    proj_dist_fn=proj_laplace)
-e071 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed),
-    proj_dist_fn=proj_laplace)
-e072 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed),
-    proj_dist_fn=proj_laplace)
+
e070 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed),
+    proj_dist_fn=proj_laplace)
+e071 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed),
+    proj_dist_fn=proj_laplace)
+e072 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed),
+    proj_dist_fn=proj_laplace)
 
-
plt = plot_examples_3d(
-    e070, "e070: lateral_disp = 0",
-    e071, "e071: lateral_disp = 1",
-    e072, "e072: lateral_disp = 3")
+
plt = plot_examples_3d(
+    e070, "e070: lateral_disp = 0",
+    e071, "e071: lateral_disp = 1",
+    e072, "e072: lateral_disp = 3")
 

e070: lateral_disp = 0, e071: lateral_disp = 1, e072: lateral_disp = 3

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Controlling final point positions from their projections on the cluster-supporting line

Points on hyperplane orthogonal to cluster-supporting line (default): point_dist_fn="n-1"

-
seed = 840
+
seed = 840
 
-
# Custom proj_dist_fn: point projections placed using the Laplace distribution
-def proj_laplace(len, n, rng):
-    return rng.laplace(scale=len / 6, size=n)
+
# Custom proj_dist_fn: point projections placed using the Laplace distribution
+def proj_laplace(len, n, rng):
+    return rng.laplace(scale=len / 6, size=n)
 
-
e073 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed))
-e074 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
-    proj_dist_fn="unif")
-e075 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
-    proj_dist_fn=proj_laplace)
+
e073 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed))
+e074 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
+    proj_dist_fn="unif")
+e075 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
+    proj_dist_fn=proj_laplace)
 
-
plt = plot_examples_3d(
-    e073, "e073: proj_dist_fn=\"norm\" (default)",
-    e074, "e074: proj_dist_fn=\"unif\"",
-    e075, "e075: custom proj_dist_fn (Laplace)")
+
plt = plot_examples_3d(
+    e073, "e073: proj_dist_fn=\"norm\" (default)",
+    e074, "e074: proj_dist_fn=\"unif\"",
+    e075, "e075: custom proj_dist_fn (Laplace)")
 

e073: proj_dist_fn="norm" (default), e074: proj_dist_fn="unif", e075: custom proj_dist_fn (Laplace)

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Points around projection on cluster-supporting line: point_dist_fn="n"

-
seed = 840
+
seed = 840
 
-
# Custom proj_dist_fn: point projections placed using the Laplace distribution
-def proj_laplace(len, n, rng):
-    return rng.laplace(scale=len / 6, size=n)
-
-e076 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
-    point_dist_fn="n")
-e077 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
-    point_dist_fn="n", proj_dist_fn="unif")
-e078 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
-    point_dist_fn="n", proj_dist_fn=proj_laplace)
+
# Custom proj_dist_fn: point projections placed using the Laplace distribution
+def proj_laplace(len, n, rng):
+    return rng.laplace(scale=len / 6, size=n)
+
+e076 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
+    point_dist_fn="n")
+e077 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
+    point_dist_fn="n", proj_dist_fn="unif")
+e078 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
+    point_dist_fn="n", proj_dist_fn=proj_laplace)
 
-
plt = plot_examples_3d(
-    e076, "e076: proj_dist_fn=\"norm\" (default)",
-    e077, "e077: proj_dist_fn=\"unif\"",
-    e078, "e078: custom proj_dist_fn (Laplace)")
+
plt = plot_examples_3d(
+    e076, "e076: proj_dist_fn=\"norm\" (default)",
+    e077, "e077: proj_dist_fn=\"unif\"",
+    e078, "e078: custom proj_dist_fn (Laplace)")
 

e076: proj_dist_fn="norm" (default), e077: proj_dist_fn="unif", e078: custom proj_dist_fn (Laplace)

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Custom point placement using the exponential distribution

@@ -1151,107 +1055,91 @@

Custom point helper function:

-
from pyclugen import clupoints_n_1_template
+
from pyclugen import clupoints_n_1_template
 
-
seed = 840
+
seed = 840
 
-
# Custom point_dist_fn: final points placed using the Exponential distribution
-def clupoints_n_1_exp(projs, lat_std, len, clu_dir, clu_ctr, rng):
-    def dist_exp(npts, lstd, rg):
-        return lstd * rg.exponential(scale=2 / lstd, size=npts)
-    return clupoints_n_1_template(projs, lat_std, clu_dir, dist_exp, rng=rng)
+
# Custom point_dist_fn: final points placed using the Exponential distribution
+def clupoints_n_1_exp(projs, lat_std, len, clu_dir, clu_ctr, rng):
+    def dist_exp(npts, lstd, rg):
+        return lstd * rg.exponential(scale=2 / lstd, size=npts)
+    return clupoints_n_1_template(projs, lat_std, clu_dir, dist_exp, rng=rng)
 
-
# Custom proj_dist_fn: point projections placed using the Laplace distribution
-def proj_laplace(len, n, rng):
-    return rng.laplace(scale=len / 6, size=n)
+
# Custom proj_dist_fn: point projections placed using the Laplace distribution
+def proj_laplace(len, n, rng):
+    return rng.laplace(scale=len / 6, size=n)
 
-
e079 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
-    point_dist_fn=clupoints_n_1_exp)
-e080 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
-    point_dist_fn=clupoints_n_1_exp, proj_dist_fn="unif")
-e081 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
-    point_dist_fn=clupoints_n_1_exp, proj_dist_fn=proj_laplace)
+
e079 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
+    point_dist_fn=clupoints_n_1_exp)
+e080 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
+    point_dist_fn=clupoints_n_1_exp, proj_dist_fn="unif")
+e081 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),
+    point_dist_fn=clupoints_n_1_exp, proj_dist_fn=proj_laplace)
 
-
plt = plot_examples_3d(
-    e079, "e079: proj_dist_fn=\"norm\" (default)",
-    e080, "e080: proj_dist_fn=\"unif\"",
-    e081, "e081: custom proj_dist_fn (Laplace)")
+
plt = plot_examples_3d(
+    e079, "e079: proj_dist_fn=\"norm\" (default)",
+    e080, "e080: proj_dist_fn=\"unif\"",
+    e081, "e081: custom proj_dist_fn (Laplace)")
 

e079: proj_dist_fn="norm" (default), e080: proj_dist_fn="unif", e081: custom proj_dist_fn (Laplace)

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-

Manipulating cluster sizes

-
seed = 555
+
seed = 555
 
-
# Custom clusizes_fn (e083): cluster sizes determined via the uniform distribution,
-# no correction for total points
-def clusizes_unif(nclu, npts, ae, rng):
-    return rng.integers(low=1, high=2 * npts / nclu + 1, size=nclu)
+
# Custom clusizes_fn (e083): cluster sizes determined via the uniform distribution,
+# no correction for total points
+def clusizes_unif(nclu, npts, ae, rng):
+    return rng.integers(low=1, high=2 * npts / nclu + 1, size=nclu)
 
-
# Custom clusizes_fn (e084): clusters all have the same size, no correction for total points
-def clusizes_equal(nclu, npts, ae, rng):
-    return (npts // nclu) * np.ones(nclu, dtype=int)
+
# Custom clusizes_fn (e084): clusters all have the same size, no correction for total points
+def clusizes_equal(nclu, npts, ae, rng):
+    return (npts // nclu) * np.ones(nclu, dtype=int)
 
-
# Custom clucenters_fn (all): yields fixed positions for the clusters
-def centers_fixed(nclu, csep, coff, rng):
-    return np.array([
-        [-csep[0], -csep[1], -csep[2]],
-        [csep[0], -csep[1], -csep[2]],
-        [-csep[0], csep[1], csep[2]],
-        [csep[0], csep[1], csep[2]]])
+
# Custom clucenters_fn (all): yields fixed positions for the clusters
+def centers_fixed(nclu, csep, coff, rng):
+    return np.array([
+        [-csep[0], -csep[1], -csep[2]],
+        [csep[0], -csep[1], -csep[2]],
+        [-csep[0], csep[1], csep[2]],
+        [csep[0], csep[1], csep[2]]])
 
-
e082 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),
-    clucenters_fn=centers_fixed, point_dist_fn="n")
-e083 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),
-    clucenters_fn=centers_fixed, clusizes_fn=clusizes_unif, point_dist_fn="n")
-e084 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),
-    clucenters_fn=centers_fixed, clusizes_fn=clusizes_equal, point_dist_fn="n")
+
e082 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),
+    clucenters_fn=centers_fixed, point_dist_fn="n")
+e083 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),
+    clucenters_fn=centers_fixed, clusizes_fn=clusizes_unif, point_dist_fn="n")
+e084 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),
+    clucenters_fn=centers_fixed, clusizes_fn=clusizes_equal, point_dist_fn="n")
 
-
plt = plot_examples_3d(
-    e082, "e082: normal dist. (default)",
-    e083, "e083: unif. dist. (custom)",
-    e084, "e084: equal size (custom)")
+
plt = plot_examples_3d(
+    e082, "e082: normal dist. (default)",
+    e083, "e083: unif. dist. (custom)",
+    e084, "e084: equal size (custom)")
 

e082: normal dist. (default), e083: unif. dist. (custom), e084: equal size (custom)

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_xlim(xmins[0], xmaxs[0])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_ylim(xmins[1], xmaxs[1])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ax.set_zlim(xmins[2], xmaxs[2])
-
-

Total running time of the script: ( 0 minutes 5.871 seconds)

+

Total running time of the script: ( 0 minutes 7.542 seconds)

Download Python source code: plot_3_3d_examples.py

diff --git a/generated/gallery/plot_3_3d_examples_codeobj.pickle b/generated/gallery/plot_3_3d_examples_codeobj.pickle index 6c6e07510fe535a07a19d06aa7eddc51304c755c..5912d0c6c69905e7d08e716833992e6f640a5eb9 100644 GIT binary patch delta 907 zcmYk3OK1~O6oz}RlgCUlnWRaYMrlwZwOES@nMoRHeLyQnrMgQ&Bb}O|m%+vdgdkKY z1sB>V4Sy{arMl3CNDJL4ZmdgPD5xvzqPny0s*8#)bY_~Fy1VE9zw^51uKYmeCR}$S zb*_ubxq4>8#c3%eg*sm#ailyWWH+j0gmhw!A0aY6iaCkpnRuh3*4*dLS4OomR>Mik z4q>)+7iC9L3CJFH%p&l|bA$|_$D42unu3Pg-XbYrU$crn?l3O+yF5(aM4tuglvVLA zv;(7|Dat0X5z0e~rYM`jVxW(*X>0`AL?yOr8^m`3gMJQh6AK5G>xjlmZ#4+b%dAdmODV88hco@;}GAuyx?Uj~o z#H=o7%~7P+b`?ugOpUxpsYT;f3F$q%i%ubj$B0H zDQ(;knos6EjYvf`p62~dbShY+Q3~QOkpy0}rbrUsTN6^doovpL%~+p)z|e5oyWcpT SlfLdfL-k(#ifIUJ_x%H_tOjiW delta 1041 zcmY*YTSyd97L4`nH zifAF$-yk9NMM8)Y-zthCh#rD^k;0P5haU2wmmVu<&g{(OzMb#;zyJF$=bSZVS;6!C zU0)HOKx(YmH4odKene`a&U*-vI>^bIhcprIt-M~qdQ^qIniL|(ptrV5ARUa?U@H)W zg+MbR3Ty;oh^VmQ(-0Ye9`8v+PQ#p66UdP10dmc#m!urOWEA$e6tv+!*spF82rW5& zkz2fE!aTF8N}Q><84!dtw*Vjf34z=wDYJgV?~dcAcACn2FjyV;kQK*4g;PGG?*|}r zX=(Gn9KLZQ@{nId36x?_C$fdcT@YMZ~`wf!R4ZFePBIYV8Od+&| z6`yD$HhkRZF;z*cIrtmShz(XqhYXImX``)#i{hwEkJ?d|m}I*cmTBifGM->0PkRg! zx{>Oq1GWXrNf>(?!RJ`;EmC+o#7_OL!FGDVl36R6)2Ak;%T_{%Erkw#d5pURiciPH z;EInlH=T5XtKl(m&Oyt#$kUq!gvWdXoaJxxbdjOYI1a0lfK>KCj3L(S409#sWQcA+ zUr5JWOn+ZWbI)KsG|0V#AE7vY%}6R}h`xi#ppLg07F>xS-Lagsf?!qNRtvVbNcBAa? Z47+L4CLt4!iM5D example with default opti
plot_examples_nd(e085, "e085: 5D with optional parameters set to defaults")
 

e085: 5D with optional parameters set to defaults

-

Out:

-
/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:249: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xycoord = (xmaxs[i] + xmins[i]) / 2
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:255: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  g.axes[i, j].set_xlim([xmins[j], xmaxs[j]])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:256: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  g.axes[i, j].set_ylim([xmins[i], xmaxs[i]])
-

5D example with proj_dist_fn = "unif" and point_dist_fn = "n"

-
seed = 579
+
seed = 579
 
-
# Number of dimensions
-nd = 5
+
# Number of dimensions
+nd = 5
 
-
e086 = clugen(nd, 6, 1500, [0.1, 0.3, 0.5, 0.3, 0.1], np.pi / 12, 30 * np.ones(nd), 35, 5, 3.5,
-    proj_dist_fn="unif", point_dist_fn="n", rng=rng(seed))
+
e086 = clugen(nd, 6, 1500, [0.1, 0.3, 0.5, 0.3, 0.1], np.pi / 12, 30 * np.ones(nd), 35, 5, 3.5,
+    proj_dist_fn="unif", point_dist_fn="n", rng=rng(seed))
 
-
plot_examples_nd(e086, "e086: 5D with proj_dist_fn=\"unif\" and point_dist_fn=\"n\"")
+
plot_examples_nd(e086, "e086: 5D with proj_dist_fn=\"unif\" and point_dist_fn=\"n\"")
 

e086: 5D with proj_dist_fn="unif" and point_dist_fn="n"

-

Out:

-
/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:249: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xycoord = (xmaxs[i] + xmins[i]) / 2
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:255: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  g.axes[i, j].set_xlim([xmins[j], xmaxs[j]])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:256: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  g.axes[i, j].set_ylim([xmins[i], xmaxs[i]])
-

4D example with custom projection placement using the Beta distribution

-
seed = 963
+
seed = 963
 
-
# Number of dimensions
-nd = 4
+
# Number of dimensions
+nd = 4
 
-
# Custom proj_dist_fn: point projections placed using the Beta distribution
-def proj_beta(len, n, rng):
-    return len * rng.beta(0.1, 0.1, size=n) - len / 2
+
# Custom proj_dist_fn: point projections placed using the Beta distribution
+def proj_beta(len, n, rng):
+    return len * rng.beta(0.1, 0.1, size=n) - len / 2
 
-
e087 = clugen(nd, 5, 1500, np.ones(nd), np.pi / 6, 30 * np.ones(nd), 60, 15, 6, rng=rng(seed),
-    proj_dist_fn=proj_beta)
+
e087 = clugen(nd, 5, 1500, np.ones(nd), np.pi / 6, 30 * np.ones(nd), 60, 15, 6, rng=rng(seed),
+    proj_dist_fn=proj_beta)
 
-
plot_examples_nd(e087, "e087: 4D with custom proj_dist_fn (Beta)")
+
plot_examples_nd(e087, "e087: 4D with custom proj_dist_fn (Beta)")
 

e087: 4D with custom proj_dist_fn (Beta)

-

Out:

-
/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:249: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xycoord = (xmaxs[i] + xmins[i]) / 2
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:255: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  g.axes[i, j].set_xlim([xmins[j], xmaxs[j]])
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:256: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  g.axes[i, j].set_ylim([xmins[i], xmaxs[i]])
-
-

Total running time of the script: ( 0 minutes 11.310 seconds)

+

Total running time of the script: ( 0 minutes 15.867 seconds)

Download Python source code: plot_4_nd_examples.py

diff --git a/generated/gallery/plot_4_nd_examples_codeobj.pickle b/generated/gallery/plot_4_nd_examples_codeobj.pickle index a1eeaf8a2017c53d0aab85a022a65c3209d0195f..68e4be8f80d24c91a03039beb0ab36b5a4cfc77d 100644 GIT binary patch delta 418 zcmbQnGmU40UJ7e~v%8tel-Ma6wNo^DSn?8cQ>XMm1$)?X^HWN5fC9pKrMU%_dPRwO zDfzj2@de50Ks`M?5b5~hjQpY!AQxHDlpc=E;`rp8#Ny&9lNniz6nHyIfi`5Y!wk>h z>|q6Kn3BPrA(Fv6c{YpW?P< zcjAA2W?i6^A)^Ab0gyh+WDC@k$E?I=nE_Hdxs6GK*$ybNkx7!-5l9Cx8L+v5q!K3^ zvibqlHn5t3NincB!9XPtk%x?y%rQWoEKox{#H>a}E2!ZaV1bFvx<Y-=`B5wg+xONE*isg-J7h=MD{je>}Tw2hreGpYGmxDXe*urLeD z3_XB1a4qNw+<6D_5TY+hrJMI=zQ1|%hT2ejGETBR-@7uKc4&zUaVv^Urj~09mbr{* zD|9?6nCg1%s2gL=$mxa-4FuCt%nXRzYM@{r5WdO>>}eROOX|CGQRC8Q623{aO) lJ*hgsLpdA(1%5eR1)sx5Kv7&v>I{FyIs5Merging and hierarchical clus

Although it is possible to merge data in any dimension, these examples will focus on merging 2D data. Therefore, we'll use the same plot_examples_2d function used for -the 2D examples:

+the 2D examples:

from plot_functions import plot_examples_2d
@@ -749,84 +749,6 @@ 

Merging two data sets gener e090, "e090: merged data sets")

e088: data set 1, e089: data set 2, e090: merged data sets

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

In the previous example, clusters from individual data sets remain as separate @@ -834,190 +756,38 @@

Merging two data sets gener cluster labels by setting the clusters_field parameter to None:

-
e091 = clumerge(e088, e089, clusters_field=None)
+
e091 = clumerge(e088, e089, clusters_field=None)
 
-
plot_examples_2d(
-    e088, "e088: data set 1",
-    e089, "e089: data set 2",
-    e091, "e091: merged data sets")
+
plot_examples_2d(
+    e088, "e088: data set 1",
+    e089, "e089: data set 2",
+    e091, "e091: merged data sets")
 

e088: data set 1, e089: data set 2, e091: merged data sets

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Adding noise to a clugen()-generated data set

-
seed = 333
+
seed = 333
 
-
prng = rng(seed)
-e092 = {"points": 120 * prng.random((500, 2)) - 60, "clusters": np.ones(500, dtype=np.int32)}
-e093 = clumerge(e092, e090) # clumerge(e092, e088, e089) would also work
+
prng = rng(seed)
+e092 = {"points": 120 * prng.random((500, 2)) - 60, "clusters": np.ones(500, dtype=np.int32)}
+e093 = clumerge(e092, e090) # clumerge(e092, e088, e089) would also work
 
-
plot_examples_2d(
-    e090, "e090: original merged data sets",
-    e092, "e092: random uniform noise",
-    e093, "e093: data sets with noise",
-    pmargin=0)
+
plot_examples_2d(
+    e090, "e090: original merged data sets",
+    e092, "e092: random uniform noise",
+    e093, "e093: data sets with noise",
+    pmargin=0)
 

e090: original merged data sets, e092: random uniform noise, e093: data sets with noise

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

Merging with data not generated with clugen()

@@ -1026,138 +796,46 @@

Merging with data not gener scikit-learn's generators:

-
seed = 321
+
seed = 321
 
-
from sklearn.datasets import make_moons
-
-X, y = make_moons(100, noise=0.05, random_state=seed)
-
-e094 = {"points": X, "clusters": y}
-e095 = clugen(2, 4, 200, [1, 1], np.pi / 12, [1, 1], 0.1, 0.01, 0.25, rng=rng(seed),
-    proj_dist_fn = "unif", point_dist_fn = "n")
-e096 = clumerge(e094, e095)
+
from sklearn.datasets import make_moons
+
+X, y = make_moons(100, noise=0.05, random_state=seed)
+
+e094 = {"points": X, "clusters": y}
+e095 = clugen(2, 4, 200, [1, 1], np.pi / 12, [1, 1], 0.1, 0.01, 0.25, rng=rng(seed),
+    proj_dist_fn = "unif", point_dist_fn = "n")
+e096 = clumerge(e094, e095)
 
-
plt = plot_examples_2d(
-    e094, "e094: generated w/ make_moons()",
-    e095, "e095: generated w/ clugen()",
-    e096, "e096: merged data")
+
plt = plot_examples_2d(
+    e094, "e094: generated w/ make_moons()",
+    e095, "e095: generated w/ clugen()",
+    e096, "e096: merged data")
 

e094: generated w/ make_moons(), e095: generated w/ clugen(), e096: merged data

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-

We can also hierarchize clusters from different sources:

-
e097 = {**e094, "hclusters": np.ones(100, dtype=np.int32)}
-e098 = {**e095._asdict(), "hclusters": 2 * np.ones(200, np.int32)}
-e099 = clumerge(e097, e098, clusters_field="hclusters")
+
e097 = {**e094, "hclusters": np.ones(100, dtype=np.int32)}
+e098 = {**e095._asdict(), "hclusters": 2 * np.ones(200, np.int32)}
+e099 = clumerge(e097, e098, clusters_field="hclusters")
 
-
plt = plot_examples_2d(
-    e097, "e097: generated w/ make_moons()",
-    e098, "e098: generated w/ clugen()",
-    e099, "e099: merged data",
-    clusters_field="hclusters")
+
plt = plot_examples_2d(
+    e097, "e097: generated w/ make_moons()",
+    e098, "e098: generated w/ clugen()",
+    e099, "e099: merged data",
+    clusters_field="hclusters")
 

e097: generated w/ make_moons(), e098: generated w/ clugen(), e099: merged data

-

Out:

-
/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  xlim=(xmins[0], xmaxs[0]),
-/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
-  ylim=(xmins[1], xmaxs[1]),
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
-  if pd.api.types.is_categorical_dtype(vector):
-/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
-  self._figure.tight_layout(*args, **kwargs)
-
-

Total running time of the script: ( 0 minutes 4.270 seconds)

+

Total running time of the script: ( 0 minutes 6.215 seconds)

Download Python source code: plot_5_mrg_examples.py

diff --git a/generated/gallery/plot_5_mrg_examples_codeobj.pickle b/generated/gallery/plot_5_mrg_examples_codeobj.pickle index 81483a307ac0f2f9766310154ca931d57963af9d..a81765abcb4f30517795d39dcd7ada8aed4ff603 100644 GIT binary patch delta 428 zcmYL_PbhUb&09844W6Vc2x%y4VGl&2wVP&*CdRnch_gOaX}IiXFHsIU-?V}`|XBi5kA>e-aj z8?{P=GBA`d&0tz-qB(3TA(}_|PcPzL39@Aue5N#8bLFFSMmt!M2k@nK(;nJ=DSkxE zS@94x-Yz;p(i_l94sT2RHHEDpo#IH+**SMjT*zsxuo%ha+8@o|tMuX{^GL3JSun?xm#=?RrlezgQBOkM{P%PDLxXvsz z<)g&HMyZLylx&pE`~k6&vSDNG-nq)|be?n0b572e^X)~dxE|HIvhnO@RyBAkv7~1W zo?MtUhdPC8P1lnx_>}zSv5Y&Q~8DB~rtF8rW|n(3o0`N-10c$HZ1sbJlni zsg4d1XDxJyT^975*k|3K4fL^qICByUqCs3Z@S3S~i8mIaE6BW#@=$qzZVPlot functionsImport the required libraries

- - -
import matplotlib.pyplot as plt  # type: ignore
-import numpy as np
-import numpy.typing as npt
-import pandas as pd
-import seaborn as sns  # type: ignore
-
-from pyclugen import Clusters
+
+
+
import os
+import warnings
+
+import matplotlib.pyplot as plt  # type: ignore
+import numpy as np
+import numpy.typing as npt
+import pandas as pd
+import seaborn as sns  # type: ignore
+
+from pyclugen import Clusters
+
+# Hide annoying warnings when building docs in CI
+if os.getenv("CI") != None:
+    warnings.filterwarnings("ignore")
 
- +

clusters2df

- +
def clusters2df(
     *exs: Clusters | dict[str, npt.ArrayLike], clusters_field: str = "clusters"
@@ -766,10 +773,10 @@ 

clusters2df return pd.concat(dfs, ignore_index=True)

- +

get_plot_lims

- +
def get_plot_lims(df: pd.DataFrame, pmargin: float = 0.1):
     """Determine the plot limits for the cluster data given in `df`."""
@@ -790,10 +797,10 @@ 

get_plot_lims return xmaxs, xmins

- +

plot_examples_1d

- +
def plot_examples_1d(*ets, ncols: int = 3, clusters_field: str = "clusters"):
     """Plot the 1D examples given in the ets parameter."""
@@ -827,10 +834,10 @@ 

plot_examples_1d for ax, t in zip(g_axes, et): ax.set_title(t)

- +

plot_examples_2d

- +
def plot_examples_2d(
     *ets, pmargin: float = 0.1, ncols: int = 3, clusters_field: str = "clusters"
@@ -855,8 +862,8 @@ 

plot_examples_2d df, col="example", hue="cluster", - xlim=(xmins[0], xmaxs[0]), - ylim=(xmins[1], xmaxs[1]), + xlim=(xmins.iloc[0], xmaxs.iloc[0]), + ylim=(xmins.iloc[1], xmaxs.iloc[1]), aspect=1, col_wrap=ncols, ) @@ -869,10 +876,10 @@

plot_examples_2d ax.set_xlabel("x") ax.set_ylabel("y")

- +

plot_examples_3d

- +
def plot_examples_3d(
     *ets,
@@ -914,9 +921,9 @@ 

plot_examples_3d axs = axs.reshape(-1) for ax, e, t in zip(axs, ex, et): ax.set_title(t, fontsize=10) - ax.set_xlim(xmins[0], xmaxs[0]) - ax.set_ylim(xmins[1], xmaxs[1]) - ax.set_zlim(xmins[2], xmaxs[2]) + ax.set_xlim(xmins.iloc[0], xmaxs.iloc[0]) + ax.set_ylim(xmins.iloc[1], xmaxs.iloc[1]) + ax.set_zlim(xmins.iloc[2], xmaxs.iloc[2]) ax.set_xlabel("$x$", labelpad=-2) ax.set_ylabel("$y$", labelpad=-2) ax.set_zlabel("$z$", labelpad=-2) @@ -937,10 +944,10 @@

plot_examples_3d ax.set_facecolor(color="white") ax.patch.set_alpha(0)

- +

plot_examples_nd

- +
def plot_examples_nd(
     ex: Clusters, t: str, pmargin: float = 0.1, clusters_field: str = "clusters"
@@ -968,17 +975,17 @@ 

plot_examples_nd for j in range(nd): if i == j: # Set the x labels in the diagonal plots - xycoord = (xmaxs[i] + xmins[i]) / 2 + xycoord = (xmaxs.iloc[i] + xmins.iloc[i]) / 2 g.axes[i, i].text( xycoord, xycoord, f"$x{i}$", fontsize=20, ha="center", va="center" ) else: # Set appropriate plot intervals and aspect ratio - g.axes[i, j].set_xlim([xmins[j], xmaxs[j]]) - g.axes[i, j].set_ylim([xmins[i], xmaxs[i]]) + g.axes[i, j].set_xlim([xmins.iloc[j], xmaxs.iloc[j]]) + g.axes[i, j].set_ylim([xmins.iloc[i], xmaxs.iloc[i]]) g.axes[i, j].set_aspect(1)

-

Total running time of the script: ( 0 minutes 0.006 seconds)

+

Total running time of the script: ( 0 minutes 0.007 seconds)

Download Python source code: plot_functions.py

diff --git a/generated/gallery/plot_functions_codeobj.pickle b/generated/gallery/plot_functions_codeobj.pickle index 9f3cc96f012b3dbfa3ebeac58dd779ef769fd997..e5d46985fb643c62bc8912a734f71c4d5cee7c2b 100644 GIT binary patch delta 643 zcmZ1?`9X@cfpuys??hHjA>QJ=V!h(jlK7I0)ZEl5u~RfA+PY5`;8u|5&*14SP3;jc zPb|vI%u6rUOUukDNiBkLC%T6N`;f(ttjh{FY6D%@J(!#J}Z?UXy!Slo@>| z&t%MG44KT#q{tXPIhRR%vJF!NV;q>ZhKZXoaq=%F>B*Owf*3PEEFQLk#JrS5u#MT1 zeVNM{i-4pIvT*6-w?N?7FJiNutjDD$zZ($vIiMh5%`43< zs04+=zR8B%mW+odXLH+6e!!8+cmZtFb&yT0_cC}oN+*Bh5S}c}#l!e;@)B-4xn~H| zm~#^=Pz`%I*_=aL?j4en#3Z24k?s39xtPn6@!RCJT&j#eC+oAPvSu+cGB8Y@#;(Ac j#R_5-vMaM@ae!Di*^F7UctI>ac6pvG0U!(P>ry=coLko1 delta 469 zcmY+8K}ZyF7{&L^&g{%I|4kz*GHG>JL0OepP!p8(qR}l9%m|fb9sRHAurxcB!h#(N z78Y`QBN!AER0JV(^(J@-gbcbwfdpQH4k8HRMR0dcdU-q^-}ioRzv07GZAn{sEh<`j zot2&Q+=BhcO-)Vv<9=oE7BW22Q@FsSG0Z*XF|M;1NuZgfa1L!e2sb0iarFv2)G?$2 z_eQnQ&Hw5(ZmM_DUvnao&p1;V*O!(|b3l87;i@*Cj&F0P8sDkvnRq0?jq)b7HwaeWzF&C^9!}!3BHdwm|?ws9}Z{rEIe-OEqKcB#vqD3Zw~Ncv{R8U zI24U3vcyqgEAkaLM3W*{xGEBgTx9`0c*`${;~m$mBtG)D)rij=Q+lw*mr5L889w(A z>j7vZ0DWVpmB1E<%#PTPQzNr>Ztm>JpFFhs@QXJ@>!m-nOS>F(9kl$MviLF8Rm^{9P^XWDrQ3ng@Q(}>jalp Bn-Ty3 diff --git a/index.html b/index.html index eb0924b..406611e 100644 --- a/index.html +++ b/index.html @@ -729,10 +729,10 @@

Further readingAlso in this documentation

diff --git a/search/search_index.json b/search/search_index.json index 5208b7c..5220ff2 100644 --- a/search/search_index.json +++ b/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"pyclugen","text":"

pyclugen is Python package for generating multidimensional clusters. Each cluster is supported by a line segment, the position, orientation and length of which guide where the respective points are placed. The clugen() function is provided for this purpose, as well as a number of auxiliary functions, used internally and modularly by clugen(). Users can swap these auxiliary functions by their own customized versions, fine-tuning their cluster generation strategies, or even use them as the basis for their own generation algorithms.

"},{"location":"#installation","title":"Installation","text":"

Install from PyPI:

pip install --upgrade pip\npip install pyclugen\n

Or directly from GitHub:

pip install --upgrade pip\npip install git+https://github.com/clugen/pyclugen.git#egg=pyclugen\n
"},{"location":"#quick-start","title":"Quick start","text":"
from pyclugen import clugen\nimport matplotlib.pyplot as plt\n
out2 = clugen(2, 4, 400, [1, 0], 0.4, [50, 10], 20, 1, 2)\nplt.scatter(out2.points[:, 0], out2.points[:, 1], c=out2.clusters)\nplt.show()\n
out3 = clugen(3, 5, 10000, [0.5, 0.5, 0.5], 0.2, [10, 10, 10], 10, 1, 2)\nfig = plt.figure()\nax = fig.add_subplot(projection=\"3d\")\nax.scatter(out3.points[:, 0], out3.points[:, 1], out3.points[:, 2], c=out3.clusters)\nplt.show()\n
"},{"location":"#further-reading","title":"Further reading","text":"

The clugen algorithm and its several implementations are detailed in the following reference (please cite it if you use this software):

  • Fachada, N. & de Andrade, D. (2023). Generating multidimensional clusters with support lines. Knowledge-Based Systems, 277, 110836. https://doi.org/10.1016/j.knosys.2023.110836 (arXiv preprint)
"},{"location":"#also-in-this-documentation","title":"Also in this documentation","text":"
  • Theory: the clugen algorithm in detail
  • Detailed usage examples
  • Reference
  • Developing this package
"},{"location":"dev/","title":"Development","text":""},{"location":"dev/#installing-for-development-andor-improving-the-package","title":"Installing for development and/or improving the package","text":"
$ git clone https://github.com/clugen/pyclugen.git\n$ cd pyclugen\n$ python -m venv env\n$ source env/bin/activate\n$ pip install -e .[dev]\n$ pre-commit install\n

On Windows replace source env/bin/activate with . env\\Scripts\\activate.

"},{"location":"dev/#run-tests","title":"Run tests","text":"

Tests can be executed with the following command:

$ pytest\n

The previous command runs the tests at normal level by default. This test level can also be specified explicitly:

$ pytest --test-level=normal\n

There are four test levels, from fastest to slowest (i.e., from less thorough to more exhaustive): fast, ci, normal and full. The fast level tests all functions using typical parameters, just to check if everything is working. The ci level performs the minimal amount of testing that yields complete test coverage. Beyond complete coverage, the normal and full levels also test increasing combinations of parameters and PRNG seeds, which may be important to root out rare corner cases. Note that the full level can be extremely slow.

To generate a test coverage report, run pytest as follows:

$ pytest --cov=pyclugen --cov-report=html --test-level=ci\n
"},{"location":"dev/#build-docs","title":"Build docs","text":"

Considering we're in the pyclugen folder, run the following commands:

$ cd docs\n$ mkdocs build\n

The generated documentation will be placed in docs/site. Alternatively, the documentation can be generated and served locally with:

$ mkdocs serve\n
"},{"location":"dev/#code-style","title":"Code style","text":"

Code style is enforced with flake8 (and a number of plugins), black, and isort. Some highlights include, but are not limited to:

  • Encoding: UTF-8
  • Indentation: 4 spaces (no tabs)
  • Line size limit: 88 chars
  • Newlines: Unix style, i.e. LF or \\n
"},{"location":"reference/","title":"Reference","text":"

Various functions for multidimensional cluster generation in Python.

Note that:

  1. clugen() is the main function of the pyclugen package, and possibly the only function most users will need.
  2. Functions which accept rng as the last parameter are stochastic. Thus, in order to obtain the same result on separate invocations of these functions, pass them an an instance of same pseudo-random number Generator initialized with the same seed.
"},{"location":"reference/#pyclugen.Clusters","title":"Clusters","text":"

Bases: NamedTuple

Read-only container for results returned by clugen().

The symbols presented in the instances variable below have the following meanings:

  • \\(n\\) : Number of dimensions.
  • \\(p\\) : Number of points.
  • \\(c\\) : Number of clusters.
Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/main.py
class Clusters(NamedTuple):\nr\"\"\"Read-only container for results returned by [`clugen()`][pyclugen.main.clugen].\n    The symbols presented in the instances variable below have the following\n    meanings:\n    - $n$ : Number of dimensions.\n    - $p$ : Number of points.\n    - $c$ : Number of clusters.\n    \"\"\"\npoints: NDArray\nr\"\"\"$p \\times n$ matrix containing the generated points for all clusters.\"\"\"\nclusters: NDArray\nr\"\"\"Vector of size $p$ indicating the cluster each point in `points`\n    belongs to.\"\"\"\nprojections: NDArray\nr\"\"\"$p \\times n$ matrix with the point projections on the cluster-supporting\n    lines.\"\"\"\nsizes: NDArray\nr\"\"\"Vector of size $c$ with the number of points in each cluster.\"\"\"\ncenters: NDArray\nr\"\"\"$c \\times n$ matrix with the coordinates of the cluster centers.\"\"\"\ndirections: NDArray\nr\"\"\"$c \\times n$ matrix with the direction of each cluster-supporting line.\"\"\"\nangles: NDArray\nr\"\"\"Vector of size $c$ with the angles between the cluster-supporting lines and\n    the main direction.\"\"\"\nlengths: NDArray\nr\"\"\"Vector of size $c$ with the lengths of the cluster-supporting lines.\"\"\"\n
"},{"location":"reference/#pyclugen.Clusters.angles","title":"angles instance-attribute","text":"
angles: NDArray\n

Vector of size \\(c\\) with the angles between the cluster-supporting lines and the main direction.

"},{"location":"reference/#pyclugen.Clusters.centers","title":"centers instance-attribute","text":"
centers: NDArray\n

\\(c \\times n\\) matrix with the coordinates of the cluster centers.

"},{"location":"reference/#pyclugen.Clusters.clusters","title":"clusters instance-attribute","text":"
clusters: NDArray\n

Vector of size \\(p\\) indicating the cluster each point in points belongs to.

"},{"location":"reference/#pyclugen.Clusters.directions","title":"directions instance-attribute","text":"
directions: NDArray\n

\\(c \\times n\\) matrix with the direction of each cluster-supporting line.

"},{"location":"reference/#pyclugen.Clusters.lengths","title":"lengths instance-attribute","text":"
lengths: NDArray\n

Vector of size \\(c\\) with the lengths of the cluster-supporting lines.

"},{"location":"reference/#pyclugen.Clusters.points","title":"points instance-attribute","text":"
points: NDArray\n

\\(p \\times n\\) matrix containing the generated points for all clusters.

"},{"location":"reference/#pyclugen.Clusters.projections","title":"projections instance-attribute","text":"
projections: NDArray\n

\\(p \\times n\\) matrix with the point projections on the cluster-supporting lines.

"},{"location":"reference/#pyclugen.Clusters.sizes","title":"sizes instance-attribute","text":"
sizes: NDArray\n

Vector of size \\(c\\) with the number of points in each cluster.

"},{"location":"reference/#pyclugen.angle_btw","title":"angle_btw","text":"
angle_btw(v1: NDArray, v2: NDArray) -> float\n

Angle between two \\(n\\)-dimensional vectors.

Typically, the angle between two vectors v1 and v2 can be obtained with:

arccos(dot(u, v) / (norm(u) * norm(v)))\n

However, this approach is numerically unstable. The version provided here is numerically stable and based on the AngleBetweenVectors Julia package by Jeffrey Sarnoff (MIT license), implementing an algorithm provided by Prof. W. Kahan in these notes (see page 15).

Examples:

>>> from numpy import array, degrees\n>>> from pyclugen import angle_btw\n>>> v1 = array([1.0, 1.0, 1.0, 1.0])\n>>> v2 = array([1.0, 0.0, 0.0, 0.0])\n>>> degrees(angle_btw(v1, v2))\n60.00000000000001\n

Parameters:

Name Type Description Default v1 NDArray

First vector.

required v2 NDArray

Second vector.

required

Returns:

Type Description float

Angle between v1 and v2 in radians.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/helper.py
def angle_btw(v1: NDArray, v2: NDArray) -> float:\nr\"\"\"Angle between two $n$-dimensional vectors.\n    Typically, the angle between two vectors `v1` and `v2` can be obtained with:\n    ```python\n    arccos(dot(u, v) / (norm(u) * norm(v)))\n    ```\n    However, this approach is numerically unstable. The version provided here is\n    numerically stable and based on the\n    [AngleBetweenVectors](https://github.com/JeffreySarnoff/AngleBetweenVectors.jl)\n    Julia package by Jeffrey Sarnoff (MIT license), implementing an algorithm\n    provided by Prof. W. Kahan in\n    [these notes](https://people.eecs.berkeley.edu/~wkahan/MathH110/Cross.pdf)\n    (see page 15).\n    Examples:\n        >>> from numpy import array, degrees\n        >>> from pyclugen import angle_btw\n        >>> v1 = array([1.0, 1.0, 1.0, 1.0])\n        >>> v2 = array([1.0, 0.0, 0.0, 0.0])\n        >>> degrees(angle_btw(v1, v2))\n        60.00000000000001\n    Args:\n      v1: First vector.\n      v2: Second vector.\n    Returns:\n      Angle between `v1` and `v2` in radians.\n    \"\"\"\nu1 = v1 / norm(v1)\nu2 = v2 / norm(v2)\ny = u1 - u2\nx = u1 + u2\nreturn 2 * arctan(norm(y) / norm(x))\n
"},{"location":"reference/#pyclugen.angle_deltas","title":"angle_deltas","text":"
angle_deltas(\nnum_clusters: int, angle_disp: float, rng: Generator = _default_rng\n) -> NDArray\n

Get angles between average cluster direction and cluster-supporting lines.

Determine the angles between the average cluster direction and the cluster-supporting lines. These angles are obtained from a wrapped normal distribution ( \\(\\mu=0\\), \\(\\sigma=\\)angle_disp) with support in the interval \\(\\left[-\\pi/2,\\pi/2\\right]\\). Note this is different from the standard wrapped normal distribution, the support of which is given by the interval \\(\\left[-\\pi,\\pi\\right]\\).

Examples:

>>> from pyclugen import angle_deltas\n>>> from numpy import degrees, pi\n>>> from numpy.random import Generator, PCG64\n>>> prng = Generator(PCG64(123))\n>>> a_rad = angle_deltas(4, pi/8, rng=prng) # Angle dispersion of 22.5 degrees\n>>> a_rad\narray([-0.38842705, -0.14442948,  0.50576707,  0.07617358])\n>>> degrees(a_rad) # Show angle deltas in degrees\narray([-22.25523038,  -8.27519966,  28.97831838,   4.36442443])\n

Parameters:

Name Type Description Default num_clusters int

Number of clusters.

required angle_disp float

Angle dispersion, in radians.

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Angles between the average cluster direction and the cluster-supporting lines, given in radians in the interval \\(\\left[-\\pi/2,\\pi/2\\right]\\).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def angle_deltas(\nnum_clusters: int, angle_disp: float, rng: Generator = _default_rng\n) -> NDArray:\nr\"\"\"Get angles between average cluster direction and cluster-supporting lines.\n    Determine the angles between the average cluster direction and the\n    cluster-supporting lines. These angles are obtained from a wrapped normal\n    distribution ( $\\mu=0$, $\\sigma=$`angle_disp`) with support in the interval\n    $\\left[-\\pi/2,\\pi/2\\right]$. Note this is different from the standard\n    wrapped normal distribution, the support of which is given by the interval\n    $\\left[-\\pi,\\pi\\right]$.\n    Examples:\n        >>> from pyclugen import angle_deltas\n        >>> from numpy import degrees, pi\n        >>> from numpy.random import Generator, PCG64\n        >>> prng = Generator(PCG64(123))\n        >>> a_rad = angle_deltas(4, pi/8, rng=prng) # Angle dispersion of 22.5 degrees\n        >>> a_rad\n        array([-0.38842705, -0.14442948,  0.50576707,  0.07617358])\n        >>> degrees(a_rad) # Show angle deltas in degrees\n        array([-22.25523038,  -8.27519966,  28.97831838,   4.36442443])\n    Args:\n      num_clusters: Number of clusters.\n      angle_disp: Angle dispersion, in radians.\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Angles between the average cluster direction and the cluster-supporting\n        lines, given in radians in the interval $\\left[-\\pi/2,\\pi/2\\right]$.\n    \"\"\"\n# Get random angle differences using the normal distribution\nangles = angle_disp * rng.normal(size=num_clusters)\n# Reduce angle differences to the interval [-\u03c0, \u03c0]\nangles = arctan2(sin(angles), cos(angles))\n# Make sure angle differences are within interval [-\u03c0/2, \u03c0/2]\nreturn where(abs(angles) > pi / 2, angles - sign(angles) * pi / 2, angles)\n
"},{"location":"reference/#pyclugen.clucenters","title":"clucenters","text":"
clucenters(\nnum_clusters: int,\nclu_sep: NDArray,\nclu_offset: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray\n

Determine cluster centers using the uniform distribution.

The number of clusters (num_clusters) and the average cluster separation (clu_sep) are taken into account.

More specifically, let \\(c=\\)num_clusters, \\(\\mathbf{s}=\\)clu_sep.reshape(-1,1), \\(\\mathbf{o}=\\)clu_offset.reshape(-1,1), \\(n=\\)clu_sep.size (i.e., number of dimensions). Cluster centers are obtained according to the following equation:

\\[ \\mathbf{C}=c\\mathbf{U} \\cdot \\operatorname{diag}(\\mathbf{s}) + \\mathbf{1}\\,\\mathbf{o}^T \\]

where \\(\\mathbf{C}\\) is the \\(c \\times n\\) matrix of cluster centers, \\(\\mathbf{U}\\) is an \\(c \\times n\\) matrix of random values drawn from the uniform distribution between -0.5 and 0.5, and \\(\\mathbf{1}\\) is an \\(c \\times 1\\) vector with all entries equal to 1.

Examples:

>>> from pyclugen import clucenters\n>>> from numpy import array\n>>> from numpy.random import Generator, PCG64\n>>> prng = Generator(PCG64(123))\n>>> clucenters(3, array([30,10]), array([-50,50]), rng=prng)\narray([[-33.58833231,  36.61463056],\n       [-75.16761145,  40.53115432],\n       [-79.1684689 ,  59.3628352 ]])\n

Parameters:

Name Type Description Default num_clusters int

Number of clusters.

required clu_sep NDArray

Average cluster separation ( \\(n \\times 1\\) vector).

required clu_offset NDArray

Cluster offsets ( \\(n \\times 1\\) vector).

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

A \\(c \\times n\\) matrix containing the cluster centers.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def clucenters(\nnum_clusters: int,\nclu_sep: NDArray,\nclu_offset: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Determine cluster centers using the uniform distribution.\n    The number of clusters (`num_clusters`) and the average cluster separation\n    (`clu_sep`) are taken into account.\n    More specifically, let $c=$`num_clusters`, $\\mathbf{s}=$`clu_sep.reshape(-1,1)`,\n    $\\mathbf{o}=$`clu_offset.reshape(-1,1)`, $n=$`clu_sep.size` (i.e., number of\n    dimensions). Cluster centers are obtained according to the following equation:\n    $$\n    \\mathbf{C}=c\\mathbf{U} \\cdot \\operatorname{diag}(\\mathbf{s}) +\n        \\mathbf{1}\\,\\mathbf{o}^T\n    $$\n    where $\\mathbf{C}$ is the $c \\times n$ matrix of cluster centers,\n    $\\mathbf{U}$ is an $c \\times n$ matrix of random values drawn from the\n    uniform distribution between -0.5 and 0.5, and $\\mathbf{1}$ is an $c \\times\n    1$ vector with all entries equal to 1.\n    Examples:\n        >>> from pyclugen import clucenters\n        >>> from numpy import array\n        >>> from numpy.random import Generator, PCG64\n        >>> prng = Generator(PCG64(123))\n        >>> clucenters(3, array([30,10]), array([-50,50]), rng=prng)\n        array([[-33.58833231,  36.61463056],\n               [-75.16761145,  40.53115432],\n               [-79.1684689 ,  59.3628352 ]])\n    Args:\n      num_clusters: Number of clusters.\n      clu_sep: Average cluster separation ( $n \\times 1$ vector).\n      clu_offset: Cluster offsets ( $n \\times 1$ vector).\n      rng: Optional pseudo-random number generator.\n    Returns:\n        A $c \\times n$ matrix containing the cluster centers.\n    \"\"\"\n# Obtain a num_clusters x num_dims matrix of uniformly distributed values\n# between -0.5 and 0.5 representing the relative cluster centers\nctr_rel = rng.random((num_clusters, clu_sep.size)) - 0.5\nreturn num_clusters * (ctr_rel @ diag(clu_sep)) + clu_offset\n
"},{"location":"reference/#pyclugen.clugen","title":"clugen","text":"
clugen(\nnum_dims: int,\nnum_clusters: int,\nnum_points: int,\ndirection: ArrayLike,\nangle_disp: float,\ncluster_sep: ArrayLike,\nllength: float,\nllength_disp: float,\nlateral_disp: float,\nallow_empty: bool = False,\ncluster_offset: Optional[ArrayLike] = None,\nproj_dist_fn: str | Callable[[float, int, Generator], NDArray] = \"norm\",\npoint_dist_fn: str\n| Callable[\n[NDArray, float, float, NDArray, NDArray, Generator], NDArray\n] = \"n-1\",\nclusizes_fn: Callable[[int, int, bool, Generator], NDArray]\n| ArrayLike = clusizes,\nclucenters_fn: Callable[[int, NDArray, NDArray, Generator], NDArray]\n| ArrayLike = clucenters,\nllengths_fn: Callable[[int, float, float, Generator], NDArray]\n| ArrayLike = llengths,\nangle_deltas_fn: Callable[[int, float, Generator], NDArray]\n| ArrayLike = angle_deltas,\nrng: Generator = _default_rng,\n) -> Clusters\n

Generate multidimensional clusters.

Tip

This is the main function of the pyclugen package, and possibly the only function most users will need.

"},{"location":"reference/#pyclugen.clugen--examples","title":"Examples:","text":"
>>> import pyclugen as cg\n>>> import matplotlib.pyplot as plt\n>>> from numpy import pi\n>>> from numpy.random import Generator, PCG64\n>>> rng = Generator(PCG64(321))\n>>> out = cg.clugen(2, 5, 10000, [1, 0.5], pi/16, [10, 40], 10, 1, 2, rng=rng)\n>>> out.centers # What are the cluster centers?\narray([[ 20.02876212,  36.59611434],\n       [-15.60290734, -26.52169579],\n       [ 23.09775166,  91.66309916],\n       [ -5.76816015,  54.9775074 ],\n       [ -4.64224681,  78.40990876]])\n>>> plt.scatter(out.points[:,0],\n...             out.points[:,1],\n...             c=out.clusters) # doctest: +SKIP\n>>> plt.show() # doctest: +SKIP\n

Note

In the descriptions below, the terms \"average\" and \"dispersion\" refer to measures of central tendency and statistical dispersion, respectively. Their exact meaning depends on several optional arguments.

Parameters:

Name Type Description Default num_dims int

Number of dimensions.

required num_clusters int

Number of clusters to generate.

required num_points int

Total number of points to generate.

required direction ArrayLike

Average direction of the cluster-supporting lines. Can be a vector of length num_dims (same direction for all clusters) or a matrix of size num_clusters x num_dims (one direction per cluster).

required angle_disp float

Angle dispersion of cluster-supporting lines (radians).

required cluster_sep ArrayLike

Average cluster separation in each dimension (vector of size num_dims).

required llength float

Average length of cluster-supporting lines.

required llength_disp float

Length dispersion of cluster-supporting lines.

required lateral_disp float

Cluster lateral dispersion, i.e., dispersion of points from their projection on the cluster-supporting line.

required allow_empty bool

Allow empty clusters? False by default.

False cluster_offset Optional[ArrayLike]

Offset to add to all cluster centers (vector of size num_dims). By default the offset will be equal to numpy.zeros(num_dims).

None proj_dist_fn str | Callable[[float, int, Generator], NDArray]

Distribution of point projections along cluster-supporting lines, with three possible values:

  • \"norm\" (default): Distribute point projections along lines using a normal distribution (\u03bc=line center, \u03c3=llength/6).
  • \"unif\": Distribute points uniformly along the line.
  • User-defined function, which accepts two parameters, line length (float), number of points (int) and an instance of Generator, and returns an array containing the distance of each point projection to the center of the line. For example, the \"norm\" option roughly corresponds to lambda l, n, rg: l * rg.random((n, 1)) / 6.
'norm' point_dist_fn str | Callable[[NDArray, float, float, NDArray, NDArray, Generator], NDArray]

Controls how the final points are created from their projections on the cluster-supporting lines, with three possible values:

  • \"n-1\" (default): Final points are placed on a hyperplane orthogonal to the cluster-supporting line, centered at each point's projection, using the normal distribution (\u03bc=0, \u03c3=lateral_disp). This is done by the clupoints_n_1() function.
  • \"n\": Final points are placed around their projection on the cluster-supporting line using the normal distribution (\u03bc=0, \u03c3=lateral_disp). This is done by the clupoints_n() function.
  • User-defined function: The user can specify a custom point placement strategy by passing a function with the same signature as clupoints_n_1() and clupoints_n().
'n-1' clusizes_fn Callable[[int, int, bool, Generator], NDArray] | ArrayLike

Distribution of cluster sizes. By default, cluster sizes are determined by the clusizes() function, which uses the normal distribution (\u03bc=num_points/num_clusters, \u03c3=\u03bc/3), and assures that the final cluster sizes add up to num_points. This parameter allows the user to specify a custom function for this purpose, which must follow clusizes() signature. Note that custom functions are not required to strictly obey the num_points parameter. Alternatively, the user can specify an array of cluster sizes directly.

clusizes clucenters_fn Callable[[int, NDArray, NDArray, Generator], NDArray] | ArrayLike

Distribution of cluster centers. By default, cluster centers are determined by the clucenters() function, which uses the uniform distribution, and takes into account the num_clusters and cluster_sep parameters for generating well-distributed cluster centers. This parameter allows the user to specify a custom function for this purpose, which must follow clucenters() signature. Alternatively, the user can specify a matrix of size num_clusters x num_dims with the exact cluster centers.

clucenters llengths_fn Callable[[int, float, float, Generator], NDArray] | ArrayLike

Distribution of line lengths. By default, the lengths of cluster-supporting lines are determined by the llengths() function, which uses the folded normal distribution (\u03bc=llength, \u03c3=llength_disp). This parameter allows the user to specify a custom function for this purpose, which must follow llengths() signature. Alternatively, the user can specify an array of line lengths directly.

llengths angle_deltas_fn Callable[[int, float, Generator], NDArray] | ArrayLike

Distribution of line angle differences with respect to direction. By default, the angles between direction and the direction of cluster-supporting lines are determined by the angle_deltas() function, which uses the wrapped normal distribution (\u03bc=0, \u03c3=angle_disp) with support in the interval [-\u03c0/2, \u03c0/2]. This parameter allows the user to specify a custom function for this purpose, which must follow angle_deltas() signature. Alternatively, the user can specify an array of angle deltas directly.

angle_deltas rng Generator

An optional instance of Generator for reproducible executions.

_default_rng

Returns:

Type Description Clusters

The generated clusters and associated information in the form of a Clusters object.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/main.py
def clugen(\nnum_dims: int,\nnum_clusters: int,\nnum_points: int,\ndirection: ArrayLike,\nangle_disp: float,\ncluster_sep: ArrayLike,\nllength: float,\nllength_disp: float,\nlateral_disp: float,\nallow_empty: bool = False,\ncluster_offset: Optional[ArrayLike] = None,\nproj_dist_fn: str | Callable[[float, int, Generator], NDArray] = \"norm\",\npoint_dist_fn: str\n| Callable[[NDArray, float, float, NDArray, NDArray, Generator], NDArray] = \"n-1\",\nclusizes_fn: Callable[[int, int, bool, Generator], NDArray] | ArrayLike = clusizes,\nclucenters_fn: Callable[[int, NDArray, NDArray, Generator], NDArray]\n| ArrayLike = clucenters,\nllengths_fn: Callable[[int, float, float, Generator], NDArray]\n| ArrayLike = llengths,\nangle_deltas_fn: Callable[[int, float, Generator], NDArray]\n| ArrayLike = angle_deltas,\nrng: Generator = _default_rng,\n) -> Clusters:\n\"\"\"Generate multidimensional clusters.\n    !!! tip\n        This is the main function of the **pyclugen** package, and possibly the\n        only function most users will need.\n    ## Examples:\n        >>> import pyclugen as cg\n        >>> import matplotlib.pyplot as plt\n        >>> from numpy import pi\n        >>> from numpy.random import Generator, PCG64\n        >>> rng = Generator(PCG64(321))\n        >>> out = cg.clugen(2, 5, 10000, [1, 0.5], pi/16, [10, 40], 10, 1, 2, rng=rng)\n        >>> out.centers # What are the cluster centers?\n        array([[ 20.02876212,  36.59611434],\n               [-15.60290734, -26.52169579],\n               [ 23.09775166,  91.66309916],\n               [ -5.76816015,  54.9775074 ],\n               [ -4.64224681,  78.40990876]])\n        >>> plt.scatter(out.points[:,0],\n        ...             out.points[:,1],\n        ...             c=out.clusters) # doctest: +SKIP\n        >>> plt.show() # doctest: +SKIP\n    ![clugen](https://user-images.githubusercontent.com/3018963/151056890-c83c9509-b40d-4ab2-a842-f2a4706344c6.png)\n    !!! Note\n        In the descriptions below, the terms \"average\" and \"dispersion\" refer to\n        measures of central tendency and statistical dispersion, respectively.\n        Their exact meaning depends on several optional arguments.\n    Args:\n      num_dims: Number of dimensions.\n      num_clusters: Number of clusters to generate.\n      num_points: Total number of points to generate.\n      direction: Average direction of the cluster-supporting lines. Can be a\n        vector of length `num_dims` (same direction for all clusters) or a\n        matrix of size `num_clusters` x `num_dims` (one direction per cluster).\n      angle_disp: Angle dispersion of cluster-supporting lines (radians).\n      cluster_sep: Average cluster separation in each dimension (vector of size\n        `num_dims`).\n      llength: Average length of cluster-supporting lines.\n      llength_disp: Length dispersion of cluster-supporting lines.\n      lateral_disp: Cluster lateral dispersion, i.e., dispersion of points from their\n        projection on the cluster-supporting line.\n      allow_empty: Allow empty clusters? `False` by default.\n      cluster_offset: Offset to add to all cluster centers (vector of size `num_dims`).\n        By default the offset will be equal to `numpy.zeros(num_dims)`.\n      proj_dist_fn: Distribution of point projections along cluster-supporting lines,\n        with three possible values:\n        - `\"norm\"` (default): Distribute point projections along lines using a normal\n          distribution (\u03bc=_line center_, \u03c3=`llength/6`).\n        - `\"unif\"`: Distribute points uniformly along the line.\n        - User-defined function, which accepts two parameters, line length (`float`),\n          number of points (`int`) and an instance of\n          [`Generator`](https://numpy.org/doc/stable/reference/random/generator.html?highlight=generator#numpy.random.Generator),\n          and returns an array containing the distance of each point projection to\n          the center of the line. For example, the `\"norm\"` option roughly corresponds\n          to `lambda l, n, rg: l * rg.random((n, 1)) / 6`.\n      point_dist_fn: Controls how the final points are created from their projections\n        on the cluster-supporting lines, with three possible values:\n        - `\"n-1\"` (default): Final points are placed on a hyperplane orthogonal to\n          the cluster-supporting line, centered at each point's projection, using the\n          normal distribution (\u03bc=0, \u03c3=`lateral_disp`). This is done by the\n          [`clupoints_n_1()`][pyclugen.module.clupoints_n_1] function.\n        - `\"n\"`: Final points are placed around their projection on the\n          cluster-supporting line using the normal distribution (\u03bc=0,\n          \u03c3=`lateral_disp`). This is done by the\n          [`clupoints_n()`][pyclugen.module.clupoints_n] function.\n        - User-defined function: The user can specify a custom point placement\n          strategy by passing a function with the same signature as\n          [`clupoints_n_1()`][pyclugen.module.clupoints_n_1] and\n          [`clupoints_n()`][pyclugen.module.clupoints_n].\n      clusizes_fn: Distribution of cluster sizes. By default, cluster sizes are\n        determined by the [`clusizes()`][pyclugen.module.clusizes] function, which\n        uses the normal distribution (\u03bc=`num_points`/`num_clusters`, \u03c3=\u03bc/3), and\n        assures that the final cluster sizes add up to `num_points`. This parameter\n        allows the user to specify a custom function for this purpose, which must\n        follow [`clusizes()`][pyclugen.module.clusizes] signature. Note that custom\n        functions are not required to strictly obey the `num_points` parameter.\n        Alternatively, the user can specify an array of cluster sizes directly.\n      clucenters_fn: Distribution of cluster centers. By default, cluster centers\n        are determined by the [`clucenters()`][pyclugen.module.clucenters] function,\n        which uses the uniform distribution, and takes into account the `num_clusters`\n        and `cluster_sep` parameters for generating well-distributed cluster centers.\n        This parameter allows the user to specify a custom function for this purpose,\n        which must follow [`clucenters()`][pyclugen.module.clucenters] signature.\n        Alternatively, the user can specify a matrix of size `num_clusters` x\n        `num_dims` with the exact cluster centers.\n      llengths_fn: Distribution of line lengths. By default, the lengths of\n        cluster-supporting lines are determined by the\n        [`llengths()`][pyclugen.module.llengths] function, which uses the folded\n        normal distribution (\u03bc=`llength`, \u03c3=`llength_disp`). This parameter allows\n        the user to specify a custom function for this purpose, which must follow\n        [`llengths()`][pyclugen.module.llengths] signature. Alternatively, the user\n        can specify an array of line lengths directly.\n      angle_deltas_fn: Distribution of line angle differences with respect to\n        `direction`. By default, the angles between `direction` and the direction of\n        cluster-supporting lines are determined by the\n        [`angle_deltas()`][pyclugen.module.angle_deltas] function, which uses the\n        wrapped normal distribution (\u03bc=0, \u03c3=`angle_disp`) with support in the interval\n        [-\u03c0/2, \u03c0/2]. This parameter allows the user to specify a custom function for\n        this purpose, which must follow [`angle_deltas()`][pyclugen.module.angle_deltas]\n        signature. Alternatively, the user can specify an array of angle deltas\n        directly.\n      rng: An optional instance of [`Generator`][numpy.random.Generator] for\n        reproducible executions.\n    Returns:\n      The generated clusters and associated information in the form of a\n        [`Clusters`][pyclugen.main.Clusters] object.\n    \"\"\"\n# ############### #\n# Validate inputs #\n# ############### #\n# Check that number of dimensions is > 0\nif num_dims < 1:\nraise ValueError(\"Number of dimensions, `num_dims`, must be > 0\")\n# Check that number of clusters is > 0\nif num_clusters < 1:\nraise ValueError(\"Number of clusters, `num_clust`, must be > 0\")\n# Convert given direction into a NumPy array\narrdir: NDArray = asarray(direction)\n# Get number of dimensions in `direction` array\ndir_ndims = arrdir.ndim\n# Is direction a vector or a matrix?\nif dir_ndims == 1:\n# It's a vector, let's convert it into a row matrix, since this will be\n# useful down the road\narrdir = arrdir.reshape((1, -1))\nelif dir_ndims == 2:\n# If a matrix was given (i.e. a main direction is given for each cluster),\n# check if the number of directions is the same as the number of clusters\ndir_size_1 = arrdir.shape[0]\nif dir_size_1 != num_clusters:\nraise ValueError(\n\"Number of rows in `direction` must be the same as the \"\n+ f\"number of clusters ({dir_size_1} != {num_clusters})\"\n)\nelse:\n# The `directions` array must be a vector or a matrix, so if we get here\n# it means we have invalid arguments\nraise ValueError(\n\"`direction` must be a vector (1D array) or a matrix (2D array), \"\n+ f\"but is {dir_ndims}D\"\n)\n# Check that direction has num_dims dimensions\ndir_size_2 = arrdir.shape[1]\nif dir_size_2 != num_dims:\nraise ValueError(\n\"Length of directions in `direction` must be equal to \"\n+ f\"`num_dims` ({dir_size_2} != {num_dims})\"\n)\n# Check that directions have magnitude > 0\ndir_magnitudes = apply_along_axis(norm, 1, arrdir)\nif any(isclose(dir_magnitudes, 0)):\nraise ValueError(\"Directions in `direction` must have magnitude > 0\")\n# If allow_empty is false, make sure there are enough points to distribute\n# by the clusters\nif (not allow_empty) and num_points < num_clusters:\nraise ValueError(\nf\"A total of {num_points} points is not enough for \"\n+ f\"{num_clusters} non-empty clusters\"\n)\n# Check that cluster_sep has num_dims dimensions\ncluster_sep = asarray(cluster_sep)\nif cluster_sep.size != num_dims:\nraise ValueError(\n\"Length of `cluster_sep` must be equal to `num_dims` \"\n+ f\"({cluster_sep.size} != {num_dims})\"\n)\n# If given, cluster_offset must have the correct number of dimensions,\n# if not given then it will be a num_dims x 1 vector of zeros\nif cluster_offset is None:\ncluster_offset = zeros(num_dims)\nelse:\ncluster_offset = asarray(cluster_offset)\nif cluster_offset.size != num_dims:\nraise ValueError(\n\"Length of `cluster_offset` must be equal to `num_dims` \"\n+ f\"({cluster_offset.size} != {num_dims})\"\n)\n# Check that proj_dist_fn specifies a valid way for projecting points along\n# cluster-supporting lines i.e., either \"norm\" (default), \"unif\" or a\n# user-defined function\npointproj_fn: Callable[[float, int, Generator], NDArray]\nif callable(proj_dist_fn):\n# Use user-defined distribution; assume function accepts length of line\n# and number of points, and returns a number of points x 1 vector\npointproj_fn = proj_dist_fn\nelif proj_dist_fn == \"unif\":\n# Point projections will be uniformly placed along cluster-supporting lines\ndef pointproj_fn(length, n, rg):\nreturn length * rg.random(n) - length / 2\nelif proj_dist_fn == \"norm\":\n# Use normal distribution for placing point projections along cluster-supporting\n# lines, mean equal to line center, standard deviation equal to 1/6 of line\n# length such that the line length contains \u224899.73% of the points\ndef pointproj_fn(length, n, rg):\nreturn (1.0 / 6.0) * length * rg.normal(size=n)\nelse:\nraise ValueError(\n\"`proj_dist_fn` has to be either 'norm', 'unif' or user-defined function\"\n)\n# Check that point_dist_fn specifies a valid way for generating points given\n# their projections along cluster-supporting lines, i.e., either \"n-1\"\n# (default), \"n\" or a user-defined function\npt_from_proj_fn: Callable[\n[NDArray, float, float, NDArray, NDArray, Generator], NDArray\n]\nif num_dims == 1:\n# If 1D was specified, point projections are the points themselves\ndef pt_from_proj_fn(projs, lat_disp, length, clu_dir, clu_ctr, rng=rng):\nreturn projs\nelif callable(point_dist_fn):\n# Use user-defined distribution; assume function accepts point projections\n# on the line, lateral disp., cluster direction and cluster center, and\n# returns a num_points x num_dims matrix containing the final points\n# for the current cluster\npt_from_proj_fn = point_dist_fn\nelif point_dist_fn == \"n-1\":\n# Points will be placed on a hyperplane orthogonal to the cluster-supporting\n# line using a normal distribution centered at their intersection\npt_from_proj_fn = clupoints_n_1\nelif point_dist_fn == \"n\":\n# Points will be placed using a multivariate normal distribution\n# centered at the point projection\npt_from_proj_fn = clupoints_n\nelse:\nraise ValueError(\n\"point_dist_fn has to be either 'n-1', 'n' or a user-defined function\"\n)\n# ############################ #\n# Determine cluster properties #\n# ############################ #\n# Normalize main direction(s)\narrdir = apply_along_axis(lambda a: a / norm(a), 1, arrdir)\n# If only one main direction was given, expand it for all clusters\nif dir_ndims == 1:\narrdir = repeat(arrdir, num_clusters, axis=0)\n# Determine cluster sizes\nif callable(clusizes_fn):\ncluster_sizes = clusizes_fn(num_clusters, num_points, allow_empty, rng)\nelif len(asarray(clusizes_fn)) == num_clusters:\ncluster_sizes = asarray(clusizes_fn)\nelse:\nraise ValueError(\n\"clusizes_fn has to be either a function or a `num_clusters`-sized array\"\n)\n# Custom clusizes_fn's are not required to obey num_points, so we update\n# it here just in case it's different from what the user specified\nnum_points = sum(cluster_sizes)\n# Determine cluster centers\nif callable(clucenters_fn):\ncluster_centers = clucenters_fn(num_clusters, cluster_sep, cluster_offset, rng)\nelif asarray(clucenters_fn).shape == (num_clusters, num_dims):\ncluster_centers = asarray(clucenters_fn)\nelse:\nraise ValueError(\n\"clucenters_fn has to be either a function or a matrix of size \"\n+ \"`num_clusters` x `num_dims`\"\n)\n# Determine length of lines supporting clusters\nif callable(llengths_fn):\ncluster_lengths = llengths_fn(num_clusters, llength, llength_disp, rng)\nelif len(asarray(llengths_fn)) == num_clusters:\ncluster_lengths = asarray(llengths_fn)\nelse:\nraise ValueError(\n\"llengths_fn has to be either a function or a `num_clusters`-sized array\"\n)\n# Obtain angles between main direction and cluster-supporting lines\nif callable(angle_deltas_fn):\ncluster_angles = angle_deltas_fn(num_clusters, angle_disp, rng)\nelif len(asarray(angle_deltas_fn)) == num_clusters:\ncluster_angles = asarray(angle_deltas_fn)\nelse:\nraise ValueError(\n\"angle_deltas_fn has to be either a function or a \"\n+ \"`num_clusters`-sized array\"\n)\n# Determine normalized cluster directions by applying the obtained angles\ncluster_directions = apply_along_axis(\nlambda v, a: rand_vector_at_angle(v, next(a), rng),\n1,\narrdir,\niter(cluster_angles),\n)\n# ################################# #\n# Determine points for each cluster #\n# ################################# #\n# Aux. vector with cumulative sum of number of points in each cluster\ncumsum_points = concatenate((asarray([0]), cumsum(cluster_sizes)))\n# Pre-allocate data structures for holding cluster info and points\npoint_clusters: NDArray = empty(\nnum_points, dtype=int32\n)  # Cluster indices of each point\npoint_projections = empty((num_points, num_dims))  # Point projections on\n#                                                  # cluster-supporting lines\npoints = empty((num_points, num_dims))  # Final points to be generated\n# Loop through clusters and create points for each one\nfor i in range(num_clusters):\n# Start and end indexes for points in current cluster\nidx_start = cumsum_points[i]\nidx_end = cumsum_points[i + 1]\n# Update cluster indices of each point\npoint_clusters[idx_start:idx_end] = i\n# Determine distance of point projections from the center of the line\nptproj_dist_fn_center = pointproj_fn(cluster_lengths[i], cluster_sizes[i], rng)\n# Determine coordinates of point projections on the line using the\n# parametric line equation (this works since cluster direction is normalized)\npoint_projections[idx_start:idx_end, :] = points_on_line(\ncluster_centers[i, :], cluster_directions[i, :], ptproj_dist_fn_center\n)\n# Determine points from their projections on the line\npoints[idx_start:idx_end, :] = pt_from_proj_fn(\npoint_projections[idx_start:idx_end, :],\nlateral_disp,\ncluster_lengths[i],\ncluster_directions[i, :],\ncluster_centers[i, :],\nrng,\n)\nreturn Clusters(\npoints,\npoint_clusters,\npoint_projections,\ncluster_sizes,\ncluster_centers,\ncluster_directions,\ncluster_angles,\ncluster_lengths,\n)\n
"},{"location":"reference/#pyclugen.clumerge","title":"clumerge","text":"
clumerge(\n*data: NamedTuple | Mapping[str, ArrayLike],\nfields: tuple[str, ...] = (\"points\", \"clusters\"),\nclusters_field: str | None = \"clusters\"\n) -> dict[str, NDArray]\n

Merges the fields (specified in fields) of two or more data sets.

Merges the fields (specified in fields) of two or more data sets (named tuples or dictionaries). The fields to be merged need to have the same number of columns. The corresponding merged field will contain the rows of the fields to be merged, and will have a common supertype.

The clusters_field parameter specifies a field containing integers that identify the cluster to which the respective points belongs to. If clusters_field is specified (by default it's specified as \"clusters\"), cluster assignments in individual datasets will be updated in the merged dataset so that clusters are considered separate. This parameter can be set to None, in which case no field will be considered as a special cluster assignments field.

This function can be used to merge data sets generated with the clugen() function, by default merging the points and clusters fields in those data sets. It also works with arbitrary data by specifying alternative fields in the fields parameter. It can be used, for example, to merge third-party data with clugen()-generated data.

Examples:

>>> from pyclugen import clugen, clumerge\n>>> data1 = clugen(2, 5, 1000, [1, 1], 0.01, [20, 20], 14, 1.2, 1.5);\n>>> data2 = clugen(2, 3, 450, [0.8, -0.3], 0, [25, 21], 6, 0.4, 3.5);\n>>> data3 = clugen(2, 2, 600, [0, -0.7], 0.2, [15, 10], 1, 0.1, 5.2);\n>>> data_merged = clumerge(data1, data2, data3)\n

Parameters:

Name Type Description Default *data NamedTuple | Mapping[str, ArrayLike]

One or more cluster data sets whose fields are to be merged.

() fields tuple[str, ...]

Fields to be merged, which must exist in the data set given in *data.

('points', 'clusters') clusters_field str | None

Field containing the integer cluster labels. If specified, cluster assignments in individual datasets will be updated in the merged dataset so that clusters are considered separate.

'clusters'

Returns:

Type Description dict[str, NDArray]

A dictionary, where keys correspond to field names, and values to the merged numerical arrays.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/main.py
def clumerge(\n*data: NamedTuple | Mapping[str, ArrayLike],\nfields: tuple[str, ...] = (\"points\", \"clusters\"),\nclusters_field: str | None = \"clusters\",\n) -> dict[str, NDArray]:\nr\"\"\"Merges the fields (specified in `fields`) of two or more `data` sets.\n    Merges the fields (specified in `fields`) of two or more `data` sets (named\n    tuples or dictionaries). The fields to be merged need to have the same\n    number of columns. The corresponding merged field will contain the rows of\n    the fields to be merged, and will have a common supertype.\n    The `clusters_field` parameter specifies a field containing integers that\n    identify the cluster to which the respective points belongs to. If\n    `clusters_field` is specified (by default it's specified as `\"clusters\"`),\n    cluster assignments in individual datasets will be updated in the merged\n    dataset so that clusters are considered separate. This parameter can be set\n    to `None`, in which case no field will be considered as a special cluster\n    assignments field.\n    This function can be used to merge data sets generated with the\n    [`clugen()`][pyclugen.main.clugen] function, by default merging the\n    `points` and `clusters` fields in those data sets. It also works with\n    arbitrary data by specifying alternative fields in the `fields` parameter.\n    It can be used, for example, to merge third-party data with\n    [`clugen()`][pyclugen.main.clugen]-generated data.\n    Examples:\n        >>> from pyclugen import clugen, clumerge\n        >>> data1 = clugen(2, 5, 1000, [1, 1], 0.01, [20, 20], 14, 1.2, 1.5);\n        >>> data2 = clugen(2, 3, 450, [0.8, -0.3], 0, [25, 21], 6, 0.4, 3.5);\n        >>> data3 = clugen(2, 2, 600, [0, -0.7], 0.2, [15, 10], 1, 0.1, 5.2);\n        >>> data_merged = clumerge(data1, data2, data3)\n    Args:\n      *data: One or more cluster data sets whose `fields` are to be merged.\n      fields: Fields to be merged, which must exist in the data set given in\n        `*data`.\n      clusters_field: Field containing the integer cluster labels. If specified,\n        cluster assignments in individual datasets will be updated in the merged\n        dataset so that clusters are considered separate.\n    Returns:\n      A dictionary, where keys correspond to field names, and values to the\n        merged numerical arrays.\n    \"\"\"\n# Number of elements in each array the merged dataset\nnumel: int = 0\n# Number of columns of values in each field\nfields_info: dict[str, _FieldInfo] = {}\n# Merged dataset to output, initially empty\noutput: dict[str, NDArray] = {}\n# Create a fields set\nfields_set: MutableSet[str] = set(fields)\n# If a clusters field is given, add it\nif clusters_field is not None:\nfields_set.add(str(clusters_field))\n# Data in dictionary format with NDArray views on data\nddata: MutableSequence[Mapping[str, NDArray]] = []\nfor dt in data:\n# If dt is a named tuple, convert it into a dictionary\nddt: Mapping[str, ArrayLike]\nif isinstance(dt, dict):\nddt = cast(dict, dt)\nelse:\nntdt = cast(NamedTuple, dt)\nddt = ntdt._asdict()\n# Convert dictionary values to NDArrays\nddtnp: Mapping[str, NDArray] = {k: asarray(v) for k, v in ddt.items()}\n# Add converted dictionary to our sequence of dictionaries\nddata.append(ddtnp)\n# Cycle through data items\nfor dt in ddata:\n# Number of elements in the current item\nnumel_i: int = -1\n# Cycle through fields for the current item\nfor field in fields_set:\nif field not in dt:\nraise ValueError(f\"Data item does not contain required field `{field}`\")\nelif field == clusters_field and not can_cast(\ndt[clusters_field].dtype, int64\n):\nraise ValueError(f\"`{clusters_field}` must contain integer types\")\n# Get the field value\nvalue: NDArray = dt[field]\n# Number of elements in field value\nnumel_tmp = len(value)\n# Check the number of elements in the field value\nif numel_i == -1:\n# First field: get number of elements in value (must be the same\n# for the remaining field values)\nnumel_i = numel_tmp\nelif numel_tmp != numel_i:\n# Fields values after the first must have the same number of\n# elements\nraise ValueError(\n\"Data item contains fields with different sizes \"\n+ f\"({numel_tmp} != {numel_i})\"\n)\n# Get/check info about the field value type\nif field not in fields_info:\n# If it's the first time this field appears, just get the info\nfields_info[field] = _FieldInfo(value.dtype, _getcols(value))\nelse:\n# If this field already appeared in previous data items, get the\n# info and check/determine its compatibility with respect to\n# previous data items\nif _getcols(value) != fields_info[field].ncol:\n# Number of columns must be the same\nraise ValueError(f\"Dimension mismatch in field `{field}`\")\n# Get the common supertype\nfields_info[field].dtype = promote_types(\nfields_info[field].dtype, value.dtype\n)\n# Update total number of elements\nnumel += numel_i\n# Initialize output dictionary fields with room for all items\nfor field in fields_info:\nif fields_info[field].ncol == 1:\noutput[field] = empty((numel,), dtype=fields_info[field].dtype)\nelse:\noutput[field] = empty(\n(numel, fields_info[field].ncol), dtype=fields_info[field].dtype\n)\n# Copy items from input data to output dictionary, field-wise\ncopied: int = 0\nlast_cluster: int = 0\n# Create merged output\nfor dt in ddata:\n# How many elements to copy for the current data item?\ntocopy: int = len(dt[fields[0]])\n# Cycle through each field and its information\nfor field in fields_info:\n# Copy elements\nif field == clusters_field:\n# If this is a clusters field, update the cluster IDs\nold_clusters = unique(dt[clusters_field])\nnew_clusters = list(\nrange(last_cluster + 1, last_cluster + len(old_clusters) + 1)\n)\nold2new = zip(old_clusters, new_clusters)\nmapping = dict(old2new)\nlast_cluster = new_clusters[-1]\noutput[field][copied : (copied + tocopy)] = [\nmapping[val] for val in dt[clusters_field]\n]\nelse:\n# Otherwise just copy the elements\nncol: int = fields_info[field].ncol\noutput[field].flat[copied * ncol : (copied + tocopy) * ncol] = dt[field]\n# Update how many were copied so far\ncopied += tocopy\n# Return result\nreturn output\n
"},{"location":"reference/#pyclugen.clupoints_n","title":"clupoints_n","text":"
clupoints_n(\nprojs: NDArray,\nlat_disp: float,\nline_len: float,\nclu_dir: NDArray,\nclu_ctr: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray\n

Generate points from their \\(n\\)-D projections on a cluster-supporting line.

Each point is placed around its projection using the normal distribution ( \\(\\mu=0\\), \\(\u03c3=\\)lat_disp).

This function's main intended use is by the clugen() function, generating the final points when the point_dist_fn parameter is set to \"n\".

Examples:

>>> from pyclugen import clupoints_n, points_on_line\n>>> from numpy import array, linspace\n>>> from numpy.random import Generator, PCG64\n>>> prng = Generator(PCG64(123))\n>>> projs = points_on_line(array([5,5]),     # Get 5 point projections\n...                        array([1,0]),     # on a 2D line\n...                        linspace(-4,4,5))\n>>> projs\narray([[1., 5.],\n       [3., 5.],\n       [5., 5.],\n       [7., 5.],\n       [9., 5.]])\n>>> clupoints_n(projs, 0.5, 1.0, array([1,0]), array([0,0]), rng=prng)\narray([[0.50543932, 4.81610667],\n       [3.64396263, 5.09698721],\n       [5.46011545, 5.2885519 ],\n       [6.68176818, 5.27097611],\n       [8.84170227, 4.83880544]])\n

Parameters:

Name Type Description Default projs NDArray

Point projections on the cluster-supporting line ( \\(p \\times n\\) matrix).

required lat_disp float

Standard deviation for the normal distribution, i.e., cluster lateral dispersion.

required line_len float

Length of cluster-supporting line (ignored).

required clu_dir NDArray

Direction of the cluster-supporting line.

required clu_ctr NDArray

Center position of the cluster-supporting line (ignored).

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Generated points ( \\(p \\times n\\) matrix).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def clupoints_n(\nprojs: NDArray,\nlat_disp: float,\nline_len: float,\nclu_dir: NDArray,\nclu_ctr: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Generate points from their $n$-D projections on a cluster-supporting line.\n    Each point is placed around its projection using the normal distribution\n    ( $\\mu=0$, $\u03c3=$`lat_disp`).\n    This function's main intended use is by the [`clugen()`][pyclugen.main.clugen]\n    function, generating the final points when the `point_dist_fn` parameter is\n    set to `\"n\"`.\n    Examples:\n        >>> from pyclugen import clupoints_n, points_on_line\n        >>> from numpy import array, linspace\n        >>> from numpy.random import Generator, PCG64\n        >>> prng = Generator(PCG64(123))\n        >>> projs = points_on_line(array([5,5]),     # Get 5 point projections\n        ...                        array([1,0]),     # on a 2D line\n        ...                        linspace(-4,4,5))\n        >>> projs\n        array([[1., 5.],\n               [3., 5.],\n               [5., 5.],\n               [7., 5.],\n               [9., 5.]])\n        >>> clupoints_n(projs, 0.5, 1.0, array([1,0]), array([0,0]), rng=prng)\n        array([[0.50543932, 4.81610667],\n               [3.64396263, 5.09698721],\n               [5.46011545, 5.2885519 ],\n               [6.68176818, 5.27097611],\n               [8.84170227, 4.83880544]])\n    Args:\n      projs: Point projections on the cluster-supporting line ( $p \\times n$ matrix).\n      lat_disp: Standard deviation for the normal distribution, i.e., cluster\n        lateral dispersion.\n      line_len: Length of cluster-supporting line (ignored).\n      clu_dir: Direction of the cluster-supporting line.\n      clu_ctr: Center position of the cluster-supporting line (ignored).\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Generated points ( $p \\times n$ matrix).\n    \"\"\"\n# Number of dimensions\nnum_dims = clu_dir.size\n# Number of points in this cluster\nclu_num_points = projs.shape[0]\n# Get random displacement vectors for each point projection\ndispl = lat_disp * rng.normal(size=(clu_num_points, num_dims))\n# Add displacement vectors to each point projection\npoints = projs + displ\nreturn points\n
"},{"location":"reference/#pyclugen.clupoints_n_1","title":"clupoints_n_1","text":"
clupoints_n_1(\nprojs: NDArray,\nlat_disp: float,\nline_len: float,\nclu_dir: NDArray,\nclu_ctr: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray\n

Generate points from their \\(n\\)-D projections on a cluster-supporting line.

Each point is placed on a hyperplane orthogonal to that line and centered at the point's projection, using the normal distribution ( \\(\\mu=0\\), \\(\u03c3=\\)lat_disp).

This function's main intended use is by the clugen() function, generating the final points when the point_dist_fn parameter is set to \"n-1\".

Examples:

>>> from pyclugen import clupoints_n_1, points_on_line\n>>> from numpy import array, linspace\n>>> from numpy.random import Generator, PCG64\n>>> prng = Generator(PCG64(123))\n>>> projs = points_on_line(array([5,5]),     # Get 5 point projections\n...                        array([1,0]),     # on a 2D line\n...                        linspace(-4,4,5))\n>>> projs\narray([[1., 5.],\n       [3., 5.],\n       [5., 5.],\n       [7., 5.],\n       [9., 5.]])\n>>> clupoints_n_1(projs, 0.5, 1.0, array([1,0]), array([0,0]), rng=prng)\narray([[1.        , 5.49456068],\n       [3.        , 5.18389333],\n       [5.        , 5.64396263],\n       [7.        , 5.09698721],\n       [9.        , 5.46011545]])\n

Parameters:

Name Type Description Default projs NDArray

Point projections on the cluster-supporting line ( \\(p \\times n\\) matrix).

required lat_disp float

Standard deviation for the normal distribution, i.e., cluster lateral dispersion.

required line_len float

Length of cluster-supporting line (ignored).

required clu_dir NDArray

Direction of the cluster-supporting line.

required clu_ctr NDArray

Center position of the cluster-supporting line (ignored).

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Generated points ( \\(p \\times n\\) matrix).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def clupoints_n_1(\nprojs: NDArray,\nlat_disp: float,\nline_len: float,\nclu_dir: NDArray,\nclu_ctr: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Generate points from their $n$-D projections on a cluster-supporting line.\n    Each point is placed on a hyperplane orthogonal to that line and centered at\n    the point's projection, using the normal distribution ( $\\mu=0$,\n    $\u03c3=$`lat_disp`).\n    This function's main intended use is by the [`clugen()`][pyclugen.main.clugen]\n    function, generating the final points when the `point_dist_fn` parameter is\n    set to `\"n-1\"`.\n    Examples:\n        >>> from pyclugen import clupoints_n_1, points_on_line\n        >>> from numpy import array, linspace\n        >>> from numpy.random import Generator, PCG64\n        >>> prng = Generator(PCG64(123))\n        >>> projs = points_on_line(array([5,5]),     # Get 5 point projections\n        ...                        array([1,0]),     # on a 2D line\n        ...                        linspace(-4,4,5))\n        >>> projs\n        array([[1., 5.],\n               [3., 5.],\n               [5., 5.],\n               [7., 5.],\n               [9., 5.]])\n        >>> clupoints_n_1(projs, 0.5, 1.0, array([1,0]), array([0,0]), rng=prng)\n        array([[1.        , 5.49456068],\n               [3.        , 5.18389333],\n               [5.        , 5.64396263],\n               [7.        , 5.09698721],\n               [9.        , 5.46011545]])\n    Args:\n      projs: Point projections on the cluster-supporting line ( $p \\times n$ matrix).\n      lat_disp: Standard deviation for the normal distribution, i.e., cluster\n        lateral dispersion.\n      line_len: Length of cluster-supporting line (ignored).\n      clu_dir: Direction of the cluster-supporting line.\n      clu_ctr: Center position of the cluster-supporting line (ignored).\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Generated points ( $p \\times n$ matrix).\n    \"\"\"\n# No blank line allowed here\n# Define function to get distances from points to their projections on the\n# line (i.e., using the normal distribution)\ndef dist_fn(clu_num_points, ldisp, rg):\nreturn ldisp * rg.normal(size=clu_num_points)\n# Use clupoints_n_1_template() to do the heavy lifting\nreturn clupoints_n_1_template(projs, lat_disp, clu_dir, dist_fn, rng=rng)\n
"},{"location":"reference/#pyclugen.clupoints_n_1_template","title":"clupoints_n_1_template","text":"
clupoints_n_1_template(\nprojs: NDArray,\nlat_disp: float,\nclu_dir: NDArray,\ndist_fn: Callable[[int, float, Generator], NDArray],\nrng: Generator = _default_rng,\n) -> NDArray\n

Create \\(p\\) points from their \\(n\\)-D projections on a cluster-supporting line.

Each point is placed on a hyperplane orthogonal to that line and centered at the point's projection. The function specified in dist_fn is used to perform the actual placement.

This function is used internally by clupoints_n_1() and may be useful for constructing user-defined final point placement strategies for the point_dist_fn parameter of the main clugen() function.

Examples:

>>> from numpy import array, zeros\n>>> from numpy.random import Generator, PCG64\n>>> from pyclugen import clupoints_n_1_template, points_on_line\n>>> ctr = zeros(2)\n>>> dir = array([1, 0])\n>>> pdist = array([-0.5, -0.2, 0.1, 0.3])\n>>> rng = Generator(PCG64(123))\n>>> proj = points_on_line(ctr, dir, pdist)\n>>> clupoints_n_1_template(proj, 0, dir, lambda p, l, r: r.random(p), rng=rng)\narray([[-0.5       ,  0.68235186],\n       [-0.2       , -0.05382102],\n       [ 0.1       ,  0.22035987],\n       [ 0.3       , -0.18437181]])\n

Parameters:

Name Type Description Default projs NDArray

Point projections on the cluster-supporting line ( \\(p \\times n\\) matrix).

required lat_disp float

Dispersion of points from their projection.

required clu_dir NDArray

Direction of the cluster-supporting line (unit vector).

required dist_fn Callable[[int, float, Generator], NDArray]

Function to place points on a second line, orthogonal to the first. The functions accepts as parameters the number of points in the current cluster, the lateral_disp parameter (the same passed to the clugen() function), and a random number generator, returning a vector containing the distance of each point to its projection on the cluster-supporting line.

required rng Generator

An optional pseudo-random number generator for reproducible executions.

_default_rng

Returns:

Type Description NDArray

Generated points ( \\(p \\times n\\) matrix).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/helper.py
def clupoints_n_1_template(\nprojs: NDArray,\nlat_disp: float,\nclu_dir: NDArray,\ndist_fn: Callable[[int, float, Generator], NDArray],\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Create $p$ points from their $n$-D projections on a cluster-supporting line.\n    Each point is placed on a hyperplane orthogonal to that line and centered at\n    the point's projection. The function specified in `dist_fn` is used to perform\n    the actual placement.\n    This function is used internally by\n    [`clupoints_n_1()`][pyclugen.module.clupoints_n_1] and may be useful for\n    constructing user-defined final point placement strategies for the `point_dist_fn`\n    parameter of the main [`clugen()`][pyclugen.main.clugen] function.\n    Examples:\n        >>> from numpy import array, zeros\n        >>> from numpy.random import Generator, PCG64\n        >>> from pyclugen import clupoints_n_1_template, points_on_line\n        >>> ctr = zeros(2)\n        >>> dir = array([1, 0])\n        >>> pdist = array([-0.5, -0.2, 0.1, 0.3])\n        >>> rng = Generator(PCG64(123))\n        >>> proj = points_on_line(ctr, dir, pdist)\n        >>> clupoints_n_1_template(proj, 0, dir, lambda p, l, r: r.random(p), rng=rng)\n        array([[-0.5       ,  0.68235186],\n               [-0.2       , -0.05382102],\n               [ 0.1       ,  0.22035987],\n               [ 0.3       , -0.18437181]])\n    Args:\n      projs: Point projections on the cluster-supporting line ( $p \\times n$ matrix).\n      lat_disp: Dispersion of points from their projection.\n      clu_dir: Direction of the cluster-supporting line (unit vector).\n      dist_fn: Function to place points on a second line, orthogonal to the first.\n        The functions accepts as parameters the number of points in the current\n        cluster, the `lateral_disp` parameter (the same passed to the\n        [`clugen()`][pyclugen.main.clugen] function), and a random number generator,\n        returning a vector containing the distance of each point to its projection\n        on the cluster-supporting line.\n      rng: An optional pseudo-random number generator for reproducible executions.\n    Returns:\n      Generated points ( $p \\times n$ matrix).\n    \"\"\"\n# Number of dimensions\nnum_dims = clu_dir.size\n# Number of points in this cluster\nclu_num_points = projs.shape[0]\n# Get distances from points to their projections on the line\npoints_dist = dist_fn(clu_num_points, lat_disp, rng)\n# Get normalized vectors, orthogonal to the current line, for each point\north_vecs = zeros((clu_num_points, num_dims))\nfor j in range(clu_num_points):\north_vecs[j, :] = rand_ortho_vector(clu_dir, rng=rng).ravel()\n# Set vector magnitudes\north_vecs = abs(points_dist).reshape(-1, 1) * orth_vecs\n# Add perpendicular vectors to point projections on the line,\n# yielding final cluster points\npoints = projs + orth_vecs\nreturn points\n
"},{"location":"reference/#pyclugen.clusizes","title":"clusizes","text":"
clusizes(\nnum_clusters: int,\nnum_points: int,\nallow_empty: bool,\nrng: Generator = _default_rng,\n) -> NDArray\n

Determine cluster sizes, i.e., the number of points in each cluster.

Cluster sizes are determined using the normal distribution ( \\(\\mu=\\)num_points \\(/\\)num_clusters, \\(\\sigma=\\mu/3\\)), and then assuring that the final cluster sizes add up to num_points via the fix_num_points() function.

Examples:

>>> from numpy.random import Generator, PCG64\n>>> from pyclugen import clusizes\n>>> prng = Generator(PCG64(123))\n>>> sizes = clusizes(4, 1000, True, rng=prng)\n>>> sizes\narray([166, 217, 354, 263])\n>>> sum(sizes)\n1000\n

Parameters:

Name Type Description Default num_clusters int

Number of clusters.

required num_points int

Total number of points.

required allow_empty bool

Allow empty clusters?

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Number of points in each cluster (vector of size num_clusters).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def clusizes(\nnum_clusters: int,\nnum_points: int,\nallow_empty: bool,\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Determine cluster sizes, i.e., the number of points in each cluster.\n    Cluster sizes are determined using the normal distribution (\n    $\\mu=$`num_points` $/$`num_clusters`, $\\sigma=\\mu/3$), and then\n    assuring that the final cluster sizes add up to `num_points` via the\n    [`fix_num_points()`][pyclugen.helper.fix_num_points] function.\n    Examples:\n        >>> from numpy.random import Generator, PCG64\n        >>> from pyclugen import clusizes\n        >>> prng = Generator(PCG64(123))\n        >>> sizes = clusizes(4, 1000, True, rng=prng)\n        >>> sizes\n        array([166, 217, 354, 263])\n        >>> sum(sizes)\n        1000\n    Args:\n      num_clusters: Number of clusters.\n      num_points: Total number of points.\n      allow_empty: Allow empty clusters?\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Number of points in each cluster (vector of size `num_clusters`).\n    \"\"\"\n# Determine number of points in each cluster using the normal distribution\n# Consider the mean an equal division of points between clusters\nmean = num_points / num_clusters\n# The standard deviation is such that the interval [0, 2 * mean] will contain\n# \u224899.7% of cluster sizes\nstd = mean / 3\n# Determine points with the normal distribution\nclu_num_points = std * rng.normal(size=num_clusters) + mean\n# Set negative values to zero\nclu_num_points = where(clu_num_points > 0, clu_num_points, 0)\n# Fix imbalances, so that num_points is respected\nif sum(clu_num_points) > 0:  # Be careful not to divide by zero\nclu_num_points *= num_points / sum(clu_num_points)\n# Round the real values to integers since a cluster sizes is represented by\n# an integer\nclu_num_points = rint(clu_num_points).astype(int)\n# Make sure total points is respected, which may not be the case at this time due\n# to rounding\nfix_num_points(clu_num_points, num_points)\n# If empty clusters are not allowed, make sure there aren't any\nif not allow_empty:\nfix_empty(clu_num_points)\nreturn clu_num_points\n
"},{"location":"reference/#pyclugen.fix_empty","title":"fix_empty","text":"
fix_empty(clu_num_points: NDArray, allow_empty: bool = False) -> NDArray\n

Certifies that, given enough points, no clusters are left empty.

This is done by removing a point from the largest cluster and adding it to an empty cluster while there are empty clusters. If the total number of points is smaller than the number of clusters (or if the allow_empty parameter is set to true), this function does nothing.

This function is used internally by clusizes() and might be useful for custom cluster sizing implementations given as the clusizes_fn parameter of the main clugen() function.

Note that the array is changed in-place.

Examples:

>>> from numpy import array\n>>> from pyclugen import fix_empty\n>>> clusters = array([3, 4, 5, 0, 0])\n>>> fix_empty(clusters)\narray([3, 3, 4, 1, 1])\n>>> clusters # Verify that the array was changed in-place\narray([3, 3, 4, 1, 1])\n

Parameters:

Name Type Description Default clu_num_points NDArray

Number of points in each cluster (vector of size \\(c\\)), where \\(c\\) is the number of clusters.

required allow_empty bool

Allow empty clusters?

False

Returns:

Type Description NDArray

Number of points in each cluster, after being fixed by this function (vector of size \\(c\\), which is the same reference than clu_num_points).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/helper.py
def fix_empty(clu_num_points: NDArray, allow_empty: bool = False) -> NDArray:\nr\"\"\"Certifies that, given enough points, no clusters are left empty.\n    This is done by removing a point from the largest cluster and adding it to an\n    empty cluster while there are empty clusters. If the total number of points is\n    smaller than the number of clusters (or if the `allow_empty` parameter is set\n    to `true`), this function does nothing.\n    This function is used internally by [`clusizes()`][pyclugen.module.clusizes]\n    and might be useful for custom cluster sizing implementations given as the\n    `clusizes_fn` parameter of the main [`clugen()`][pyclugen.main.clugen] function.\n    Note that the array is changed in-place.\n    Examples:\n        >>> from numpy import array\n        >>> from pyclugen import fix_empty\n        >>> clusters = array([3, 4, 5, 0, 0])\n        >>> fix_empty(clusters)\n        array([3, 3, 4, 1, 1])\n        >>> clusters # Verify that the array was changed in-place\n        array([3, 3, 4, 1, 1])\n    Args:\n      clu_num_points: Number of points in each cluster (vector of size $c$),\n        where $c$ is the number of clusters.\n      allow_empty: Allow empty clusters?\n    Returns:\n      Number of points in each cluster, after being fixed by this function (vector\n        of size $c$, which is the same reference than `clu_num_points`).\n    \"\"\"\n# If the allow_empty parameter is set to true, don't do anything and return\n# immediately; this is useful for quick `clusizes_fn` one-liners\nif not allow_empty:\n# Find empty clusters\nempty_clusts = [idx for idx, val in enumerate(clu_num_points) if val == 0]\n# If there are empty clusters and enough points for all clusters...\nif len(empty_clusts) > 0 and sum(clu_num_points) >= clu_num_points.size:\n# Go through the empty clusters...\nfor i0 in empty_clusts:\n# ...get a point from the largest cluster and assign it to the\n# current empty cluster\nimax = argmax(clu_num_points)\nclu_num_points[imax] -= 1\nclu_num_points[i0] += 1\nreturn clu_num_points\n
"},{"location":"reference/#pyclugen.fix_num_points","title":"fix_num_points","text":"
fix_num_points(clu_num_points: NDArray, num_points: int) -> NDArray\n

Certifies that the values in the clu_num_points array add up to num_points.

If this is not the case, the clu_num_points array is modified in-place, incrementing the value corresponding to the smallest cluster while sum(clu_num_points) < num_points, or decrementing the value corresponding to the largest cluster while sum(clu_num_points) > num_points.

This function is used internally by clusizes() and might be useful for custom cluster sizing implementations given as the clusizes_fn parameter of the main clugen() function.

Examples:

>>> from numpy import array\n>>> from pyclugen import fix_num_points\n>>> clusters = array([1, 6, 3])  # 10 total points\n>>> fix_num_points(clusters, 12) # But we want 12 total points\narray([3, 6, 3])\n>>> clusters # Verify that the array was changed in-place\narray([3, 6, 3])\n

Parameters:

Name Type Description Default clu_num_points NDArray

Number of points in each cluster (vector of size \\(c\\)), where \\(c\\) is the number of clusters.

required num_points int

The expected total number of points.

required

Returns:

Type Description NDArray

Number of points in each cluster, after being fixed by this function (vector of size \\(c\\), which is the same reference than clu_num_points).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/helper.py
def fix_num_points(clu_num_points: NDArray, num_points: int) -> NDArray:\nr\"\"\"Certifies that the values in the `clu_num_points` array add up to `num_points`.\n    If this is not the case, the `clu_num_points` array is modified in-place,\n    incrementing the value corresponding to the smallest cluster while\n    `sum(clu_num_points) < num_points`, or decrementing the value corresponding to\n    the largest cluster while `sum(clu_num_points) > num_points`.\n    This function is used internally by [`clusizes()`][pyclugen.module.clusizes]\n    and might be useful for custom cluster sizing implementations given as the\n    `clusizes_fn` parameter of the main [`clugen()`][pyclugen.main.clugen] function.\n    Examples:\n        >>> from numpy import array\n        >>> from pyclugen import fix_num_points\n        >>> clusters = array([1, 6, 3])  # 10 total points\n        >>> fix_num_points(clusters, 12) # But we want 12 total points\n        array([3, 6, 3])\n        >>> clusters # Verify that the array was changed in-place\n        array([3, 6, 3])\n    Args:\n      clu_num_points: Number of points in each cluster (vector of size $c$),\n        where $c$ is the number of clusters.\n      num_points: The expected total number of points.\n    Returns:\n      Number of points in each cluster, after being fixed by this function (vector\n        of size $c$, which is the same reference than `clu_num_points`).\n    \"\"\"\nwhile sum(clu_num_points) < num_points:\nimin = argmin(clu_num_points)\nclu_num_points[imin] += 1\nwhile sum(clu_num_points) > num_points:\nimax = argmax(clu_num_points)\nclu_num_points[imax] -= 1\nreturn clu_num_points\n
"},{"location":"reference/#pyclugen.llengths","title":"llengths","text":"
llengths(\nnum_clusters: int,\nllength: float,\nllength_disp: float,\nrng: Generator = _default_rng,\n) -> NDArray\n

Determine length of cluster-supporting lines.

Line lengths are determined using the folded normal distribution ( \\(\\mu=\\)llength, \\(\\sigma=\\)llength_disp).

Examples:

>>> from numpy.random import Generator, MT19937\n>>> from pyclugen import llengths\n>>> prng = Generator(MT19937(123))\n>>> llengths(4, 20, 3.5, rng=prng)\narray([19.50968733, 19.92482858, 25.99013804, 18.58029672])\n

Parameters:

Name Type Description Default num_clusters int

Number of clusters.

required llength float

Average line length.

required llength_disp float

Line length dispersion.

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Lengths of cluster-supporting lines (vector of size num_clusters).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def llengths(\nnum_clusters: int,\nllength: float,\nllength_disp: float,\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Determine length of cluster-supporting lines.\n    Line lengths are determined using the folded normal distribution (\n    $\\mu=$`llength`, $\\sigma=$`llength_disp`).\n    Examples:\n        >>> from numpy.random import Generator, MT19937\n        >>> from pyclugen import llengths\n        >>> prng = Generator(MT19937(123))\n        >>> llengths(4, 20, 3.5, rng=prng)\n        array([19.50968733, 19.92482858, 25.99013804, 18.58029672])\n    Args:\n      num_clusters: Number of clusters.\n      llength: Average line length.\n      llength_disp: Line length dispersion.\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Lengths of cluster-supporting lines (vector of size `num_clusters`).\n    \"\"\"\nreturn abs(llength + llength_disp * rng.normal(size=num_clusters))\n
"},{"location":"reference/#pyclugen.points_on_line","title":"points_on_line","text":"
points_on_line(\ncenter: NDArray, direction: NDArray, dist_center: NDArray\n) -> NDArray\n

Determine coordinates of points on a line.

Determine coordinates of points on a line with center and direction, based on the distances from the center given in dist_center.

This works by using the vector formulation of the line equation assuming direction is a \\(n\\)-dimensional unit vector. In other words, considering \\(\\mathbf{d}=\\)direction.reshape(-1,1) ( \\(n \\times 1\\) vector), \\(\\mathbf{c}=\\)center.reshape(-1,1) ( \\(n \\times 1\\) vector), and \\(\\mathbf{w}=\\) dist_center.reshape(-1,1) ( \\(p \\times 1\\) vector), the coordinates of points on the line are given by:

\\[ \\mathbf{P}=\\mathbf{1}\\,\\mathbf{c}^T + \\mathbf{w}\\mathbf{d}^T \\]

where \\(\\mathbf{P}\\) is the \\(p \\times n\\) matrix of point coordinates on the line, and \\(\\mathbf{1}\\) is a \\(p \\times 1\\) vector with all entries equal to 1.

Examples:

>>> from pyclugen import points_on_line\n>>> from numpy import array, linspace\n>>> points_on_line(array([5., 5.]),\n...                array([1., 0.]),\n...                linspace(-4, 4, 5)) # 2D, 5 points\narray([[1., 5.],\n       [3., 5.],\n       [5., 5.],\n       [7., 5.],\n       [9., 5.]])\n>>> points_on_line(array([-2, 0, 0., 2]),\n...                array([0., 0, -1, 0]),\n...                array([10, -10])) # 4D, 2 points\narray([[ -2.,   0., -10.,   2.],\n       [ -2.,   0.,  10.,   2.]])\n

Parameters:

Name Type Description Default center NDArray

Center of the line ( \\(n\\)-component vector).

required direction NDArray

Line direction ( \\(n\\)-component unit vector).

required dist_center NDArray

Distance of each point to the center of the line ( \\(p\\)-component vector, where \\(p\\) is the number of points).

required

Returns:

Type Description NDArray

Coordinates of points on the specified line ( \\(p \\times n\\) matrix).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/core.py
def points_on_line(\ncenter: NDArray, direction: NDArray, dist_center: NDArray\n) -> NDArray:\nr\"\"\"Determine coordinates of points on a line.\n    Determine coordinates of points on a line with `center` and `direction`,\n    based on the distances from the center given in `dist_center`.\n    This works by using the vector formulation of the line equation assuming\n    `direction` is a $n$-dimensional unit vector. In other words, considering\n    $\\mathbf{d}=$`direction.reshape(-1,1)` ( $n \\times 1$ vector),\n    $\\mathbf{c}=$`center.reshape(-1,1)` ( $n \\times 1$ vector), and\n    $\\mathbf{w}=$ `dist_center.reshape(-1,1)` ( $p \\times 1$ vector),\n    the coordinates of points on the line are given by:\n    $$\n    \\mathbf{P}=\\mathbf{1}\\,\\mathbf{c}^T + \\mathbf{w}\\mathbf{d}^T\n    $$\n    where $\\mathbf{P}$ is the $p \\times n$ matrix of point coordinates on the\n    line, and $\\mathbf{1}$ is a $p \\times 1$ vector with all entries equal to 1.\n    Examples:\n        >>> from pyclugen import points_on_line\n        >>> from numpy import array, linspace\n        >>> points_on_line(array([5., 5.]),\n        ...                array([1., 0.]),\n        ...                linspace(-4, 4, 5)) # 2D, 5 points\n        array([[1., 5.],\n               [3., 5.],\n               [5., 5.],\n               [7., 5.],\n               [9., 5.]])\n        >>> points_on_line(array([-2, 0, 0., 2]),\n        ...                array([0., 0, -1, 0]),\n        ...                array([10, -10])) # 4D, 2 points\n        array([[ -2.,   0., -10.,   2.],\n               [ -2.,   0.,  10.,   2.]])\n    Args:\n      center: Center of the line ( $n$-component vector).\n      direction: Line direction ( $n$-component unit vector).\n      dist_center: Distance of each point to the center of the line\n        ( $p$-component vector, where $p$ is the number of points).\n    Returns:\n      Coordinates of points on the specified line ( $p \\times n$ matrix).\n    \"\"\"\nreturn center.reshape(1, -1) + dist_center.reshape(-1, 1) @ direction.reshape(\n(1, -1)\n)\n
"},{"location":"reference/#pyclugen.rand_ortho_vector","title":"rand_ortho_vector","text":"
rand_ortho_vector(u: NDArray, rng: Generator = _default_rng) -> NDArray\n

Get a random unit vector orthogonal to u.

Note that u is expected to be a unit vector itself.

Examples:

>>> from pyclugen import rand_ortho_vector\n>>> from numpy import isclose, dot\n>>> from numpy.linalg import norm\n>>> from numpy.random import Generator, PCG64\n>>> rng = Generator(PCG64(123))\n>>> r = rng.random(3) # Get a random vector with 3 components (3D)\n>>> r = r / norm(r) # Normalize it\n>>> r_ort = rand_ortho_vector(r, rng=rng) # Get random unit vector orth. to r\n>>> r_ort\narray([-0.1982903 , -0.61401512,  0.76398062])\n>>> isclose(dot(r, r_ort), 0) # Check that vectors are indeed orthogonal\nTrue\n

Parameters:

Name Type Description Default u NDArray

Unit vector with \\(n\\) components.

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

A random unit vector with \\(n\\) components orthogonal to u.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/core.py
def rand_ortho_vector(u: NDArray, rng: Generator = _default_rng) -> NDArray:\nr\"\"\"Get a random unit vector orthogonal to `u`.\n    Note that `u` is expected to be a unit vector itself.\n    Examples:\n        >>> from pyclugen import rand_ortho_vector\n        >>> from numpy import isclose, dot\n        >>> from numpy.linalg import norm\n        >>> from numpy.random import Generator, PCG64\n        >>> rng = Generator(PCG64(123))\n        >>> r = rng.random(3) # Get a random vector with 3 components (3D)\n        >>> r = r / norm(r) # Normalize it\n        >>> r_ort = rand_ortho_vector(r, rng=rng) # Get random unit vector orth. to r\n        >>> r_ort\n        array([-0.1982903 , -0.61401512,  0.76398062])\n        >>> isclose(dot(r, r_ort), 0) # Check that vectors are indeed orthogonal\n        True\n    Args:\n      u: Unit vector with $n$ components.\n      rng: Optional pseudo-random number generator.\n    Returns:\n      A random unit vector with $n$ components orthogonal to `u`.\n    \"\"\"\n# If 1D, just return a random unit vector\nif u.size == 1:\nreturn rand_unit_vector(1, rng=rng)\n# Find a random, non-parallel vector to u\nwhile True:\n# Find normalized random vector\nr = rand_unit_vector(u.size, rng=rng)\n# If not parallel to u we can keep it and break the loop\nif not isclose(abs(dot(u, r)), 1):\nbreak\n# Get vector orthogonal to u using 1st iteration of Gram-Schmidt process\nv = r - dot(u, r) / dot(u, u) * u\n# Normalize it\nv = v / norm(v)\n# And return it\nreturn v\n
"},{"location":"reference/#pyclugen.rand_unit_vector","title":"rand_unit_vector","text":"
rand_unit_vector(num_dims: int, rng: Generator = _default_rng) -> NDArray\n

Get a random unit vector with num_dims components.

Examples:

>>> from pyclugen import rand_unit_vector\n>>> rand_unit_vector(4)\narray([ 0.48653889,  0.50753862,  0.05711487, -0.70881757])\n
>>> from pyclugen import rand_unit_vector\n>>> from numpy.random import Generator, PCG64\n>>> rng = Generator(PCG64(123))\n>>> rand_unit_vector(2, rng=rng) # Reproducible\narray([ 0.3783202 , -0.92567479])\n

Parameters:

Name Type Description Default num_dims int

Number of components in vector (i.e. vector size).

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

A random unit vector with num_dims components.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/core.py
def rand_unit_vector(num_dims: int, rng: Generator = _default_rng) -> NDArray:\nr\"\"\"Get a random unit vector with `num_dims` components.\n    Examples:\n        >>> from pyclugen import rand_unit_vector\n        >>> rand_unit_vector(4) # doctest: +SKIP\n        array([ 0.48653889,  0.50753862,  0.05711487, -0.70881757])\n        >>> from pyclugen import rand_unit_vector\n        >>> from numpy.random import Generator, PCG64\n        >>> rng = Generator(PCG64(123))\n        >>> rand_unit_vector(2, rng=rng) # Reproducible\n        array([ 0.3783202 , -0.92567479])\n    Args:\n      num_dims: Number of components in vector (i.e. vector size).\n      rng: Optional pseudo-random number generator.\n    Returns:\n      A random unit vector with `num_dims` components.\n    \"\"\"\nr = rng.random(num_dims) - 0.5\nr = r / norm(r)\nreturn r\n
"},{"location":"reference/#pyclugen.rand_vector_at_angle","title":"rand_vector_at_angle","text":"
rand_vector_at_angle(\nu: NDArray, angle: float, rng: Generator = _default_rng\n) -> NDArray\n

Get a random unit vector which is at angle radians of vector u.

Note that u is expected to be a unit vector itself.

Examples:

>>> from pyclugen import rand_vector_at_angle\n>>> from numpy import arccos, array, degrees, pi, dot\n>>> from numpy.linalg import norm\n>>> from numpy.random import Generator, PCG64\n>>> rng = Generator(PCG64(123))\n>>> u = array([ 1.0, 0, 0.5, -0.5 ]) # Define a 4D vector\n>>> u = u / norm(u) # Normalize the vector\n>>> v = rand_vector_at_angle(u, pi/4, rng=rng) # Get a vector at 45 degrees\n>>> v\narray([ 0.633066  , -0.50953554, -0.10693823, -0.57285705])\n>>> degrees(arccos(dot(u, v) / norm(u) * norm(v))) # Angle between u and v\n45.0\n

Parameters:

Name Type Description Default u NDArray

Unit vector with \\(n\\) components.

required angle float

Angle in radians.

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Random unit vector with \\(n\\) components which is at angle radians with vector u.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/core.py
def rand_vector_at_angle(\nu: NDArray, angle: float, rng: Generator = _default_rng\n) -> NDArray:\nr\"\"\"Get a random unit vector which is at `angle` radians of vector `u`.\n    Note that `u` is expected to be a unit vector itself.\n    Examples:\n        >>> from pyclugen import rand_vector_at_angle\n        >>> from numpy import arccos, array, degrees, pi, dot\n        >>> from numpy.linalg import norm\n        >>> from numpy.random import Generator, PCG64\n        >>> rng = Generator(PCG64(123))\n        >>> u = array([ 1.0, 0, 0.5, -0.5 ]) # Define a 4D vector\n        >>> u = u / norm(u) # Normalize the vector\n        >>> v = rand_vector_at_angle(u, pi/4, rng=rng) # Get a vector at 45 degrees\n        >>> v\n        array([ 0.633066  , -0.50953554, -0.10693823, -0.57285705])\n        >>> degrees(arccos(dot(u, v) / norm(u) * norm(v))) # Angle between u and v\n        45.0\n    Args:\n      u: Unit vector with $n$ components.\n      angle: Angle in radians.\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Random unit vector with $n$ components which is at `angle` radians\n        with vector `u`.\n    \"\"\"\nif isclose(abs(angle), pi / 2) and u.size > 1:\nreturn rand_ortho_vector(u, rng=rng)\nelif -pi / 2 < angle < pi / 2 and u.size > 1:\nv = u + rand_ortho_vector(u, rng=rng) * tan(angle)\nreturn v / norm(v)\nelse:\n# For |\u03b8| > \u03c0/2 or the 1D case, simply return a random vector\nreturn rand_unit_vector(u.size, rng=rng)\n
"},{"location":"theory/","title":"Theory","text":"

This section describes the theoretical framework of the clugen algorithm, starting with a general Overview, then moving on to a Detailed description.

"},{"location":"theory/#overview","title":"Overview","text":"

Clugen is an algorithm for generating multidimensional clusters. Each cluster is supported by a line segment, the position, orientation and length of which guide where the respective points are placed. For brevity, line segments will be referred to as lines.

Given an \\(n\\)-dimensional direction vector \\(\\mathbf{d}\\) (and a number of additional parameters, which will be discussed shortly), the clugen algorithm works as follows (\\(^*\\) means the algorithm step is stochastic):

  1. Normalize \\(\\mathbf{d}\\).
  2. \\(^*\\)Determine cluster sizes.
  3. \\(^*\\)Determine cluster centers.
  4. \\(^*\\)Determine lengths of cluster-supporting lines.
  5. \\(^*\\)Determine angles between \\(\\mathbf{d}\\) and cluster-supporting lines.
  6. For each cluster:
  7. \\(^*\\)Determine direction of the cluster-supporting line.
  8. \\(^*\\)Determine distance of point projections from the center of the cluster-supporting line.
  9. Determine coordinates of point projections on the cluster-supporting line.
  10. \\(^*\\)Determine points from their projections on the cluster-supporting line.

Figure 1 provides a stylized overview of the algorithm's steps.

The example in Figure 1 was generated with the following parameters, the exact meaning of each will be discussed shortly:

Parameter values Description \\(n=2\\) Number of dimensions. \\(c=4\\) Number of clusters. \\(p=200\\) Total number of points. \\(\\mathbf{d}=\\begin{bmatrix}1 & 1\\end{bmatrix}^T\\) Average direction. \\(\\theta_\\sigma=\\pi/16\\approx{}11.25^{\\circ}\\) Angle dispersion. \\(\\mathbf{s}=\\begin{bmatrix}10 & 10\\end{bmatrix}^T\\) Average cluster separation. \\(l=10\\) Average line length. \\(l_\\sigma=1.5\\) Line length dispersion. \\(f_\\sigma=1\\) Cluster lateral dispersion.

Additionally, all optional parameters (not listed above) were left to their default values. These will also be discussed next.

"},{"location":"theory/#detailed-description","title":"Detailed description","text":"

In this section we provide a detailed description of the algorithm and its parameters. We start by listing and describing all parameters (mandatory and optional), and then analyze the algorithm in detail, highlighting how each parameter influences the end result.

"},{"location":"theory/#algorithm-parameters","title":"Algorithm parameters","text":"

The clugen algorithm (and consequently, the clugen() function) has mandatory and optional parameters, listed and described in the tables below. The optional parameters are set to sensible defaults, and in many situations may be left unchanged. Nonetheless, these allow all of the algorithm's steps to be fully customized by the user.

"},{"location":"theory/#mandatory-parameters","title":"Mandatory parameters","text":"Symbol Parameter Description \\(n\\) num_dims Number of dimensions. \\(c\\) num_clusters Number of clusters. \\(p\\) num_points Total number of points to generate. \\(\\mathbf{d}\\) direction Average direction of cluster-supporting lines (\\(n \\times 1\\)). \\(\\theta_\\sigma\\) angle_disp Angle dispersion of cluster-supporting lines (radians). \\(\\mathbf{s}\\) cluster_sep Average cluster separation in each dimension (\\(n \\times 1\\)). \\(l\\) llength Average length of cluster-supporting lines. \\(l_\\sigma\\) llength_disp Length dispersion of cluster-supporting lines. \\(f_\\sigma\\) lateral_disp Cluster lateral dispersion, i.e., dispersion of points from their projection on the cluster-supporting line."},{"location":"theory/#optional-parameters","title":"Optional parameters","text":"Symbol Parameter Default value Description \\(\\phi\\) allow_empty False Allow empty clusters? \\(\\mathbf{o}\\) cluster_offset zeros(num_dims) Offset to add to all cluster centers (\\(n \\times 1\\)). \\(p_\\text{proj}()\\) proj_dist_fn \"norm\" Distribution of point projections along cluster-supporting lines. \\(p_\\text{final}()\\) point_dist_fn \"n-1\" Distribution of final points from their projections. \\(c_s()\\) clusizes_fn clusizes() Distribution of cluster sizes. \\(c_c()\\) clucenters_fn clucenters() Distribution of cluster centers. \\(l()\\) llengths_fn llengths() Distribution of line lengths. \\(\\theta_\\Delta()\\) angle_deltas_fn angle_deltas() Distribution of line angle deltas (w.r.t. \\(\\mathbf{d}\\))."},{"location":"theory/#the-algorithm-in-detail","title":"The algorithm in detail","text":"

The clugen algorithm is presented in Overview. In this section we will analyze each of the algorithms steps in detail.

"},{"location":"theory/#1-normalize-mathbfd","title":"1. Normalize \\(\\mathbf{d}\\)","text":"

This is a basic step, which consists of converting \\(\\mathbf{d}\\) to a unit vector:

\\[ \\hat{\\mathbf{d}} = \\cfrac{\\mathbf{d}}{\\left\\lVert\\mathbf{d}\\right\\rVert} \\]"},{"location":"theory/#2-determine-cluster-sizes","title":"2. Determine cluster sizes","text":"

Cluster sizes are given by the \\(c_s()\\) function according to:

\\[ \\mathbf{c_s} = c_s(c, p, \\phi) \\]

where \\(\\mathbf{c_s}\\) is an \\(c \\times 1\\) integer vector containing the final cluster sizes, \\(c\\) is the number of clusters, \\(p\\) is the total number of points, and \\(\\phi\\) is a boolean which determines whether empty clusters are acceptable.

The \\(c_s()\\) function is an optional parameter, allowing users to customize its behavior. By default, \\(c_s()\\) is implemented by the clusizes() function, which behaves according to the following algorithm:

  1. Determine the size \\(p_i\\) of each cluster \\(i\\) according to \\(p_i\\sim\\left\\lfloor\\max\\left(\\mathcal{N}(\\frac{p}{c}, (\\frac{p}{3c})^2),0\\right)\\right\\rceil\\), where \\(\\lfloor\\rceil\\) denotes the round to nearest integer function, and \\(\\mathcal{N}(\\mu,\\sigma^2)\\) represents the normal distribution with mean \\(\\mu\\) and variance \\(\\sigma^2\\).
  2. Assure that the final cluster sizes add up to \\(p\\) by incrementing the smallest cluster size while \\(\\sum_{i=1}^c p_i<p\\) or decrementing the largest cluster size while \\(\\sum_{i=1}^c p_i>p\\). This step is delegated to the fix_num_points() helper function.
  3. If \\(\\neg\\phi\\wedge p\\ge c\\) then, for each empty cluster \\(i\\) (i.e., \\(p_i=0\\)), increment \\(p_i\\) and decrement \\(p_j\\), where \\(j\\) denotes the largest cluster. This step is delegated to the fix_empty() helper function.

Figure 2 demonstrates possible cluster sizes with various definitions of \\(c_s()\\) for \\(c=4\\) and \\(p=5000\\). The default behavior, implemented in the clusizes() function, is shown in Figure 2a, while Figures 2b-d present results obtained with custom user functions. Figure 2b displays cluster sizes obtained with the discrete uniform distribution over \\(\\left\\{1, 2, \\ldots, \\frac{2p}{c}\\right\\}\\), corrected with fix_num_points(). In turn, Figure 2c highlights cluster sizes obtained with the Poisson distribution with \\(\\lambda=\\frac{p}{c}\\), also corrected with fix_num_points(). The cluster sizes shown in Figure 2d were determined with the same distribution (Poisson, \\(\\lambda=\\frac{p}{c}\\)), but were not corrected. Thus, cluster sizes do not add up to \\(p\\), highlighting the fact that this is not a requirement of the clugen algorithm, i.e., user-defined \\(c_s()\\) implementations can consider \\(p\\) a hint rather than an obligation.

"},{"location":"theory/#3-determine-cluster-centers","title":"3. Determine cluster centers","text":"

Cluster sizes are given by the \\(c_c()\\) function according to:

\\[ \\mathbf{C} = c_c(c, \\mathbf{s}, \\mathbf{o}) \\]

where \\(\\mathbf{C}\\) is an \\(c \\times n\\) matrix containing the final cluster centers, \\(c\\) is the number of clusters, \\(\\mathbf{s}\\) is the average cluster separation (\\(n \\times 1\\) vector), and \\(\\mathbf{o}\\) is an \\(n \\times 1\\) vector of cluster offsets.

The \\(c_c()\\) function is an optional parameter, allowing users to customize its behavior. By default, \\(c_c()\\) is implemented by the clucenters() function, which determines the cluster centers according to:

\\[ \\mathbf{C}=c\\mathbf{U} \\cdot \\operatorname{diag}(\\mathbf{s}) + \\mathbf{1}\\,\\mathbf{o}^T \\]

where \\(\\mathbf{U}\\) is an \\(c \\times n\\) matrix of random values drawn from the uniform distribution between -0.5 and 0.5, and \\(\\mathbf{1}\\) is an \\(c \\times 1\\) vector with all entries equal to 1.

Figure 3 shows scatters plots of the results generated by clugen for two different implementations of the \\(c_c()\\) function, namely using the uniform the distribution (the default, implemented by the clucenters() function, Figure 3a), and direct specification of cluster centers (Figure 3b).

"},{"location":"theory/#4-determine-lengths-of-cluster-supporting-lines","title":"4. Determine lengths of cluster-supporting lines","text":"

The lengths of the cluster-supporting lines are given by the \\(l()\\) function according to:

\\[ \\pmb{\\ell} = l(c, l, l_\\sigma) \\]

where \\(\\pmb{\\ell}\\) is an \\(c \\times 1\\) vector containing the final lengths of the cluster-supporting lines, \\(c\\) is the number of clusters, \\(l\\) is the average length, and \\(l_\\sigma\\) is the length dispersion.

The \\(l()\\) function is an optional parameter, allowing users to customize its behavior. By default, \\(l()\\) is implemented by the llengths() function, which determines the \\(\\ell_i\\) length of each cluster-supporting line \\(i\\) according to:

\\[ \\ell_i\\sim\\left|\\mathcal{N}(l,l_\\sigma^2)\\right| \\]

where \\(\\left|\\mathcal{N}(\\mu,\\sigma^2)\\right|\\) represents the folded normal distribution with mean \\(\\mu\\) and variance \\(\\sigma^2\\).

Figure 4 shows cluster-supporting line lengths obtained with different implementations of \\(l()\\).

"},{"location":"theory/#5-determine-angles-between-mathbfd-and-cluster-supporting-lines","title":"5. Determine angles between \\(\\mathbf{d}\\) and cluster-supporting lines","text":"

The angles between \\(\\mathbf{d}\\) and the cluster-supporting lines are given by the \\(\\theta_\\Delta()\\) function according to:

\\[ \\mathbf{\\Theta_\\Delta} = \\theta_\\Delta(c, \\theta_\\sigma) \\]

where \\(\\mathbf{\\Theta_\\Delta}\\) is an \\(c \\times 1\\) vector containing the final angle differences between \\(\\mathbf{d}\\) and the cluster-supporting lines, \\(c\\) is the number of clusters, and \\(\\theta_\\sigma\\) is the angle dispersion.

The \\(\\theta_\\Delta()\\) function is an optional parameter, allowing users to customize its behavior. By default, \\(\\theta_\\Delta()\\) is implemented by the angle_deltas() function, which determines the \\(\\theta_{\\Delta i}\\) angle difference between \\(\\mathbf{d}\\) and the \\(i\\)-th cluster-supporting line according to:

\\[ \\theta_{\\Delta i}\\sim\\mathcal{WN}_{-\\pi/2}^{\\pi/2}(0,\\theta_\\sigma^2) \\]

where \\(\\mathcal{WN}_{-\\pi/2}^{\\pi/2}(\\mu,\\sigma^2)\\) represents the wrapped normal distribution with mean \\(\\mu\\), variance \\(\\sigma^2\\), and support in the \\(\\left[-\\pi/2,\\pi/2\\right]\\) interval, and \\(\\theta_\\sigma\\) is the angle dispersion of the cluster-supporting lines.

Figure 5 shows the final direction of the cluster-supporting lines for two different implementations of \\(\\theta_\\Delta()\\).

"},{"location":"theory/#6-for-each-cluster-i","title":"6. For each cluster \\(i\\):","text":""},{"location":"theory/#61-determine-direction-of-the-cluster-supporting-line","title":"6.1. Determine direction of the cluster-supporting line","text":"

In order to obtain the \\(\\hat{\\mathbf{d}}_i\\) final direction of cluster \\(i\\) supporting line, the following algorithm is used:

  • 1. Find random vector \\(\\mathbf{r}\\) with each component taken from the uniform distribution between -0.5 and 0.5.
  • 2. Normalize \\(\\mathbf{r}\\):
\\[ \\hat{\\mathbf{r}}=\\cfrac{\\mathbf{r}}{\\left\\lVert\\mathbf{r}\\right\\rVert} \\]
  • 3. If \\(|\\theta_{\\Delta i}| > \\pi/2\\) or \\(n=1\\), set \\(\\hat{\\mathbf{d}}_i=\\hat{\\mathbf{r}}\\) and terminate the algorithm.
  • 4. If \\(\\hat{\\mathbf{r}}\\) is parallel to \\(\\hat{\\mathbf{d}}\\) go to 1.
  • 5. Determine vector \\(\\mathbf{d}_\\perp\\) orthogonal to \\(\\hat{\\mathbf{d}}\\) using the first iteration of the Gram-Schmidt process:
\\[ \\mathbf{d}_\\perp=\\hat{\\mathbf{r}}-\\cfrac{\\hat{\\mathbf{d}}\\cdot\\hat{\\mathbf{r}}}{\\hat{\\mathbf{d}}\\cdot\\hat{\\mathbf{d}}}\\:\\hat{\\mathbf{d}} \\]
  • 6. Normalize \\(\\mathbf{d}_\\perp\\):
\\[ \\hat{\\mathbf{d}}_\\perp=\\cfrac{\\mathbf{d}_\\perp}{\\left\\lVert\\mathbf{d}_\\perp\\right\\rVert} \\]
  • 7. Determine vector \\(\\mathbf{d}_i\\) at angle \\(\\theta_{\\Delta i}\\) with \\(\\hat{\\mathbf{d}}\\):
\\[ \\mathbf{d}_i=\\hat{\\mathbf{d}}+\\tan(\\theta_{\\Delta i})\\hat{\\mathbf{d}}_\\perp \\]
  • 8. Normalize \\(\\mathbf{d}_i\\):
\\[ \\hat{\\mathbf{d}}_i=\\cfrac{\\mathbf{d}_i}{\\left\\lVert\\mathbf{d}_i\\right\\rVert} \\]"},{"location":"theory/#62-determine-distance-of-point-projections-from-the-center-of-the-cluster-supporting-line","title":"6.2. Determine distance of point projections from the center of the cluster-supporting line","text":"

The distance of point projections from the center of the cluster-supporting line is given by the \\(p_\\text{proj}()\\) function according to:

\\[ \\mathbf{w}_i = p_\\text{proj}(\\ell_i, p_i) \\]

where \\(\\mathbf{w}_i\\) is an \\(p_i \\times 1\\) vector containing the distance of each point projection to the center of the line, while \\(\\ell_i\\) and \\(p_i\\) are the line length and number of points in cluster \\(i\\), respectively.

The \\(p_\\text{proj}()\\) function is an optional parameter, allowing users to customize its behavior. pyclugen provides two concrete implementations out of the box, specified by passing \"norm\" or \"unif\" to clugen()'s proj_dist_fn parameter. These work as follows:

  • \"norm\" (default) - Each element of \\(\\mathbf{w}_i\\) is derived from \\(\\mathcal{N}(0, (\\frac{\\ell_i}{6})^2)\\), i.e., from the normal distribution, centered on the cluster-supporting line center (\\(\\mu=0\\)) and with a standard deviation of \\(\\sigma=\\frac{\\ell_i}{6}\\), such that the length of the line segment encompasses \\(\\approx\\) 99.73% of the generated projections. Consequently, some projections may be placed outside the line's end points.
  • \"unif\" - Each element of \\(\\mathbf{w}_i\\) is derived from \\(\\mathcal{U}(-\\frac{\\ell_i}{2}, \\frac{\\ell_i}{2})\\), i.e., from the continuous uniform distribution in the interval \\(\\left[-\\frac{\\ell_i}{2}, \\frac{\\ell_i}{2}\\right[\\). Thus, projections will be uniformly dispersed along the cluster-supporting line.

The impact of various implementations of \\(p_\\text{proj}()\\) is demonstrated in Figure 6. Figures 6a and 6b show the clusters generated with the \"norm\" and \"unif\" options, respectively, while Figures 6c and 6d highlight custom user functions implementing the Laplace and Rayleigh distributions, respectively. All parameters are set as in Figure 1, except for \\(p_\\text{proj}()\\) in the case of Figures 6b-6d, and \\(p\\), which is set to 5000.

"},{"location":"theory/#63-determine-coordinates-of-point-projections-on-the-cluster-supporting-line","title":"6.3. Determine coordinates of point projections on the cluster-supporting line","text":"

This is a deterministic step performed by the points_on_line() function using the vector formulation of the line equation, as follows:

\\[ \\mathbf{P}_i^\\text{proj}=\\mathbf{1}\\,\\mathbf{c}_i^T + \\mathbf{w}_i\\hat{\\mathbf{d}}_i^T \\]

where \\(\\mathbf{P}_i^\\text{proj}\\) is the \\(p_i \\times n\\) matrix of point projection coordinates on the line, \\(\\mathbf{1}\\) is an \\(p_i \\times 1\\) vector with all entries equal to 1, \\(\\mathbf{c}_i\\) are the coordinates of the line center (\\(n \\times 1\\) vector), \\(\\mathbf{w}_i\\) is the distance of each point projection to the center of the line (\\(p_i \\times 1\\) vector obtained in the previous step), and \\(\\hat{\\mathbf{d}}_i\\) is the direction of the cluster-supporting line for cluster \\(i\\).

"},{"location":"theory/#64-determine-points-from-their-projections-on-the-cluster-supporting-line","title":"6.4. Determine points from their projections on the cluster-supporting line","text":"

The final cluster points, obtained from their projections on the cluster-supporting line, are given by the \\(p_\\text{final}()\\) function according to:

\\[ \\mathbf{P}_i^\\text{final} = p_\\text{final}(\\mathbf{P}_i^\\text{proj}, f_\\sigma, \\ell_i, \\hat{\\mathbf{d}}_i, \\mathbf{c}_i) \\]

where \\(\\mathbf{P}_i^\\text{final}\\) is a \\(p_i \\times n\\) matrix containing the coordinates of the generated points, \\(\\mathbf{P}_i^\\text{proj}\\) is the \\(p_i \\times n\\) matrix of projection coordinates (determined in the previous step), and \\(f_\\sigma\\) is the lateral dispersion parameter. In turn, \\(\\ell_i\\), \\(\\hat{\\mathbf{d}}_i\\) and \\(\\mathbf{c}_i\\) are the length, direction and center of the cluster-supporting line.

The \\(p_\\text{final}()\\) function is an optional parameter, allowing users to customize its behavior. pyclugen provides two concrete implementations out of the box, specified by passing \"n-1\" or \"n\" to clugen()'s point_dist_fn parameter. These work as follows:

  • \"n-1\" (default) - Points are placed on a hyperplane orthogonal to the cluster-supporting line and intersecting the point's projection. This is done by obtaining \\(p_i\\) random unit vectors orthogonal to \\(\\hat{\\mathbf{d}}_i\\), and determining their magnitude using the normal distribution (\\(\\mu=0\\), \\(\\sigma=f_\\sigma\\)). These vectors are then added to the respective projections on the cluster-supporting line, yielding the final cluster points. This behavior is implemented in the clupoints_n_1() function.
  • \"n\" - Points are placed around their respective projections. This is done by obtaining \\(p_i\\) random unit vectors, and determining their magnitude using the normal distribution (\\(\\mu=0\\), \\(\\sigma=f_\\sigma\\)). These vectors are then added to the respective projections on the cluster-supporting line, yielding the final cluster points. This behavior is implemented in the clupoints_n() function.

Figure 7 highlights the differences between these two approaches in 2D, where a hyperplane is simply a line.

In general, points can be placed using a \"n-1\" or \"n\" strategy using any distribution. Figure 8 displays several examples for various implementations of \\(p_\\text{final}()\\), either based on \"n-1\" or \"n\" strategy, using different distributions. Figures 8a and 8b show the built-in \"n-1\" and \"n\" strategies making use of the normal distribution. Figures 8c-8f highlight some possibilities with custom user functions. Figure 8c shows the effect of using the exponential distribution in a \"n-1\" strategy, while Figure 8d displays the result of using a bimodal distribution with the same strategy. A more complex distribution, producing \"hollow\" clusters with a \"n\" strategy, is employed in Figures 8e and 8f, with the latter also having the \\(p_\\text{proj}()\\) function set to \"unif\". The remaining parameters (for all subfigures) are set as in Figure 1, except for \\(p\\), which is set to 5000.

"},{"location":"generated/gallery/","title":"Examples","text":""},{"location":"generated/gallery/#examples","title":"Examples","text":"

Examples in 1D

Examples in 2D

Examples in 3D

Examples in nD

Merging and hierarchical cluster examples

Plot functions

Download all examples in Python source code: gallery_python.zip

Download all examples in Jupyter notebooks: gallery_jupyter.zip

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/mg_execution_times/","title":"Computation times","text":"

00:36.628 total execution time for generated_gallery files:

+----------------------------------------------------------------------------------------+-----------+--------+ | plot_2_2d_examples (docs/examples/plot_2_2d_examples.py) | 00:13.505 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ | plot_4_nd_examples (docs/examples/plot_4_nd_examples.py) | 00:11.310 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ | plot_3_3d_examples (docs/examples/plot_3_3d_examples.py) | 00:05.871 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ | plot_5_mrg_examples (docs/examples/plot_5_mrg_examples.py) | 00:04.270 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ | plot_1_1d_examples (docs/examples/plot_1_1d_examples.py) | 00:01.666 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ | plot_functions (docs/examples/plot_functions.py) | 00:00.006 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+

"},{"location":"generated/gallery/plot_1_1d_examples/","title":"Examples in 1D","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_1_1d_examples/#examples-in-1d","title":"Examples in 1D","text":"

This section contains several examples on how to generate 1D data with pyclugen. To run the examples we first need to import the clugen() function:

from pyclugen import clugen\n

To make the examples exactly reproducible we'll import a random number generator from NumPy and pass it as a parameter to clugen(). We'll also create a small helper function for providing us a brand new seeded generator:

import numpy as np\nfrom numpy.random import PCG64, Generator\ndef rng(seed):\nreturn Generator(PCG64(seed))\n

To plot these examples we use the plot_examples_1d function:

from plot_functions import plot_examples_1d\n
"},{"location":"generated/gallery/plot_1_1d_examples/#basic-1d-example-with-density-plot","title":"Basic 1D example with density plot","text":"
seed = 23456\n
# Custom proj_dist_fn: point projections placed using the Weibull distribution\ndef proj_weibull(len, n, rng):\nreturn len / 2 * rng.weibull(1.5, size=n)\n
e082 = clugen(1, 3, 1000, [1], 0, [10], 6, 1.5, 0, rng=rng(seed))\ne083 = clugen(1, 3, 1000, [1], 0, [10], 6, 1.5, 0, rng=rng(seed), proj_dist_fn=\"unif\")\ne084 = clugen(1, 3, 1000, [1], 0, [10], 6, 1.5, 0, rng=rng(seed), proj_dist_fn=proj_weibull)\n
plot_examples_1d(\ne082, \"e082: proj_dist_fn = 'norm' (default)\",\ne083, \"e083: proj_dist_fn = 'unif'\",\ne084, \"e084: custom proj_dist_fn (Weibull)\")\n

Out:

/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.\n  with pd.option_context('mode.use_inf_as_na', True):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n

Total running time of the script: ( 0 minutes 1.666 seconds)

Download Python source code: plot_1_1d_examples.py

Download Jupyter notebook: plot_1_1d_examples.ipynb

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/plot_2_2d_examples/","title":"Examples in 2D","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_2_2d_examples/#examples-in-2d","title":"Examples in 2D","text":"

This section contains several examples on how to generate 2D data with pyclugen. To run the examples we first need to import the clugen() function:

from pyclugen import clugen\n

To make the examples exactly reproducible we'll import a random number generator from NumPy and pass it as a parameter to clugen(). We'll also create a small helper function for providing us a brand new seeded generator:

import numpy as np\nfrom numpy.random import PCG64, Generator\ndef rng(seed):\nreturn Generator(PCG64(seed))\n

To plot these examples we use the plot_examples_2d function:

from plot_functions import plot_examples_2d\n
"},{"location":"generated/gallery/plot_2_2d_examples/#manipulating-the-direction-of-cluster-supporting-lines","title":"Manipulating the direction of cluster-supporting lines","text":""},{"location":"generated/gallery/plot_2_2d_examples/#using-the-direction-parameter","title":"Using the direction parameter","text":"
seed = 123\n
e001 = clugen(2, 4, 2000, [1, 0], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed))\ne002 = clugen(2, 4, 200, [1, 1], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed))\ne003 = clugen(2, 4, 200, [0, 1], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed))\n
plot_examples_2d(\ne001, \"e001: direction = [1, 0]\",\ne002, \"e002: direction = [1, 1]\",\ne003, \"e003: direction = [0, 1]\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#changing-the-angle_disp-parameter-and-using-a-custom-angle_deltas_fn-function","title":"Changing the angle_disp parameter and using a custom angle_deltas_fn function","text":"
seed = 321\n
# Custom angle_deltas function: arbitrarily rotate some clusters by 90 degrees\ndef angdel_90_fn(nclu, astd, rng):\nreturn rng.choice([0, np.pi / 2], size=nclu)\n
e004 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed))\ne005 = clugen(2, 6, 500, [1, 0], np.pi / 8, [10, 10], 10, 1.5, 0.5, rng=rng(seed))\ne006 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed),\nangle_deltas_fn=angdel_90_fn)\n
plot_examples_2d(\ne004, \"e004: angle_disp = 0\",\ne005, \"e005: angle_disp = \u03c0/8\",\ne006, \"e006: custom angle_deltas function\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#manipulating-the-length-of-cluster-supporting-lines","title":"Manipulating the length of cluster-supporting lines","text":""},{"location":"generated/gallery/plot_2_2d_examples/#using-the-llength-parameter","title":"Using the llength parameter","text":"
seed = 567\n
e007 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10],  0, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne008 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 10, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne009 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 30, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\n
plot_examples_2d(\ne007, \"e007: llength = 0\",\ne008, \"e008: llength = 10\",\ne009, \"e009: llength = 30\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#changing-the-llength_disp-parameter-and-using-a-custom-llengths_fn-function","title":"Changing the llength_disp parameter and using a custom llengths_fn function","text":"
seed = 567\n
# Custom llengths function: line lengths grow for each new cluster\ndef llen_grow_fn(nclu, llen, llenstd, rng):\nreturn llen * np.arange(nclu) + rng.normal(scale=llenstd, size=nclu)\n
e010 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 15,  0.0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne011 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 15, 10.0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne012 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 10,  0.1, 0.5, rng=rng(seed),\nllengths_fn=llen_grow_fn, point_dist_fn=\"n\")\n
plot_examples_2d(\ne010, \"e010: llength_disp = 0.0\",\ne011, \"e011: llength_disp = 5.0\",\ne012, \"e012: custom llengths function\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#manipulating-relative-cluster-positions","title":"Manipulating relative cluster positions","text":""},{"location":"generated/gallery/plot_2_2d_examples/#using-the-cluster_sep-parameter","title":"Using the cluster_sep parameter","text":"
seed = 21\n
e013 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed))\ne014 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [30, 10], 10, 2, 2.5, rng=rng(seed))\ne015 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 30], 10, 2, 2.5, rng=rng(seed))\n
plt = plot_examples_2d(\ne013, \"e013: cluster_sep = [10, 10]\",\ne014, \"e014: cluster_sep = [30, 10]\",\ne015, \"e015: cluster_sep = [10, 30]\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#changing-the-cluster_offset-parameter-and-using-a-custom-clucenters_fn-function","title":"Changing the cluster_offset parameter and using a custom clucenters_fn function","text":"
seed = 21\n
# Custom clucenters function: places clusters in a diagonal\ndef centers_diag_fn(nclu, csep, coff, rng):\nreturn np.ones((nclu, len(csep))) * np.arange(1, nclu + 1)[:, None] * np.max(csep) + coff\n
e016 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed))\ne017 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed),\ncluster_offset=[20, -20])\ne018 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed),\ncluster_offset=[-50, -50], clucenters_fn=centers_diag_fn)\n
plt = plot_examples_2d(\ne016, \"e016: default\",\ne017, \"e017: cluster_offset = [20, -20]\",\ne018, \"e018: custom clucenters function\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#lateral-dispersion-and-placement-of-point-projections-on-the-line","title":"Lateral dispersion and placement of point projections on the line","text":""},{"location":"generated/gallery/plot_2_2d_examples/#normal-projection-placement-default-proj_dist_fn-norm","title":"Normal projection placement (default): proj_dist_fn = \"norm\"","text":"
seed = 654\n
e019 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed))\ne020 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed))\ne021 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed))\n
plt = plot_examples_2d(\ne019, \"e019: lateral_disp = 0\",\ne020, \"e020: lateral_disp = 1\",\ne021, \"e021: lateral_disp = 3\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#uniform-projection-placement-proj_dist_fn-unif","title":"Uniform projection placement: proj_dist_fn = \"unif\"","text":"
seed = 654\n
e022 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne023 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne024 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\n
plt = plot_examples_2d(\ne022, \"e022: lateral_disp = 0\",\ne023, \"e023: lateral_disp = 1\",\ne024, \"e024: lateral_disp = 3\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#custom-projection-placement-using-the-laplace-distribution","title":"Custom projection placement using the Laplace distribution","text":"
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e025 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\ne026 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\ne027 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\n
plt = plot_examples_2d(\ne025, \"e025: lateral_disp = 0\",\ne026, \"e026: lateral_disp = 1\",\ne027, \"e027: lateral_disp = 3\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#controlling-final-point-positions-from-their-projections-on-the-cluster-supporting-line","title":"Controlling final point positions from their projections on the cluster-supporting line","text":""},{"location":"generated/gallery/plot_2_2d_examples/#points-on-hyperplane-orthogonal-to-cluster-supporting-line-default-point_dist_fn-n-1","title":"Points on hyperplane orthogonal to cluster-supporting line (default): point_dist_fn = \"n-1\"","text":"
seed = 1357\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e028 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed))\ne029 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne030 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\n
plt = plot_examples_2d(\ne028, \"e028: proj_dist_fn=\\\"norm\\\" (default)\",\ne029, \"e029: proj_dist_fn=\\\"unif\\\"\",\ne030, \"e030: custom proj_dist_fn (Laplace)\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#points-around-projection-on-cluster-supporting-line-point_dist_fn-n","title":"Points around projection on cluster-supporting line: point_dist_fn = \"n\"","text":"
seed = 1357\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e031 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=\"n\")\ne032 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=\"n\", proj_dist_fn=\"unif\")\ne033 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=\"n\", proj_dist_fn=proj_laplace)\n
plt = plot_examples_2d(\ne031, \"e031: proj_dist_fn=\\\"norm\\\" (default)\",\ne032, \"e032: proj_dist_fn=\\\"unif\\\"\",\ne033, \"e033: custom proj_dist_fn (Laplace)\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#custom-point-placement-using-the-exponential-distribution","title":"Custom point placement using the exponential distribution","text":"

For this example we require the clupoints_n_1_template() helper function:

from pyclugen import clupoints_n_1_template\n
seed = 1357\n
# Custom point_dist_fn: final points placed using the Exponential distribution\ndef clupoints_n_1_exp(projs, lat_std, len, clu_dir, clu_ctr, rng):\ndef dist_exp(npts, lstd, rg):\nreturn lstd * rg.exponential(scale=2 / lstd, size=npts)\nreturn clupoints_n_1_template(projs, lat_std, clu_dir, dist_exp, rng=rng)\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e034 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp)\ne035 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp, proj_dist_fn=\"unif\")\ne036 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp, proj_dist_fn=proj_laplace)\n
plt = plot_examples_2d(\ne034, \"e034: proj_dist_fn=\\\"norm\\\" (default)\",\ne035, \"e035: proj_dist_fn=\\\"unif\\\"\",\ne036, \"e036: custom proj_dist_fn (Laplace)\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#manipulating-cluster-sizes","title":"Manipulating cluster sizes","text":"
seed = 963\n
# Custom clusizes_fn (e038): cluster sizes determined via the uniform distribution,\n# no correction for total points\ndef clusizes_unif(nclu, npts, ae, rng):\nreturn rng.integers(low=1, high=2 * npts / nclu + 1, size=nclu)\n
# Custom clusizes_fn (e039): clusters all have the same size, no correction for total points\ndef clusizes_equal(nclu, npts, ae, rng):\nreturn (npts // nclu) * np.ones(nclu, dtype=int)\n
# Custom clucenters_fn (all): yields fixed positions for the clusters\ndef centers_fixed(nclu, csep, coff, rng):\nreturn np.array([[-csep[0], -csep[1]], [csep[0], -csep[1]], [-csep[0], csep[1]], [csep[0], csep[1]]])\n
e037 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),\npoint_dist_fn=\"n\", clucenters_fn=centers_fixed)\ne038 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),\npoint_dist_fn=\"n\", clucenters_fn=centers_fixed, clusizes_fn=clusizes_unif)\ne039 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),\npoint_dist_fn=\"n\", clucenters_fn=centers_fixed, clusizes_fn=clusizes_equal)\n
plt = plot_examples_2d(\ne037, \"e037: normal dist. (default)\",\ne038, \"e038: unif. dist. (custom)\",\ne039, \"e039: equal size (custom)\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_2_2d_examples/#direct-specification-of-optional-parameters","title":"Direct specification of optional parameters","text":"
seed = 123\n
e040 = clugen(2, 4, 1000, [-1, 1], 0, [0, 0], 0, 0, 0.2, rng=rng(seed),\nproj_dist_fn=\"unif\", point_dist_fn=\"n\", clusizes_fn=[50, 200, 500, 2000],\nllengths_fn=[0, 2, 4, 6], clucenters_fn=[[-5, -5], [-2.5, -2.5], [0, 0], [2.5, 2.5]])\ne041 = clugen(2, 5, 1000, [[1, 1], [1, 0], [1, 0], [0, 1], [0, 1]],\n0, [0, 0], 0, 0, 0.2, rng=rng(seed),\nproj_dist_fn=\"unif\", point_dist_fn=\"n\",\nclusizes_fn=[200, 500, 500, 500, 500], llengths_fn=[0, 5, 5, 5, 5],\nclucenters_fn=[[0, 0], [0, 5], [0, -5], [5, 0], [-5, 0]])\ne042 = clugen(2, 5, 1000, [[0, 1], [0.25, 0.75], [0.5, 0.5], [0.75, 0.25], [1, 0]],\n0, [0, 0], 5, 0, 0.2, rng=rng(seed),\nproj_dist_fn=\"unif\", point_dist_fn=\"n\", clusizes_fn=[500, 500, 500, 500, 500],\nclucenters_fn=[[-5, 0], [-3, -0.3], [-1, -0.8], [1, -1.6], [3, -2.5]])\n
plt = plot_examples_2d(\ne040, \"e040: direct params 1\",\ne041, \"e041: direct params 2\",\ne042, \"e042: direct params 3\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n

Total running time of the script: ( 0 minutes 13.505 seconds)

Download Python source code: plot_2_2d_examples.py

Download Jupyter notebook: plot_2_2d_examples.ipynb

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/plot_3_3d_examples/","title":"Examples in 3D","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_3_3d_examples/#examples-in-3d","title":"Examples in 3D","text":"

This section contains several examples on how to generate 3D data with pyclugen. To run the examples we first need to import the clugen() function:

from pyclugen import clugen\n

To make the examples exactly reproducible we'll import a random number generator from NumPy and pass it as a parameter to clugen(). We'll also create a small helper function for providing us a brand new seeded generator:

import numpy as np\nfrom numpy.random import PCG64, Generator\ndef rng(seed):\nreturn Generator(PCG64(seed))\n

To plot these examples we use the plot_examples_3d function:

from plot_functions import plot_examples_3d\n
"},{"location":"generated/gallery/plot_3_3d_examples/#manipulating-the-direction-of-cluster-supporting-lines","title":"Manipulating the direction of cluster-supporting lines","text":""},{"location":"generated/gallery/plot_3_3d_examples/#using-the-direction-parameter","title":"Using the direction parameter","text":"
seed = 321\n
e043 = clugen(3, 4, 500, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))\ne044 = clugen(3, 4, 500, [1, 1, 1], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))\ne045 = clugen(3, 4, 500, [0, 0, 1], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))\n
plt = plot_examples_3d(\ne043, \"e043: direction = [1, 0, 0]\",\ne044, \"e044: direction = [1, 1, 1]\",\ne045, \"e045: direction = [0, 0, 1]\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#changing-the-angle_disp-parameter-and-using-a-custom-angle_deltas_fn-function","title":"Changing the angle_disp parameter and using a custom angle_deltas_fn function","text":"
seed = 321\n# Custom angle_deltas function: arbitrarily rotate some clusters by 90 degrees\ndef angdel_90_fn(nclu, astd, rng):\nreturn rng.choice([0, np.pi / 2], size=nclu)\n
e046 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))\ne047 = clugen(3, 6, 1000, [1, 0, 0], np.pi / 8, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))\ne048 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed),\nangle_deltas_fn=angdel_90_fn)\n
plt = plot_examples_3d(\ne046, \"e046: angle_disp = 0\",\ne047, \"e047: angle_disp = \u03c0 / 8\",\ne048, \"e048: custom angle_deltas function\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#specifying-a-main-direction-for-each-cluster-and-changing-angle_disp","title":"Specifying a main direction for each cluster and changing angle_disp","text":"
seed = 123\n# Define a main direction for each cluster\ndirs = [[1, 1, 1], [0, 0, 1], [1, 0, 0], [0, 1, 0], [-1, 1, 1]]\n
e049 = clugen(3, 5, 1000, dirs, 0, np.zeros(3), 20, 0, 0.2, proj_dist_fn=\"unif\", rng=rng(seed))\ne050 = clugen(3, 5, 1000, dirs, np.pi / 12, np.zeros(3), 20, 0, 0.2, proj_dist_fn=\"unif\", rng=rng(seed))\ne051 = clugen(3, 5, 1000, dirs, np.pi / 4, np.zeros(3), 20, 0, 0.2, proj_dist_fn=\"unif\", rng=rng(seed))\n
plot_examples_3d(\ne049, \"e049: angle_disp = 0\",\ne050, \"e050: angle_disp = \u03c0 / 12\",\ne051, \"e051: angle_disp = \u03c0 / 4\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#manipulating-the-length-of-cluster-supporting-lines","title":"Manipulating the length of cluster-supporting lines","text":""},{"location":"generated/gallery/plot_3_3d_examples/#using-the-llength-parameter","title":"Using the llength parameter","text":"
seed = 789\n
e052 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 0, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne053 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 10, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne054 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 30, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\n
plt = plot_examples_3d(\ne052, \"e052: llength = 0\",\ne053, \"e053: llength = 10\",\ne054, \"e054: llength = 30\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#changing-the-llength_disp-parameter-and-using-a-custom-llengths_fn-function","title":"Changing the llength_disp parameter and using a custom llengths_fn function","text":"
seed = 765\n
# Custom llengths function: line lengths tend to grow for each new cluster\ndef llen_grow_fn(nclu, llen, llenstd, rng):\nreturn llen * np.arange(nclu) + rng.normal(scale=llenstd, size=nclu)\ne055 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 15,  0.0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne056 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 15, 10.0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne057 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 10,  0.1, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\", llengths_fn=llen_grow_fn)\n
plt = plot_examples_3d(\ne055, \"e055: llength_disp = 0.0\",\ne056, \"e056: llength_disp = 10.0\",\ne057, \"e057: custom llengths function\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#manipulating-relative-cluster-positions","title":"Manipulating relative cluster positions","text":""},{"location":"generated/gallery/plot_3_3d_examples/#using-the-cluster_sep-parameter","title":"Using the cluster_sep parameter","text":"
seed = 765\n
e058 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [30, 10, 10], 25, 4, 3, rng=rng(seed))\ne059 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 30, 10], 25, 4, 3, rng=rng(seed))\ne060 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 30], 25, 4, 3, rng=rng(seed))\n
plt = plot_examples_3d(\ne058, \"e058: cluster_sep = [30, 10, 10]\",\ne059, \"e059: cluster_sep = [10, 30, 10]\",\ne060, \"e060: cluster_sep = [10, 10, 30]\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#changing-the-cluster_offset-parameter-and-using-a-custom-clucenters_fn-function","title":"Changing the cluster_offset parameter and using a custom clucenters_fn function","text":"
# Custom clucenters function: places clusters in a diagonal\ndef centers_diag_fn(nclu, csep, coff, rng):\nreturn np.ones((nclu, len(csep))) * np.arange(1, nclu + 1)[:, None] * np.max(csep) + coff\ne061 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed))\ne062 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed),\ncluster_offset=[30, -30, 30])\ne063 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed),\ncluster_offset=[-40, -40, -40], clucenters_fn=centers_diag_fn)\n
plt = plot_examples_3d(\ne061, \"e061: default\",\ne062, \"e062: cluster_offset=[30, -30, 30]\",\ne063, \"e063: custom clucenters function\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#lateral-dispersion-and-placement-of-point-projections-on-the-line","title":"Lateral dispersion and placement of point projections on the line","text":""},{"location":"generated/gallery/plot_3_3d_examples/#normal-projection-placement-default-proj_dist_fnnorm","title":"Normal projection placement (default): proj_dist_fn=\"norm\"","text":"
seed = 246\n
e064 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed))\ne065 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed))\ne066 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed))\n
plt = plot_examples_3d(\ne064, \"e064: lateral_disp = 0\",\ne065, \"e065: lateral_disp = 1\",\ne066, \"e066: lateral_disp = 3\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#uniform-projection-placement-proj_dist_fnunif","title":"Uniform projection placement: proj_dist_fn=\"unif\"","text":"
seed = 246\n
e067 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne068 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne069 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\n
plt = plot_examples_3d(\ne067, \"e067: lateral_disp = 0\",\ne068, \"e068: lateral_disp = 1\",\ne069, \"e069: lateral_disp = 3\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#custom-projection-placement-using-the-laplace-distribution","title":"Custom projection placement using the Laplace distribution","text":"
seed = 246\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e070 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\ne071 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\ne072 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\n
plt = plot_examples_3d(\ne070, \"e070: lateral_disp = 0\",\ne071, \"e071: lateral_disp = 1\",\ne072, \"e072: lateral_disp = 3\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#controlling-final-point-positions-from-their-projections-on-the-cluster-supporting-line","title":"Controlling final point positions from their projections on the cluster-supporting line","text":""},{"location":"generated/gallery/plot_3_3d_examples/#points-on-hyperplane-orthogonal-to-cluster-supporting-line-default-point_dist_fnn-1","title":"Points on hyperplane orthogonal to cluster-supporting line (default): point_dist_fn=\"n-1\"","text":"
seed = 840\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e073 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed))\ne074 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne075 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\nproj_dist_fn=proj_laplace)\n
plt = plot_examples_3d(\ne073, \"e073: proj_dist_fn=\\\"norm\\\" (default)\",\ne074, \"e074: proj_dist_fn=\\\"unif\\\"\",\ne075, \"e075: custom proj_dist_fn (Laplace)\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#points-around-projection-on-cluster-supporting-line-point_dist_fnn","title":"Points around projection on cluster-supporting line: point_dist_fn=\"n\"","text":"
seed = 840\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\ne076 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=\"n\")\ne077 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=\"n\", proj_dist_fn=\"unif\")\ne078 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=\"n\", proj_dist_fn=proj_laplace)\n
plt = plot_examples_3d(\ne076, \"e076: proj_dist_fn=\\\"norm\\\" (default)\",\ne077, \"e077: proj_dist_fn=\\\"unif\\\"\",\ne078, \"e078: custom proj_dist_fn (Laplace)\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#custom-point-placement-using-the-exponential-distribution","title":"Custom point placement using the exponential distribution","text":"

For this example we require the clupoints_n_1_template() helper function:

from pyclugen import clupoints_n_1_template\n
seed = 840\n
# Custom point_dist_fn: final points placed using the Exponential distribution\ndef clupoints_n_1_exp(projs, lat_std, len, clu_dir, clu_ctr, rng):\ndef dist_exp(npts, lstd, rg):\nreturn lstd * rg.exponential(scale=2 / lstd, size=npts)\nreturn clupoints_n_1_template(projs, lat_std, clu_dir, dist_exp, rng=rng)\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e079 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp)\ne080 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp, proj_dist_fn=\"unif\")\ne081 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp, proj_dist_fn=proj_laplace)\n
plt = plot_examples_3d(\ne079, \"e079: proj_dist_fn=\\\"norm\\\" (default)\",\ne080, \"e080: proj_dist_fn=\\\"unif\\\"\",\ne081, \"e081: custom proj_dist_fn (Laplace)\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n
"},{"location":"generated/gallery/plot_3_3d_examples/#manipulating-cluster-sizes","title":"Manipulating cluster sizes","text":"
seed = 555\n
# Custom clusizes_fn (e083): cluster sizes determined via the uniform distribution,\n# no correction for total points\ndef clusizes_unif(nclu, npts, ae, rng):\nreturn rng.integers(low=1, high=2 * npts / nclu + 1, size=nclu)\n
# Custom clusizes_fn (e084): clusters all have the same size, no correction for total points\ndef clusizes_equal(nclu, npts, ae, rng):\nreturn (npts // nclu) * np.ones(nclu, dtype=int)\n
# Custom clucenters_fn (all): yields fixed positions for the clusters\ndef centers_fixed(nclu, csep, coff, rng):\nreturn np.array([\n[-csep[0], -csep[1], -csep[2]],\n[csep[0], -csep[1], -csep[2]],\n[-csep[0], csep[1], csep[2]],\n[csep[0], csep[1], csep[2]]])\n
e082 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),\nclucenters_fn=centers_fixed, point_dist_fn=\"n\")\ne083 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),\nclucenters_fn=centers_fixed, clusizes_fn=clusizes_unif, point_dist_fn=\"n\")\ne084 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),\nclucenters_fn=centers_fixed, clusizes_fn=clusizes_equal, point_dist_fn=\"n\")\n
plt = plot_examples_3d(\ne082, \"e082: normal dist. (default)\",\ne083, \"e083: unif. dist. (custom)\",\ne084, \"e084: equal size (custom)\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:195: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_xlim(xmins[0], xmaxs[0])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:196: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_ylim(xmins[1], xmaxs[1])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:197: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nax.set_zlim(xmins[2], xmaxs[2])\n

Total running time of the script: ( 0 minutes 5.871 seconds)

Download Python source code: plot_3_3d_examples.py

Download Jupyter notebook: plot_3_3d_examples.ipynb

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/plot_4_nd_examples/","title":"Examples in nD","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_4_nd_examples/#examples-in-nd","title":"Examples in nD","text":"

This section contains several examples on how to generate nD (n > 3) data with pyclugen. To run the examples we first need to import the clugen() function:

from pyclugen import clugen\n

To make the examples exactly reproducible we'll import a random number generator from NumPy and pass it as a parameter to clugen(). We'll also create a small helper function for providing us a brand new seeded generator:

import numpy as np\nfrom numpy.random import PCG64, Generator\ndef rng(seed):\nreturn Generator(PCG64(seed))\n

To plot these examples we use the plot_examples_nd function:

from plot_functions import plot_examples_nd\n
"},{"location":"generated/gallery/plot_4_nd_examples/#5d-example-with-default-optional-arguments","title":"5D example with default optional arguments","text":"
seed = 123\n
# Number of dimensions\nnd = 5\n
e085 = clugen(nd, 6, 1500, [1, 1, 0.5, 0, 0], np.pi / 16, 30 * np.ones(nd), 30, 4, 3, rng=rng(seed))\n
plot_examples_nd(e085, \"e085: 5D with optional parameters set to defaults\")\n

Out:

/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:249: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxycoord = (xmaxs[i] + xmins[i]) / 2\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:255: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\ng.axes[i, j].set_xlim([xmins[j], xmaxs[j]])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:256: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\ng.axes[i, j].set_ylim([xmins[i], xmaxs[i]])\n
"},{"location":"generated/gallery/plot_4_nd_examples/#5d-example-with-proj_dist_fn-unif-and-point_dist_fn-n","title":"5D example with proj_dist_fn = \"unif\" and point_dist_fn = \"n\"","text":"
seed = 579\n
# Number of dimensions\nnd = 5\n
e086 = clugen(nd, 6, 1500, [0.1, 0.3, 0.5, 0.3, 0.1], np.pi / 12, 30 * np.ones(nd), 35, 5, 3.5,\nproj_dist_fn=\"unif\", point_dist_fn=\"n\", rng=rng(seed))\n
plot_examples_nd(e086, \"e086: 5D with proj_dist_fn=\\\"unif\\\" and point_dist_fn=\\\"n\\\"\")\n

Out:

/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:249: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxycoord = (xmaxs[i] + xmins[i]) / 2\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:255: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\ng.axes[i, j].set_xlim([xmins[j], xmaxs[j]])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:256: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\ng.axes[i, j].set_ylim([xmins[i], xmaxs[i]])\n
"},{"location":"generated/gallery/plot_4_nd_examples/#4d-example-with-custom-projection-placement-using-the-beta-distribution","title":"4D example with custom projection placement using the Beta distribution","text":"
seed = 963\n
# Number of dimensions\nnd = 4\n
# Custom proj_dist_fn: point projections placed using the Beta distribution\ndef proj_beta(len, n, rng):\nreturn len * rng.beta(0.1, 0.1, size=n) - len / 2\n
e087 = clugen(nd, 5, 1500, np.ones(nd), np.pi / 6, 30 * np.ones(nd), 60, 15, 6, rng=rng(seed),\nproj_dist_fn=proj_beta)\n
plot_examples_nd(e087, \"e087: 4D with custom proj_dist_fn (Beta)\")\n

Out:

/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:249: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxycoord = (xmaxs[i] + xmins[i]) / 2\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:255: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\ng.axes[i, j].set_xlim([xmins[j], xmaxs[j]])\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:256: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\ng.axes[i, j].set_ylim([xmins[i], xmaxs[i]])\n

Total running time of the script: ( 0 minutes 11.310 seconds)

Download Python source code: plot_4_nd_examples.py

Download Jupyter notebook: plot_4_nd_examples.ipynb

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/plot_5_mrg_examples/","title":"Merging and hierarchical cluster examples","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_5_mrg_examples/#merging-and-hierarchical-cluster-examples","title":"Merging and hierarchical cluster examples","text":"

This section contains several examples on how to merge cluster data, either generated with pyclugen or from other sources. To run the examples we first need to import the clugen() and clugen() functions:

from pyclugen import clugen, clumerge\n

To make the examples exactly reproducible we'll import a random number generator from NumPy and pass it as a parameter to clugen(). We'll also create a small helper function for providing us a brand new seeded generator:

import numpy as np\nfrom numpy.random import PCG64, Generator\ndef rng(seed):\nreturn Generator(PCG64(seed))\n

Although it is possible to merge data in any dimension, these examples will focus on merging 2D data. Therefore, we'll use the same plot_examples_2d function used for the 2D examples:

from plot_functions import plot_examples_2d\n
"},{"location":"generated/gallery/plot_5_mrg_examples/#merging-two-data-sets-generated-with-clugen","title":"Merging two data sets generated with clugen()","text":"
seed1 = 444\nseed2 = 555\n
e088 = clugen(2, 5, 1000, [1, 1], np.pi / 12, [20, 20], 14, 1.2, 1.5, rng=rng(seed1),\nproj_dist_fn=\"unif\", point_dist_fn=\"n\")\ne089 = clugen(2, 3, 1500, [1, 0], 0.05, [20, 20], 0, 0, 4, rng=rng(seed2),\npoint_dist_fn=\"n\", cluster_offset = [20, 0])\ne090 = clumerge(e088, e089)\n
plot_examples_2d(\ne088, \"e088: data set 1\",\ne089, \"e089: data set 2\",\ne090, \"e090: merged data sets\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n

In the previous example, clusters from individual data sets remain as separate clusters in the merged data set. It's also possible to maintain the original cluster labels by setting the clusters_field parameter to None:

e091 = clumerge(e088, e089, clusters_field=None)\n
plot_examples_2d(\ne088, \"e088: data set 1\",\ne089, \"e089: data set 2\",\ne091, \"e091: merged data sets\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_5_mrg_examples/#adding-noise-to-a-clugen-generated-data-set","title":"Adding noise to a clugen()-generated data set","text":"
seed = 333\n
prng = rng(seed)\ne092 = {\"points\": 120 * prng.random((500, 2)) - 60, \"clusters\": np.ones(500, dtype=np.int32)}\ne093 = clumerge(e092, e090) # clumerge(e092, e088, e089) would also work\n
plot_examples_2d(\ne090, \"e090: original merged data sets\",\ne092, \"e092: random uniform noise\",\ne093, \"e093: data sets with noise\",\npmargin=0)\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n
"},{"location":"generated/gallery/plot_5_mrg_examples/#merging-with-data-not-generated-with-clugen","title":"Merging with data not generated with clugen()","text":"

Data generated with clugen() can be merged with other data sets, for example data created with one of scikit-learn's generators:

seed = 321\n
from sklearn.datasets import make_moons\nX, y = make_moons(100, noise=0.05, random_state=seed)\ne094 = {\"points\": X, \"clusters\": y}\ne095 = clugen(2, 4, 200, [1, 1], np.pi / 12, [1, 1], 0.1, 0.01, 0.25, rng=rng(seed),\nproj_dist_fn = \"unif\", point_dist_fn = \"n\")\ne096 = clumerge(e094, e095)\n
plt = plot_examples_2d(\ne094, \"e094: generated w/ make_moons()\",\ne095, \"e095: generated w/ clugen()\",\ne096, \"e096: merged data\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n

We can also hierarchize clusters from different sources:

e097 = {**e094, \"hclusters\": np.ones(100, dtype=np.int32)}\ne098 = {**e095._asdict(), \"hclusters\": 2 * np.ones(200, np.int32)}\ne099 = clumerge(e097, e098, clusters_field=\"hclusters\")\n
plt = plot_examples_2d(\ne097, \"e097: generated w/ make_moons()\",\ne098, \"e098: generated w/ clugen()\",\ne099, \"e099: merged data\",\nclusters_field=\"hclusters\")\n

Out:

/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:136: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nxlim=(xmins[0], xmaxs[0]),\n/home/runner/work/pyclugen/pyclugen/docs/docs/examples/plot_functions.py:137: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\nylim=(xmins[1], xmaxs[1]),\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead\n  if pd.api.types.is_categorical_dtype(vector):\n/home/runner/.local/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight\n  self._figure.tight_layout(*args, **kwargs)\n

Total running time of the script: ( 0 minutes 4.270 seconds)

Download Python source code: plot_5_mrg_examples.py

Download Jupyter notebook: plot_5_mrg_examples.ipynb

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/plot_functions/","title":"Plot functions","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_functions/#plot-functions","title":"Plot functions","text":"

Several auxiliary functions for plotting the examples in this documentation.

"},{"location":"generated/gallery/plot_functions/#import-the-required-libraries","title":"Import the required libraries","text":"
import matplotlib.pyplot as plt  # type: ignore\nimport numpy as np\nimport numpy.typing as npt\nimport pandas as pd\nimport seaborn as sns  # type: ignore\nfrom pyclugen import Clusters\n
"},{"location":"generated/gallery/plot_functions/#clusters2df","title":"clusters2df","text":"
def clusters2df(\n*exs: Clusters | dict[str, npt.ArrayLike], clusters_field: str = \"clusters\"\n) -> pd.DataFrame:\n\"\"\"Convert a sequence of clusters to a Pandas dataframe.\"\"\"\ndfs = []\niex = 1\nfor ex in exs:\nif isinstance(ex, dict):\npoints = ex[\"points\"]\nclusters = ex[clusters_field]\nelse:\npoints = ex.points\nclusters = ex.clusters\ndf = pd.DataFrame(\ndata=points, columns=[f\"x{i}\" for i in range(np.size(points, 1))]\n)\ndf[\"cluster\"] = clusters.tolist()\ndf[\"example\"] = [iex] * clusters.size\ndfs.append(df)\niex += 1\nreturn pd.concat(dfs, ignore_index=True)\n
"},{"location":"generated/gallery/plot_functions/#get_plot_lims","title":"get_plot_lims","text":"
def get_plot_lims(df: pd.DataFrame, pmargin: float = 0.1):\n\"\"\"Determine the plot limits for the cluster data given in `df`.\"\"\"\n# Get maximum and minimum points in each dimension\nxmaxs = df.iloc[:, :-2].max()\nxmins = df.iloc[:, :-2].min()\n# Determine plot centers in each dimension\nxcenters = (xmaxs + xmins) / 2\n# Determine plots span for all dimensions\nsidespan = (1 + pmargin) * np.max(np.abs(xmaxs - xmins)) / 2\n# Determine final plots limits\nxmaxs = xcenters + sidespan\nxmins = xcenters - sidespan\nreturn xmaxs, xmins\n
"},{"location":"generated/gallery/plot_functions/#plot_examples_1d","title":"plot_examples_1d","text":"
def plot_examples_1d(*ets, ncols: int = 3, clusters_field: str = \"clusters\"):\n\"\"\"Plot the 1D examples given in the ets parameter.\"\"\"\n# Get examples\nex = ets[0::2]\n# Get titles\net = ets[1::2]\ndf = clusters2df(*ex, clusters_field=clusters_field)\n# Set seaborn's dark grid style\nsns.set_theme(style=\"darkgrid\")\n# Use seaborn to create the plots\ng = sns.FacetGrid(df, col=\"example\", hue=\"cluster\", col_wrap=ncols)\n# Plot the kernel density estimation plots\ng.map(sns.kdeplot, \"x0\", multiple=\"layer\", fill=True)\n# Get a flattened view of the axes array\ng_axes = g.axes.reshape(-1)\n# Determine the height of the rugs in the rug plot to 5% of total height\nrug_height = g_axes[0].get_ylim()[1] * 0.05\n# Plot the rug markers below the kde plots\ng.map(sns.rugplot, \"x0\", height=rug_height)\n# Set titles\nfor ax, t in zip(g_axes, et):\nax.set_title(t)\n
"},{"location":"generated/gallery/plot_functions/#plot_examples_2d","title":"plot_examples_2d","text":"
def plot_examples_2d(\n*ets, pmargin: float = 0.1, ncols: int = 3, clusters_field: str = \"clusters\"\n):\n\"\"\"Plot the 2D examples given in the ets parameter.\"\"\"\n# Get examples\nex = ets[0::2]\n# Get titles\net = ets[1::2]\ndf = clusters2df(*ex, clusters_field=clusters_field)\n# Get limits in each dimension\nxmaxs, xmins = get_plot_lims(df, pmargin=pmargin)\n# Set seaborn's dark grid style\nsns.set_theme(style=\"darkgrid\")\n# Use seaborn to create the plots\ng = sns.FacetGrid(\ndf,\ncol=\"example\",\nhue=\"cluster\",\nxlim=(xmins[0], xmaxs[0]),\nylim=(xmins[1], xmaxs[1]),\naspect=1,\ncol_wrap=ncols,\n)\ng.map(sns.scatterplot, \"x0\", \"x1\", s=10)\n# Set the plot titles and x, y labels\nfor ax, t in zip(g.axes, et):\nax.set_title(t)\nax.set_xlabel(\"x\")\nax.set_ylabel(\"y\")\n
"},{"location":"generated/gallery/plot_functions/#plot_examples_3d","title":"plot_examples_3d","text":"
def plot_examples_3d(\n*ets,\npmargin: float = 0.1,\nncols: int = 3,\nside=350,\nclusters_field: str = \"clusters\",\n):\n\"\"\"Plot the 3D examples given in the ets parameter.\"\"\"\n# Get examples\nex = ets[0::2]\n# Get titles\net = ets[1::2]\n# Number of plots and number of rows in combined plot\nnum_plots = len(ex)\nnrows = max(1, int(np.ceil(num_plots / ncols)))\nblank_plots = nrows * ncols - num_plots\ndf = clusters2df(*ex, clusters_field=clusters_field)\n# Get limits in each dimension\nxmaxs, xmins = get_plot_lims(df, pmargin=pmargin)\n# Reset to default Matplotlib style, to avoid seaborn interference\nsns.reset_orig()\n# To convert inches to pixels afterwards\npx = 1 / plt.rcParams[\"figure.dpi\"]  # pixel in inches\n# Use Matplotlib to create the plots\n_, axs = plt.subplots(\nnrows,\nncols,\nfigsize=(side * px * ncols, side * px * nrows),\nsubplot_kw=dict(projection=\"3d\"),\n)\naxs = axs.reshape(-1)\nfor ax, e, t in zip(axs, ex, et):\nax.set_title(t, fontsize=10)\nax.set_xlim(xmins[0], xmaxs[0])\nax.set_ylim(xmins[1], xmaxs[1])\nax.set_zlim(xmins[2], xmaxs[2])\nax.set_xlabel(\"$x$\", labelpad=-2)\nax.set_ylabel(\"$y$\", labelpad=-2)\nax.set_zlabel(\"$z$\", labelpad=-2)\nax.tick_params(labelsize=8, pad=-2)\nax.scatter(\ne.points[:, 0],\ne.points[:, 1],\ne.points[:, 2],\nc=e.clusters,\ndepthshade=False,\nedgecolor=\"black\",\nlinewidths=0.2,\n)\n# Remaining plots are left blank\nfor ax in axs[len(ex) : len(ex) + blank_plots]:\nax.set_axis_off()\nax.set_facecolor(color=\"white\")\nax.patch.set_alpha(0)\n
"},{"location":"generated/gallery/plot_functions/#plot_examples_nd","title":"plot_examples_nd","text":"
def plot_examples_nd(\nex: Clusters, t: str, pmargin: float = 0.1, clusters_field: str = \"clusters\"\n):\n\"\"\"Plot the nD example given in the ex parameter.\"\"\"\n# How many dimensions?\nnd = ex.points.shape[1]\ndf = clusters2df(ex, clusters_field=clusters_field)\n# Get limits in each dimension\nxmaxs, xmins = get_plot_lims(df, pmargin=pmargin)\n# Set seaborn's dark grid style\nsns.set_theme(style=\"darkgrid\")\n# Create pairwise plots with nothing on the diagonal\ng = sns.PairGrid(df.iloc[:, :-1], hue=\"cluster\", palette=\"deep\")\ng.map_offdiag(sns.scatterplot, s=10)\ng.figure.suptitle(t, y=1)\n# Decorate plot\nfor i in range(nd):\nfor j in range(nd):\nif i == j:\n# Set the x labels in the diagonal plots\nxycoord = (xmaxs[i] + xmins[i]) / 2\ng.axes[i, i].text(\nxycoord, xycoord, f\"$x{i}$\", fontsize=20, ha=\"center\", va=\"center\"\n)\nelse:\n# Set appropriate plot intervals and aspect ratio\ng.axes[i, j].set_xlim([xmins[j], xmaxs[j]])\ng.axes[i, j].set_ylim([xmins[i], xmaxs[i]])\ng.axes[i, j].set_aspect(1)\n

Total running time of the script: ( 0 minutes 0.006 seconds)

Download Python source code: plot_functions.py

Download Jupyter notebook: plot_functions.ipynb

Gallery generated by mkdocs-gallery

"}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"pyclugen","text":"

pyclugen is Python package for generating multidimensional clusters. Each cluster is supported by a line segment, the position, orientation and length of which guide where the respective points are placed. The clugen() function is provided for this purpose, as well as a number of auxiliary functions, used internally and modularly by clugen(). Users can swap these auxiliary functions by their own customized versions, fine-tuning their cluster generation strategies, or even use them as the basis for their own generation algorithms.

"},{"location":"#installation","title":"Installation","text":"

Install from PyPI:

pip install --upgrade pip\npip install pyclugen\n

Or directly from GitHub:

pip install --upgrade pip\npip install git+https://github.com/clugen/pyclugen.git#egg=pyclugen\n
"},{"location":"#quick-start","title":"Quick start","text":"
from pyclugen import clugen\nimport matplotlib.pyplot as plt\n
out2 = clugen(2, 4, 400, [1, 0], 0.4, [50, 10], 20, 1, 2)\nplt.scatter(out2.points[:, 0], out2.points[:, 1], c=out2.clusters)\nplt.show()\n
out3 = clugen(3, 5, 10000, [0.5, 0.5, 0.5], 0.2, [10, 10, 10], 10, 1, 2)\nfig = plt.figure()\nax = fig.add_subplot(projection=\"3d\")\nax.scatter(out3.points[:, 0], out3.points[:, 1], out3.points[:, 2], c=out3.clusters)\nplt.show()\n
"},{"location":"#further-reading","title":"Further reading","text":"

The clugen algorithm and its several implementations are detailed in the following reference (please cite it if you use this software):

  • Fachada, N. & de Andrade, D. (2023). Generating multidimensional clusters with support lines. Knowledge-Based Systems, 277, 110836. https://doi.org/10.1016/j.knosys.2023.110836 (arXiv preprint)
"},{"location":"#also-in-this-documentation","title":"Also in this documentation","text":"
  • Theory: the clugen algorithm in detail
  • Detailed usage examples
  • Reference
  • Developing this package
"},{"location":"dev/","title":"Development","text":""},{"location":"dev/#installing-for-development-andor-improving-the-package","title":"Installing for development and/or improving the package","text":"
$ git clone https://github.com/clugen/pyclugen.git\n$ cd pyclugen\n$ python -m venv env\n$ source env/bin/activate\n$ pip install -e .[dev]\n$ pre-commit install\n

On Windows replace source env/bin/activate with . env\\Scripts\\activate.

"},{"location":"dev/#run-tests","title":"Run tests","text":"

Tests can be executed with the following command:

$ pytest\n

The previous command runs the tests at normal level by default. This test level can also be specified explicitly:

$ pytest --test-level=normal\n

There are four test levels, from fastest to slowest (i.e., from less thorough to more exhaustive): fast, ci, normal and full. The fast level tests all functions using typical parameters, just to check if everything is working. The ci level performs the minimal amount of testing that yields complete test coverage. Beyond complete coverage, the normal and full levels also test increasing combinations of parameters and PRNG seeds, which may be important to root out rare corner cases. Note that the full level can be extremely slow.

To generate a test coverage report, run pytest as follows:

$ pytest --cov=pyclugen --cov-report=html --test-level=ci\n
"},{"location":"dev/#build-docs","title":"Build docs","text":"

Considering we're in the pyclugen folder, run the following commands:

$ cd docs\n$ mkdocs build\n

The generated documentation will be placed in docs/site. Alternatively, the documentation can be generated and served locally with:

$ mkdocs serve\n
"},{"location":"dev/#code-style","title":"Code style","text":"

Code style is enforced with flake8 (and a number of plugins), black, and isort. Some highlights include, but are not limited to:

  • Encoding: UTF-8
  • Indentation: 4 spaces (no tabs)
  • Line size limit: 88 chars
  • Newlines: Unix style, i.e. LF or \\n
"},{"location":"reference/","title":"Reference","text":"

Various functions for multidimensional cluster generation in Python.

Note that:

  1. clugen() is the main function of the pyclugen package, and possibly the only function most users will need.
  2. Functions which accept rng as the last parameter are stochastic. Thus, in order to obtain the same result on separate invocations of these functions, pass them an an instance of same pseudo-random number Generator initialized with the same seed.
"},{"location":"reference/#pyclugen.Clusters","title":"Clusters","text":"

Bases: NamedTuple

Read-only container for results returned by clugen().

The symbols presented in the instances variable below have the following meanings:

  • \\(n\\) : Number of dimensions.
  • \\(p\\) : Number of points.
  • \\(c\\) : Number of clusters.
Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/main.py
class Clusters(NamedTuple):\nr\"\"\"Read-only container for results returned by [`clugen()`][pyclugen.main.clugen].\n    The symbols presented in the instances variable below have the following\n    meanings:\n    - $n$ : Number of dimensions.\n    - $p$ : Number of points.\n    - $c$ : Number of clusters.\n    \"\"\"\npoints: NDArray\nr\"\"\"$p \\times n$ matrix containing the generated points for all clusters.\"\"\"\nclusters: NDArray\nr\"\"\"Vector of size $p$ indicating the cluster each point in `points`\n    belongs to.\"\"\"\nprojections: NDArray\nr\"\"\"$p \\times n$ matrix with the point projections on the cluster-supporting\n    lines.\"\"\"\nsizes: NDArray\nr\"\"\"Vector of size $c$ with the number of points in each cluster.\"\"\"\ncenters: NDArray\nr\"\"\"$c \\times n$ matrix with the coordinates of the cluster centers.\"\"\"\ndirections: NDArray\nr\"\"\"$c \\times n$ matrix with the direction of each cluster-supporting line.\"\"\"\nangles: NDArray\nr\"\"\"Vector of size $c$ with the angles between the cluster-supporting lines and\n    the main direction.\"\"\"\nlengths: NDArray\nr\"\"\"Vector of size $c$ with the lengths of the cluster-supporting lines.\"\"\"\n
"},{"location":"reference/#pyclugen.Clusters.angles","title":"angles instance-attribute","text":"
angles: NDArray\n

Vector of size \\(c\\) with the angles between the cluster-supporting lines and the main direction.

"},{"location":"reference/#pyclugen.Clusters.centers","title":"centers instance-attribute","text":"
centers: NDArray\n

\\(c \\times n\\) matrix with the coordinates of the cluster centers.

"},{"location":"reference/#pyclugen.Clusters.clusters","title":"clusters instance-attribute","text":"
clusters: NDArray\n

Vector of size \\(p\\) indicating the cluster each point in points belongs to.

"},{"location":"reference/#pyclugen.Clusters.directions","title":"directions instance-attribute","text":"
directions: NDArray\n

\\(c \\times n\\) matrix with the direction of each cluster-supporting line.

"},{"location":"reference/#pyclugen.Clusters.lengths","title":"lengths instance-attribute","text":"
lengths: NDArray\n

Vector of size \\(c\\) with the lengths of the cluster-supporting lines.

"},{"location":"reference/#pyclugen.Clusters.points","title":"points instance-attribute","text":"
points: NDArray\n

\\(p \\times n\\) matrix containing the generated points for all clusters.

"},{"location":"reference/#pyclugen.Clusters.projections","title":"projections instance-attribute","text":"
projections: NDArray\n

\\(p \\times n\\) matrix with the point projections on the cluster-supporting lines.

"},{"location":"reference/#pyclugen.Clusters.sizes","title":"sizes instance-attribute","text":"
sizes: NDArray\n

Vector of size \\(c\\) with the number of points in each cluster.

"},{"location":"reference/#pyclugen.angle_btw","title":"angle_btw","text":"
angle_btw(v1: NDArray, v2: NDArray) -> float\n

Angle between two \\(n\\)-dimensional vectors.

Typically, the angle between two vectors v1 and v2 can be obtained with:

arccos(dot(u, v) / (norm(u) * norm(v)))\n

However, this approach is numerically unstable. The version provided here is numerically stable and based on the AngleBetweenVectors Julia package by Jeffrey Sarnoff (MIT license), implementing an algorithm provided by Prof. W. Kahan in these notes (see page 15).

Examples:

>>> from numpy import array, degrees\n>>> from pyclugen import angle_btw\n>>> v1 = array([1.0, 1.0, 1.0, 1.0])\n>>> v2 = array([1.0, 0.0, 0.0, 0.0])\n>>> degrees(angle_btw(v1, v2))\n60.00000000000001\n

Parameters:

Name Type Description Default v1 NDArray

First vector.

required v2 NDArray

Second vector.

required

Returns:

Type Description float

Angle between v1 and v2 in radians.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/helper.py
def angle_btw(v1: NDArray, v2: NDArray) -> float:\nr\"\"\"Angle between two $n$-dimensional vectors.\n    Typically, the angle between two vectors `v1` and `v2` can be obtained with:\n    ```python\n    arccos(dot(u, v) / (norm(u) * norm(v)))\n    ```\n    However, this approach is numerically unstable. The version provided here is\n    numerically stable and based on the\n    [AngleBetweenVectors](https://github.com/JeffreySarnoff/AngleBetweenVectors.jl)\n    Julia package by Jeffrey Sarnoff (MIT license), implementing an algorithm\n    provided by Prof. W. Kahan in\n    [these notes](https://people.eecs.berkeley.edu/~wkahan/MathH110/Cross.pdf)\n    (see page 15).\n    Examples:\n        >>> from numpy import array, degrees\n        >>> from pyclugen import angle_btw\n        >>> v1 = array([1.0, 1.0, 1.0, 1.0])\n        >>> v2 = array([1.0, 0.0, 0.0, 0.0])\n        >>> degrees(angle_btw(v1, v2))\n        60.00000000000001\n    Args:\n      v1: First vector.\n      v2: Second vector.\n    Returns:\n      Angle between `v1` and `v2` in radians.\n    \"\"\"\nu1 = v1 / norm(v1)\nu2 = v2 / norm(v2)\ny = u1 - u2\nx = u1 + u2\nreturn 2 * arctan(norm(y) / norm(x))\n
"},{"location":"reference/#pyclugen.angle_deltas","title":"angle_deltas","text":"
angle_deltas(\nnum_clusters: int, angle_disp: float, rng: Generator = _default_rng\n) -> NDArray\n

Get angles between average cluster direction and cluster-supporting lines.

Determine the angles between the average cluster direction and the cluster-supporting lines. These angles are obtained from a wrapped normal distribution ( \\(\\mu=0\\), \\(\\sigma=\\)angle_disp) with support in the interval \\(\\left[-\\pi/2,\\pi/2\\right]\\). Note this is different from the standard wrapped normal distribution, the support of which is given by the interval \\(\\left[-\\pi,\\pi\\right]\\).

Examples:

>>> from pyclugen import angle_deltas\n>>> from numpy import degrees, pi\n>>> from numpy.random import Generator, PCG64\n>>> prng = Generator(PCG64(123))\n>>> a_rad = angle_deltas(4, pi/8, rng=prng) # Angle dispersion of 22.5 degrees\n>>> a_rad\narray([-0.38842705, -0.14442948,  0.50576707,  0.07617358])\n>>> degrees(a_rad) # Show angle deltas in degrees\narray([-22.25523038,  -8.27519966,  28.97831838,   4.36442443])\n

Parameters:

Name Type Description Default num_clusters int

Number of clusters.

required angle_disp float

Angle dispersion, in radians.

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Angles between the average cluster direction and the cluster-supporting lines, given in radians in the interval \\(\\left[-\\pi/2,\\pi/2\\right]\\).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def angle_deltas(\nnum_clusters: int, angle_disp: float, rng: Generator = _default_rng\n) -> NDArray:\nr\"\"\"Get angles between average cluster direction and cluster-supporting lines.\n    Determine the angles between the average cluster direction and the\n    cluster-supporting lines. These angles are obtained from a wrapped normal\n    distribution ( $\\mu=0$, $\\sigma=$`angle_disp`) with support in the interval\n    $\\left[-\\pi/2,\\pi/2\\right]$. Note this is different from the standard\n    wrapped normal distribution, the support of which is given by the interval\n    $\\left[-\\pi,\\pi\\right]$.\n    Examples:\n        >>> from pyclugen import angle_deltas\n        >>> from numpy import degrees, pi\n        >>> from numpy.random import Generator, PCG64\n        >>> prng = Generator(PCG64(123))\n        >>> a_rad = angle_deltas(4, pi/8, rng=prng) # Angle dispersion of 22.5 degrees\n        >>> a_rad\n        array([-0.38842705, -0.14442948,  0.50576707,  0.07617358])\n        >>> degrees(a_rad) # Show angle deltas in degrees\n        array([-22.25523038,  -8.27519966,  28.97831838,   4.36442443])\n    Args:\n      num_clusters: Number of clusters.\n      angle_disp: Angle dispersion, in radians.\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Angles between the average cluster direction and the cluster-supporting\n        lines, given in radians in the interval $\\left[-\\pi/2,\\pi/2\\right]$.\n    \"\"\"\n# Get random angle differences using the normal distribution\nangles = angle_disp * rng.normal(size=num_clusters)\n# Reduce angle differences to the interval [-\u03c0, \u03c0]\nangles = arctan2(sin(angles), cos(angles))\n# Make sure angle differences are within interval [-\u03c0/2, \u03c0/2]\nreturn where(abs(angles) > pi / 2, angles - sign(angles) * pi / 2, angles)\n
"},{"location":"reference/#pyclugen.clucenters","title":"clucenters","text":"
clucenters(\nnum_clusters: int,\nclu_sep: NDArray,\nclu_offset: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray\n

Determine cluster centers using the uniform distribution.

The number of clusters (num_clusters) and the average cluster separation (clu_sep) are taken into account.

More specifically, let \\(c=\\)num_clusters, \\(\\mathbf{s}=\\)clu_sep.reshape(-1,1), \\(\\mathbf{o}=\\)clu_offset.reshape(-1,1), \\(n=\\)clu_sep.size (i.e., number of dimensions). Cluster centers are obtained according to the following equation:

\\[ \\mathbf{C}=c\\mathbf{U} \\cdot \\operatorname{diag}(\\mathbf{s}) + \\mathbf{1}\\,\\mathbf{o}^T \\]

where \\(\\mathbf{C}\\) is the \\(c \\times n\\) matrix of cluster centers, \\(\\mathbf{U}\\) is an \\(c \\times n\\) matrix of random values drawn from the uniform distribution between -0.5 and 0.5, and \\(\\mathbf{1}\\) is an \\(c \\times 1\\) vector with all entries equal to 1.

Examples:

>>> from pyclugen import clucenters\n>>> from numpy import array\n>>> from numpy.random import Generator, PCG64\n>>> prng = Generator(PCG64(123))\n>>> clucenters(3, array([30,10]), array([-50,50]), rng=prng)\narray([[-33.58833231,  36.61463056],\n       [-75.16761145,  40.53115432],\n       [-79.1684689 ,  59.3628352 ]])\n

Parameters:

Name Type Description Default num_clusters int

Number of clusters.

required clu_sep NDArray

Average cluster separation ( \\(n \\times 1\\) vector).

required clu_offset NDArray

Cluster offsets ( \\(n \\times 1\\) vector).

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

A \\(c \\times n\\) matrix containing the cluster centers.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def clucenters(\nnum_clusters: int,\nclu_sep: NDArray,\nclu_offset: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Determine cluster centers using the uniform distribution.\n    The number of clusters (`num_clusters`) and the average cluster separation\n    (`clu_sep`) are taken into account.\n    More specifically, let $c=$`num_clusters`, $\\mathbf{s}=$`clu_sep.reshape(-1,1)`,\n    $\\mathbf{o}=$`clu_offset.reshape(-1,1)`, $n=$`clu_sep.size` (i.e., number of\n    dimensions). Cluster centers are obtained according to the following equation:\n    $$\n    \\mathbf{C}=c\\mathbf{U} \\cdot \\operatorname{diag}(\\mathbf{s}) +\n        \\mathbf{1}\\,\\mathbf{o}^T\n    $$\n    where $\\mathbf{C}$ is the $c \\times n$ matrix of cluster centers,\n    $\\mathbf{U}$ is an $c \\times n$ matrix of random values drawn from the\n    uniform distribution between -0.5 and 0.5, and $\\mathbf{1}$ is an $c \\times\n    1$ vector with all entries equal to 1.\n    Examples:\n        >>> from pyclugen import clucenters\n        >>> from numpy import array\n        >>> from numpy.random import Generator, PCG64\n        >>> prng = Generator(PCG64(123))\n        >>> clucenters(3, array([30,10]), array([-50,50]), rng=prng)\n        array([[-33.58833231,  36.61463056],\n               [-75.16761145,  40.53115432],\n               [-79.1684689 ,  59.3628352 ]])\n    Args:\n      num_clusters: Number of clusters.\n      clu_sep: Average cluster separation ( $n \\times 1$ vector).\n      clu_offset: Cluster offsets ( $n \\times 1$ vector).\n      rng: Optional pseudo-random number generator.\n    Returns:\n        A $c \\times n$ matrix containing the cluster centers.\n    \"\"\"\n# Obtain a num_clusters x num_dims matrix of uniformly distributed values\n# between -0.5 and 0.5 representing the relative cluster centers\nctr_rel = rng.random((num_clusters, clu_sep.size)) - 0.5\nreturn num_clusters * (ctr_rel @ diag(clu_sep)) + clu_offset\n
"},{"location":"reference/#pyclugen.clugen","title":"clugen","text":"
clugen(\nnum_dims: int,\nnum_clusters: int,\nnum_points: int,\ndirection: ArrayLike,\nangle_disp: float,\ncluster_sep: ArrayLike,\nllength: float,\nllength_disp: float,\nlateral_disp: float,\nallow_empty: bool = False,\ncluster_offset: Optional[ArrayLike] = None,\nproj_dist_fn: str | Callable[[float, int, Generator], NDArray] = \"norm\",\npoint_dist_fn: str\n| Callable[\n[NDArray, float, float, NDArray, NDArray, Generator], NDArray\n] = \"n-1\",\nclusizes_fn: Callable[[int, int, bool, Generator], NDArray]\n| ArrayLike = clusizes,\nclucenters_fn: Callable[[int, NDArray, NDArray, Generator], NDArray]\n| ArrayLike = clucenters,\nllengths_fn: Callable[[int, float, float, Generator], NDArray]\n| ArrayLike = llengths,\nangle_deltas_fn: Callable[[int, float, Generator], NDArray]\n| ArrayLike = angle_deltas,\nrng: Generator = _default_rng,\n) -> Clusters\n

Generate multidimensional clusters.

Tip

This is the main function of the pyclugen package, and possibly the only function most users will need.

"},{"location":"reference/#pyclugen.clugen--examples","title":"Examples:","text":"
>>> import pyclugen as cg\n>>> import matplotlib.pyplot as plt\n>>> from numpy import pi\n>>> from numpy.random import Generator, PCG64\n>>> rng = Generator(PCG64(321))\n>>> out = cg.clugen(2, 5, 10000, [1, 0.5], pi/16, [10, 40], 10, 1, 2, rng=rng)\n>>> out.centers # What are the cluster centers?\narray([[ 20.02876212,  36.59611434],\n       [-15.60290734, -26.52169579],\n       [ 23.09775166,  91.66309916],\n       [ -5.76816015,  54.9775074 ],\n       [ -4.64224681,  78.40990876]])\n>>> plt.scatter(out.points[:,0],\n...             out.points[:,1],\n...             c=out.clusters) # doctest: +SKIP\n>>> plt.show() # doctest: +SKIP\n

Note

In the descriptions below, the terms \"average\" and \"dispersion\" refer to measures of central tendency and statistical dispersion, respectively. Their exact meaning depends on several optional arguments.

Parameters:

Name Type Description Default num_dims int

Number of dimensions.

required num_clusters int

Number of clusters to generate.

required num_points int

Total number of points to generate.

required direction ArrayLike

Average direction of the cluster-supporting lines. Can be a vector of length num_dims (same direction for all clusters) or a matrix of size num_clusters x num_dims (one direction per cluster).

required angle_disp float

Angle dispersion of cluster-supporting lines (radians).

required cluster_sep ArrayLike

Average cluster separation in each dimension (vector of size num_dims).

required llength float

Average length of cluster-supporting lines.

required llength_disp float

Length dispersion of cluster-supporting lines.

required lateral_disp float

Cluster lateral dispersion, i.e., dispersion of points from their projection on the cluster-supporting line.

required allow_empty bool

Allow empty clusters? False by default.

False cluster_offset Optional[ArrayLike]

Offset to add to all cluster centers (vector of size num_dims). By default the offset will be equal to numpy.zeros(num_dims).

None proj_dist_fn str | Callable[[float, int, Generator], NDArray]

Distribution of point projections along cluster-supporting lines, with three possible values:

  • \"norm\" (default): Distribute point projections along lines using a normal distribution (\u03bc=line center, \u03c3=llength/6).
  • \"unif\": Distribute points uniformly along the line.
  • User-defined function, which accepts two parameters, line length (float), number of points (int) and an instance of Generator, and returns an array containing the distance of each point projection to the center of the line. For example, the \"norm\" option roughly corresponds to lambda l, n, rg: l * rg.random((n, 1)) / 6.
'norm' point_dist_fn str | Callable[[NDArray, float, float, NDArray, NDArray, Generator], NDArray]

Controls how the final points are created from their projections on the cluster-supporting lines, with three possible values:

  • \"n-1\" (default): Final points are placed on a hyperplane orthogonal to the cluster-supporting line, centered at each point's projection, using the normal distribution (\u03bc=0, \u03c3=lateral_disp). This is done by the clupoints_n_1() function.
  • \"n\": Final points are placed around their projection on the cluster-supporting line using the normal distribution (\u03bc=0, \u03c3=lateral_disp). This is done by the clupoints_n() function.
  • User-defined function: The user can specify a custom point placement strategy by passing a function with the same signature as clupoints_n_1() and clupoints_n().
'n-1' clusizes_fn Callable[[int, int, bool, Generator], NDArray] | ArrayLike

Distribution of cluster sizes. By default, cluster sizes are determined by the clusizes() function, which uses the normal distribution (\u03bc=num_points/num_clusters, \u03c3=\u03bc/3), and assures that the final cluster sizes add up to num_points. This parameter allows the user to specify a custom function for this purpose, which must follow clusizes() signature. Note that custom functions are not required to strictly obey the num_points parameter. Alternatively, the user can specify an array of cluster sizes directly.

clusizes clucenters_fn Callable[[int, NDArray, NDArray, Generator], NDArray] | ArrayLike

Distribution of cluster centers. By default, cluster centers are determined by the clucenters() function, which uses the uniform distribution, and takes into account the num_clusters and cluster_sep parameters for generating well-distributed cluster centers. This parameter allows the user to specify a custom function for this purpose, which must follow clucenters() signature. Alternatively, the user can specify a matrix of size num_clusters x num_dims with the exact cluster centers.

clucenters llengths_fn Callable[[int, float, float, Generator], NDArray] | ArrayLike

Distribution of line lengths. By default, the lengths of cluster-supporting lines are determined by the llengths() function, which uses the folded normal distribution (\u03bc=llength, \u03c3=llength_disp). This parameter allows the user to specify a custom function for this purpose, which must follow llengths() signature. Alternatively, the user can specify an array of line lengths directly.

llengths angle_deltas_fn Callable[[int, float, Generator], NDArray] | ArrayLike

Distribution of line angle differences with respect to direction. By default, the angles between direction and the direction of cluster-supporting lines are determined by the angle_deltas() function, which uses the wrapped normal distribution (\u03bc=0, \u03c3=angle_disp) with support in the interval [-\u03c0/2, \u03c0/2]. This parameter allows the user to specify a custom function for this purpose, which must follow angle_deltas() signature. Alternatively, the user can specify an array of angle deltas directly.

angle_deltas rng Generator

An optional instance of Generator for reproducible executions.

_default_rng

Returns:

Type Description Clusters

The generated clusters and associated information in the form of a Clusters object.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/main.py
def clugen(\nnum_dims: int,\nnum_clusters: int,\nnum_points: int,\ndirection: ArrayLike,\nangle_disp: float,\ncluster_sep: ArrayLike,\nllength: float,\nllength_disp: float,\nlateral_disp: float,\nallow_empty: bool = False,\ncluster_offset: Optional[ArrayLike] = None,\nproj_dist_fn: str | Callable[[float, int, Generator], NDArray] = \"norm\",\npoint_dist_fn: str\n| Callable[[NDArray, float, float, NDArray, NDArray, Generator], NDArray] = \"n-1\",\nclusizes_fn: Callable[[int, int, bool, Generator], NDArray] | ArrayLike = clusizes,\nclucenters_fn: Callable[[int, NDArray, NDArray, Generator], NDArray]\n| ArrayLike = clucenters,\nllengths_fn: Callable[[int, float, float, Generator], NDArray]\n| ArrayLike = llengths,\nangle_deltas_fn: Callable[[int, float, Generator], NDArray]\n| ArrayLike = angle_deltas,\nrng: Generator = _default_rng,\n) -> Clusters:\n\"\"\"Generate multidimensional clusters.\n    !!! tip\n        This is the main function of the **pyclugen** package, and possibly the\n        only function most users will need.\n    ## Examples:\n        >>> import pyclugen as cg\n        >>> import matplotlib.pyplot as plt\n        >>> from numpy import pi\n        >>> from numpy.random import Generator, PCG64\n        >>> rng = Generator(PCG64(321))\n        >>> out = cg.clugen(2, 5, 10000, [1, 0.5], pi/16, [10, 40], 10, 1, 2, rng=rng)\n        >>> out.centers # What are the cluster centers?\n        array([[ 20.02876212,  36.59611434],\n               [-15.60290734, -26.52169579],\n               [ 23.09775166,  91.66309916],\n               [ -5.76816015,  54.9775074 ],\n               [ -4.64224681,  78.40990876]])\n        >>> plt.scatter(out.points[:,0],\n        ...             out.points[:,1],\n        ...             c=out.clusters) # doctest: +SKIP\n        >>> plt.show() # doctest: +SKIP\n    ![clugen](https://user-images.githubusercontent.com/3018963/151056890-c83c9509-b40d-4ab2-a842-f2a4706344c6.png)\n    !!! Note\n        In the descriptions below, the terms \"average\" and \"dispersion\" refer to\n        measures of central tendency and statistical dispersion, respectively.\n        Their exact meaning depends on several optional arguments.\n    Args:\n      num_dims: Number of dimensions.\n      num_clusters: Number of clusters to generate.\n      num_points: Total number of points to generate.\n      direction: Average direction of the cluster-supporting lines. Can be a\n        vector of length `num_dims` (same direction for all clusters) or a\n        matrix of size `num_clusters` x `num_dims` (one direction per cluster).\n      angle_disp: Angle dispersion of cluster-supporting lines (radians).\n      cluster_sep: Average cluster separation in each dimension (vector of size\n        `num_dims`).\n      llength: Average length of cluster-supporting lines.\n      llength_disp: Length dispersion of cluster-supporting lines.\n      lateral_disp: Cluster lateral dispersion, i.e., dispersion of points from their\n        projection on the cluster-supporting line.\n      allow_empty: Allow empty clusters? `False` by default.\n      cluster_offset: Offset to add to all cluster centers (vector of size `num_dims`).\n        By default the offset will be equal to `numpy.zeros(num_dims)`.\n      proj_dist_fn: Distribution of point projections along cluster-supporting lines,\n        with three possible values:\n        - `\"norm\"` (default): Distribute point projections along lines using a normal\n          distribution (\u03bc=_line center_, \u03c3=`llength/6`).\n        - `\"unif\"`: Distribute points uniformly along the line.\n        - User-defined function, which accepts two parameters, line length (`float`),\n          number of points (`int`) and an instance of\n          [`Generator`](https://numpy.org/doc/stable/reference/random/generator.html?highlight=generator#numpy.random.Generator),\n          and returns an array containing the distance of each point projection to\n          the center of the line. For example, the `\"norm\"` option roughly corresponds\n          to `lambda l, n, rg: l * rg.random((n, 1)) / 6`.\n      point_dist_fn: Controls how the final points are created from their projections\n        on the cluster-supporting lines, with three possible values:\n        - `\"n-1\"` (default): Final points are placed on a hyperplane orthogonal to\n          the cluster-supporting line, centered at each point's projection, using the\n          normal distribution (\u03bc=0, \u03c3=`lateral_disp`). This is done by the\n          [`clupoints_n_1()`][pyclugen.module.clupoints_n_1] function.\n        - `\"n\"`: Final points are placed around their projection on the\n          cluster-supporting line using the normal distribution (\u03bc=0,\n          \u03c3=`lateral_disp`). This is done by the\n          [`clupoints_n()`][pyclugen.module.clupoints_n] function.\n        - User-defined function: The user can specify a custom point placement\n          strategy by passing a function with the same signature as\n          [`clupoints_n_1()`][pyclugen.module.clupoints_n_1] and\n          [`clupoints_n()`][pyclugen.module.clupoints_n].\n      clusizes_fn: Distribution of cluster sizes. By default, cluster sizes are\n        determined by the [`clusizes()`][pyclugen.module.clusizes] function, which\n        uses the normal distribution (\u03bc=`num_points`/`num_clusters`, \u03c3=\u03bc/3), and\n        assures that the final cluster sizes add up to `num_points`. This parameter\n        allows the user to specify a custom function for this purpose, which must\n        follow [`clusizes()`][pyclugen.module.clusizes] signature. Note that custom\n        functions are not required to strictly obey the `num_points` parameter.\n        Alternatively, the user can specify an array of cluster sizes directly.\n      clucenters_fn: Distribution of cluster centers. By default, cluster centers\n        are determined by the [`clucenters()`][pyclugen.module.clucenters] function,\n        which uses the uniform distribution, and takes into account the `num_clusters`\n        and `cluster_sep` parameters for generating well-distributed cluster centers.\n        This parameter allows the user to specify a custom function for this purpose,\n        which must follow [`clucenters()`][pyclugen.module.clucenters] signature.\n        Alternatively, the user can specify a matrix of size `num_clusters` x\n        `num_dims` with the exact cluster centers.\n      llengths_fn: Distribution of line lengths. By default, the lengths of\n        cluster-supporting lines are determined by the\n        [`llengths()`][pyclugen.module.llengths] function, which uses the folded\n        normal distribution (\u03bc=`llength`, \u03c3=`llength_disp`). This parameter allows\n        the user to specify a custom function for this purpose, which must follow\n        [`llengths()`][pyclugen.module.llengths] signature. Alternatively, the user\n        can specify an array of line lengths directly.\n      angle_deltas_fn: Distribution of line angle differences with respect to\n        `direction`. By default, the angles between `direction` and the direction of\n        cluster-supporting lines are determined by the\n        [`angle_deltas()`][pyclugen.module.angle_deltas] function, which uses the\n        wrapped normal distribution (\u03bc=0, \u03c3=`angle_disp`) with support in the interval\n        [-\u03c0/2, \u03c0/2]. This parameter allows the user to specify a custom function for\n        this purpose, which must follow [`angle_deltas()`][pyclugen.module.angle_deltas]\n        signature. Alternatively, the user can specify an array of angle deltas\n        directly.\n      rng: An optional instance of [`Generator`][numpy.random.Generator] for\n        reproducible executions.\n    Returns:\n      The generated clusters and associated information in the form of a\n        [`Clusters`][pyclugen.main.Clusters] object.\n    \"\"\"\n# ############### #\n# Validate inputs #\n# ############### #\n# Check that number of dimensions is > 0\nif num_dims < 1:\nraise ValueError(\"Number of dimensions, `num_dims`, must be > 0\")\n# Check that number of clusters is > 0\nif num_clusters < 1:\nraise ValueError(\"Number of clusters, `num_clust`, must be > 0\")\n# Convert given direction into a NumPy array\narrdir: NDArray = asarray(direction)\n# Get number of dimensions in `direction` array\ndir_ndims = arrdir.ndim\n# Is direction a vector or a matrix?\nif dir_ndims == 1:\n# It's a vector, let's convert it into a row matrix, since this will be\n# useful down the road\narrdir = arrdir.reshape((1, -1))\nelif dir_ndims == 2:\n# If a matrix was given (i.e. a main direction is given for each cluster),\n# check if the number of directions is the same as the number of clusters\ndir_size_1 = arrdir.shape[0]\nif dir_size_1 != num_clusters:\nraise ValueError(\n\"Number of rows in `direction` must be the same as the \"\n+ f\"number of clusters ({dir_size_1} != {num_clusters})\"\n)\nelse:\n# The `directions` array must be a vector or a matrix, so if we get here\n# it means we have invalid arguments\nraise ValueError(\n\"`direction` must be a vector (1D array) or a matrix (2D array), \"\n+ f\"but is {dir_ndims}D\"\n)\n# Check that direction has num_dims dimensions\ndir_size_2 = arrdir.shape[1]\nif dir_size_2 != num_dims:\nraise ValueError(\n\"Length of directions in `direction` must be equal to \"\n+ f\"`num_dims` ({dir_size_2} != {num_dims})\"\n)\n# Check that directions have magnitude > 0\ndir_magnitudes = apply_along_axis(norm, 1, arrdir)\nif any(isclose(dir_magnitudes, 0)):\nraise ValueError(\"Directions in `direction` must have magnitude > 0\")\n# If allow_empty is false, make sure there are enough points to distribute\n# by the clusters\nif (not allow_empty) and num_points < num_clusters:\nraise ValueError(\nf\"A total of {num_points} points is not enough for \"\n+ f\"{num_clusters} non-empty clusters\"\n)\n# Check that cluster_sep has num_dims dimensions\ncluster_sep = asarray(cluster_sep)\nif cluster_sep.size != num_dims:\nraise ValueError(\n\"Length of `cluster_sep` must be equal to `num_dims` \"\n+ f\"({cluster_sep.size} != {num_dims})\"\n)\n# If given, cluster_offset must have the correct number of dimensions,\n# if not given then it will be a num_dims x 1 vector of zeros\nif cluster_offset is None:\ncluster_offset = zeros(num_dims)\nelse:\ncluster_offset = asarray(cluster_offset)\nif cluster_offset.size != num_dims:\nraise ValueError(\n\"Length of `cluster_offset` must be equal to `num_dims` \"\n+ f\"({cluster_offset.size} != {num_dims})\"\n)\n# Check that proj_dist_fn specifies a valid way for projecting points along\n# cluster-supporting lines i.e., either \"norm\" (default), \"unif\" or a\n# user-defined function\npointproj_fn: Callable[[float, int, Generator], NDArray]\nif callable(proj_dist_fn):\n# Use user-defined distribution; assume function accepts length of line\n# and number of points, and returns a number of points x 1 vector\npointproj_fn = proj_dist_fn\nelif proj_dist_fn == \"unif\":\n# Point projections will be uniformly placed along cluster-supporting lines\ndef pointproj_fn(length, n, rg):\nreturn length * rg.random(n) - length / 2\nelif proj_dist_fn == \"norm\":\n# Use normal distribution for placing point projections along cluster-supporting\n# lines, mean equal to line center, standard deviation equal to 1/6 of line\n# length such that the line length contains \u224899.73% of the points\ndef pointproj_fn(length, n, rg):\nreturn (1.0 / 6.0) * length * rg.normal(size=n)\nelse:\nraise ValueError(\n\"`proj_dist_fn` has to be either 'norm', 'unif' or user-defined function\"\n)\n# Check that point_dist_fn specifies a valid way for generating points given\n# their projections along cluster-supporting lines, i.e., either \"n-1\"\n# (default), \"n\" or a user-defined function\npt_from_proj_fn: Callable[\n[NDArray, float, float, NDArray, NDArray, Generator], NDArray\n]\nif num_dims == 1:\n# If 1D was specified, point projections are the points themselves\ndef pt_from_proj_fn(projs, lat_disp, length, clu_dir, clu_ctr, rng=rng):\nreturn projs\nelif callable(point_dist_fn):\n# Use user-defined distribution; assume function accepts point projections\n# on the line, lateral disp., cluster direction and cluster center, and\n# returns a num_points x num_dims matrix containing the final points\n# for the current cluster\npt_from_proj_fn = point_dist_fn\nelif point_dist_fn == \"n-1\":\n# Points will be placed on a hyperplane orthogonal to the cluster-supporting\n# line using a normal distribution centered at their intersection\npt_from_proj_fn = clupoints_n_1\nelif point_dist_fn == \"n\":\n# Points will be placed using a multivariate normal distribution\n# centered at the point projection\npt_from_proj_fn = clupoints_n\nelse:\nraise ValueError(\n\"point_dist_fn has to be either 'n-1', 'n' or a user-defined function\"\n)\n# ############################ #\n# Determine cluster properties #\n# ############################ #\n# Normalize main direction(s)\narrdir = apply_along_axis(lambda a: a / norm(a), 1, arrdir)\n# If only one main direction was given, expand it for all clusters\nif dir_ndims == 1:\narrdir = repeat(arrdir, num_clusters, axis=0)\n# Determine cluster sizes\nif callable(clusizes_fn):\ncluster_sizes = clusizes_fn(num_clusters, num_points, allow_empty, rng)\nelif len(asarray(clusizes_fn)) == num_clusters:\ncluster_sizes = asarray(clusizes_fn)\nelse:\nraise ValueError(\n\"clusizes_fn has to be either a function or a `num_clusters`-sized array\"\n)\n# Custom clusizes_fn's are not required to obey num_points, so we update\n# it here just in case it's different from what the user specified\nnum_points = sum(cluster_sizes)\n# Determine cluster centers\nif callable(clucenters_fn):\ncluster_centers = clucenters_fn(num_clusters, cluster_sep, cluster_offset, rng)\nelif asarray(clucenters_fn).shape == (num_clusters, num_dims):\ncluster_centers = asarray(clucenters_fn)\nelse:\nraise ValueError(\n\"clucenters_fn has to be either a function or a matrix of size \"\n+ \"`num_clusters` x `num_dims`\"\n)\n# Determine length of lines supporting clusters\nif callable(llengths_fn):\ncluster_lengths = llengths_fn(num_clusters, llength, llength_disp, rng)\nelif len(asarray(llengths_fn)) == num_clusters:\ncluster_lengths = asarray(llengths_fn)\nelse:\nraise ValueError(\n\"llengths_fn has to be either a function or a `num_clusters`-sized array\"\n)\n# Obtain angles between main direction and cluster-supporting lines\nif callable(angle_deltas_fn):\ncluster_angles = angle_deltas_fn(num_clusters, angle_disp, rng)\nelif len(asarray(angle_deltas_fn)) == num_clusters:\ncluster_angles = asarray(angle_deltas_fn)\nelse:\nraise ValueError(\n\"angle_deltas_fn has to be either a function or a \"\n+ \"`num_clusters`-sized array\"\n)\n# Determine normalized cluster directions by applying the obtained angles\ncluster_directions = apply_along_axis(\nlambda v, a: rand_vector_at_angle(v, next(a), rng),\n1,\narrdir,\niter(cluster_angles),\n)\n# ################################# #\n# Determine points for each cluster #\n# ################################# #\n# Aux. vector with cumulative sum of number of points in each cluster\ncumsum_points = concatenate((asarray([0]), cumsum(cluster_sizes)))\n# Pre-allocate data structures for holding cluster info and points\npoint_clusters: NDArray = empty(\nnum_points, dtype=int32\n)  # Cluster indices of each point\npoint_projections = empty((num_points, num_dims))  # Point projections on\n#                                                  # cluster-supporting lines\npoints = empty((num_points, num_dims))  # Final points to be generated\n# Loop through clusters and create points for each one\nfor i in range(num_clusters):\n# Start and end indexes for points in current cluster\nidx_start = cumsum_points[i]\nidx_end = cumsum_points[i + 1]\n# Update cluster indices of each point\npoint_clusters[idx_start:idx_end] = i\n# Determine distance of point projections from the center of the line\nptproj_dist_fn_center = pointproj_fn(cluster_lengths[i], cluster_sizes[i], rng)\n# Determine coordinates of point projections on the line using the\n# parametric line equation (this works since cluster direction is normalized)\npoint_projections[idx_start:idx_end, :] = points_on_line(\ncluster_centers[i, :], cluster_directions[i, :], ptproj_dist_fn_center\n)\n# Determine points from their projections on the line\npoints[idx_start:idx_end, :] = pt_from_proj_fn(\npoint_projections[idx_start:idx_end, :],\nlateral_disp,\ncluster_lengths[i],\ncluster_directions[i, :],\ncluster_centers[i, :],\nrng,\n)\nreturn Clusters(\npoints,\npoint_clusters,\npoint_projections,\ncluster_sizes,\ncluster_centers,\ncluster_directions,\ncluster_angles,\ncluster_lengths,\n)\n
"},{"location":"reference/#pyclugen.clumerge","title":"clumerge","text":"
clumerge(\n*data: NamedTuple | Mapping[str, ArrayLike],\nfields: tuple[str, ...] = (\"points\", \"clusters\"),\nclusters_field: str | None = \"clusters\"\n) -> dict[str, NDArray]\n

Merges the fields (specified in fields) of two or more data sets.

Merges the fields (specified in fields) of two or more data sets (named tuples or dictionaries). The fields to be merged need to have the same number of columns. The corresponding merged field will contain the rows of the fields to be merged, and will have a common supertype.

The clusters_field parameter specifies a field containing integers that identify the cluster to which the respective points belongs to. If clusters_field is specified (by default it's specified as \"clusters\"), cluster assignments in individual datasets will be updated in the merged dataset so that clusters are considered separate. This parameter can be set to None, in which case no field will be considered as a special cluster assignments field.

This function can be used to merge data sets generated with the clugen() function, by default merging the points and clusters fields in those data sets. It also works with arbitrary data by specifying alternative fields in the fields parameter. It can be used, for example, to merge third-party data with clugen()-generated data.

Examples:

>>> from pyclugen import clugen, clumerge\n>>> data1 = clugen(2, 5, 1000, [1, 1], 0.01, [20, 20], 14, 1.2, 1.5);\n>>> data2 = clugen(2, 3, 450, [0.8, -0.3], 0, [25, 21], 6, 0.4, 3.5);\n>>> data3 = clugen(2, 2, 600, [0, -0.7], 0.2, [15, 10], 1, 0.1, 5.2);\n>>> data_merged = clumerge(data1, data2, data3)\n

Parameters:

Name Type Description Default *data NamedTuple | Mapping[str, ArrayLike]

One or more cluster data sets whose fields are to be merged.

() fields tuple[str, ...]

Fields to be merged, which must exist in the data set given in *data.

('points', 'clusters') clusters_field str | None

Field containing the integer cluster labels. If specified, cluster assignments in individual datasets will be updated in the merged dataset so that clusters are considered separate.

'clusters'

Returns:

Type Description dict[str, NDArray]

A dictionary, where keys correspond to field names, and values to the merged numerical arrays.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/main.py
def clumerge(\n*data: NamedTuple | Mapping[str, ArrayLike],\nfields: tuple[str, ...] = (\"points\", \"clusters\"),\nclusters_field: str | None = \"clusters\",\n) -> dict[str, NDArray]:\nr\"\"\"Merges the fields (specified in `fields`) of two or more `data` sets.\n    Merges the fields (specified in `fields`) of two or more `data` sets (named\n    tuples or dictionaries). The fields to be merged need to have the same\n    number of columns. The corresponding merged field will contain the rows of\n    the fields to be merged, and will have a common supertype.\n    The `clusters_field` parameter specifies a field containing integers that\n    identify the cluster to which the respective points belongs to. If\n    `clusters_field` is specified (by default it's specified as `\"clusters\"`),\n    cluster assignments in individual datasets will be updated in the merged\n    dataset so that clusters are considered separate. This parameter can be set\n    to `None`, in which case no field will be considered as a special cluster\n    assignments field.\n    This function can be used to merge data sets generated with the\n    [`clugen()`][pyclugen.main.clugen] function, by default merging the\n    `points` and `clusters` fields in those data sets. It also works with\n    arbitrary data by specifying alternative fields in the `fields` parameter.\n    It can be used, for example, to merge third-party data with\n    [`clugen()`][pyclugen.main.clugen]-generated data.\n    Examples:\n        >>> from pyclugen import clugen, clumerge\n        >>> data1 = clugen(2, 5, 1000, [1, 1], 0.01, [20, 20], 14, 1.2, 1.5);\n        >>> data2 = clugen(2, 3, 450, [0.8, -0.3], 0, [25, 21], 6, 0.4, 3.5);\n        >>> data3 = clugen(2, 2, 600, [0, -0.7], 0.2, [15, 10], 1, 0.1, 5.2);\n        >>> data_merged = clumerge(data1, data2, data3)\n    Args:\n      *data: One or more cluster data sets whose `fields` are to be merged.\n      fields: Fields to be merged, which must exist in the data set given in\n        `*data`.\n      clusters_field: Field containing the integer cluster labels. If specified,\n        cluster assignments in individual datasets will be updated in the merged\n        dataset so that clusters are considered separate.\n    Returns:\n      A dictionary, where keys correspond to field names, and values to the\n        merged numerical arrays.\n    \"\"\"\n# Number of elements in each array the merged dataset\nnumel: int = 0\n# Number of columns of values in each field\nfields_info: dict[str, _FieldInfo] = {}\n# Merged dataset to output, initially empty\noutput: dict[str, NDArray] = {}\n# Create a fields set\nfields_set: MutableSet[str] = set(fields)\n# If a clusters field is given, add it\nif clusters_field is not None:\nfields_set.add(str(clusters_field))\n# Data in dictionary format with NDArray views on data\nddata: MutableSequence[Mapping[str, NDArray]] = []\nfor dt in data:\n# If dt is a named tuple, convert it into a dictionary\nddt: Mapping[str, ArrayLike]\nif isinstance(dt, dict):\nddt = cast(dict, dt)\nelse:\nntdt = cast(NamedTuple, dt)\nddt = ntdt._asdict()\n# Convert dictionary values to NDArrays\nddtnp: Mapping[str, NDArray] = {k: asarray(v) for k, v in ddt.items()}\n# Add converted dictionary to our sequence of dictionaries\nddata.append(ddtnp)\n# Cycle through data items\nfor dt in ddata:\n# Number of elements in the current item\nnumel_i: int = -1\n# Cycle through fields for the current item\nfor field in fields_set:\nif field not in dt:\nraise ValueError(f\"Data item does not contain required field `{field}`\")\nelif field == clusters_field and not can_cast(\ndt[clusters_field].dtype, int64\n):\nraise ValueError(f\"`{clusters_field}` must contain integer types\")\n# Get the field value\nvalue: NDArray = dt[field]\n# Number of elements in field value\nnumel_tmp = len(value)\n# Check the number of elements in the field value\nif numel_i == -1:\n# First field: get number of elements in value (must be the same\n# for the remaining field values)\nnumel_i = numel_tmp\nelif numel_tmp != numel_i:\n# Fields values after the first must have the same number of\n# elements\nraise ValueError(\n\"Data item contains fields with different sizes \"\n+ f\"({numel_tmp} != {numel_i})\"\n)\n# Get/check info about the field value type\nif field not in fields_info:\n# If it's the first time this field appears, just get the info\nfields_info[field] = _FieldInfo(value.dtype, _getcols(value))\nelse:\n# If this field already appeared in previous data items, get the\n# info and check/determine its compatibility with respect to\n# previous data items\nif _getcols(value) != fields_info[field].ncol:\n# Number of columns must be the same\nraise ValueError(f\"Dimension mismatch in field `{field}`\")\n# Get the common supertype\nfields_info[field].dtype = promote_types(\nfields_info[field].dtype, value.dtype\n)\n# Update total number of elements\nnumel += numel_i\n# Initialize output dictionary fields with room for all items\nfor field in fields_info:\nif fields_info[field].ncol == 1:\noutput[field] = empty((numel,), dtype=fields_info[field].dtype)\nelse:\noutput[field] = empty(\n(numel, fields_info[field].ncol), dtype=fields_info[field].dtype\n)\n# Copy items from input data to output dictionary, field-wise\ncopied: int = 0\nlast_cluster: int = 0\n# Create merged output\nfor dt in ddata:\n# How many elements to copy for the current data item?\ntocopy: int = len(dt[fields[0]])\n# Cycle through each field and its information\nfor field in fields_info:\n# Copy elements\nif field == clusters_field:\n# If this is a clusters field, update the cluster IDs\nold_clusters = unique(dt[clusters_field])\nnew_clusters = list(\nrange(last_cluster + 1, last_cluster + len(old_clusters) + 1)\n)\nold2new = zip(old_clusters, new_clusters)\nmapping = dict(old2new)\nlast_cluster = new_clusters[-1]\noutput[field][copied : (copied + tocopy)] = [\nmapping[val] for val in dt[clusters_field]\n]\nelse:\n# Otherwise just copy the elements\nncol: int = fields_info[field].ncol\noutput[field].flat[copied * ncol : (copied + tocopy) * ncol] = dt[field]\n# Update how many were copied so far\ncopied += tocopy\n# Return result\nreturn output\n
"},{"location":"reference/#pyclugen.clupoints_n","title":"clupoints_n","text":"
clupoints_n(\nprojs: NDArray,\nlat_disp: float,\nline_len: float,\nclu_dir: NDArray,\nclu_ctr: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray\n

Generate points from their \\(n\\)-D projections on a cluster-supporting line.

Each point is placed around its projection using the normal distribution ( \\(\\mu=0\\), \\(\u03c3=\\)lat_disp).

This function's main intended use is by the clugen() function, generating the final points when the point_dist_fn parameter is set to \"n\".

Examples:

>>> from pyclugen import clupoints_n, points_on_line\n>>> from numpy import array, linspace\n>>> from numpy.random import Generator, PCG64\n>>> prng = Generator(PCG64(123))\n>>> projs = points_on_line(array([5,5]),     # Get 5 point projections\n...                        array([1,0]),     # on a 2D line\n...                        linspace(-4,4,5))\n>>> projs\narray([[1., 5.],\n       [3., 5.],\n       [5., 5.],\n       [7., 5.],\n       [9., 5.]])\n>>> clupoints_n(projs, 0.5, 1.0, array([1,0]), array([0,0]), rng=prng)\narray([[0.50543932, 4.81610667],\n       [3.64396263, 5.09698721],\n       [5.46011545, 5.2885519 ],\n       [6.68176818, 5.27097611],\n       [8.84170227, 4.83880544]])\n

Parameters:

Name Type Description Default projs NDArray

Point projections on the cluster-supporting line ( \\(p \\times n\\) matrix).

required lat_disp float

Standard deviation for the normal distribution, i.e., cluster lateral dispersion.

required line_len float

Length of cluster-supporting line (ignored).

required clu_dir NDArray

Direction of the cluster-supporting line.

required clu_ctr NDArray

Center position of the cluster-supporting line (ignored).

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Generated points ( \\(p \\times n\\) matrix).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def clupoints_n(\nprojs: NDArray,\nlat_disp: float,\nline_len: float,\nclu_dir: NDArray,\nclu_ctr: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Generate points from their $n$-D projections on a cluster-supporting line.\n    Each point is placed around its projection using the normal distribution\n    ( $\\mu=0$, $\u03c3=$`lat_disp`).\n    This function's main intended use is by the [`clugen()`][pyclugen.main.clugen]\n    function, generating the final points when the `point_dist_fn` parameter is\n    set to `\"n\"`.\n    Examples:\n        >>> from pyclugen import clupoints_n, points_on_line\n        >>> from numpy import array, linspace\n        >>> from numpy.random import Generator, PCG64\n        >>> prng = Generator(PCG64(123))\n        >>> projs = points_on_line(array([5,5]),     # Get 5 point projections\n        ...                        array([1,0]),     # on a 2D line\n        ...                        linspace(-4,4,5))\n        >>> projs\n        array([[1., 5.],\n               [3., 5.],\n               [5., 5.],\n               [7., 5.],\n               [9., 5.]])\n        >>> clupoints_n(projs, 0.5, 1.0, array([1,0]), array([0,0]), rng=prng)\n        array([[0.50543932, 4.81610667],\n               [3.64396263, 5.09698721],\n               [5.46011545, 5.2885519 ],\n               [6.68176818, 5.27097611],\n               [8.84170227, 4.83880544]])\n    Args:\n      projs: Point projections on the cluster-supporting line ( $p \\times n$ matrix).\n      lat_disp: Standard deviation for the normal distribution, i.e., cluster\n        lateral dispersion.\n      line_len: Length of cluster-supporting line (ignored).\n      clu_dir: Direction of the cluster-supporting line.\n      clu_ctr: Center position of the cluster-supporting line (ignored).\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Generated points ( $p \\times n$ matrix).\n    \"\"\"\n# Number of dimensions\nnum_dims = clu_dir.size\n# Number of points in this cluster\nclu_num_points = projs.shape[0]\n# Get random displacement vectors for each point projection\ndispl = lat_disp * rng.normal(size=(clu_num_points, num_dims))\n# Add displacement vectors to each point projection\npoints = projs + displ\nreturn points\n
"},{"location":"reference/#pyclugen.clupoints_n_1","title":"clupoints_n_1","text":"
clupoints_n_1(\nprojs: NDArray,\nlat_disp: float,\nline_len: float,\nclu_dir: NDArray,\nclu_ctr: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray\n

Generate points from their \\(n\\)-D projections on a cluster-supporting line.

Each point is placed on a hyperplane orthogonal to that line and centered at the point's projection, using the normal distribution ( \\(\\mu=0\\), \\(\u03c3=\\)lat_disp).

This function's main intended use is by the clugen() function, generating the final points when the point_dist_fn parameter is set to \"n-1\".

Examples:

>>> from pyclugen import clupoints_n_1, points_on_line\n>>> from numpy import array, linspace\n>>> from numpy.random import Generator, PCG64\n>>> prng = Generator(PCG64(123))\n>>> projs = points_on_line(array([5,5]),     # Get 5 point projections\n...                        array([1,0]),     # on a 2D line\n...                        linspace(-4,4,5))\n>>> projs\narray([[1., 5.],\n       [3., 5.],\n       [5., 5.],\n       [7., 5.],\n       [9., 5.]])\n>>> clupoints_n_1(projs, 0.5, 1.0, array([1,0]), array([0,0]), rng=prng)\narray([[1.        , 5.49456068],\n       [3.        , 5.18389333],\n       [5.        , 5.64396263],\n       [7.        , 5.09698721],\n       [9.        , 5.46011545]])\n

Parameters:

Name Type Description Default projs NDArray

Point projections on the cluster-supporting line ( \\(p \\times n\\) matrix).

required lat_disp float

Standard deviation for the normal distribution, i.e., cluster lateral dispersion.

required line_len float

Length of cluster-supporting line (ignored).

required clu_dir NDArray

Direction of the cluster-supporting line.

required clu_ctr NDArray

Center position of the cluster-supporting line (ignored).

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Generated points ( \\(p \\times n\\) matrix).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def clupoints_n_1(\nprojs: NDArray,\nlat_disp: float,\nline_len: float,\nclu_dir: NDArray,\nclu_ctr: NDArray,\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Generate points from their $n$-D projections on a cluster-supporting line.\n    Each point is placed on a hyperplane orthogonal to that line and centered at\n    the point's projection, using the normal distribution ( $\\mu=0$,\n    $\u03c3=$`lat_disp`).\n    This function's main intended use is by the [`clugen()`][pyclugen.main.clugen]\n    function, generating the final points when the `point_dist_fn` parameter is\n    set to `\"n-1\"`.\n    Examples:\n        >>> from pyclugen import clupoints_n_1, points_on_line\n        >>> from numpy import array, linspace\n        >>> from numpy.random import Generator, PCG64\n        >>> prng = Generator(PCG64(123))\n        >>> projs = points_on_line(array([5,5]),     # Get 5 point projections\n        ...                        array([1,0]),     # on a 2D line\n        ...                        linspace(-4,4,5))\n        >>> projs\n        array([[1., 5.],\n               [3., 5.],\n               [5., 5.],\n               [7., 5.],\n               [9., 5.]])\n        >>> clupoints_n_1(projs, 0.5, 1.0, array([1,0]), array([0,0]), rng=prng)\n        array([[1.        , 5.49456068],\n               [3.        , 5.18389333],\n               [5.        , 5.64396263],\n               [7.        , 5.09698721],\n               [9.        , 5.46011545]])\n    Args:\n      projs: Point projections on the cluster-supporting line ( $p \\times n$ matrix).\n      lat_disp: Standard deviation for the normal distribution, i.e., cluster\n        lateral dispersion.\n      line_len: Length of cluster-supporting line (ignored).\n      clu_dir: Direction of the cluster-supporting line.\n      clu_ctr: Center position of the cluster-supporting line (ignored).\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Generated points ( $p \\times n$ matrix).\n    \"\"\"\n# No blank line allowed here\n# Define function to get distances from points to their projections on the\n# line (i.e., using the normal distribution)\ndef dist_fn(clu_num_points, ldisp, rg):\nreturn ldisp * rg.normal(size=clu_num_points)\n# Use clupoints_n_1_template() to do the heavy lifting\nreturn clupoints_n_1_template(projs, lat_disp, clu_dir, dist_fn, rng=rng)\n
"},{"location":"reference/#pyclugen.clupoints_n_1_template","title":"clupoints_n_1_template","text":"
clupoints_n_1_template(\nprojs: NDArray,\nlat_disp: float,\nclu_dir: NDArray,\ndist_fn: Callable[[int, float, Generator], NDArray],\nrng: Generator = _default_rng,\n) -> NDArray\n

Create \\(p\\) points from their \\(n\\)-D projections on a cluster-supporting line.

Each point is placed on a hyperplane orthogonal to that line and centered at the point's projection. The function specified in dist_fn is used to perform the actual placement.

This function is used internally by clupoints_n_1() and may be useful for constructing user-defined final point placement strategies for the point_dist_fn parameter of the main clugen() function.

Examples:

>>> from numpy import array, zeros\n>>> from numpy.random import Generator, PCG64\n>>> from pyclugen import clupoints_n_1_template, points_on_line\n>>> ctr = zeros(2)\n>>> dir = array([1, 0])\n>>> pdist = array([-0.5, -0.2, 0.1, 0.3])\n>>> rng = Generator(PCG64(123))\n>>> proj = points_on_line(ctr, dir, pdist)\n>>> clupoints_n_1_template(proj, 0, dir, lambda p, l, r: r.random(p), rng=rng)\narray([[-0.5       ,  0.68235186],\n       [-0.2       , -0.05382102],\n       [ 0.1       ,  0.22035987],\n       [ 0.3       , -0.18437181]])\n

Parameters:

Name Type Description Default projs NDArray

Point projections on the cluster-supporting line ( \\(p \\times n\\) matrix).

required lat_disp float

Dispersion of points from their projection.

required clu_dir NDArray

Direction of the cluster-supporting line (unit vector).

required dist_fn Callable[[int, float, Generator], NDArray]

Function to place points on a second line, orthogonal to the first. The functions accepts as parameters the number of points in the current cluster, the lateral_disp parameter (the same passed to the clugen() function), and a random number generator, returning a vector containing the distance of each point to its projection on the cluster-supporting line.

required rng Generator

An optional pseudo-random number generator for reproducible executions.

_default_rng

Returns:

Type Description NDArray

Generated points ( \\(p \\times n\\) matrix).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/helper.py
def clupoints_n_1_template(\nprojs: NDArray,\nlat_disp: float,\nclu_dir: NDArray,\ndist_fn: Callable[[int, float, Generator], NDArray],\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Create $p$ points from their $n$-D projections on a cluster-supporting line.\n    Each point is placed on a hyperplane orthogonal to that line and centered at\n    the point's projection. The function specified in `dist_fn` is used to perform\n    the actual placement.\n    This function is used internally by\n    [`clupoints_n_1()`][pyclugen.module.clupoints_n_1] and may be useful for\n    constructing user-defined final point placement strategies for the `point_dist_fn`\n    parameter of the main [`clugen()`][pyclugen.main.clugen] function.\n    Examples:\n        >>> from numpy import array, zeros\n        >>> from numpy.random import Generator, PCG64\n        >>> from pyclugen import clupoints_n_1_template, points_on_line\n        >>> ctr = zeros(2)\n        >>> dir = array([1, 0])\n        >>> pdist = array([-0.5, -0.2, 0.1, 0.3])\n        >>> rng = Generator(PCG64(123))\n        >>> proj = points_on_line(ctr, dir, pdist)\n        >>> clupoints_n_1_template(proj, 0, dir, lambda p, l, r: r.random(p), rng=rng)\n        array([[-0.5       ,  0.68235186],\n               [-0.2       , -0.05382102],\n               [ 0.1       ,  0.22035987],\n               [ 0.3       , -0.18437181]])\n    Args:\n      projs: Point projections on the cluster-supporting line ( $p \\times n$ matrix).\n      lat_disp: Dispersion of points from their projection.\n      clu_dir: Direction of the cluster-supporting line (unit vector).\n      dist_fn: Function to place points on a second line, orthogonal to the first.\n        The functions accepts as parameters the number of points in the current\n        cluster, the `lateral_disp` parameter (the same passed to the\n        [`clugen()`][pyclugen.main.clugen] function), and a random number generator,\n        returning a vector containing the distance of each point to its projection\n        on the cluster-supporting line.\n      rng: An optional pseudo-random number generator for reproducible executions.\n    Returns:\n      Generated points ( $p \\times n$ matrix).\n    \"\"\"\n# Number of dimensions\nnum_dims = clu_dir.size\n# Number of points in this cluster\nclu_num_points = projs.shape[0]\n# Get distances from points to their projections on the line\npoints_dist = dist_fn(clu_num_points, lat_disp, rng)\n# Get normalized vectors, orthogonal to the current line, for each point\north_vecs = zeros((clu_num_points, num_dims))\nfor j in range(clu_num_points):\north_vecs[j, :] = rand_ortho_vector(clu_dir, rng=rng).ravel()\n# Set vector magnitudes\north_vecs = abs(points_dist).reshape(-1, 1) * orth_vecs\n# Add perpendicular vectors to point projections on the line,\n# yielding final cluster points\npoints = projs + orth_vecs\nreturn points\n
"},{"location":"reference/#pyclugen.clusizes","title":"clusizes","text":"
clusizes(\nnum_clusters: int,\nnum_points: int,\nallow_empty: bool,\nrng: Generator = _default_rng,\n) -> NDArray\n

Determine cluster sizes, i.e., the number of points in each cluster.

Cluster sizes are determined using the normal distribution ( \\(\\mu=\\)num_points \\(/\\)num_clusters, \\(\\sigma=\\mu/3\\)), and then assuring that the final cluster sizes add up to num_points via the fix_num_points() function.

Examples:

>>> from numpy.random import Generator, PCG64\n>>> from pyclugen import clusizes\n>>> prng = Generator(PCG64(123))\n>>> sizes = clusizes(4, 1000, True, rng=prng)\n>>> sizes\narray([166, 217, 354, 263])\n>>> sum(sizes)\n1000\n

Parameters:

Name Type Description Default num_clusters int

Number of clusters.

required num_points int

Total number of points.

required allow_empty bool

Allow empty clusters?

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Number of points in each cluster (vector of size num_clusters).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def clusizes(\nnum_clusters: int,\nnum_points: int,\nallow_empty: bool,\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Determine cluster sizes, i.e., the number of points in each cluster.\n    Cluster sizes are determined using the normal distribution (\n    $\\mu=$`num_points` $/$`num_clusters`, $\\sigma=\\mu/3$), and then\n    assuring that the final cluster sizes add up to `num_points` via the\n    [`fix_num_points()`][pyclugen.helper.fix_num_points] function.\n    Examples:\n        >>> from numpy.random import Generator, PCG64\n        >>> from pyclugen import clusizes\n        >>> prng = Generator(PCG64(123))\n        >>> sizes = clusizes(4, 1000, True, rng=prng)\n        >>> sizes\n        array([166, 217, 354, 263])\n        >>> sum(sizes)\n        1000\n    Args:\n      num_clusters: Number of clusters.\n      num_points: Total number of points.\n      allow_empty: Allow empty clusters?\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Number of points in each cluster (vector of size `num_clusters`).\n    \"\"\"\n# Determine number of points in each cluster using the normal distribution\n# Consider the mean an equal division of points between clusters\nmean = num_points / num_clusters\n# The standard deviation is such that the interval [0, 2 * mean] will contain\n# \u224899.7% of cluster sizes\nstd = mean / 3\n# Determine points with the normal distribution\nclu_num_points = std * rng.normal(size=num_clusters) + mean\n# Set negative values to zero\nclu_num_points = where(clu_num_points > 0, clu_num_points, 0)\n# Fix imbalances, so that num_points is respected\nif sum(clu_num_points) > 0:  # Be careful not to divide by zero\nclu_num_points *= num_points / sum(clu_num_points)\n# Round the real values to integers since a cluster sizes is represented by\n# an integer\nclu_num_points = rint(clu_num_points).astype(int)\n# Make sure total points is respected, which may not be the case at this time due\n# to rounding\nfix_num_points(clu_num_points, num_points)\n# If empty clusters are not allowed, make sure there aren't any\nif not allow_empty:\nfix_empty(clu_num_points)\nreturn clu_num_points\n
"},{"location":"reference/#pyclugen.fix_empty","title":"fix_empty","text":"
fix_empty(clu_num_points: NDArray, allow_empty: bool = False) -> NDArray\n

Certifies that, given enough points, no clusters are left empty.

This is done by removing a point from the largest cluster and adding it to an empty cluster while there are empty clusters. If the total number of points is smaller than the number of clusters (or if the allow_empty parameter is set to true), this function does nothing.

This function is used internally by clusizes() and might be useful for custom cluster sizing implementations given as the clusizes_fn parameter of the main clugen() function.

Note that the array is changed in-place.

Examples:

>>> from numpy import array\n>>> from pyclugen import fix_empty\n>>> clusters = array([3, 4, 5, 0, 0])\n>>> fix_empty(clusters)\narray([3, 3, 4, 1, 1])\n>>> clusters # Verify that the array was changed in-place\narray([3, 3, 4, 1, 1])\n

Parameters:

Name Type Description Default clu_num_points NDArray

Number of points in each cluster (vector of size \\(c\\)), where \\(c\\) is the number of clusters.

required allow_empty bool

Allow empty clusters?

False

Returns:

Type Description NDArray

Number of points in each cluster, after being fixed by this function (vector of size \\(c\\), which is the same reference than clu_num_points).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/helper.py
def fix_empty(clu_num_points: NDArray, allow_empty: bool = False) -> NDArray:\nr\"\"\"Certifies that, given enough points, no clusters are left empty.\n    This is done by removing a point from the largest cluster and adding it to an\n    empty cluster while there are empty clusters. If the total number of points is\n    smaller than the number of clusters (or if the `allow_empty` parameter is set\n    to `true`), this function does nothing.\n    This function is used internally by [`clusizes()`][pyclugen.module.clusizes]\n    and might be useful for custom cluster sizing implementations given as the\n    `clusizes_fn` parameter of the main [`clugen()`][pyclugen.main.clugen] function.\n    Note that the array is changed in-place.\n    Examples:\n        >>> from numpy import array\n        >>> from pyclugen import fix_empty\n        >>> clusters = array([3, 4, 5, 0, 0])\n        >>> fix_empty(clusters)\n        array([3, 3, 4, 1, 1])\n        >>> clusters # Verify that the array was changed in-place\n        array([3, 3, 4, 1, 1])\n    Args:\n      clu_num_points: Number of points in each cluster (vector of size $c$),\n        where $c$ is the number of clusters.\n      allow_empty: Allow empty clusters?\n    Returns:\n      Number of points in each cluster, after being fixed by this function (vector\n        of size $c$, which is the same reference than `clu_num_points`).\n    \"\"\"\n# If the allow_empty parameter is set to true, don't do anything and return\n# immediately; this is useful for quick `clusizes_fn` one-liners\nif not allow_empty:\n# Find empty clusters\nempty_clusts = [idx for idx, val in enumerate(clu_num_points) if val == 0]\n# If there are empty clusters and enough points for all clusters...\nif len(empty_clusts) > 0 and sum(clu_num_points) >= clu_num_points.size:\n# Go through the empty clusters...\nfor i0 in empty_clusts:\n# ...get a point from the largest cluster and assign it to the\n# current empty cluster\nimax = argmax(clu_num_points)\nclu_num_points[imax] -= 1\nclu_num_points[i0] += 1\nreturn clu_num_points\n
"},{"location":"reference/#pyclugen.fix_num_points","title":"fix_num_points","text":"
fix_num_points(clu_num_points: NDArray, num_points: int) -> NDArray\n

Certifies that the values in the clu_num_points array add up to num_points.

If this is not the case, the clu_num_points array is modified in-place, incrementing the value corresponding to the smallest cluster while sum(clu_num_points) < num_points, or decrementing the value corresponding to the largest cluster while sum(clu_num_points) > num_points.

This function is used internally by clusizes() and might be useful for custom cluster sizing implementations given as the clusizes_fn parameter of the main clugen() function.

Examples:

>>> from numpy import array\n>>> from pyclugen import fix_num_points\n>>> clusters = array([1, 6, 3])  # 10 total points\n>>> fix_num_points(clusters, 12) # But we want 12 total points\narray([3, 6, 3])\n>>> clusters # Verify that the array was changed in-place\narray([3, 6, 3])\n

Parameters:

Name Type Description Default clu_num_points NDArray

Number of points in each cluster (vector of size \\(c\\)), where \\(c\\) is the number of clusters.

required num_points int

The expected total number of points.

required

Returns:

Type Description NDArray

Number of points in each cluster, after being fixed by this function (vector of size \\(c\\), which is the same reference than clu_num_points).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/helper.py
def fix_num_points(clu_num_points: NDArray, num_points: int) -> NDArray:\nr\"\"\"Certifies that the values in the `clu_num_points` array add up to `num_points`.\n    If this is not the case, the `clu_num_points` array is modified in-place,\n    incrementing the value corresponding to the smallest cluster while\n    `sum(clu_num_points) < num_points`, or decrementing the value corresponding to\n    the largest cluster while `sum(clu_num_points) > num_points`.\n    This function is used internally by [`clusizes()`][pyclugen.module.clusizes]\n    and might be useful for custom cluster sizing implementations given as the\n    `clusizes_fn` parameter of the main [`clugen()`][pyclugen.main.clugen] function.\n    Examples:\n        >>> from numpy import array\n        >>> from pyclugen import fix_num_points\n        >>> clusters = array([1, 6, 3])  # 10 total points\n        >>> fix_num_points(clusters, 12) # But we want 12 total points\n        array([3, 6, 3])\n        >>> clusters # Verify that the array was changed in-place\n        array([3, 6, 3])\n    Args:\n      clu_num_points: Number of points in each cluster (vector of size $c$),\n        where $c$ is the number of clusters.\n      num_points: The expected total number of points.\n    Returns:\n      Number of points in each cluster, after being fixed by this function (vector\n        of size $c$, which is the same reference than `clu_num_points`).\n    \"\"\"\nwhile sum(clu_num_points) < num_points:\nimin = argmin(clu_num_points)\nclu_num_points[imin] += 1\nwhile sum(clu_num_points) > num_points:\nimax = argmax(clu_num_points)\nclu_num_points[imax] -= 1\nreturn clu_num_points\n
"},{"location":"reference/#pyclugen.llengths","title":"llengths","text":"
llengths(\nnum_clusters: int,\nllength: float,\nllength_disp: float,\nrng: Generator = _default_rng,\n) -> NDArray\n

Determine length of cluster-supporting lines.

Line lengths are determined using the folded normal distribution ( \\(\\mu=\\)llength, \\(\\sigma=\\)llength_disp).

Examples:

>>> from numpy.random import Generator, MT19937\n>>> from pyclugen import llengths\n>>> prng = Generator(MT19937(123))\n>>> llengths(4, 20, 3.5, rng=prng)\narray([19.50968733, 19.92482858, 25.99013804, 18.58029672])\n

Parameters:

Name Type Description Default num_clusters int

Number of clusters.

required llength float

Average line length.

required llength_disp float

Line length dispersion.

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Lengths of cluster-supporting lines (vector of size num_clusters).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/module.py
def llengths(\nnum_clusters: int,\nllength: float,\nllength_disp: float,\nrng: Generator = _default_rng,\n) -> NDArray:\nr\"\"\"Determine length of cluster-supporting lines.\n    Line lengths are determined using the folded normal distribution (\n    $\\mu=$`llength`, $\\sigma=$`llength_disp`).\n    Examples:\n        >>> from numpy.random import Generator, MT19937\n        >>> from pyclugen import llengths\n        >>> prng = Generator(MT19937(123))\n        >>> llengths(4, 20, 3.5, rng=prng)\n        array([19.50968733, 19.92482858, 25.99013804, 18.58029672])\n    Args:\n      num_clusters: Number of clusters.\n      llength: Average line length.\n      llength_disp: Line length dispersion.\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Lengths of cluster-supporting lines (vector of size `num_clusters`).\n    \"\"\"\nreturn abs(llength + llength_disp * rng.normal(size=num_clusters))\n
"},{"location":"reference/#pyclugen.points_on_line","title":"points_on_line","text":"
points_on_line(\ncenter: NDArray, direction: NDArray, dist_center: NDArray\n) -> NDArray\n

Determine coordinates of points on a line.

Determine coordinates of points on a line with center and direction, based on the distances from the center given in dist_center.

This works by using the vector formulation of the line equation assuming direction is a \\(n\\)-dimensional unit vector. In other words, considering \\(\\mathbf{d}=\\)direction.reshape(-1,1) ( \\(n \\times 1\\) vector), \\(\\mathbf{c}=\\)center.reshape(-1,1) ( \\(n \\times 1\\) vector), and \\(\\mathbf{w}=\\) dist_center.reshape(-1,1) ( \\(p \\times 1\\) vector), the coordinates of points on the line are given by:

\\[ \\mathbf{P}=\\mathbf{1}\\,\\mathbf{c}^T + \\mathbf{w}\\mathbf{d}^T \\]

where \\(\\mathbf{P}\\) is the \\(p \\times n\\) matrix of point coordinates on the line, and \\(\\mathbf{1}\\) is a \\(p \\times 1\\) vector with all entries equal to 1.

Examples:

>>> from pyclugen import points_on_line\n>>> from numpy import array, linspace\n>>> points_on_line(array([5., 5.]),\n...                array([1., 0.]),\n...                linspace(-4, 4, 5)) # 2D, 5 points\narray([[1., 5.],\n       [3., 5.],\n       [5., 5.],\n       [7., 5.],\n       [9., 5.]])\n>>> points_on_line(array([-2, 0, 0., 2]),\n...                array([0., 0, -1, 0]),\n...                array([10, -10])) # 4D, 2 points\narray([[ -2.,   0., -10.,   2.],\n       [ -2.,   0.,  10.,   2.]])\n

Parameters:

Name Type Description Default center NDArray

Center of the line ( \\(n\\)-component vector).

required direction NDArray

Line direction ( \\(n\\)-component unit vector).

required dist_center NDArray

Distance of each point to the center of the line ( \\(p\\)-component vector, where \\(p\\) is the number of points).

required

Returns:

Type Description NDArray

Coordinates of points on the specified line ( \\(p \\times n\\) matrix).

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/core.py
def points_on_line(\ncenter: NDArray, direction: NDArray, dist_center: NDArray\n) -> NDArray:\nr\"\"\"Determine coordinates of points on a line.\n    Determine coordinates of points on a line with `center` and `direction`,\n    based on the distances from the center given in `dist_center`.\n    This works by using the vector formulation of the line equation assuming\n    `direction` is a $n$-dimensional unit vector. In other words, considering\n    $\\mathbf{d}=$`direction.reshape(-1,1)` ( $n \\times 1$ vector),\n    $\\mathbf{c}=$`center.reshape(-1,1)` ( $n \\times 1$ vector), and\n    $\\mathbf{w}=$ `dist_center.reshape(-1,1)` ( $p \\times 1$ vector),\n    the coordinates of points on the line are given by:\n    $$\n    \\mathbf{P}=\\mathbf{1}\\,\\mathbf{c}^T + \\mathbf{w}\\mathbf{d}^T\n    $$\n    where $\\mathbf{P}$ is the $p \\times n$ matrix of point coordinates on the\n    line, and $\\mathbf{1}$ is a $p \\times 1$ vector with all entries equal to 1.\n    Examples:\n        >>> from pyclugen import points_on_line\n        >>> from numpy import array, linspace\n        >>> points_on_line(array([5., 5.]),\n        ...                array([1., 0.]),\n        ...                linspace(-4, 4, 5)) # 2D, 5 points\n        array([[1., 5.],\n               [3., 5.],\n               [5., 5.],\n               [7., 5.],\n               [9., 5.]])\n        >>> points_on_line(array([-2, 0, 0., 2]),\n        ...                array([0., 0, -1, 0]),\n        ...                array([10, -10])) # 4D, 2 points\n        array([[ -2.,   0., -10.,   2.],\n               [ -2.,   0.,  10.,   2.]])\n    Args:\n      center: Center of the line ( $n$-component vector).\n      direction: Line direction ( $n$-component unit vector).\n      dist_center: Distance of each point to the center of the line\n        ( $p$-component vector, where $p$ is the number of points).\n    Returns:\n      Coordinates of points on the specified line ( $p \\times n$ matrix).\n    \"\"\"\nreturn center.reshape(1, -1) + dist_center.reshape(-1, 1) @ direction.reshape(\n(1, -1)\n)\n
"},{"location":"reference/#pyclugen.rand_ortho_vector","title":"rand_ortho_vector","text":"
rand_ortho_vector(u: NDArray, rng: Generator = _default_rng) -> NDArray\n

Get a random unit vector orthogonal to u.

Note that u is expected to be a unit vector itself.

Examples:

>>> from pyclugen import rand_ortho_vector\n>>> from numpy import isclose, dot\n>>> from numpy.linalg import norm\n>>> from numpy.random import Generator, PCG64\n>>> rng = Generator(PCG64(123))\n>>> r = rng.random(3) # Get a random vector with 3 components (3D)\n>>> r = r / norm(r) # Normalize it\n>>> r_ort = rand_ortho_vector(r, rng=rng) # Get random unit vector orth. to r\n>>> r_ort\narray([-0.1982903 , -0.61401512,  0.76398062])\n>>> isclose(dot(r, r_ort), 0) # Check that vectors are indeed orthogonal\nTrue\n

Parameters:

Name Type Description Default u NDArray

Unit vector with \\(n\\) components.

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

A random unit vector with \\(n\\) components orthogonal to u.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/core.py
def rand_ortho_vector(u: NDArray, rng: Generator = _default_rng) -> NDArray:\nr\"\"\"Get a random unit vector orthogonal to `u`.\n    Note that `u` is expected to be a unit vector itself.\n    Examples:\n        >>> from pyclugen import rand_ortho_vector\n        >>> from numpy import isclose, dot\n        >>> from numpy.linalg import norm\n        >>> from numpy.random import Generator, PCG64\n        >>> rng = Generator(PCG64(123))\n        >>> r = rng.random(3) # Get a random vector with 3 components (3D)\n        >>> r = r / norm(r) # Normalize it\n        >>> r_ort = rand_ortho_vector(r, rng=rng) # Get random unit vector orth. to r\n        >>> r_ort\n        array([-0.1982903 , -0.61401512,  0.76398062])\n        >>> isclose(dot(r, r_ort), 0) # Check that vectors are indeed orthogonal\n        True\n    Args:\n      u: Unit vector with $n$ components.\n      rng: Optional pseudo-random number generator.\n    Returns:\n      A random unit vector with $n$ components orthogonal to `u`.\n    \"\"\"\n# If 1D, just return a random unit vector\nif u.size == 1:\nreturn rand_unit_vector(1, rng=rng)\n# Find a random, non-parallel vector to u\nwhile True:\n# Find normalized random vector\nr = rand_unit_vector(u.size, rng=rng)\n# If not parallel to u we can keep it and break the loop\nif not isclose(abs(dot(u, r)), 1):\nbreak\n# Get vector orthogonal to u using 1st iteration of Gram-Schmidt process\nv = r - dot(u, r) / dot(u, u) * u\n# Normalize it\nv = v / norm(v)\n# And return it\nreturn v\n
"},{"location":"reference/#pyclugen.rand_unit_vector","title":"rand_unit_vector","text":"
rand_unit_vector(num_dims: int, rng: Generator = _default_rng) -> NDArray\n

Get a random unit vector with num_dims components.

Examples:

>>> from pyclugen import rand_unit_vector\n>>> rand_unit_vector(4)\narray([ 0.48653889,  0.50753862,  0.05711487, -0.70881757])\n
>>> from pyclugen import rand_unit_vector\n>>> from numpy.random import Generator, PCG64\n>>> rng = Generator(PCG64(123))\n>>> rand_unit_vector(2, rng=rng) # Reproducible\narray([ 0.3783202 , -0.92567479])\n

Parameters:

Name Type Description Default num_dims int

Number of components in vector (i.e. vector size).

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

A random unit vector with num_dims components.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/core.py
def rand_unit_vector(num_dims: int, rng: Generator = _default_rng) -> NDArray:\nr\"\"\"Get a random unit vector with `num_dims` components.\n    Examples:\n        >>> from pyclugen import rand_unit_vector\n        >>> rand_unit_vector(4) # doctest: +SKIP\n        array([ 0.48653889,  0.50753862,  0.05711487, -0.70881757])\n        >>> from pyclugen import rand_unit_vector\n        >>> from numpy.random import Generator, PCG64\n        >>> rng = Generator(PCG64(123))\n        >>> rand_unit_vector(2, rng=rng) # Reproducible\n        array([ 0.3783202 , -0.92567479])\n    Args:\n      num_dims: Number of components in vector (i.e. vector size).\n      rng: Optional pseudo-random number generator.\n    Returns:\n      A random unit vector with `num_dims` components.\n    \"\"\"\nr = rng.random(num_dims) - 0.5\nr = r / norm(r)\nreturn r\n
"},{"location":"reference/#pyclugen.rand_vector_at_angle","title":"rand_vector_at_angle","text":"
rand_vector_at_angle(\nu: NDArray, angle: float, rng: Generator = _default_rng\n) -> NDArray\n

Get a random unit vector which is at angle radians of vector u.

Note that u is expected to be a unit vector itself.

Examples:

>>> from pyclugen import rand_vector_at_angle\n>>> from numpy import arccos, array, degrees, pi, dot\n>>> from numpy.linalg import norm\n>>> from numpy.random import Generator, PCG64\n>>> rng = Generator(PCG64(123))\n>>> u = array([ 1.0, 0, 0.5, -0.5 ]) # Define a 4D vector\n>>> u = u / norm(u) # Normalize the vector\n>>> v = rand_vector_at_angle(u, pi/4, rng=rng) # Get a vector at 45 degrees\n>>> v\narray([ 0.633066  , -0.50953554, -0.10693823, -0.57285705])\n>>> degrees(arccos(dot(u, v) / norm(u) * norm(v))) # Angle between u and v\n45.0\n

Parameters:

Name Type Description Default u NDArray

Unit vector with \\(n\\) components.

required angle float

Angle in radians.

required rng Generator

Optional pseudo-random number generator.

_default_rng

Returns:

Type Description NDArray

Random unit vector with \\(n\\) components which is at angle radians with vector u.

Source code in /home/runner/.local/lib/python3.10/site-packages/pyclugen/core.py
def rand_vector_at_angle(\nu: NDArray, angle: float, rng: Generator = _default_rng\n) -> NDArray:\nr\"\"\"Get a random unit vector which is at `angle` radians of vector `u`.\n    Note that `u` is expected to be a unit vector itself.\n    Examples:\n        >>> from pyclugen import rand_vector_at_angle\n        >>> from numpy import arccos, array, degrees, pi, dot\n        >>> from numpy.linalg import norm\n        >>> from numpy.random import Generator, PCG64\n        >>> rng = Generator(PCG64(123))\n        >>> u = array([ 1.0, 0, 0.5, -0.5 ]) # Define a 4D vector\n        >>> u = u / norm(u) # Normalize the vector\n        >>> v = rand_vector_at_angle(u, pi/4, rng=rng) # Get a vector at 45 degrees\n        >>> v\n        array([ 0.633066  , -0.50953554, -0.10693823, -0.57285705])\n        >>> degrees(arccos(dot(u, v) / norm(u) * norm(v))) # Angle between u and v\n        45.0\n    Args:\n      u: Unit vector with $n$ components.\n      angle: Angle in radians.\n      rng: Optional pseudo-random number generator.\n    Returns:\n      Random unit vector with $n$ components which is at `angle` radians\n        with vector `u`.\n    \"\"\"\nif isclose(abs(angle), pi / 2) and u.size > 1:\nreturn rand_ortho_vector(u, rng=rng)\nelif -pi / 2 < angle < pi / 2 and u.size > 1:\nv = u + rand_ortho_vector(u, rng=rng) * tan(angle)\nreturn v / norm(v)\nelse:\n# For |\u03b8| > \u03c0/2 or the 1D case, simply return a random vector\nreturn rand_unit_vector(u.size, rng=rng)\n
"},{"location":"theory/","title":"Theory","text":"

This section describes the theoretical framework of the clugen algorithm, starting with a general Overview, then moving on to a Detailed description.

"},{"location":"theory/#overview","title":"Overview","text":"

Clugen is an algorithm for generating multidimensional clusters. Each cluster is supported by a line segment, the position, orientation and length of which guide where the respective points are placed. For brevity, line segments will be referred to as lines.

Given an \\(n\\)-dimensional direction vector \\(\\mathbf{d}\\) (and a number of additional parameters, which will be discussed shortly), the clugen algorithm works as follows (\\(^*\\) means the algorithm step is stochastic):

  1. Normalize \\(\\mathbf{d}\\).
  2. \\(^*\\)Determine cluster sizes.
  3. \\(^*\\)Determine cluster centers.
  4. \\(^*\\)Determine lengths of cluster-supporting lines.
  5. \\(^*\\)Determine angles between \\(\\mathbf{d}\\) and cluster-supporting lines.
  6. For each cluster:
  7. \\(^*\\)Determine direction of the cluster-supporting line.
  8. \\(^*\\)Determine distance of point projections from the center of the cluster-supporting line.
  9. Determine coordinates of point projections on the cluster-supporting line.
  10. \\(^*\\)Determine points from their projections on the cluster-supporting line.

Figure 1 provides a stylized overview of the algorithm's steps.

The example in Figure 1 was generated with the following parameters, the exact meaning of each will be discussed shortly:

Parameter values Description \\(n=2\\) Number of dimensions. \\(c=4\\) Number of clusters. \\(p=200\\) Total number of points. \\(\\mathbf{d}=\\begin{bmatrix}1 & 1\\end{bmatrix}^T\\) Average direction. \\(\\theta_\\sigma=\\pi/16\\approx{}11.25^{\\circ}\\) Angle dispersion. \\(\\mathbf{s}=\\begin{bmatrix}10 & 10\\end{bmatrix}^T\\) Average cluster separation. \\(l=10\\) Average line length. \\(l_\\sigma=1.5\\) Line length dispersion. \\(f_\\sigma=1\\) Cluster lateral dispersion.

Additionally, all optional parameters (not listed above) were left to their default values. These will also be discussed next.

"},{"location":"theory/#detailed-description","title":"Detailed description","text":"

In this section we provide a detailed description of the algorithm and its parameters. We start by listing and describing all parameters (mandatory and optional), and then analyze the algorithm in detail, highlighting how each parameter influences the end result.

"},{"location":"theory/#algorithm-parameters","title":"Algorithm parameters","text":"

The clugen algorithm (and consequently, the clugen() function) has mandatory and optional parameters, listed and described in the tables below. The optional parameters are set to sensible defaults, and in many situations may be left unchanged. Nonetheless, these allow all of the algorithm's steps to be fully customized by the user.

"},{"location":"theory/#mandatory-parameters","title":"Mandatory parameters","text":"Symbol Parameter Description \\(n\\) num_dims Number of dimensions. \\(c\\) num_clusters Number of clusters. \\(p\\) num_points Total number of points to generate. \\(\\mathbf{d}\\) direction Average direction of cluster-supporting lines (\\(n \\times 1\\)). \\(\\theta_\\sigma\\) angle_disp Angle dispersion of cluster-supporting lines (radians). \\(\\mathbf{s}\\) cluster_sep Average cluster separation in each dimension (\\(n \\times 1\\)). \\(l\\) llength Average length of cluster-supporting lines. \\(l_\\sigma\\) llength_disp Length dispersion of cluster-supporting lines. \\(f_\\sigma\\) lateral_disp Cluster lateral dispersion, i.e., dispersion of points from their projection on the cluster-supporting line."},{"location":"theory/#optional-parameters","title":"Optional parameters","text":"Symbol Parameter Default value Description \\(\\phi\\) allow_empty False Allow empty clusters? \\(\\mathbf{o}\\) cluster_offset zeros(num_dims) Offset to add to all cluster centers (\\(n \\times 1\\)). \\(p_\\text{proj}()\\) proj_dist_fn \"norm\" Distribution of point projections along cluster-supporting lines. \\(p_\\text{final}()\\) point_dist_fn \"n-1\" Distribution of final points from their projections. \\(c_s()\\) clusizes_fn clusizes() Distribution of cluster sizes. \\(c_c()\\) clucenters_fn clucenters() Distribution of cluster centers. \\(l()\\) llengths_fn llengths() Distribution of line lengths. \\(\\theta_\\Delta()\\) angle_deltas_fn angle_deltas() Distribution of line angle deltas (w.r.t. \\(\\mathbf{d}\\))."},{"location":"theory/#the-algorithm-in-detail","title":"The algorithm in detail","text":"

The clugen algorithm is presented in Overview. In this section we will analyze each of the algorithms steps in detail.

"},{"location":"theory/#1-normalize-mathbfd","title":"1. Normalize \\(\\mathbf{d}\\)","text":"

This is a basic step, which consists of converting \\(\\mathbf{d}\\) to a unit vector:

\\[ \\hat{\\mathbf{d}} = \\cfrac{\\mathbf{d}}{\\left\\lVert\\mathbf{d}\\right\\rVert} \\]"},{"location":"theory/#2-determine-cluster-sizes","title":"2. Determine cluster sizes","text":"

Cluster sizes are given by the \\(c_s()\\) function according to:

\\[ \\mathbf{c_s} = c_s(c, p, \\phi) \\]

where \\(\\mathbf{c_s}\\) is an \\(c \\times 1\\) integer vector containing the final cluster sizes, \\(c\\) is the number of clusters, \\(p\\) is the total number of points, and \\(\\phi\\) is a boolean which determines whether empty clusters are acceptable.

The \\(c_s()\\) function is an optional parameter, allowing users to customize its behavior. By default, \\(c_s()\\) is implemented by the clusizes() function, which behaves according to the following algorithm:

  1. Determine the size \\(p_i\\) of each cluster \\(i\\) according to \\(p_i\\sim\\left\\lfloor\\max\\left(\\mathcal{N}(\\frac{p}{c}, (\\frac{p}{3c})^2),0\\right)\\right\\rceil\\), where \\(\\lfloor\\rceil\\) denotes the round to nearest integer function, and \\(\\mathcal{N}(\\mu,\\sigma^2)\\) represents the normal distribution with mean \\(\\mu\\) and variance \\(\\sigma^2\\).
  2. Assure that the final cluster sizes add up to \\(p\\) by incrementing the smallest cluster size while \\(\\sum_{i=1}^c p_i<p\\) or decrementing the largest cluster size while \\(\\sum_{i=1}^c p_i>p\\). This step is delegated to the fix_num_points() helper function.
  3. If \\(\\neg\\phi\\wedge p\\ge c\\) then, for each empty cluster \\(i\\) (i.e., \\(p_i=0\\)), increment \\(p_i\\) and decrement \\(p_j\\), where \\(j\\) denotes the largest cluster. This step is delegated to the fix_empty() helper function.

Figure 2 demonstrates possible cluster sizes with various definitions of \\(c_s()\\) for \\(c=4\\) and \\(p=5000\\). The default behavior, implemented in the clusizes() function, is shown in Figure 2a, while Figures 2b-d present results obtained with custom user functions. Figure 2b displays cluster sizes obtained with the discrete uniform distribution over \\(\\left\\{1, 2, \\ldots, \\frac{2p}{c}\\right\\}\\), corrected with fix_num_points(). In turn, Figure 2c highlights cluster sizes obtained with the Poisson distribution with \\(\\lambda=\\frac{p}{c}\\), also corrected with fix_num_points(). The cluster sizes shown in Figure 2d were determined with the same distribution (Poisson, \\(\\lambda=\\frac{p}{c}\\)), but were not corrected. Thus, cluster sizes do not add up to \\(p\\), highlighting the fact that this is not a requirement of the clugen algorithm, i.e., user-defined \\(c_s()\\) implementations can consider \\(p\\) a hint rather than an obligation.

"},{"location":"theory/#3-determine-cluster-centers","title":"3. Determine cluster centers","text":"

Cluster sizes are given by the \\(c_c()\\) function according to:

\\[ \\mathbf{C} = c_c(c, \\mathbf{s}, \\mathbf{o}) \\]

where \\(\\mathbf{C}\\) is an \\(c \\times n\\) matrix containing the final cluster centers, \\(c\\) is the number of clusters, \\(\\mathbf{s}\\) is the average cluster separation (\\(n \\times 1\\) vector), and \\(\\mathbf{o}\\) is an \\(n \\times 1\\) vector of cluster offsets.

The \\(c_c()\\) function is an optional parameter, allowing users to customize its behavior. By default, \\(c_c()\\) is implemented by the clucenters() function, which determines the cluster centers according to:

\\[ \\mathbf{C}=c\\mathbf{U} \\cdot \\operatorname{diag}(\\mathbf{s}) + \\mathbf{1}\\,\\mathbf{o}^T \\]

where \\(\\mathbf{U}\\) is an \\(c \\times n\\) matrix of random values drawn from the uniform distribution between -0.5 and 0.5, and \\(\\mathbf{1}\\) is an \\(c \\times 1\\) vector with all entries equal to 1.

Figure 3 shows scatters plots of the results generated by clugen for two different implementations of the \\(c_c()\\) function, namely using the uniform the distribution (the default, implemented by the clucenters() function, Figure 3a), and direct specification of cluster centers (Figure 3b).

"},{"location":"theory/#4-determine-lengths-of-cluster-supporting-lines","title":"4. Determine lengths of cluster-supporting lines","text":"

The lengths of the cluster-supporting lines are given by the \\(l()\\) function according to:

\\[ \\pmb{\\ell} = l(c, l, l_\\sigma) \\]

where \\(\\pmb{\\ell}\\) is an \\(c \\times 1\\) vector containing the final lengths of the cluster-supporting lines, \\(c\\) is the number of clusters, \\(l\\) is the average length, and \\(l_\\sigma\\) is the length dispersion.

The \\(l()\\) function is an optional parameter, allowing users to customize its behavior. By default, \\(l()\\) is implemented by the llengths() function, which determines the \\(\\ell_i\\) length of each cluster-supporting line \\(i\\) according to:

\\[ \\ell_i\\sim\\left|\\mathcal{N}(l,l_\\sigma^2)\\right| \\]

where \\(\\left|\\mathcal{N}(\\mu,\\sigma^2)\\right|\\) represents the folded normal distribution with mean \\(\\mu\\) and variance \\(\\sigma^2\\).

Figure 4 shows cluster-supporting line lengths obtained with different implementations of \\(l()\\).

"},{"location":"theory/#5-determine-angles-between-mathbfd-and-cluster-supporting-lines","title":"5. Determine angles between \\(\\mathbf{d}\\) and cluster-supporting lines","text":"

The angles between \\(\\mathbf{d}\\) and the cluster-supporting lines are given by the \\(\\theta_\\Delta()\\) function according to:

\\[ \\mathbf{\\Theta_\\Delta} = \\theta_\\Delta(c, \\theta_\\sigma) \\]

where \\(\\mathbf{\\Theta_\\Delta}\\) is an \\(c \\times 1\\) vector containing the final angle differences between \\(\\mathbf{d}\\) and the cluster-supporting lines, \\(c\\) is the number of clusters, and \\(\\theta_\\sigma\\) is the angle dispersion.

The \\(\\theta_\\Delta()\\) function is an optional parameter, allowing users to customize its behavior. By default, \\(\\theta_\\Delta()\\) is implemented by the angle_deltas() function, which determines the \\(\\theta_{\\Delta i}\\) angle difference between \\(\\mathbf{d}\\) and the \\(i\\)-th cluster-supporting line according to:

\\[ \\theta_{\\Delta i}\\sim\\mathcal{WN}_{-\\pi/2}^{\\pi/2}(0,\\theta_\\sigma^2) \\]

where \\(\\mathcal{WN}_{-\\pi/2}^{\\pi/2}(\\mu,\\sigma^2)\\) represents the wrapped normal distribution with mean \\(\\mu\\), variance \\(\\sigma^2\\), and support in the \\(\\left[-\\pi/2,\\pi/2\\right]\\) interval, and \\(\\theta_\\sigma\\) is the angle dispersion of the cluster-supporting lines.

Figure 5 shows the final direction of the cluster-supporting lines for two different implementations of \\(\\theta_\\Delta()\\).

"},{"location":"theory/#6-for-each-cluster-i","title":"6. For each cluster \\(i\\):","text":""},{"location":"theory/#61-determine-direction-of-the-cluster-supporting-line","title":"6.1. Determine direction of the cluster-supporting line","text":"

In order to obtain the \\(\\hat{\\mathbf{d}}_i\\) final direction of cluster \\(i\\) supporting line, the following algorithm is used:

  • 1. Find random vector \\(\\mathbf{r}\\) with each component taken from the uniform distribution between -0.5 and 0.5.
  • 2. Normalize \\(\\mathbf{r}\\):
\\[ \\hat{\\mathbf{r}}=\\cfrac{\\mathbf{r}}{\\left\\lVert\\mathbf{r}\\right\\rVert} \\]
  • 3. If \\(|\\theta_{\\Delta i}| > \\pi/2\\) or \\(n=1\\), set \\(\\hat{\\mathbf{d}}_i=\\hat{\\mathbf{r}}\\) and terminate the algorithm.
  • 4. If \\(\\hat{\\mathbf{r}}\\) is parallel to \\(\\hat{\\mathbf{d}}\\) go to 1.
  • 5. Determine vector \\(\\mathbf{d}_\\perp\\) orthogonal to \\(\\hat{\\mathbf{d}}\\) using the first iteration of the Gram-Schmidt process:
\\[ \\mathbf{d}_\\perp=\\hat{\\mathbf{r}}-\\cfrac{\\hat{\\mathbf{d}}\\cdot\\hat{\\mathbf{r}}}{\\hat{\\mathbf{d}}\\cdot\\hat{\\mathbf{d}}}\\:\\hat{\\mathbf{d}} \\]
  • 6. Normalize \\(\\mathbf{d}_\\perp\\):
\\[ \\hat{\\mathbf{d}}_\\perp=\\cfrac{\\mathbf{d}_\\perp}{\\left\\lVert\\mathbf{d}_\\perp\\right\\rVert} \\]
  • 7. Determine vector \\(\\mathbf{d}_i\\) at angle \\(\\theta_{\\Delta i}\\) with \\(\\hat{\\mathbf{d}}\\):
\\[ \\mathbf{d}_i=\\hat{\\mathbf{d}}+\\tan(\\theta_{\\Delta i})\\hat{\\mathbf{d}}_\\perp \\]
  • 8. Normalize \\(\\mathbf{d}_i\\):
\\[ \\hat{\\mathbf{d}}_i=\\cfrac{\\mathbf{d}_i}{\\left\\lVert\\mathbf{d}_i\\right\\rVert} \\]"},{"location":"theory/#62-determine-distance-of-point-projections-from-the-center-of-the-cluster-supporting-line","title":"6.2. Determine distance of point projections from the center of the cluster-supporting line","text":"

The distance of point projections from the center of the cluster-supporting line is given by the \\(p_\\text{proj}()\\) function according to:

\\[ \\mathbf{w}_i = p_\\text{proj}(\\ell_i, p_i) \\]

where \\(\\mathbf{w}_i\\) is an \\(p_i \\times 1\\) vector containing the distance of each point projection to the center of the line, while \\(\\ell_i\\) and \\(p_i\\) are the line length and number of points in cluster \\(i\\), respectively.

The \\(p_\\text{proj}()\\) function is an optional parameter, allowing users to customize its behavior. pyclugen provides two concrete implementations out of the box, specified by passing \"norm\" or \"unif\" to clugen()'s proj_dist_fn parameter. These work as follows:

  • \"norm\" (default) - Each element of \\(\\mathbf{w}_i\\) is derived from \\(\\mathcal{N}(0, (\\frac{\\ell_i}{6})^2)\\), i.e., from the normal distribution, centered on the cluster-supporting line center (\\(\\mu=0\\)) and with a standard deviation of \\(\\sigma=\\frac{\\ell_i}{6}\\), such that the length of the line segment encompasses \\(\\approx\\) 99.73% of the generated projections. Consequently, some projections may be placed outside the line's end points.
  • \"unif\" - Each element of \\(\\mathbf{w}_i\\) is derived from \\(\\mathcal{U}(-\\frac{\\ell_i}{2}, \\frac{\\ell_i}{2})\\), i.e., from the continuous uniform distribution in the interval \\(\\left[-\\frac{\\ell_i}{2}, \\frac{\\ell_i}{2}\\right[\\). Thus, projections will be uniformly dispersed along the cluster-supporting line.

The impact of various implementations of \\(p_\\text{proj}()\\) is demonstrated in Figure 6. Figures 6a and 6b show the clusters generated with the \"norm\" and \"unif\" options, respectively, while Figures 6c and 6d highlight custom user functions implementing the Laplace and Rayleigh distributions, respectively. All parameters are set as in Figure 1, except for \\(p_\\text{proj}()\\) in the case of Figures 6b-6d, and \\(p\\), which is set to 5000.

"},{"location":"theory/#63-determine-coordinates-of-point-projections-on-the-cluster-supporting-line","title":"6.3. Determine coordinates of point projections on the cluster-supporting line","text":"

This is a deterministic step performed by the points_on_line() function using the vector formulation of the line equation, as follows:

\\[ \\mathbf{P}_i^\\text{proj}=\\mathbf{1}\\,\\mathbf{c}_i^T + \\mathbf{w}_i\\hat{\\mathbf{d}}_i^T \\]

where \\(\\mathbf{P}_i^\\text{proj}\\) is the \\(p_i \\times n\\) matrix of point projection coordinates on the line, \\(\\mathbf{1}\\) is an \\(p_i \\times 1\\) vector with all entries equal to 1, \\(\\mathbf{c}_i\\) are the coordinates of the line center (\\(n \\times 1\\) vector), \\(\\mathbf{w}_i\\) is the distance of each point projection to the center of the line (\\(p_i \\times 1\\) vector obtained in the previous step), and \\(\\hat{\\mathbf{d}}_i\\) is the direction of the cluster-supporting line for cluster \\(i\\).

"},{"location":"theory/#64-determine-points-from-their-projections-on-the-cluster-supporting-line","title":"6.4. Determine points from their projections on the cluster-supporting line","text":"

The final cluster points, obtained from their projections on the cluster-supporting line, are given by the \\(p_\\text{final}()\\) function according to:

\\[ \\mathbf{P}_i^\\text{final} = p_\\text{final}(\\mathbf{P}_i^\\text{proj}, f_\\sigma, \\ell_i, \\hat{\\mathbf{d}}_i, \\mathbf{c}_i) \\]

where \\(\\mathbf{P}_i^\\text{final}\\) is a \\(p_i \\times n\\) matrix containing the coordinates of the generated points, \\(\\mathbf{P}_i^\\text{proj}\\) is the \\(p_i \\times n\\) matrix of projection coordinates (determined in the previous step), and \\(f_\\sigma\\) is the lateral dispersion parameter. In turn, \\(\\ell_i\\), \\(\\hat{\\mathbf{d}}_i\\) and \\(\\mathbf{c}_i\\) are the length, direction and center of the cluster-supporting line.

The \\(p_\\text{final}()\\) function is an optional parameter, allowing users to customize its behavior. pyclugen provides two concrete implementations out of the box, specified by passing \"n-1\" or \"n\" to clugen()'s point_dist_fn parameter. These work as follows:

  • \"n-1\" (default) - Points are placed on a hyperplane orthogonal to the cluster-supporting line and intersecting the point's projection. This is done by obtaining \\(p_i\\) random unit vectors orthogonal to \\(\\hat{\\mathbf{d}}_i\\), and determining their magnitude using the normal distribution (\\(\\mu=0\\), \\(\\sigma=f_\\sigma\\)). These vectors are then added to the respective projections on the cluster-supporting line, yielding the final cluster points. This behavior is implemented in the clupoints_n_1() function.
  • \"n\" - Points are placed around their respective projections. This is done by obtaining \\(p_i\\) random unit vectors, and determining their magnitude using the normal distribution (\\(\\mu=0\\), \\(\\sigma=f_\\sigma\\)). These vectors are then added to the respective projections on the cluster-supporting line, yielding the final cluster points. This behavior is implemented in the clupoints_n() function.

Figure 7 highlights the differences between these two approaches in 2D, where a hyperplane is simply a line.

In general, points can be placed using a \"n-1\" or \"n\" strategy using any distribution. Figure 8 displays several examples for various implementations of \\(p_\\text{final}()\\), either based on \"n-1\" or \"n\" strategy, using different distributions. Figures 8a and 8b show the built-in \"n-1\" and \"n\" strategies making use of the normal distribution. Figures 8c-8f highlight some possibilities with custom user functions. Figure 8c shows the effect of using the exponential distribution in a \"n-1\" strategy, while Figure 8d displays the result of using a bimodal distribution with the same strategy. A more complex distribution, producing \"hollow\" clusters with a \"n\" strategy, is employed in Figures 8e and 8f, with the latter also having the \\(p_\\text{proj}()\\) function set to \"unif\". The remaining parameters (for all subfigures) are set as in Figure 1, except for \\(p\\), which is set to 5000.

"},{"location":"generated/gallery/","title":"Examples","text":""},{"location":"generated/gallery/#examples","title":"Examples","text":"

Examples in 1D

Examples in 2D

Examples in 3D

Examples in nD

Merging and hierarchical cluster examples

Plot functions

Download all examples in Python source code: gallery_python.zip

Download all examples in Jupyter notebooks: gallery_jupyter.zip

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/mg_execution_times/","title":"Computation times","text":"

00:51.721 total execution time for generated_gallery files:

+----------------------------------------------------------------------------------------+-----------+--------+ | plot_2_2d_examples (docs/examples/plot_2_2d_examples.py) | 00:19.947 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ | plot_4_nd_examples (docs/examples/plot_4_nd_examples.py) | 00:15.867 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ | plot_3_3d_examples (docs/examples/plot_3_3d_examples.py) | 00:07.542 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ | plot_5_mrg_examples (docs/examples/plot_5_mrg_examples.py) | 00:06.215 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ | plot_1_1d_examples (docs/examples/plot_1_1d_examples.py) | 00:02.143 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+ | plot_functions (docs/examples/plot_functions.py) | 00:00.007 | 0.0 MB | +----------------------------------------------------------------------------------------+-----------+--------+

"},{"location":"generated/gallery/plot_1_1d_examples/","title":"Examples in 1D","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_1_1d_examples/#examples-in-1d","title":"Examples in 1D","text":"

This section contains several examples on how to generate 1D data with pyclugen. To run the examples we first need to import the clugen() function:

from pyclugen import clugen\n

To make the examples exactly reproducible we'll import a random number generator from NumPy and pass it as a parameter to clugen(). We'll also create a small helper function for providing us a brand new seeded generator:

import numpy as np\nfrom numpy.random import PCG64, Generator\ndef rng(seed):\nreturn Generator(PCG64(seed))\n

To plot these examples we use the plot_examples_1d function:

from plot_functions import plot_examples_1d\n
"},{"location":"generated/gallery/plot_1_1d_examples/#basic-1d-example-with-density-plot","title":"Basic 1D example with density plot","text":"
seed = 23456\n
# Custom proj_dist_fn: point projections placed using the Weibull distribution\ndef proj_weibull(len, n, rng):\nreturn len / 2 * rng.weibull(1.5, size=n)\n
e082 = clugen(1, 3, 1000, [1], 0, [10], 6, 1.5, 0, rng=rng(seed))\ne083 = clugen(1, 3, 1000, [1], 0, [10], 6, 1.5, 0, rng=rng(seed), proj_dist_fn=\"unif\")\ne084 = clugen(1, 3, 1000, [1], 0, [10], 6, 1.5, 0, rng=rng(seed), proj_dist_fn=proj_weibull)\n
plot_examples_1d(\ne082, \"e082: proj_dist_fn = 'norm' (default)\",\ne083, \"e083: proj_dist_fn = 'unif'\",\ne084, \"e084: custom proj_dist_fn (Weibull)\")\n

Total running time of the script: ( 0 minutes 2.143 seconds)

Download Python source code: plot_1_1d_examples.py

Download Jupyter notebook: plot_1_1d_examples.ipynb

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/plot_2_2d_examples/","title":"Examples in 2D","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_2_2d_examples/#examples-in-2d","title":"Examples in 2D","text":"

This section contains several examples on how to generate 2D data with pyclugen. To run the examples we first need to import the clugen() function:

from pyclugen import clugen\n

To make the examples exactly reproducible we'll import a random number generator from NumPy and pass it as a parameter to clugen(). We'll also create a small helper function for providing us a brand new seeded generator:

import numpy as np\nfrom numpy.random import PCG64, Generator\ndef rng(seed):\nreturn Generator(PCG64(seed))\n

To plot these examples we use the plot_examples_2d function:

from plot_functions import plot_examples_2d\n
"},{"location":"generated/gallery/plot_2_2d_examples/#manipulating-the-direction-of-cluster-supporting-lines","title":"Manipulating the direction of cluster-supporting lines","text":""},{"location":"generated/gallery/plot_2_2d_examples/#using-the-direction-parameter","title":"Using the direction parameter","text":"
seed = 123\n
e001 = clugen(2, 4, 2000, [1, 0], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed))\ne002 = clugen(2, 4, 200, [1, 1], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed))\ne003 = clugen(2, 4, 200, [0, 1], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed))\n
plot_examples_2d(\ne001, \"e001: direction = [1, 0]\",\ne002, \"e002: direction = [1, 1]\",\ne003, \"e003: direction = [0, 1]\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#changing-the-angle_disp-parameter-and-using-a-custom-angle_deltas_fn-function","title":"Changing the angle_disp parameter and using a custom angle_deltas_fn function","text":"
seed = 321\n
# Custom angle_deltas function: arbitrarily rotate some clusters by 90 degrees\ndef angdel_90_fn(nclu, astd, rng):\nreturn rng.choice([0, np.pi / 2], size=nclu)\n
e004 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed))\ne005 = clugen(2, 6, 500, [1, 0], np.pi / 8, [10, 10], 10, 1.5, 0.5, rng=rng(seed))\ne006 = clugen(2, 6, 500, [1, 0], 0, [10, 10], 10, 1.5, 0.5, rng=rng(seed),\nangle_deltas_fn=angdel_90_fn)\n
plot_examples_2d(\ne004, \"e004: angle_disp = 0\",\ne005, \"e005: angle_disp = \u03c0/8\",\ne006, \"e006: custom angle_deltas function\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#manipulating-the-length-of-cluster-supporting-lines","title":"Manipulating the length of cluster-supporting lines","text":""},{"location":"generated/gallery/plot_2_2d_examples/#using-the-llength-parameter","title":"Using the llength parameter","text":"
seed = 567\n
e007 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10],  0, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne008 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 10, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne009 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 30, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\n
plot_examples_2d(\ne007, \"e007: llength = 0\",\ne008, \"e008: llength = 10\",\ne009, \"e009: llength = 30\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#changing-the-llength_disp-parameter-and-using-a-custom-llengths_fn-function","title":"Changing the llength_disp parameter and using a custom llengths_fn function","text":"
seed = 567\n
# Custom llengths function: line lengths grow for each new cluster\ndef llen_grow_fn(nclu, llen, llenstd, rng):\nreturn llen * np.arange(nclu) + rng.normal(scale=llenstd, size=nclu)\n
e010 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 15,  0.0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne011 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 15, 10.0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne012 = clugen(2, 5, 800, [1, 0], np.pi / 10, [10, 10], 10,  0.1, 0.5, rng=rng(seed),\nllengths_fn=llen_grow_fn, point_dist_fn=\"n\")\n
plot_examples_2d(\ne010, \"e010: llength_disp = 0.0\",\ne011, \"e011: llength_disp = 5.0\",\ne012, \"e012: custom llengths function\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#manipulating-relative-cluster-positions","title":"Manipulating relative cluster positions","text":""},{"location":"generated/gallery/plot_2_2d_examples/#using-the-cluster_sep-parameter","title":"Using the cluster_sep parameter","text":"
seed = 21\n
e013 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed))\ne014 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [30, 10], 10, 2, 2.5, rng=rng(seed))\ne015 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 30], 10, 2, 2.5, rng=rng(seed))\n
plt = plot_examples_2d(\ne013, \"e013: cluster_sep = [10, 10]\",\ne014, \"e014: cluster_sep = [30, 10]\",\ne015, \"e015: cluster_sep = [10, 30]\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#changing-the-cluster_offset-parameter-and-using-a-custom-clucenters_fn-function","title":"Changing the cluster_offset parameter and using a custom clucenters_fn function","text":"
seed = 21\n
# Custom clucenters function: places clusters in a diagonal\ndef centers_diag_fn(nclu, csep, coff, rng):\nreturn np.ones((nclu, len(csep))) * np.arange(1, nclu + 1)[:, None] * np.max(csep) + coff\n
e016 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed))\ne017 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed),\ncluster_offset=[20, -20])\ne018 = clugen(2, 8, 1000, [1, 1], np.pi / 4, [10, 10], 10, 2, 2.5, rng=rng(seed),\ncluster_offset=[-50, -50], clucenters_fn=centers_diag_fn)\n
plt = plot_examples_2d(\ne016, \"e016: default\",\ne017, \"e017: cluster_offset = [20, -20]\",\ne018, \"e018: custom clucenters function\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#lateral-dispersion-and-placement-of-point-projections-on-the-line","title":"Lateral dispersion and placement of point projections on the line","text":""},{"location":"generated/gallery/plot_2_2d_examples/#normal-projection-placement-default-proj_dist_fn-norm","title":"Normal projection placement (default): proj_dist_fn = \"norm\"","text":"
seed = 654\n
e019 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed))\ne020 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed))\ne021 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed))\n
plt = plot_examples_2d(\ne019, \"e019: lateral_disp = 0\",\ne020, \"e020: lateral_disp = 1\",\ne021, \"e021: lateral_disp = 3\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#uniform-projection-placement-proj_dist_fn-unif","title":"Uniform projection placement: proj_dist_fn = \"unif\"","text":"
seed = 654\n
e022 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne023 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne024 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\n
plt = plot_examples_2d(\ne022, \"e022: lateral_disp = 0\",\ne023, \"e023: lateral_disp = 1\",\ne024, \"e024: lateral_disp = 3\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#custom-projection-placement-using-the-laplace-distribution","title":"Custom projection placement using the Laplace distribution","text":"
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e025 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 0.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\ne026 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 1.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\ne027 = clugen(2, 4, 1000, [1, 0], np.pi / 2, [20, 20], 13, 2, 3.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\n
plt = plot_examples_2d(\ne025, \"e025: lateral_disp = 0\",\ne026, \"e026: lateral_disp = 1\",\ne027, \"e027: lateral_disp = 3\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#controlling-final-point-positions-from-their-projections-on-the-cluster-supporting-line","title":"Controlling final point positions from their projections on the cluster-supporting line","text":""},{"location":"generated/gallery/plot_2_2d_examples/#points-on-hyperplane-orthogonal-to-cluster-supporting-line-default-point_dist_fn-n-1","title":"Points on hyperplane orthogonal to cluster-supporting line (default): point_dist_fn = \"n-1\"","text":"
seed = 1357\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e028 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed))\ne029 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne030 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\n
plt = plot_examples_2d(\ne028, \"e028: proj_dist_fn=\\\"norm\\\" (default)\",\ne029, \"e029: proj_dist_fn=\\\"unif\\\"\",\ne030, \"e030: custom proj_dist_fn (Laplace)\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#points-around-projection-on-cluster-supporting-line-point_dist_fn-n","title":"Points around projection on cluster-supporting line: point_dist_fn = \"n\"","text":"
seed = 1357\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e031 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=\"n\")\ne032 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=\"n\", proj_dist_fn=\"unif\")\ne033 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=\"n\", proj_dist_fn=proj_laplace)\n
plt = plot_examples_2d(\ne031, \"e031: proj_dist_fn=\\\"norm\\\" (default)\",\ne032, \"e032: proj_dist_fn=\\\"unif\\\"\",\ne033, \"e033: custom proj_dist_fn (Laplace)\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#custom-point-placement-using-the-exponential-distribution","title":"Custom point placement using the exponential distribution","text":"

For this example we require the clupoints_n_1_template() helper function:

from pyclugen import clupoints_n_1_template\n
seed = 1357\n
# Custom point_dist_fn: final points placed using the Exponential distribution\ndef clupoints_n_1_exp(projs, lat_std, len, clu_dir, clu_ctr, rng):\ndef dist_exp(npts, lstd, rg):\nreturn lstd * rg.exponential(scale=2 / lstd, size=npts)\nreturn clupoints_n_1_template(projs, lat_std, clu_dir, dist_exp, rng=rng)\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e034 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp)\ne035 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp, proj_dist_fn=\"unif\")\ne036 = clugen(2, 5, 1500, [1, 0], np.pi / 3, [20, 20], 12, 3, 1.0, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp, proj_dist_fn=proj_laplace)\n
plt = plot_examples_2d(\ne034, \"e034: proj_dist_fn=\\\"norm\\\" (default)\",\ne035, \"e035: proj_dist_fn=\\\"unif\\\"\",\ne036, \"e036: custom proj_dist_fn (Laplace)\")\n

"},{"location":"generated/gallery/plot_2_2d_examples/#manipulating-cluster-sizes","title":"Manipulating cluster sizes","text":"
seed = 963\n
# Custom clusizes_fn (e038): cluster sizes determined via the uniform distribution,\n# no correction for total points\ndef clusizes_unif(nclu, npts, ae, rng):\nreturn rng.integers(low=1, high=2 * npts / nclu + 1, size=nclu)\n
# Custom clusizes_fn (e039): clusters all have the same size, no correction for total points\ndef clusizes_equal(nclu, npts, ae, rng):\nreturn (npts // nclu) * np.ones(nclu, dtype=int)\n
# Custom clucenters_fn (all): yields fixed positions for the clusters\ndef centers_fixed(nclu, csep, coff, rng):\nreturn np.array([[-csep[0], -csep[1]], [csep[0], -csep[1]], [-csep[0], csep[1]], [csep[0], csep[1]]])\n
e037 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),\npoint_dist_fn=\"n\", clucenters_fn=centers_fixed)\ne038 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),\npoint_dist_fn=\"n\", clucenters_fn=centers_fixed, clusizes_fn=clusizes_unif)\ne039 = clugen(2, 4, 1500, [1, 1], np.pi, [20, 20], 0, 0, 5, rng=rng(seed),\npoint_dist_fn=\"n\", clucenters_fn=centers_fixed, clusizes_fn=clusizes_equal)\n
plt = plot_examples_2d(\ne037, \"e037: normal dist. (default)\",\ne038, \"e038: unif. dist. (custom)\",\ne039, \"e039: equal size (custom)\")\n
"},{"location":"generated/gallery/plot_2_2d_examples/#direct-specification-of-optional-parameters","title":"Direct specification of optional parameters","text":"
seed = 123\n
e040 = clugen(2, 4, 1000, [-1, 1], 0, [0, 0], 0, 0, 0.2, rng=rng(seed),\nproj_dist_fn=\"unif\", point_dist_fn=\"n\", clusizes_fn=[50, 200, 500, 2000],\nllengths_fn=[0, 2, 4, 6], clucenters_fn=[[-5, -5], [-2.5, -2.5], [0, 0], [2.5, 2.5]])\ne041 = clugen(2, 5, 1000, [[1, 1], [1, 0], [1, 0], [0, 1], [0, 1]],\n0, [0, 0], 0, 0, 0.2, rng=rng(seed),\nproj_dist_fn=\"unif\", point_dist_fn=\"n\",\nclusizes_fn=[200, 500, 500, 500, 500], llengths_fn=[0, 5, 5, 5, 5],\nclucenters_fn=[[0, 0], [0, 5], [0, -5], [5, 0], [-5, 0]])\ne042 = clugen(2, 5, 1000, [[0, 1], [0.25, 0.75], [0.5, 0.5], [0.75, 0.25], [1, 0]],\n0, [0, 0], 5, 0, 0.2, rng=rng(seed),\nproj_dist_fn=\"unif\", point_dist_fn=\"n\", clusizes_fn=[500, 500, 500, 500, 500],\nclucenters_fn=[[-5, 0], [-3, -0.3], [-1, -0.8], [1, -1.6], [3, -2.5]])\n
plt = plot_examples_2d(\ne040, \"e040: direct params 1\",\ne041, \"e041: direct params 2\",\ne042, \"e042: direct params 3\")\n

Total running time of the script: ( 0 minutes 19.947 seconds)

Download Python source code: plot_2_2d_examples.py

Download Jupyter notebook: plot_2_2d_examples.ipynb

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/plot_3_3d_examples/","title":"Examples in 3D","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_3_3d_examples/#examples-in-3d","title":"Examples in 3D","text":"

This section contains several examples on how to generate 3D data with pyclugen. To run the examples we first need to import the clugen() function:

from pyclugen import clugen\n

To make the examples exactly reproducible we'll import a random number generator from NumPy and pass it as a parameter to clugen(). We'll also create a small helper function for providing us a brand new seeded generator:

import numpy as np\nfrom numpy.random import PCG64, Generator\ndef rng(seed):\nreturn Generator(PCG64(seed))\n

To plot these examples we use the plot_examples_3d function:

from plot_functions import plot_examples_3d\n
"},{"location":"generated/gallery/plot_3_3d_examples/#manipulating-the-direction-of-cluster-supporting-lines","title":"Manipulating the direction of cluster-supporting lines","text":""},{"location":"generated/gallery/plot_3_3d_examples/#using-the-direction-parameter","title":"Using the direction parameter","text":"
seed = 321\n
e043 = clugen(3, 4, 500, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))\ne044 = clugen(3, 4, 500, [1, 1, 1], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))\ne045 = clugen(3, 4, 500, [0, 0, 1], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))\n
plt = plot_examples_3d(\ne043, \"e043: direction = [1, 0, 0]\",\ne044, \"e044: direction = [1, 1, 1]\",\ne045, \"e045: direction = [0, 0, 1]\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#changing-the-angle_disp-parameter-and-using-a-custom-angle_deltas_fn-function","title":"Changing the angle_disp parameter and using a custom angle_deltas_fn function","text":"
seed = 321\n# Custom angle_deltas function: arbitrarily rotate some clusters by 90 degrees\ndef angdel_90_fn(nclu, astd, rng):\nreturn rng.choice([0, np.pi / 2], size=nclu)\n
e046 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))\ne047 = clugen(3, 6, 1000, [1, 0, 0], np.pi / 8, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed))\ne048 = clugen(3, 6, 1000, [1, 0, 0], 0, [10, 10, 10], 15, 1.5, 0.5, rng=rng(seed),\nangle_deltas_fn=angdel_90_fn)\n
plt = plot_examples_3d(\ne046, \"e046: angle_disp = 0\",\ne047, \"e047: angle_disp = \u03c0 / 8\",\ne048, \"e048: custom angle_deltas function\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#specifying-a-main-direction-for-each-cluster-and-changing-angle_disp","title":"Specifying a main direction for each cluster and changing angle_disp","text":"
seed = 123\n# Define a main direction for each cluster\ndirs = [[1, 1, 1], [0, 0, 1], [1, 0, 0], [0, 1, 0], [-1, 1, 1]]\n
e049 = clugen(3, 5, 1000, dirs, 0, np.zeros(3), 20, 0, 0.2, proj_dist_fn=\"unif\", rng=rng(seed))\ne050 = clugen(3, 5, 1000, dirs, np.pi / 12, np.zeros(3), 20, 0, 0.2, proj_dist_fn=\"unif\", rng=rng(seed))\ne051 = clugen(3, 5, 1000, dirs, np.pi / 4, np.zeros(3), 20, 0, 0.2, proj_dist_fn=\"unif\", rng=rng(seed))\n
plot_examples_3d(\ne049, \"e049: angle_disp = 0\",\ne050, \"e050: angle_disp = \u03c0 / 12\",\ne051, \"e051: angle_disp = \u03c0 / 4\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#manipulating-the-length-of-cluster-supporting-lines","title":"Manipulating the length of cluster-supporting lines","text":""},{"location":"generated/gallery/plot_3_3d_examples/#using-the-llength-parameter","title":"Using the llength parameter","text":"
seed = 789\n
e052 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 0, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne053 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 10, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne054 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 30, 0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\n
plt = plot_examples_3d(\ne052, \"e052: llength = 0\",\ne053, \"e053: llength = 10\",\ne054, \"e054: llength = 30\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#changing-the-llength_disp-parameter-and-using-a-custom-llengths_fn-function","title":"Changing the llength_disp parameter and using a custom llengths_fn function","text":"
seed = 765\n
# Custom llengths function: line lengths tend to grow for each new cluster\ndef llen_grow_fn(nclu, llen, llenstd, rng):\nreturn llen * np.arange(nclu) + rng.normal(scale=llenstd, size=nclu)\ne055 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 15,  0.0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne056 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 15, 10.0, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\")\ne057 = clugen(3, 5, 800, [1, 0, 0], np.pi / 10, [10, 10, 10], 10,  0.1, 0.5, rng=rng(seed),\npoint_dist_fn=\"n\", llengths_fn=llen_grow_fn)\n
plt = plot_examples_3d(\ne055, \"e055: llength_disp = 0.0\",\ne056, \"e056: llength_disp = 10.0\",\ne057, \"e057: custom llengths function\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#manipulating-relative-cluster-positions","title":"Manipulating relative cluster positions","text":""},{"location":"generated/gallery/plot_3_3d_examples/#using-the-cluster_sep-parameter","title":"Using the cluster_sep parameter","text":"
seed = 765\n
e058 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [30, 10, 10], 25, 4, 3, rng=rng(seed))\ne059 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 30, 10], 25, 4, 3, rng=rng(seed))\ne060 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 30], 25, 4, 3, rng=rng(seed))\n
plt = plot_examples_3d(\ne058, \"e058: cluster_sep = [30, 10, 10]\",\ne059, \"e059: cluster_sep = [10, 30, 10]\",\ne060, \"e060: cluster_sep = [10, 10, 30]\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#changing-the-cluster_offset-parameter-and-using-a-custom-clucenters_fn-function","title":"Changing the cluster_offset parameter and using a custom clucenters_fn function","text":"
# Custom clucenters function: places clusters in a diagonal\ndef centers_diag_fn(nclu, csep, coff, rng):\nreturn np.ones((nclu, len(csep))) * np.arange(1, nclu + 1)[:, None] * np.max(csep) + coff\ne061 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed))\ne062 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed),\ncluster_offset=[30, -30, 30])\ne063 = clugen(3, 8, 1000, [1, 1, 1], np.pi / 4, [10, 10, 10], 12, 3, 2.5, rng=rng(seed),\ncluster_offset=[-40, -40, -40], clucenters_fn=centers_diag_fn)\n
plt = plot_examples_3d(\ne061, \"e061: default\",\ne062, \"e062: cluster_offset=[30, -30, 30]\",\ne063, \"e063: custom clucenters function\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#lateral-dispersion-and-placement-of-point-projections-on-the-line","title":"Lateral dispersion and placement of point projections on the line","text":""},{"location":"generated/gallery/plot_3_3d_examples/#normal-projection-placement-default-proj_dist_fnnorm","title":"Normal projection placement (default): proj_dist_fn=\"norm\"","text":"
seed = 246\n
e064 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed))\ne065 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed))\ne066 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed))\n
plt = plot_examples_3d(\ne064, \"e064: lateral_disp = 0\",\ne065, \"e065: lateral_disp = 1\",\ne066, \"e066: lateral_disp = 3\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#uniform-projection-placement-proj_dist_fnunif","title":"Uniform projection placement: proj_dist_fn=\"unif\"","text":"
seed = 246\n
e067 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne068 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne069 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed),\nproj_dist_fn=\"unif\")\n
plt = plot_examples_3d(\ne067, \"e067: lateral_disp = 0\",\ne068, \"e068: lateral_disp = 1\",\ne069, \"e069: lateral_disp = 3\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#custom-projection-placement-using-the-laplace-distribution","title":"Custom projection placement using the Laplace distribution","text":"
seed = 246\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e070 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 0.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\ne071 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 1.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\ne072 = clugen(3, 4, 1000, [1, 0, 0], np.pi / 2, [20, 20, 20], 13, 2, 3.0, rng=rng(seed),\nproj_dist_fn=proj_laplace)\n
plt = plot_examples_3d(\ne070, \"e070: lateral_disp = 0\",\ne071, \"e071: lateral_disp = 1\",\ne072, \"e072: lateral_disp = 3\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#controlling-final-point-positions-from-their-projections-on-the-cluster-supporting-line","title":"Controlling final point positions from their projections on the cluster-supporting line","text":""},{"location":"generated/gallery/plot_3_3d_examples/#points-on-hyperplane-orthogonal-to-cluster-supporting-line-default-point_dist_fnn-1","title":"Points on hyperplane orthogonal to cluster-supporting line (default): point_dist_fn=\"n-1\"","text":"
seed = 840\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e073 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed))\ne074 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\nproj_dist_fn=\"unif\")\ne075 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\nproj_dist_fn=proj_laplace)\n
plt = plot_examples_3d(\ne073, \"e073: proj_dist_fn=\\\"norm\\\" (default)\",\ne074, \"e074: proj_dist_fn=\\\"unif\\\"\",\ne075, \"e075: custom proj_dist_fn (Laplace)\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#points-around-projection-on-cluster-supporting-line-point_dist_fnn","title":"Points around projection on cluster-supporting line: point_dist_fn=\"n\"","text":"
seed = 840\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\ne076 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=\"n\")\ne077 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=\"n\", proj_dist_fn=\"unif\")\ne078 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=\"n\", proj_dist_fn=proj_laplace)\n
plt = plot_examples_3d(\ne076, \"e076: proj_dist_fn=\\\"norm\\\" (default)\",\ne077, \"e077: proj_dist_fn=\\\"unif\\\"\",\ne078, \"e078: custom proj_dist_fn (Laplace)\")\n
"},{"location":"generated/gallery/plot_3_3d_examples/#custom-point-placement-using-the-exponential-distribution","title":"Custom point placement using the exponential distribution","text":"

For this example we require the clupoints_n_1_template() helper function:

from pyclugen import clupoints_n_1_template\n
seed = 840\n
# Custom point_dist_fn: final points placed using the Exponential distribution\ndef clupoints_n_1_exp(projs, lat_std, len, clu_dir, clu_ctr, rng):\ndef dist_exp(npts, lstd, rg):\nreturn lstd * rg.exponential(scale=2 / lstd, size=npts)\nreturn clupoints_n_1_template(projs, lat_std, clu_dir, dist_exp, rng=rng)\n
# Custom proj_dist_fn: point projections placed using the Laplace distribution\ndef proj_laplace(len, n, rng):\nreturn rng.laplace(scale=len / 6, size=n)\n
e079 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp)\ne080 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp, proj_dist_fn=\"unif\")\ne081 = clugen(3, 5, 1500, [1, 0, 0], np.pi / 3, [20, 20, 20], 22, 3, 2, rng=rng(seed),\npoint_dist_fn=clupoints_n_1_exp, proj_dist_fn=proj_laplace)\n
plt = plot_examples_3d(\ne079, \"e079: proj_dist_fn=\\\"norm\\\" (default)\",\ne080, \"e080: proj_dist_fn=\\\"unif\\\"\",\ne081, \"e081: custom proj_dist_fn (Laplace)\")\n

"},{"location":"generated/gallery/plot_3_3d_examples/#manipulating-cluster-sizes","title":"Manipulating cluster sizes","text":"
seed = 555\n
# Custom clusizes_fn (e083): cluster sizes determined via the uniform distribution,\n# no correction for total points\ndef clusizes_unif(nclu, npts, ae, rng):\nreturn rng.integers(low=1, high=2 * npts / nclu + 1, size=nclu)\n
# Custom clusizes_fn (e084): clusters all have the same size, no correction for total points\ndef clusizes_equal(nclu, npts, ae, rng):\nreturn (npts // nclu) * np.ones(nclu, dtype=int)\n
# Custom clucenters_fn (all): yields fixed positions for the clusters\ndef centers_fixed(nclu, csep, coff, rng):\nreturn np.array([\n[-csep[0], -csep[1], -csep[2]],\n[csep[0], -csep[1], -csep[2]],\n[-csep[0], csep[1], csep[2]],\n[csep[0], csep[1], csep[2]]])\n
e082 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),\nclucenters_fn=centers_fixed, point_dist_fn=\"n\")\ne083 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),\nclucenters_fn=centers_fixed, clusizes_fn=clusizes_unif, point_dist_fn=\"n\")\ne084 = clugen(3, 4, 1500, [1, 1, 1], np.pi, [20, 20, 20], 0, 0, 5, rng=rng(seed),\nclucenters_fn=centers_fixed, clusizes_fn=clusizes_equal, point_dist_fn=\"n\")\n
plt = plot_examples_3d(\ne082, \"e082: normal dist. (default)\",\ne083, \"e083: unif. dist. (custom)\",\ne084, \"e084: equal size (custom)\")\n

Total running time of the script: ( 0 minutes 7.542 seconds)

Download Python source code: plot_3_3d_examples.py

Download Jupyter notebook: plot_3_3d_examples.ipynb

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/plot_4_nd_examples/","title":"Examples in nD","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_4_nd_examples/#examples-in-nd","title":"Examples in nD","text":"

This section contains several examples on how to generate nD (n > 3) data with pyclugen. To run the examples we first need to import the clugen() function:

from pyclugen import clugen\n

To make the examples exactly reproducible we'll import a random number generator from NumPy and pass it as a parameter to clugen(). We'll also create a small helper function for providing us a brand new seeded generator:

import numpy as np\nfrom numpy.random import PCG64, Generator\ndef rng(seed):\nreturn Generator(PCG64(seed))\n

To plot these examples we use the plot_examples_nd function:

from plot_functions import plot_examples_nd\n
"},{"location":"generated/gallery/plot_4_nd_examples/#5d-example-with-default-optional-arguments","title":"5D example with default optional arguments","text":"
seed = 123\n
# Number of dimensions\nnd = 5\n
e085 = clugen(nd, 6, 1500, [1, 1, 0.5, 0, 0], np.pi / 16, 30 * np.ones(nd), 30, 4, 3, rng=rng(seed))\n
plot_examples_nd(e085, \"e085: 5D with optional parameters set to defaults\")\n
"},{"location":"generated/gallery/plot_4_nd_examples/#5d-example-with-proj_dist_fn-unif-and-point_dist_fn-n","title":"5D example with proj_dist_fn = \"unif\" and point_dist_fn = \"n\"","text":"
seed = 579\n
# Number of dimensions\nnd = 5\n
e086 = clugen(nd, 6, 1500, [0.1, 0.3, 0.5, 0.3, 0.1], np.pi / 12, 30 * np.ones(nd), 35, 5, 3.5,\nproj_dist_fn=\"unif\", point_dist_fn=\"n\", rng=rng(seed))\n
plot_examples_nd(e086, \"e086: 5D with proj_dist_fn=\\\"unif\\\" and point_dist_fn=\\\"n\\\"\")\n
"},{"location":"generated/gallery/plot_4_nd_examples/#4d-example-with-custom-projection-placement-using-the-beta-distribution","title":"4D example with custom projection placement using the Beta distribution","text":"
seed = 963\n
# Number of dimensions\nnd = 4\n
# Custom proj_dist_fn: point projections placed using the Beta distribution\ndef proj_beta(len, n, rng):\nreturn len * rng.beta(0.1, 0.1, size=n) - len / 2\n
e087 = clugen(nd, 5, 1500, np.ones(nd), np.pi / 6, 30 * np.ones(nd), 60, 15, 6, rng=rng(seed),\nproj_dist_fn=proj_beta)\n
plot_examples_nd(e087, \"e087: 4D with custom proj_dist_fn (Beta)\")\n

Total running time of the script: ( 0 minutes 15.867 seconds)

Download Python source code: plot_4_nd_examples.py

Download Jupyter notebook: plot_4_nd_examples.ipynb

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/plot_5_mrg_examples/","title":"Merging and hierarchical cluster examples","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_5_mrg_examples/#merging-and-hierarchical-cluster-examples","title":"Merging and hierarchical cluster examples","text":"

This section contains several examples on how to merge cluster data, either generated with pyclugen or from other sources. To run the examples we first need to import the clugen() and clugen() functions:

from pyclugen import clugen, clumerge\n

To make the examples exactly reproducible we'll import a random number generator from NumPy and pass it as a parameter to clugen(). We'll also create a small helper function for providing us a brand new seeded generator:

import numpy as np\nfrom numpy.random import PCG64, Generator\ndef rng(seed):\nreturn Generator(PCG64(seed))\n

Although it is possible to merge data in any dimension, these examples will focus on merging 2D data. Therefore, we'll use the same plot_examples_2d function used for the 2D examples:

from plot_functions import plot_examples_2d\n
"},{"location":"generated/gallery/plot_5_mrg_examples/#merging-two-data-sets-generated-with-clugen","title":"Merging two data sets generated with clugen()","text":"
seed1 = 444\nseed2 = 555\n
e088 = clugen(2, 5, 1000, [1, 1], np.pi / 12, [20, 20], 14, 1.2, 1.5, rng=rng(seed1),\nproj_dist_fn=\"unif\", point_dist_fn=\"n\")\ne089 = clugen(2, 3, 1500, [1, 0], 0.05, [20, 20], 0, 0, 4, rng=rng(seed2),\npoint_dist_fn=\"n\", cluster_offset = [20, 0])\ne090 = clumerge(e088, e089)\n
plot_examples_2d(\ne088, \"e088: data set 1\",\ne089, \"e089: data set 2\",\ne090, \"e090: merged data sets\")\n

In the previous example, clusters from individual data sets remain as separate clusters in the merged data set. It's also possible to maintain the original cluster labels by setting the clusters_field parameter to None:

e091 = clumerge(e088, e089, clusters_field=None)\n
plot_examples_2d(\ne088, \"e088: data set 1\",\ne089, \"e089: data set 2\",\ne091, \"e091: merged data sets\")\n

"},{"location":"generated/gallery/plot_5_mrg_examples/#adding-noise-to-a-clugen-generated-data-set","title":"Adding noise to a clugen()-generated data set","text":"
seed = 333\n
prng = rng(seed)\ne092 = {\"points\": 120 * prng.random((500, 2)) - 60, \"clusters\": np.ones(500, dtype=np.int32)}\ne093 = clumerge(e092, e090) # clumerge(e092, e088, e089) would also work\n
plot_examples_2d(\ne090, \"e090: original merged data sets\",\ne092, \"e092: random uniform noise\",\ne093, \"e093: data sets with noise\",\npmargin=0)\n
"},{"location":"generated/gallery/plot_5_mrg_examples/#merging-with-data-not-generated-with-clugen","title":"Merging with data not generated with clugen()","text":"

Data generated with clugen() can be merged with other data sets, for example data created with one of scikit-learn's generators:

seed = 321\n
from sklearn.datasets import make_moons\nX, y = make_moons(100, noise=0.05, random_state=seed)\ne094 = {\"points\": X, \"clusters\": y}\ne095 = clugen(2, 4, 200, [1, 1], np.pi / 12, [1, 1], 0.1, 0.01, 0.25, rng=rng(seed),\nproj_dist_fn = \"unif\", point_dist_fn = \"n\")\ne096 = clumerge(e094, e095)\n
plt = plot_examples_2d(\ne094, \"e094: generated w/ make_moons()\",\ne095, \"e095: generated w/ clugen()\",\ne096, \"e096: merged data\")\n

We can also hierarchize clusters from different sources:

e097 = {**e094, \"hclusters\": np.ones(100, dtype=np.int32)}\ne098 = {**e095._asdict(), \"hclusters\": 2 * np.ones(200, np.int32)}\ne099 = clumerge(e097, e098, clusters_field=\"hclusters\")\n
plt = plot_examples_2d(\ne097, \"e097: generated w/ make_moons()\",\ne098, \"e098: generated w/ clugen()\",\ne099, \"e099: merged data\",\nclusters_field=\"hclusters\")\n

Total running time of the script: ( 0 minutes 6.215 seconds)

Download Python source code: plot_5_mrg_examples.py

Download Jupyter notebook: plot_5_mrg_examples.ipynb

Gallery generated by mkdocs-gallery

"},{"location":"generated/gallery/plot_functions/","title":"Plot functions","text":"

Note

Click here to download the full example code

"},{"location":"generated/gallery/plot_functions/#plot-functions","title":"Plot functions","text":"

Several auxiliary functions for plotting the examples in this documentation.

"},{"location":"generated/gallery/plot_functions/#import-the-required-libraries","title":"Import the required libraries","text":"
import os\nimport warnings\nimport matplotlib.pyplot as plt  # type: ignore\nimport numpy as np\nimport numpy.typing as npt\nimport pandas as pd\nimport seaborn as sns  # type: ignore\nfrom pyclugen import Clusters\n# Hide annoying warnings when building docs in CI\nif os.getenv(\"CI\") != None:\nwarnings.filterwarnings(\"ignore\")\n
"},{"location":"generated/gallery/plot_functions/#clusters2df","title":"clusters2df","text":"
def clusters2df(\n*exs: Clusters | dict[str, npt.ArrayLike], clusters_field: str = \"clusters\"\n) -> pd.DataFrame:\n\"\"\"Convert a sequence of clusters to a Pandas dataframe.\"\"\"\ndfs = []\niex = 1\nfor ex in exs:\nif isinstance(ex, dict):\npoints = ex[\"points\"]\nclusters = ex[clusters_field]\nelse:\npoints = ex.points\nclusters = ex.clusters\ndf = pd.DataFrame(\ndata=points, columns=[f\"x{i}\" for i in range(np.size(points, 1))]\n)\ndf[\"cluster\"] = clusters.tolist()\ndf[\"example\"] = [iex] * clusters.size\ndfs.append(df)\niex += 1\nreturn pd.concat(dfs, ignore_index=True)\n
"},{"location":"generated/gallery/plot_functions/#get_plot_lims","title":"get_plot_lims","text":"
def get_plot_lims(df: pd.DataFrame, pmargin: float = 0.1):\n\"\"\"Determine the plot limits for the cluster data given in `df`.\"\"\"\n# Get maximum and minimum points in each dimension\nxmaxs = df.iloc[:, :-2].max()\nxmins = df.iloc[:, :-2].min()\n# Determine plot centers in each dimension\nxcenters = (xmaxs + xmins) / 2\n# Determine plots span for all dimensions\nsidespan = (1 + pmargin) * np.max(np.abs(xmaxs - xmins)) / 2\n# Determine final plots limits\nxmaxs = xcenters + sidespan\nxmins = xcenters - sidespan\nreturn xmaxs, xmins\n
"},{"location":"generated/gallery/plot_functions/#plot_examples_1d","title":"plot_examples_1d","text":"
def plot_examples_1d(*ets, ncols: int = 3, clusters_field: str = \"clusters\"):\n\"\"\"Plot the 1D examples given in the ets parameter.\"\"\"\n# Get examples\nex = ets[0::2]\n# Get titles\net = ets[1::2]\ndf = clusters2df(*ex, clusters_field=clusters_field)\n# Set seaborn's dark grid style\nsns.set_theme(style=\"darkgrid\")\n# Use seaborn to create the plots\ng = sns.FacetGrid(df, col=\"example\", hue=\"cluster\", col_wrap=ncols)\n# Plot the kernel density estimation plots\ng.map(sns.kdeplot, \"x0\", multiple=\"layer\", fill=True)\n# Get a flattened view of the axes array\ng_axes = g.axes.reshape(-1)\n# Determine the height of the rugs in the rug plot to 5% of total height\nrug_height = g_axes[0].get_ylim()[1] * 0.05\n# Plot the rug markers below the kde plots\ng.map(sns.rugplot, \"x0\", height=rug_height)\n# Set titles\nfor ax, t in zip(g_axes, et):\nax.set_title(t)\n
"},{"location":"generated/gallery/plot_functions/#plot_examples_2d","title":"plot_examples_2d","text":"
def plot_examples_2d(\n*ets, pmargin: float = 0.1, ncols: int = 3, clusters_field: str = \"clusters\"\n):\n\"\"\"Plot the 2D examples given in the ets parameter.\"\"\"\n# Get examples\nex = ets[0::2]\n# Get titles\net = ets[1::2]\ndf = clusters2df(*ex, clusters_field=clusters_field)\n# Get limits in each dimension\nxmaxs, xmins = get_plot_lims(df, pmargin=pmargin)\n# Set seaborn's dark grid style\nsns.set_theme(style=\"darkgrid\")\n# Use seaborn to create the plots\ng = sns.FacetGrid(\ndf,\ncol=\"example\",\nhue=\"cluster\",\nxlim=(xmins.iloc[0], xmaxs.iloc[0]),\nylim=(xmins.iloc[1], xmaxs.iloc[1]),\naspect=1,\ncol_wrap=ncols,\n)\ng.map(sns.scatterplot, \"x0\", \"x1\", s=10)\n# Set the plot titles and x, y labels\nfor ax, t in zip(g.axes, et):\nax.set_title(t)\nax.set_xlabel(\"x\")\nax.set_ylabel(\"y\")\n
"},{"location":"generated/gallery/plot_functions/#plot_examples_3d","title":"plot_examples_3d","text":"
def plot_examples_3d(\n*ets,\npmargin: float = 0.1,\nncols: int = 3,\nside=350,\nclusters_field: str = \"clusters\",\n):\n\"\"\"Plot the 3D examples given in the ets parameter.\"\"\"\n# Get examples\nex = ets[0::2]\n# Get titles\net = ets[1::2]\n# Number of plots and number of rows in combined plot\nnum_plots = len(ex)\nnrows = max(1, int(np.ceil(num_plots / ncols)))\nblank_plots = nrows * ncols - num_plots\ndf = clusters2df(*ex, clusters_field=clusters_field)\n# Get limits in each dimension\nxmaxs, xmins = get_plot_lims(df, pmargin=pmargin)\n# Reset to default Matplotlib style, to avoid seaborn interference\nsns.reset_orig()\n# To convert inches to pixels afterwards\npx = 1 / plt.rcParams[\"figure.dpi\"]  # pixel in inches\n# Use Matplotlib to create the plots\n_, axs = plt.subplots(\nnrows,\nncols,\nfigsize=(side * px * ncols, side * px * nrows),\nsubplot_kw=dict(projection=\"3d\"),\n)\naxs = axs.reshape(-1)\nfor ax, e, t in zip(axs, ex, et):\nax.set_title(t, fontsize=10)\nax.set_xlim(xmins.iloc[0], xmaxs.iloc[0])\nax.set_ylim(xmins.iloc[1], xmaxs.iloc[1])\nax.set_zlim(xmins.iloc[2], xmaxs.iloc[2])\nax.set_xlabel(\"$x$\", labelpad=-2)\nax.set_ylabel(\"$y$\", labelpad=-2)\nax.set_zlabel(\"$z$\", labelpad=-2)\nax.tick_params(labelsize=8, pad=-2)\nax.scatter(\ne.points[:, 0],\ne.points[:, 1],\ne.points[:, 2],\nc=e.clusters,\ndepthshade=False,\nedgecolor=\"black\",\nlinewidths=0.2,\n)\n# Remaining plots are left blank\nfor ax in axs[len(ex) : len(ex) + blank_plots]:\nax.set_axis_off()\nax.set_facecolor(color=\"white\")\nax.patch.set_alpha(0)\n
"},{"location":"generated/gallery/plot_functions/#plot_examples_nd","title":"plot_examples_nd","text":"
def plot_examples_nd(\nex: Clusters, t: str, pmargin: float = 0.1, clusters_field: str = \"clusters\"\n):\n\"\"\"Plot the nD example given in the ex parameter.\"\"\"\n# How many dimensions?\nnd = ex.points.shape[1]\ndf = clusters2df(ex, clusters_field=clusters_field)\n# Get limits in each dimension\nxmaxs, xmins = get_plot_lims(df, pmargin=pmargin)\n# Set seaborn's dark grid style\nsns.set_theme(style=\"darkgrid\")\n# Create pairwise plots with nothing on the diagonal\ng = sns.PairGrid(df.iloc[:, :-1], hue=\"cluster\", palette=\"deep\")\ng.map_offdiag(sns.scatterplot, s=10)\ng.figure.suptitle(t, y=1)\n# Decorate plot\nfor i in range(nd):\nfor j in range(nd):\nif i == j:\n# Set the x labels in the diagonal plots\nxycoord = (xmaxs.iloc[i] + xmins.iloc[i]) / 2\ng.axes[i, i].text(\nxycoord, xycoord, f\"$x{i}$\", fontsize=20, ha=\"center\", va=\"center\"\n)\nelse:\n# Set appropriate plot intervals and aspect ratio\ng.axes[i, j].set_xlim([xmins.iloc[j], xmaxs.iloc[j]])\ng.axes[i, j].set_ylim([xmins.iloc[i], xmaxs.iloc[i]])\ng.axes[i, j].set_aspect(1)\n

Total running time of the script: ( 0 minutes 0.007 seconds)

Download Python source code: plot_functions.py

Download Jupyter notebook: plot_functions.ipynb

Gallery generated by mkdocs-gallery

"}]} \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz index abd90bdeab91a4c3470dd66ee6ac9c03f39d56ac..daf9690ca9851c69a84e66ca03c948fe77b03973 100644 GIT binary patch delta 15 WcmdnYw3&%bzMF%?dB;XJT}A*S1q2HK delta 15 WcmdnYw3&%bzMF$%$C{07x{LrNhXiy0