Isabel F. Cruz

156 papers A* 6A 4B 14C 4Misc 1Journal 32Unranked 77
YearRankTypeTitle / Venue / Authors
2021 conf
OM@ISWC
Zhu Wang, Isabel F. Cruz
2021 A* conf
WWW
Shen Wang, Xiaokai Wei, Cícero Nogueira dos Santos, Zhiguo Wang, Ramesh Nallapati, Andrew O. Arnold, Bing Xiang, Philip S. Yu, Isabel F. Cruz
2020 conf
COVID@SIGSPATIAL
Zhu Wang, Isabel F. Cruz
2020 conf
OM@ISWC
Beatriz Lima, Daniel Faria, Francisco M. Couto, Isabel F. Cruz, Catia Pesquita
2020 conf
SIGSPATIAL/GIS
Goce Trajcevski, Booma Sowkarthiga Balasubramani, Isabel F. Cruz, Roberto Tamassia, Xu Teng
2019 conf
OM@ISWC
Daniel Faria, Catia Pesquita, Teemu Tervo, Francisco M. Couto, Isabel F. Cruz
2019 ch.
Encyclopedia of Big Data Technologies
Booma Sowkarthiga Balasubramani, Isabel F. Cruz
2019 ed.
ISWC (1)
Chiara Ghidini, Olaf Hartig, Maria Maleshkova, Vojtech Svátek, Isabel F. Cruz, Aidan Hogan, Jie Song, Maxime Lefrançois, Fabien Gandon
2019 ed.
ISWC (2)
Chiara Ghidini, Olaf Hartig, Maria Maleshkova, Vojtech Svátek, Isabel F. Cruz, Aidan Hogan, Jie Song, Maxime Lefrançois, Fabien Gandon
2018 A* conf
WWW
Riccardo Porrini, Matteo Palmonari, Isabel F. Cruz
2018 conf
OM@ISWC
Daniel Faria, Catia Pesquita, Booma Sowkarthiga Balasubramani, Teemu Tervo, David Carriço, Rodrigo Garrilha, Francisco M. Couto, Isabel F. Cruz
2018 J jnl
J. Biomed. Semant.
Daniel Faria, Catia Pesquita, Isabela Mott, Catarina Martins, Francisco M. Couto, Isabel F. Cruz
2017 J jnl
CoRR
Booma Sowkarthiga Balasubramani, Omar Belingheri, Eric S. Boria, Isabel F. Cruz, Sybil Derrible, Michael D. Siciliano
2017 conf
SIGSPATIAL/GIS
Booma Sowkarthiga Balasubramani, Omar Belingheri, Eric S. Boria, Isabel F. Cruz, Sybil Derrible, Michael D. Siciliano
2017 conf
UrbanGIS@SIGSPATIAL
Vivek R. Shivaprabhu, Booma Sowkarthiga Balasubramani, Isabel F. Cruz
2017 conf
UrbanGIS@SIGSPATIAL
Zhu Wang, Booma Sowkarthiga Balasubramani, Isabel F. Cruz
2017 conf
OM@ISWC
Daniel Faria, Booma S. Balasubramani, Vivek R. Shivaprabhu, Isabela Mott, Catia Pesquita, Francisco M. Couto, Isabel F. Cruz
2017 J jnl
Semantic Web
Michelle Cheatham, Isabel F. Cruz, Jérôme Euzenat, Catia Pesquita
2016 conf
SIGSPATIAL/GIS
Seyed Iman Mirrezaei, Bruno Martins, Isabel F. Cruz
2016 J jnl
IEEE Trans. Knowl. Data Eng.
Isabel F. Cruz, Elena Ferrari, Yufei Tao
2016 conf
OM@ISWC
Daniel Faria, Catia Pesquita, Booma S. Balasubramani, Catarina Martins, João Cardoso, Hugo Curado, Francisco M. Couto, Isabel F. Cruz
2016 conf
UrbanGIS@SIGSPATIAL
Booma Sowkarthiga Balasubramani, Vivek R. Shivaprabhu, Smitha Krishnamurthy, Isabel F. Cruz, Tanu Malik
2016 J jnl
Semantic Web
Isabel F. Cruz, Matteo Palmonari, Francesco Loprete, Cosmin Stroe, Aynaz Taheri
2015 conf
OM
Daniel Faria, Catarina Martins, Amruta Nanavaty, Daniela Oliveira, Booma Sowkarthiga, Aynaz Taheri, Catia Pesquita, Francisco M. Couto, Isabel F. Cruz
2015 conf
VOILA@ISWC
Yiting Li, Cosmin Stroe, Isabel F. Cruz
2015 J jnl
Appl. Artif. Intell.
Joel Booth, Barbara Di Eugenio, Isabel F. Cruz, Ouri Wolfson
2015 conf
KNOW@LOD
Seyed Iman Mirrezaei, Bruno Martins, Isabel F. Cruz
2015 conf
ESWC (Satellite Events)
Seyed Iman Mirrezaei, Bruno Martins, Isabel F. Cruz
2015 conf
OM
Booma S. Balasubramani, Aynaz Taheri, Isabel F. Cruz
2015 conf
VOILA@ISWC
Jillian Aurisano, Amruta Nanavaty, Isabel F. Cruz
2014 conf
ISWC (Posters & Demos)
Daniel Faria, Catia Pesquita, Emanuel Santos, Isabel F. Cruz, Francisco M. Couto
2014 conf
OM
Daniel Faria, Catarina Martins, Amruta Nanavaty, Aynaz Taheri, Catia Pesquita, Emanuel Santos, Isabel F. Cruz, Francisco M. Couto
2014 A* ed.
ICDE
Isabel F. Cruz, Elena Ferrari, Yufei Tao, Elisa Bertino, Goce Trajcevski
2014 B conf
EKAW
Isabel F. Cruz, Francesco Loprete, Matteo Palmonari, Cosmin Stroe, Aynaz Taheri
2013 conf
OM
Daniel Faria, Catia Pesquita, Emanuel Santos, Isabel F. Cruz, Francisco M. Couto
2013 J jnl
Artif. Intell. Rev.
Isabel F. Cruz, Matteo Palmonari, Federico Caimi, Cosmin Stroe
2013 conf
SIGSPATIAL/GIS
Isabel F. Cruz, Venkat R. Ganesh, Claudio Caletti, Pavan Reddy
2013 conf
GIR
Isabel F. Cruz, Venkat R. Ganesh, Seyed Iman Mirrezaei
2013 conf
OTM Conferences
Daniel Faria, Catia Pesquita, Emanuel Santos, Matteo Palmonari, Isabel F. Cruz, Francisco M. Couto
2013 conf
ISWC (1)
Catia Pesquita, Daniel Faria, Cosmin Stroe, Emanuel Santos, Isabel F. Cruz, Francisco M. Couto
2012 B conf
ESWC
Isabel F. Cruz, Alessio Fabiani, Federico Caimi, Cosmin Stroe, Matteo Palmonari
2012 A* conf
ICDE
Isabel F. Cruz, Cosmin Stroe, Matteo Palmonari
2012 conf
OTM Conferences (2)
Sonia Bergamaschi, Isabel F. Cruz
2012 conf
OTM Workshops
Sonia Bergamaschi, Isabel F. Cruz
2012 ed.
OTM Conferences (1)
Robert Meersman, Hervé Panetto, Tharam S. Dillon, Stefanie Rinderle-Ma, Peter Dadam, Xiaofang Zhou, Siani Pearson, Alois Ferscha, Sonia Bergamaschi, Isabel F. Cruz
2012 ed.
OTM Conferences (2)
Robert Meersman, Hervé Panetto, Tharam S. Dillon, Stefanie Rinderle-Ma, Peter Dadam, Xiaofang Zhou, Siani Pearson, Alois Ferscha, Sonia Bergamaschi, Isabel F. Cruz
2012 ed.
SIGSPATIAL/GIS
Isabel F. Cruz, Craig A. Knoblock, Peer Kröger, Egemen Tanin, Peter Widmayer
2012 J jnl
CoRR
Daniel Faria, Catia Pesquita, Emanuel Santos, Francisco M. Couto, Cosmin Stroe, Isabel F. Cruz
2012 B ed.
WISE
Xiaoyang Sean Wang, Isabel F. Cruz, Alex Delis, Guangyan Huang
2011 C ed.
IDEAS
Bipin C. Desai, Isabel F. Cruz, Jorge Bernardino
2011 ed.
GIS
Isabel F. Cruz, Divyakant Agrawal, Christian S. Jensen, Eyal Ofek, Egemen Tanin
2011 conf
ICBO
Valerie Cross, Cosmin Stroe, Xueheng Hu, Pramit Silwal, Maryam Panahiazar, Isabel F. Cruz, Priti Parikh, Amit P. Sheth
2011 conf
ICBO
Isabel F. Cruz, Cosmin Stroe, Catia Pesquita, Francisco M. Couto, Valerie Cross
2011 conf
Geospatial Semantics and the Semantic Web
Rigel Gjomemo, Isabel F. Cruz
2011 ed.
OM
Pavel Shvaiko, Jérôme Euzenat, Tom Heath, Christoph Quix, Ming Mao, Isabel F. Cruz
2011 J jnl
VLDB J.
Goce Trajcevski, Roberto Tamassia, Isabel F. Cruz, Peter Scheuermann, David Hartglass, Christopher Zamierowski
2011 conf
LDH
Isabel F. Cruz, Matteo Palmonari, Federico Caimi, Cosmin Stroe
2011 conf
OM
Isabel F. Cruz, Cosmin Stroe, Federico Caimi, Alessio Fabiani, Catia Pesquita, Francisco M. Couto, Matteo Palmonari
2010 conf
SPRINGL
Isabel F. Cruz, Rigel Gjomemo, Greg Jarzab
2010 conf
OM
Catia Pesquita, Cosmin Stroe, Isabel F. Cruz, Francisco M. Couto
2010 conf
AMW
Isabel F. Cruz
2010 ed.
OM
Pavel Shvaiko, Jérôme Euzenat, Fausto Giunchiglia, Heiner Stuckenschmidt, Ming Mao, Isabel F. Cruz
2010 conf
OM
Isabel F. Cruz, Cosmin Stroe, Michele Caci, Federico Caimi, Matteo Palmonari, Flavio Palandri Antonelli, Ulas C. Keles
2009 B conf
EDBT
Joel Booth, A. Prasad Sistla, Ouri Wolfson, Isabel F. Cruz
2009 J jnl
Proc. VLDB Endow.
Isabel F. Cruz, Flavio Palandri Antonelli, Cosmin Stroe
2009 B conf
EDBT
Goce Trajcevski, Roberto Tamassia, Hui Ding, Peter Scheuermann, Isabel F. Cruz
2009 conf
OM
Isabel F. Cruz, Flavio Palandri Antonelli, Cosmin Stroe
2009 ch.
Complex Systems in Knowledge-based Environments
Isabel F. Cruz, Huiyong Xiao
2009 conf
ICSC
Joel Booth, Barbara Di Eugenio, Isabel F. Cruz, Ouri Wolfson
2009 conf
OM
Isabel F. Cruz, Flavio Palandri Antonelli, Cosmin Stroe, Ulas C. Keles, Angela Maduko
2008 C conf
CollaborateCom
Isabel F. Cruz, Rigel Gjomemo, Benjamin Lin, Mirko Orsini
2008 conf
KES (2)
Isabel F. Cruz, Rigel Gjomemo, Mirko Orsini
2008 J jnl
VLDB J.
Isabel F. Cruz, Huiyong Xiao
2008 conf
GIS
Isabel F. Cruz, Rigel Gjomemo, Benjamin Lin, Mirko Orsini
2008 conf
DMSN
Goce Trajcevski, Oliviu Ghica, Peter Scheuermann, Roberto Tamassia, Isabel F. Cruz
2008 ch.
Geospatial Services and Applications for the Internet
Isabel F. Cruz, Huiyong Xiao
2008 J jnl
Trans. GIS
Isabel F. Cruz, William Sunna
2007 conf
OTM Workshops (2)
Lorenzo Cirio, Isabel F. Cruz, Roberto Tamassia
2007 J jnl
J. Vis. Lang. Comput.
Isabel F. Cruz, William Sunna, Nalin Makar, Sujan Bathala
2007 B conf
MDM
Goce Trajcevski, Hui Ding, Peter Scheuermann, Isabel F. Cruz
2007 B conf
DBSec
Isabel F. Cruz, Roberto Tamassia, Danfeng Yao
2007 conf
GeoS
William Sunna, Isabel F. Cruz
2007 conf
OM
William Sunna, Isabel F. Cruz
2006 conf
SemDesk
Huiyong Xiao, Isabel F. Cruz
2006 J jnl
J. Data Semant.
Huiyong Xiao, Isabel F. Cruz
2006 J jnl
GeoInformatica
Dieter Pfoser, Isabel F. Cruz
2006 Misc ed.
ISWC
Isabel F. Cruz, Stefan Decker, Dean Allemang, Chris Preist, Daniel Schwabe, Peter Mika, Michael Uschold, Lora Aroyo
2005 conf
Semantic Desktop Workshop
Huiyong Xiao, Isabel F. Cruz
2005 J jnl
Int. J. Electron. Gov. Res.
Nancy Wiegand, Isabel F. Cruz, Naijun Zhou, William Sunna
2005 ed.
GeoS
M. Andrea Rodríguez, Isabel F. Cruz, Max J. Egenhofer, Sergei Levashkin
2004 ed.
GIS
Dieter Pfoser, Isabel F. Cruz, Marc Ronthaler
2004 B conf
VL/HCC
Isabel F. Cruz, Yuan Feng Huang
2004 conf
DG.O
Nancy Wiegand, Naijun Zhou, Isabel F. Cruz, William Sunna
2004 C conf
IDEAS
Isabel F. Cruz, Huiyong Xiao, Feihong Hsu
2004 conf
DG.O
Isabel F. Cruz, William Sunna, Anjli Chaudhry
2004 conf
DG.O
Isabel F. Cruz, William Sunna, Nancy Wiegand, Naijun Zhou
2004 conf
AP2PC
Isabel F. Cruz, Huiyong Xiao, Feihong Hsu
2004 J jnl
SIGMOD Rec.
Silvia Nittel, Anthony Stefanidis, Isabel F. Cruz, Max J. Egenhofer, Dina Q. Goldin, A. Howard, Alexandros Labrinidis, Samuel Madden, Agnès Voisard, Michael F. Worboys
2004 conf
GIScience
Isabel F. Cruz, William Sunna, Anjli Chaudhry
2003 conf
Multimedia Information Systems
Isabel F. Cruz, Haiyan Lin, Yuan Feng Huang
2003 B conf
SSDBM
Nancy Wiegand, Naijun Zhou, Isabel F. Cruz
2003 conf
DG.O
Nancy Wiegand, Naijun Zhou, Stephen J. Ventura, Isabel F. Cruz
2003 ed.
PSSS
Raphael Volz, Stefan Decker, Isabel F. Cruz
2003 ed.
SWDB
Isabel F. Cruz, Vipul Kashyap, Stefan Decker, Rainer Eckstein
2003 conf
DG.O
Nancy Wiegand, Naijun Zhou, Stephen J. Ventura, Isabel F. Cruz, William Sunna
2003 J jnl
IEEE Intell. Syst.
Isabel F. Cruz, Afsheen Rajendran
2003 B conf
WISE
Isabel F. Cruz, Huiyong Xiao
2002 J jnl
IEEE Multim.
David C. Brown, Esteban Burbano, Joel Minski, Isabel F. Cruz
2002 conf
ACM-GIS
Isabel F. Cruz, Afsheen Rajendran, William Sunna, Nancy Wiegand
2002 conf
DG.O
Nancy Wiegand, E. D. Patterson, Naijun Zhou, Stephen J. Ventura, Isabel F. Cruz
2002 J jnl
SIGMOD Rec.
Isabel F. Cruz, Ashfaq A. Khokhar, Bing Liu, A. Prasad Sistla, Ouri Wolfson, Clement T. Yu
2002 ed.
The Emerging Semantic Web
Isabel F. Cruz, Stefan Decker, Jérôme Euzenat, Deborah L. McGuinness
2002 ch.
Visualizing the Semantic Web
Stephen Kimani, Tiziana Catarci, Isabel F. Cruz
2001 J jnl
J. Vis. Lang. Comput.
Isabel F. Cruz, Peter S. Leveille
2001 conf
SWWS
Isabel F. Cruz, Paul W. Calnan
2001 conf
The Emerging Semantic Web
Isabel F. Cruz, Paul W. Calnan
2001 ed.
SWWS
Isabel F. Cruz, Stefan Decker, Jérôme Euzenat, Deborah L. McGuinness
2000 A conf
SIGCSE
David C. Brown, Isabel F. Cruz, David Finkel, Robert E. Kinicki, Craig E. Wills
2000 conf
VL
Isabel F. Cruz, Peter S. Leveille
2000 J jnl
SIGMOD Rec.
Isabel F. Cruz
2000 conf
VDB
Isabel F. Cruz, Lijun Leo Liu, Tony Y. Wu
1999 conf
SIGMOD Conference
Isabel F. Cruz, Kimberly M. James
1999 conf
DANTE
Tiziana Catarci, Giuseppe Santucci, Maria Francesca Costabile, Isabel F. Cruz
1999 conf
SIGDOC
Isabel F. Cruz, Gerard T. McGuire
1999 J jnl
Int. J. Digit. Libr.
Isabel F. Cruz
1999 conf
ICMCS, Vol. 2
Isabel F. Cruz, Parag S. Mahalley
1999 C conf
IDEAS
Isabel F. Cruz, Kimberly M. James
1999 J jnl
Comput. Geom.
James E. Baker, Isabel F. Cruz, Giuseppe Liotta, Roberto Tamassia
1999 B conf
ITiCSE
David Finkel, Isabel F. Cruz
1998 J jnl
Theory Pract. Object Syst.
Isabel F. Cruz, Wendy T. Lucas
1998 A conf
GD
Isabel F. Cruz, Donald I. Lambe
1998 J jnl
Constraints An Int. J.
Isabel F. Cruz, Kim Marriott, Pascal Van Hentenryck
1998 conf
EP
Isabel F. Cruz, Slava Borisov, Michael A. Marks, Timothy R. Webb
1997 A* conf
ACM Multimedia
Isabel F. Cruz, Wendy T. Lucas
1997 conf
VL
Isabel F. Cruz, Wendy T. Lucas
1997 conf
SIGMOD Conference
Isabel F. Cruz, Michael Averbuch, Wendy T. Lucas, Melissa Radzyminski, Kirby Zhang
1996 B conf
AVI
James E. Baker, Isabel F. Cruz, Giuseppe Liotta, Roberto Tamassia
1996 conf
SCG
James E. Baker, Isabel F. Cruz, Giuseppe Liotta, Roberto Tamassia
1996 J jnl
SIGMOD Rec.
Tiziana Catarci, Isabel F. Cruz
1996 B conf
AVI
Isabel F. Cruz
1996 J jnl
ACM Comput. Surv.
Brad A. Myers, James D. Hollan, Isabel F. Cruz
1996 J jnl
ACM Comput. Surv.
Isabel F. Cruz
1996 B conf
AVI
James E. Baker, Isabel F. Cruz, Giuseppe Liotta, Roberto Tamassia
1995 A conf
GD
Isabel F. Cruz, Joseph P. Twarog
1995 J jnl
ACM Comput. Surv.
James E. Baker, Isabel F. Cruz, Giuseppe Liotta, Roberto Tamassia
1995 J jnl
J. Vis. Lang. Comput.
Isabel F. Cruz, Peter Eades
1995 conf
VDB
Tiziana Catarci, Maria Francesca Costabile, Isabel F. Cruz, Yannis E. Ioannidis, Ben Shneiderman
1994 A conf
GD
Isabel F. Cruz, Ashim Garg
1994 conf
Workshop on Deductive Databases and Logic Programming
Tiziana Catarci, Isabel F. Cruz
1994 conf
VL
Isabel F. Cruz
1993 conf
PPCP
Isabel F. Cruz
1992 conf
SIGMOD Conference
Isabel F. Cruz
1992 J jnl
SIGMOD Rec.
Mariano P. Consens, Isabel F. Cruz, Alberto O. Mendelzon
1989 A* conf
ICDE
Isabel F. Cruz, Theodore S. Norvell
1988 conf
Expert Database Conf.
Isabel F. Cruz, Alberto O. Mendelzon, Peter T. Wood
1987 conf
SIGMOD Conference
Isabel F. Cruz, Alberto O. Mendelzon, Peter T. Wood
tests/unit/test_decompile_similarity.py
← Index tests/unit/test_decompile_similarity.py python
"""Unit tests for similarity modules:
- bninja/similarity/minhashcustom.py
- bninja/similarity/minhasher.py
"""
import numpy as np
import pytest

