code-loader 1.0.68a0__py3-none-any.whl → 1.0.69.dev0__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.
@@ -196,7 +196,6 @@ class CustomLayerHandler:
196
196
  init_arg_names: List[str]
197
197
  call_arg_names: List[str]
198
198
  use_custom_latent_space: bool = False
199
- build: bool = True
200
199
 
201
200
 
202
201
  @dataclass
@@ -1,4 +1,4 @@
1
- from typing import List, Any, Union, Optional
1
+ from typing import List, Any, Tuple, Union, Optional
2
2
 
3
3
  import numpy as np
4
4
  import numpy.typing as npt
@@ -85,19 +85,36 @@ class LeapGraph:
85
85
  Attributes:
86
86
  data (npt.NDArray[np.float32]): The array data, shaped [M, N] where M is the number of data points and N is the number of variables.
87
87
  type (LeapDataType): The data type, default is LeapDataType.Graph.
88
+ x_label (Optional[str]): The x-axis label.
89
+ y_label (Optional[str]): The y-axis label.
90
+ x_range (Optional[Tuple[float, float]]): The range of x-axis. mapping the index to the range.
88
91
 
89
92
  Example:
90
93
  graph_data = np.random.rand(100, 3).astype(np.float32)
91
- leap_graph = LeapGraph(data=graph_data)
94
+ x_label = 'Frequency [Seconds]'
95
+ y_label = 'Amplitude [Voltage]'
96
+ x_range = (0.1, 3.0)
97
+ leap_graph = LeapGraph(data=graph_data, x_label=x_label, y_label=y_label, x_range=x_range)
92
98
  """
93
99
  data: npt.NDArray[np.float32]
94
100
  type: LeapDataType = LeapDataType.Graph
101
+ x_label: Optional[str] = None
102
+ y_label: Optional[str] = None
103
+ x_range: Optional[Tuple[float,float]] = None
95
104
 
96
105
  def __post_init__(self) -> None:
97
106
  validate_type(self.type, LeapDataType.Graph)
98
107
  validate_type(type(self.data), np.ndarray)
99
108
  validate_type(self.data.dtype, np.float32)
100
109
  validate_type(len(self.data.shape), 2, 'Graph must be of shape 2')
110
+ validate_type(type(self.x_label), [str, type(None)], 'x_label must be a string or None')
111
+ validate_type(type(self.y_label), [str, type(None)], 'y_label must be a string or None')
112
+ validate_type(type(self.x_range), [tuple, type(None)], 'x_range must be a tuple or None')
113
+ if self.x_range is not None:
114
+ if len(self.x_range) != 2:
115
+ raise LeapValidationError('x_range must be a tuple of length 2')
116
+ validate_type(type(self.x_range[0]), [float, int] , 'x_range must be a tuple of floats or integers')
117
+ validate_type(type(self.x_range[1]), [float, int], 'x_range must be a tuple of floats or integers')
101
118
 
102
119
 
103
120
  @dataclass
@@ -33,7 +33,6 @@ class LeapBinder:
33
33
  setup_container (DatasetIntegrationSetup): Container to hold setup configurations.
34
34
  cache_container (Dict[str, Any]): Cache container to store intermediate data.
35
35
  """
36
-
37
36
  def __init__(self) -> None:
38
37
  self.setup_container = DatasetIntegrationSetup()
39
38
  self.cache_container: Dict[str, Any] = {"word_to_index": {}}
@@ -353,8 +352,7 @@ class LeapBinder:
353
352
  self.setup_container.metadata.append(MetadataHandler(name, function))
354
353
 
