Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 5 additions & 26 deletions Units.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ The package provides support for the following units:
- **Angle**
- *In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle.*

- **ApparentEnergy**
- *A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules.*

- **ApparentPower**
- *Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current.*

- **Area**
- *Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept).*

Expand All @@ -39,9 +33,6 @@ The package provides support for the following units:
- **BrakeSpecificFuelConsumption**
- *Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output.*

- **Capacitance**
- *Capacitance is the ability of a body to store an electric charge.*

- **CoefficientOfThermalExpansion**
- *A unit that represents a fractional change in size in response to a change in temperature.*

Expand Down Expand Up @@ -105,15 +96,9 @@ The package provides support for the following units:
- **ElectricPotential**
- *In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point.*

- **ElectricPotentialAc**
- *The Electric Potential of a system known to use Alternating Current.*

- **ElectricPotentialChangeRate**
- *ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time).*

- **ElectricPotentialDc**
- *The Electric Potential of a system known to use Direct Current.*

- **ElectricReactance**
- *In electrical circuits, reactance is the opposition presented to alternating current by inductance and capacitance. Along with resistance, it is one of two elements of impedance.*

Expand Down Expand Up @@ -160,7 +145,7 @@ The package provides support for the following units:
- *The number of occurrences of a repeating event per unit time.*

- **FuelEfficiency**
- *Fuel efficiency is a form of thermal efficiency, meaning the ratio from effort to result of a process that converts chemical potential energy contained in a carrier (fuel) into kinetic energy or work. Fuel economy is stated as "fuel consumption" in liters per 100 kilometers (L/100 km). In countries using non-metric system, fuel economy is expressed in miles per gallon (mpg) (imperial galon or US galon).*
- *In the context of transport, fuel economy is the energy efficiency of a particular vehicle, given as a ratio of distance traveled per unit of fuel consumed. In most countries, using the metric system, fuel economy is stated as "fuel consumption" in liters per 100 kilometers (L/100 km) or kilometers per liter (km/L or kmpl). In countries using non-metric system, fuel economy is expressed in miles per gallon (mpg) (imperial galon or US galon).*

- **HeatFlux**
- *Heat flux is the flow of energy per unit of area per unit of time*
Expand Down Expand Up @@ -303,12 +288,6 @@ The package provides support for the following units:
- **RatioChangeRate**
- *The change in ratio per unit of time.*

- **ReactiveEnergy**
- *The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour.*

- **ReactivePower**
- *Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase.*

- **ReciprocalArea**
- *Reciprocal area (Inverse-square) quantity is used to specify a physical quantity inversely proportional to the square of the distance.*

Expand Down Expand Up @@ -372,15 +351,15 @@ The package provides support for the following units:
- **ThermalConductivity**
- *Thermal conductivity is the property of a material to conduct heat.*

- **ThermalInsulance**
- *Thermal insulance (R-value) is a measure of a material's resistance to the heat current. It quantifies how effectively a material can resist the transfer of heat through conduction, convection, and radiation. It has the units square metre kelvins per watt (m2⋅K/W) in SI units or square foot degree Fahrenheit–hours per British thermal unit (ft2⋅°F⋅h/Btu) in imperial units. The higher the thermal insulance, the better a material insulates against heat transfer. It is commonly used in construction to assess the insulation properties of materials such as walls, roofs, and insulation products.*

- **ThermalResistance**
- *Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat.*
- *Thermal resistance (R) measures the opposition to the heat current in a material or system. It is measured in units of kelvins per watt (K/W) and indicates how much temperature difference (in kelvins) is required to transfer a unit of heat current (in watts) through the material or object. It is essential to optimize the building insulation, evaluate the efficiency of electronic devices, and enhance the performance of heat sinks in various applications.*

- **Torque**
- *Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt.*

- **TorquePerLength**
- *The magnitude of torque per unit length.*

- **Turbidity**
- *Turbidity is the cloudiness or haziness of a fluid caused by large numbers of individual particles that are generally invisible to the naked eye, similar to smoke in air. The measurement of turbidity is a key test of water quality.*

Expand Down
2 changes: 1 addition & 1 deletion tests/test_unit_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_convert_unit_to_base(self):

def test_convert_base_prefix_to_base(self):
angle = Angle.from_microdegrees(180000000)
self.assertEqual(angle.degrees, 180)
self.assertAlmostEqual(angle.degrees, 180, delta=0.00001)

