ocf-data-sampler 0.2.37__py3-none-any.whl → 0.2.38__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ocf-data-sampler might be problematic. Click here for more details.

@@ -242,6 +242,11 @@ def intersection_of_2_dataframes_of_periods(a: pd.DataFrame, b: pd.DataFrame) ->
242
242
  if a.empty or b.empty:
243
243
  return pd.DataFrame(columns=["start_dt", "end_dt"])
244
244
 
245
+ # Maybe switch these for efficiency in the next section. We will do the native python loop over
246
+ # the shorter dataframe
247
+ if len(a) > len(b):
248
+ a, b = b, a
249
+
245
250
  all_intersecting_periods = []
246
251
  for a_period in a.itertuples():
247
252
  # Five ways in which two periods may overlap:
@@ -250,12 +255,12 @@ def intersection_of_2_dataframes_of_periods(a: pd.DataFrame, b: pd.DataFrame) ->
250
255
  # In all five, `a` must always start before (or equal to) where `b` ends,
251
256
  # and `a` must always end after (or equal to) where `b` starts.
252
257
 
253
- overlapping_periods = b[(a_period.start_dt <= b.end_dt) & (a_period.end_dt >= b.start_dt)]
254
-
255
258
  # There are two ways in which two periods may *not* overlap:
256
259
  # a: |---| or |---|
257
260
  # b: |---| |---|
258
- # `overlapping` will not include periods which do *not* overlap.
261
+ # `overlapping_periods` will not include periods which do *not* overlap.
262
+
263
+ overlapping_periods = b[(a_period.start_dt <= b.end_dt) & (a_period.end_dt >= b.start_dt)]
259
264
 
260
265
  # Now find the intersection of each period in `overlapping_periods` with
261
266
  # the period from `a` that starts at `a_start_dt` and ends at `a_end_dt`.
@@ -269,5 +274,6 @@ def intersection_of_2_dataframes_of_periods(a: pd.DataFrame, b: pd.DataFrame) ->
269
274
 
270
275
  all_intersecting_periods.append(intersection)
271
276
 
277
+
272
278
  all_intersecting_periods = pd.concat(all_intersecting_periods)
273
279
  return all_intersecting_periods.sort_values(by="start_dt").reset_index(drop=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ocf-data-sampler
3
- Version: 0.2.37
3
+ Version: 0.2.38
4
4
  Author: James Fulton, Peter Dudfield
5
5
  Author-email: Open Climate Fix team <info@openclimatefix.org>
6
6
  License: MIT License
@@ -33,7 +33,7 @@ ocf_data_sampler/numpy_sample/sun_position.py,sha256=5tt-zNm6aRuZMsxZPaAxyg7Heik
33
33
  ocf_data_sampler/select/__init__.py,sha256=mK7Wu_-j9IXGTYrOuDf5yDDuU5a306b0iGKTAooNg_s,210
34
34
  ocf_data_sampler/select/dropout.py,sha256=9gPyDF7bGmvSoMjMPu1j0gTZFHNFqsT3ToIo9mFNA00,1565
35
35
  ocf_data_sampler/select/fill_time_periods.py,sha256=TlGxp1xiAqnhdWfLy0pv3FuZc00dtimjWdLzr4JoTGA,865
36
- ocf_data_sampler/select/find_contiguous_time_periods.py,sha256=8lkWsV5i7iLCVGqQ-PGZbvWxsz3wBvLO70GSf6WeR0k,11363
36
+ ocf_data_sampler/select/find_contiguous_time_periods.py,sha256=etkr6LuB7zxkfzWJ6SgHiULdRuFzFlq5bOUNd257Qx4,11545
37
37
  ocf_data_sampler/select/geospatial.py,sha256=CDExkl36eZOKmdJPzUr_K0Wn3axHqv5nYo-EkSiINcc,5032
38
38
  ocf_data_sampler/select/location.py,sha256=AZvGR8y62opiW7zACGXjoOtBEWRfSLOZIA73O5Deu0c,1037
39
39
  ocf_data_sampler/select/select_spatial_slice.py,sha256=Hd4jGRUfIZRoWCirOQZeoLpaUnStB6KyFSTPX69wZLw,8790
@@ -55,7 +55,7 @@ ocf_data_sampler/torch_datasets/utils/validation_utils.py,sha256=YqmT-lExWlI8_ul
55
55
  scripts/download_gsp_location_data.py,sha256=rRDXMoqX-RYY4jPdxhdlxJGhWdl6r245F5UARgKV6P4,3121
56
56
  scripts/refactor_site.py,sha256=skzvsPP0Cn9yTKndzkilyNcGz4DZ88ctvCJ0XrBdc2A,3135
57
57
  utils/compute_icon_mean_stddev.py,sha256=a1oWMRMnny39rV-dvu8rcx85sb4bXzPFrR1gkUr4Jpg,2296
58
- ocf_data_sampler-0.2.37.dist-info/METADATA,sha256=KejDSbMqRFuGL-XF8CVoM4QFqzgCbzzTEDrkY8C3VJc,12184
59
- ocf_data_sampler-0.2.37.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
60
- ocf_data_sampler-0.2.37.dist-info/top_level.txt,sha256=LEFU4Uk-PEo72QGLAfnVZIUEm37Q8mKuMeg_Xk-p33g,31
61
- ocf_data_sampler-0.2.37.dist-info/RECORD,,
58
+ ocf_data_sampler-0.2.38.dist-info/METADATA,sha256=NK9cml2LTr6c3ZJlZ2--EoTkQxnczEz8tmW35ZBnnLc,12184
59
+ ocf_data_sampler-0.2.38.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
60
+ ocf_data_sampler-0.2.38.dist-info/top_level.txt,sha256=LEFU4Uk-PEo72QGLAfnVZIUEm37Q8mKuMeg_Xk-p33g,31
61
+ ocf_data_sampler-0.2.38.dist-info/RECORD,,