pygx 0.2.0__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.
- pygx/__init__.py +600 -0
- pygx/_core.py +152 -0
- pygx/_core_test.py +149 -0
- pygx/_lazy_import_test.py +43 -0
- pygx/algo/__init__.py +39 -0
- pygx/algo/early_stopping/__init__.py +60 -0
- pygx/algo/early_stopping/_base.py +87 -0
- pygx/algo/early_stopping/_base_test.py +106 -0
- pygx/algo/early_stopping/_step_wise.py +329 -0
- pygx/algo/early_stopping/_step_wise_test.py +309 -0
- pygx/algo/evolution/__init__.py +161 -0
- pygx/algo/evolution/_base.py +1742 -0
- pygx/algo/evolution/_base_test.py +1070 -0
- pygx/algo/evolution/_hill_climb.py +54 -0
- pygx/algo/evolution/_hill_climb_test.py +127 -0
- pygx/algo/evolution/_mutators.py +320 -0
- pygx/algo/evolution/_mutators_test.py +734 -0
- pygx/algo/evolution/_neat.py +273 -0
- pygx/algo/evolution/_neat_test.py +178 -0
- pygx/algo/evolution/_nsga2.py +201 -0
- pygx/algo/evolution/_nsga2_test.py +314 -0
- pygx/algo/evolution/_recombinators.py +1183 -0
- pygx/algo/evolution/_recombinators_test.py +745 -0
- pygx/algo/evolution/_regularized_evolution.py +63 -0
- pygx/algo/evolution/_regularized_evolution_test.py +149 -0
- pygx/algo/evolution/_selectors.py +443 -0
- pygx/algo/evolution/_selectors_test.py +319 -0
- pygx/algo/evolution/_where.py +200 -0
- pygx/algo/evolution/_where_test.py +73 -0
- pygx/algo/mutfun/__init__.py +154 -0
- pygx/algo/mutfun/_base.py +620 -0
- pygx/algo/mutfun/_base_test.py +812 -0
- pygx/algo/mutfun/_basic_ops.py +216 -0
- pygx/algo/mutfun/_basic_ops_test.py +495 -0
- pygx/algo/scalars/__init__.py +131 -0
- pygx/algo/scalars/_base.py +336 -0
- pygx/algo/scalars/_base_test.py +126 -0
- pygx/algo/scalars/_maths.py +157 -0
- pygx/algo/scalars/_maths_test.py +133 -0
- pygx/algo/scalars/_randoms.py +134 -0
- pygx/algo/scalars/_randoms_test.py +68 -0
- pygx/algo/scalars/_step_wise.py +133 -0
- pygx/algo/scalars/_step_wise_test.py +98 -0
- pygx/coding/__init__.py +74 -0
- pygx/coding/_errors.py +118 -0
- pygx/coding/_errors_test.py +118 -0
- pygx/coding/_execution.py +417 -0
- pygx/coding/_execution_test.py +584 -0
- pygx/coding/_function_generation.py +54 -0
- pygx/coding/_function_generation_test.py +68 -0
- pygx/coding/_parsing.py +136 -0
- pygx/coding/_parsing_test.py +156 -0
- pygx/coding/_permissions.py +111 -0
- pygx/coding/_permissions_test.py +98 -0
- pygx/concurrent/__init__.py +129 -0
- pygx/concurrent/_async.py +270 -0
- pygx/concurrent/_async_test.py +200 -0
- pygx/concurrent/_executor.py +137 -0
- pygx/concurrent/_executor_test.py +51 -0
- pygx/concurrent/_job.py +162 -0
- pygx/concurrent/_job_test.py +82 -0
- pygx/concurrent/_map.py +676 -0
- pygx/concurrent/_map_test.py +1292 -0
- pygx/concurrent/_progress.py +415 -0
- pygx/concurrent/_progress_test.py +269 -0
- pygx/concurrent/_retry.py +295 -0
- pygx/concurrent/_retry_test.py +259 -0
- pygx/concurrent/_thread_local.py +169 -0
- pygx/concurrent/_thread_local_test.py +206 -0
- pygx/contextual/__init__.py +58 -0
- pygx/contextual/_contextual.py +163 -0
- pygx/contextual/_contextual_object.py +364 -0
- pygx/contextual/_contextual_object_test.py +369 -0
- pygx/contextual/_contextual_test.py +102 -0
- pygx/detouring/__init__.py +55 -0
- pygx/detouring/_class_detour.py +390 -0
- pygx/detouring/_class_detour_test.py +236 -0
- pygx/error_handling/__init__.py +45 -0
- pygx/error_handling/_error_info.py +156 -0
- pygx/error_handling/_error_info_test.py +100 -0
- pygx/error_handling/_error_utils.py +169 -0
- pygx/error_handling/_error_utils_test.py +90 -0
- pygx/formatting/__init__.py +71 -0
- pygx/formatting/_formatting.py +700 -0
- pygx/formatting/_formatting_test.py +673 -0
- pygx/formatting/_text_color.py +149 -0
- pygx/formatting/_text_color_test.py +144 -0
- pygx/geno/__init__.py +131 -0
- pygx/geno/_base.py +1934 -0
- pygx/geno/_base_test.py +1469 -0
- pygx/geno/_categorical.py +902 -0
- pygx/geno/_categorical_test.py +812 -0
- pygx/geno/_custom.py +237 -0
- pygx/geno/_custom_test.py +238 -0
- pygx/geno/_deduping.py +190 -0
- pygx/geno/_deduping_test.py +162 -0
- pygx/geno/_dna_generator.py +265 -0
- pygx/geno/_dna_generator_test.py +208 -0
- pygx/geno/_numerical.py +253 -0
- pygx/geno/_numerical_test.py +205 -0
- pygx/geno/_random.py +92 -0
- pygx/geno/_random_test.py +178 -0
- pygx/geno/_space.py +339 -0
- pygx/geno/_space_test.py +590 -0
- pygx/geno/_sweeping.py +45 -0
- pygx/geno/_sweeping_test.py +98 -0
- pygx/hyper/__init__.py +158 -0
- pygx/hyper/_base.py +224 -0
- pygx/hyper/_categorical.py +814 -0
- pygx/hyper/_categorical_test.py +560 -0
- pygx/hyper/_custom.py +177 -0
- pygx/hyper/_custom_test.py +130 -0
- pygx/hyper/_derived.py +188 -0
- pygx/hyper/_derived_test.py +176 -0
- pygx/hyper/_dynamic_evaluation.py +670 -0
- pygx/hyper/_dynamic_evaluation_test.py +625 -0
- pygx/hyper/_evolvable.py +312 -0
- pygx/hyper/_evolvable_test.py +296 -0
- pygx/hyper/_iter.py +204 -0
- pygx/hyper/_iter_test.py +143 -0
- pygx/hyper/_numerical.py +277 -0
- pygx/hyper/_numerical_test.py +181 -0
- pygx/hyper/_object_template.py +640 -0
- pygx/hyper/_object_template_test.py +353 -0
- pygx/importing/__init__.py +58 -0
- pygx/importing/_lazy.py +444 -0
- pygx/importing/_lazy_test.py +683 -0
- pygx/importing/_module_deps.py +138 -0
- pygx/importing/_module_deps_test.py +184 -0
- pygx/importing/_reloader.py +112 -0
- pygx/importing/_reloader_test.py +79 -0
- pygx/importing/_remote.py +428 -0
- pygx/importing/_remote_test.py +514 -0
- pygx/instrument/__init__.py +40 -0
- pygx/instrument/_logging.py +174 -0
- pygx/instrument/_logging_test.py +96 -0
- pygx/instrument/_monitoring.py +685 -0
- pygx/instrument/_monitoring_test.py +315 -0
- pygx/instrument/_timing.py +256 -0
- pygx/instrument/_timing_test.py +172 -0
- pygx/io/__init__.py +44 -0
- pygx/io/_file_system.py +1009 -0
- pygx/io/_file_system_test.py +775 -0
- pygx/io/_sequence.py +333 -0
- pygx/io/_sequence_test.py +138 -0
- pygx/patching/__init__.py +76 -0
- pygx/patching/_object_factory.py +101 -0
- pygx/patching/_object_factory_test.py +152 -0
- pygx/patching/_pattern_based.py +270 -0
- pygx/patching/_pattern_based_test.py +90 -0
- pygx/patching/_rule_based.py +433 -0
- pygx/patching/_rule_based_test.py +589 -0
- pygx/symbolic/__init__.py +279 -0
- pygx/symbolic/_base.py +3685 -0
- pygx/symbolic/_base_test.py +442 -0
- pygx/symbolic/_boilerplate.py +179 -0
- pygx/symbolic/_boilerplate_test.py +228 -0
- pygx/symbolic/_class_wrapper.py +627 -0
- pygx/symbolic/_class_wrapper_test.py +814 -0
- pygx/symbolic/_compounding.py +326 -0
- pygx/symbolic/_compounding_test.py +373 -0
- pygx/symbolic/_dataclass_field.py +300 -0
- pygx/symbolic/_dict.py +1798 -0
- pygx/symbolic/_dict_test.py +3040 -0
- pygx/symbolic/_diff.py +596 -0
- pygx/symbolic/_diff_test.py +654 -0
- pygx/symbolic/_flags.py +775 -0
- pygx/symbolic/_flags_test.py +150 -0
- pygx/symbolic/_functor.py +794 -0
- pygx/symbolic/_functor_test.py +1157 -0
- pygx/symbolic/_inferred.py +114 -0
- pygx/symbolic/_inferred_test.py +44 -0
- pygx/symbolic/_io.py +228 -0
- pygx/symbolic/_list.py +1271 -0
- pygx/symbolic/_list_test.py +2478 -0
- pygx/symbolic/_native_seam.py +196 -0
- pygx/symbolic/_native_seam_test.py +255 -0
- pygx/symbolic/_object.py +4147 -0
- pygx/symbolic/_object_attrs.py +193 -0
- pygx/symbolic/_object_codegen.py +1423 -0
- pygx/symbolic/_object_meta.py +1047 -0
- pygx/symbolic/_object_seam.py +746 -0
- pygx/symbolic/_object_shared.py +174 -0
- pygx/symbolic/_object_test.py +13828 -0
- pygx/symbolic/_origin.py +195 -0
- pygx/symbolic/_origin_test.py +120 -0
- pygx/symbolic/_pure_symbolic.py +90 -0
- pygx/symbolic/_ref.py +339 -0
- pygx/symbolic/_ref_test.py +428 -0
- pygx/symbolic/_stacktrace.py +59 -0
- pygx/symbolic/_stacktrace_test.py +86 -0
- pygx/symbolic/_symbolize.py +184 -0
- pygx/symbolic/_symbolize_test.py +241 -0
- pygx/symbolic/_unknown_symbols.py +151 -0
- pygx/symbolic/_unknown_symbols_test.py +109 -0
- pygx/symbolic/_uri.py +1158 -0
- pygx/symbolic/_uri_test.py +751 -0
- pygx/topology/__init__.py +73 -0
- pygx/topology/_hierarchical.py +682 -0
- pygx/topology/_hierarchical_test.py +823 -0
- pygx/topology/_maybe_partial.py +69 -0
- pygx/topology/_missing.py +99 -0
- pygx/topology/_missing_test.py +74 -0
- pygx/topology/_value_location.py +969 -0
- pygx/topology/_value_location_test.py +743 -0
- pygx/tuning/__init__.py +77 -0
- pygx/tuning/_backend.py +177 -0
- pygx/tuning/_backend_test.py +70 -0
- pygx/tuning/_early_stopping.py +70 -0
- pygx/tuning/_early_stopping_test.py +74 -0
- pygx/tuning/_local_backend.py +449 -0
- pygx/tuning/_protocols.py +512 -0
- pygx/tuning/_protocols_test.py +143 -0
- pygx/tuning/_sample.py +301 -0
- pygx/tuning/_sample_test.py +701 -0
- pygx/typing/__init__.py +478 -0
- pygx/typing/_annotation_conversion.py +706 -0
- pygx/typing/_annotation_conversion_test.py +832 -0
- pygx/typing/_annotation_future_test.py +142 -0
- pygx/typing/_callable_ext.py +308 -0
- pygx/typing/_callable_ext_test.py +330 -0
- pygx/typing/_callable_signature.py +966 -0
- pygx/typing/_callable_signature_test.py +1065 -0
- pygx/typing/_class_schema.py +2727 -0
- pygx/typing/_class_schema_test.py +1669 -0
- pygx/typing/_custom_typing.py +72 -0
- pygx/typing/_docstr.py +181 -0
- pygx/typing/_docstr_test.py +162 -0
- pygx/typing/_functor.py +49 -0
- pygx/typing/_inspection.py +244 -0
- pygx/typing/_inspection_test.py +361 -0
- pygx/typing/_json_schema.py +613 -0
- pygx/typing/_json_schema_test.py +1087 -0
- pygx/typing/_key_specs.py +463 -0
- pygx/typing/_key_specs_test.py +221 -0
- pygx/typing/_pytype_support.py +69 -0
- pygx/typing/_type_conversion.py +122 -0
- pygx/typing/_type_conversion_test.py +196 -0
- pygx/typing/_typing_compat.py +73 -0
- pygx/typing/_value_specs.py +5123 -0
- pygx/typing/_value_specs_test.py +5193 -0
- pygx/views/__init__.py +69 -0
- pygx/views/_base.py +841 -0
- pygx/views/_base_test.py +551 -0
- pygx/views/html/__init__.py +63 -0
- pygx/views/html/_base.py +720 -0
- pygx/views/html/_base_test.py +904 -0
- pygx/views/html/_tree_view.py +1617 -0
- pygx/views/html/_tree_view_test.py +1493 -0
- pygx/views/html/controls/__init__.py +50 -0
- pygx/views/html/controls/_base.py +277 -0
- pygx/views/html/controls/_base_test.py +88 -0
- pygx/views/html/controls/_label.py +268 -0
- pygx/views/html/controls/_label_test.py +218 -0
- pygx/views/html/controls/_progress_bar.py +201 -0
- pygx/views/html/controls/_progress_bar_test.py +115 -0
- pygx/views/html/controls/_tab.py +407 -0
- pygx/views/html/controls/_tab_test.py +285 -0
- pygx/views/html/controls/_tooltip.py +131 -0
- pygx/views/html/controls/_tooltip_test.py +116 -0
- pygx/wire/__init__.py +78 -0
- pygx/wire/_conversion.py +1378 -0
- pygx/wire/_conversion_test.py +1056 -0
- pygx/wire/_format.py +272 -0
- pygx/wire/_format_test.py +233 -0
- pygx/wire/_registry.py +230 -0
- pygx/wire/_value.py +60 -0
- pygx-0.2.0.dist-info/METADATA +538 -0
- pygx-0.2.0.dist-info/RECORD +272 -0
- pygx-0.2.0.dist-info/WHEEL +5 -0
- pygx-0.2.0.dist-info/licenses/LICENSE +202 -0
- pygx-0.2.0.dist-info/top_level.txt +1 -0
pygx/__init__.py
ADDED
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
# Copyright 2026 Daiyi Peng.
|
|
2
|
+
#
|
|
3
|
+
# Derived from PyGlove (https://github.com/google/pyglove), originally
|
|
4
|
+
# authored by Daiyi Peng et al. as "PyGlove Authors" and released
|
|
5
|
+
# under the Apache License, Version 2.0.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
|
|
19
|
+
"""Package pygx.
|
|
20
|
+
|
|
21
|
+
This package is the facade of the public PyGX library, which includes modules
|
|
22
|
+
for symbolic type definition and manipulation, symbolic typing and constraints,
|
|
23
|
+
symbolic value generation and etc. It only has a handful of dependencies such
|
|
24
|
+
as enum, six, yaml.
|
|
25
|
+
|
|
26
|
+
Top-level sub-packages:
|
|
27
|
+
|
|
28
|
+
pygx
|
|
29
|
+
|__ symbolic : Symbolic program constructs and operations.
|
|
30
|
+
|__ typing : Runtime type check and value validation.
|
|
31
|
+
|__ geno : Genome types for program generation/manipulation.
|
|
32
|
+
|__ hyper : Encoding/Decoding between a program and a genome.
|
|
33
|
+
|__ tuning : Interface for program tuning with a local backend.
|
|
34
|
+
|__ detouring : Detouring classes creation without symbolic types.
|
|
35
|
+
|__ patching : Patching a program with URL-like strings.
|
|
36
|
+
|__ formatting : String formatting primitives (Formattable, format,
|
|
37
|
+
print, colored, ...).
|
|
38
|
+
|__ topology : Tree topology primitives (KeyPath, MISSING_VALUE,
|
|
39
|
+
MaybePartial, traverse, transform, merge, ...).
|
|
40
|
+
|__ wire : Wire formats for serialization (WireConvertible,
|
|
41
|
+
to_json, from_json, registered_types, ...).
|
|
42
|
+
|__ contextual : Context-scoped value overrides.
|
|
43
|
+
|__ error_handling : catch_errors, match_error, ErrorInfo.
|
|
44
|
+
|__ views : Object visualization.
|
|
45
|
+
|__ io : IO abstractions.
|
|
46
|
+
|__ coding : Code generation, parsing, execution.
|
|
47
|
+
|__ instrument : Instrumentation utilities (logging, monitoring,
|
|
48
|
+
timing).
|
|
49
|
+
|__ importing : Module dependency inspection and reload helpers.
|
|
50
|
+
|__ concurrent : Concurrent execution with retry and progress.
|
|
51
|
+
|__ algo : Algorithm sub-packages (scalars, mutfun, evolution,
|
|
52
|
+
early_stopping).
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
__all__ = [
|
|
56
|
+
'symbolic',
|
|
57
|
+
'active_core',
|
|
58
|
+
'allow_empty_field_description',
|
|
59
|
+
'allow_repeated_class_registration',
|
|
60
|
+
'set_origin_stacktrace_limit',
|
|
61
|
+
'allow_partial',
|
|
62
|
+
'allow_writable_accessors',
|
|
63
|
+
'auto_call_functors',
|
|
64
|
+
'notify_on_change',
|
|
65
|
+
'notify_once',
|
|
66
|
+
'enable_type_debug',
|
|
67
|
+
'is_type_debug_enabled',
|
|
68
|
+
'warn_on_field_override_no_annotation',
|
|
69
|
+
'is_warn_on_field_override_no_annotation_enabled',
|
|
70
|
+
'warn_on_capability_narrowing',
|
|
71
|
+
'is_warn_on_capability_narrowing_enabled',
|
|
72
|
+
'track_origin',
|
|
73
|
+
'as_sealed',
|
|
74
|
+
'Symbolic',
|
|
75
|
+
'PureSymbolic',
|
|
76
|
+
'Dict',
|
|
77
|
+
'dict',
|
|
78
|
+
'List',
|
|
79
|
+
'list',
|
|
80
|
+
'Object',
|
|
81
|
+
'ClassWrapper',
|
|
82
|
+
'Functor',
|
|
83
|
+
'Inferentiable',
|
|
84
|
+
'InferredValue',
|
|
85
|
+
'Ref',
|
|
86
|
+
'maybe_ref',
|
|
87
|
+
'ErrorInfo',
|
|
88
|
+
'members',
|
|
89
|
+
'field',
|
|
90
|
+
'symbolize',
|
|
91
|
+
'functor',
|
|
92
|
+
'functor_class',
|
|
93
|
+
'wrap',
|
|
94
|
+
'wrap_module',
|
|
95
|
+
'compound',
|
|
96
|
+
'compound_class',
|
|
97
|
+
'boilerplate_class',
|
|
98
|
+
'ContextualObject',
|
|
99
|
+
'apply_wrappers',
|
|
100
|
+
'eq',
|
|
101
|
+
'ne',
|
|
102
|
+
'lt',
|
|
103
|
+
'gt',
|
|
104
|
+
'hash',
|
|
105
|
+
'clone',
|
|
106
|
+
'TraverseAction',
|
|
107
|
+
'traverse',
|
|
108
|
+
'query',
|
|
109
|
+
'contains',
|
|
110
|
+
'is_abstract',
|
|
111
|
+
'is_pure_symbolic',
|
|
112
|
+
'is_deterministic',
|
|
113
|
+
'Diff',
|
|
114
|
+
'diff',
|
|
115
|
+
'from_json',
|
|
116
|
+
'from_json_str',
|
|
117
|
+
'to_json',
|
|
118
|
+
'to_json_str',
|
|
119
|
+
'serialize',
|
|
120
|
+
'deserialize',
|
|
121
|
+
'save',
|
|
122
|
+
'load',
|
|
123
|
+
'open_jsonl',
|
|
124
|
+
'get_load_handler',
|
|
125
|
+
'set_load_handler',
|
|
126
|
+
'get_save_handler',
|
|
127
|
+
'set_save_handler',
|
|
128
|
+
'Origin',
|
|
129
|
+
'FieldUpdate',
|
|
130
|
+
'Insertion',
|
|
131
|
+
'WritePermissionError',
|
|
132
|
+
'SymbolicModeError',
|
|
133
|
+
'typing',
|
|
134
|
+
'KeySpec',
|
|
135
|
+
'ValueSpec',
|
|
136
|
+
'Field',
|
|
137
|
+
'Schema',
|
|
138
|
+
'CustomTyping',
|
|
139
|
+
'validate',
|
|
140
|
+
'signature',
|
|
141
|
+
'schema',
|
|
142
|
+
'geno',
|
|
143
|
+
'DNA',
|
|
144
|
+
'DNASpec',
|
|
145
|
+
'DNAGenerator',
|
|
146
|
+
'random_dna',
|
|
147
|
+
'hyper',
|
|
148
|
+
'template',
|
|
149
|
+
'oneof',
|
|
150
|
+
'manyof',
|
|
151
|
+
'permutate',
|
|
152
|
+
'floatv',
|
|
153
|
+
'evolve',
|
|
154
|
+
'one_of',
|
|
155
|
+
'sublist_of',
|
|
156
|
+
'float_value',
|
|
157
|
+
'search_space',
|
|
158
|
+
'dna_spec',
|
|
159
|
+
'materialize',
|
|
160
|
+
'iter',
|
|
161
|
+
'random_sample',
|
|
162
|
+
'tuning',
|
|
163
|
+
'sample',
|
|
164
|
+
'poll_result',
|
|
165
|
+
'detouring',
|
|
166
|
+
'detour',
|
|
167
|
+
'patching',
|
|
168
|
+
'patch',
|
|
169
|
+
'patcher',
|
|
170
|
+
'patch_on_key',
|
|
171
|
+
'patch_on_path',
|
|
172
|
+
'patch_on_value',
|
|
173
|
+
'patch_on_type',
|
|
174
|
+
'patch_on_member',
|
|
175
|
+
'ObjectFactory',
|
|
176
|
+
'from_uri',
|
|
177
|
+
'formatting',
|
|
178
|
+
'topology',
|
|
179
|
+
'wire',
|
|
180
|
+
'contextual',
|
|
181
|
+
'error_handling',
|
|
182
|
+
'KeyPath',
|
|
183
|
+
'KeyPathSet',
|
|
184
|
+
'MISSING_VALUE',
|
|
185
|
+
'MissingValue',
|
|
186
|
+
'Formattable',
|
|
187
|
+
'repr_format',
|
|
188
|
+
'str_format',
|
|
189
|
+
'MaybePartial',
|
|
190
|
+
'WireConvertible',
|
|
191
|
+
'WireValue',
|
|
192
|
+
'WireFormat',
|
|
193
|
+
'JsonFormat',
|
|
194
|
+
'YamlFormat',
|
|
195
|
+
'register_format',
|
|
196
|
+
'get_format',
|
|
197
|
+
'DocStr',
|
|
198
|
+
'registered_types',
|
|
199
|
+
'is_partial',
|
|
200
|
+
'format',
|
|
201
|
+
'print',
|
|
202
|
+
'docstr',
|
|
203
|
+
'catch_errors',
|
|
204
|
+
'match_error',
|
|
205
|
+
'timeit',
|
|
206
|
+
'colored',
|
|
207
|
+
'decolor',
|
|
208
|
+
'views',
|
|
209
|
+
'view',
|
|
210
|
+
'view_options',
|
|
211
|
+
'View',
|
|
212
|
+
'Html',
|
|
213
|
+
'to_html',
|
|
214
|
+
'to_html_str',
|
|
215
|
+
'controls',
|
|
216
|
+
'io',
|
|
217
|
+
'coding',
|
|
218
|
+
'instrument',
|
|
219
|
+
'logging',
|
|
220
|
+
'monitoring',
|
|
221
|
+
'importing',
|
|
222
|
+
'reload',
|
|
223
|
+
'concurrent',
|
|
224
|
+
'algo',
|
|
225
|
+
]
|
|
226
|
+
|
|
227
|
+
# pylint: disable=invalid-name,wrong-import-position
|
|
228
|
+
# pylint: disable=g-bad-import-order
|
|
229
|
+
# pylint: disable=unused-import
|
|
230
|
+
# pylint: disable=reimported
|
|
231
|
+
# pylint: disable=g-import-not-at-top
|
|
232
|
+
# pylint: disable=redefined-builtin
|
|
233
|
+
# pylint: disable=import-outside-toplevel
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
#
|
|
237
|
+
# Active symbolic core (the PYGX_CORE differential switch).
|
|
238
|
+
#
|
|
239
|
+
|
|
240
|
+
from pygx import _core as _core
|
|
241
|
+
|
|
242
|
+
# Validate $PYGX_CORE eagerly so a typo fails at import rather than silently
|
|
243
|
+
# falling back to the oracle. See pygx/_core.py and
|
|
244
|
+
# docs/design/dual-core-design.md.
|
|
245
|
+
active_core = _core.active_core
|
|
246
|
+
active_core()
|
|
247
|
+
|
|
248
|
+
#
|
|
249
|
+
# Symbols from 'symbolic' sub-module.
|
|
250
|
+
#
|
|
251
|
+
|
|
252
|
+
from pygx import symbolic as symbolic
|
|
253
|
+
|
|
254
|
+
# Global flags.
|
|
255
|
+
allow_empty_field_description = symbolic.allow_empty_field_description
|
|
256
|
+
allow_repeated_class_registration = symbolic.allow_repeated_class_registration
|
|
257
|
+
set_origin_stacktrace_limit = symbolic.set_origin_stacktrace_limit
|
|
258
|
+
|
|
259
|
+
# Context manager for scoped flags.
|
|
260
|
+
allow_partial = symbolic.allow_partial
|
|
261
|
+
allow_writable_accessors = symbolic.allow_writable_accessors
|
|
262
|
+
auto_call_functors = symbolic.auto_call_functors
|
|
263
|
+
notify_on_change = symbolic.notify_on_change
|
|
264
|
+
notify_once = symbolic.notify_once
|
|
265
|
+
enable_type_debug = symbolic.enable_type_debug
|
|
266
|
+
is_type_debug_enabled = symbolic.is_type_debug_enabled
|
|
267
|
+
warn_on_field_override_no_annotation = (
|
|
268
|
+
symbolic.warn_on_field_override_no_annotation
|
|
269
|
+
)
|
|
270
|
+
is_warn_on_field_override_no_annotation_enabled = (
|
|
271
|
+
symbolic.is_warn_on_field_override_no_annotation_enabled
|
|
272
|
+
)
|
|
273
|
+
warn_on_capability_narrowing = symbolic.warn_on_capability_narrowing
|
|
274
|
+
is_warn_on_capability_narrowing_enabled = (
|
|
275
|
+
symbolic.is_warn_on_capability_narrowing_enabled
|
|
276
|
+
)
|
|
277
|
+
track_origin = symbolic.track_origin
|
|
278
|
+
as_sealed = symbolic.as_sealed
|
|
279
|
+
|
|
280
|
+
# Symbolic types.
|
|
281
|
+
Symbolic = symbolic.Symbolic
|
|
282
|
+
PureSymbolic = symbolic.PureSymbolic
|
|
283
|
+
|
|
284
|
+
Dict = symbolic.Dict
|
|
285
|
+
dict = Dict # pylint: disable=redefined-builtin
|
|
286
|
+
|
|
287
|
+
List = symbolic.List
|
|
288
|
+
list = List # pylint: disable=redefined-builtin
|
|
289
|
+
|
|
290
|
+
Object = symbolic.Object
|
|
291
|
+
ClassWrapper = symbolic.ClassWrapper
|
|
292
|
+
Functor = symbolic.Functor
|
|
293
|
+
|
|
294
|
+
# Inferentiable base classes.
|
|
295
|
+
Inferentiable = symbolic.Inferential
|
|
296
|
+
InferredValue = symbolic.InferredValue
|
|
297
|
+
|
|
298
|
+
# Reference types.
|
|
299
|
+
Ref = symbolic.Ref
|
|
300
|
+
maybe_ref = symbolic.maybe_ref
|
|
301
|
+
|
|
302
|
+
# Decorator for declaring symbolic. members for `pg.Object`.
|
|
303
|
+
members = symbolic.members
|
|
304
|
+
|
|
305
|
+
# Field descriptor for `pg.Object` dataclass-like fields (PEP 681).
|
|
306
|
+
field = symbolic.field
|
|
307
|
+
|
|
308
|
+
#
|
|
309
|
+
# Methods for making symbolic types.
|
|
310
|
+
#
|
|
311
|
+
|
|
312
|
+
# Function/Decorator for symbolizing existing types.
|
|
313
|
+
symbolize = symbolic.symbolize
|
|
314
|
+
|
|
315
|
+
# Decorator for converting a function into `pg.Functor`.
|
|
316
|
+
functor = symbolic.functor
|
|
317
|
+
|
|
318
|
+
# Method for making a functor class out from a function.
|
|
319
|
+
functor_class = symbolic.functor_class
|
|
320
|
+
|
|
321
|
+
# Function for wrapping a single class.
|
|
322
|
+
wrap = symbolic.wrap
|
|
323
|
+
|
|
324
|
+
# Function for wrapping multiple classes under a module.
|
|
325
|
+
wrap_module = symbolic.wrap_module
|
|
326
|
+
|
|
327
|
+
# Decorator for creating compound class.
|
|
328
|
+
compound = symbolic.compound
|
|
329
|
+
|
|
330
|
+
# Function for making compound class.
|
|
331
|
+
compound_class = symbolic.compound_class
|
|
332
|
+
|
|
333
|
+
# Method for declaring a boilerplated class from a symbolic instance.
|
|
334
|
+
boilerplate_class = symbolic.boilerplate_class
|
|
335
|
+
|
|
336
|
+
# Methods for contextual objects.
|
|
337
|
+
ContextualObject = symbolic.ContextualObject
|
|
338
|
+
|
|
339
|
+
#
|
|
340
|
+
# Context manager for swapping wrapped class with their wrappers.
|
|
341
|
+
#
|
|
342
|
+
|
|
343
|
+
apply_wrappers = symbolic.apply_wrappers
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
# Methods for symbolic operations.
|
|
347
|
+
eq = symbolic.eq
|
|
348
|
+
ne = symbolic.ne
|
|
349
|
+
lt = symbolic.lt
|
|
350
|
+
gt = symbolic.gt
|
|
351
|
+
hash = symbolic.hash # pylint: disable=redefined-builtin
|
|
352
|
+
clone = symbolic.clone
|
|
353
|
+
|
|
354
|
+
# Methods for querying symbolic types.
|
|
355
|
+
TraverseAction = symbolic.TraverseAction
|
|
356
|
+
traverse = symbolic.traverse
|
|
357
|
+
query = symbolic.query
|
|
358
|
+
contains = symbolic.contains
|
|
359
|
+
|
|
360
|
+
is_abstract = symbolic.is_abstract
|
|
361
|
+
is_pure_symbolic = symbolic.is_pure_symbolic
|
|
362
|
+
is_deterministic = symbolic.is_deterministic
|
|
363
|
+
|
|
364
|
+
# Method for differentiating symbolic types.
|
|
365
|
+
Diff = symbolic.Diff
|
|
366
|
+
diff = symbolic.diff
|
|
367
|
+
|
|
368
|
+
# Methods for serializing/deserializing symbolic types.
|
|
369
|
+
from_json = symbolic.from_json
|
|
370
|
+
from_json_str = symbolic.from_json_str
|
|
371
|
+
to_json = symbolic.to_json
|
|
372
|
+
to_json_str = symbolic.to_json_str
|
|
373
|
+
save = symbolic.save
|
|
374
|
+
load = symbolic.load
|
|
375
|
+
open_jsonl = symbolic.open_jsonl
|
|
376
|
+
get_load_handler = symbolic.get_load_handler
|
|
377
|
+
set_load_handler = symbolic.set_load_handler
|
|
378
|
+
get_save_handler = symbolic.get_save_handler
|
|
379
|
+
set_save_handler = symbolic.set_save_handler
|
|
380
|
+
|
|
381
|
+
# Auxiliary classes:
|
|
382
|
+
Origin = symbolic.Origin
|
|
383
|
+
FieldUpdate = symbolic.FieldUpdate
|
|
384
|
+
Insertion = symbolic.Insertion
|
|
385
|
+
WritePermissionError = symbolic.WritePermissionError
|
|
386
|
+
SymbolicModeError = symbolic.SymbolicModeError
|
|
387
|
+
|
|
388
|
+
#
|
|
389
|
+
# Symbols from 'typing' sub-module.
|
|
390
|
+
#
|
|
391
|
+
|
|
392
|
+
from pygx import typing as typing
|
|
393
|
+
|
|
394
|
+
# Promote the following concepts to top level as they may be used in pytype
|
|
395
|
+
# annotation frequently.
|
|
396
|
+
KeySpec = typing.KeySpec
|
|
397
|
+
ValueSpec = typing.ValueSpec
|
|
398
|
+
Field = typing.Field
|
|
399
|
+
Schema = typing.Schema
|
|
400
|
+
CustomTyping = typing.CustomTyping
|
|
401
|
+
|
|
402
|
+
# The TypeAdapter-style one-liner (#520): validate a bare value against a
|
|
403
|
+
# type annotation (`pg.validate([1, 2], list[int])`).
|
|
404
|
+
validate = typing.validate
|
|
405
|
+
|
|
406
|
+
signature = typing.signature
|
|
407
|
+
schema = typing.schema
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
#
|
|
411
|
+
# Symbols from 'geno' sub-module.
|
|
412
|
+
#
|
|
413
|
+
|
|
414
|
+
from pygx import geno as geno
|
|
415
|
+
|
|
416
|
+
DNA = geno.DNA
|
|
417
|
+
DNASpec = geno.DNASpec
|
|
418
|
+
DNAGenerator = geno.DNAGenerator
|
|
419
|
+
|
|
420
|
+
random_dna = geno.random_dna
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
#
|
|
424
|
+
# Symbols from 'hyper' sub-module.
|
|
425
|
+
#
|
|
426
|
+
|
|
427
|
+
from pygx import hyper as hyper
|
|
428
|
+
|
|
429
|
+
# Methods for creating hyper values.
|
|
430
|
+
template = hyper.template
|
|
431
|
+
|
|
432
|
+
oneof = hyper.oneof
|
|
433
|
+
manyof = hyper.manyof
|
|
434
|
+
permutate = hyper.permutate
|
|
435
|
+
floatv = hyper.floatv
|
|
436
|
+
evolve = hyper.evolve
|
|
437
|
+
|
|
438
|
+
# Aliases for backward compatibility.
|
|
439
|
+
one_of = hyper.one_of
|
|
440
|
+
sublist_of = hyper.sublist_of
|
|
441
|
+
float_value = hyper.float_value
|
|
442
|
+
search_space = hyper.search_space
|
|
443
|
+
|
|
444
|
+
# Helper methods for operating with hyper values.
|
|
445
|
+
dna_spec = hyper.search_space
|
|
446
|
+
materialize = hyper.materialize
|
|
447
|
+
|
|
448
|
+
iter = hyper.iterate # pylint: disable=redefined-builtin
|
|
449
|
+
random_sample = hyper.random_sample
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
#
|
|
453
|
+
# Symbols from 'tuning' sub-module.
|
|
454
|
+
#
|
|
455
|
+
|
|
456
|
+
from pygx import tuning as tuning
|
|
457
|
+
|
|
458
|
+
sample = tuning.sample
|
|
459
|
+
poll_result = tuning.poll_result
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
#
|
|
463
|
+
# Symbols from 'detouring' sub-module.
|
|
464
|
+
#
|
|
465
|
+
|
|
466
|
+
from pygx import detouring as detouring
|
|
467
|
+
|
|
468
|
+
detour = detouring.detour
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
#
|
|
472
|
+
# Symbols from 'patching' sub-module.
|
|
473
|
+
#
|
|
474
|
+
|
|
475
|
+
from pygx import patching as patching
|
|
476
|
+
|
|
477
|
+
patch = patching.patch
|
|
478
|
+
patcher = patching.patcher
|
|
479
|
+
patch_on_key = patching.patch_on_key
|
|
480
|
+
patch_on_path = patching.patch_on_path
|
|
481
|
+
patch_on_value = patching.patch_on_value
|
|
482
|
+
patch_on_type = patching.patch_on_type
|
|
483
|
+
patch_on_member = patching.patch_on_member
|
|
484
|
+
ObjectFactory = patching.ObjectFactory
|
|
485
|
+
|
|
486
|
+
# ``pg.from_uri`` builds a symbolic object from a URI string. Distinct from
|
|
487
|
+
# ``pg.patching.from_uri``, which resolves a URI to a registered ``Patcher``.
|
|
488
|
+
from_uri = symbolic.from_uri
|
|
489
|
+
|
|
490
|
+
#
|
|
491
|
+
# Cross-cutting low-level submodules (no `pg.utils` anymore).
|
|
492
|
+
#
|
|
493
|
+
|
|
494
|
+
from pygx import contextual as contextual
|
|
495
|
+
from pygx import error_handling as error_handling
|
|
496
|
+
from pygx import formatting as formatting
|
|
497
|
+
from pygx import topology as topology
|
|
498
|
+
from pygx import wire as wire
|
|
499
|
+
|
|
500
|
+
KeyPath = topology.KeyPath
|
|
501
|
+
KeyPathSet = topology.KeyPathSet
|
|
502
|
+
MISSING_VALUE = topology.MISSING_VALUE
|
|
503
|
+
MissingValue = topology.MissingValue
|
|
504
|
+
|
|
505
|
+
Formattable = formatting.Formattable
|
|
506
|
+
repr_format = formatting.repr_format
|
|
507
|
+
str_format = formatting.str_format
|
|
508
|
+
|
|
509
|
+
MaybePartial = topology.MaybePartial
|
|
510
|
+
WireConvertible = wire.WireConvertible
|
|
511
|
+
WireValue = wire.WireValue
|
|
512
|
+
WireFormat = wire.WireFormat
|
|
513
|
+
JsonFormat = wire.JsonFormat
|
|
514
|
+
YamlFormat = wire.YamlFormat
|
|
515
|
+
register_format = wire.register_format
|
|
516
|
+
get_format = wire.get_format
|
|
517
|
+
serialize = wire.serialize
|
|
518
|
+
deserialize = wire.deserialize
|
|
519
|
+
DocStr = typing.DocStr
|
|
520
|
+
|
|
521
|
+
registered_types = wire.registered_types
|
|
522
|
+
|
|
523
|
+
is_partial = topology.is_partial
|
|
524
|
+
format = formatting.format # pylint: disable=redefined-builtin
|
|
525
|
+
print = formatting.printv # pylint: disable=redefined-builtin
|
|
526
|
+
docstr = typing.docstr
|
|
527
|
+
catch_errors = error_handling.catch_errors
|
|
528
|
+
match_error = error_handling.match_error
|
|
529
|
+
ErrorInfo = error_handling.ErrorInfo
|
|
530
|
+
|
|
531
|
+
colored = formatting.colored
|
|
532
|
+
decolor = formatting.decolor
|
|
533
|
+
|
|
534
|
+
# Symbols from 'views' sub-module.
|
|
535
|
+
|
|
536
|
+
from pygx import views as views
|
|
537
|
+
|
|
538
|
+
view = views.view
|
|
539
|
+
view_options = views.view_options
|
|
540
|
+
View = views.View
|
|
541
|
+
Html = views.Html
|
|
542
|
+
to_html = views.to_html
|
|
543
|
+
to_html_str = views.to_html_str
|
|
544
|
+
|
|
545
|
+
#
|
|
546
|
+
# Symbols from `io` sub-module.
|
|
547
|
+
#
|
|
548
|
+
|
|
549
|
+
#
|
|
550
|
+
# Symbols from `coding` sub-module.
|
|
551
|
+
#
|
|
552
|
+
from pygx import coding as coding
|
|
553
|
+
|
|
554
|
+
#
|
|
555
|
+
# Symbols from `instrument` sub-package.
|
|
556
|
+
#
|
|
557
|
+
from pygx import instrument as instrument
|
|
558
|
+
from pygx import io as io
|
|
559
|
+
|
|
560
|
+
# `controls` is lazily attached to `pygx.views.html` via a module-level
|
|
561
|
+
# `__getattr__` (see `pygx/views/html/__init__.py`) to avoid the circular
|
|
562
|
+
# dependency between `pygx.views.html` and `pygx.symbolic`. Re-export here so
|
|
563
|
+
# `pg.controls` keeps working.
|
|
564
|
+
from pygx.views.html import controls as controls
|
|
565
|
+
|
|
566
|
+
# Top-level shortcuts for the instrumentation modules.
|
|
567
|
+
logging = instrument.logging
|
|
568
|
+
monitoring = instrument.monitoring
|
|
569
|
+
timeit = instrument.timeit
|
|
570
|
+
|
|
571
|
+
#
|
|
572
|
+
# Symbols from `importing` sub-package.
|
|
573
|
+
#
|
|
574
|
+
from pygx import importing as importing
|
|
575
|
+
|
|
576
|
+
reload = importing.reload
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
#
|
|
580
|
+
# Algorithm sub-packages.
|
|
581
|
+
#
|
|
582
|
+
# `pygx.algo` and `pygx.concurrent` are bound to lazy-loading proxies:
|
|
583
|
+
# importing the four algo subpackages eagerly costs ~70 ms but is rarely
|
|
584
|
+
# needed by code that just uses pygx's symbolic/typing/io machinery. The
|
|
585
|
+
# proxy executes the subpackage's body on first non-introspection attribute
|
|
586
|
+
# access; users who actually need them can either `import pygx.algo`
|
|
587
|
+
# directly or simply access `pg.algo.X`.
|
|
588
|
+
|
|
589
|
+
# Placeholder for Google-internal imports.
|
|
590
|
+
|
|
591
|
+
algo = importing.lazy_load('pygx.algo')
|
|
592
|
+
concurrent = importing.lazy_load('pygx.concurrent')
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
# pylint: enable=g-import-not-at-top
|
|
596
|
+
# pylint: enable=reimported
|
|
597
|
+
# pylint: enable=unused-import
|
|
598
|
+
# pylint: enable=g-bad-import-order
|
|
599
|
+
|
|
600
|
+
__version__ = '0.2.0'
|