-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable comparing Elements for equality #43
Conversation
This handles my use case perfectly, thanks! The things I can think of - basic behavior of There appear to be many attributes left over after In [1]: from mendeleev import element, O
In [2]: assert element(8) == O
In [3]: assert element(8) == element(8)
In [4]: assert O == O
In [5]: def f():
...: return element(8)
...:
In [6]: assert f() == element(8) == O
In [7]: element_dict = {O: 0}
In [8]: element_dict[O] = 1
In [9]: element_dict[O]
Out[9]: 1
In [10]: to_drop = [
...: "_ionization_energies",
...: "_oxidation_states",
...: "_sa_instance_state",
...: "_series",
...: "_series_id",
...: "ec",
...: "group",
...: "ionic_radii",
...: "isotopes",
...: "screening_constants",
...: ]
In [11]: [(k, v) for k, v in O.__dict__.items() if k not in to_drop]
Out[11]:
[('covalent_radius_cordero', 66.0),
('en_ghosh', 0.304575),
('mendeleev_number', 99),
('covalent_radius_pyykko', 63.0),
('en_pauling', 3.44),
('metallic_radius', None),
('covalent_radius_pyykko_double', 57.0),
('evaporation_heat', None),
('metallic_radius_c12', None),
('covalent_radius_pyykko_triple', 53.0),
('fusion_heat', None),
('molcas_gv_color', '#f32e42'),
('c6', 15.6),
('gas_basicity', 459.6),
('name', 'Oxygen'),
('c6_gb', 16.7),
('geochemical_class', 'major'),
('name_origin', 'Greek: oxys and genes, (acid former).'),
('cpk_color', '#f00000'),
('glawe_number', 97),
('period', 2),
('density', 0.0013080000000000001),
('goldschmidt_class', 'litophile'),
('pettifor_number', 101),
('group_id', 16),
('proton_affinity', 485.2),
('description',
"A colourless, odourless gaseous element belonging to group 16 of the periodic table. It is the most abundant element present in the earth's crust. It also makes up 20.8% of the Earth's atmosphere. For industrial purposes, it is separated from liquid air by fractional distillation. It is used in high temperature welding, and in breathing. It commonly comes in the form of Oxygen, but is found as Ozone in the upper atmosphere. It was discovered by Priestley in 1774."),
('dipole_polarizability', 5.3),
('heat_of_formation', 249.229),
('sources',
'Obtained primarily from liquid air by fractional distillation. Small amounts are made in the laboratory by electrolysis of water or heating potassium chlorate (KClO3) with manganese dioxide (MnO2) catalyst.'),
('dipole_polarizability_unc', 0.2),
('is_monoisotopic', None),
('specific_heat', None),
('discoverers', 'Joseph Priestly, Carl Wilhelm Scheele'),
('is_radioactive', False),
('symbol', 'O'),
('discovery_location', 'England/Sweden'),
('jmol_color', '#ff0d0d'),
('thermal_conductivity', 0.027),
('discovery_year', 1774),
('lattice_constant', 6.83),
('uses',
'Used in steel making, welding, and supporting life. Naturally occuring ozone (O3) in the upper atmosphere shields the earth from ultraviolet radiation.'),
('electron_affinity', 1.4611135),
('lattice_structure', 'CUB'),
('vdw_radius', 152.0),
('en_allen', 21.36),
('melting_point', 54.8),
('vdw_radius_alvarez', 150.0),
('vdw_radius_bondi', 152.0),
('econf', '[He] 2s2 2p4'),
('vdw_radius_truhlar', None),
('vdw_radius_rt', 158.0),
('abundance_crust', 461000.0),
('vdw_radius_batsanov', 155.0),
('abundance_sea', 857000.0),
('vdw_radius_dreiding', 340.46),
('annotation', 'density(@ -183C), '),
('vdw_radius_uff', 350.0),
('atomic_number', 8),
('vdw_radius_mm3', 182.0),
('atomic_radius', 60.0),
('atomic_radius_rahm', 171.0),
('atomic_volume', 14.0),
('atomic_weight', 15.999),
('atomic_weight_uncertainty', None),
('block', 'p'),
('boiling_point', 90.19),
('cas', '7782-44-7'),
('covalent_radius_bragg', 65.0)]
In [12]: assert O != element(7)
In [13]: assert element(8) != element(7) |
32513be
to
0579dc3
Compare
Thanks for the feedback @mattwthompson! |
Thanks for the comments @kalvdans! If you feel something should still be reworked please submit an issue. |
Yes, I feel that the hash is misused for equality, I've opened #47 with my suggestions :) |
fixes #42