def from_json(cls, json_file, **kwargs): """ Instantiate from a JSON file A simple wrapper to the from_dict method Args: json_file (str): **kwargs: Passed to from_dict() Returns: slf """ idict = utils.loadjson(json_file) slf = cls.from_dict(idict, **kwargs) return slf
def from_json(cls, json_file, **kwargs): """ Args: json_file: **kwargs: Returns: FRBGalaxy or None """ try: idict = utils.loadjson(json_file) except FileNotFoundError: warnings.warn("File {} not found. This galaxy probably does not exist yet.".format(json_file)) return None slf = cls.from_dict(idict, **kwargs) return slf