Skip to content

Commit

Permalink
Making error message more general, and a global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymedina committed Jul 15, 2023
1 parent b94cad6 commit b24cd8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions astrocut/make_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
from mmap import MADV_SEQUENTIAL

__all__ = ['CubeFactory', 'TicaCubeFactory']

ERROR_MSG = "One or more incorrect file types were input. Please input TICA FFI files when using\
``TicaCubeFactory``, and SPOC FFI files when using ``CubeFactory``."

class CubeFactory():
"""
Expand Down Expand Up @@ -88,7 +89,7 @@ def _configure_cube(self, file_list, **extra_keywords):
try:
slice_size = image_shape[1] * len(self.file_list) * 2 * 4 # in bytes (float32)
except IndexError:
raise ValueError("One or more TICA FFIs were input. Please use ``TicaCubeFactory`` to process TICA FFIs.")
raise ValueError(ERROR_MSG)
max_block_size = int((self.max_memory * 1e9)//slice_size)

self.num_blocks = int(image_shape[0]/max_block_size + 1)
Expand Down Expand Up @@ -407,12 +408,11 @@ def _configure_cube(self, file_list, **extra_keywords):

start_times[i] = ffi_data[0].header.get(self.time_keyword)

error_msg = "One or more SPOC FFIs were input. Please use ``CubeFactory`` to process SPOC FFIs."
if image_shape is None: # Only need to fill this once
try:
image_shape = ffi_data[0].data.shape
except AttributeError:
raise ValueError(error_msg)
raise ValueError(ERROR_MSG)

if self.template_file is None: # Only check this if we don't already have it

Expand Down
4 changes: 2 additions & 2 deletions astrocut/tests/test_make_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def test_invalid_inputs(tmpdir, ffi_type):

# Assigning some variables
target_name = "TICA FFI" if ffi_type == "TICA" else "TESS FFI"
class_name = "``TicaCubeFactory``" if ffi_type == "TICA" else "``CubeFactory``"
value_error = f"One or more {ffi_type} FFIs were input. Please use {class_name} to process {ffi_type} FFIs."
value_error = "One or more incorrect file types were input. Please input TICA FFI files when using\
``TicaCubeFactory``, and SPOC FFI files when using ``CubeFactory``."

# Getting TESS sector 27 observations for the given coordinate
observations = Observations.query_criteria(coordinates=coordinates,
Expand Down

0 comments on commit b24cd8f

Please sign in to comment.