revisit 0.0.12__py2.py3-none-any.whl → 0.0.13__py2.py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
revisit/revisit.py CHANGED
@@ -10,7 +10,8 @@ import re
10
10
  import os
11
11
  import shutil
12
12
  from . import widget as _widget
13
-
13
+ import ast
14
+ import time
14
15
 
15
16
  __all__ = [
16
17
  "component",
@@ -67,6 +68,7 @@ class _WrappedComponent(_JSONableBaseModel):
67
68
  component_name__: str
68
69
  base__: Optional[_WrappedComponent] = None
69
70
  context__: Optional[dict] = None
71
+ metadata__: Optional[dict] = None
70
72
  root: rvt_models.IndividualComponent
71
73
 
72
74
  def model_post_init(self, __context: Any) -> None:
@@ -158,18 +160,29 @@ class _WrappedComponentBlock(_JSONableBaseModel):
158
160
 
159
161
  def get_component(self, name: str) -> _WrappedComponent:
160
162
  for entry in self.component_objects__:
161
- print(f'Comp Name: {entry.component_name__}')
162
- print(f'Name: {name}')
163
163
  if entry.component_name__ == name:
164
164
  return entry
165
165
 
166
- def permute(self, factors: List[str], order: rvt_models.Order, numSamples: Optional[int] = None,) -> None:
166
+ def permute(
167
+ self,
168
+ factors: List[str],
169
+ order: rvt_models.Order,
170
+ numSamples: Optional[int] = None,
171
+ component_function=None
172
+ ) -> None:
167
173
  # Convert to JSON
168
174
  self_json = json.loads(self.__str__())
169
175
  # Get all current component dictionaries
170
176
  components_dict = {c.component_name__: c for c in self.component_objects__}
171
177
  # Recursively start permutation function
172
- new_permuted_component_block = _recursive_json_permutation(self_json, factors=factors, order=order, numSamples=numSamples, input_components=components_dict)
178
+ new_permuted_component_block = _recursive_json_permutation(
179
+ self_json,
180
+ factors=factors,
181
+ order=order,
182
+ numSamples=numSamples,
183
+ input_components=components_dict,
184
+ component_function=component_function
185
+ )
173
186
  # Set new objects
174
187
  self.component_objects__ = new_permuted_component_block.component_objects__
175
188
  # Set new root
@@ -685,7 +698,8 @@ def _recursive_json_permutation(
685
698
  factors: List[str],
686
699
  order: rvt_models.Order,
687
700
  numSamples: int,
688
- input_components: dict
701
+ input_components: dict,
702
+ component_function=None
689
703
  ):
690
704
  new_seq = __sequence__(order=order, numSamples=numSamples)
691
705
  while input_json['components']:
@@ -698,20 +712,22 @@ def _recursive_json_permutation(
698
712
  curr_seq = __sequence__(order=order, numSamples=numSamples)
699
713
  # Generate new comp for each
700
714
  for entry in factors:
701
- # Split factor entry
702
- [name, value] = entry.split(":")
703
715
  # Assign params
704
- new_params = {name: value}
705
- if curr_comp.root.parameters is not None:
706
- new_params = {**curr_comp.root.parameters, **new_params}
716
+ metadata = entry
717
+ if curr_comp.metadata__ is not None:
718
+ metadata = {**curr_comp.metadata__, **entry}
707
719
  # Create new component
708
- curr_comp = __component__(
709
- base__=curr_comp,
710
- component_name__=f"{c}__{entry}",
711
- parameters=new_params
712
- )
720
+ comp_name = ":".join(f"{key}:{value}" for key, value in entry.items())
721
+ if component_function:
722
+ new_comp = component_function(**metadata)
723
+ else:
724
+ new_comp = __component__(
725
+ base__=curr_comp,
726
+ component_name__=f"{c}__{comp_name}",
727
+ metadata__=metadata
728
+ )
713
729
  # Add to curr seq block
714
- curr_seq = curr_seq + curr_comp
730
+ curr_seq = curr_seq + new_comp
715
731
  # Add seq block to outer seq block
716
732
  else:
717
733
  new_input_json = c
@@ -724,7 +740,8 @@ def _recursive_json_permutation(
724
740
  order=order,
725
741
  numSamples=numSamples,
726
742
  input_components=input_components,
727
- factors=factors
743
+ factors=factors,
744
+ component_function=component_function
728
745
  )
729
746
  curr_seq.root.order = new_input_json['order']
730
747
  curr_seq.root.numSamples = temp_num_samples
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: revisit
3
- Version: 0.0.12
3
+ Version: 0.0.13
4
4
  Requires-Dist: altair[all]>=5.5.0
5
5
  Requires-Dist: anywidget
6
6
  Requires-Dist: ipykernel>=6.29.5
@@ -1,10 +1,10 @@
1
1
  revisit/StudyConfigSchema.json,sha256=xtzwZifuPJoiHASx0o8PHqBuh5L30mjBlhQ5eqsYm10,132168
2
2
  revisit/__init__.py,sha256=QCvYt8m9QwpjcK4dv6GlLMUDCzRXGy16cua1r2biNCg,255
3
3
  revisit/models.py,sha256=FRy8IlUAtDS3gdmZwwvqR935lbViTPnnr7k0CAkDkzI,134084
4
- revisit/revisit.py,sha256=MnXxWXi2k-hT8BzvFNcigURw5ZCJFJvxBq0fJoK865I,26505
4
+ revisit/revisit.py,sha256=ZJDKbaQqvMTatcBxO8l7LhQ-EBb-2A_RKinQTIJe58k,26864
5
5
  revisit/widget.py,sha256=VvFqRvvvn86fW8ASe1pxaAvh5ZLvvSRThI5XtlCdgcg,915
6
6
  revisit/static/widget.css,sha256=TLu5F6k0CvowQtmApPswG-JZUXYszo7a10dVWKnZsIg,647
7
7
  revisit/static/widget.js,sha256=G5J9A5HvuMEEPKz2hAUGG25jFz4KHemocGLnJgwF_b8,186472
8
- revisit-0.0.12.dist-info/METADATA,sha256=Qgm7xz677b8fAyNNYrRKpGyR612mbpPH1TVrzAlc5vQ,8914
9
- revisit-0.0.12.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
10
- revisit-0.0.12.dist-info/RECORD,,
8
+ revisit-0.0.13.dist-info/METADATA,sha256=SoINQTeJwTFfaKiW2mpn9KhNXC4DT8Ew6lk3AWU59aM,8914
9
+ revisit-0.0.13.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
10
+ revisit-0.0.13.dist-info/RECORD,,