pvlib / twoaxistracking

twoaxistracking is a python package for simulating two-axis tracking solar collectors, particularly self-shading.
http://twoaxistracking.rtfd.io/
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

Fix shapely 2.0 ImportError #40

Closed AdamRJensen closed 1 year ago

AdamRJensen commented 1 year ago

This PR fixes the import errors that occur when utilizing the newly released Shapely 2.0.

Closes #39

With Shapely 2.0, there are two import errors when running the twoaxistracking tests. The first occurs in this line:

 from shapely.geos import lgeos

which is used to check if Shapely and its dependencies were properly installed (in the init.py file).

The second import failure occurs when calling shapely.affinity.translate. It seems that the affinity module is not imported automatically anymore when importing Shapely. To solve this, I added a specific import: from shapely import affinity.

AdamRJensen commented 1 year ago

@kanderso-nrel Are you ok dropping the Shapely installation check? If I recall correctly, it's not such an issue anymore now that pip handles binaries.

AdamRJensen commented 1 year ago

Doesn't have to be now, but looks like we'll need to address this eventually:

twoaxistracking/tests/test_shading.py::test_return_geometries_normal_case
  /home/runner/work/twoaxistracking/twoaxistracking/twoaxistracking/tests/test_shading.py:235: ShapelyDeprecationWarning: The 'almost_equals()' method is deprecated and will be removed in Shapely 2.1; use 'equals_exact()' instead
    assert geometries['shading_geometries'][0].almost_equals(expected_shading_geometries)

Nice catch! Instead of using the deprecated almost_equals function, I have changed it to the new equals_exact function which takes a tolerance parameter.