Skip to content

Commit

Permalink
Changed int and float data types to generic values to be compatible w…
Browse files Browse the repository at this point in the history
…ith Windows machines that use single precision
  • Loading branch information
tomasstolker committed Oct 6, 2021
1 parent 55e5c2f commit 0ee6b88
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 38 deletions.
49 changes: 34 additions & 15 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PynPoint is compatible with Python 3.7/3.8/3.9. Earlier versions (up to v0.7.0)
Virtual Environment
-------------------

PynPoint is available in the `PyPI repository <https://pypi.org/project/pynpoint/>`_ and on `Github <https://github.com/PynPoint/PynPoint>`_. We recommend using a Python virtual environment to install and run PynPoint such that the correct versions of the dependencies can be installed without affecting other installed Python packages. First install `virtualenv`, for example with the `pip package manager <https://packaging.python.org/tutorials/installing-packages/>`_:
PynPoint is available in the `PyPI repository <https://pypi.org/project/pynpoint/>`_ and on `Github <https://github.com/PynPoint/PynPoint>`_. We recommend using a Python virtual environment to install and run PynPoint such that the correct versions of the dependencies can be installed without affecting other installed Python packages. First install ``virtualenv``, for example with the `pip package manager <https://packaging.python.org/tutorials/installing-packages/>`_:

.. code-block:: console
Expand Down Expand Up @@ -65,46 +65,65 @@ To update the installation to the most recent version:
Installation from Github
------------------------

Instead of using ``pip``, the repository with the most recent implementations can also be cloned from Github:
Using pip
^^^^^^^^^

The Github repository contains the latest commits. Installation from Github is also possible with ``pip``:

.. code-block:: console
$ pip install git+git://github.com/PynPoint/PynPoint.git@main
This will also install the required dependencies.

Cloning the repository
^^^^^^^^^^^^^^^^^^^^^^

Alternatively, the Github repository can be cloned, which is in particular useful if you want to look into and/or make changes to the code:

.. code-block:: console
$ git clone git@github.com:PynPoint/PynPoint.git
The package is installed by running the setup script:
PynPoint and the dependencies can be installed by running the setup script:

.. code-block:: console
$ python setup.py install
Alternatively, the path of the repository can be added to the ``PYTHONPATH`` environment variable such that PynPoint can be imported from any working folder:
Instead of running ``setup.py``, the path of the repository can also be added to the ``PYTHONPATH`` environment variable such that PynPoint can be imported from any working folder. When using a ``virtualenv``, the ``PYTHONPATH`` can be added to the activation script:

.. code-block:: console
$ echo "export PYTHONPATH='$PYTHONPATH:/path/to/pynpoint'" >> folder_name/bin/activate
The dependencies can also be installed manually from the PynPoint folder:

.. code-block:: console
With this last approach, the dependencies need to be installed manually.

$ pip install -r requirements.txt
.. important::
Make sure to adjust the path to the PynPoint folder and the virtual environment.

Or updated to the latest versions with which PynPoint is compatible:
Once a local copy of the repository exists, new commits can be pulled from Github with:

.. code-block:: console
$ pip install --upgrade -r requirements.txt
$ git pull origin main
Once a local copy of the repository exists, new commits can be pulled from Github with:
Do you want to makes changes to the code? Please fork the PynPoint repository on the Github page and clone your own fork instead of the main repository. We very much welcome contributions and pull requests (see :ref:`contributing` section).

Dependencies
^^^^^^^^^^^^

If needed, the dependencies can be manually installed from the PynPoint folder:

.. code-block:: console
$ git pull origin main
$ pip install -r requirements.txt
.. important::
Make sure to adjust local path in which PynPoint will be cloned from the Github repository.
Or updated to the latest versions with which PynPoint is compatible:

.. code-block:: console
Do you want to makes changes to the code? Then please fork the PynPoint repository on the Github page and clone your own fork instead of the main repository. We very much welcome contributions and pull requests (see :ref:`contributing` section).
$ pip install --upgrade -r requirements.txt
.. _testing_pynpoint:

