Package sim2net.area

This package provides a collection of simulation area classes.

Area expresses a simulation surface by its shape and extent in the two-dimensional space with the origin in (0, 0).

Module sim2net.area._area

Contains an abstract class that should be implemented by all simulation area classes.

class sim2net.area._area.Area(name)

Bases: object

This class is an abstract class that should be implemented by all simulation area classes.

Parameters: - name (str): a name of the implemented simulation area.

ORIGIN = (0.0, 0.0)

The origin for simulation areas.

get_area()

Creates a dictionary that stores information about the simulation area.

Returns:
A dictionary containing the simulation area information.
Raises:
  • NotImplementedError: this method is an abstract method.
height

(Property) A height of the simulation area of type float.

Raises:
  • NotImplementedError: this property is an abstract property.
logger

(Property) A logger object of the logging.Logger class with an appropriate channel name.

width

(Property) A width of the simulation area of type float.

Raises:
  • NotImplementedError: this property is an abstract property.
within(horizontal_coordinate, vertical_coordinate)

Tests whether the given coordinates are within the simulation area.

Parameters:
  • horizontal_coordinate (float): a horizontal (x-axis) coordinate;
  • vertical_coordinate (float): a vertical (y-axis) coordinate.
Returns:
(bool) True if the given coordinates are within the simulation area, or False otherwise.
Raises:
  • NotImplementedError: this method is an abstract method.

Module sim2net.area.rectangle

Provides an implementation of a rectangular simulation area in the two-dimensional space.

class sim2net.area.rectangle.Rectangle(width, height)

Bases: sim2net.area._area.Area

This class implements a rectangular simulation area of the given size in the two-dimensional space with the origin in (0, 0).

Parameters:
  • width (float): a width of the rectangular simulation area (along the horizontal x-axis),
  • height (float): a height of the rectangular simulation area (along the vertical y-axis).
Raises:
  • ValueError: raised when a given value of either width or height parameter is equal to or less than 0.
get_area()

Creates a dictionary that stores information about the simulation area.

Returns:

A dictionary that stores information about the simulation area; it has the following fields:

  • ‘area name’: a name of the simulation area of type str,
  • ‘width’: a width of the simulation area of type float,
  • ‘height’: a height of the simulation area of type float.
height

(Property) A height of the simulation area of type float.

width

(Property) A width of the simulation area of type float.

within(horizontal_coordinate, vertical_coordinate)

Tests whether the given coordinates are within the simulation area.

Parameters:
  • horizontal_coordinate (float): a horizontal (x-axis) coordinate;
  • vertical_coordinate (float): a vertical (y-axis) coordinate.
Returns:
(bool) True if the given coordinates are within the rectangular simulation area, or False otherwise.

Module sim2net.area.square

Provides an implementation of a square simulation area in the two-dimensional space.

class sim2net.area.square.Square(side)

Bases: sim2net.area.rectangle.Rectangle

This class implements a square simulation area of the given size in the two-dimensional space with the origin in (0, 0).

Parameters:
  • side (float): a side length of the square simulation area.

Note

In this case, the sim2net.area.rectangle.Rectangle() method is called with the width and height parameters set to the value of the given side argument.

get_area()

Creates a dictionary that stores information about the simulation area.

Returns:

A dictionary that stores information about the simulation area; it has the following fields:

  • ‘area name’: a name of the simulation area of type str,
  • ‘side’: a side length of the square simulation area of type float.