Giter Club home page Giter Club logo

Comments (5)

bpuchala avatar bpuchala commented on June 14, 2024 1

@bpuchala Would you be able to submit a fix for this that implements the type promotion so we can see if there are any unintended downstream implications?

Sorry, I'm just a user here :)

from pymatgen.

janosh avatar janosh commented on June 14, 2024

Oh dear, loss of symmetry in __eq__ is pretty serious, esp. in the core Structure class.
@bpuchala Thanks for reporting and thanks for finding the root cause! 🙏

I'm in favor of making Structure.__eq__ more discriminative by promoting Elements to Species with oxi state 0 so that

element_structure == species_structure
>>> False
# and
species_structure == element_structure
>>> False

but I'm interested to hear @shyuep and @mkhorton's opinions.

@bpuchala Would you be able to submit a fix for this that implements the type promotion so we can see if there are any unintended downstream implications?

from pymatgen.

shyuep avatar shyuep commented on June 14, 2024

I would just fix Element such that it only equates equal to Element and not Specie. I dislike the ElementBase implementation. I think it overcomplicates matters relative to just a straight Enum.

from pymatgen.

janosh avatar janosh commented on June 14, 2024

I would just fix Element such that it only equates equal to Element and not Specie.

That's already the case.

from pymatgen.core import Element, Species

Element('O') == Species('O')
>>> False

I dislike the ElementBase implementation. I think it overcomplicates matters relative to just a straight Enum.

I've said the same thing in the past. IIRC @mkhorton had some reservations about that.

from pymatgen.

shyuep avatar shyuep commented on June 14, 2024

@janosh No, that wasn't the case. Species("Fe", 0) == Element("Fe") but Element("Fe") != Species("Fe", 0). That was the whole crux of the issue reported. I already pushed a fix.

from pymatgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.