imt-ring 1.6.9__tar.gz → 1.6.10__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {imt_ring-1.6.9 → imt_ring-1.6.10}/PKG-INFO +1 -1
- {imt_ring-1.6.9 → imt_ring-1.6.10}/pyproject.toml +1 -1
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/imt_ring.egg-info/PKG-INFO +1 -1
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/generator/base.py +41 -4
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/generator/batch.py +7 -7
- {imt_ring-1.6.9 → imt_ring-1.6.10}/readme.md +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/setup.cfg +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/imt_ring.egg-info/SOURCES.txt +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/imt_ring.egg-info/dependency_links.txt +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/imt_ring.egg-info/requires.txt +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/imt_ring.egg-info/top_level.txt +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algebra.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/_random.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/custom_joints/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/custom_joints/rr_imp_joint.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/custom_joints/rr_joint.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/custom_joints/suntay.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/dynamics.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/generator/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/generator/finalize_fns.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/generator/motion_artifacts.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/generator/pd_control.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/generator/setup_fns.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/generator/types.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/jcalc.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/kinematics.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/algorithms/sensors.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/base.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/branched.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/exclude/knee_trans_dof.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/exclude/standard_sys.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/exclude/standard_sys_rr_imp.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/inv_pendulum.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/knee_flexible_imus.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/spherical_stiff.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/symmetric.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_all_1.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_all_2.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_ang0_pos0.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_control.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_double_pendulum.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_free.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_kinematics.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_morph_system/four_seg_seg1.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_morph_system/four_seg_seg3.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_randomize_position.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_sensors.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples/test_three_seg_seg2.xml +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/examples.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/test_examples.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/xml/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/xml/abstract.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/xml/from_xml.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/xml/test_from_xml.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/xml/test_to_xml.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/io/xml/to_xml.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/maths.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/base.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/callbacks.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/ml_utils.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/optimizer.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/params/0x13e3518065c21cd8.pickle +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/params/0x1d76628065a71e0f.pickle +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/ringnet.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/rnno_v1.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/train.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/ml/training_loop.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/rendering/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/rendering/base_render.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/rendering/mujoco_render.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/rendering/vispy_render.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/rendering/vispy_visuals.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/sim2real/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/sim2real/sim2real.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/spatial.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/sys_composer/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/sys_composer/delete_sys.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/sys_composer/inject_sys.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/sys_composer/morph_sys.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/backend.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/batchsize.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/colab.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/hdf5.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/normalizer.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/path.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/randomize_sys.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/register_gym_envs/__init__.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/register_gym_envs/saddle.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/src/ring/utils/utils.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_algebra.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_base.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_custom_joints.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_dynamics.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_generator.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_jcalc.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_jit.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_kinematics.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_maths.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_ml_utils.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_motion_artifacts.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_pd_control.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_quickstart_example.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_random.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_randomize.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_rcmg.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_render.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_sensors.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_sim2real.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_sys_composer.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_train.py +0 -0
- {imt_ring-1.6.9 → imt_ring-1.6.10}/tests/test_utils.py +0 -0
@@ -6,6 +6,7 @@ import jax
|
|
6
6
|
import jax.numpy as jnp
|
7
7
|
import numpy as np
|
8
8
|
import tree_utils
|
9
|
+
from tree_utils import PyTree
|
9
10
|
|
10
11
|
from ring import base
|
11
12
|
from ring import utils
|
@@ -143,9 +144,7 @@ class RCMG:
|
|
143
144
|
|
144
145
|
return n_calls
|
145
146
|
|
146
|
-
def
|
147
|
-
self, sizes: int | list[int] = 1, seed: int = 1
|
148
|
-
) -> list[tree_utils.PyTree[np.ndarray]]:
|
147
|
+
def _generators_ncalls(self, sizes: int | list[int] = 1):
|
149
148
|
"Returns list of unbatched sequences as numpy arrays."
|
150
149
|
repeats = self._compute_repeats(sizes)
|
151
150
|
sizes = list(jnp.array(repeats) * jnp.array(self._size_of_generators))
|
@@ -165,7 +164,45 @@ class RCMG:
|
|
165
164
|
batch.generators_lazy([self.gens[i]], [reduced_repeats[i]], jits[i])
|
166
165
|
)
|
167
166
|
|
168
|
-
return
|
167
|
+
return gens, n_calls
|
168
|
+
|
169
|
+
def to_list(
|
170
|
+
self, sizes: int | list[int] = 1, seed: int = 1
|
171
|
+
) -> list[tree_utils.PyTree[np.ndarray]]:
|
172
|
+
"Returns list of unbatched sequences as numpy arrays."
|
173
|
+
gens, n_calls = self._generators_ncalls(sizes)
|
174
|
+
|
175
|
+
data = []
|
176
|
+
batch.generators_eager(
|
177
|
+
gens, n_calls, lambda d: data.extend(d), seed, self._disable_tqdm
|
178
|
+
)
|
179
|
+
return data
|
180
|
+
|
181
|
+
def to_folder(
|
182
|
+
self,
|
183
|
+
path: str,
|
184
|
+
sizes: int | list[int] = 1,
|
185
|
+
seed: int = 1,
|
186
|
+
overwrite: bool = True,
|
187
|
+
file_prefix: str = "seq",
|
188
|
+
save_fn: Callable[[PyTree[np.ndarray], str], None] = utils.pickle_save,
|
189
|
+
verbose: bool = True,
|
190
|
+
):
|
191
|
+
|
192
|
+
i = 0
|
193
|
+
|
194
|
+
def callback(data: list[PyTree[np.ndarray]]) -> None:
|
195
|
+
nonlocal i
|
196
|
+
data = utils.replace_elements_w_nans(data, verbose=verbose)
|
197
|
+
for d in data:
|
198
|
+
file = utils.parse_path(
|
199
|
+
path, file_prefix + str(i), file_exists_ok=overwrite
|
200
|
+
)
|
201
|
+
save_fn(d, file)
|
202
|
+
i += 1
|
203
|
+
|
204
|
+
gens, n_calls = self._generators_ncalls(sizes)
|
205
|
+
batch.generators_eager(gens, n_calls, callback, seed, self._disable_tqdm)
|
169
206
|
|
170
207
|
def to_pickle(
|
171
208
|
self,
|
@@ -1,8 +1,10 @@
|
|
1
|
+
from typing import Callable
|
2
|
+
|
1
3
|
import jax
|
2
4
|
import jax.numpy as jnp
|
3
5
|
import numpy as np
|
4
6
|
from tqdm import tqdm
|
5
|
-
import
|
7
|
+
from tree_utils import PyTree
|
6
8
|
|
7
9
|
from ring import utils
|
8
10
|
from ring.algorithms.generator import types
|
@@ -50,15 +52,15 @@ def generators_lazy(
|
|
50
52
|
return generator
|
51
53
|
|
52
54
|
|
53
|
-
def
|
55
|
+
def generators_eager(
|
54
56
|
generators: list[types.BatchedGenerator],
|
55
57
|
n_calls: list[int],
|
58
|
+
callback: Callable[[list[PyTree[np.ndarray]]], None],
|
56
59
|
seed: int = 1,
|
57
60
|
disable_tqdm: bool = False,
|
58
|
-
) ->
|
61
|
+
) -> None:
|
59
62
|
|
60
63
|
key = jax.random.PRNGKey(seed)
|
61
|
-
data = []
|
62
64
|
for gen, n_call in tqdm(
|
63
65
|
zip(generators, n_calls),
|
64
66
|
desc="executing generators",
|
@@ -81,6 +83,4 @@ def generators_eager_to_list(
|
|
81
83
|
|
82
84
|
sample_flat, _ = jax.tree_util.tree_flatten(sample)
|
83
85
|
size = 1 if len(sample_flat) == 0 else sample_flat[0].shape[0]
|
84
|
-
|
85
|
-
|
86
|
-
return data
|
86
|
+
callback([jax.tree_map(lambda a: a[i], sample) for i in range(size)])
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|