marsilea 0.4.0__py3-none-any.whl → 0.4.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
marsilea/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Declarative creation of composable visualization"""
2
2
 
3
- __version__ = "0.4.0"
3
+ __version__ = "0.4.2"
4
4
 
5
5
  import marsilea.plotter as plotter
6
6
  from ._deform import Deformation
marsilea/base.py CHANGED
@@ -15,7 +15,7 @@ from matplotlib.figure import Figure
15
15
 
16
16
  from ._deform import Deformation
17
17
  from .dendrogram import Dendrogram
18
- from .exceptions import SplitTwice
18
+ from .exceptions import SplitTwice, DuplicatePlotter
19
19
  from .layout import CrossLayout, CompositeCrossLayout
20
20
  from .plotter import RenderPlan, Title, SizedMesh
21
21
  from .utils import pairwise, batched, get_plot_name, _check_side
@@ -332,6 +332,8 @@ class WhiteBoard(LegendMaker):
332
332
  If True, the legend will be included when calling :meth:`~marsilea.base.LegendMaker.add_legends`
333
333
 
334
334
  """
335
+ if plot.name is not None:
336
+ raise DuplicatePlotter(plot)
335
337
  plot_name = get_plot_name(name, side, plot.__class__.__name__)
336
338
  self._legend_switch[plot_name] = legend
337
339
 
@@ -821,6 +823,9 @@ class ClusterBoard(WhiteBoard):
821
823
  )
822
824
  self._row_den = []
823
825
  self._col_den = []
826
+ cluster_data = np.asarray(cluster_data)
827
+ if cluster_data.ndim != 2:
828
+ raise ValueError("Cluster data must be 2D array")
824
829
  self._cluster_data = cluster_data
825
830
  self._deform = Deformation(cluster_data)
826
831
 
@@ -1043,7 +1048,8 @@ class ClusterBoard(WhiteBoard):
1043
1048
  warnings.warn(
1044
1049
  DeprecationWarning(
1045
1050
  "`hsplit` will be deprecated in v0.5.0, use `cut_rows` or `group_rows` instead"
1046
- )
1051
+ ),
1052
+ stacklevel=2,
1047
1053
  )
1048
1054
  if self._split_row:
1049
1055
  raise SplitTwice(axis="horizontally")
@@ -1110,7 +1116,8 @@ class ClusterBoard(WhiteBoard):
1110
1116
  warnings.warn(
1111
1117
  DeprecationWarning(
1112
1118
  "`vsplit` will be deprecated in v0.5.0, use `cut_cols` or `group_cols` instead"
1113
- )
1119
+ ),
1120
+ stacklevel=2,
1114
1121
  )
1115
1122
  if self._split_col:
1116
1123
  raise SplitTwice(axis="vertically")
@@ -1295,20 +1302,20 @@ class ClusterBoard(WhiteBoard):
1295
1302
  if deform.is_col_split:
1296
1303
  for plan in self._col_plan:
1297
1304
  if plan.allow_split:
1298
- if deform.is_col_cluster:
1299
- group_ratios = None
1300
- else:
1301
- group_ratios = plan.get_split_regroup()
1305
+ # if deform.is_col_cluster:
1306
+ # group_ratios = None
1307
+ # else:
1308
+ group_ratios = plan.get_split_regroup()
1302
1309
  self.layout.vsplit(plan.name, w_ratios, wspace, group_ratios)
1303
1310
 
1304
1311
  # split row axes
1305
1312
  if deform.is_row_split:
1306
1313
  for plan in self._row_plan:
1307
1314
  if plan.allow_split:
1308
- if deform.is_row_cluster:
1309
- group_ratios = None
1310
- else:
1311
- group_ratios = plan.get_split_regroup()
1315
+ # if deform.is_row_cluster:
1316
+ # group_ratios = None
1317
+ # else:
1318
+ group_ratios = plan.get_split_regroup()
1312
1319
  self.layout.hsplit(plan.name, h_ratios, hspace, group_ratios)
1313
1320
 
1314
1321
  def _render_dendrogram(self):
