From adf06fdb2a5896ba07ac4438b307f0870b57427e Mon Sep 17 00:00:00 2001
From: "Ankur Sinha (Ankur Sinha Gmail)" <sanjay.ankur@gmail.com>
Date: Wed, 18 Aug 2021 19:23:27 +0100
Subject: [PATCH] fix(py3.10) correct collections import
---
pyphi/db.py | 5 ++++-
pyphi/labels.py | 2 +-
pyphi/models/actual_causation.py | 2 +-
pyphi/models/cmp.py | 5 ++++-
pyphi/models/cuts.py | 2 +-
pyphi/models/subsystem.py | 2 +-
pyphi/registry.py | 2 +-
7 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/pyphi/db.py b/pyphi/db.py
index f1df5d15..8352dfe8 100644
--- a/pyphi/db.py
+++ b/pyphi/db.py
@@ -7,7 +7,10 @@ Interface to MongoDB that exposes it as a key-value store.
"""
import pickle
-from collections import Iterable
+try:
+ from collections import Iterable
+except ImportError:
+ from collections.abc import Iterable
import pymongo
from bson.binary import Binary
diff --git a/pyphi/labels.py b/pyphi/labels.py
index 14400aef..800be2a6 100644
--- a/pyphi/labels.py
+++ b/pyphi/labels.py
@@ -22,7 +22,7 @@ def default_labels(indices):
return tuple(default_label(i) for i in indices)
-class NodeLabels(collections.Sequence):
+class NodeLabels(collections.abc.Sequence):
'''Text labels for nodes in a network.
Labels can either be instantiated as a tuple of strings:
diff --git a/pyphi/models/actual_causation.py b/pyphi/models/actual_causation.py
index 08416baa..d1298b05 100644
--- a/pyphi/models/actual_causation.py
+++ b/pyphi/models/actual_causation.py
@@ -216,7 +216,7 @@ class Event(collections.namedtuple('Event', ['actual_cause', 'actual_effect'])):
return self.actual_cause.mechanism
-class Account(cmp.Orderable, collections.Sequence):
+class Account(cmp.Orderable, collections.abc.Sequence):
"""The set of |CausalLinks| with |alpha > 0|. This includes both actual
causes and actual effects.
"""
diff --git a/pyphi/models/cmp.py b/pyphi/models/cmp.py
index 5e475a7d..7b1d5f24 100644
--- a/pyphi/models/cmp.py
+++ b/pyphi/models/cmp.py
@@ -7,7 +7,10 @@ Utilities for comparing phi-objects.
"""
import functools
-from collections import Iterable
+try:
+ from collections import Iterable
+except ImportError:
+ from collections.abc import Iterable
import numpy as np
diff --git a/pyphi/models/cuts.py b/pyphi/models/cuts.py
index 7c461f9c..95cccd44 100644
--- a/pyphi/models/cuts.py
+++ b/pyphi/models/cuts.py
@@ -266,7 +266,7 @@ class Part(collections.namedtuple('Part', ['mechanism', 'purview'])):
return {'mechanism': self.mechanism, 'purview': self.purview}
-class KPartition(collections.Sequence):
+class KPartition(collections.abc.Sequence):
"""A partition with an arbitrary number of parts."""
__slots__ = ['parts', 'node_labels']
diff --git a/pyphi/models/subsystem.py b/pyphi/models/subsystem.py
index 15c48fe0..2fcecd23 100644
--- a/pyphi/models/subsystem.py
+++ b/pyphi/models/subsystem.py
@@ -17,7 +17,7 @@ def _concept_sort_key(concept):
return (len(concept.mechanism), concept.mechanism)
-class CauseEffectStructure(cmp.Orderable, collections.Sequence):
+class CauseEffectStructure(cmp.Orderable, collections.abc.Sequence):
"""A collection of concepts."""
def __init__(self, concepts=(), subsystem=None, time=None):
diff --git a/pyphi/registry.py b/pyphi/registry.py
index 94dda74b..cce8a4db 100644
--- a/pyphi/registry.py
+++ b/pyphi/registry.py
@@ -9,7 +9,7 @@ A function registry for storing custom measures and partition strategies.
import collections
-class Registry(collections.Mapping):
+class Registry(collections.abc.Mapping):
"""Generic registry for user-supplied functions.
See ``pyphi.subsystem.PartitionRegistry`` and
--
2.31.1