numpy.rint

Here are the examples of the python api numpy.rint taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

185 Examples 7

3 Source : test_umath.py
with GNU General Public License v3.0
from adityaprakash-bobby

def test_rint_big_int():
    # np.rint bug for large integer values on Windows 32-bit and MKL
    # https://github.com/numpy/numpy/issues/6685
    val = 4607998452777363968
    # This is exactly representable in floating point
    assert_equal(val, int(float(val)))
    # Rint should not change the value
    assert_equal(val, np.rint(val))


def test_signaling_nan_exceptions():

3 Source : misc.py
with MIT License
from AugustDS

def format_time(seconds):
    s = int(np.rint(seconds))
    if s   <   60:         return '%ds'                % (s)
    elif s  <  60*60:    return '%dm %02ds'          % (s // 60, s % 60)
    elif s  <  24*60*60: return '%dh %02dm %02ds'    % (s // (60*60), (s // 60) % 60, s % 60)
    else:              return '%dd %02dh %02dm'    % (s // (24*60*60), (s // (60*60)) % 24, (s // 60) % 60)

#----------------------------------------------------------------------------
# Locating results.

def locate_result_subdir(run_id_or_result_subdir):

3 Source : util.py
with MIT License
from autonomousvision

def format_time(seconds: Union[int, float]) -> str:
    """Convert the seconds to human readable string with days, hours, minutes and seconds."""
    s = int(np.rint(seconds))

    if s   <   60:
        return "{0}s".format(s)
    elif s  <  60 * 60:
        return "{0}m {1:02}s".format(s // 60, s % 60)
    elif s  <  24 * 60 * 60:
        return "{0}h {1:02}m {2:02}s".format(s // (60 * 60), (s // 60) % 60, s % 60)
    else:
        return "{0}d {1:02}h {2:02}m".format(s // (24 * 60 * 60), (s // (60 * 60)) % 24, (s // 60) % 60)


def format_time_brief(seconds: Union[int, float]) -> str:

3 Source : util.py
with MIT License
from autonomousvision

def format_time_brief(seconds: Union[int, float]) -> str:
    """Convert the seconds to human readable string with days, hours, minutes and seconds."""
    s = int(np.rint(seconds))

    if s   <   60:
        return "{0}s".format(s)
    elif s  <  60 * 60:
        return "{0}m {1:02}s".format(s // 60, s % 60)
    elif s  <  24 * 60 * 60:
        return "{0}h {1:02}m".format(s // (60 * 60), (s // 60) % 60)
    else:
        return "{0}d {1:02}h".format(s // (24 * 60 * 60), (s // (60 * 60)) % 24)


def ask_yes_no(question: str) -> bool:

3 Source : util.py
with GNU Affero General Public License v3.0
from boschresearch

def format_time(seconds: Union[int, float]) -> str:
    """Convert the seconds to human readable string with days, hours, minutes and seconds."""
    s = int(np.rint(seconds))

    if s   <   60:
        return "{0}s".format(s)
    elif s  <  60 * 60:
        return "{0}m {1:02}s".format(s // 60, s % 60)
    elif s  <  24 * 60 * 60:
        return "{0}h {1:02}m {2:02}s".format(s // (60 * 60), (s // 60) % 60, s % 60)
    else:
        return "{0}d {1:02}h {2:02}m".format(s // (24 * 60 * 60), (s // (60 * 60)) % 24, (s // 60) % 60)


def ask_yes_no(question: str) -> bool:

3 Source : utils.py
with GNU General Public License v3.0
from btobers

def twtt2sample(array, dt):
    sample_array = np.rint(array / dt)
    return sample_array


# sample2twtt
def sample2twtt(array, dt):

3 Source : daq_utils.py
with MIT License
from CEMES-CNRS

def rint(x):
    """
    almost same as numpy rint function but return an integer
    Parameters
    ----------
    x: (float or integer)

    Returns
    -------
    nearest integer
    """
    return int(np.rint(x))


def elt_as_first_element(elt_list, match_word='Mock'):

3 Source : base_application.py
with MIT License
from d909b

    def init_seeds(self):
        import torch
        import random as rn

        seed = int(np.rint(self.args["seed"]))
        info("Seed is", seed)

        os.environ['PYTHONHASHSEED'] = '0'
        rn.seed(seed)
        np.random.seed(seed)
        torch.manual_seed(seed)

    def setup(self):

3 Source : main.py
with MIT License
from d909b

    def load_data(self):
        resample_with_replacement = self.args["resample_with_replacement"]
        seed = int(np.rint(self.args["seed"]))

        self.training_set, self.validation_set, self.test_set, self.input_shape, \
         self.output_dim, self.feature_names, self.feature_types, self.output_names, self.output_types,\
          self.train_patients, self.val_patients, self.test_patients, self.preprocessors, self.output_preprocessors = \
            self.get_data(seed=seed, resample=resample_with_replacement, resample_seed=seed)

    def setup(self):

3 Source : main.py
with MIT License
from d909b

    def make_train_generator(self, randomise=True, stratify=True):
        batch_size = int(np.rint(self.args["batch_size"]))
        seed = int(np.rint(self.args["seed"]))
        num_losses = self.get_num_losses()

        train_generator, train_steps = make_generator(
            dataset=self.training_set,
            batch_size=batch_size,
            num_losses=num_losses,
            shuffle=randomise,
            seed=seed
        )
        return train_generator, train_steps

    def make_validation_generator(self, randomise=False):

3 Source : main.py
with MIT License
from d909b

    def make_validation_generator(self, randomise=False):
        batch_size = int(np.rint(self.args["batch_size"]))
        num_losses = self.get_num_losses()

        val_generator, val_steps = make_generator(
            dataset=self.validation_set,
            batch_size=batch_size,
            num_losses=num_losses,
            shuffle=randomise
        )
        return val_generator, val_steps

    def make_test_generator(self, randomise=False):

3 Source : main.py
with MIT License
from d909b

    def make_test_generator(self, randomise=False):
        batch_size = int(np.rint(self.args["batch_size"]))
        num_losses = self.get_num_losses()

        test_generator, test_steps = make_generator(
            dataset=self.test_set,
            batch_size=batch_size,
            num_losses=num_losses,
            shuffle=randomise
        )
        return test_generator, test_steps

    def get_visualisation_output_directory(self):

3 Source : main.py
with MIT License
from d909b

    def make_train_generator(self, randomise=True, stratify=True):
        seed = int(np.rint(self.args["seed"]))
        validation_fraction = clip_percentage(self.args["validation_set_fraction"])
        test_fraction = clip_percentage(self.args["test_set_fraction"])

        train_generator, train_steps = make_generator(self.args,
                                                      self.benchmark,
                                                      is_validation=False,
                                                      is_test=False,
                                                      validation_fraction=validation_fraction,
                                                      test_fraction=test_fraction,
                                                      seed=seed,
                                                      randomise=randomise,
                                                      stratify=stratify)
        return train_generator, train_steps

    def make_validation_generator(self, randomise=False):

3 Source : main.py
with MIT License
from d909b

    def make_validation_generator(self, randomise=False):
        seed = int(np.rint(self.args["seed"]))
        validation_fraction = clip_percentage(self.args["validation_set_fraction"])
        test_fraction = clip_percentage(self.args["test_set_fraction"])

        val_generator, val_steps = make_generator(self.args,
                                                  self.benchmark,
                                                  is_validation=True,
                                                  is_test=False,
                                                  validation_fraction=validation_fraction,
                                                  test_fraction=test_fraction,
                                                  seed=seed,
                                                  randomise=randomise)
        return val_generator, val_steps

    def make_test_generator(self, randomise=False, do_not_sample_equalised=False):

3 Source : main.py
with MIT License
from d909b

    def make_test_generator(self, randomise=False, do_not_sample_equalised=False):
        seed = int(np.rint(self.args["seed"]))
        validation_fraction = clip_percentage(self.args["validation_set_fraction"])
        test_fraction = clip_percentage(self.args["test_set_fraction"])

        test_generator, test_steps = make_generator(self.args,
                                                    self.benchmark,
                                                    is_validation=False,
                                                    is_test=True,
                                                    validation_fraction=validation_fraction,
                                                    test_fraction=test_fraction,
                                                    seed=seed,
                                                    randomise=randomise)
        return test_generator, test_steps

    def get_best_model_path(self):

3 Source : data_access.py
with MIT License
from d909b

    def __init__(self, data_dir, **kwargs):
        self.data_dir = data_dir
        self.tcga_num_features = int(np.rint(kwargs["tcga_num_features"]))
        self.db = None
        this_directory = os.path.dirname(os.path.realpath(__file__))
        min_path = os.path.join(this_directory, DataAccess.MIN_FILE_NAME)
        max_path = os.path.join(this_directory, DataAccess.MAX_FILE_NAME)
        if os.path.exists(min_path) and \
           os.path.exists(max_path):
            self.min_val, self.max_val = np.load(min_path)[:-1], np.load(max_path)[:-1]
        else:
            self.min_val, self.max_val = None, None
        self.connect()
        self.setup_schema()

    def connect(self):

3 Source : bart.py
with MIT License
from d909b

    def _build(self, **kwargs):
        from rpy2.robjects import numpy2ri, pandas2ri
        n_jobs = int(np.rint(kwargs["n_jobs"]))

        bart = self.install_bart()
        bart.set_bart_machine_num_cores(n_jobs)

        self.bart = bart
        numpy2ri.activate()
        pandas2ri.activate()

        self.with_exposure = kwargs["with_exposure"]
        return None

    def predict_for_model(self, model, x):

3 Source : gradientboosted.py
with MIT License
from d909b

    def _build(self, **kwargs):
        num_units = int(np.rint(kwargs["num_units"]))
        num_layers = int(np.rint(kwargs["num_layers"]))
        return GradientBoostingClassifier(n_estimators=num_units, max_depth=num_layers)

    def preprocess(self, x):

3 Source : psm_pbm.py
with MIT License
from d909b

    def _build(self, **kwargs):
        self.args = kwargs
        self.num_treatments = kwargs["num_treatments"]
        self.batch_size = kwargs["batch_size"]
        self.benchmark = kwargs["benchmark"]
        self.batch_augmentation = BatchAugmentation()
        self.propensity_batch_probability = float(kwargs["propensity_batch_probability"])
        self.num_randomised_neighbours = int(np.rint(kwargs["num_randomised_neighbours"]))
        self.with_exposure = kwargs["with_exposure"]
        return super(PSM_PBM, self)._build(**kwargs)

    def fit_generator(self, train_generator, train_steps, val_generator, val_steps, num_epochs, batch_size):

3 Source : random_forest.py
with MIT License
from d909b

    def _build(self, **kwargs):
        num_units = int(np.rint(kwargs["num_units"]))
        num_layers = int(np.rint(kwargs["num_layers"]))
        self.with_exposure = kwargs["with_exposure"]
        return RandomForestRegressor(n_estimators=num_units, max_depth=num_layers)

    def preprocess(self, x):

3 Source : data_access.py
with MIT License
from d909b

    def __init__(self, data_dir, **kwargs):
        self.data_dir = data_dir
        self.tcga_num_features = int(np.rint(kwargs["tcga_num_features"]))
        self.db = None
        this_directory = os.path.dirname(os.path.realpath(__file__))
        min_path = os.path.join(this_directory, DataAccess.MIN_FILE_NAME)
        max_path = os.path.join(this_directory, DataAccess.MAX_FILE_NAME)
        if os.path.exists(min_path) and \
           os.path.exists(max_path):
            self.min_val, self.max_val = np.load(min_path)[:-1], np.load(max_path)[:-1]
        else:
            self.min_val, self.max_val = None, None
        self.connect()
        self.setup_schema()

    def get_split_indices(self):

3 Source : bart.py
with MIT License
from d909b

    def _build(self, **kwargs):
        from rpy2.robjects import numpy2ri, pandas2ri
        n_jobs = int(np.rint(kwargs["n_jobs"]))

        bart = self.install_bart()
        bart.set_bart_machine_num_cores(n_jobs)

        self.bart = bart
        numpy2ri.activate()
        pandas2ri.activate()

        return None

    def predict_for_model(self, model, x):

3 Source : psm_pbm.py
with MIT License
from d909b

    def _build(self, **kwargs):
        self.args = kwargs
        self.num_treatments = kwargs["num_treatments"]
        self.batch_size = kwargs["batch_size"]
        self.benchmark = kwargs["benchmark"]
        self.batch_augmentation = BatchAugmentation()
        self.propensity_batch_probability = float(kwargs["propensity_batch_probability"])
        self.num_randomised_neighbours = int(np.rint(kwargs["num_randomised_neighbours"]))

        return super(PSM_PBM, self)._build(**kwargs)

    def fit_generator(self, train_generator, train_steps, val_generator, val_steps, num_epochs, batch_size):

3 Source : random_forest.py
with MIT License
from d909b

    def _build(self, **kwargs):
        num_units = int(np.rint(kwargs["num_units"]))
        num_layers = int(np.rint(kwargs["num_layers"]))
        return RandomForestRegressor(n_estimators=num_units, max_depth=num_layers)

    def preprocess(self, x):

3 Source : classes_scattering.py
with Apache License 2.0
from DanPorter

    def hkl(self, HKL, energy_kev=None):
        """ Calculate the two-theta and intensity of the given HKL, display the result"""
        
        if energy_kev is None:
            energy_kev = self._energy_kev
        
        HKL = np.asarray(np.rint(HKL),dtype=np.float).reshape([-1,3])
        tth = self.xtl.Cell.tth(HKL,energy_kev)
        inten = self.intensity(HKL)
        
        print('Energy = %6.3f keV' % energy_kev)
        print('( h, k, l) TwoTheta  Intensity')
        for n in range(len(tth)):
            print('(%2.0f,%2.0f,%2.0f) %8.2f  %9.2f' % (HKL[n,0],HKL[n,1],HKL[n,2],tth[n],inten[n]))
    
    def hkl_reflection(self, HKL, energy_kev=None):

3 Source : classes_scattering.py
with Apache License 2.0
from DanPorter

    def hkl_transmission(self,HKL,energy_kev=None):
        " Calculate the theta, two-theta and intensity of the given HKL in transmission geometry, display the result"
        
        if energy_kev is None:
            energy_kev = self._energy_kev
        
        HKL = np.asarray(np.rint(HKL),dtype=np.float).reshape([-1,3])
        tth = self.xtl.Cell.tth(HKL,energy_kev)
        theta = self.xtl.Cell.theta_transmission(HKL, energy_kev, self._scattering_specular_direction,self._scattering_theta_offset)
        inten = self.intensity(HKL)
        
        print('Energy = %6.3f keV' % energy_kev)
        print('Direction parallel to beam  = (%1.0g,%1.0g,%1.0g)' %(self._scattering_parallel_direction[0],self._scattering_parallel_direction[1],self._scattering_parallel_direction[2]))
        print('( h, k, l)    Theta TwoTheta  Intensity')
        for n in range(len(tth)):
            print('(%2.0f,%2.0f,%2.0f) %8.2f %8.2f  %9.2f' % (HKL[n,0],HKL[n,1],HKL[n,2],theta[n],tth[n],inten[n]))

    def generate_powder(self, q_max=8, peak_width=0.01, background=0, powder_average=True):

3 Source : functions_scattering.py
with Apache License 2.0
from DanPorter

def phase_factor(hkl, uvw):
    """
    Return the complex phase factor:
        phase_factor = exp(i.2.pi.HKL.UVW')
    :param hkl: array [n,3] integer reflections
    :param uvw: array [m,3] atomic positions in atomic basis units
    :return: complex array [n,m]
    """

    hkl = np.asarray(np.rint(hkl), dtype=np.float).reshape([-1, 3])
    uvw = np.asarray(uvw, dtype=np.float).reshape([-1, 3])

    dotprod = np.dot(hkl, uvw.T)
    return np.exp(1j * 2 * np.pi * dotprod)


def phase_factor_qr(q, r):

3 Source : test_umath.py
with Apache License 2.0
from dashanji

def test_rint_big_int():
    # np.rint bug for large integer values on Windows 32-bit and MKL
    # https://github.com/numpy/numpy/issues/6685
    val = 4607998452777363968
    # This is exactly representable in floating point
    assert_equal(val, int(float(val)))
    # Rint should not change the value
    assert_equal(val, np.rint(val))

@pytest.mark.parametrize('ftype', [np.float32, np.float64])

3 Source : classification_image_log.py
with MIT License
from data-sachez-2511

    def __common_part2(self, x, y, output, epoch, dataloader_idx):
        transform = self.inv_transform if self.mode == 'train' else self.inv_transform[dataloader_idx]
        x = [np.rint(transform(image=_)['image']).astype('uint8') for _ in x]
        values, indexes = torch.topk(output, dim=1, k=min(self.n_top_classes, output.size(1)))
        results = [{self.class_names[indexes[obj_idx][i]]: values[obj_idx][i] for i in range(len(indexes[obj_idx]))}
                   for obj_idx in range(len(indexes))]
        values, indexes = torch.topk(y, dim=1, k=min(self.n_top_classes, output.size(1)))
        targets = [{self.class_names[indexes[obj_idx][i]]: values[obj_idx][i] for i in range(len(indexes[obj_idx]))}
                   for obj_idx in range(len(indexes))]
        for i in range(len(x)):
            x[i] = self.__draw_results(x[i], results[i], targets[i])
            dest_dir = os.path.join(self.output_dir, f'epoch_{epoch}', self.mode)
            dest_dir = os.path.join(dest_dir, f'dataloader_{dataloader_idx}') if self.mode == 'val' else dest_dir
            os.makedirs(dest_dir, exist_ok=True)
            cv2.imwrite(os.path.join(dest_dir, '{}.jpg'.format(uuid.uuid4())), x[i])

    def on_validation_batch_end(

3 Source : element_wise_test.py
with BSD 3-Clause "New" or "Revised" License
from deepanshs

def test_rint():
    b = np.rint(a2)
    assert np.allclose(b.dependent_variables[0].components[0], np.rint(data2))


def test_sign():

3 Source : test_video.py
with Apache License 2.0
from DeepMC-DCVC

def write_torch_frame(frame, path):
    frame_result = frame.clone()
    frame_result = frame_result.cpu().detach().numpy().transpose(1, 2, 0)*255
    frame_result = np.clip(np.rint(frame_result), 0, 255)
    frame_result = Image.fromarray(frame_result.astype('uint8'), 'RGB')
    frame_result.save(path)

def encode_one(args_dict, device):

3 Source : fmm_planner.py
with MIT License
from devendrachaplot

    def __init__(self, traversible, scale=1, step_size=5):
        self.scale = scale
        self.step_size = step_size
        if scale != 1.:
            self.traversible = cv2.resize(traversible,
                                          (traversible.shape[1] // scale,
                                           traversible.shape[0] // scale),
                                          interpolation=cv2.INTER_NEAREST)
            self.traversible = np.rint(self.traversible)
        else:
            self.traversible = traversible

        self.du = int(self.step_size / (self.scale * 1.))
        self.fmm_dist = None

    def set_goal(self, goal, auto_improve=False):

3 Source : image.py
with MIT License
from DHI-GRAS

def to_uint8(data: Array, lower_bound: Number, upper_bound: Number) -> Array:
    """Re-scale an array to [1, 255] and cast to uint8 (0 is used for transparency)"""
    rescaled = contrast_stretch(data, (lower_bound, upper_bound), (1, 255), clip=True)
    rescaled = np.rint(rescaled)
    return rescaled.astype(np.uint8)


def label(data: Array, labels: Sequence[Number]) -> Array:

3 Source : misc.py
with MIT License
from DingfanChen

def format_time(seconds):
    s = int(np.rint(seconds))
    if s   <   60:
        return '%ds' % (s)
    elif s  <  60 * 60:
        return '%dm %02ds' % (s // 60, s % 60)
    elif s  <  24 * 60 * 60:
        return '%dh %02dm %02ds' % (s // (60 * 60), (s // 60) % 60, s % 60)
    else:
        return '%dd %02dh %02dm' % (s // (24 * 60 * 60), (s // (60 * 60)) % 24, (s // 60) % 60)


# ----------------------------------------------------------------------------
# Locating results.

def locate_result_subdir(run_id_or_result_subdir):

3 Source : mtbo.py
with BSD 3-Clause "New" or "Revised" License
from DMALab

def transform(X, lower, upper):
    X_norm, _, _ = normalization.zero_one_normalization(X[:, :-1], lower, upper)
    X_norm = np.concatenate((X_norm, np.rint(X[:, None, -1])), axis=1)
    return X_norm


def transformation(X, acq, lower, upper):

3 Source : mtbo_gp.py
with BSD 3-Clause "New" or "Revised" License
from DMALab

def normalize(X, lower, upper):
    X_norm, _, _ = normalization.zero_one_normalization(X[:, :-1], lower, upper)
    X_norm = np.concatenate((X_norm,  np.rint(X[:, None, -1])), axis=1)
    return X_norm


class MTBOGPMCMC(GaussianProcessMCMC):

3 Source : test_autoai_libs.py
with Apache License 2.0
from IBM

    def test_TNoOp(self):
        from autoai_libs.utils.fc_methods import is_not_categorical

        trainable = lale.lib.autoai_libs.TNoOp(
            fun=np.rint,
            name="do nothing",
            datatypes=["numeric"],
            feat_constraints=[is_not_categorical],
        )
        self.doTest(trainable, **self._iris)

    def test_TA1(self):

3 Source : controller.py
with GNU General Public License v3.0
from JanCBrammer

    def _load_peaks(self):
        self._model.status = "Loading peaks."
        dfpeaks = pd.read_csv(self._model.rpathpeaks)
        if dfpeaks.shape[1] == 1:
            peaks = dfpeaks['peaks'].copy()
            peaks = peaks * self._model.sfreq    # convert back to samples
            peaks = peaks.to_numpy()
            peaks = np.rint(peaks).astype(int)    # reshape to a format understood by plotting function (ndarray of int)
            self._model.peaks = peaks
        elif dfpeaks.shape[1] == 2:
            extrema = np.concatenate((dfpeaks['peaks'].copy(),
                                      dfpeaks['troughs'].copy()))
            sortidcs = extrema.argsort(kind='mergesort')
            extrema = extrema[sortidcs]
            extrema = extrema[~np.isnan(extrema)]    # remove NANs that may have been appended in case of odd number of extrema (see _save_peaks)
            extrema = np.rint(extrema * self._model.sfreq).astype(int)    # convert extrema from seconds to samples
            self._model.peaks = extrema

    @threaded

3 Source : controller.py
with BSD 3-Clause "New" or "Revised" License
from JaneliaSciComp

def snippets_doubletap_callback(event):
    x_tic = int(np.rint(event.x/(M.snippets_gap_pix+M.snippets_pix)-0.5))
    y_tic = int(np.floor(-(event.y-1)/V.snippets_dy))
    idouble_tapped_sample = M.nearest_samples[y_tic*M.snippets_nx + x_tic]
    toggle_annotation(idouble_tapped_sample)

def _find_nearest_clustered_sample(history_idx):

3 Source : test_dirax.py
with GNU General Public License v3.0
from LaurentRDC

def test_dirax_indexing_ideal(name, bound):
    """
    Test that indexing always succeeds with an ideal
    set of reflections: no noise, no alien reflections.
    """
    cryst = Crystal.from_database(name)
    refls = [cryst.scattering_vector(r) for r in cryst.bounded_reflections(bound=bound)]
    lat, hkls = index_dirax(refls)

    assert np.allclose(hkls - np.rint(hkls), 0, atol=0.001)


@pytest.mark.parametrize("name", ["Pu-epsilon", "C", "vo2-m1", "BaTiO3_cubic"])

3 Source : discretize.py
with BSD 3-Clause "New" or "Revised" License
from lingquant

    def round_to_int(self):
        """round Markov states to integer."""
        for t in range(1,self.T):
            self.Markov_states[t] = numpy.rint(self.Markov_states[t])

    def SA(self):

3 Source : test_phase_class.py
with GNU General Public License v3.0
from mhvk

    def test_rint(self):
        out = np.rint(self.phase)
        assert_equal(out, self.phase.int)
        out2 = np.rint(self.im_phase)
        assert_equal(out2, self.im_phase.int)

    def test_rint_with_out(self):

3 Source : test_phase_class.py
with GNU General Public License v3.0
from mhvk

    def test_rint_with_out(self):
        out = 0 * self.phase
        result = np.rint(self.phase, out=out)
        assert result is out
        assert_equal(result, Phase(self.phase.int))
        out2 = np.empty(self.phase.shape) * u.cycle
        result2 = np.rint(self.phase, out=out2)
        assert result2 is out2
        expected = u.Quantity(self.phase.int)
        assert_equal(result2, expected)

    def test_unitless_multiplication(self):

3 Source : asap_evaluator.py
with MIT License
from midas-research

	def calc_qwk(self, dev_pred, test_pred):
		# Kappa only supports integer values
		dev_pred_int = np.rint(dev_pred).astype('int32')
		test_pred_int = np.rint(test_pred).astype('int32')
		dev_qwk = qwk(self.dev_y_org, dev_pred_int, self.low, self.high)
		test_qwk = qwk(self.test_y_org, test_pred_int, self.low, self.high)
		dev_lwk = lwk(self.dev_y_org, dev_pred_int, self.low, self.high)
		test_lwk = lwk(self.test_y_org, test_pred_int, self.low, self.high)
		return dev_qwk, test_qwk, dev_lwk, test_lwk
	
	def evaluate(self, model, epoch, print_info=False):

3 Source : rint_run.py
with Apache License 2.0
from mindspore-ai

def gen_data(shape, dtype):
    """gen_data"""
    input_x = random_gaussian(shape, miu=10, sigma=0.3).astype(dtype)
    exp_output = np.rint(input_x)
    # inputs and output to hold the data
    output = np.full(shape, np.nan, dtype)
    args = [input_x, output]
    return args, exp_output, input_x

3 Source : float.py
with Apache License 2.0
from netket

def is_approx_int(x: Array, atol: float = 1e-08) -> Array:
    """
    Returns `True` for all elements of the array that are within
    `atol` to an integer.
    """
    return np.isclose(x, np.rint(x), rtol=0.0, atol=atol)

3 Source : eval.py
with MIT License
from NeurAI-Lab

def destandardize(image, mean=0.443, std=0.129, tile=True, transpose=False):
    image = ((image * std) + mean) * 255.
    image = np.rint(image)
    image[image > 255] = 255
    image[image   <   0] = 0
    image = image.astype(np.uint8)
    if transpose:
        image = image.transpose((1, 2, 0))
    if tile:
        image = np.tile(image, (1, 1, 3))
    return image


def draw_rect(image, corners, color='b', thickness=2):

3 Source : functions.py
with GNU General Public License v3.0
from nrc-cnrc

def rint(x):
    """
    Returns x rounded to the nearest integer value where x can be float, complex, 
    gummy or jummy.
    """
    return _bcallg(np.rint,x)

def fix(x):

3 Source : image_2d.py
with GNU General Public License v3.0
from OxfordIonTrapGroup

def _num_points_in_range(range_spec):
    min, max, increment = range_spec
    return int(np.rint((max - min) / increment + 1))


def _coords_to_indices(coords, range_spec):

3 Source : keras_demo.py
with BSD 2-Clause "Simplified" License
from PhilipMay

def custom_average_recall_score(y_true, y_pred, pos_label):
    rounded_pred = np.rint(y_pred)
    return sklearn.metrics.recall_score(y_true, rounded_pred, pos_label)


mltb_callback = mltb.keras.BinaryClassifierMetricsCallback(

See More Examples