from redb.extractors.decompiler.bninja.similarity.minhashcustom import MinHashCustom
from redb.extractors.decompiler.bninja.analysis.low_level_normalization import LowLevelNormalization


# ============================================================================
# 2a. MinHashCustom
# ============================================================================

class TestMinHashCustomInit:
    def test_init_empty(self):
        mh = MinHashCustom()
        assert not mh.hasMinHash()
        assert mh.minhash == b""
        assert mh.minhash_int == []

    def test_init_from_signature(self):
        sig = [10, 20, 30, 40]
        mh = MinHashCustom(minhash_signature=sig)
        assert mh.hasMinHash()
        assert mh.minhash_int == sig

    def test_init_from_bytes_uint32(self):
        """Verify round-trip: ints -> bytes -> MinHashCustom -> ints."""
        sig = [100, 200, 300]
        packed = np.array(sig, dtype=np.uint32).tobytes()
        # np.frombuffer returns numpy scalars; setMinHash does % 2**32 which
        # overflows numpy uint32, so verify the raw bytes round-trip instead.
        raw_arr = np.frombuffer(packed, dtype=np.uint32)
        assert list(raw_arr) == sig

    def test_init_from_bytes_uint8(self):
        """Verify round-trip: ints -> bytes -> back."""
        sig = [10, 20, 30]
        packed = np.array(sig, dtype=np.uint8).tobytes()
        raw_arr = np.frombuffer(packed, dtype=np.uint8)
        assert list(raw_arr) == sig

    def test_init_both_raises(self):
        sig = [1, 2, 3]
        packed = np.array(sig, dtype=np.uint32).tobytes()
        with pytest.raises(ValueError, match="only one"):
            MinHashCustom(minhash_bytes=packed, minhash_signature=sig)


