f9540d6da262c88cd4dfa2c3d9e8c2e570ea2f11,mushroom_rl/algorithms/agent.py,Agent,save,#Agent#Any#,130

Before Change


                location.

        
        if not isinstance(path, str):
            raise ValueError("path has to be of type string")

        path_obj = Path(path)
        path_obj.mkdir(parents=True, exist_ok=True)

        // Save algorithm type and save_attributes

After Change


        path = Path(path)
        path.parent.mkdir(parents=True, exist_ok=True)

        with ZipFile(path, "w") as zip_file:
            agent_config = dict(
                type=type(self),
                save_attributes=self._save_attributes
            )

            self._save_pickle(zip_file, "agent.config", agent_config)

            for att, method in self._save_attributes.items():
                attribute = getattr(self, att) if hasattr(self, att) else None
                save_method = getattr(self, "_save_{}".format(method)) if hasattr(
                    self, "_save_{}".format(method)) else None
                if attribute is None:
                    continue
                elif save_method is None:
                    raise NotImplementedError(
                        "Method _save_{} is not implemented for class "{}"".format(
                            method, self.__class__.__name__)
                    )
                else:
                    file_name = "{}.{}".format(att, method)
                    save_method(zip_file, file_name, attribute)

    def copy(self):
        
        Returns:
             A deepcopy of the agent.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: AIRLab-POLIMI/mushroom
Commit Name: f9540d6da262c88cd4dfa2c3d9e8c2e570ea2f11
Time: 2020-04-21
Author: boris.ilpossente@hotmail.it
File Name: mushroom_rl/algorithms/agent.py
Class Name: Agent
Method Name: save


Project Name: AIRLab-POLIMI/mushroom
Commit Name: f9540d6da262c88cd4dfa2c3d9e8c2e570ea2f11
Time: 2020-04-21
Author: boris.ilpossente@hotmail.it
File Name: mushroom_rl/algorithms/agent.py
Class Name: Agent
Method Name: load


Project Name: theislab/scanpy
Commit Name: d603299e387628f3878ff0b783698494f87c602c
Time: 2019-03-29
Author: ivirshup@gmail.com
File Name: scanpy/datasets/_expression_atlas.py
Class Name:
Method Name: expression_atlas