From 36c7ccf29022125947a5db3b77fb9d1a060511c4 Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Mon, 20 Mar 2023 17:55:36 +0900 Subject: [PATCH 1/3] DOC: add docstrings to units --- scimath/units/acceleration.py | 3 +++ scimath/units/angle.py | 4 ++++ scimath/units/area.py | 7 +++++++ scimath/units/density.py | 4 ++++ scimath/units/dimensionless.py | 6 ++++++ scimath/units/electromagnetism.py | 13 +++++++++++++ scimath/units/energy.py | 7 +++++++ scimath/units/force.py | 6 ++++++ scimath/units/frequency.py | 2 ++ scimath/units/length.py | 7 +++++++ scimath/units/mass.py | 6 ++++++ scimath/units/power.py | 1 + scimath/units/pressure.py | 5 ++++- scimath/units/speed.py | 5 +++++ scimath/units/substance.py | 5 +++++ scimath/units/temperature.py | 6 ++++++ scimath/units/time.py | 4 ++++ scimath/units/volume.py | 6 ++++++ 18 files changed, 96 insertions(+), 1 deletion(-) diff --git a/scimath/units/acceleration.py b/scimath/units/acceleration.py index d9196aa..cd1fc3b 100644 --- a/scimath/units/acceleration.py +++ b/scimath/units/acceleration.py @@ -9,6 +9,9 @@ # Thanks for using Enthought open source! """ Define units of acceleration + +Symbols defined: feet_per_second_squared, meters_per_second_squared [and aliases] + """ ##################################################################### diff --git a/scimath/units/angle.py b/scimath/units/angle.py index cc6c917..8698c3b 100644 --- a/scimath/units/angle.py +++ b/scimath/units/angle.py @@ -9,6 +9,10 @@ # Thanks for using Enthought open source! """ Define units of angle (dimensionless with meaning) + +Symbols defined: circle, degree, grad, quadrant, mil, right_angle, radian, revolution, sextant, sign, turn + minute, second, [and aliases] + """ ############################################################################# diff --git a/scimath/units/area.py b/scimath/units/area.py index 8c6bb2d..c0e6b3d 100644 --- a/scimath/units/area.py +++ b/scimath/units/area.py @@ -18,6 +18,13 @@ from .length import meter, centimeter, inch, foot, mile +""" Define units of area + +Symbols defined: acre, hectare, + barn, + square_centimeter, square_foot, square_inch, square_meter, square_mile [and aliases] + +""" # # Definitions of common area units diff --git a/scimath/units/density.py b/scimath/units/density.py index d34ba60..36a501a 100644 --- a/scimath/units/density.py +++ b/scimath/units/density.py @@ -9,10 +9,14 @@ # Thanks for using Enthought open source! """ Defines units of density + Derived from: units/density.py [pyre system] Michael A.G. Aivazis California Institute of Technology (c) 1998-2003 + +Symbols defined: grams_per_cubic_centimeter, kilograms_per_cubic_meter, lb_per_gal [and aliases] + """ ############################################################################# diff --git a/scimath/units/dimensionless.py b/scimath/units/dimensionless.py index 40d03c8..2795b9c 100644 --- a/scimath/units/dimensionless.py +++ b/scimath/units/dimensionless.py @@ -8,6 +8,12 @@ # # Thanks for using Enthought open source! +""" Defines units of dimensionless + +Symbols defined: fractional, parts_per_million, parts_per_one, percent [and aliases] + +""" + from copy import copy from scimath.units.SI import dimensionless from scimath.units.unit import one, dim diff --git a/scimath/units/electromagnetism.py b/scimath/units/electromagnetism.py index 6e9f2f8..a5898e9 100644 --- a/scimath/units/electromagnetism.py +++ b/scimath/units/electromagnetism.py @@ -8,6 +8,19 @@ # # Thanks for using Enthought open source! +""" Defines units of electromagnetism + +Symbols defined: ampere, milli_ampere, + farad, micro_farad, pico_farad, + henry, + ohm, ohm_meter, ohmm, + siemen, mSiemen, siemens_per_meter, + tesla, + volt, milivolt, + weber [and aliases] + +""" + from copy import copy from scimath.units.SI import ampere, coulomb, farad, henry, joule, ohm, \ diff --git a/scimath/units/energy.py b/scimath/units/energy.py index d7e7be1..9197bc1 100644 --- a/scimath/units/energy.py +++ b/scimath/units/energy.py @@ -30,6 +30,13 @@ # The NIST Reference on Constants, Units and Uncertainty, # http://physics.nist.gov/cuu # +# Symbols defined: Btu, +# Calorie, calorie, +# electron_volt, +# erg, +# foot_pound, +# horse_power_hour, kilowatt_hour [and aliases] +# Btu = 1055 * joule diff --git a/scimath/units/force.py b/scimath/units/force.py index 76aa4f1..caa6e84 100644 --- a/scimath/units/force.py +++ b/scimath/units/force.py @@ -8,6 +8,12 @@ # # Thanks for using Enthought open source! +""" Defines units of force + +Symbols defined: lbf, lbs, N [and aliases] + +""" + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # Michael A.G. Aivazis diff --git a/scimath/units/frequency.py b/scimath/units/frequency.py index 5ca12d4..cb42d1e 100644 --- a/scimath/units/frequency.py +++ b/scimath/units/frequency.py @@ -9,6 +9,8 @@ # Thanks for using Enthought open source! """ Defines units of frequency + +Symbols defined: hertz, kilohertz, rpm [and aliases] """ ############################################################################# diff --git a/scimath/units/length.py b/scimath/units/length.py index 2bbad3a..ba11541 100644 --- a/scimath/units/length.py +++ b/scimath/units/length.py @@ -13,6 +13,13 @@ Michael A.G. Aivazis California Institute of Technology (c) 1998-2003 + +Symbols defined: kilo-, centi-, milli-, micro-, nano-, pico-, meter, + inch, foot, yard, mile, + fathom, nautical_mile, + angstrom, fermi, survey_foot, us_foot, us_feet, + astronomical_unit, light_year, parsec [and aliases] + """ ############################################################################# diff --git a/scimath/units/mass.py b/scimath/units/mass.py index 345d0be..c7e3d86 100644 --- a/scimath/units/mass.py +++ b/scimath/units/mass.py @@ -9,10 +9,16 @@ # Thanks for using Enthought open source! """ Defines units of mass + Derived from: units/mass.py [pyre system] Michael A.G. Aivazis California Institute of Technology (c) 1998-2003 + +Symbols defined: centigram, gram, kilogram, milligram, + metric_ton, ton, + ounce, pound [and aliases] + """ ############################################################################# diff --git a/scimath/units/power.py b/scimath/units/power.py index 089ed23..3bde657 100644 --- a/scimath/units/power.py +++ b/scimath/units/power.py @@ -22,6 +22,7 @@ # Definitions of common power units # Data taken from Appendix F of Halliday, Resnick, Walker, "Fundamentals of Physics", # fourth edition, John Willey and Sons, 1993 +# Symbols defined: kilowatt, horsepower [and aliases] kilowatt = kilo * watt kw = kilowatt diff --git a/scimath/units/pressure.py b/scimath/units/pressure.py index cc5b02e..e212aed 100644 --- a/scimath/units/pressure.py +++ b/scimath/units/pressure.py @@ -29,9 +29,12 @@ # # The NIST Reference on Constants, Units and Uncertainty, # http://physics.nist.gov/cuu +# +# Symbols defined: pascal, kPa, MPa, GPa, inHg, +# bar, kilobar, millibar, torr, atmosphere, +# pounds_per_square_inch [and aliases] # - # aliases Pa = pascal diff --git a/scimath/units/speed.py b/scimath/units/speed.py index 98a7918..7b4ecb2 100644 --- a/scimath/units/speed.py +++ b/scimath/units/speed.py @@ -9,10 +9,15 @@ # Thanks for using Enthought open source! """ Defines units of density. + Derived from: units/density.py [pyre system] Michael A.G. Aivazis California Institute of Technology (c) 1998-2003 + +Symbols defined: feet_per_second, meters_per_second, kilometers_per_second, miles_per_hour, + knot [and aliases] + """ ############################################################################# diff --git a/scimath/units/substance.py b/scimath/units/substance.py index c21f883..f0ce8d6 100644 --- a/scimath/units/substance.py +++ b/scimath/units/substance.py @@ -16,6 +16,11 @@ # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +""" Defines units of substance + +Symbols defined: mole, kmole [and aliases] +""" + from .SI import mole, kilo diff --git a/scimath/units/temperature.py b/scimath/units/temperature.py index ea76ad1..3839ab7 100644 --- a/scimath/units/temperature.py +++ b/scimath/units/temperature.py @@ -16,6 +16,12 @@ # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +""" Defines units of temperature + +Symbols defined: celsius, fahrenheit, kelvin, rankine [and aliases] + +""" + from scimath.units.unit import unit # Tk = Tk diff --git a/scimath/units/time.py b/scimath/units/time.py index e7b9229..fc13875 100644 --- a/scimath/units/time.py +++ b/scimath/units/time.py @@ -13,6 +13,10 @@ Michael A.G. Aivazis California Institute of Technology (c) 1998-2003 + +Symbols defined: milli-, micro-, nano-, pico-, second, + minute, hour, day, week, year [and aliases] + """ ############################################################################# diff --git a/scimath/units/volume.py b/scimath/units/volume.py index 01238a6..17afa2f 100644 --- a/scimath/units/volume.py +++ b/scimath/units/volume.py @@ -15,6 +15,12 @@ Michael A.G. Aivazis California Institute of Technology (c) 1998-2003 + +Symbols defined: cubic_centimeter, cubic_foot, cubic_meter, + liter, barrel, + us_pint, + us_fluid_ounce, us_fluid_quart, us_fluid_gallon [and aliases] + """ ############################################################################# # Imports: From fce9e7a88426d3a0708b6b8269bf0d1fc37c40fe Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Thu, 23 Mar 2023 11:48:34 +0900 Subject: [PATCH 2/3] reformat docstring --- scimath/units/SI.py | 15 ++++++++++++++ scimath/units/acceleration.py | 2 +- scimath/units/angle.py | 4 ++-- scimath/units/area.py | 6 +++--- scimath/units/density.py | 10 +++++----- scimath/units/dimensionless.py | 2 +- scimath/units/electromagnetism.py | 16 +++++++-------- scimath/units/energy.py | 33 ++++++++++++++----------------- scimath/units/force.py | 2 +- scimath/units/frequency.py | 2 +- scimath/units/geo_units.py | 9 +++++++++ scimath/units/length.py | 21 ++++++++++---------- scimath/units/mass.py | 14 ++++++------- scimath/units/power.py | 11 ++++++----- scimath/units/pressure.py | 25 +++++++++++------------ scimath/units/speed.py | 12 +++++------ scimath/units/substance.py | 2 +- scimath/units/temperature.py | 3 +-- scimath/units/time.py | 13 ++++++------ scimath/units/volume.py | 19 +++++++++--------- 20 files changed, 120 insertions(+), 101 deletions(-) diff --git a/scimath/units/SI.py b/scimath/units/SI.py index 83f0895..1bbb778 100644 --- a/scimath/units/SI.py +++ b/scimath/units/SI.py @@ -16,6 +16,21 @@ # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +""" Defines units of SI + + Symbols defined: meter, kilogram, second, ampere, mole, candela, + radian, steradian, hertz, newton, + pascal, joule, watt, coulomb, + volt, farad, ohm, siemens, weber, + tesla, henry, lumen, lux, becquerel, + gray, sievert, katal [and aliases] + + Prefixes defined: yotta, zetta, exa, peta, tera, giga, mega, kilo, + hecto, deka, deci, centi, milli, micro, nano, pico, + femto, atto, zepto, yocto + +""" + from copy import copy from scimath.units.unit import unit, dimensionless, none diff --git a/scimath/units/acceleration.py b/scimath/units/acceleration.py index cd1fc3b..be26d41 100644 --- a/scimath/units/acceleration.py +++ b/scimath/units/acceleration.py @@ -10,7 +10,7 @@ """ Define units of acceleration -Symbols defined: feet_per_second_squared, meters_per_second_squared [and aliases] + Symbols defined: feet_per_second_squared, meters_per_second_squared [and aliases] """ diff --git a/scimath/units/angle.py b/scimath/units/angle.py index 8698c3b..84bdaca 100644 --- a/scimath/units/angle.py +++ b/scimath/units/angle.py @@ -10,8 +10,8 @@ """ Define units of angle (dimensionless with meaning) -Symbols defined: circle, degree, grad, quadrant, mil, right_angle, radian, revolution, sextant, sign, turn - minute, second, [and aliases] + Symbols defined: circle, degree, grad, quadrant, mil, right_angle, radian, revolution, sextant, sign, turn + minute, second, [and aliases] """ diff --git a/scimath/units/area.py b/scimath/units/area.py index c0e6b3d..6eaaf4a 100644 --- a/scimath/units/area.py +++ b/scimath/units/area.py @@ -20,9 +20,9 @@ """ Define units of area -Symbols defined: acre, hectare, - barn, - square_centimeter, square_foot, square_inch, square_meter, square_mile [and aliases] + Symbols defined: acre, hectare, + barn, + square_centimeter, square_foot, square_inch, square_meter, square_mile [and aliases] """ diff --git a/scimath/units/density.py b/scimath/units/density.py index 36a501a..e105350 100644 --- a/scimath/units/density.py +++ b/scimath/units/density.py @@ -10,12 +10,12 @@ """ Defines units of density -Derived from: units/density.py [pyre system] - Michael A.G. Aivazis - California Institute of Technology - (c) 1998-2003 + Derived from: units/density.py [pyre system] + Michael A.G. Aivazis + California Institute of Technology + (c) 1998-2003 -Symbols defined: grams_per_cubic_centimeter, kilograms_per_cubic_meter, lb_per_gal [and aliases] + Symbols defined: grams_per_cubic_centimeter, kilograms_per_cubic_meter, lb_per_gal [and aliases] """ diff --git a/scimath/units/dimensionless.py b/scimath/units/dimensionless.py index 2795b9c..17407ac 100644 --- a/scimath/units/dimensionless.py +++ b/scimath/units/dimensionless.py @@ -10,7 +10,7 @@ """ Defines units of dimensionless -Symbols defined: fractional, parts_per_million, parts_per_one, percent [and aliases] + Symbols defined: fractional, parts_per_million, parts_per_one, percent [and aliases] """ diff --git a/scimath/units/electromagnetism.py b/scimath/units/electromagnetism.py index a5898e9..a65f339 100644 --- a/scimath/units/electromagnetism.py +++ b/scimath/units/electromagnetism.py @@ -10,14 +10,14 @@ """ Defines units of electromagnetism -Symbols defined: ampere, milli_ampere, - farad, micro_farad, pico_farad, - henry, - ohm, ohm_meter, ohmm, - siemen, mSiemen, siemens_per_meter, - tesla, - volt, milivolt, - weber [and aliases] + Symbols defined: ampere, milli_ampere, + farad, micro_farad, pico_farad, + henry, + ohm, ohm_meter, ohmm, + siemen, mSiemen, siemens_per_meter, + tesla, + volt, milivolt, + weber [and aliases] """ diff --git a/scimath/units/energy.py b/scimath/units/energy.py index 9197bc1..8d68258 100644 --- a/scimath/units/energy.py +++ b/scimath/units/energy.py @@ -19,24 +19,21 @@ from .SI import joule, kilo, mega, giga -# -# Definitions of common energy units -# -# Data taken from -# -# Appendix F of Halliday, Resnick, Walker, "Fundamentals of Physics", -# fourth edition, John Willey and Sons, 1993 -# -# The NIST Reference on Constants, Units and Uncertainty, -# http://physics.nist.gov/cuu -# -# Symbols defined: Btu, -# Calorie, calorie, -# electron_volt, -# erg, -# foot_pound, -# horse_power_hour, kilowatt_hour [and aliases] -# +""" Definitions of common energy units + + Data taken from Appendix F of Halliday, Resnick, Walker, "Fundamentals of Physics", + fourth edition, John Willey and Sons, 1993 + + The NIST Reference on Constants, Units and Uncertainty, + http://physics.nist.gov/cuu + + Symbols defined: Btu, + Calorie, calorie, + electron_volt, + erg, + foot_pound, + horse_power_hour, kilowatt_hour [and aliases] +""" Btu = 1055 * joule diff --git a/scimath/units/force.py b/scimath/units/force.py index caa6e84..126f32e 100644 --- a/scimath/units/force.py +++ b/scimath/units/force.py @@ -10,7 +10,7 @@ """ Defines units of force -Symbols defined: lbf, lbs, N [and aliases] + Symbols defined: lbf, lbs, N [and aliases] """ diff --git a/scimath/units/frequency.py b/scimath/units/frequency.py index cb42d1e..bc041a6 100644 --- a/scimath/units/frequency.py +++ b/scimath/units/frequency.py @@ -10,7 +10,7 @@ """ Defines units of frequency -Symbols defined: hertz, kilohertz, rpm [and aliases] + Symbols defined: hertz, kilohertz, rpm [and aliases] """ ############################################################################# diff --git a/scimath/units/geo_units.py b/scimath/units/geo_units.py index 7f41ab6..6732b9f 100644 --- a/scimath/units/geo_units.py +++ b/scimath/units/geo_units.py @@ -8,6 +8,15 @@ # # Thanks for using Enthought open source! +""" Defines units of Geo Units + + Symbols defined: g_km_per_cc_s, g_ft_per_cc_s, rayl, mrayl, + barns_per_electron, psi_per_f, + MPa_per_m, MPa_per_100f, + lb_per_gal, api, gapi, us_per_ft [and aliases] + +""" + from copy import copy from scimath.units.SI import ampere, atto, becquerel, candela, centi, \ diff --git a/scimath/units/length.py b/scimath/units/length.py index ba11541..9b527dd 100644 --- a/scimath/units/length.py +++ b/scimath/units/length.py @@ -9,16 +9,17 @@ # Thanks for using Enthought open source! """ Defines units of length -Derived from: units/length.py [pyre system] - Michael A.G. Aivazis - California Institute of Technology - (c) 1998-2003 - -Symbols defined: kilo-, centi-, milli-, micro-, nano-, pico-, meter, - inch, foot, yard, mile, - fathom, nautical_mile, - angstrom, fermi, survey_foot, us_foot, us_feet, - astronomical_unit, light_year, parsec [and aliases] + + Derived from: units/length.py [pyre system] + Michael A.G. Aivazis + California Institute of Technology + (c) 1998-2003 + + Symbols defined: kilo-, centi-, milli-, micro-, nano-, pico-, meter, + inch, foot, yard, mile, + fathom, nautical_mile, + angstrom, fermi, survey_foot, us_foot, us_feet, + astronomical_unit, light_year, parsec [and aliases] """ diff --git a/scimath/units/mass.py b/scimath/units/mass.py index c7e3d86..f07d68d 100644 --- a/scimath/units/mass.py +++ b/scimath/units/mass.py @@ -10,14 +10,14 @@ """ Defines units of mass -Derived from: units/mass.py [pyre system] - Michael A.G. Aivazis - California Institute of Technology - (c) 1998-2003 + Derived from: units/mass.py [pyre system] + Michael A.G. Aivazis + California Institute of Technology + (c) 1998-2003 -Symbols defined: centigram, gram, kilogram, milligram, - metric_ton, ton, - ounce, pound [and aliases] + Symbols defined: centigram, gram, kilogram, milligram, + metric_ton, ton, + ounce, pound [and aliases] """ diff --git a/scimath/units/power.py b/scimath/units/power.py index 3bde657..56abf76 100644 --- a/scimath/units/power.py +++ b/scimath/units/power.py @@ -18,11 +18,12 @@ from .SI import watt, kilo -# -# Definitions of common power units -# Data taken from Appendix F of Halliday, Resnick, Walker, "Fundamentals of Physics", -# fourth edition, John Willey and Sons, 1993 -# Symbols defined: kilowatt, horsepower [and aliases] +""" Definitions of common power units + + Data taken from Appendix F of Halliday, Resnick, Walker, "Fundamentals of Physics", + fourth edition, John Willey and Sons, 1993 + Symbols defined: kilowatt, horsepower [and aliases] +""" kilowatt = kilo * watt kw = kilowatt diff --git a/scimath/units/pressure.py b/scimath/units/pressure.py index e212aed..6a0caf6 100644 --- a/scimath/units/pressure.py +++ b/scimath/units/pressure.py @@ -20,20 +20,17 @@ from scimath.units.force import lbf from scimath.units.length import inch from scimath.units.unit import unit -# -# Definitions of common pressure units -# -# Data taken from -# Appendix F of Halliday, Resnick, Walker, "Fundamentals of Physics", -# fourth edition, John Willey and Sons, 1993 -# -# The NIST Reference on Constants, Units and Uncertainty, -# http://physics.nist.gov/cuu -# -# Symbols defined: pascal, kPa, MPa, GPa, inHg, -# bar, kilobar, millibar, torr, atmosphere, -# pounds_per_square_inch [and aliases] -# +""" Definitions of common pressure units + + Data taken from Appendix F of Halliday, Resnick, Walker, "Fundamentals of Physics", + fourth edition, John Willey and Sons, 1993 + The NIST Reference on Constants, Units and Uncertainty, + http://physics.nist.gov/cuu + + Symbols defined: pascal, kPa, MPa, GPa, inHg, + bar, kilobar, millibar, torr, atmosphere, + pounds_per_square_inch [and aliases] +""" # aliases diff --git a/scimath/units/speed.py b/scimath/units/speed.py index 7b4ecb2..a766f7b 100644 --- a/scimath/units/speed.py +++ b/scimath/units/speed.py @@ -10,13 +10,13 @@ """ Defines units of density. -Derived from: units/density.py [pyre system] - Michael A.G. Aivazis - California Institute of Technology - (c) 1998-2003 + Derived from: units/density.py [pyre system] + Michael A.G. Aivazis + California Institute of Technology + (c) 1998-2003 -Symbols defined: feet_per_second, meters_per_second, kilometers_per_second, miles_per_hour, - knot [and aliases] + Symbols defined: feet_per_second, meters_per_second, kilometers_per_second, miles_per_hour, + knot [and aliases] """ diff --git a/scimath/units/substance.py b/scimath/units/substance.py index f0ce8d6..b259390 100644 --- a/scimath/units/substance.py +++ b/scimath/units/substance.py @@ -18,7 +18,7 @@ """ Defines units of substance -Symbols defined: mole, kmole [and aliases] + Symbols defined: mole, kmole [and aliases] """ from .SI import mole, kilo diff --git a/scimath/units/temperature.py b/scimath/units/temperature.py index 3839ab7..a337600 100644 --- a/scimath/units/temperature.py +++ b/scimath/units/temperature.py @@ -18,8 +18,7 @@ """ Defines units of temperature -Symbols defined: celsius, fahrenheit, kelvin, rankine [and aliases] - + Symbols defined: celsius, fahrenheit, kelvin, rankine [and aliases] """ from scimath.units.unit import unit diff --git a/scimath/units/time.py b/scimath/units/time.py index fc13875..079436f 100644 --- a/scimath/units/time.py +++ b/scimath/units/time.py @@ -9,13 +9,14 @@ # Thanks for using Enthought open source! """ Defines units of time -Derived from: units/time.py [pyre system] - Michael A.G. Aivazis - California Institute of Technology - (c) 1998-2003 -Symbols defined: milli-, micro-, nano-, pico-, second, - minute, hour, day, week, year [and aliases] + Derived from: units/time.py [pyre system] + Michael A.G. Aivazis + California Institute of Technology + (c) 1998-2003 + + Symbols defined: milli-, micro-, nano-, pico-, second, + minute, hour, day, week, year [and aliases] """ diff --git a/scimath/units/volume.py b/scimath/units/volume.py index 17afa2f..feeb8be 100644 --- a/scimath/units/volume.py +++ b/scimath/units/volume.py @@ -8,18 +8,17 @@ # # Thanks for using Enthought open source! -""" -Description: Define units of volume +""" Description: Define units of volume -Derived from: units/volume.py [pyre system] - Michael A.G. Aivazis - California Institute of Technology - (c) 1998-2003 + Derived from: units/volume.py [pyre system] + Michael A.G. Aivazis + California Institute of Technology + (c) 1998-2003 -Symbols defined: cubic_centimeter, cubic_foot, cubic_meter, - liter, barrel, - us_pint, - us_fluid_ounce, us_fluid_quart, us_fluid_gallon [and aliases] + Symbols defined: cubic_centimeter, cubic_foot, cubic_meter, + liter, barrel, + us_pint, + us_fluid_ounce, us_fluid_quart, us_fluid_gallon [and aliases] """ ############################################################################# From 3fd27e4e926ef14d3780ebd7d9fdd8f73d36328a Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Wed, 29 Mar 2023 16:14:33 +0900 Subject: [PATCH 3/3] fix sphinx error --- scimath/units/convert.py | 76 ++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/scimath/units/convert.py b/scimath/units/convert.py index 0bc0710..829ce05 100644 --- a/scimath/units/convert.py +++ b/scimath/units/convert.py @@ -22,44 +22,44 @@ def convert(value, from_unit, to_unit): """ Coverts value from one unit to another. - Parameters - ---------- - value : float - value to convert - from_unit : scimath.unit object - implied units of 'value' - to_unit : scimath.unit object - implied units of the returned float - - Returns - ------- - value * conversion_factor + offset : data type is the same as was passed - in. - - Description - ----------- - - Checks first to see if from_unit and to_unit are equal and passes value - back in that case. Then convert() forms a conversion factor by dividing the - units. The offset is zero unless explicitly set otherwise in the unit - definition. Handling of UnitArrays is done by checking whether value is a - numpy.ndarray. - - **Note**: Enthought has extended the original units implementation to - handle temperature conversions. Temperature units are a special case - because they can have a different origin. - - This causes a fundamental ambiguity. What behavior do we expect when we - convert temperature? - - Option #1 When we convert 0 degrees centigrade we get 32 fahrenheit. - - Option #2 When we convert a temperature difference of 0 degrees centigrade - we get a temperature difference of 0 degrees fahrenheit. - - By convention we have made the units system behave like in Option - #1 so that convert() handles absolute temperatures, not temperature - differences. + Parameters + ---------- + value : float + value to convert + from_unit : scimath.unit object + implied units of 'value' + to_unit : scimath.unit object + implied units of the returned float + + Returns + ------- + value * conversion_factor + offset : data type is the same as was passed + in. + + Description + ----------- + + Checks first to see if from_unit and to_unit are equal and passes value + back in that case. Then convert() forms a conversion factor by dividing the + units. The offset is zero unless explicitly set otherwise in the unit + definition. Handling of UnitArrays is done by checking whether value is a + numpy.ndarray. + + **Note**: Enthought has extended the original units implementation to + handle temperature conversions. Temperature units are a special case + because they can have a different origin. + + This causes a fundamental ambiguity. What behavior do we expect when we + convert temperature? + + Option #1 When we convert 0 degrees centigrade we get 32 fahrenheit. + + Option #2 When we convert a temperature difference of 0 degrees centigrade + we get a temperature difference of 0 degrees fahrenheit. + + By convention we have made the units system behave like in Option + #1 so that convert() handles absolute temperatures, not temperature + differences. """ # TODO: it would be nice if this function could handle inversion as well as