Land Module Reference¶
terai.py
This module provides functions to convert values between different Terai land measurement units (bigha, kattha, dhur) and square meters. The conversions ensure precision and support configurable floating-point rounding.
Functions: - terai_to_sq_meters: Converts a value from a Terai land unit to square meters. - sq_meters_to_terai: Converts a value in square meters to a Terai land unit. - terai_to_terai: Converts directly between two Terai land units.
Constants: - TERAI_TO_SQ_M: Dictionary mapping Terai land units to their square meter equivalents. - TERAI_CONVERSION_FACTORS: Nested dictionary containing direct conversion ratios between Terai land units.
- rupantaran.land.terai.sq_meters_to_terai(area_m2: float, to_unit: str, precision: int = 4) float[source]¶
Converts a value in square meters to a specified Terai land unit.
- Parameters:
area_m2 (float) – The area in square meters (must be non-negative).
to_unit (str) – The Terai land unit to convert to (‘bigha’, ‘kattha’, or ‘dhur’).
precision (int, optional) – Number of decimal places to round to (must be non-negative). Default is 4.
- Returns:
Equivalent area in the specified Terai land unit, rounded to the specified precision.
- Return type:
float
- Raises:
ValueError –
If area_m2 is negative or not a number.
If precision is negative.
If to_unit is not a recognized Terai land unit.
Example¶
- rupantaran.land.terai.terai_to_sq_meters(value: float, from_unit: str, precision: int = 4) float[source]¶
Converts a value from a Terai land unit (bigha, kattha, dhur) to square meters.
- Parameters:
value (float) – The numeric amount to convert (must be non-negative).
from_unit (str) – The Terai land unit (‘bigha’, ‘kattha’, or ‘dhur’).
precision (int, optional) – Number of decimal places to round to (must be non-negative). Default is 4.
- Returns:
Equivalent area in square meters, rounded to the specified precision.
- Return type:
float
- Raises:
ValueError –
If value is negative or not a number.
If precision is negative.
If from_unit is not a recognized Terai land unit.
Example¶
- rupantaran.land.terai.terai_to_terai(value: float, from_unit: str, to_unit: str, precision: int = 4) float[source]¶
Converts directly between any two Terai land units using predefined conversion factors.
- Parameters:
value (float) – The numeric amount in the from_unit (must be non-negative).
from_unit (str) – The source Terai land unit (‘bigha’, ‘kattha’, or ‘dhur’).
to_unit (str) – The target Terai land unit (‘bigha’, ‘kattha’, or ‘dhur’).
precision (int, optional) – Number of decimal places to round to (must be non-negative). Default is 4.
- Returns:
Equivalent value in the target Terai land unit, rounded to the specified precision.
- Return type:
float
- Raises:
ValueError –
If value is negative or not a number.
If precision is negative.
If either from_unit or to_unit is not recognized.
Example¶
hilly.py
This module provides functions to convert values between different Hilly land measurement units and square meters. It allows conversions with configurable floating-point precision.
Functions: - hilly_to_sq_meters: Converts a value from a Hilly land unit to square meters. - sq_meters_to_hilly: Converts a value in square meters to a Hilly land unit. - hilly_to_hilly: Converts directly between two Hilly land units.
Constants: - HILLY_TO_SQ_M: Dictionary mapping Hilly land units to their square meter equivalents. - HILLY_CONVERSION_FACTORS: Nested dictionary containing direct conversion ratios between Hilly land units.
- rupantaran.land.hilly.hilly_to_hilly(value: float, from_unit: str, to_unit: str, precision: int = 4) float[source]¶
Converts directly between any two Hilly land units using predefined conversion factors.
- Parameters:
value (float) – The numeric amount in the from_unit (must be non-negative).
from_unit (str) – The source Hilly land unit (e.g., ‘ropani’, ‘aana’, ‘paisa’, ‘dam’).
to_unit (str) – The target Hilly land unit (e.g., ‘ropani’, ‘aana’, ‘paisa’, ‘dam’).
precision (int, optional) – Number of decimal places to round to (must be non-negative). Default is 4.
- Returns:
Equivalent value in the target Hilly land unit, rounded to the specified precision.
- Return type:
float
- Raises:
ValueError –
If value is negative or not a number.
If precision is negative.
If either from_unit or to_unit is not recognized.
Example¶
- rupantaran.land.hilly.hilly_to_sq_meters(value: float, from_unit: str, precision: int = 4) float[source]¶
Converts a value from a Hilly land unit to square meters.
- Parameters:
value (float) – The numeric amount to convert (must be non-negative).
from_unit (str) – The Hilly land unit (e.g., ‘ropani’, ‘aana’, ‘paisa’, ‘dam’).
precision (int, optional) – Number of decimal places to round to (must be non-negative). Default is 4.
- Returns:
Equivalent area in square meters, rounded to the specified precision.
- Return type:
float
- Raises:
ValueError –
If value is negative or not a number.
If precision is negative.
If from_unit is not a recognized Hilly land unit.
Example¶
- rupantaran.land.hilly.sq_meters_to_hilly(area_m2: float, to_unit: str, precision: int = 4) float[source]¶
Converts a value in square meters to a specified Hilly land unit.
- Parameters:
area_m2 (float) – The area in square meters (must be non-negative).
to_unit (str) – The Hilly land unit to convert to (e.g., ‘ropani’, ‘aana’, ‘paisa’, ‘dam’).
precision (int, optional) – Number of decimal places to round to (must be non-negative). Default is 4.
- Returns:
Equivalent area in the specified Hilly land unit, rounded to the specified precision.
- Return type:
float
- Raises:
ValueError –
If area_m2 is negative or not a number.
If precision is negative.
If to_unit is not a recognized Hilly land unit.
Example¶
cross_system.py
This module provides functions to convert land measurements between Terai and Hilly land units by using square meters as an intermediary conversion step.
Functions: - terai_to_hilly: Converts a value from a Terai land unit to a Hilly land unit. - hilly_to_terai: Converts a value from a Hilly land unit to a Terai land unit.
Dependencies: - terai_to_sq_meters: Converts Terai land units to square meters. - sq_meters_to_terai: Converts square meters to Terai land units. - hilly_to_sq_meters: Converts Hilly land units to square meters. - sq_meters_to_hilly: Converts square meters to Hilly land units.
- rupantaran.land.cross_system.hilly_to_terai(value: float, from_unit: str, to_unit: str, precision: int = 4) float[source]¶
Converts a value from a Hilly land unit to a Terai land unit using square meters as an intermediary.
- Parameters:
value (float) – The numeric amount in the from_unit (must be non-negative).
from_unit (str) – The source Hilly land unit (e.g., ‘ropani’, ‘aana’, ‘paisa’, ‘daam’).
to_unit (str) – The target Terai land unit (e.g., ‘bigha’, ‘kattha’, ‘dhur’).
precision (int, optional) – Number of decimal places for rounding (must be non-negative). Default is 4.
- Returns:
The equivalent value in the target Terai land unit, rounded to the specified precision.
- Return type:
float
- Raises:
ValueError –
If value is negative or not a number.
If precision is negative.
If from_unit is not a recognized Hilly land unit.
If to_unit is not a recognized Terai land unit.
Example¶
- rupantaran.land.cross_system.terai_to_hilly(value: float, from_unit: str, to_unit: str, precision: int = 4) float[source]¶
Converts a value from a Terai land unit to a Hilly land unit using square meters as an intermediary.
- Parameters:
value (float) – The numeric amount in the from_unit (must be non-negative).
from_unit (str) – The source Terai land unit (e.g., ‘bigha’, ‘kattha’, ‘dhur’).
to_unit (str) – The target Hilly land unit (e.g., ‘ropani’, ‘aana’, ‘paisa’, ‘daam’).
precision (int, optional) – Number of decimal places for rounding (must be non-negative). Default is 4.
- Returns:
The equivalent value in the target Hilly land unit, rounded to the specified precision.
- Return type:
float
- Raises:
ValueError –
If value is negative or not a number.
If precision is negative.
If from_unit is not a recognized Terai land unit.
If to_unit is not a recognized Hilly land unit.
Example¶
mixed_units.py
This module provides functions for parsing and converting mixed land measurement expressions (e.g., ‘2 ropani 3 aana’) into square meters and vice versa. It also supports cross-system conversions between Hilly and Terai land measurement systems.
Functions: - parse_terai_mixed_unit: Parses a Terai mixed-unit expression into square meters. - parse_hilly_mixed_unit: Parses a Hilly mixed-unit expression into square meters. - sq_meters_to_terai_mixed: Converts square meters to a Terai mixed-unit expression. - sq_meters_to_hilly_mixed: Converts square meters to a Hilly mixed-unit expression. - hilly_mixed_to_terai_mixed: Converts a Hilly mixed-unit expression to a Terai mixed-unit expression. - terai_mixed_to_hilly_mixed: Converts a Terai mixed-unit expression to a Hilly mixed-unit expression.
Constants: - TERAI_TO_SQ_M: Dictionary mapping Terai land units to their square meter equivalents. - HILLY_TO_SQ_M: Dictionary mapping Hilly land units to their square meter equivalents.
- rupantaran.land.mixed_units.hilly_mixed_to_terai_mixed(expression: str, precision: int = 4) str[source]¶
Converts a Hilly mixed-unit expression to a Terai mixed-unit expression.
- Parameters:
expression (str) – A string representing a Hilly mixed-unit value.
precision (int, optional) – Number of decimal places for dhur rounding (must be non-negative). Default is 4.
- Returns:
The equivalent Terai mixed-unit expression.
- Return type:
str
- Raises:
ValueError –
If the input string format is incorrect.
If precision is negative.
Example¶
- rupantaran.land.mixed_units.parse_hilly_mixed_unit(expression: str) float[source]¶
Parses a mixed Hilly land measurement expression into total square meters.
- Parameters:
expression (str) – A string representing a Hilly mixed-unit value (e.g., ‘2 ropani 3 aana 2 paisa’).
- Returns:
The equivalent area in square meters.
- Return type:
float
- Raises:
ValueError –
If the input string format is incorrect.
If an unsupported unit is encountered.
If any value in the expression is negative.
Example¶
- rupantaran.land.mixed_units.parse_terai_mixed_unit(expression: str) float[source]¶
Parses a mixed Terai land measurement expression into total square meters.
- Parameters:
expression (str) – A string representing a Terai mixed-unit value (e.g., ‘1 bigha 5 kattha 10 dhur’).
- Returns:
The equivalent area in square meters.
- Return type:
float
- Raises:
ValueError –
If the input string format is incorrect.
If an unsupported unit is encountered.
If any value in the expression is negative.
Example¶
- rupantaran.land.mixed_units.sq_meters_to_hilly_mixed(area_m2: float, precision: int = 4) str[source]¶
Converts a given area in square meters to a Hilly mixed-unit expression.
- Parameters:
area_m2 (float) – The area in square meters (must be non-negative).
precision (int, optional) – Number of decimal places for daam rounding (must be non-negative). Default is 4.
- Returns:
The equivalent Hilly mixed-unit expression.
- Return type:
str
- Raises:
ValueError –
If area_m2 is negative or not a number.
If precision is negative.
Example¶
- rupantaran.land.mixed_units.sq_meters_to_terai_mixed(area_m2: float, precision: int = 4) str[source]¶
Converts a given area in square meters to a Terai mixed-unit expression.
- Parameters:
area_m2 (float) – The area in square meters (must be non-negative).
precision (int, optional) – Number of decimal places for dhur rounding (must be non-negative). Default is 4.
- Returns:
The equivalent Terai mixed-unit expression.
- Return type:
str
- Raises:
ValueError –
If area_m2 is negative or not a number.
If precision is negative.
Example¶
- rupantaran.land.mixed_units.terai_mixed_to_hilly_mixed(expression: str, precision: int = 4) str[source]¶
Converts a Terai mixed-unit expression to a Hilly mixed-unit expression.
- Parameters:
expression (str) – A string representing a Terai mixed-unit value.
precision (int, optional) – Number of decimal places for daam rounding (must be non-negative). Default is 4.
- Returns:
The equivalent Hilly mixed-unit expression.
- Return type:
str
- Raises:
ValueError –
If the input string format is incorrect.
If precision is negative.
Example¶