Skip to content

Commit

Permalink
remove other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed Oct 28, 2024
1 parent 8cad73b commit 6938d26
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions xgi/readwrite/xgi_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ..convert import cut_to_order, from_hif_dict, from_hypergraph_dict
from ..exception import XGIError
from ..utils import request_json_from_url, request_json_from_url_cached
from .hif import write_hif, write_hif_collection

__all__ = ["load_xgi_data", "download_xgi_data"]

Expand Down Expand Up @@ -59,9 +58,9 @@ def load_xgi_data(
if read:
cfp = join(path, dataset + ".json")
if exists(cfp):
from ..readwrite import read_hif
from ..readwrite import read_json

return read_hif(cfp, nodetype=nodetype, edgetype=edgetype)
return read_json(cfp, nodetype=nodetype, edgetype=edgetype)
else:
warn(
f"No local copy was found at {cfp}. The data is requested "
Expand Down Expand Up @@ -109,6 +108,8 @@ def download_xgi_data(dataset, path="", collection_name=""):
The name of the collection of data (if any). If `dataset` is not
a collection, this argument is unused.
"""
from ..readwrite import write_json

index_url = "https://raw.githubusercontent.com/xgi-org/xgi-data/main/index.json"
index_data = request_json_from_url(index_url)

Expand All @@ -124,10 +125,10 @@ def download_xgi_data(dataset, path="", collection_name=""):
url, nodetype=None, edgetype=None, max_order=None, cache=True
)
if isinstance(H, dict):
write_hif_collection(H, path, collection_name=collection_name)
write_json(H, path, collection_name=collection_name)
else:
filename = join(path, key + ".json")
write_hif(H, filename)
write_json(H, filename)


def _request_from_xgi_data(
Expand Down Expand Up @@ -166,8 +167,8 @@ def _request_from_xgi_data(
if "incidences" in jsondata:
H = from_hif_dict(H, nodetype=nodetype, edgetype=edgetype)
return cut_to_order(H, order=max_order)
if "type" in jsondata and jsondata["type"] != "collection":

if "type" in jsondata and jsondata["type"] == "collection":
collection = {}
for name, data in jsondata["datasets"].items():
relpath = data["relative-path"]
Expand Down

0 comments on commit 6938d26

Please sign in to comment.