modusa 0.3.30__py3-none-any.whl → 0.3.41__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.
- modusa/fonts/NotoSansDevanagari-Regular.ttf +0 -0
- modusa/tools/plotter.py +59 -13
- {modusa-0.3.30.dist-info → modusa-0.3.41.dist-info}/METADATA +1 -1
- {modusa-0.3.30.dist-info → modusa-0.3.41.dist-info}/RECORD +7 -6
- {modusa-0.3.30.dist-info → modusa-0.3.41.dist-info}/WHEEL +0 -0
- {modusa-0.3.30.dist-info → modusa-0.3.41.dist-info}/entry_points.txt +0 -0
- {modusa-0.3.30.dist-info → modusa-0.3.41.dist-info}/licenses/LICENSE.md +0 -0
| Binary file | 
    
        modusa/tools/plotter.py
    CHANGED
    
    | @@ -25,9 +25,31 @@ def _calculate_extent(x, y): | |
| 25 25 | 
             
            		y[0] - dy / 2,
         | 
| 26 26 | 
             
            		y[-1] + dy / 2
         | 
| 27 27 | 
             
            	]
         | 
| 28 | 
            +
            	
         | 
| 29 | 
            +
            # Helper to load fonts (devnagri)
         | 
| 30 | 
            +
            def set_default_hindi_font():
         | 
| 31 | 
            +
            	"""
         | 
| 32 | 
            +
            	Hindi fonts works for both english and hindi.
         | 
| 33 | 
            +
            	"""
         | 
| 34 | 
            +
            	from pathlib import Path
         | 
| 35 | 
            +
            	import matplotlib as mpl
         | 
| 36 | 
            +
            	import matplotlib.font_manager as fm
         | 
| 37 | 
            +
            	# Path to your bundled font
         | 
| 38 | 
            +
            	font_path = Path(__file__).resolve().parents[1] / "fonts" / "NotoSansDevanagari-Regular.ttf"
         | 
| 39 | 
            +
            	
         | 
| 40 | 
            +
            	# Register the font with matplotlib
         | 
| 41 | 
            +
            	fm.fontManager.addfont(str(font_path))
         | 
| 42 | 
            +
            	
         | 
| 43 | 
            +
            	# Get the font family name from the file
         | 
| 44 | 
            +
            	hindi_font = fm.FontProperties(fname=str(font_path))
         | 
| 45 | 
            +
            	
         | 
| 46 | 
            +
            	# Set as default rcParam
         | 
| 47 | 
            +
            	mpl.rcParams['font.family'] = hindi_font.get_name()
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            set_default_hindi_font()
         | 
| 28 50 |  | 
| 29 51 | 
             
            #======== 1D ===========
         | 
| 30 | 
            -
            def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, legend=None, show_grid=False, show_stem=False):
         | 
| 52 | 
            +
            def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylabel=None, title=None, legend=None, fmt=None, show_grid=False, show_stem=False):
         | 
| 31 53 | 
             
            		"""
         | 
| 32 54 | 
             
            		Plots a 1D signal using matplotlib.
         | 
| 33 55 |  | 
| @@ -72,6 +94,9 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab | |
| 72 94 | 
             
            		legend : list[str] | None
         | 
| 73 95 | 
             
            			- List of legend labels corresponding to each signal if plotting multiple lines.
         | 
| 74 96 | 
             
            			- Default: None
         | 
| 97 | 
            +
            		fmt: list[str] | None
         | 
| 98 | 
            +
            			- linefmt for different line plots.
         | 
| 99 | 
            +
            			- Default: None
         | 
| 75 100 | 
             
            		show_grid: bool
         | 
| 76 101 | 
             
            			- If you want to show the grid.
         | 
| 77 102 | 
             
            			- Default: False
         | 
| @@ -84,21 +109,24 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab | |
| 84 109 | 
             
            		plt.Figure
         | 
| 85 110 | 
             
            			Matplolib figure.
         | 
| 86 111 | 
             
            		"""
         | 
