prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  ENH: New geoaccessor to generate great circle distances matrix
  <!--
  Thanks for contributing a pull request!
  
  Please follow these standard acronyms to start the commit message:
  
  - ENH: enhancement
  - BUG: bug fix
  - DOC: documentation
  - TYP: type annotations
  - TST: addition or modification of tests
  - MAINT: maintenance commit (refactoring, typos, etc.)
  - BLD: change related to building
  - REL: related to releasing
  - API: an (incompatible) API change
  - DEP: deprecate something, or remove a deprecated object
  - DEV: development tool or utility
  - REV: revert an earlier commit
  - PERF: performance improvement
  - BOT: always commit via a bot
  - CI: related to CI or CD
  - CLN: Code cleanup
  -->
  
  - [x] closes #699
  - [ ] whatsnew entry
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `dtoolkit/geoaccessor/geoseries/geodistance_matrix.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 import geopandas as gpd
  4 import numpy as np
  5 import pandas as pd
  6 
  7 from dtoolkit.geoaccessor.register import register_geoseries_method
  8 
  9 
  10 @register_geoseries_method
  11 def geodistance_matrix(
  12     s: gpd.GeoSeries,
  13     /,
  14     other: gpd.GeoSeries | gpd.GeoDataFrame | None = None,
  15     radius: float = 6371008.7714150598,
  16 ) -> pd.DataFrame:
  17     """
  18     Returns a ``DataFrame`` containing the `great-circle`__ distances matrix between in
  19     ``s`` and ``other`` via haversine formula.
  20 
  21     __ https://en.wikipedia.org/wiki/Great-circle_distance
  22 
  23     .. math::
  24 
  25         D(x, y) = 2 \\arcsin [
  26             \\sqrt{
  27                 \\sin^2 ((x_1 - y_1) / 2)
  28                 + \\cos(x_1) \\cos(y_1) \\sin^2 ((x_2 - y_2) / 2)
  29             }
  30         ]
  31 
  32     Parameters
  33     ----------
  34     other : GeoSeries, or GeoDataFrame, default None
  35         If None, uses ``other=s``.
  36 
  37     radius : float, default 6371008.7714150598
  38         Great-circle distance uses a spherical model of the earth, using the mean earth
  39         radius as defined by the International Union of Geodesy and Geophysics,
  40         (2\\ *a* + *b*)/3 = 6371008.7714150598 meters for WGS-84.
  41 
  42     Returns
  43     -------
  44     DataFrame
  45         - The index and columns are the same as the index of ``s`` and ``other``.
  46         - The values are the great-circle distances and its unit is meters.
  47 
  48     Raises
  49     ------
  50     ModuleNotFoundError
  51         If don't have module named 'sklearn'.
  52 
  53     ValueError
  54         If the CRS is not ``ESGP:4326``.
  55 
  56     See Also
  57     --------
  58     sklearn.metrics.pairwise.haversine_distances
  59     dtoolkit.geoaccessor.geoseries.geodistance
  60     dtoolkit.geoaccessor.geoseries.geodistance_matrix
  61     dtoolkit.geoaccessor.geodataframe.geodistance
  62     dtoolkit.geoaccessor.geodataframe.geodistance_matrix
  63 
  64     Notes
  65     -----
  66     - Currently, only supports Point geometry.
  67     - The great-circle distance is the angular distance between two points on the
  68       surface of a sphere. As the Earth is nearly spherical, the haversine formula
  69       provides a good approximation of the distance between two points of the Earth
  70       surface, with a less than 1% error on average.
  71 
  72     Examples
  73     --------
  74     >>> import dtoolkit.geoaccessor
  75     >>> df = pd.DataFrame(
  76     ...     {
  77     ...         "x": [120, 122, 100],
  78     ...         "y":[30, 55, 1],
  79     ...     },
  80     ... ).from_xy("x", "y", crs=4326)
  81     >>> df
  82          x   y                    geometry
  83     0  120  30  POINT (120.00000 30.00000)
  84     1  122  55  POINT (122.00000 55.00000)
  85     2  100   1   POINT (100.00000 1.00000)
  86     >>> other = pd.DataFrame(
  87     ...     {
  88     ...         "x": [120, 110],
  89     ...         "y":[30, 40],
  90     ...     },
  91     ... ).from_xy("x", "y", crs=4326)
  92     >>> other
  93          x   y                    geometry
  94     0  120  30  POINT (120.00000 30.00000)
  95     1  110  40  POINT (110.00000 40.00000)
  96     >>> df.geodistance_matrix(other)
  97                   0             1
  98     0  0.000000e+00  1.435335e+06
  99     1  2.784435e+06  1.889892e+06
  100     2  3.855604e+06  4.453100e+06
  101     """
  102     from sklearn.metrics.pairwise import haversine_distances
  103 
  104     if s.crs != 4326:
  105         raise ValueError(f"Only support 'EPSG:4326' CRS, but got {s.crs!r}.")
  106 
  107     if isinstance(other, gpd.base.GeoPandasBase):
  108         if other.crs != 4326:
  109             raise ValueError(f"Only support 'EPSG:4326' CRS, but got {other.crs!r}.")
  110 
  111         # Force convert to GeoSeries
  112         other = other.geometry
  113 
  114     X = np.radians(np.stack((s.y, s.x), axis=1))
  115     Y = np.radians(np.stack((other.y, other.x), axis=1)) if other is not None else other
  116     return pd.DataFrame(
  117         radius * haversine_distances(X, Y),
  118         index=s.index,
  119         columns=other.index,
  120     )
  121
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/dtoolkit/geoaccessor/geoseries/geodistance_matrix.py b/dtoolkit/geoaccessor/geoseries/geodistance_matrix.py
  --- a/dtoolkit/geoaccessor/geoseries/geodistance_matrix.py
  +++ b/dtoolkit/geoaccessor/geoseries/geodistance_matrix.py
  @@ -53,6 +53,9 @@
       ValueError
           If the CRS is not ``ESGP:4326``.
   
  +    TypeError
  +        If the other is not a GeoSeries, GeoDataFrame, or None type.
  +
       See Also
       --------
       sklearn.metrics.pairwise.haversine_distances
  @@ -72,6 +75,7 @@
       Examples
       --------
       >>> import dtoolkit.geoaccessor
  +    >>> import pandas as pd
       >>> df = pd.DataFrame(
       ...     {
       ...         "x": [120, 122, 100],
  @@ -104,17 +108,19 @@
       if s.crs != 4326:
           raise ValueError(f"Only support 'EPSG:4326' CRS, but got {s.crs!r}.")
   
  -    if isinstance(other, gpd.base.GeoPandasBase):
  +    if other is None:
  +        Y = None
  +    elif isinstance(other, gpd.base.GeoPandasBase):
           if other.crs != 4326:
               raise ValueError(f"Only support 'EPSG:4326' CRS, but got {other.crs!r}.")
   
  -        # Force convert to GeoSeries
  -        other = other.geometry
  +        Y = np.radians(np.stack((other.geometry.y, other.geometry.x), axis=1))
  +    else:
  +        raise TypeError(f"Unknown type: {type(other).__name__!r}.")
   
       X = np.radians(np.stack((s.y, s.x), axis=1))
  -    Y = np.radians(np.stack((other.y, other.x), axis=1)) if other is not None else other
       return pd.DataFrame(
           radius * haversine_distances(X, Y),
           index=s.index,
  -        columns=other.index,
  +        columns=other.index if other is not None else s.index,
       )
  
verification_info: {"golden_diff": "diff --git a/dtoolkit/geoaccessor/geoseries/geodistance_matrix.py b/dtoolkit/geoaccessor/geoseries/geodistance_matrix.py\n--- a/dtoolkit/geoaccessor/geoseries/geodistance_matrix.py\n+++ b/dtoolkit/geoaccessor/geoseries/geodistance_matrix.py\n@@ -53,6 +53,9 @@\n     ValueError\n         If the CRS is not ``ESGP:4326``.\n \n+    TypeError\n+        If the other is not a GeoSeries, GeoDataFrame, or None type.\n+\n     See Also\n     --------\n     sklearn.metrics.pairwise.haversine_distances\n@@ -72,6 +75,7 @@\n     Examples\n     --------\n     >>> import dtoolkit.geoaccessor\n+    >>> import pandas as pd\n     >>> df = pd.DataFrame(\n     ...     {\n     ...         \"x\": [120, 122, 100],\n@@ -104,17 +108,19 @@\n     if s.crs != 4326:\n         raise ValueError(f\"Only support 'EPSG:4326' CRS, but got {s.crs!r}.\")\n \n-    if isinstance(other, gpd.base.GeoPandasBase):\n+    if other is None:\n+        Y = None\n+    elif isinstance(other, gpd.base.GeoPandasBase):\n         if other.crs != 4326:\n             raise ValueError(f\"Only support 'EPSG:4326' CRS, but got {other.crs!r}.\")\n \n-        # Force convert to GeoSeries\n-        other = other.geometry\n+        Y = np.radians(np.stack((other.geometry.y, other.geometry.x), axis=1))\n+    else:\n+        raise TypeError(f\"Unknown type: {type(other).__name__!r}.\")\n \n     X = np.radians(np.stack((s.y, s.x), axis=1))\n-    Y = np.radians(np.stack((other.y, other.x), axis=1)) if other is not None else other\n     return pd.DataFrame(\n         radius * haversine_distances(X, Y),\n         index=s.index,\n-        columns=other.index,\n+        columns=other.index if other is not None else s.index,\n     )\n", "issue": "ENH: New geoaccessor to generate great circle distances matrix\n<!--\r\nThanks for contributing a pull request!\r\n\r\nPlease follow these standard acronyms to start the commit message:\r\n\r\n- ENH: enhancement\r\n- BUG: bug fix\r\n- DOC: documentation\r\n- TYP: type annotations\r\n- TST: addition or modification of tests\r\n- MAINT: maintenance commit (refactoring, typos, etc.)\r\n- BLD: change related to building\r\n- REL: related to releasing\r\n- API: an (incompatible) API change\r\n- DEP: deprecate something, or remove a deprecated object\r\n- DEV: development tool or utility\r\n- REV: revert an earlier commit\r\n- PERF: performance improvement\r\n- BOT: always commit via a bot\r\n- CI: related to CI or CD\r\n- CLN: Code cleanup\r\n-->\r\n\r\n- [x] closes #699\r\n- [ ] whatsnew entry\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nimport geopandas as gpd\nimport numpy as np\nimport pandas as pd\n\nfrom dtoolkit.geoaccessor.register import register_geoseries_method\n\n\n@register_geoseries_method\ndef geodistance_matrix(\n    s: gpd.GeoSeries,\n    /,\n    other: gpd.GeoSeries | gpd.GeoDataFrame | None = None,\n    radius: float = 6371008.7714150598,\n) -> pd.DataFrame:\n    \"\"\"\n    Returns a ``DataFrame`` containing the `great-circle`__ distances matrix between in\n    ``s`` and ``other`` via haversine formula.\n\n    __ https://en.wikipedia.org/wiki/Great-circle_distance\n\n    .. math::\n\n        D(x, y) = 2 \\\\arcsin [\n            \\\\sqrt{\n                \\\\sin^2 ((x_1 - y_1) / 2)\n                + \\\\cos(x_1) \\\\cos(y_1) \\\\sin^2 ((x_2 - y_2) / 2)\n            }\n        ]\n\n    Parameters\n    ----------\n    other : GeoSeries, or GeoDataFrame, default None\n        If None, uses ``other=s``.\n\n    radius : float, default 6371008.7714150598\n        Great-circle distance uses a spherical model of the earth, using the mean earth\n        radius as defined by the International Union of Geodesy and Geophysics,\n        (2\\\\ *a* + *b*)/3 = 6371008.7714150598 meters for WGS-84.\n\n    Returns\n    -------\n    DataFrame\n        - The index and columns are the same as the index of ``s`` and ``other``.\n        - The values are the great-circle distances and its unit is meters.\n\n    Raises\n    ------\n    ModuleNotFoundError\n        If don't have module named 'sklearn'.\n\n    ValueError\n        If the CRS is not ``ESGP:4326``.\n\n    See Also\n    --------\n    sklearn.metrics.pairwise.haversine_distances\n    dtoolkit.geoaccessor.geoseries.geodistance\n    dtoolkit.geoaccessor.geoseries.geodistance_matrix\n    dtoolkit.geoaccessor.geodataframe.geodistance\n    dtoolkit.geoaccessor.geodataframe.geodistance_matrix\n\n    Notes\n    -----\n    - Currently, only supports Point geometry.\n    - The great-circle distance is the angular distance between two points on the\n      surface of a sphere. As the Earth is nearly spherical, the haversine formula\n      provides a good approximation of the distance between two points of the Earth\n      surface, with a less than 1% error on average.\n\n    Examples\n    --------\n    >>> import dtoolkit.geoaccessor\n    >>> df = pd.DataFrame(\n    ...     {\n    ...         \"x\": [120, 122, 100],\n    ...         \"y\":[30, 55, 1],\n    ...     },\n    ... ).from_xy(\"x\", \"y\", crs=4326)\n    >>> df\n         x   y                    geometry\n    0  120  30  POINT (120.00000 30.00000)\n    1  122  55  POINT (122.00000 55.00000)\n    2  100   1   POINT (100.00000 1.00000)\n    >>> other = pd.DataFrame(\n    ...     {\n    ...         \"x\": [120, 110],\n    ...         \"y\":[30, 40],\n    ...     },\n    ... ).from_xy(\"x\", \"y\", crs=4326)\n    >>> other\n         x   y                    geometry\n    0  120  30  POINT (120.00000 30.00000)\n    1  110  40  POINT (110.00000 40.00000)\n    >>> df.geodistance_matrix(other)\n                  0             1\n    0  0.000000e+00  1.435335e+06\n    1  2.784435e+06  1.889892e+06\n    2  3.855604e+06  4.453100e+06\n    \"\"\"\n    from sklearn.metrics.pairwise import haversine_distances\n\n    if s.crs != 4326:\n        raise ValueError(f\"Only support 'EPSG:4326' CRS, but got {s.crs!r}.\")\n\n    if isinstance(other, gpd.base.GeoPandasBase):\n        if other.crs != 4326:\n            raise ValueError(f\"Only support 'EPSG:4326' CRS, but got {other.crs!r}.\")\n\n        # Force convert to GeoSeries\n        other = other.geometry\n\n    X = np.radians(np.stack((s.y, s.x), axis=1))\n    Y = np.radians(np.stack((other.y, other.x), axis=1)) if other is not None else other\n    return pd.DataFrame(\n        radius * haversine_distances(X, Y),\n        index=s.index,\n        columns=other.index,\n    )\n", "path": "dtoolkit/geoaccessor/geoseries/geodistance_matrix.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport geopandas as gpd\nimport numpy as np\nimport pandas as pd\n\nfrom dtoolkit.geoaccessor.register import register_geoseries_method\n\n\n@register_geoseries_method\ndef geodistance_matrix(\n    s: gpd.GeoSeries,\n    /,\n    other: gpd.GeoSeries | gpd.GeoDataFrame | None = None,\n    radius: float = 6371008.7714150598,\n) -> pd.DataFrame:\n    \"\"\"\n    Returns a ``DataFrame`` containing the `great-circle`__ distances matrix between in\n    ``s`` and ``other`` via haversine formula.\n\n    __ https://en.wikipedia.org/wiki/Great-circle_distance\n\n    .. math::\n\n        D(x, y) = 2 \\\\arcsin [\n            \\\\sqrt{\n                \\\\sin^2 ((x_1 - y_1) / 2)\n                + \\\\cos(x_1) \\\\cos(y_1) \\\\sin^2 ((x_2 - y_2) / 2)\n            }\n        ]\n\n    Parameters\n    ----------\n    other : GeoSeries, or GeoDataFrame, default None\n        If None, uses ``other=s``.\n\n    radius : float, default 6371008.7714150598\n        Great-circle distance uses a spherical model of the earth, using the mean earth\n        radius as defined by the International Union of Geodesy and Geophysics,\n        (2\\\\ *a* + *b*)/3 = 6371008.7714150598 meters for WGS-84.\n\n    Returns\n    -------\n    DataFrame\n        - The index and columns are the same as the index of ``s`` and ``other``.\n        - The values are the great-circle distances and its unit is meters.\n\n    Raises\n    ------\n    ModuleNotFoundError\n        If don't have module named 'sklearn'.\n\n    ValueError\n        If the CRS is not ``ESGP:4326``.\n\n    TypeError\n        If the other is not a GeoSeries, GeoDataFrame, or None type.\n\n    See Also\n    --------\n    sklearn.metrics.pairwise.haversine_distances\n    dtoolkit.geoaccessor.geoseries.geodistance\n    dtoolkit.geoaccessor.geoseries.geodistance_matrix\n    dtoolkit.geoaccessor.geodataframe.geodistance\n    dtoolkit.geoaccessor.geodataframe.geodistance_matrix\n\n    Notes\n    -----\n    - Currently, only supports Point geometry.\n    - The great-circle distance is the angular distance between two points on the\n      surface of a sphere. As the Earth is nearly spherical, the haversine formula\n      provides a good approximation of the distance between two points of the Earth\n      surface, with a less than 1% error on average.\n\n    Examples\n    --------\n    >>> import dtoolkit.geoaccessor\n    >>> import pandas as pd\n    >>> df = pd.DataFrame(\n    ...     {\n    ...         \"x\": [120, 122, 100],\n    ...         \"y\":[30, 55, 1],\n    ...     },\n    ... ).from_xy(\"x\", \"y\", crs=4326)\n    >>> df\n         x   y                    geometry\n    0  120  30  POINT (120.00000 30.00000)\n    1  122  55  POINT (122.00000 55.00000)\n    2  100   1   POINT (100.00000 1.00000)\n    >>> other = pd.DataFrame(\n    ...     {\n    ...         \"x\": [120, 110],\n    ...         \"y\":[30, 40],\n    ...     },\n    ... ).from_xy(\"x\", \"y\", crs=4326)\n    >>> other\n         x   y                    geometry\n    0  120  30  POINT (120.00000 30.00000)\n    1  110  40  POINT (110.00000 40.00000)\n    >>> df.geodistance_matrix(other)\n                  0             1\n    0  0.000000e+00  1.435335e+06\n    1  2.784435e+06  1.889892e+06\n    2  3.855604e+06  4.453100e+06\n    \"\"\"\n    from sklearn.metrics.pairwise import haversine_distances\n\n    if s.crs != 4326:\n        raise ValueError(f\"Only support 'EPSG:4326' CRS, but got {s.crs!r}.\")\n\n    if other is None:\n        Y = None\n    elif isinstance(other, gpd.base.GeoPandasBase):\n        if other.crs != 4326:\n            raise ValueError(f\"Only support 'EPSG:4326' CRS, but got {other.crs!r}.\")\n\n        Y = np.radians(np.stack((other.geometry.y, other.geometry.x), axis=1))\n    else:\n        raise TypeError(f\"Unknown type: {type(other).__name__!r}.\")\n\n    X = np.radians(np.stack((s.y, s.x), axis=1))\n    return pd.DataFrame(\n        radius * haversine_distances(X, Y),\n        index=s.index,\n        columns=other.index if other is not None else s.index,\n    )\n", "path": "dtoolkit/geoaccessor/geoseries/geodistance_matrix.py"}]}