class TestMinHashCustomSetGet:
    def test_set_and_get_minhash(self):
        mh = MinHashCustom()
        sig = [5, 10, 15]
        mh.setMinHash(sig)
        raw = mh.getMinHash()
        assert raw == np.array(sig, dtype=np.uint32).tobytes()
        assert mh.getMinHashInt() == sig

    def test_minhash_int_truncation(self):
        mh = MinHashCustom(minhash_bits=8)
        # Values > 256 should be truncated mod 2^8
        mh.setMinHash([300, 500, 256])
        for val in mh.minhash_int:
            assert 0 <= val < 256


class TestMinHashCustomHashData:
    def test_hash_data_string(self):
        result = MinHashCustom.hashData("hello", 42)
        assert isinstance(result, int)
        assert 0 <= result <= 0xFFFFFFFF

    def test_hash_data_bytes(self):
        result = MinHashCustom.hashData(b"bytes", 42)
        assert isinstance(result, int)
        assert 0 <= result <= 0xFFFFFFFF

    def test_hash_data_list(self):
        result = MinHashCustom.hashData([1, 2, 3], 42)
        assert isinstance(result, int)
        assert 0 <= result <= 0xFFFFFFFF

    def test_hash_data_unsupported_type(self):
        with pytest.raises(NotImplementedError, match="Type not supported"):
            MinHashCustom.hashData(123, 42)

    def test_hash_data_deterministic(self):
        assert MinHashCustom.hashData("test", 7) == MinHashCustom.hashData("test", 7)