marsilea/exceptions.py CHANGED
@@ -6,6 +6,18 @@ class DuplicateName(Exception):
6
6
  return f"Axes with name `{self.name}` already exists."
7
7
 
8
8
 
9
+ class DuplicatePlotter(Exception):
10
+
11
+ def __init__(self, plotter):
12
+ self.plotter = plotter
13
+
14
+ def __str__(self):
15
+ name = self.plotter.__class__.__name__
16
+ return (f"You have added `{name}` "
17
+ f"to the `{self.plotter.side}`, "
18
+ f"please create a new `{name}` if you want to add it again.")
19
+
20
+
9
21
  class SplitTwice(Exception):
10
22
  def __init__(self, axis="col"):
11
23
  self.axis = axis
marsilea/plotter/base.py CHANGED
@@ -538,6 +538,10 @@ class RenderPlan:
538
538
  self._split_regroup = ratio
539
539
 
540
540
  def get_split_regroup(self):
541
+ if self._split_regroup is None:
542
+ return None
543
+ if self.is_flank:
544
+ return self._split_regroup[::-1]
541
545
  return self._split_regroup
542
546
 
543
547
 
marsilea/plotter/mesh.py CHANGED
@@ -357,7 +357,7 @@ class Colors(MeshBase):
357
357
  self.palette = palette
358
358
 
359
359
  self.render_cmap = ListedColormap(render_colors)
360
- self.vmax = len(render_colors)
360
+ self.vmax = len(render_colors) - 1
361
361
  # Encode data into cmap range
362
362
  encode_data = encode_numeric(data, encoder)
363
363
  self.set_data(_mask_data(encode_data, mask=mask))
marsilea/utils.py CHANGED
@@ -69,12 +69,13 @@ def relative_luminance(color):
69
69
 
70
70
 
71
71
  def get_colormap(cmap):
72
- if isinstance(cmap, Colormap):
73
- return cmap
74
72
  try:
75
- return mpl.colormap.get(cmap)
73
+ return mpl.cm.ColormapRegistry.get_cmap(cmap)
76
74
  except AttributeError:
77
- return mpl.cm.get_cmap(cmap)
75
+ try:
76
+ return mpl.colormaps.get(cmap)
77
+ except AttributeError:
78
+ return mpl.cm.get_cmap(cmap)
78
79
 
79
80
 
