Closed KylinGuo closed 3 months ago
Hey, thanks for reporting this. I'm not quite certain what you are trying to achieve here, would you mind explaining your use case? It seems that you are duplicating the mendeleev.models.Element
class - maybe have a look at it and see it satisfies your use case.
A longer answer is that currently mendeleev
suffers from a long import time (only first import) since it's fetching data for 118 elements and instantiating objects to allow for importing elements directly, i.e.
from mendeev import Fe, Ni
print(Fe.name)
There are a few ways of fetching data from mendeleev as explained in this section of the docs. In essence you have several options:
elements
or importing element objects directly as in the example aboveelements.db
sqlite database shipped with the packageThe order roughly corresponds to slowest to fastest with certain caveats but without more info on your use case it's hard to say anything more.
Does that help?
Hey, thanks for reporting this. I'm not quite sure what you are trying to achieve here, would you mind explaining you use case? It seems that you are duplicating the
mendeleev.models.Element
class - maybe have a look at it and see it satisfies your use case.A longer answer is that currently
mendeleev
suffers from a long import time (only first import) since it's fetching data for 118 elements and instantiating objects to allow for importing elements directly, i.e.from mendeev import Fe, Ni print(Fe.name)
There are a few ways of fetching data from mendeleev as explained in this section of the docs. In essence you have several options:
- using mendeleev python api, with methods like
elements
or importing element object directly as in the example above- fetching entire tables from the db with pandas or sqlalchemy
- querying the db from python with sqlalchemy or sqlite
- getting data straight from
elements.db
sqlite database shipped with the packageThe order roughly corresponds to slowest to fastest with certain caveats but without more info on your use case it's hard to say anything more.
Does that help?
Dear Immentel, Thank you for your assistance! I've come to recognize the improper usage of Mendeleev's 'element' in my class 'Element'. 'fetch_table' seems to be a more suitable approach for me. Once again, thank you. Allow me to provide some context on my previous work. I am in the process of featurizing a set of compositions. One potential solution involves utilizing composition-weighted elemental properties, which necessitates having the properties of each chemical element within a composition. Best regards, Qilin.
I'm happy it helped. Please note that while bulk of the element properties are stored and the db and available with fetch_table
some properties are computed on the fly and therefore not stored. Examples of computed properties: electrophilicity
, hardness
, softness
, etc.
I'm closing this issue, but feel free to open a new one if you have further questions.
Dear Developers, Thanks for your very deep and brilliant work for this packages! Here I seek for your help/suggestions on my code to improve the performance. I defined
Element
class in oder to build features for compositions. However I find that myElement
works slowly compared with pymatgenElement
when dealing with a lot of compositions. The question is that how can I improve the performance. I guess that I am not on the right way. Here are my MWE. Any suggestion will be great appreciated!Here is the sample output.