Python numpy.mod() Examples
The following are 30 code examples for showing how to use numpy.mod(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example 1
Project: DOTA_models Author: ringringyi File: graph_utils.py License: Apache License 2.0 | 6 votes |
def heuristic_fn_vec(n1, n2, n_ori, step_size): # n1 is a vector and n2 is a single point. dx = (n1[:,0] - n2[0,0])/step_size dy = (n1[:,1] - n2[0,1])/step_size dt = n1[:,2] - n2[0,2] dt = np.mod(dt, n_ori) dt = np.minimum(dt, n_ori-dt) if n_ori == 6: if dx*dy > 0: d = np.maximum(np.abs(dx), np.abs(dy)) else: d = np.abs(dy-dx) elif n_ori == 4: d = np.abs(dx) + np.abs(dy) return (d + dt).reshape((-1,1))
Example 2
Project: DOTA_models Author: ringringyi File: utils.py License: Apache License 2.0 | 6 votes |
def toc(self, average=True, log_at=-1, log_str='', type='calls'): if self.start_time == 0: logging.error('Timer not started by calling tic().') t = time.time() diff = time.time() - self.start_time self.total_time += diff self.calls += 1. self.time_per_call = self.total_time/self.calls if type == 'calls' and log_at > 0 and np.mod(self.calls, log_at) == 0: _ = [] logging.info('%s: %f seconds.', log_str, self.time_per_call) elif type == 'time' and log_at > 0 and t - self.last_log_time >= log_at: _ = [] logging.info('%s: %f seconds.', log_str, self.time_per_call) self.last_log_time = t if average: return self.time_per_call else: return diff
Example 3
Project: pymoo Author: msu-coinlab File: bounds_back_repair.py License: Apache License 2.0 | 6 votes |
def bounds_back(problem, X): only_1d = (X.ndim == 1) X = at_least_2d_array(X) if problem.xl is not None and problem.xu is not None: xl = np.repeat(problem.xl[None, :], X.shape[0], axis=0) xu = np.repeat(problem.xu[None, :], X.shape[0], axis=0) # otherwise bounds back into the feasible space _range = xu - xl X[X < xl] = (xl + np.mod((xl - X), _range))[X < xl] X[X > xu] = (xu - np.mod((X - xu), _range))[X > xu] if only_1d: return X[0, :] else: return X
Example 4
Project: recruit Author: Frank-qlu File: test_ufunc.py License: Apache License 2.0 | 6 votes |
def test_NotImplemented_not_returned(self): # See gh-5964 and gh-2091. Some of these functions are not operator # related and were fixed for other reasons in the past. binary_funcs = [ np.power, np.add, np.subtract, np.multiply, np.divide, np.true_divide, np.floor_divide, np.bitwise_and, np.bitwise_or, np.bitwise_xor, np.left_shift, np.right_shift, np.fmax, np.fmin, np.fmod, np.hypot, np.logaddexp, np.logaddexp2, np.logical_and, np.logical_or, np.logical_xor, np.maximum, np.minimum, np.mod, np.greater, np.greater_equal, np.less, np.less_equal, np.equal, np.not_equal] a = np.array('1') b = 1 c = np.array([1., 2.]) for f in binary_funcs: assert_raises(TypeError, f, a, b) assert_raises(TypeError, f, c, a)
Example 5
Project: pytim Author: Marcello-Sega File: basic_observables.py License: GNU General Public License v3.0 | 6 votes |
def compute(self, inp): try: pos = inp.atoms.positions pos = pos.flatten() except AttributeError: try: pos = inp.flatten() except AttributeError: raise ValueError('must pass an atom group or a ndarray') n = pos.shape[0] if np.mod(n, 9) > 0: # 3 atoms x 3 coordinates raise ValueError('number of atoms in group not a multiple of 3') n = n // 3 pos = pos.reshape(n, 3, 3) if self.QR is True: return np.asarray([np.linalg.qr(A)[0] for A in pos]) else: return np.asarray([self._modified_GS(A) for A in pos])
Example 6
Project: opt-mmd Author: djsutherland File: model_mmd.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def discriminator(self, image, y=None, reuse=False): if reuse: tf.get_variable_scope().reuse_variables() s = self.output_size if np.mod(s, 16) == 0: h0 = lrelu(conv2d(image, self.df_dim, name='d_h0_conv')) h1 = lrelu(self.d_bn1(conv2d(h0, self.df_dim*2, name='d_h1_conv'))) h2 = lrelu(self.d_bn2(conv2d(h1, self.df_dim*4, name='d_h2_conv'))) h3 = lrelu(self.d_bn3(conv2d(h2, self.df_dim*8, name='d_h3_conv'))) h4 = linear(tf.reshape(h3, [self.batch_size, -1]), 1, 'd_h3_lin') return tf.nn.sigmoid(h4), h4 else: h0 = lrelu(conv2d(image, self.df_dim, name='d_h0_conv')) h1 = lrelu(self.d_bn1(conv2d(h0, self.df_dim*2, name='d_h1_conv'))) h2 = linear(tf.reshape(h1, [self.batch_size, -1]), 1, 'd_h2_lin') if not self.config.use_kernel: return tf.nn.sigmoid(h2), h2 else: return tf.nn.sigmoid(h2), h2, h1, h0
Example 7
Project: opt-mmd Author: djsutherland File: model_mmd_fm.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def discriminator(self, image, y=None, reuse=False): if reuse: tf.get_variable_scope().reuse_variables() s = self.output_size if np.mod(s, 16) == 0: h0 = lrelu(conv2d(image, self.df_dim, name='d_h0_conv')) h1 = lrelu(self.d_bn1(conv2d(h0, self.df_dim*2, name='d_h1_conv'))) h2 = lrelu(self.d_bn2(conv2d(h1, self.df_dim*4, name='d_h2_conv'))) h3 = lrelu(self.d_bn3(conv2d(h2, self.df_dim*8, name='d_h3_conv'))) h4 = linear(tf.reshape(h3, [self.batch_size, -1]), 1, 'd_h3_lin') return tf.nn.sigmoid(h4), h4 else: h0 = lrelu(conv2d(image, self.df_dim, name='d_h0_conv')) h1 = lrelu(self.d_bn1(conv2d(h0, self.df_dim*2, name='d_h1_conv'))) h2 = linear(tf.reshape(h1, [self.batch_size, -1]), 1, 'd_h2_lin') if not self.config.use_kernel: return tf.nn.sigmoid(h2), h2 else: return tf.nn.sigmoid(h2), h2, h1, h0
Example 8
Project: opt-mmd Author: djsutherland File: model_tmmd.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def discriminator(self, image, y=None, reuse=False): if reuse: tf.get_variable_scope().reuse_variables() s = self.output_size if np.mod(s, 16) == 0: h0 = lrelu(conv2d(image, self.df_dim, name='d_h0_conv')) h1 = lrelu(self.d_bn1(conv2d(h0, self.df_dim*2, name='d_h1_conv'))) h2 = lrelu(self.d_bn2(conv2d(h1, self.df_dim*4, name='d_h2_conv'))) h3 = lrelu(self.d_bn3(conv2d(h2, self.df_dim*8, name='d_h3_conv'))) h4 = linear(tf.reshape(h3, [self.batch_size, -1]), 1, 'd_h3_lin') return tf.nn.sigmoid(h4), h4 else: h0 = lrelu(conv2d(image, self.df_dim, name='d_h0_conv')) h1 = lrelu(self.d_bn1(conv2d(h0, self.df_dim*2, name='d_h1_conv'))) h2 = linear(tf.reshape(h1, [self.batch_size, -1]), 1, 'd_h2_lin') if not self.config.use_kernel: return tf.nn.sigmoid(h2), h2 else: return tf.nn.sigmoid(h2), h2, h1, h0
Example 9
Project: tenpy Author: tenpy File: lattice.py License: GNU General Public License v3.0 | 6 votes |
def mps2lat_idx(self, i): """Translate MPS index `i` to lattice indices ``(x_0, ..., x_{dim-1}, u)``. Parameters ---------- i : int | array_like of int MPS index/indices. Returns ------- lat_idx : array First dimensions like `i`, last dimension has len `dim`+1 and contains the lattice indices ``(x_0, ..., x_{dim-1}, u)`` corresponding to `i`. For `i` accross the MPS unit cell and "infinite" `bc_MPS`, we shift `x_0` accordingly. """ if self.bc_MPS == 'infinite': # allow `i` outsit of MPS unit cell for bc_MPS infinite i0 = i i = np.mod(i, self.N_sites) if np.any(i0 != i): lat = self.order[i].copy() lat[..., 0] += (i0 - i) * self.N_rings // self.N_sites # N_sites_per_ring might not be set for IrregularLattice return lat return self.order[i].copy()
Example 10
Project: tenpy Author: tenpy File: lattice.py License: GNU General Public License v3.0 | 6 votes |
def get_lattice(lattice_name): """Given the name of a :class:`Lattice` class, get the lattice class itself. Parameters ---------- lattice_name : str Name of a :class:`Lattice` class defined in the module :mod:`~tenpy.models.lattice`, for example ``"Chain", "Square", "Honeycomb", ...``. Returns ------- LatticeClass : :class:`Lattice` The lattice class (type, not instance) specified by `lattice_name`. """ LatticeClass = globals()[lattice_name] assert issubclass(LatticeClass, Lattice) return LatticeClass
Example 11
Project: tenpy Author: tenpy File: charges.py License: GNU General Public License v3.0 | 6 votes |
def save_hdf5(self, hdf5_saver, h5gr, subpath): """Export `self` into a HDF5 file. This method saves all the data it needs to reconstruct `self` with :meth:`from_hdf5`. It stores the :attr:`names` under the path ``"names"``, and :attr:`mod` as dataset ``"U1_ZN"``. Parameters ---------- hdf5_saver : :class:`~tenpy.tools.hdf5_io.Hdf5Saver` Instance of the saving engine. h5gr : :class`Group` HDF5 group which is supposed to represent `self`. subpath : str The `name` of `h5gr` with a ``'/'`` in the end. """ h5gr.attrs['num_charges'] = self._qnumber hdf5_saver.save(self._mod, subpath + "U1_ZN") hdf5_saver.save(self.names, subpath + "names")
Example 12
Project: tenpy Author: tenpy File: charges.py License: GNU General Public License v3.0 | 6 votes |
def drop(cls, chinfo, charge=None): """Remove a charge from a :class:`ChargeInfo`. Parameters ---------- chinfo : :class:`ChargeInfo` The ChargeInfo from where to drop/remove a charge. charge : int | str Number or `name` of the charge (within `chinfo`) which is to be dropped. ``None`` means dropping all charges. Returns ------- chinfo : :class:`ChargeInfo` ChargeInfo where the specified charge is dropped. """ if charge is None: return cls() # trivial charge if isinstance(charge, str): charge = chinfo.names.index(charge) names = list(chinfo.names) names.pop(charge) return cls(np.delete(chinfo.mod, charge), names)
Example 13
Project: tenpy Author: tenpy File: charges.py License: GNU General Public License v3.0 | 6 votes |
def change(cls, chinfo, charge, new_qmod, new_name=''): """Change the `qmod` of a given charge. Parameters ---------- chinfo : :class:`ChargeInfo` The ChargeInfo for which `qmod` of `charge` should be changed. new_qmod : int The new `qmod` to be set. new_name : str The new name of the charge. Returns ------- chinfo : :class:`ChargeInfo` ChargeInfo where `qmod` of the specified charge was changed. """ if isinstance(charge, str): charge = chinfo.names.index(charge) names = list(chinfo.names) names[charge] = new_name mod = chinfo.mod.copy() mod[charge] = new_qmod return cls(mod, names)
Example 14
Project: tenpy Author: tenpy File: charges.py License: GNU General Public License v3.0 | 6 votes |
def make_valid(self, charges=None): """Take charges modulo self.mod. Parameters ---------- charges : array_like or None 1D or 2D array of charges, last dimension `self.qnumber` None defaults to trivial charges ``np.zeros(qnumber, dtype=QTYPE)``. Returns ------- charges : A copy of `charges` taken modulo `mod`, but with ``x % 1 := x`` """ if charges is None: return np.zeros((self.qnumber, ), dtype=QTYPE) charges = np.asarray(charges, dtype=QTYPE) charges[..., self._mask] = np.mod(charges[..., self._mask], self._mod_masked) return charges
Example 15
Project: CausalGAN Author: mkocaoglu File: CausalGAN.py License: MIT License | 6 votes |
def train_step(self,sess,counter): ''' This is a generic function that will be called by the Trainer class once per iteration. The simplest body for this part would be simply "sess.run(self.train_op)". But you may have more complications. Running self.summary_op is handeled by Trainer.Supervisor and doesn't need to be addressed here Only counters, not epochs are explicitly kept track of ''' ###You can wait until counter>N to do stuff for example: if self.config.pretrain_LabelerR and counter < self.config.pretrain_LabelerR_no_of_iters: sess.run(self.d_label_optim) else: if np.mod(counter, 3) == 0: sess.run(self.g_optim) sess.run([self.train_op,self.k_t_update,self.inc_step])#all ops else: sess.run([self.g_optim, self.k_t_update ,self.inc_step]) sess.run(self.g_optim)
Example 16
Project: lingvo Author: tensorflow File: kitti_data.py License: Apache License 2.0 | 6 votes |
def BBox3DToKITTIObject(bbox3d, velo_to_cam_transform): """Convert one bbox3d into KITTI's location, dimension, and rotation_y.""" x, y, z, length, width, height, rot = bbox3d # Avoid transforming objects with invalid boxes. See _KITTIObjectHas3DInfo. if width == -1 or length == -1 or height == -1: return [-1000, -1000, -1000], [-1, -1, -1], -10 # Convert our velodyne bbox rotation back to camera. Reverse the direction and # rotate by np.pi/2. See http://www.cvlibs.net/datasets/kitti/setup.php. rotation_y = rot + np.pi / 2. rotation_y = -rotation_y rotation_y = np.mod(rotation_y, 2 * np.pi) rotation_y = np.where(rotation_y >= np.pi, rotation_y - 2 * np.pi, rotation_y) # Reposition z so that it is at the bottom of the object. if height > 0: z -= height / 2. camera_xyz = np.dot(velo_to_cam_transform, np.asarray([x, y, z, 1.])) location = camera_xyz.tolist()[:3] dimensions = height, width, length return location, dimensions, rotation_y
Example 17
Project: pytorch_stacked_hourglass Author: princeton-vl File: dp.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
def preprocess(self, data): # random hue and saturation data = cv2.cvtColor(data, cv2.COLOR_RGB2HSV); delta = (np.random.random() * 2 - 1) * 0.2 data[:, :, 0] = np.mod(data[:,:,0] + (delta * 360 + 360.), 360.) delta_sature = np.random.random() + 0.5 data[:, :, 1] *= delta_sature data[:,:, 1] = np.maximum( np.minimum(data[:,:,1], 1), 0 ) data = cv2.cvtColor(data, cv2.COLOR_HSV2RGB) # adjust brightness delta = (np.random.random() * 2 - 1) * 0.3 data += delta # adjust contrast mean = data.mean(axis=2, keepdims=True) data = (data - mean) * (np.random.random() + 0.5) + mean data = np.minimum(np.maximum(data, 0), 1) return data
Example 18
Project: FRIDA Author: LCAV File: utils.py License: MIT License | 5 votes |
def polar_error(x1, x2): tp = 2*np.pi e = np.minimum(np.mod(x1-x2, tp), np.mod(x2-x1, tp)) return e
Example 19
Project: dustmaps Author: gregreen File: bh.py License: GNU General Public License v2.0 | 5 votes |
def _lb2RN_mid(self, l, b): R = (np.abs(b) - 10.) / 0.6 N = (np.mod(l, 360.) + 0.15) / 0.3 - 1 return np.round(R).astype('i4'), np.round(N).astype('i4')
Example 20
Project: neuropythy Author: noahbenson File: core.py License: GNU Affero General Public License v3.0 | 5 votes |
def vertex_angle(m, property=None): p = vertex_prop(m, property) if p is None: ang0 = next((m[kk] for k in _vertex_angle_prefixes for kk in [k+'polar_angle'] if kk in m), None) if ang0 is not None: return ang0 ang0 = next((m[kk] for name in ['angle', 'theta'] for k in _vertex_angle_prefixes for kk in [k + name] if kk in m), None) if ang0 is not None: return np.mod(90.0 - 180.0/np.pi*ang0 + 180, 360) - 180 return None return p
Example 21
Project: neuropythy Author: noahbenson File: retinotopy.py License: GNU Affero General Public License v3.0 | 5 votes |
def _clean_angle_deg(polang): polang = np.asarray(polang) clean = np.mod(polang + 180, 360) - 180 is180 = np.isclose(polang, -180) clean[is180] = np.abs(clean[is180]) * np.sign(polang[is180]) return clean
Example 22
Project: neuropythy Author: noahbenson File: retinotopy.py License: GNU Affero General Public License v3.0 | 5 votes |
def _clean_angle_rad(polang): polang = np.asarray(polang) clean = np.mod(polang + np.pi, np.pi*2) - np.pi return clean
Example 23
Project: neuropythy Author: noahbenson File: cmag.py License: GNU Affero General Public License v3.0 | 5 votes |
def theta(polar_angle): return pimms.imm_array(np.mod(np.pi/180.0*(90 - polar_angle) + np.pi, 2*np.pi) - np.pi)
Example 24
Project: neuropythy Author: noahbenson File: core.py License: GNU Affero General Public License v3.0 | 5 votes |
def tangent(x, null=(-np.inf, np.inf), rtol=default_rtol, atol=default_atol): ''' tangent(x) is equivalent to tan(x) except that it also works on sparse arrays. The optional argument null (default, (-numpy.inf, numpy.inf)) may be specified to indicate what value(s) should be assigned when x == -pi/2 or -pi/2. If only one number is given, then it is used for both values; otherwise the first value corresponds to -pi/2 and the second to pi/2. A value of x is considered to be equal to one of these valids based on numpy.isclose. The optional arguments rtol and atol are passed along to isclose. If null is None, then no replacement is performed. ''' if sps.issparse(x): x = x.copy() x.data = tangent(x.data, null=null, rtol=rtol, atol=atol) return x else: x = np.asarray(x) if rtol is None: rtol = default_rtol if atol is None: atol = default_atol try: (nln,nlp) = null except Exception: (nln,nlp) = (null,null) x = np.mod(x + pi, tau) - pi ii = None if nln is None else np.where(np.isclose(x, neghpi, rtol=rtol, atol=atol)) jj = None if nlp is None else np.where(np.isclose(x, hpi, rtol=rtol, atol=atol)) x = np.tan(x) if ii: x[ii] = nln if jj: x[jj] = nlp return x
Example 25
Project: neuropythy Author: noahbenson File: core.py License: GNU Affero General Public License v3.0 | 5 votes |
def cotangent(x, null=(-np.inf, np.inf), rtol=default_rtol, atol=default_atol): ''' cotangent(x) is equivalent to cot(x) except that it also works on sparse arrays. The optional argument null (default, (-numpy.inf, numpy.inf)) may be specified to indicate what value(s) should be assigned when x == 0 or pi. If only one number is given, then it is used for both values; otherwise the first value corresponds to 0 and the second to pi. A value of x is considered to be equal to one of these valids based on numpy.isclose. The optional arguments rtol and atol are passed along to isclose. If null is None, then no replacement is performed. ''' if sps.issparse(x): x = x.toarray() else: x = np.asarray(x) if rtol is None: rtol = default_rtol if atol is None: atol = default_atol try: (nln,nlp) = null except Exception: (nln,nlp) = (null,null) x = np.mod(x + hpi, tau) - hpi ii = None if nln is None else np.where(np.isclose(x, 0, rtol=rtol, atol=atol)) jj = None if nlp is None else np.where(np.isclose(x, pi, rtol=rtol, atol=atol)) x = np.tan(x) if ii: x[ii] = 1 if jj: x[jj] = 1 x = 1.0 / x if ii: x[ii] = nln if jj: x[jj] = nlp return x
Example 26
Project: neuropythy Author: noahbenson File: core.py License: GNU Affero General Public License v3.0 | 5 votes |
def secant(x, null=(-np.inf, np.inf), rtol=default_rtol, atol=default_atol): ''' secant(x) is equivalent to 1/sin(x) except that it also works on sparse arrays. The optional argument null (default, (-numpy.inf, numpy.inf)) may be specified to indicate what value(s) should be assigned when x == -pi/2 or -pi/2. If only one number is given, then it is used for both values; otherwise the first value corresponds to -pi/2 and the second to pi/2. A value of x is considered to be equal to one of these valids based on numpy.isclose. The optional arguments rtol and atol are passed along to isclose. If null is None, then an error is raised when -pi/2 or pi/2 is encountered. ''' if sps.issparse(x): x = x.toarray() else: x = np.asarray(x) if rtol is None: rtol = default_rtol if atol is None: atol = default_atol try: (nln,nlp) = null except Exception: (nln,nlp) = (null,null) x = np.mod(x + pi, tau) - pi ii = None if nln is None else np.where(np.isclose(x, neghpi, rtol=rtol, atol=atol)) jj = None if nlp is None else np.where(np.isclose(x, hpi, rtol=rtol, atol=atol)) x = np.cos(x) if ii: x[ii] = 1.0 if jj: x[jj] = 1.0 x = 1.0/x if ii: x[ii] = nln if jj: x[jj] = nlp return x
Example 27
Project: neuropythy Author: noahbenson File: core.py License: GNU Affero General Public License v3.0 | 5 votes |
def cosecant(x, null=(-np.inf, np.inf), rtol=default_rtol, atol=default_atol): ''' cosecant(x) is equivalent to 1/sin(x) except that it also works on sparse arrays. The optional argument null (default, (-numpy.inf, numpy.inf)) may be specified to indicate what value(s) should be assigned when x == 0 or pi. If only one number is given, then it is used for both values; otherwise the first value corresponds to 0 and the second to pi. A value x is considered to be equal to one of these valids based on numpy.isclose. The optional arguments rtol and atol are passed along to isclose. If null is None, then an error is raised when -pi/2 or pi/2 is encountered. ''' if sps.issparse(x): x = x.toarray() else: x = np.asarray(x) if rtol is None: rtol = default_rtol if atol is None: atol = default_atol try: (nln,nlp) = null except Exception: (nln,nlp) = (null,null) x = np.mod(x + hpi, tau) - hpi # center on pi/2 so that 0 and pi are easy to detect ii = None if nln is None else np.where(np.isclose(x, 0, rtol=rtol, atol=atol)) jj = None if nlp is None else np.where(np.isclose(x, pi, rtol=rtol, atol=atol)) x = np.sin(x) if ii: x[ii] = 1.0 if jj: x[jj] = 1.0 x = 1.0/x if ii: x[ii] = nln if jj: x[jj] = nlp return x
Example 28
Project: DOTA_models Author: ringringyi File: graph_utils.py License: Apache License 2.0 | 5 votes |
def _get_next_nodes(n, sc, n_ori): nodes_to_add = [] nodes_to_validate = [] (p, q, r) = n for r_, a_ in zip([-1, 0, 1], [1, 0, 2]): nodes_to_add.append((n, (p, q, np.mod(r+r_, n_ori)), a_)) if n_ori == 6: if r == 0: v = (p + sc, q, r) elif r == 1: v = (p + sc, q + sc, r) elif r == 2: v = (p, q + sc, r) elif r == 3: v = (p - sc, q, r) elif r == 4: v = (p - sc, q - sc, r) elif r == 5: v = (p, q - sc, r) elif n_ori == 4: if r == 0: v = (p + sc, q, r) elif r == 1: v = (p, q + sc, r) elif r == 2: v = (p - sc, q, r) elif r == 3: v = (p, q - sc, r) nodes_to_validate.append((n,v,3)) return nodes_to_add, nodes_to_validate
Example 29
Project: DOTA_models Author: ringringyi File: nav_env.py License: Apache License 2.0 | 5 votes |
def _pick_data(self, task_number): logging.error('Input Building Names: %s', self.building_names) self.flip = [np.mod(task_number / len(self.building_names), 2) == 1] id = np.mod(task_number, len(self.building_names)) self.building_names = [self.building_names[id]] self.task_params.building_seed = task_number logging.error('BuildingMultiplexer: Picked Building Name: %s', self.building_names) self.building_names = self.building_names[0].split('+') self.flip = [self.flip[0] for _ in self.building_names] logging.error('BuildingMultiplexer: Picked Building Name: %s', self.building_names) logging.error('BuildingMultiplexer: Flipping Buildings: %s', self.flip) logging.error('BuildingMultiplexer: Set building_seed: %d', self.task_params.building_seed) self.num_buildings = len(self.building_names) logging.error('BuildingMultiplexer: Num buildings: %d', self.num_buildings)
Example 30
Project: DOTA_models Author: ringringyi File: env_spec.py License: Apache License 2.0 | 5 votes |
def convert_actions_to_env(self, actions): if self.combine_actions: new_actions = [] actions = actions[0] for dim in self.orig_act_dims: new_actions.append(np.mod(actions, dim)) actions = (actions / dim).astype('int32') actions = new_actions if self.discretize_actions: new_actions = [] idx = 0 for i, (dim, typ) in enumerate(zip(self._act_dims, self._act_types)): if typ == spaces.discrete: new_actions.append(actions[idx]) idx += 1 elif typ == spaces.box: low, high = self.act_info[i] cur_action = [] for j in xrange(dim): cur_action.append( low[j] + (high[j] - low[j]) * actions[idx] / float(self.discretize_actions)) idx += 1 new_actions.append(np.hstack(cur_action)) actions = new_actions return actions