Expand Down
3 changes: 2 additions & 1 deletion pynpoint/core/pypeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,8 @@ def get_shape(self,

@typechecked
def list_attributes(self,
data_tag: str) -> Dict[str, Union[str, np.float64, np.ndarray]]:
data_tag: str) -> Dict[str, Union[
str, np.integer, np.floating, np.ndarray, list]]:
"""
Method for printing and returning an overview of all attributes of a dataset.
Expand Down
4 changes: 2 additions & 2 deletions pynpoint/processing/frameselection.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def __init__(self,
def aperture_phot(image: np.ndarray,
position: np.ndarray,
aperture: Union[Tuple[str, float, float],
Tuple[str, None, float]]) -> np.float64:
Tuple[str, None, float]]) -> np.floating:
"""
Parameters
----------
Expand All @@ -219,7 +219,7 @@ def aperture_phot(image: np.ndarray,
Returns
-------
np.float64
np.floating
Photometry value.
"""

Expand Down
16 changes: 8 additions & 8 deletions pynpoint/processing/pcabackground.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ def _separate(self,
def _initialize() -> Tuple[np.array, Optional[np.ndarray], np.ndarray, np.ndarray,
Optional[np.ndarray], np.ndarray]:

background_nframes = np.empty(0, dtype=np.int64)
star_nframes = np.empty(0, dtype=np.int64)
background_nframes = np.empty(0, dtype=int)
star_nframes = np.empty(0, dtype=int)

background_index = np.empty(0, dtype=np.int64)
star_index = np.empty(0, dtype=np.int64)
background_index = np.empty(0, dtype=int)
star_index = np.empty(0, dtype=int)

if parang is None:
background_parang = None
star_parang = None

else:
background_parang = np.empty(0, dtype=np.float64)
star_parang = np.empty(0, dtype=np.float64)
background_parang = np.empty(0, dtype=float)
star_parang = np.empty(0, dtype=float)

return star_index, star_parang, star_nframes, background_index, \
background_parang, background_nframes
Expand Down Expand Up @@ -439,7 +439,7 @@ def _model_background(basis: np.ndarray,

@typechecked
def _dot_product(x_dot: np.ndarray,
*p: np.float64) -> np.ndarray:
*p: np.floating) -> np.ndarray:
return np.dot(p, x_dot)

fit_im_chi = np.zeros(im_arr.shape)
Expand Down Expand Up @@ -696,7 +696,7 @@ def run(self) -> None:
def _admin_start(count: int,
n_dither: int,
position: Tuple[int, int],
star_pos: Union[np.ndarray, np.int64]) -> None:
star_pos: Union[np.ndarray, np.integer]) -> None:
print(f'Processing dither position {count+1} out of {n_dither}...')
print(f'Center position = {position}')

Expand Down
2 changes: 1 addition & 1 deletion pynpoint/util/apply_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def crop_rotating_star(image: np.ndarray,
@typechecked
def photometry(image: np.ndarray,
im_index: int,
aperture: Union[Aperture, List[Aperture]]) -> np.float64:
aperture: Union[Aperture, List[Aperture]]) -> np.array:
# https://photutils.readthedocs.io/en/stable/overview.html
# In Photutils, pixel coordinates are zero-indexed, meaning that (x, y) = (0, 0)
# corresponds to the center of the lowest, leftmost array element. This means that
Expand Down
4 changes: 2 additions & 2 deletions pynpoint/util/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ def shift_image(image: np.ndarray,

@typechecked
def scale_image(image: np.ndarray,
scaling_y: Union[float, np.float32],
scaling_x: Union[float, np.float32]) -> np.ndarray:
scaling_y: Union[float, np.floating],
scaling_x: Union[float, np.floating]) -> np.ndarray:
"""
Function to spatially scale an image.
Expand Down
4 changes: 2 additions & 2 deletions pynpoint/util/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def time_string(delta_time: float) -> str:


@typechecked
def memory_frames(memory: Union[int, np.int64],
def memory_frames(memory: Union[int, np.integer],
nimages: int) -> np.ndarray:
"""
Function to subdivide the input images is in quantities of MEMORY.
Expand Down Expand Up @@ -179,7 +179,7 @@ def angle_difference(angle_1: float,


@typechecked
def stack_angles(memory: Union[int, np.int64],
def stack_angles(memory: Union[int, np.integer],
parang: np.ndarray,
max_rotation: float) -> np.ndarray:
"""
Expand Down
2 changes: 1 addition & 1 deletion pynpoint/util/multiproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TaskInput:

@typechecked
def __init__(self,
input_data: Union[np.ndarray, np.int64, tuple],
input_data: Union[np.ndarray, np.integer, tuple],
job_parameter: tuple) -> None:
"""
Parameters
Expand Down
3 changes: 2 additions & 1 deletion pynpoint/util/postproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
def postprocessor(images: np.ndarray,
angles: np.ndarray,
scales: Optional[np.ndarray],
pca_number: Union[int, Tuple[Union[int, np.int64], Union[int, np.int64]]],
pca_number: Union[int, Tuple[Union[int, np.integer],
Union[int, np.integer]]],
pca_sklearn: PCA = None,
im_shape: Union[None, tuple] = None,
indices: np.ndarray = None,
Expand Down
2 changes: 1 addition & 1 deletion pynpoint/util/psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@typechecked
def pca_psf_subtraction(images: np.ndarray,
angles: Optional[np.ndarray],
pca_number: Union[int, np.int64],
pca_number: Union[int, np.integer],
scales: Optional[np.ndarray] = None,
pca_sklearn: Optional[PCA] = None,
im_shape: Optional[tuple] = None,
Expand Down
2 changes: 1 addition & 1 deletion pynpoint/util/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


@typechecked
def write_selected_data(memory: Union[int, np.int64],
def write_selected_data(memory: Union[int, np.integer],
indices: np.ndarray,
image_in_port: InputPort,
selected_out_port: Optional[OutputPort],
Expand Down
2 changes: 1 addition & 1 deletion pynpoint/util/star.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def star_positions(input_port: InputPort,
"""

nimages = input_port.get_shape()[0]
starpos = np.zeros((nimages, 2), dtype=np.int64)
starpos = np.zeros((nimages, 2), dtype=int)

if position is not None and position[2] is None:
# [y. x] position
Expand Down
4 changes: 2 additions & 2 deletions pynpoint/util/wavelets.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def __pad_signal(self) -> None:
padding_length = int(len(self._m_data) * 0.5)

if self.m_padding == 'zero':
new_data = np.append(self._m_data, np.zeros(padding_length, dtype=np.float64))
self._m_data = np.append(np.zeros(padding_length, dtype=np.float64), new_data)
new_data = np.append(self._m_data, np.zeros(padding_length, dtype=float))
self._m_data = np.append(np.zeros(padding_length, dtype=float), new_data)

elif self.m_padding == 'mirror':
left_half_signal = self._m_data[:padding_length]
Expand Down

0 comments on commit 0ee6b88

Please sign in to comment.