From 5a91c6fb5f23bd3e5acb2f9f54158577873f241d Mon Sep 17 00:00:00 2001 From: Virgil Griffith Date: Sat, 24 Jan 2026 13:54:47 -0500 Subject: [PATCH 1/2] added out=None Fixing a complaint jupyter notebook gives about this line. --- pyphi/metrics/distribution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyphi/metrics/distribution.py b/pyphi/metrics/distribution.py index e52a77371..3492ce35c 100644 --- a/pyphi/metrics/distribution.py +++ b/pyphi/metrics/distribution.py @@ -888,7 +888,7 @@ def generalized_intrinsic_difference( def pointwise_intrinsic_differentiation(p): - return -np.log2(p, where=(p > 0)) + -np.log2(p, where=(p > 0), out=None) @measures.register("INTRINSIC_DIFFERENTIATION", asymmetric=True) From 47f1316f1b4070ebf851bf3df5d675224a7ec559 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 24 Jan 2026 19:39:55 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit hooks --- profiling/gprof2dot | 2 +- test/test_big_phi_robust.py | 42 ++++++++++++++++---------------- test/test_iit4_robust.py | 24 +++++++++---------- test/test_invariants.py | 48 ++++++++++++++++++------------------- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/profiling/gprof2dot b/profiling/gprof2dot index f63368588..d48b16e56 100755 --- a/profiling/gprof2dot +++ b/profiling/gprof2dot @@ -1367,7 +1367,7 @@ class AXEParser(Parser): attrs[name] = value return Struct(attrs) - _cg_header_re = re.compile("^Index |" "^-----+ ") + _cg_header_re = re.compile("^Index |^-----+ ") _cg_footer_re = re.compile(r"^Index\s+Function\s*$") diff --git a/test/test_big_phi_robust.py b/test/test_big_phi_robust.py index e9f5a86c9..b73153f32 100644 --- a/test/test_big_phi_robust.py +++ b/test/test_big_phi_robust.py @@ -175,17 +175,17 @@ def test_sia_standard_example_has_repertoires(self, s): # Check cause repertoire exists and has required attributes assert result.cause is not None, "SIA missing cause repertoire" assert hasattr(result.cause, "phi"), "Cause RIA missing phi attribute" - assert hasattr( - result.cause, "mechanism" - ), "Cause RIA missing mechanism attribute" + assert hasattr(result.cause, "mechanism"), ( + "Cause RIA missing mechanism attribute" + ) assert hasattr(result.cause, "purview"), "Cause RIA missing purview attribute" # Check effect repertoire exists and has required attributes assert result.effect is not None, "SIA missing effect repertoire" assert hasattr(result.effect, "phi"), "Effect RIA missing phi attribute" - assert hasattr( - result.effect, "mechanism" - ), "Effect RIA missing mechanism attribute" + assert hasattr(result.effect, "mechanism"), ( + "Effect RIA missing mechanism attribute" + ) assert hasattr(result.effect, "purview"), "Effect RIA missing purview attribute" def test_sia_standard_example_has_system_state(self, s): @@ -242,9 +242,9 @@ def test_sia_standard_example_partition_type(self, s): # System has phi > 0, so should have non-null partition assert result.phi > 0, "Standard example should have phi > 0" - assert not isinstance( - result.partition, NullCut - ), "Irreducible system has NullCut partition" + assert not isinstance(result.partition, NullCut), ( + "Irreducible system has NullCut partition" + ) def test_reducible_system_has_null_partition(self, reducible): """Reducible system should have null partition. @@ -254,12 +254,12 @@ def test_reducible_system_has_null_partition(self, reducible): """ result = reducible.sia() - assert isinstance( - result, NullSystemIrreducibilityAnalysis - ), "Reducible system should return NullSIA" - assert isinstance( - result.partition, NullCut - ), "Reducible system should have NullCut partition" + assert isinstance(result, NullSystemIrreducibilityAnalysis), ( + "Reducible system should return NullSIA" + ) + assert isinstance(result.partition, NullCut), ( + "Reducible system should have NullCut partition" + ) assert result.phi == 0.0, "Reducible system should have phi=0" def test_empty_subsystem_has_null_partition(self, s_empty): @@ -270,12 +270,12 @@ def test_empty_subsystem_has_null_partition(self, s_empty): """ result = s_empty.sia() - assert isinstance( - result, NullSystemIrreducibilityAnalysis - ), "Empty subsystem should return NullSIA" - assert isinstance( - result.partition, NullCut - ), "Empty subsystem should have NullCut partition" + assert isinstance(result, NullSystemIrreducibilityAnalysis), ( + "Empty subsystem should return NullSIA" + ) + assert isinstance(result.partition, NullCut), ( + "Empty subsystem should have NullCut partition" + ) assert result.phi == 0.0, "Empty subsystem should have phi=0" diff --git a/test/test_iit4_robust.py b/test/test_iit4_robust.py index f75f56629..31c63fda4 100644 --- a/test/test_iit4_robust.py +++ b/test/test_iit4_robust.py @@ -195,9 +195,9 @@ def test_phi_structure_has_distinctions_attribute(self, example_name): subsystem = EXAMPLES["subsystem"][example_name]() result = new_big_phi.phi_structure(subsystem) - assert hasattr( - result, "distinctions" - ), f"PhiStructure for '{example_name}' missing 'distinctions' attribute" + assert hasattr(result, "distinctions"), ( + f"PhiStructure for '{example_name}' missing 'distinctions' attribute" + ) @pytest.mark.parametrize( "example_name", @@ -227,9 +227,9 @@ def test_phi_structure_has_relations_attribute(self, example_name): subsystem = EXAMPLES["subsystem"][example_name]() result = new_big_phi.phi_structure(subsystem) - assert hasattr( - result, "relations" - ), f"PhiStructure for '{example_name}' missing 'relations' attribute" + assert hasattr(result, "relations"), ( + f"PhiStructure for '{example_name}' missing 'relations' attribute" + ) @pytest.mark.parametrize( "example_name", @@ -255,9 +255,9 @@ def test_phi_structure_distinctions_are_non_empty(self, example_name): subsystem = EXAMPLES["subsystem"][example_name]() result = new_big_phi.phi_structure(subsystem) - assert hasattr( - result, "distinctions" - ), "PhiStructure missing distinctions attribute" + assert hasattr(result, "distinctions"), ( + "PhiStructure missing distinctions attribute" + ) distinctions = result.distinctions assert distinctions is not None, ( @@ -310,9 +310,9 @@ def test_distinctions_have_mechanism_attribute(self): # Check each distinction has a mechanism for i, distinction in enumerate(concepts): - assert hasattr( - distinction, "mechanism" - ), f"Distinction {i} missing 'mechanism' attribute" + assert hasattr(distinction, "mechanism"), ( + f"Distinction {i} missing 'mechanism' attribute" + ) def test_distinctions_mechanisms_are_within_subsystem(self): """Distinction mechanisms should be subsets of subsystem nodes. diff --git a/test/test_invariants.py b/test/test_invariants.py index dd67ddec3..11d9a6a3b 100644 --- a/test/test_invariants.py +++ b/test/test_invariants.py @@ -156,21 +156,21 @@ def test_sia_partition_attribute_consistency(self, s, micro_s, reducible): # Irreducible systems with phi > 0 should have non-null partitions s_result = s.sia() if s_result.phi > 0: - assert not isinstance( - s_result.partition, NullCut - ), "System with phi > 0 has NullCut partition (should have real partition)" + assert not isinstance(s_result.partition, NullCut), ( + "System with phi > 0 has NullCut partition (should have real partition)" + ) micro_result = micro_s.sia() if micro_result.phi > 0: - assert not isinstance( - micro_result.partition, NullCut - ), "System with phi > 0 has NullCut partition (should have real partition)" + assert not isinstance(micro_result.partition, NullCut), ( + "System with phi > 0 has NullCut partition (should have real partition)" + ) # Reducible system should have null partition reducible_result = reducible.sia() - assert isinstance( - reducible_result.partition, NullCut - ), "Reducible system should have NullCut partition" + assert isinstance(reducible_result.partition, NullCut), ( + "Reducible system should have NullCut partition" + ) def test_partition_reduces_or_maintains_phi(self, s, micro_s): """Partitioned system cannot have more phi than unpartitioned. @@ -220,9 +220,9 @@ def test_selfloop_phi_depends_on_config(self, noisy_selfloop_single): # With config disabled, phi should be 0 with config.override(SINGLE_MICRO_NODES_WITH_SELFLOOPS_HAVE_PHI=False): result_disabled = noisy_selfloop_single.sia() - assert ( - result_disabled.phi == 0.0 - ), "Expected phi=0 when SINGLE_MICRO_NODES_WITH_SELFLOOPS_HAVE_PHI=False" + assert result_disabled.phi == 0.0, ( + "Expected phi=0 when SINGLE_MICRO_NODES_WITH_SELFLOOPS_HAVE_PHI=False" + ) # With config enabled and EMD, phi should be > 0 with config.override( @@ -251,9 +251,9 @@ def test_cache_clearing_option(self, s): CACHE_REPERTOIRES=True, ): _ = s.sia() - assert ( - s._repertoire_cache.cache - ), "Cache should have entries when clearing is disabled" + assert s._repertoire_cache.cache, ( + "Cache should have entries when clearing is disabled" + ) # Test with cache clearing enabled with config.override( @@ -262,9 +262,9 @@ def test_cache_clearing_option(self, s): CACHE_REPERTOIRES=True, ): _ = s.sia() - assert ( - not s._repertoire_cache.cache - ), "Cache should be empty when clearing is enabled" + assert not s._repertoire_cache.cache, ( + "Cache should be empty when clearing is enabled" + ) class TestPhiStructureInvariants: @@ -291,12 +291,12 @@ def test_phi_structure_has_distinctions(self, example_name): # Systems that have phi should have distinctions if hasattr(result, "phi") and result.phi > 0: - assert hasattr( - result, "distinctions" - ), f"System '{example_name}' has phi > 0 but no distinctions attribute" - assert ( - len(result.distinctions) > 0 - ), f"System '{example_name}' has phi > 0 but zero distinctions" + assert hasattr(result, "distinctions"), ( + f"System '{example_name}' has phi > 0 but no distinctions attribute" + ) + assert len(result.distinctions) > 0, ( + f"System '{example_name}' has phi > 0 but zero distinctions" + ) @pytest.mark.parametrize("example_name", ["basic", "fig4"]) def test_phi_structure_has_relations(self, example_name):