@@ -1983,10 +1983,16 @@ def dtype(self):
1983
1983
):
1984
1984
# Use the cached dtype
1985
1985
return self ._dtype_
1986
+
1987
+ # Return None if there is a missing operand (e.g. a removed file on disk)
1988
+ if any (v is None for v in self .operands .values ()):
1989
+ return None
1990
+
1986
1991
operands = {
1987
1992
key : np .ones (np .ones (len (value .shape ), dtype = int ), dtype = value .dtype )
1988
1993
for key , value in self .operands .items ()
1989
1994
}
1995
+
1990
1996
if "contains" in self .expression :
1991
1997
_out = ne_evaluate (self .expression , local_dict = operands )
1992
1998
else :
@@ -2019,6 +2025,11 @@ def shape(self):
2019
2025
):
2020
2026
# Use the cached shape
2021
2027
return self ._shape_
2028
+
2029
+ # Return None if there is a missing operand (e.g. a removed file on disk)
2030
+ if any (v is None for v in self .operands .values ()):
2031
+ return None
2032
+
2022
2033
# Operands shape can change, so we always need to recompute this
2023
2034
_shape , chunks , blocks , fast_path = validate_inputs (self .operands , getattr (self , "_out" , None ))
2024
2035
if fast_path :
@@ -3099,11 +3110,16 @@ def _open_lazyarray(array):
3099
3110
raise TypeError ("Error when retrieving the operands" )
3100
3111
3101
3112
expr = lazyarray ["expression" ]
3102
- new_expr = LazyExpr ._new_expr (expr , operands_dict , guess = True , out = None , where = None )
3103
- # Make the array info available for the user (only available when opened from disk)
3104
- new_expr .array = array
3105
- # We want to expose schunk too, so that .info() can be used on the LazyArray
3106
- new_expr .schunk = array .schunk
3113
+ try :
3114
+ new_expr = LazyExpr ._new_expr (expr , operands_dict , guess = True , out = None , where = None )
3115
+ # Make the array info available for the user (only available when opened from disk)
3116
+ new_expr .array = array
3117
+ # We want to expose schunk too, so that .info() can be used on the LazyArray
3118
+ new_expr .schunk = array .schunk
3119
+ except RuntimeError :
3120
+ # Something unexpected happened. Avoid guessing and return something that
3121
+ # can be introspected.
3122
+ new_expr = LazyExpr ._new_expr (expr , operands_dict , guess = False , out = None , where = None )
3107
3123
return new_expr
3108
3124
3109
3125
0 commit comments