From 70601429eeb4ed5989833d04b06c28201d2d16c3 Mon Sep 17 00:00:00 2001 From: Jonathan Maack Date: Tue, 14 Jan 2025 15:45:25 -0700 Subject: [PATCH] import future annotations for type hints in python 3.8; remove bounds update from nonant LShapedHub update --- mpisppy/cylinders/cross_scen_spoke.py | 4 ++++ mpisppy/cylinders/hub.py | 7 ++++--- mpisppy/cylinders/lshaped_bounder.py | 2 +- mpisppy/cylinders/spcommunicator.py | 5 ++++- mpisppy/cylinders/spoke.py | 4 ++++ mpisppy/cylinders/spwindow.py | 2 -- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/mpisppy/cylinders/cross_scen_spoke.py b/mpisppy/cylinders/cross_scen_spoke.py index fe9ad0c2e..462bca57b 100644 --- a/mpisppy/cylinders/cross_scen_spoke.py +++ b/mpisppy/cylinders/cross_scen_spoke.py @@ -6,6 +6,10 @@ # All rights reserved. Please see the files COPYRIGHT.md and LICENSE.md for # full copyright and license information. ############################################################################### + +# TODO Remove after this program no longer support Python 3.8 +from __future__ import annotations + from mpisppy.cylinders.spcommunicator import communicator_array from pyomo.repn.standard_repn import generate_standard_repn from mpisppy import MPI diff --git a/mpisppy/cylinders/hub.py b/mpisppy/cylinders/hub.py index cb81751b9..135a1d6a8 100644 --- a/mpisppy/cylinders/hub.py +++ b/mpisppy/cylinders/hub.py @@ -6,6 +6,10 @@ # All rights reserved. Please see the files COPYRIGHT.md and LICENSE.md for # full copyright and license information. ############################################################################### + +# TODO Remove after this program no longer support Python 3.8 +from __future__ import annotations + import numpy as np import abc import logging @@ -740,10 +744,7 @@ def send_nonants(self): nonant_send_buffer[ci] = nonant_to_root_var_map[xvar]._value ci += 1 logging.debug("hub is sending X nonants={}".format(nonant_send_buffer)) - self._populate_boundsout_cache(nonant_send_buffer) - # for idx in self.nonant_spoke_indices: - # self.hub_to_spoke(nonant_send_buffer, idx) my_nonants = self._sends[Field.NONANT] self.hub_to_spoke(nonant_send_buffer, Field.NONANT, my_nonants.next_write_id()) diff --git a/mpisppy/cylinders/lshaped_bounder.py b/mpisppy/cylinders/lshaped_bounder.py index b4bc9c406..550ea5227 100644 --- a/mpisppy/cylinders/lshaped_bounder.py +++ b/mpisppy/cylinders/lshaped_bounder.py @@ -62,7 +62,7 @@ def main(self): while not self.got_kill_signal(): if self.new_nonants: - + self.opt._put_nonant_cache(self.localnonants) self.opt._restore_nonants() obj = self.opt.calculate_incumbent(fix_nonants=True) diff --git a/mpisppy/cylinders/spcommunicator.py b/mpisppy/cylinders/spcommunicator.py index 0681add24..ec175dd7e 100644 --- a/mpisppy/cylinders/spcommunicator.py +++ b/mpisppy/cylinders/spcommunicator.py @@ -18,13 +18,16 @@ Separate hub and spoke classes for memory/window management? """ + +# TODO Remove after this program no longer support Python 3.8 +from __future__ import annotations + import numpy as np import abc import time from mpisppy.cylinders.spwindow import Field, SPWindow - def communicator_array(size): arr = np.empty(size+1) arr[:] = np.nan diff --git a/mpisppy/cylinders/spoke.py b/mpisppy/cylinders/spoke.py index 6931e4826..f7763d4a1 100644 --- a/mpisppy/cylinders/spoke.py +++ b/mpisppy/cylinders/spoke.py @@ -6,6 +6,10 @@ # All rights reserved. Please see the files COPYRIGHT.md and LICENSE.md for # full copyright and license information. ############################################################################### + +# TODO Remove after this program no longer support Python 3.8 +from __future__ import annotations + import numpy as np import abc import enum diff --git a/mpisppy/cylinders/spwindow.py b/mpisppy/cylinders/spwindow.py index 46d7b0b52..e0114b9f3 100644 --- a/mpisppy/cylinders/spwindow.py +++ b/mpisppy/cylinders/spwindow.py @@ -70,8 +70,6 @@ def __init__(self, my_fields: dict, strata_comm: MPI.Comm, field_order=None): self.buff[offset + length - 1] = 0.0 ## End for - # print(self.buff) - self.strata_buffer_layouts = strata_comm.allgather(self.buffer_layout) self.window_constructed = True