class TestMinHashCustomScore:
    def test_score_identical(self):
        sig = [1, 2, 3, 4, 5]
        mh1 = MinHashCustom(minhash_signature=sig)
        mh2 = MinHashCustom(minhash_signature=sig)
        score = MinHashCustom.calculateMinHashScore(
            mh1.getMinHash(), mh2.getMinHash()
        )
        assert score == 100.0

    def test_score_different(self):
        mh1 = MinHashCustom(minhash_signature=[1, 2, 3, 4, 5])
        mh2 = MinHashCustom(minhash_signature=[6, 7, 8, 9, 10])
        score = MinHashCustom.calculateMinHashScore(
            mh1.getMinHash(), mh2.getMinHash()
        )
        assert score < 100.0

    def test_score_against(self):
        sig1 = [1, 2, 3, 4, 5]
        sig2 = [1, 2, 99, 4, 5]
        mh1 = MinHashCustom(minhash_signature=sig1)
        mh2 = MinHashCustom(minhash_signature=sig2)
        instance_score = mh1.scoreAgainst(mh2)
        static_score = MinHashCustom.calculateMinHashScore(
            mh1.getMinHash(), mh2.getMinHash()
        )
        assert instance_score == static_score


class TestMinHashCustomBitModes:
    def test_8bit_mode(self):
        mh = MinHashCustom(minhash_bits=8)
        mh.setMinHash([10, 20, 30])
        raw = mh.getMinHash()
        arr = np.frombuffer(raw, dtype=np.uint8)
        assert list(arr) == [10, 20, 30]

    def test_32bit_mode(self):
        mh = MinHashCustom(minhash_bits=32)
        mh.setMinHash([10, 20, 30])
        raw = mh.getMinHash()
        arr = np.frombuffer(raw, dtype=np.uint32)
        assert list(arr) == [10, 20, 30]