def test_convert_unit_prefix_to_base(self):
angle = Angle.from_microradians(3141592.65358979)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unit_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
class TestUnitFormatting(unittest.TestCase):
def test_format_base(self):
angle = Angle.from_degrees(180)
self.assertEqual(angle.to_string(), "180 °")
self.assertEqual(angle.to_string(), "3.141592653589793 rad")

def test_format_other_unit(self):
angle = Angle.from_degrees(180)
self.assertEqual(angle.to_string(AngleUnits.Degree), "180 °")
self.assertEqual(angle.to_string(AngleUnits.Degree, 0), "180 °")
self.assertEqual(angle.to_string(AngleUnits.Radian), "3.141592653589793 rad")
self.assertEqual(angle.to_string(AngleUnits.Milliradian), "3141.592653589793 mrad")

Expand Down
18 changes: 2 additions & 16 deletions unitsnet_py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
from .units.amount_of_substance import AmountOfSubstance, AmountOfSubstanceUnits, AmountOfSubstanceDto
from .units.amplitude_ratio import AmplitudeRatio, AmplitudeRatioUnits, AmplitudeRatioDto
from .units.angle import Angle, AngleUnits, AngleDto
from .units.apparent_energy import ApparentEnergy, ApparentEnergyUnits, ApparentEnergyDto
from .units.apparent_power import ApparentPower, ApparentPowerUnits, ApparentPowerDto
from .units.area import Area, AreaUnits, AreaDto
from .units.area_density import AreaDensity, AreaDensityUnits, AreaDensityDto
from .units.area_moment_of_inertia import AreaMomentOfInertia, AreaMomentOfInertiaUnits, AreaMomentOfInertiaDto
from .units.bit_rate import BitRate, BitRateUnits, BitRateDto
from .units.brake_specific_fuel_consumption import BrakeSpecificFuelConsumption, BrakeSpecificFuelConsumptionUnits, BrakeSpecificFuelConsumptionDto
from .units.capacitance import Capacitance, CapacitanceUnits, CapacitanceDto
from .units.coefficient_of_thermal_expansion import CoefficientOfThermalExpansion, CoefficientOfThermalExpansionUnits, CoefficientOfThermalExpansionDto
from .units.compressibility import Compressibility, CompressibilityUnits, CompressibilityDto
from .units.density import Density, DensityUnits, DensityDto
Expand All @@ -32,9 +29,7 @@
from .units.electric_impedance import ElectricImpedance, ElectricImpedanceUnits, ElectricImpedanceDto
from .units.electric_inductance import ElectricInductance, ElectricInductanceUnits, ElectricInductanceDto
from .units.electric_potential import ElectricPotential, ElectricPotentialUnits, ElectricPotentialDto
from .units.electric_potential_ac import ElectricPotentialAc, ElectricPotentialAcUnits, ElectricPotentialAcDto
from .units.electric_potential_change_rate import ElectricPotentialChangeRate, ElectricPotentialChangeRateUnits, ElectricPotentialChangeRateDto
from .units.electric_potential_dc import ElectricPotentialDc, ElectricPotentialDcUnits, ElectricPotentialDcDto
from .units.electric_reactance import ElectricReactance, ElectricReactanceUnits, ElectricReactanceDto
from .units.electric_reactive_energy import ElectricReactiveEnergy, ElectricReactiveEnergyUnits, ElectricReactiveEnergyDto
from .units.electric_reactive_power import ElectricReactivePower, ElectricReactivePowerUnits, ElectricReactivePowerDto
Expand Down Expand Up @@ -98,8 +93,6 @@
from .units.radioactivity import Radioactivity, RadioactivityUnits, RadioactivityDto
from .units.ratio import Ratio, RatioUnits, RatioDto
from .units.ratio_change_rate import RatioChangeRate, RatioChangeRateUnits, RatioChangeRateDto
from .units.reactive_energy import ReactiveEnergy, ReactiveEnergyUnits, ReactiveEnergyDto
from .units.reactive_power import ReactivePower, ReactivePowerUnits, ReactivePowerDto
from .units.reciprocal_area import ReciprocalArea, ReciprocalAreaUnits, ReciprocalAreaDto
from .units.reciprocal_length import ReciprocalLength, ReciprocalLengthUnits, ReciprocalLengthDto
from .units.relative_humidity import RelativeHumidity, RelativeHumidityUnits, RelativeHumidityDto
Expand All @@ -121,9 +114,9 @@
from .units.temperature_delta import TemperatureDelta, TemperatureDeltaUnits, TemperatureDeltaDto
from .units.temperature_gradient import TemperatureGradient, TemperatureGradientUnits, TemperatureGradientDto
from .units.thermal_conductivity import ThermalConductivity, ThermalConductivityUnits, ThermalConductivityDto
from .units.thermal_insulance import ThermalInsulance, ThermalInsulanceUnits, ThermalInsulanceDto
from .units.thermal_resistance import ThermalResistance, ThermalResistanceUnits, ThermalResistanceDto
from .units.torque import Torque, TorqueUnits, TorqueDto
from .units.torque_per_length import TorquePerLength, TorquePerLengthUnits, TorquePerLengthDto
from .units.turbidity import Turbidity, TurbidityUnits, TurbidityDto
from .units.vitamin_a import VitaminA, VitaminAUnits, VitaminADto
from .units.volume import Volume, VolumeUnits, VolumeDto
Expand All @@ -141,14 +134,11 @@
'AmountOfSubstance', 'AmountOfSubstanceUnits', 'AmountOfSubstanceDto',
'AmplitudeRatio', 'AmplitudeRatioUnits', 'AmplitudeRatioDto',
'Angle', 'AngleUnits', 'AngleDto',
'ApparentEnergy', 'ApparentEnergyUnits', 'ApparentEnergyDto',
'ApparentPower', 'ApparentPowerUnits', 'ApparentPowerDto',
'Area', 'AreaUnits', 'AreaDto',
'AreaDensity', 'AreaDensityUnits', 'AreaDensityDto',
'AreaMomentOfInertia', 'AreaMomentOfInertiaUnits', 'AreaMomentOfInertiaDto',
'BitRate', 'BitRateUnits', 'BitRateDto',
'BrakeSpecificFuelConsumption', 'BrakeSpecificFuelConsumptionUnits', 'BrakeSpecificFuelConsumptionDto',
'Capacitance', 'CapacitanceUnits', 'CapacitanceDto',
'CoefficientOfThermalExpansion', 'CoefficientOfThermalExpansionUnits', 'CoefficientOfThermalExpansionDto',
'Compressibility', 'CompressibilityUnits', 'CompressibilityDto',
'Density', 'DensityUnits', 'DensityDto',
Expand All @@ -170,9 +160,7 @@
'ElectricImpedance', 'ElectricImpedanceUnits', 'ElectricImpedanceDto',
'ElectricInductance', 'ElectricInductanceUnits', 'ElectricInductanceDto',
'ElectricPotential', 'ElectricPotentialUnits', 'ElectricPotentialDto',
'ElectricPotentialAc', 'ElectricPotentialAcUnits', 'ElectricPotentialAcDto',
'ElectricPotentialChangeRate', 'ElectricPotentialChangeRateUnits', 'ElectricPotentialChangeRateDto',
'ElectricPotentialDc', 'ElectricPotentialDcUnits', 'ElectricPotentialDcDto',
'ElectricReactance', 'ElectricReactanceUnits', 'ElectricReactanceDto',
'ElectricReactiveEnergy', 'ElectricReactiveEnergyUnits', 'ElectricReactiveEnergyDto',
'ElectricReactivePower', 'ElectricReactivePowerUnits', 'ElectricReactivePowerDto',
Expand Down Expand Up @@ -236,8 +224,6 @@
'Radioactivity', 'RadioactivityUnits', 'RadioactivityDto',
'Ratio', 'RatioUnits', 'RatioDto',
'RatioChangeRate', 'RatioChangeRateUnits', 'RatioChangeRateDto',
'ReactiveEnergy', 'ReactiveEnergyUnits', 'ReactiveEnergyDto',
'ReactivePower', 'ReactivePowerUnits', 'ReactivePowerDto',
'ReciprocalArea', 'ReciprocalAreaUnits', 'ReciprocalAreaDto',
'ReciprocalLength', 'ReciprocalLengthUnits', 'ReciprocalLengthDto',
'RelativeHumidity', 'RelativeHumidityUnits', 'RelativeHumidityDto',
Expand All @@ -259,9 +245,9 @@
'TemperatureDelta', 'TemperatureDeltaUnits', 'TemperatureDeltaDto',
'TemperatureGradient', 'TemperatureGradientUnits', 'TemperatureGradientDto',
'ThermalConductivity', 'ThermalConductivityUnits', 'ThermalConductivityDto',
'ThermalInsulance', 'ThermalInsulanceUnits', 'ThermalInsulanceDto',
'ThermalResistance', 'ThermalResistanceUnits', 'ThermalResistanceDto',
'Torque', 'TorqueUnits', 'TorqueDto',
'TorquePerLength', 'TorquePerLengthUnits', 'TorquePerLengthDto',
'Turbidity', 'TurbidityUnits', 'TurbidityDto',
'VitaminA', 'VitaminAUnits', 'VitaminADto',
'Volume', 'VolumeUnits', 'VolumeDto',
Expand Down
45 changes: 45 additions & 0 deletions unitsnet_py/units/absorbed_dose_of_ionizing_radiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class AbsorbedDoseOfIonizingRadiationUnits(Enum):

