Skip to content

Commit

Permalink
added gym-minigrid and fixed str | None
Browse files Browse the repository at this point in the history
  • Loading branch information
watakandai committed Jan 10, 2024
1 parent 6aac485 commit f87f7f5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ torch
ltlf2dfa
minigrid
click
gym-minigrid
8 changes: 4 additions & 4 deletions specless/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"""
import os
from abc import abstractmethod
from typing import Any, Callable, List
from typing import Any, Callable, List, Optional

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -74,7 +74,7 @@ def __getitem__(self, idx: int) -> Any:
def apply(self, func: Callable[..., Any]) -> None:
list(map(func, self.data))

def tolist(self, key: str | None = None):
def tolist(self, key: Optional[str] = None):
if key is None:
return list(map(lambda d: d.values.tolist(), self.data))
else:
Expand All @@ -91,7 +91,7 @@ class CSVDataset(BaseDataset):

def __init__(
self,
filedir: str | None = None,
filedir: Optional[str] = None,
filepaths: List[str] | None = None,
) -> None:
"""
Expand All @@ -106,7 +106,7 @@ def __init__(
>> dataset = CSVDataset(filedir, filepaths=filepaths)
Args:
filedir (str | None, optional): _description_. Defaults to None.
filedir (str, optional): _description_. Defaults to None.
"""
if filedir is None and filepaths is None:
raise Exception("Provide either filedir or filepaths")
Expand Down
2 changes: 1 addition & 1 deletion specless/factory/tspadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def add_initial_state(self, initial_state: Tuple = None) -> None:
self.obs_to_nodes[obs].append(node_id)


class MiniGridSytemAndTSPAdapter(MiniGridSytemAndTSPAdapter):
class MiniGridSytemAndTSPAdapterWithTPO(MiniGridSytemAndTSPAdapter):
"""Converts Transition System To a TSP Problem"""

def __call__(
Expand Down
4 changes: 2 additions & 2 deletions specless/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from abc import ABCMeta, abstractmethod
from collections import defaultdict
from pathlib import Path
from typing import Any, Callable, Dict, List, Tuple, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

import graphviz
import networkx as nx
Expand Down Expand Up @@ -457,7 +457,7 @@ def __init__(
self._learned_model_filepath: str
self._initial_output_addon_name = "init_dfa"
self._initial_model_filepath: str
self._output_base_filepath: str | None = None
self._output_base_filepath: Optional[str] = None
self._output_directory: str = output_directory
self._flexfringe_output_dir_popt_str: str = "o"
Path(output_directory).mkdir(parents=True, exist_ok=True)
Expand Down
4 changes: 2 additions & 2 deletions specless/inference/edsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import subprocess as sp
import time
from pathlib import Path
from typing import Union
from typing import Optional, Union

import graphviz
from IPython.display import Image, display
Expand Down Expand Up @@ -57,7 +57,7 @@ def __init__(
self._learned_model_filepath: str
self._initial_output_addon_name = "init_dfa"
self._initial_model_filepath: str
self._output_base_filepath: str | None = None
self._output_base_filepath: Optional[str] = None
self._output_directory: str = output_directory
self._flexfringe_output_dir_popt_str: str = "o"
Path(output_directory).mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit f87f7f5

Please sign in to comment.