# ============================================================================
# 2b. MinHasher
# ============================================================================


class MockILNode:
    """Mock IL node with operation and operands for normalization."""
    def __init__(self, operation, operands=None):
        self.operation = operation
        self.operands = operands or []


class MockLLILBasicBlock:
    """Mock LLIL basic block that yields IL instructions."""
    def __init__(self, instructions):
        self._instructions = instructions

    def __iter__(self):
        return iter(self._instructions)


class MockLLILFunction:
    """Mock LLIL function with basic blocks."""
    def __init__(self, basic_blocks):
        self.basic_blocks = basic_blocks


# Import MinHasher after we know the module can handle the import
from redb.extractors.decompiler.bninja.similarity.minhasher import (
    MinHasher,
    MINHASH_SIGNATURE_LENGTH,
    MINHASH_SIGNATURE_BITS,
)


class TestMinHasherMakeNgrams:
    def setup_method(self):
        # Create a minimal minhasher with a mock LLIL function
        empty_func = MockLLILFunction([])
        self.hasher = MinHasher(seed=42, il_function=empty_func)

    def test_make_ngrams_basic(self):
        result = self.hasher.make_ngrams(["a", "b", "c", "d"], n=3)
        assert result == [("a", "b", "c"), ("b", "c", "d")]

    def test_make_ngrams_short_input(self):
        result = self.hasher.make_ngrams(["a", "b"], n=3)
        assert result == []

    def test_make_ngrams_exact_n(self):
        result = self.hasher.make_ngrams(["a", "b", "c"], n=3)
        assert result == [("a", "b", "c")]