| 87 | 
            -
             | 
| 88 112 | 
             
            		for arg in args:
         | 
| 89 113 | 
             
            			if len(arg) not in [1, 2]: # 1 if it just provides values, 2 if it provided axis as well
         | 
| 90 114 | 
             
            				raise ValueError(f"1D signal needs to have max 2 arrays (y, x) or simply (y, )")
         | 
| 91 115 |  | 
| 92 116 | 
             
            		if isinstance(legend, str): legend = (legend, )
         | 
| 93 | 
            -
            		
         | 
| 94 117 | 
             
            		if legend is not None:
         | 
| 95 118 | 
             
            			if len(legend) < len(args):
         | 
| 96 | 
            -
            				raise ValueError(f" | 
| 119 | 
            +
            				raise ValueError(f"`legend` should be provided for each signal.")
         | 
| 120 | 
            +
            		
         | 
| 121 | 
            +
            		if isinstance(fmt, str): fmt = [fmt]
         | 
| 122 | 
            +
            		if fmt is not None:
         | 
| 123 | 
            +
            			if len(fmt) < len(args):
         | 
| 124 | 
            +
            				raise ValueError(f"`fmt` should be provided for each signal.")
         | 
| 125 | 
            +
             | 
| 126 | 
            +
            		colors = plt.get_cmap('tab10').colors
         | 
| 97 127 |  | 
| 98 128 | 
             
            		fig = plt.figure(figsize=(16, 2))
         | 
| 99 129 | 
             
            		gs = gridspec.GridSpec(2, 1, height_ratios=[0.2, 1])
         | 
| 100 | 
            -
            			
         | 
| 101 | 
            -
            		colors = plt.get_cmap('tab10').colors
         | 
| 102 130 |  | 
| 103 131 | 
             
            		signal_ax = fig.add_subplot(gs[1, 0])
         | 
| 104 132 | 
             
            		annotation_ax = fig.add_subplot(gs[0, 0], sharex=signal_ax)
         | 
| @@ -109,7 +137,6 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab | |
| 109 137 |  | 
| 110 138 | 
             
            		if ylim is not None:
         | 
| 111 139 | 
             
            			signal_ax.set_ylim(ylim)
         | 
| 112 | 
            -
            		
         | 
| 113 140 |  | 
| 114 141 | 
             
            		# Add signal plot
         | 
| 115 142 | 
             
            		for i, signal in enumerate(args):
         | 
| @@ -123,7 +150,10 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab | |
| 123 150 | 
             
            						stemlines.set_color(colors[i])
         | 
| 124 151 | 
             
            						baseline.set_color("k")
         | 
| 125 152 | 
             
            					else:
         | 
| 126 | 
            -
            						 | 
| 153 | 
            +
            						if fmt is not None:
         | 
| 154 | 
            +
            							signal_ax.plot(x, y, fmt[i], markersize=4, label=legend[i])
         | 
| 155 | 
            +
            						else:
         | 
| 156 | 
            +
            							signal_ax.plot(x, y, color=colors[i], label=legend[i])
         | 
| 127 157 | 
             
            				else:
         | 
| 128 158 | 
             
            					if show_stem is True:
         | 
| 129 159 | 
             
            						markerline, stemlines, baseline = signal_ax.stem(x, y)
         | 
| @@ -131,20 +161,36 @@ def plot1d(*args, ann=None, events=None, xlim=None, ylim=None, xlabel=None, ylab | |
| 131 161 | 
             
            						stemlines.set_color(colors[i])
         | 
| 132 162 | 
             
            						baseline.set_color("k")
         | 
| 133 163 | 
             
            					else:
         | 
| 134 | 
            -
            						 | 
| 164 | 
            +
            						if fmt is not None:
         | 
| 165 | 
            +
            							signal_ax.plot(x, y, fmt[i], markersize=4)
         | 
| 166 | 
            +
            						else:
         | 
| 167 | 
            +
            							signal_ax.plot(x, y, color=colors[i])
         | 
| 135 168 |  | 
| 136 169 | 
             
            			elif len(signal) == 2:
         | 
| 137 170 | 
             
            				y, x = signal[0], signal[1]
         | 
| 138 171 | 
             
            				if legend is not None:
         | 
| 139 172 | 
             
            					if show_stem is True:
         | 
| 140 | 
            -
            						signal_ax.stem(x, y,  | 
| 173 | 
            +
            						markerline, stemlines, baseline = signal_ax.stem(x, y, label=legend[i])
         | 
| 174 | 
            +
            						markerline.set_color(colors[i])
         | 
| 175 | 
            +
            						stemlines.set_color(colors[i])
         | 
| 176 | 
            +
            						baseline.set_color("k")
         | 
| 141 177 | 
             
            					else:
         | 
| 142 | 
            -
            						 | 
| 178 | 
            +
            						if fmt is not None:
         | 
| 179 | 
            +
            							signal_ax.plot(x, y, fmt[i], markersize=4, label=legend[i])
         | 
| 180 | 
            +
            						else:
         | 
| 181 | 
            +
            							signal_ax.plot(x, y, color=colors[i], label=legend[i])
         | 
| 143 182 | 
             
            				else:
         | 
| 144 183 | 
             
            					if show_stem is True:
         | 
| 145 | 
            -
            						signal_ax.stem(x, y | 
| 184 | 
            +
            						markerline, stemlines, baseline = signal_ax.stem(x, y)
         | 
| 185 | 
            +
            						markerline.set_color(colors[i])
         | 
| 186 | 
            +
            						stemlines.set_color(colors[i])
         | 
| 187 | 
            +
            						baseline.set_color("k")
         | 
| 146 188 | 
             
            					else:
         | 
| 147 | 
            -
            						 | 
| 189 | 
            +
            						if fmt is not None:
         | 
| 190 | 
            +
            							signal_ax.plot(x, y, fmt[i], markersize=4)
         | 
| 191 | 
            +
            						else:
         | 
| 192 | 
            +
            							signal_ax.plot(x, y, color=colors[i])
         | 
| 193 | 
            +
            							
         | 
| 148 194 |  | 
| 149 195 | 
             
            		# Add annotations
         | 
| 150 196 | 
             
            		if ann is not None:
         | 
| @@ -1,7 +1,7 @@ | |
| 1 | 
            -
            modusa-0.3. | 
| 2 | 
            -
            modusa-0.3. | 
| 3 | 
            -
            modusa-0.3. | 
| 4 | 
            -
            modusa-0.3. | 
| 1 | 
            +
            modusa-0.3.41.dist-info/METADATA,sha256=h6zQe0lZ2sqn5JHLbqAw9wqexEXjWW28gNqmXV8OdCk,1369
         | 
| 2 | 
            +
            modusa-0.3.41.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
         | 
| 3 | 
            +
            modusa-0.3.41.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
         | 
| 4 | 
            +
            modusa-0.3.41.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
         | 
| 5 5 | 
             
            modusa/.DS_Store,sha256=_gm6qJREwfMi8dE7n5S89_RG46u5t3xHyD-smNhtNoM,6148
         | 
| 6 6 | 
             
            modusa/__init__.py,sha256=uq6kORFFAODiCMGmOLWO0shE8-dVFWf5gmV8wxekmnk,280
         | 
| 7 7 | 
             
            modusa/config.py,sha256=bTqK4t00FZqERVITrxW_q284aDDJAa9aMSfFknfR-oU,280
         | 
| @@ -17,6 +17,7 @@ modusa/devtools/templates/model.py,sha256=iwmXadLMA4IAMgOEktdCWKZsceLgaaZkTWcJHq | |
| 17 17 | 
             
            modusa/devtools/templates/plugin.py,sha256=MWqrxBxfRKVw2zjEgfAG0RYUAMjuazhqC5PXIb0gJi4,868
         | 
| 18 18 | 
             
            modusa/devtools/templates/test.py,sha256=CjZ_oqwJFhltNYzqfK1pcz1ShgeJXZLOnYpmOawfASs,244
         | 
| 19 19 | 
             
            modusa/devtools/templates/tool.py,sha256=2iQfHbFKtTELPvNoX42rHr9_5lXRrXpwxb9z5OL96Xc,435
         | 
| 20 | 
            +
            modusa/fonts/NotoSansDevanagari-Regular.ttf,sha256=CEqU2J61Sq-5OgVuFUJcNP2Fn2NCh1Fl0wSDezvPwtI,221084
         | 
| 20 21 | 
             
            modusa/generators/__init__.py,sha256=xQUsOObRhTEPzdZsBGd4nT_9AWaL8uE_bisFAN_Wp9Q,236
         | 
| 21 22 | 
             
            modusa/generators/audio.py,sha256=91CnBDPZhagfJOx-cDoBBj3NrE92m70PmFmv7T8aQco,4477
         | 
| 22 23 | 
             
            modusa/generators/audio_waveforms.py,sha256=x-r4_kDi2xieQNBCo11qY2uk2bFcvzeNOppfJnj2oYs,6105
         | 
| @@ -47,7 +48,7 @@ modusa/tools/audio_loader.py,sha256=DrCzq0pdiQrUDIG-deLJGcu8EaylO5yRtwT4lr8WSf8, | |
| 47 48 | 
             
            modusa/tools/audio_player.py,sha256=GP04TWW4jBwQBjANkfR_cJtEy7cIhvbu8RTwnf9hD6E,2817
         | 
| 48 49 | 
             
            modusa/tools/base.py,sha256=C0ESJ0mIfjjRlAkRbSetNtMoOfS6IrHBjexRp3l_Mh4,1293
         | 
| 49 50 | 
             
            modusa/tools/math_ops.py,sha256=ZZ7U4DgqT7cOeE7_Lzi_Qq-48WYfwR9_osbZwTmE9eg,8690
         | 
| 50 | 
            -
            modusa/tools/plotter.py,sha256= | 
| 51 | 
            +
            modusa/tools/plotter.py,sha256=e1NKFTFm8tG7yd-9VLmxmI9h9mTcUl1vaK1XDMvyoOw,18917
         | 
| 51 52 | 
             
            modusa/tools/youtube_downloader.py,sha256=hB_X8-7nOHXOlxg6vv3wyhBLoAsWyomrULP6_uCQL7s,1698
         | 
| 52 53 | 
             
            modusa/utils/.DS_Store,sha256=nLXMwF7QJNuglLI_Gk74F7vl5Dyus2Wd74Mgowijmdo,6148
         | 
| 53 54 | 
             
            modusa/utils/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
         | 
| @@ -56,4 +57,4 @@ modusa/utils/excp.py,sha256=L9vhaGjKpv9viJYdmC9n5ndmk2GVbUBuFyZyhAQZmWY,906 | |
| 56 57 | 
             
            modusa/utils/logger.py,sha256=K0rsnObeNKCxlNeSnVnJeRhgfmob6riB2uyU7h3dDmA,571
         | 
| 57 58 | 
             
            modusa/utils/np_func_cat.py,sha256=TyIFgRc6bARRMDnZxlVURO5Z0I-GWhxRONYyIv-Vwxs,1007
         | 
| 58 59 | 
             
            modusa/utils/plot.py,sha256=s_vNdxvKfwxEngvJPgrF1PcmxZNnNaaXPViHWjyjJ-c,5335
         | 
| 59 | 
            -
            modusa-0.3. | 
| 60 | 
            +
            modusa-0.3.41.dist-info/RECORD,,
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         |