355
354
  def set_custom_layer(self, custom_layer: Type[Any], name: str, inspect_layer: bool = False,
356
- kernel_index: Optional[int] = None, use_custom_latent_space: bool = False,
357
- build: bool = True) -> None:
355
+ kernel_index: Optional[int] = None, use_custom_latent_space: bool = False) -> None:
358
356
  """
359
357
  Set a custom layer for the model.
360
358
 
@@ -379,14 +377,12 @@ class LeapBinder:
379
377
  custom_layer.kernel_index = kernel_index
380
378
 
381
379
  if use_custom_latent_space and not hasattr(custom_layer, custom_latent_space_attribute):
382
- raise Exception(
383
- f"{custom_latent_space_attribute} function has not been set for custom layer: {custom_layer.__name__}")
380
+ raise Exception(f"{custom_latent_space_attribute} function has not been set for custom layer: {custom_layer.__name__}")
384
381
 
385
382
  init_args = inspect.getfullargspec(custom_layer.__init__)[0][1:]
386
383
  call_args = inspect.getfullargspec(custom_layer.call)[0][1:]
387
384
  self.setup_container.custom_layers[name] = CustomLayerHandler(name, custom_layer, init_args, call_args,
388
- use_custom_latent_space=use_custom_latent_space,
389
- build=build)
385
+ use_custom_latent_space=use_custom_latent_space)
390
386
 
391
387
  def check_preprocess(self, preprocess_result: Dict[DataStateEnum, PreprocessResponse]) -> None:
392
388
  preprocess_handler = self.setup_container.preprocess
@@ -494,3 +490,7 @@ class LeapBinder:
494
490
 
495
491
  def set_batch_size_to_validate(self, batch_size: int) -> None:
496
492
  self.batch_size_to_validate = batch_size
493
+
494
+
495
+
496
+
@@ -355,7 +355,7 @@ def tensorleap_custom_loss(name: str):
355
355
  assert isinstance(elem, valid_types), (f'tensorleap_custom_loss validation failed: '
356
356
  f'Element #{y} of list should be a numpy array. Got {type(elem)}.')
357
357
  else:
358
- assert isinstance(arg, tf.Tensor), (f'tensorleap_custom_loss validation failed: '
358
+ assert isinstance(arg, valid_types), (f'tensorleap_custom_loss validation failed: '
359
359
  f'Argument #{i} should be a numpy array. Got {type(arg)}.')
360
360
  for _arg_name, arg in kwargs.items():
361
361
  if isinstance(arg, list):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: code-loader
3
- Version: 1.0.68a0
3
+ Version: 1.0.69.dev0
4
4
  Summary:
5
5
  Home-page: https://github.com/tensorleap/code-loader
6
6
  License: MIT
@@ -1,11 +1,11 @@
1
1
  LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
2
2
  code_loader/__init__.py,sha256=6MMWr0ObOU7hkqQKgOqp4Zp3I28L7joGC9iCbQYtAJg,241
3
3
  code_loader/contract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- code_loader/contract/datasetclasses.py,sha256=3tL8v5bKoWUNiHln5CF95-CrvOP4jai3iIqc5KTKGr0,6996
4
+ code_loader/contract/datasetclasses.py,sha256=L_fSdSvf-eKoez2uBJ8VjfrKedEP0szNOPvaUvsWeRQ,6973
5
5
  code_loader/contract/enums.py,sha256=6Lo7p5CUog68Fd31bCozIuOgIp_IhSiPqWWph2k3OGU,1602
6
6
  code_loader/contract/exceptions.py,sha256=jWqu5i7t-0IG0jGRsKF4DjJdrsdpJjIYpUkN1F4RiyQ,51
7
7
  code_loader/contract/responsedataclasses.py,sha256=RSx9m_R3LawhK5o1nAcO3hfp2F9oJYtxZr_bpP3bTmw,4005
8
- code_loader/contract/visualizer_classes.py,sha256=zD7SVgI1R_DaGby3FPJY2rFphK162P7F2hRTHp2xUuM,12428
8
+ code_loader/contract/visualizer_classes.py,sha256=I2VK4szHwTpdKn_yS-hNCAAG59x4Fk8pqYsgyicRdDA,13578
9
9
  code_loader/default_losses.py,sha256=NoOQym1106bDN5dcIk56Elr7ZG5quUHArqfP5-Nyxyo,1139
10
10
  code_loader/default_metrics.py,sha256=v16Mrt2Ze1tXPgfKywGVdRSrkaK4CKLNQztN1UdVqIY,5010
11
11
  code_loader/experiment_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -19,14 +19,14 @@ code_loader/experiment_api/types.py,sha256=MY8xFARHwdVA7p4dxyhD60ShmttgTvb4qdp1o
19
19
  code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZJEqBqc,3304
20
20
  code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
21
21
  code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
22
- code_loader/inner_leap_binder/leapbinder.py,sha256=uU1jU6rsw8kFd_iUBE_m6SzOirIdiiccqgzLRAS8zEY,26101
23
- code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=P42U-sqsPKZgsaAzmX8y13F2N3CogeTzU1Iozj4S0GY,20778
22
+ code_loader/inner_leap_binder/leapbinder.py,sha256=o57Pj-iY61-OBuTjK-jYUKCJ0g2pPWbbqitv_e75Bps,25959
23
+ code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=S4XHoC4GVicUIhM0UAAsQ6qVmztD52L-Uxa-6OcZptA,20780
24
24
  code_loader/leaploader.py,sha256=K__WKfqtKwEch40au177Po10EUX7gm0PJzcV6kpUMlo,22212
25
25
  code_loader/leaploaderbase.py,sha256=aHlqWDZRacIdBefeB9goYVnpApaNN2FT24uPIWKkCeQ,3090
26
26
  code_loader/utils.py,sha256=aw2i_fqW_ADjLB66FWZd9DfpCQ7mPdMyauROC5Nd51I,2197
27
27
  code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  code_loader/visualizers/default_visualizers.py,sha256=Ffx5VHVOe5ujBOsjBSxN_aIEVwFSQ6gbhTMG5aUS-po,2305
29
- code_loader-1.0.68a0.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
30
- code_loader-1.0.68a0.dist-info/METADATA,sha256=AfcuMlL6hB8YgvZ9wFa1dSs2PAIJUKlcjuf0D30T2DQ,851
31
- code_loader-1.0.68a0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
- code_loader-1.0.68a0.dist-info/RECORD,,
29
+ code_loader-1.0.69.dev0.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
30
+ code_loader-1.0.69.dev0.dist-info/METADATA,sha256=kOgi7zTYOTUA0W1-Wi63PiwFT2iSjlsRwBbbYdZDhk4,854
31
+ code_loader-1.0.69.dev0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
32
+ code_loader-1.0.69.dev0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 1.9.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any