gr-libs 0.1.5__py3-none-any.whl → 0.1.7.post0__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.
gr_libs/__init__.py CHANGED
@@ -1,2 +1,6 @@
1
1
  from gr_libs.recognizer.graml.graml_recognizer import ExpertBasedGraml, GCGraml
2
- from gr_libs.recognizer.gr_as_rl.gr_as_rl_recognizer import Graql
2
+ from gr_libs.recognizer.gr_as_rl.gr_as_rl_recognizer import Graql
3
+ try:
4
+ from ._version import version as __version__
5
+ except ImportError:
6
+ __version__ = "0.0.0" # fallback if file isn't present
gr_libs/_version.py ADDED
@@ -0,0 +1,21 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
6
+ TYPE_CHECKING = False
7
+ if TYPE_CHECKING:
8
+ from typing import Tuple
9
+ from typing import Union
10
+
11
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
12
+ else:
13
+ VERSION_TUPLE = object
14
+
15
+ version: str
16
+ __version__: str
17
+ __version_tuple__: VERSION_TUPLE
18
+ version_tuple: VERSION_TUPLE
19
+
20
+ __version__ = version = '0.1.7.post0'
21
+ __version_tuple__ = version_tuple = (0, 1, 7, 'post0')
@@ -12,11 +12,11 @@ def is_extra_installed(package: str, extra: str) -> bool:
12
12
  return False # The package is not installed
13
13
 
14
14
  # Check if `gr_libs[minigrid]` was installed
15
- for env in ["minigrid", "panda", "parking", "point_maze"]:
15
+ for env in ["minigrid", "panda", "highway", "maze"]:
16
16
  if is_extra_installed("gr_libs", f"gr_envs[{env}]"):
17
17
  try:
18
18
  importlib.import_module(f"gr_envs.{env}_scripts.envs")
19
19
  except ImportError:
20
- raise ImportError(f"gr_libs[{env}] was not installed, but gr_libs[{env}] requires it! if you messed with gr_libs installation, you can reinstall gr_libs.")
20
+ raise ImportError(f"gr_envs[{env}] was not installed, but gr_libs[{env}] requires it! if you messed with gr_envs installation, you can reinstall gr_libs.")
21
21
  else:
22
22
  warnings.warn(f"gr_libs[{env}] was not installed, skipping {env} imports.", RuntimeWarning)
@@ -105,7 +105,7 @@ class MinigridProperty(EnvProperty):
105
105
  env_id = problem_name.split("-DynamicGoal-")[0] + "-DynamicGoal-" + problem_name.split("-DynamicGoal-")[1]
106
106
  result = register(
107
107
  id=env_id,
108
- entry_point="gr_libss.minigrid_scripts.envs:CustomColorEnv",
108
+ entry_point="gr_envs.minigrid_scripts.envs:CustomColorEnv",
109
109
  kwargs={"size": 13 if 'Simple' in problem_name else 9,
110
110
  "num_crossings": 4 if 'Simple' in problem_name else 3,
111
111
  "goal_pos": self.str_to_goal(problem_name),
@@ -5,7 +5,6 @@ import numpy as np
5
5
 
6
6
  from typing import Callable, Generator, List, Dict, Tuple, Any
7
7
  from math import log2
8
- from numpy.core.fromnumeric import mean
9
8
  from scipy.stats import wasserstein_distance
10
9
  from gymnasium.spaces.discrete import Discrete
11
10
  # import torch
@@ -43,7 +42,7 @@ def kl_divergence_norm_softmax(observations: List[Tuple[State, Any]], agent, act
43
42
  qp2_flatten_distribution_list: List[float] = agent.get_actions_probabilities(
44
43
  observation=(observation, agent_pos))
45
44
  distances.append(kl_divergence(qp1, qp2_flatten_distribution_list))
46
- return mean(distances)
45
+ return np.mean(distances)
47
46
 
48
47
 
49
48
  def amplify(values, alpha=1.0):
@@ -351,7 +351,7 @@ class TabularQLearner(TabularRLAgent):
351
351
  def simplify_observation(self, observation):
352
352
  return [(obs['direction'], agent_pos_x, agent_pos_y, action) for ((obs, (agent_pos_x, agent_pos_y)), action) in observation] # list of tuples, each tuple the sample
353
353
 
354
- def generate_observation(self, action_selection_method: MethodType, random_optimalism, save_fig = False, fig_path: str=None, env_prop=None):
354
+ def generate_observation(self, action_selection_method: MethodType, random_optimalism, save_fig=False, fig_path: str=None, env_prop=None):
355
355
  """
356
356
  Generate a single observation given a list of agents
357
357
 
@@ -15,6 +15,13 @@ def get_storage_framework_dir(recognizer: str):
15
15
  return os.path.join(get_storage_dir(),recognizer)
16
16
 
17
17
  def get_storage_dir():
18
+ # Prefer local directory if it exists (e.g., in GitHub workspace)
19
+ if os.path.exists("dataset"):
20
+ return "dataset"
21
+ # Fall back to pre-mounted directory (e.g., in Docker container)
22
+ if os.path.exists("/preloaded_data"):
23
+ return "/preloaded_data"
24
+ # Default to "dataset" even if it doesn't exist (e.g., will be created)
18
25
  return "dataset"
19
26
 
20
27
  def _get_models_directory_name():
File without changes