<commit_before># This file is part of QNET.
#
#    QNET is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#    QNET is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with QNET.  If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2016, <NAME>
#
###########################################################################

from qnet.circuit_components.displace_cc import Displace


def test_displace_uniqueness():
    """Test that different instantiations of a Displace component are poperly
    recognized as different"""
    W1 = Displace('W', alpha=(-79.838356622-35.806239846j))
    W2 = Displace('W', alpha=-79.838356622)
    W3 = Displace('W')
    assert 'alpha' in W1.kwargs
    assert hash(W1) != hash(W2)
    assert W1 != W2
    assert W2 != W3
    assert W1 != W3<commit_msg>Verify "identical" subcomponents can be told apart<commit_after># This file is part of QNET.
#
#    QNET is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#    QNET is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with QNET.  If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2016, <NAME>
#
###########################################################################

from qnet.circuit_components.displace_cc import Displace
from qnet.circuit_components.two_port_kerr_cavity_cc import TwoPortKerrCavity


def test_displace_uniqueness():
    """Test that different instantiations of a Displace component are poperly
    recognized as different"""
    W1 = Displace('W', alpha=(-79.838356622-35.806239846j))
    W2 = Displace('W', alpha=-79.838356622)
    W3 = Displace('W')
    assert 'alpha' in W1.kwargs
    assert hash(W1) != hash(W2)
    assert W1 != W2
    assert W2 != W3
    assert W1 != W3


def test_subcomponents_uniqueness():
    """Test that two "identical" subcomponent from two different components do
    not compare as identical"""
    C1 = TwoPortKerrCavity('Kerr', Delta=1.0)
    C2 = TwoPortKerrCavity('Kerr', Delta=2.0)
    assert C1 != C2
    assert C1.port1 != C2.port1
    assert C1.port2 != C2.port2
{'fraction_non_alphanumeric': 0.13367174280879865, 'fraction_numerical': 0.03925549915397631, 'mean_word_length': 3.744783306581059, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2882249', 'n_tokens_mistral': 924, 'n_tokens_neox': 867, 'n_words': 340}