Skip to content

Conversation

Copy link

Copilot AI commented Sep 16, 2025

Addresses issue #242 by adding comprehensive documentation for the units feature that was implemented in PR #239.

Overview

The mendeleev package now supports accessing physical properties with proper units using the Pint library. Users can append _u to any property name to get a Quantity object with units attached, enabling safer calculations and easy unit conversions.

Example Usage

from mendeleev import H, Al
from mendeleev.models import ureg

# Access properties with units
print(H.atomic_weight_u)  # 1.008 dalton
print(Al.density_u)       # 2.7 gram / centimeter ** 3

# Unit conversions
temp = Al.melting_point_u
print(temp.to('celsius'))  # 660.323 degree_Celsius

# Safe calculations
volume = 1 * ureg.liter
mass = Al.density_u * volume
print(mass.to('gram'))     # 2700.0 gram

Documentation Added

1. Comprehensive Reference (docs/source/data_access.rst)

  • Complete listing of all 80 properties across classes that support units
  • 63 Element properties organized by category (atomic, thermal, electronic, etc.)
  • Coverage of IonicRadius, IonizationEnergy, Isotope, PhaseTransition, and ScatteringFactor classes
  • Detailed examples and error handling documentation

2. Interactive Tutorial (docs/source/notebooks/working_with_units.ipynb)

  • Step-by-step tutorial with practical examples
  • Unit conversions, calculations, and multi-element comparisons
  • Error handling and edge cases
  • Integration with other model classes

3. Quick Reference (docs/source/quick.rst)

  • Brief introduction to units feature for discoverability
  • Simple example to get users started

Properties with Units Support

The documentation covers all supported properties including:

Element properties: atomic_weight, density, melting_point, boiling_point, atomic_radius, covalent_radius_, vdw_radius_, abundance_*, electron_affinity, dipole_polarizability, thermal_conductivity, and many more.

Other classes: IonicRadius (ionic_radius, crystal_radius, charge), IonizationEnergy (ionization_energy, uncertainty), Isotope (mass, quadrupole_moment), and others.

Testing

All documented examples have been thoroughly tested to ensure they work correctly, including:

  • Basic property access with units
  • Unit conversions using Pint
  • Calculations preserving units
  • Error handling for properties without units
  • None value handling for missing data
  • Cross-class functionality

This completes the TODO item from PR #239 and provides users with comprehensive guidance on using the units feature.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Create a pull request addressing the issue @lmmentel/mendeleev/issues/242 Add comprehensive documentation for units feature Sep 16, 2025
Copilot AI requested a review from lmmentel September 16, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants