From 18bb3545af6a3e936b3006fd3bb329b823632d25 Mon Sep 17 00:00:00 2001 From: Ben Nebgen Date: Wed, 3 Jul 2024 22:02:51 -0600 Subject: [PATCH] Enabled removing leading comments from json DB Encountered a json DB without leading comments. Added option to adjust the number of expected comments in a json DB. --- hippynn/databases/SNAPJson.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hippynn/databases/SNAPJson.py b/hippynn/databases/SNAPJson.py index 717c1078..c9cb208b 100644 --- a/hippynn/databases/SNAPJson.py +++ b/hippynn/databases/SNAPJson.py @@ -25,6 +25,7 @@ def __init__( transpose_cell=True, allow_unfound=False, quiet=False, + comments=1, **kwargs, ): @@ -34,6 +35,7 @@ def __init__( self.targets = targets self.transpose_cell = transpose_cell self.depth = depth + self.comments = comments arr_dict = self.load_arrays(quiet=quiet, allow_unfound=allow_unfound) super().__init__(arr_dict, inputs, targets, *args, **kwargs, allow_unfound=allow_unfound, quiet=quiet) @@ -96,7 +98,8 @@ def filter_arrays(self, arr_dict, allow_unfound=False, quiet=False): def extract_snap_file(self, file): with open(file, "rt") as jf: - comment = jf.readline() + for i in range(self.comments): + comment = jf.readline() content = jf.read() parsed = json.loads(content) dataset = parsed["Dataset"]