Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "h5py in functional component" in Python

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'h5py' in functional components in Python. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

for line in open(seqs_bed_file):
    a = line.split()
    model_seqs.append(ModelSeq(a[0],int(a[1]),int(a[2]),None))

  # read blacklist regions
  black_chr_trees = read_blacklist(options.blacklist_bed)

  # compute dimensions
  num_seqs = len(model_seqs)
  seq_len_nt = model_seqs[0].end - model_seqs[0].start
  seq_len_nt -= 2*options.crop_bp
  target_length = seq_len_nt // options.pool_width
  assert(target_length > 0)

  # initialize sequences coverage file
  seqs_cov_open = h5py.File(seqs_cov_file, 'w')
  seqs_cov_open.create_dataset('seqs_cov', shape=(num_seqs, target_length), dtype='float16')

  # open genome coverage file
  genome_cov_open = CovFace(genome_cov_file)

  # for each model sequence
  for si in range(num_seqs):
    mseq = model_seqs[si]

    # read coverage
    seq_cov_nt = genome_cov_open.read(mseq.chr, mseq.start, mseq.end)

    # determine baseline coverage
    baseline_cov = np.percentile(seq_cov_nt, 10)
    baseline_cov = np.nan_to_num(baseline_cov)
quad_slow = slow // self.n_quads
      module_fast = quad_fast
      module_slow = quad_slow // self.n_modules
      asic_fast = module_fast
      asic_slow = module_slow // self.n_asics

    detector = instrument.create_group('ELE_D0')
    detector.attrs['NX_class']  = 'NXdetector'
    if 'mask' in h5py.File(self.params.cxi_file, 'r')['entry_1/data_1']:
      detector.create_dataset('pixel_mask_applied', (1,), data=[True], dtype='uint32')
      detector['pixel_mask'] = h5py.ExternalLink(self.params.cxi_file, "entry_1/data_1/mask")
    array_name = 'ARRAY_D0'

    alias = 'data'
    data_name = 'data'
    detector[alias] = h5py.SoftLink('/entry/data/%s'%data_name)

    for quad in range(self.n_quads):
      q_key = "q%d"%quad
      q_name = 'AXIS_D0Q%d'%quad
      quad_vector = self.hierarchy[q_key].local_origin.elems
      self.create_vector(transformations, q_name, 0.0, depends_on='AXIS_D0', equipment='detector', equipment_component='detector_quad',transformation_type='rotation', units='degrees', vector=(0., 0., -1.), offset = quad_vector, offset_units = 'mm')
      for module_num in range(self.n_modules):
        m_key = "p%d"%((quad*self.n_modules)+module_num)
        m_name = 'AXIS_D0Q%dM%d'%(quad, module_num)
        module_vector = self.hierarchy[q_key][m_key].local_origin.elems
        self.create_vector(transformations, m_name, 0.0, depends_on=q_name, equipment='detector', equipment_component='detector_module',transformation_type='rotation', units='degrees', vector=(0., 0., -1.), offset = module_vector, offset_units = 'mm')

        for asic_num in range(self.n_asics):
          a_key = "p%da%d"%((quad*self.n_modules)+module_num, asic_num)
          a_name = 'AXIS_D0Q%dM%dA%d'%(quad, module_num, asic_num)
          asic_vector = self.hierarchy[q_key][m_key][a_key]['local_origin'].elems
# Utilities.  The full HDF5 REST Server copyright notice, including       s   #
# terms governing use, modification, and redistribution, is contained in     #
# the file COPYING, which can be found at the root of the source code        #
# distribution tree.  If you do not have access to this file, you may        #
# request a copy from help@hdfgroup.org.                                     #
##############################################################################

import os
import sys
import h5py

unit_tests = ( 'hdf5dtypeTest', 'hdf5dbTest' )
integ_tests = ( 'h5tojson_test', 'jsontoh5_test' )
print(h5py.version.info)
# verify the hdf5 lib version is recent
hdf5_version = h5py.version.hdf5_version_tuple
if hdf5_version[1] < 8:
    sys.exit("Need hdf5 lib 1.8 or later")
if hdf5_version[1] == 8 and hdf5_version[2] < 4:
    sys.exit("Need hdf5 lib 1.8.4 or later")
# verify we have a recent version of h5py

h5py_version = h5py.version.version_tuple
if h5py_version[0] != 2 or h5py_version[1] < 5:
    sys.exit("Need h5py version 2.5 or later")
    
#
#
# Run all hdf5-json tests
# Run this script before running any integ tests
#
os.chdir('test/unit')
#                                                                            #
# This file is part of H5Serv (HDF5 REST Server) Service, Libraries and      #
# Utilities.  The full HDF5 REST Server copyright notice, including       s   #
# terms governing use, modification, and redistribution, is contained in     #
# the file COPYING, which can be found at the root of the source code        #
# distribution tree.  If you do not have access to this file, you may        #
# request a copy from help@hdfgroup.org.                                     #
##############################################################################

import os
import sys
import h5py

unit_tests = ( 'hdf5dtypeTest', 'hdf5dbTest' )
integ_tests = ( 'h5tojson_test', 'jsontoh5_test' )
print(h5py.version.info)
# verify the hdf5 lib version is recent
hdf5_version = h5py.version.hdf5_version_tuple
if hdf5_version[1] < 8:
    sys.exit("Need hdf5 lib 1.8 or later")
if hdf5_version[1] == 8 and hdf5_version[2] < 4:
    sys.exit("Need hdf5 lib 1.8.4 or later")
# verify we have a recent version of h5py

