Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Shapely 2.0+ #22

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fd1d56c
Add instructions for testing
joseph-sch Jan 21, 2025
676d999
Fix the check on shapely/GEOS
joseph-sch Jan 21, 2025
3a5c7f9
WIP on base.py - compose instead of inheriting
joseph-sch Jan 21, 2025
1a4a666
12 tests of base and 4 of utils pass
joseph-sch Jan 21, 2025
f478801
Whitespace
joseph-sch Jan 21, 2025
8ca29b6
Fix in plot
joseph-sch Jan 21, 2025
1ddd543
6 utils test pass, with 1 warning
joseph-sch Jan 21, 2025
92bee9d
More adaptations -> 86 passed, 16 failed
joseph-sch Jan 22, 2025
f1386cf
Implemen cache of _geometry for ShadeCollection and PVSegment
joseph-sch Jan 22, 2025
c511b4d
Property coords and iterate over difference geometries 90 vs. 12
joseph-sch Jan 22, 2025
d90f5a7
Add method intersects to BaseSide
joseph-sch Jan 22, 2025
7525d92
Migrate PVRow
joseph-sch Jan 22, 2025
a4746fb
Add centroid property to BaseSurface
joseph-sch Jan 22, 2025
7f9cbe3
Fix plots
joseph-sch Jan 22, 2025
2fabbe4
All tests pass
joseph-sch Jan 22, 2025
7d38df6
Update requirements
joseph-sch Jan 22, 2025
36e39f8
Removed a line
joseph-sch Jan 22, 2025
594b122
Bring README to relevance (links, etc.)
joseph-sch Jan 22, 2025
416af05
Merge branch 'update_readme' into migrate_to_shapely_2.0
joseph-sch Jan 23, 2025
783c451
Use dwithin rather than distance
joseph-sch Jan 23, 2025
ff383e3
Fix all but 3 divide-by-zero RuntimeWarning
joseph-sch Jan 23, 2025
c774861
Fix an error message and README
joseph-sch Jan 27, 2025
0fb57bb
Fix for failing Read the Docs build
joseph-sch Jan 27, 2025
f684812
Fix to fix?
joseph-sch Jan 27, 2025
7317e7c
Restore missing path
joseph-sch Jan 27, 2025
d5f8980
Remove ~=4.0 in sphinx requirement
joseph-sch Jan 27, 2025
90b3128
Fix sphinx exception
joseph-sch Jan 27, 2025
9cedd87
Fix README.rst (solarfactors instead of openfactors)
joseph-sch Jan 30, 2025
4a9011a
Fix README.rst (solarfactors instead of openfactors)
joseph-sch Jan 30, 2025
5789f49
Merge remote-tracking branch 'origin/main' into migrate_to_shapely_2.0
joseph-sch Jan 30, 2025
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
65 changes: 42 additions & 23 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ This fork exists so that the pvfactors model can continue to be used with
`pvlib python <https://github.com/pvlib/pvlib-python>`_ even though the original
repository is no longer maintained. The objective is to provide a working
dependency for the existing pvfactors functionality currently in pvlib python.
New features may be added, but don't count on it.

Documentation for this fork can be found at `Read The Docs <https://solarfactors.readthedocs.io>`_.
Documentation for this fork can be found at `Read the Docs <https://solarfactors.readthedocs.io>`_.

The project can be installed from PyPI using ``pip install solarfactors``. Note
that the package is still used from python under the ``pvfactors`` name, i.e.
with ``from pvfactors.geometry import OrderedPVArray``.

The original ``pvfactors`` is preserved below:


pvfactors: irradiance modeling made simple
==========================================
Expand All @@ -34,6 +31,8 @@ equations to account for reflections between all of the surfaces.