class TestMinHasherCalculate:
    def _make_llil_function(self, num_instructions=10):
        """Create a mock LLIL function with enough instructions."""
        instructions = [
            MockILNode(operation=i % 20) for i in range(num_instructions)
        ]
        bb = MockLLILBasicBlock(instructions)
        return MockLLILFunction([bb])

    def test_calculate_minhash_empty_function(self):
        # Function with < 3 LLIL instructions -> empty list
        func = self._make_llil_function(num_instructions=2)
        hasher = MinHasher(seed=42, il_function=func)
        result = hasher.calculateMinHash()
        assert result == []

    def test_calculate_minhash_deterministic(self):
        func = self._make_llil_function(num_instructions=20)
        h1 = MinHasher(seed=42, il_function=func)
        h2 = MinHasher(seed=42, il_function=func)
        assert h1.calculateMinHash() == h2.calculateMinHash()

    def test_calculate_minhash_length(self):
        func = self._make_llil_function(num_instructions=20)
        hasher = MinHasher(seed=42, il_function=func)
        result = hasher.calculateMinHash()
        assert len(result) == MINHASH_SIGNATURE_LENGTH

    def test_calculate_minhash_value_range(self):
        func = self._make_llil_function(num_instructions=20)
        hasher = MinHasher(seed=42, il_function=func)
        result = hasher.calculateMinHash()
        for val in result:
            assert 0 <= val < 2 ** MINHASH_SIGNATURE_BITS

    def test_shingle_hash_deterministic(self):
        func = self._make_llil_function(num_instructions=5)
        hasher = MinHasher(seed=42, il_function=func)
        shingle = ([1, 2], [3, 4], [5, 6])
        assert hasher.shingle_hash(shingle, 99) == hasher.shingle_hash(shingle, 99)

    def test_seed_reproducibility(self):
        func = self._make_llil_function(num_instructions=20)
        h1 = MinHasher(seed=1, il_function=func)
        h2 = MinHasher(seed=2, il_function=func)
        r1 = h1.calculateMinHash()
        r2 = h2.calculateMinHash()
        # Different seeds should (very likely) produce different results
        assert r1 != r2