h5py_version = h5py.version.version_tuple
if h5py_version[0] != 2 or h5py_version[1] < 5:
    sys.exit("Need h5py version 2.5 or later")
    
#
#
# Run all hdf5-json tests
# Run this script before running any integ tests
def tearDown(self):
        if isinstance(self.hdf_file, h5py.File):
            self.hdf_file.close()
        os.close(self.temp_fd)
        os.remove(self.temp_filename)
        if isinstance(self.hdf_file_nocache, h5py.File):
            self.hdf_file_nocache.close()
        os.close(self.temp_fd_nocache)
        os.remove(self.temp_filename_nocache)
        if isinstance(self.hdf_file_empty, h5py.File):
            self.hdf_file_empty.close()
        os.close(self.temp_fd_empty)
        os.remove(self.temp_filename_empty)
def makeExternalLinks():
    file_path = SRC + "/link_example.h5"
    if os.path.exists(file_path):
        return # don't waste time re-creating  
    tgt_link_path = os.path.abspath(DES)  # for absolute paths in link
    tgt_link_path += "/tall.h5"
    f = h5py.File(file_path, 'w')
    f.create_group('g1')
    f.create_group('g1/g1.1')
    f['soft_link'] = h5py.SoftLink('g1')
    f['external_link1'] = h5py.ExternalLink('tall.h5', 'g1/g1.1')
    f['external_link2'] = h5py.ExternalLink('tall', 'g1/g1.1')
    f['external_link3'] = h5py.ExternalLink('tall.test.hdfgroup.org', 'g1/g1.1')
    f['external_link4'] = h5py.ExternalLink(tgt_link_path, 'g1/g1.1')
    f['external_link5'] = h5py.ExternalLink('tall.subdir.test.hdfgroup.org', 'g1/g1.1')
    f['external_link6'] = h5py.ExternalLink('tall.subdir', 'g1/g1.1')
    f['external_link7'] = h5py.ExternalLink('subdir/tall.h5', 'g1/g1.1')
    f.close()
def makeExternalLinks():
    file_path = SRC + "/link_example.h5"
    if os.path.exists(file_path):
        return # don't waste time re-creating  
    tgt_link_path = os.path.abspath(DES)  # for absolute paths in link
    tgt_link_path += "/tall.h5"
    f = h5py.File(file_path, 'w')
    f.create_group('g1')
    f.create_group('g1/g1.1')
    f['soft_link'] = h5py.SoftLink('g1')
    f['external_link1'] = h5py.ExternalLink('tall.h5', 'g1/g1.1')
    f['external_link2'] = h5py.ExternalLink('tall', 'g1/g1.1')
    f['external_link3'] = h5py.ExternalLink('tall.test.hdfgroup.org', 'g1/g1.1')
    f['external_link4'] = h5py.ExternalLink(tgt_link_path, 'g1/g1.1')
    f['external_link5'] = h5py.ExternalLink('tall.subdir.test.hdfgroup.org', 'g1/g1.1')
    f['external_link6'] = h5py.ExternalLink('tall.subdir', 'g1/g1.1')
    f['external_link7'] = h5py.ExternalLink('subdir/tall.h5', 'g1/g1.1')
    f.close()
self.assertTrue("mysoftlink" in r)
        self.assertEqual(len(r), 5)
        self.assertEqual(len(g1), 1)
        self.assertEqual(len(g1_1), 0)

        slink = r['mysoftlink']
        self.assertEqual(slink.id, g1_1.id)

        # create a file that we'll link to
        link_target_filename = self.getFileName("link_target")
        g = h5py.File(link_target_filename, 'w')
        g.create_group("somepath")
        g.close()

        # create a external hardlink
        r['myexternallink'] = h5py.ExternalLink(link_target_filename, "somepath")
        # test getclass
        g1_class = r.get('g1', getclass=True)
        self.assertEqual(g1_class, h5py.Group)
        linkee_class = r.get('mysoftlink', getclass=True)
        self.assertEqual(linkee_class, h5py.Group)
        link_class = r.get('mysoftlink', getclass=True, getlink=True)
        self.assertEqual(link_class, h5py.SoftLink)
        softlink = r.get('mysoftlink', getlink=True)
        self.assertEqual(softlink.path, '/g1/g1.1')

        linkee_class = r.get('myexternallink', getclass=True)
        link_class = r.get('myexternallink', getclass=True, getlink=True)
        self.assertEqual(link_class, h5py.ExternalLink)
        external_link = r.get('myexternallink', getlink=True)
        self.assertEqual(external_link.path, 'somepath')
        external_link_filename = external_link.filename
def test_obj_track_times(self):
        """
        tests if the object track times  set/get
        """
        # test for groups
        gcid = h5p.create(h5p.GROUP_CREATE)
        gcid.set_obj_track_times(False)
        self.assertEqual(False,gcid.get_obj_track_times())

        gcid.set_obj_track_times(True)
        self.assertEqual(True,gcid.get_obj_track_times())
        # test for datasets
        dcid = h5p.create(h5p.DATASET_CREATE)
        dcid.set_obj_track_times(False)
        self.assertEqual(False,dcid.get_obj_track_times())

        dcid.set_obj_track_times(True)
        self.assertEqual(True,dcid.get_obj_track_times())

        # test for generic objects
        ocid = h5p.create(h5p.OBJECT_CREATE)
        ocid.set_obj_track_times(False)
def test_to_memory_to_disk(self):
        field_loader, _ = db_generator.get_test_data_FieldLoader('train')

        field_loader.to_memory = True
        field_loader.to_memory = False

        assert isinstance(field_loader.data, h5py._hl.dataset.Dataset)

Is your System Free of Underlying Vulnerabilities?
Find Out Now