80
81
  def get_canvas_size_by_data(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: marsilea
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: Declarative creation of composable visualization
5
5
  Author: Zhihang Zheng
6
6
  Author-email: Mr-Milk <yzheng@cemm.at>
@@ -1,15 +1,15 @@
1
- marsilea/__init__.py,sha256=6yq4oaMr8fCKXwXWnyZ-mKf2-HU-P_1yQgmPJViUIaU,541
1
+ marsilea/__init__.py,sha256=d0Ly-YfvxU50ILe2FqnmpvcnSg6XwCHVIh1LRIqQfNE,541
2
2
  marsilea/_api.py,sha256=tymWZHfjhx8-0NNd9762znfdIu36NrARRweEIr5L1mA,283
3
3
  marsilea/_deform.py,sha256=SKXLvhyUrwTRAw7Fl--OpupDLk6T3S5DRfwCAdewHQs,14138
4
- marsilea/base.py,sha256=ouHt55C_KbeN_R6p6-I0_F3CDv5LSOtW9IKVd9mvbVo,46341
4
+ marsilea/base.py,sha256=HSY25Ax39Vj80FxSZkg4es0YklNtFJ_DgfQzbFIJseI,46637
5
5
  marsilea/dataset.py,sha256=a0mXjPu9_tRGHofnnQaTryFpxftkfqldq_ZLXMSBf7A,4410
6
6
  marsilea/dendrogram.py,sha256=WUnV2JMSY9mPt1sfkFAEikkl2ta7xHFD13teas_iZgE,14767
7
- marsilea/exceptions.py,sha256=Wxy31eCWkoXTPwqaa7R5F7cJ3uCtzqhJXmxVqqX8eAA,661
7
+ marsilea/exceptions.py,sha256=kIXDRF8Fy-BkNqeMbLqde06PaWESuKiGCMGyDpVpWIE,1006
8
8
  marsilea/heatmap.py,sha256=lKGt0lTtziNFDsb_SBfFt3zoYzVYRzezc9aae5RxHyk,4168
9
9
  marsilea/layers.py,sha256=puXLlGGpEqAzaTqadpgpsYmIDPH33WyyHIuysRSqFZQ,12163
10
10
  marsilea/layout.py,sha256=X8MGPlAbbr7dcZiqW4pI7sEb8U3jVaiS7t1DKOqMYLI,27758
11
11
  marsilea/upset.py,sha256=U1Rsmo1WpCAV9z3LBlE2L4T0nAW9ols8Z36fXzmXycw,30388
12
- marsilea/utils.py,sha256=IaAaOBdE668XuGiA-k_gmOtHYqfpIxPv_-molMSBPfs,2851
12
+ marsilea/utils.py,sha256=LJ7U0aVw_Ru45DXo4x5zi1FEjjIKt4j0mpdDY34wiNA,2903
13
13
  marsilea/plotter/__init__.py,sha256=n1E53C5oqnsHZcXAtN6HgZsZdcAvANONNx-fupTxzN0,738
14
14
  marsilea/plotter/_images.py,sha256=RWCI4FhcxJZimLrhdy9CHw3ri1kweGRICUyByE4wzmg,3065
15
15
  marsilea/plotter/_seaborn.py,sha256=aK0EnboshfNCNvNjsIc7dxDE_4KBKi4HMUt7CKWt_6U,8188
@@ -17,11 +17,11 @@ marsilea/plotter/_utils.py,sha256=Efhdk-TrrAanhbXRiEVWThMYvZ4vVHZMVYMs5X3JvIM,71
17
17
  marsilea/plotter/arc.py,sha256=PFXlJ0TBIJ1mEB-lIl-Zs2UdEXkLSwDlRJbsSa5Ss5U,8165
18
18
  marsilea/plotter/area.py,sha256=zjjAhvgKHYe9rqzcseqZqhwfpgvzm0w2FRJ_vr9Fxm4,2650
19
19
  marsilea/plotter/bar.py,sha256=TeX6li--kE9NtqCRflDTX0jkG1-uIq0Dn8ILKSv-AuA,12080
20
- marsilea/plotter/base.py,sha256=0UiJqNefv9mieMB0ICpKQ2rXqGaFYigqyxQe4BzBP24,20321
20
+ marsilea/plotter/base.py,sha256=NgaoFnbMS6Mj4BghVcGaSYYN8A9e3DD_rRomDIm4C5c,20456
21
21
  marsilea/plotter/bio.py,sha256=_pZkGoAei7eirFCpu7AcZJhebBneNjUKcZlI36bpqUE,5044
22
- marsilea/plotter/mesh.py,sha256=ArioOXZJpD1T2wrYDmm_cFQpUmq_3q7W_qrJ_zCX3zU,23793
22
+ marsilea/plotter/mesh.py,sha256=YY6aq62QS1HyTeIWF79rpIJUUQTOxWXx3LZ7oZXYlzU,23797
23
23
  marsilea/plotter/text.py,sha256=oYJ5py3_nGHKi60DSVzFgPg4drnTSTw__IcYs0cut4M,36222
24
- marsilea-0.4.0.dist-info/LICENSE,sha256=2TLD8FnLJqXzg8YBRs7W3VZBwfWfp4ArDfBl-rn96Qc,1074
25
- marsilea-0.4.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
26
- marsilea-0.4.0.dist-info/METADATA,sha256=1D7C_hcPfQ1nGkNOVnLkqg04gsumrAsjU4nf5U4pZaU,4074
27
- marsilea-0.4.0.dist-info/RECORD,,
24
+ marsilea-0.4.2.dist-info/LICENSE,sha256=2TLD8FnLJqXzg8YBRs7W3VZBwfWfp4ArDfBl-rn96Qc,1074
25
+ marsilea-0.4.2.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
26
+ marsilea-0.4.2.dist-info/METADATA,sha256=3H95A_-TertDPICUSKoJECa8Hf29atnkEYs28p00lLE,4074
27
+ marsilea-0.4.2.dist-info/RECORD,,