def example_4(): """ Just a crazy example to try as many methods as possible :return: """ print("Some words:") words = [ "This is a test", "Hola ? Is this a good test ?", "H o l a l a", "Lorem ipsum foo bar", "This test is a good one" ] print(words) print("Some letters:") letters = "someletterswilloccurmorethanonceandthisisreallycool! \n" print(letters) # Extract single letter words from 'words' and count them dds_words = DDS().load(words, 10).map_and_flatten(lambda x: x.split(" "))\ .filter(lambda x: len(x) == 1).count_by_value() # Extract letters from 'letters' and count them dds_letters = DDS().load(letters, 5).map_and_flatten(lambda x: list(x))\ .count_by_value() print() print( "Amongst single letter words and letters, the highest occurrence is:") # Join, group by letter and show the highest occurrence print(dds_words.union(dds_letters).reduce_by_key(_sum).max(lambda x: x[1])) print('______________END OF THE EXAMPLE________________\n')
def run_dds(self): # deal1 = {'N': ['C14', 'C13', 'C12', 'C11'], 'E': ['S14', 'S13', 'H12', 'H13'], # 'S': ['D14', 'D11', 'H14', 'H11'], 'W': ['D12', 'D13', 'S12', 'S11']} # displayer.print_hands(deal1) # d = Deal(hands=deal1, current_trick=current_trick) # dds = DDS(d) # start_time = time.time() # utility_dict = dds.get_decision() # print(utility_dict) # # print(f"DDS says playing {decision} will bring {utility} tricks") # print(f"Time Taken = {time.time() - start_time}") # sys.exit(1) start_time = time.time() # Let south start this hand for i in range(0, 800): # seed = np.random.randint(1000) d = Deal(seed=i, cards_each=4, current_turn_index=3, trumps=None) dds = DDS(d) # displayer.print_hands(d.original_hands) # print("Trumps:", d.trumps) # utility_dict = dds.get_utilities() move = dds.get_move() # print(move) # print(utility_dict) print(f"Time Taken = {time.time() - start_time}")
def post(self): """Takes in a single hand and returns a DDS table""" data = request.get_json() # Verify the data here # self.verifyinput(data) dds = DDS(max_threads=2) dds_table = dds.calc_dd_table(data['hands']) return dds_table
def sds_multiprocess(self, layout, deal): d = Deal(hands=layout, current_turn_index=deal.current_turn_index, current_trick=deal.current_trick.copy(), trumps=deal.trumps) dds = DDS(d) # displayer.print_hands(d.original_hands) # displayer.print_deal_info(d) utility_dict = dds.get_utilities() return utility_dict
def start(self): # start_time = time.time() seed = 14 # seed = np.random.randint(100) deal1 = Deal(seed=seed, cards_each=4, first_turn='S') print("Seed =", seed) displayer.print_hands(deal1.current_hands) print("Trumps:", deal1.trumps) # deal1.play_card('W', deal1.current_hands['W'][0]) # print("Lead of", deal1.lead) player = deal1.play_order[deal1.current_turn_index] # start_time = time.time() all_layouts = simulator.find_layouts(deal1, player, on_lead=False) print(f"{len(all_layouts)} possible layouts") # print(f"Time Taken = {time.time() - start_time}") # displayer.print_hands(all_layouts[0]) start_time = time.time() df = self.sds(all_layouts, deal1) mean_df = df.mean() print(mean_df) print(f"Time Taken = {time.time() - start_time}") sys.exit(1) all_args = [[i] + [deal1] for i in all_layouts[:10000]] start_time = time.time() with Pool() as pool: results = pool.starmap(self.sds_multiprocess, all_args) df = pd.DataFrame(results) print(df.head()) print(df.mean()) print(f"Time Taken = {time.time() - start_time}") sys.exit(1) result_list = [] for layout in all_layouts[:1000]: d = Deal(hands=layout, current_turn_index=deal1.current_turn_index, current_trick=deal1.current_trick.copy()) dds = DDS(d) # displayer.print_hands(d.original_hands) # displayer.print_deal_info(d) utility_dict = dds.get_decision() # print(utility_dict) result_list.append(utility_dict.copy()) df = pd.DataFrame(result_list) print(df.mean()) print(f"Time Taken = {time.time() - start_time}") sys.exit(1)
def example_2(): # EXAMPLE 3 print("Occurrences of letters in different strings are as following:") occurrences = [("a", 1), ("b", 1), ("c", 2), ("d", 7), ("a", 2), ("b", 7), ("b", 6), ("a", 2), ("c", 7), ("d", 6), ("e", 2), ("n", 7), ("m", 2), ("n", 6), ("e", 2), ("e", 12)] print(occurrences) print("Retrieve the letters that have more than 5 occurrences in total:") dds = DDS(occurrences) print(dds.reduce_by_key(_sum).filter(lambda x: x[1] > 5).keys().collect()) print('______________END OF THE EXAMPLE________________\n')
def example_3(): print("Given: ID's of players and their points from different tries are:") results = [(1, 10), (2, 5), (3, 8), (1, 7), (2, 6), (3, 15), (1, 5), (2, 6)] print(results) print( "Knowing that maximum tries is 3, show the results of the players " "who have finished the game :)") dds = DDS(results) completed = dds.combine_by_key(to_list, append, extender).filter(_finished).collect() for k, v in completed: print("Player ID: ", k) print("Points: ", v) print('______________END OF THE EXAMPLE________________\n')
def example_5(): print( "WordCount for lines containing '#' (sharp, 'hashtag' for SM " "addicts) in a file.") file_name = 'test.txt' f = open(file_name, 'w') for i in range(1000): f.write("This is a line with #\n") f.write("This one doesn't have a sharp {}\n") f.close() results = DDS().load_text_file(file_name, chunk_size=100)\ .filter(lambda line: '#' in line)\ .map_and_flatten(lambda line: line.split(" ")) \ .count_by_value()\ .filter(lambda x: len(x[0]) > 2)\ .collect_as_dict() print("Words of lines containing '#':") print(results) import os os.remove(file_name) print("______________END OF THE EXAMPLE________________\n")
def pi_estimation(): """ Example is taken from: https://spark.apache.org/examples.html """ print("Estimating Pi by 'throwing darts' algorithm.") tries = 100000 print("Number of tries: {}".format(tries)) count = DDS().load(range(0, tries), 10) \ .filter(inside).count() print("Pi is roughly %f" % (4.0 * count / tries)) print('______________END OF THE EXAMPLE________________\n')
def word_count(): path_file = sys.argv[1] size_block = int(sys.argv[3]) start = time.time() result = DDS().load_file(path_file, chunk_size=size_block, worker_read=True)\ .map_and_flatten(lambda x: x.split()).count_by_value(as_dict=True) print("Elapsed Time: ", time.time() - start) print result return
def sds(self, layouts, deal): """ This runs a dds for every possible layout as viewed from the current player. And then aggregates the results by taking the mean number of tricks for each card """ results_list = [] for layout in layouts: d = Deal(hands=layout, current_turn_index=deal.current_turn_index, current_trick=deal.current_trick.copy(), trumps=deal.trumps) dds = DDS(d) # displayer.print_hands(d.original_hands) # displayer.print_deal_info(d) utility_dict = dds.get_utilities() # print(utility_dict) results_list.append(utility_dict.copy()) df = pd.DataFrame(results_list) return df
def example_1(): print("Creating a DDS with range(10) and 5 partitions:") dds = DDS(range(10), 5) print("Elements of the DDS:") print(dds.collect()) print("Elements & Partitions of the DDS:") dds = DDS(range(10), 5) print(dds.collect(True)) print('______________END OF THE EXAMPLE________________\n')
def __init__(self, HSDIO, AO, DO, label): # declare dds channels self.mot_3d_dds = DDS(HSDIO, mot_3d_dds_pinout, mot_3d_dds_profiles) self.fort_dds = DDS(HSDIO, fort_dds_pinout, fort_dds_profiles) self.mot_2d_dds = DDS(HSDIO, mot_2d_dds_pinout, mot_2d_dds_profiles) self.op_dds = DDS(HSDIO, op_dds_pinout, op_dds_profiles) #self.ryd780b_dds_dds = DDS(HSDIO, ryd780b_dds_pinout, ryd780b_dds_profiles) self.red_pointing_dds = DDS(HSDIO, red_pointing_dds_pinout, red_pointing_dds_profiles) self.blue_pointing_dds = DDS(HSDIO, blue_pointing_dds_pinout, blue_pointing_dds_profiles) self.microwave_dds = DDS(HSDIO, microwave_dds_pinout, microwave_dds_profiles) self.ryd780a_dds = DDS(HSDIO, ryd780a_dds_pinout, ryd780a_dds_profiles) # declare switches self.mot_aom_switch = Switch(HSDIO, mot_aom_switch_chan, profiles=mot_aom_switch_profile, delay=mot_aom_switch_delay) self.fort_aom_switch = Switch(HSDIO, fort_aom_switch_chan, profiles=fort_aom_switch_profile, delay=fort_aom_switch_delay) self.mot_2d_aom_switch = Switch(HSDIO, mot_2d_aom_switch_chan, profiles=mot_2d_aom_switch_profile, delay=mot_2d_aom_switch_delay) self.op_aom_switch = Switch(HSDIO, op_aom_switch_chan, profiles=op_aom_switch_profile, delay=op_aom_switch_delay) self.hf_aom_switch = Switch(HSDIO, hf_aom_switch_chan, profiles=hf_aom_switch_profile, delay=hf_aom_switch_delay) self.mot_3d_x_shutter_switch = Switch( HSDIO, mot_3d_x_shutter_switch_chan, profiles=mot_3d_x_shutter_switch_profile, delay=mot_3d_x_shutter_switch_delay) self.mot_3d_y_shutter_switch = Switch( HSDIO, mot_3d_y_shutter_switch_chan, profiles=mot_3d_y_shutter_switch_profile, delay=mot_3d_y_shutter_switch_delay) self.mot_3d_z1_shutter_switch = Switch( HSDIO, mot_3d_z1_shutter_switch_chan, profiles=mot_3d_z1_shutter_switch_profile, delay=mot_3d_z1_shutter_switch_delay) self.mot_3d_z2_shutter_switch = Switch( HSDIO, mot_3d_z2_shutter_switch_chan, profiles=mot_3d_z2_shutter_switch_profile, delay=mot_3d_z2_shutter_switch_delay) self.repumper_shutter_switch = Switch( HSDIO, repumper_shutter_switch_chan, profiles=repumper_shutter_switch_profile, delay=repumper_shutter_switch_delay) self.microwave_switch = Switch(HSDIO, microwave_switch_chan, profiles=microwave_switch_profile, delay=microwave_switch_delay) self.camera = Camera( HSDIO=HSDIO, channel=andor_trigger_chan, delay=andor_trigger_delay, pulse_length= 5 # in millisecond. this can be overwrttten in functional waveform window ) self.PGcamera = Camera( # Pointgret camera, standard trigger control HSDIO=HSDIO, channel=pointgrey_trigger_chan, delay=pointgrey_trigger_delay, pulse_length= 1 # in millisecond. this can be overwrttten in functional waveform window ) self.PGcamera2 = Camera( # Pointgret camera, standard trigger control HSDIO=HSDIO, channel=pointgrey2_trigger_chan, delay=pointgrey2_trigger_delay, pulse_length= 1 # in millisecond. this can be overwrttten in functional waveform window ) self.red_pointing_aom_switch = Switch( HSDIO, red_pointing_aom_switch_chan, profiles=red_pointing_aom_switch_profile, delay=red_pointing_aom_switch_delay) self.blue_pointing_aom_switch = Switch( HSDIO, blue_pointing_aom_switch_chan, profiles=blue_pointing_aom_switch_profile, delay=blue_pointing_aom_switch_delay) self.ryd780a_aom_switch = Switch(HSDIO, ryd780a_aom_switch_chan, profiles=ryd780a_aom_switch_profile, delay=ryd780a_aom_switch_delay) self.ground_aom_switch = Switch(HSDIO, ground_aom_switch_chan, profiles=ground_aom_switch_profile, delay=ground_aom_switch_delay) self.MOT_scope_trigger_switch = Switch( HSDIO, MOT_scope_trigger_chan, profiles=MOT_scope_trigger_profile, delay=MOT_scope_trigger_delay) self.scope_trigger_switch = Switch(HSDIO, scope_trigger_chan, profiles=scope_trigger_profile, delay=scope_trigger_delay) self.pointgrey_trigger_switch = Switch( HSDIO, pointgrey_trigger_chan, profiles=pointgrey_trigger_profile, delay=pointgrey_trigger_delay) self.pointgrey2_trigger_switch = Switch( HSDIO, pointgrey2_trigger_chan, profiles=pointgrey2_trigger_profile, delay=pointgrey2_trigger_delay) self.FORT_NE_trigger_switch = Switch(HSDIO, FORT_NE_trigger_chan, profiles=FORT_NE_trigger_profile, delay=FORT_NE_trigger_delay) self.ryd780A_NE_trigger_switch = Switch( HSDIO, ryd780A_NE_trigger_chan, profiles=ryd780A_NE_trigger_profile, delay=ryd780A_NE_trigger_delay)
def duc(clearn, dac_clock, dac2x_clock, loopen, loopback, fifo_empty, fifo_re, fifo_dvld, fifo_rdata, fifo_underflow, system_txen, system_txstop, system_ddsen, system_filteren, system_interp, system_shift, system_fcw, system_correct_i, system_correct_q, system_gain_i, system_gain_q, underrun, sample, dac_en, dac_data, dac_last, rx_fifo_full, rx_fifo_we, rx_fifo_wdata, rxen, rxstop, rxfilteren, decim, system_rx_correct_i, system_rx_correct_q, rx_overrun, rx_sample, adc_idata, adc_qdata, adc_last, fir_coeff_ram_addr, fir_coeff_ram_din0, fir_coeff_ram_din1, fir_coeff_ram_blk, fir_coeff_ram_wen, fir_coeff_ram_dout0, fir_coeff_ram_dout1, fir_delay_line_i_ram_addr, fir_delay_line_i_ram_din, fir_delay_line_i_ram_blk, fir_delay_line_i_ram_wen, fir_delay_line_i_ram_dout, fir_delay_line_q_ram_addr, fir_delay_line_q_ram_din, fir_delay_line_q_ram_blk, fir_delay_line_q_ram_wen, fir_delay_line_q_ram_dout, system_firen, system_fir_bank1, system_fir_bank0, system_fir_N, **kwargs): """The Digital Up Converter. :param clearn: Reset signal, completely resets the dsp chain. :param dac_clock: The sampling clock. :param dac2x_clock: Twice the sampling clock. :param loopen: Enable the loopback device. :param loopback: The loopback signature to the digital down converter. :param fifo_empty: Input signal that the fifo is empty. :param fifo_re: Output signal to enable a sample read. :param fifo_dvld: Input signal that FIFO data is valid. :param fifo_rdata: Input sample data. :param fifo_underflow: Input signal that fifo underflowed. :param system_txen: Enable transmit. :param system_txstop: Stop the transmitter. :param system_ddsen: Enable the DDS. :param system_filteren: Enable the CIC filter. :param system_interp: Interpolation rate. :param system_fcw: Set the frequency control word of the DDS. :param system_correct_i: Set the i-Channel AQM DC Offset Correction. :param system_correct_q: Set the q-Channel AQM DC Offset Correction. :param system_gain_i: Set the i-channel AQM gain correction. :param system_gain_q: Set the q-channel AQM gain correction. :param underrun: Output of number of underruns to RFE. :param sample: The sample. :param dac_en: Enable DAC on valid data signal. :param dac_data: The interleaved DAC data. :param dac_last: The last sample going out on the DAC, stops the transmit. :returns: A MyHDL synthesizable module. """ dspsim = kwargs.get('dspsim', None) # DIGIAL UP CONVERTER interp_default = kwargs.get('interp', 1) sync_txen = Signal(bool(0)) txen = Signal(bool(0)) sync_txstop = Signal(bool(0)) txstop = Signal(bool(0)) sync_ddsen = Signal(bool(0)) ddsen = Signal(bool(0)) sync_filteren = Signal(bool(0)) filteren = Signal(bool(0)) sync_interp = Signal(intbv(interp_default)[len(system_interp):]) interp = Signal(intbv(interp_default)[len(system_interp):]) sync_shift = Signal(intbv(0)[len(system_shift):]) shift = Signal(intbv(0)[len(system_shift):]) sync_firen = Signal(bool(0)) firen = Signal(bool(0)) sync_fir_bank0 = Signal(bool(0)) fir_bank0 = Signal(bool(0)) sync_fir_bank1 = Signal(bool(0)) fir_bank1 = Signal(bool(0)) sync_fir_N = Signal(intbv(0, min=system_fir_N.min, max=system_fir_N.max)) fir_N = Signal(intbv(0, min=system_fir_N.min, max=system_fir_N.max)) sync_fcw = Signal(intbv(0)[len(system_fcw):]) fcw = Signal(intbv(0)[len(system_fcw):]) sync_correct_i = Signal(intbv(0)[len(system_correct_i):]) correct_i = Signal(intbv(0)[len(system_correct_i):]) sync_correct_q = Signal(intbv(0)[len(system_correct_q):]) correct_q = Signal(intbv(0)[len(system_correct_q):]) sync_gain_i = Signal(intbv(int(1.0 * 2**9 + .5))[10:]) gain_i = Signal(intbv(int(1.0 * 2**9 + .5))[10:]) sync_gain_q = Signal(intbv(int(1.0 * 2**9 + .5))[10:]) gain_q = Signal(intbv(int(1.0 * 2**9 + .5))[10:]) sync_rx_correct_i = Signal(intbv(0)[len(system_rx_correct_i):]) rx_correct_i = Signal(intbv(0)[len(system_rx_correct_i):]) sync_rx_correct_q = Signal(intbv(0)[len(system_rx_correct_q):]) rx_correct_q = Signal(intbv(0)[len(system_rx_correct_q):]) sample_valid = sample.valid sample_last = sample.last sample_i = sample.i sample_q = sample.q rx_sample_valid = rx_sample.valid rx_sample_last = rx_sample.last rx_sample_i = rx_sample.i rx_sample_q = rx_sample.q adc_sample = Signature("adc", True, bits=10, valid=rxen, last=adc_last, i=adc_idata, q=adc_qdata) truncated_1 = Signature("truncated1", True, bits=9) truncator_1 = truncator(clearn, dac_clock, sample, truncated_1) duc_chain = (truncator_1, ) if kwargs.get('dds_enable', True): if_out = Signature("if_out", True, bits=9) dds_args = clearn, dac_clock, ddsen, truncated_1, if_out, fcw dds = DDS(*dds_args, num_samples=DDS_NUM_SAMPLES) duc_chain = duc_chain + (dds, ) else: if_out = truncated_1 if kwargs.get('fir_enable', True): filtered = Signature("filtered", True, bits=9) fir_0 = FIR(clearn, dac_clock, if_out, filtered, fir_coeff_ram_addr, fir_coeff_ram_din0, fir_coeff_ram_din1, fir_coeff_ram_blk, fir_coeff_ram_wen, fir_coeff_ram_dout0, fir_coeff_ram_dout1, fir_delay_line_i_ram_addr, fir_delay_line_i_ram_din, fir_delay_line_i_ram_blk, fir_delay_line_i_ram_wen, fir_delay_line_i_ram_dout, fir_delay_line_q_ram_addr, fir_delay_line_q_ram_din, fir_delay_line_q_ram_blk, fir_delay_line_q_ram_wen, fir_delay_line_q_ram_dout, firen, fir_bank1, fir_bank0, fir_N) duc_chain = duc_chain + (fir_0, ) else: filtered = if_out upsampled = Signature("upsampled", True, bits=9) upsampler_0 = upsampler(clearn, dac_clock, filtered, upsampled, interp) duc_chain = duc_chain + (upsampler_0, ) if kwargs.get('cic_enable', True): rate_changed = Signature("rate_changed", True, bits=10) cic_0 = cic(clearn, dac_clock, filtered, rate_changed, interp, shift, cic_order=kwargs.get('cic_order', 4), cic_delay=kwargs.get('cic_delay', 1), sim=dspsim) duc_chain = duc_chain + (cic_0, ) processed = Signature("processed", True, bits=10) processed_mux = iqmux(clearn, dac_clock, filteren, upsampled, rate_changed, processed) duc_chain = duc_chain + (processed_mux, ) else: processed = upsampled rf_out = processed tx_loopback = pass_through_with_enable(clearn, dac_clock, rf_out, loopback, loopen) duc_chain = duc_chain + (tx_loopback, ) if kwargs.get('conditioning_enable', True): gain_corrected = Signature("gain_corrected", True, bits=10) gain_corrector_0 = gain_corrector(clearn, dac_clock, gain_i, gain_q, rf_out, gain_corrected) duc_chain = duc_chain + (gain_corrector_0, ) corrected = Signature("offset_corrected", True, bits=10) offset_corrector_0 = offset_corrector(clearn, dac_clock, correct_i, correct_q, gain_corrected, corrected) duc_chain = duc_chain + (offset_corrector_0, ) else: corrected = rf_out offset = Signature("binary_offset", False, bits=10) offseter = binary_offseter(clearn, dac_clock, corrected, offset) duc_chain = duc_chain + (offseter, ) interleaver_0 = interleaver(clearn, dac_clock, dac2x_clock, offset, dac_en, dac_data, dac_last) duc_chain = duc_chain + (interleaver_0, ) # DIGITAL DOWN CONVERTER rx_offset_corrected = Signature("rx_offset_corrected", True, bits=10) rx_offset_corrector = offset_corrector(clearn, dac_clock, rx_correct_i, rx_correct_q, adc_sample, rx_offset_corrected) ddc_chain = (rx_offset_corrector, ) downsampled = Signature("downsampled", True, bits=10) downsampled_i = downsampled.i downsampled_q = downsampled.q downsampled_valid = downsampled.valid downsampler_0 = downsampler(clearn, dac_clock, rx_offset_corrected, downsampled, decim) ddc_chain = ddc_chain + (downsampler_0, ) @always_seq(dac_clock.posedge, reset=clearn) def synchronizer(): sync_txen.next = system_txen txen.next = sync_txen sync_txstop.next = system_txstop txstop.next = sync_txstop sync_ddsen.next = system_ddsen ddsen.next = sync_ddsen sync_filteren.next = system_filteren filteren.next = sync_filteren sync_interp.next = system_interp interp.next = sync_interp sync_shift.next = system_shift shift.next = sync_shift sync_firen.next = system_firen firen.next = sync_firen sync_fir_bank1.next = system_fir_bank1 fir_bank1.next = sync_fir_bank1 sync_fir_bank0.next = system_fir_bank0 fir_bank0.next = sync_fir_bank0 sync_fir_N.next = system_fir_N fir_N.next = sync_fir_N sync_fcw.next = system_fcw fcw.next = sync_fcw sync_correct_i.next = system_correct_i correct_i.next = sync_correct_i sync_correct_q.next = system_correct_q correct_q.next = sync_correct_q sync_gain_i.next = system_gain_i gain_i.next = sync_gain_i sync_gain_q.next = system_gain_q gain_q.next = sync_gain_q sync_rx_correct_i.next = system_rx_correct_i rx_correct_i.next = sync_rx_correct_i sync_rx_correct_q.next = system_rx_correct_q rx_correct_q.next = sync_rx_correct_q interp_counter = Signal(intbv(0)[32:]) done = Signal(bool(0)) decim_counter = Signal(intbv(0)[32:]) rx_done = Signal(bool(0)) @always_seq(dac_clock.posedge, reset=clearn) def consumer(): if txen: if interp_counter == 0: interp_counter.next = interp - 1 if fifo_empty: if txstop: done.next = True fifo_re.next = False else: underrun.next = underrun + 1 done.next = False fifo_re.next = False else: done.next = False fifo_re.next = True else: interp_counter.next = interp_counter - 1 fifo_re.next = False @always_seq(dac_clock.posedge, reset=clearn) def producer(): if rxen and downsampled_valid: if rx_fifo_full: if rxstop: rx_done.next = True rx_fifo_we.next = False else: rx_overrun.next = rx_overrun + 1 rx_done.next = False rx_fifo_we.next = False else: rx_done.next = False rx_fifo_we.next = True else: rx_done.next = False rx_fifo_we.next = False @always_seq(dac_clock.posedge, reset=clearn) def sampler(): if txen: if done: sample_i.next = 0 sample_q.next = 0 sample_valid.next = True sample_last.next = True elif fifo_dvld: sample_i.next = fifo_rdata[16:].signed() sample_q.next = fifo_rdata[32:16].signed() sample_valid.next = True sample_last.next = False else: sample_i.next = 0 sample_q.next = 0 sample_valid.next = False sample_last.next = False else: sample_i.next = 0 sample_q.next = 0 sample_valid.next = False sample_last.next = False if rxen and downsampled_valid: rx_fifo_wdata.next = concat(downsampled_q[9], downsampled_q[9], downsampled_q[9], downsampled_q[9], downsampled_q[9], downsampled_q[9], downsampled_q[10:], downsampled_i[9], downsampled_i[9], downsampled_i[9], downsampled_i[9], downsampled_i[9], downsampled_i[9], downsampled_i[10:]) else: rx_fifo_wdata.next = 0 return ( synchronizer, consumer, producer, sampler, ) + duc_chain + ddc_chain
f"{err}") raise except Exception as err: app.logger.warning(f"Unable to load configuration {config_filename}: " f"{err}") app.logger.warning("Using the default configuration.") app.config.from_mapping(config.get('flask', {})) CORS(app) api = Api(app) # When SetMaxThreads is called there must not be any other threads calling # libdds. The easiest way to avoid parallel calls is to keep only one DDS # object as long as server runs. dds = DDS(max_threads=mt, max_memory=mm) class DDSTable(Resource): def get(self): return {'hello': 'world'} def post(self): """Takes in a single hand and returns a DDS table""" data = request.get_json() # Verify the data here # self.verifyinput(data) dds_table = dds.calc_dd_table(data['hands']) return dds_table
def reduce_example(): test = DDS(range(100), 50).reduce((lambda b, a: b + a), initial=100, arity=3, collect=False)\ .map(lambda a: a+1).collect() print(test)