pvfactors was originally ported from the SunPower developed 'vf_model' package, which was introduced at the IEEE PV Specialist Conference 44 2017 (see [#pvfactors_paper]_ and link_ to paper).

This fork, `pvlib/solarfactors <https://github.com/pvlib/solarfactors>`_ is maintained by the pvlib project with contributions from the pvlib community.

------------------------------------------

.. contents:: Table of contents
Expand All @@ -44,8 +43,8 @@ pvfactors was originally ported from the SunPower developed 'vf_model' package,
Documentation
-------------

The documentation can be found `here <https://sunpower.github.io/pvfactors>`_.
It includes a lot of tutorials_ that describe the different ways of using pvfactors.
The documentation of this fork can be found `here <https://solarfactors.readthedocs.io>`_.
It includes a lot of tutorials_ that describe the different ways of using solarfactors.


Quick Start
Expand Down Expand Up @@ -187,11 +186,11 @@ The users can also create a "report" while running the simulations that will rel
Installation
------------

pvfactors is currently compatible and tested with 3.6+, and is available in `PyPI <https://pypi.org/project/pvfactors/>`_. The easiest way to install pvfactors is to use pip_ as follows:
solarfactors is currently compatible and tested with Python 3.11 and Shapely 2.0.6, and is available in `PyPI <https://pypi.org/project/solarfactors/>`_. The easiest way to install solarfactors is to use pip_ as follows:

.. code:: sh

$ pip install pvfactors
$ pip install solarfactors

The package wheel files are also available in the `release section`_ of the Github repository.

Expand All @@ -203,13 +202,13 @@ Requirements are included in the ``requirements.txt`` file of the package. Here

* `numpy <https://pypi.python.org/pypi/numpy>`_
* `pvlib-python <https://pypi.python.org/pypi/pvlib>`_
* `shapely <https://pypi.python.org/pypi/Shapely>`_
* `shapely <https://pypi.python.org/pypi/Shapely>`_ (version >= 2.0)


Citing pvfactors
----------------

We appreciate your use of pvfactors. If you use pvfactors in a published work, we kindly ask that you cite:
If you use openfactors in a published work, cite the following paper:
joseph-sch marked this conversation as resolved.
Show resolved Hide resolved


.. parsed-literal::
Expand All @@ -220,8 +219,9 @@ We appreciate your use of pvfactors. If you use pvfactors in a published work, w
Contributing
------------

Contributions are needed in order to improve pvfactors.
If you wish to contribute, you can start by forking and cloning the repository, and then installing pvfactors using pip_ in the root folder of the package:
Contributions are needed in order to improve openfactors.
joseph-sch marked this conversation as resolved.
Show resolved Hide resolved

If you wish to contribute, you can start by forking and cloning the repository, and then installing openfactors using pip_ in the root folder of the package:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you wish to contribute, you can start by forking and cloning the repository, and then installing openfactors using pip_ in the root folder of the package:
If you wish to contribute, you can start by forking and cloning the repository, and then installing solarfactors using pip_ in the root folder of the package:

oops, one more


.. code:: sh

Expand All @@ -234,6 +234,25 @@ To install the package in editable mode, you can use:

$ pip install -e .


Testing
+++++++

Install test dependencies by running:

.. code:: sh

$ pip install pytest mock
Comment on lines +241 to +245
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Install test dependencies by running:
.. code:: sh
$ pip install pytest mock
Install test dependencies using the ``test`` extra:
.. code:: sh
$ pip install .[test]


Then run the tests using:

.. code:: sh

$ python -m pytest

You will need to close manually the plots that are generated during the tests, unless you define the ``CI`` environment variable, which will disable the tests that generate plots.
kandersolar marked this conversation as resolved.
Show resolved Hide resolved


Releasing
+++++++++

Expand All @@ -254,27 +273,27 @@ References

.. _link: https://pdfs.semanticscholar.org/ebb2/35e3c3796b158e1a3c45b40954e60d876ea9.pdf

.. _tutorials: https://sunpower.github.io/pvfactors/tutorials/index.html
.. _tutorials: https://solarfactors.readthedocs.io/en/latest/tutorials/index.html

.. _`full mode`: https://sunpower.github.io/pvfactors/theory/problem_formulation.html#full-simulations
.. _`full mode`: https://solarfactors.readthedocs.io/en/latest/theory/problem_formulation.html#full-simulations

.. _`fast mode`: https://sunpower.github.io/pvfactors/theory/problem_formulation.html#fast-simulations
.. _`fast mode`: https://solarfactors.readthedocs.io/en/latest/theory/problem_formulation.html#fast-simulations

.. _pip: https://pip.pypa.io/en/stable/

.. _`release section`: https://github.com/SunPower/pvfactors/releases
.. _`release section`: https://github.com/pvlib/solarfactors/releases

.. |Logo| image:: https://raw.githubusercontent.com/SunPower/pvfactors/master/docs/sphinx/_static/logo.png
:target: http://sunpower.github.io/pvfactors/
.. |Logo| image:: https://github.com/pvlib/solarfactors/blob/main/docs/sphinx/_static/logo_small.png?raw=true
:target: https://solarfactors.readthedocs.io/en/latest/index.html

.. |CircleCI| image:: https://circleci.com/gh/SunPower/pvfactors.svg?style=shield
:target: https://circleci.com/gh/SunPower/pvfactors

.. |License| image:: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg
:target: https://github.com/SunPower/pvfactors/blob/master/LICENSE
:target: https://github.com/pvlib/solarfactors/blob/main/LICENSE

.. |PyPI-Status| image:: https://img.shields.io/pypi/v/pvfactors.svg
:target: https://pypi.org/project/pvfactors
.. |PyPI-Status| image:: https://img.shields.io/pypi/v/solarfactors.svg
:target: https://pypi.org/project/solarfactors/

.. |PyPI-Versions| image:: https://img.shields.io/pypi/pyversions/pvfactors.svg?logo=python&logoColor=white
:target: https://pypi.org/project/pvfactors
.. |PyPI-Versions| image:: https://img.shields.io/pypi/pyversions/solarfactors.svg?logo=python&logoColor=white
:target: https://pypi.org/project/solarfactors/
8 changes: 4 additions & 4 deletions docs/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ def setup(app):


extlinks = {
'issue': ('https://github.com/pvlib/solarfactors/issues/%s', 'GH'),
'pull': ('https://github.com/pvlib/solarfactors/pull/%s', 'GH'),
'doi': ('http://dx.doi.org/%s', 'DOI: '),
'ghuser': ('https://github.com/%s', '@')
'issue': ('https://github.com/pvlib/solarfactors/issues/%s', 'GH #%s'),
'pull': ('https://github.com/pvlib/solarfactors/pull/%s', 'GH #%s'),
'doi': ('http://dx.doi.org/%s', 'DOI:%s'),
'ghuser': ('https://github.com/%s', '@%s')
}
18 changes: 6 additions & 12 deletions pvfactors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@
logging.basicConfig()

try:
from shapely.geos import lgeos # noqa: F401
except OSError as err:
# https://github.com/SunPower/pvfactors/issues/109
from shapely import geos_version, geos_capi_version # noqa: F401
except ImportError as err:
msg = (
"pvfactors encountered an error when importing the shapely package. "
"This often happens when a binary dependency is missing because "
"shapely was installed from PyPI using pip. Try reinstalling shapely "
"from another source like conda-forge with "
"`conda install -c conda-forge shapely`, or alternatively from "
"Christoph Gohlke's website if you're on Windows: "
"https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely"
"pvfactors detected that the Shapely package is not correctly installed. "
"Make sure that you installed the prerequisites, including Shapely version "
"2.0+, in a supported environment."
)
err.strerror += "; " + msg
raise err
raise ImportError(msg) from err


class PVFactorsError(Exception):
Expand Down
Loading