"""

Decigray = 'Decigray'
"""

"""

Kilogray = 'Kilogray'
"""

Expand Down Expand Up @@ -172,6 +177,8 @@ def __init__(self, value: float, from_unit: AbsorbedDoseOfIonizingRadiationUnits

self.__centigrays = None

self.__decigrays = None

self.__kilograys = None

self.__megagrays = None
Expand Down Expand Up @@ -267,6 +274,9 @@ def __convert_from_base(self, from_unit: AbsorbedDoseOfIonizingRadiationUnits) -
if from_unit == AbsorbedDoseOfIonizingRadiationUnits.Centigray:
return ((value) / 0.01)

if from_unit == AbsorbedDoseOfIonizingRadiationUnits.Decigray:
return ((value) / 0.1)

if from_unit == AbsorbedDoseOfIonizingRadiationUnits.Kilogray:
return ((value) / 1000.0)

Expand Down Expand Up @@ -320,6 +330,9 @@ def __convert_to_base(self, value: float, to_unit: AbsorbedDoseOfIonizingRadiati
if to_unit == AbsorbedDoseOfIonizingRadiationUnits.Centigray:
return ((value) * 0.01)

if to_unit == AbsorbedDoseOfIonizingRadiationUnits.Decigray:
return ((value) * 0.1)

if to_unit == AbsorbedDoseOfIonizingRadiationUnits.Kilogray:
return ((value) * 1000.0)

Expand Down Expand Up @@ -472,6 +485,21 @@ def from_centigrays(centigrays: float):
return AbsorbedDoseOfIonizingRadiation(centigrays, AbsorbedDoseOfIonizingRadiationUnits.Centigray)


@staticmethod
def from_decigrays(decigrays: float):
"""
Create a new instance of AbsorbedDoseOfIonizingRadiation from a value in decigrays.



:param meters: The AbsorbedDoseOfIonizingRadiation value in decigrays.
:type decigrays: float
:return: A new instance of AbsorbedDoseOfIonizingRadiation.
:rtype: AbsorbedDoseOfIonizingRadiation
"""
return AbsorbedDoseOfIonizingRadiation(decigrays, AbsorbedDoseOfIonizingRadiationUnits.Decigray)


@staticmethod
def from_kilograys(kilograys: float):
"""
Expand Down Expand Up @@ -680,6 +708,17 @@ def centigrays(self) -> float:
return self.__centigrays


@property
def decigrays(self) -> float:
"""

"""
if self.__decigrays != None:
return self.__decigrays
self.__decigrays = self.__convert_from_base(AbsorbedDoseOfIonizingRadiationUnits.Decigray)
return self.__decigrays


@property
def kilograys(self) -> float:
"""
Expand Down Expand Up @@ -807,6 +846,9 @@ def to_string(self, unit: AbsorbedDoseOfIonizingRadiationUnits = AbsorbedDoseOfI
if unit == AbsorbedDoseOfIonizingRadiationUnits.Centigray:
return f"""{super()._truncate_fraction_digits(self.centigrays, fractional_digits)} cGy"""

if unit == AbsorbedDoseOfIonizingRadiationUnits.Decigray:
return f"""{super()._truncate_fraction_digits(self.decigrays, fractional_digits)} dGy"""

if unit == AbsorbedDoseOfIonizingRadiationUnits.Kilogray:
return f"""{super()._truncate_fraction_digits(self.kilograys, fractional_digits)} kGy"""

Expand Down Expand Up @@ -865,6 +907,9 @@ def get_unit_abbreviation(self, unit_abbreviation: AbsorbedDoseOfIonizingRadiati
if unit_abbreviation == AbsorbedDoseOfIonizingRadiationUnits.Centigray:
return """cGy"""

if unit_abbreviation == AbsorbedDoseOfIonizingRadiationUnits.Decigray:
return """dGy"""

if unit_abbreviation == AbsorbedDoseOfIonizingRadiationUnits.Kilogray:
return """kGy"""

Expand Down
Loading