RuntimeError: Support for the <ufunc 'clip'> ufunc with 3 inputs has not beenadded to YTArray.
Closed this issue · 5 comments
RuntimeError: Support for the <ufunc 'clip'> ufunc with 3 inputs has not beenadded to YTArray.
some errors when i first import trident ,after download file hm2012_lr.h5.gz
when i use trident.verify() also get wrong.
Downloading file: hm2012_lr.h5.gz: 100%|██████████| 41066.58984375/41066.58984375 [1:33:04<00:00, 11.50it/s]
Unzipping file: hm2012_lr.h5.gz
Installation complete. I recommend verifying your installation
to assure that everything is working. Try: trident.verify()
yt : [INFO ] 2020-02-07 19:33:48,157 Saving field data to yt dataset: ray.h5.
yt : [INFO ] 2020-02-07 19:33:48,459 Parameters: current_time = 0.0
yt : [INFO ] 2020-02-07 19:33:48,459 Parameters: domain_dimensions = [2 2 2]
yt : [INFO ] 2020-02-07 19:33:48,460 Parameters: domain_left_edge = [0. 0. 0.] kpc
yt : [INFO ] 2020-02-07 19:33:48,461 Parameters: domain_right_edge = [10. 10. 10.] kpc
yt : [INFO ] 2020-02-07 19:33:48,462 Parameters: cosmological_simulation = 0.0
yt : [INFO ] 2020-02-07 19:33:48,463 Setting instrument to COS
yt : [INFO ] 2020-02-07 19:33:48,479 Using all 213 available lines in 'lines.txt'.
yt : [INFO ] 2020-02-07 19:33:48,493 Allocating for 1.000e+00 particles (index particle type 'all')
yt : [INFO ] 2020-02-07 19:33:48,498 Allocating for 1.000e+00 particles (index particle type 'all')
RuntimeError Traceback (most recent call last)
~/.local/lib/python3.6/site-packages/trident/spectrum_generator.py in make_spectrum(self, ray, lines, output_file, output_absorbers_file, use_peculiar_velocity, observing_redshift, ly_continuum, store_observables, min_tau, njobs)
381 try:
--> 382 ad._determine_fields(line.field)[0]
383 # otherwise we probably need to add the field to the dataset
~/.local/lib/python3.6/site-packages/yt/data_objects/data_containers.py in _determine_fields(self, fields)
1164 fname = field
-> 1165 finfo = self.ds._get_field_info("unknown", fname)
1166 if finfo.particle_type:
~/.local/lib/python3.6/site-packages/yt/data_objects/static_output.py in _get_field_info(self, ftype, fname)
755 def _get_field_info(self, ftype, fname = None):
--> 756 self.index
757 if fname is None:
~/.local/lib/python3.6/site-packages/yt/data_objects/static_output.py in index(self)
508 self._instantiated_index = self._index_class(
--> 509 self, dataset_type=self.dataset_type)
510 # Now we do things that we need an instantiated index for
~/.local/lib/python3.6/site-packages/yt/geometry/particle_geometry_handler.py in init(self, ds, dataset_type)
38 self.float_type = np.float64
---> 39 super(ParticleIndex, self).init(ds, dataset_type)
40
~/.local/lib/python3.6/site-packages/yt/geometry/geometry_handler.py in init(self, ds, dataset_type)
49 mylog.debug("Setting up domain geometry.")
---> 50 self._setup_geometry()
51
~/.local/lib/python3.6/site-packages/yt/geometry/particle_geometry_handler.py in _setup_geometry(self)
49 mylog.debug("Initializing Particle Geometry Handler.")
---> 50 self._initialize_particle_handler()
51
~/.local/lib/python3.6/site-packages/yt/geometry/particle_geometry_handler.py in _initialize_particle_handler(self)
103 [N, N, N], len(self.data_files))
--> 104 self._initialize_indices()
105 self.oct_handler.finalize()
~/.local/lib/python3.6/site-packages/yt/geometry/particle_geometry_handler.py in _initialize_indices(self)
133 morton[ind:ind + npart] =
--> 134 self.io._initialize_index(data_file, self.regions)
135 ind += npart
~/.local/lib/python3.6/site-packages/yt/frontends/ytdata/io.py in _initialize_index(self, data_file, regions)
253 # domain edges. This helps alleviate that.
--> 254 np.clip(pos, dle + dx, dre - dx, pos)
255 if np.any(pos.min(axis=0) < dle) or \
<array_function internals> in clip(*args, **kwargs)
~/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in clip(a, a_min, a_max, out, **kwargs)
2083 """
-> 2084 return _wrapfunc(a, 'clip', a_min, a_max, out=out, **kwargs)
2085
~/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
60 try:
---> 61 return bound(*args, **kwds)
62 except TypeError:
~/.local/lib/python3.6/site-packages/numpy/core/_methods.py in _clip(a, min, max, out, casting, **kwargs)
131 return _clip_dep_invoke_with_casting(
--> 132 um.clip, a, min, max, out=out, casting=casting, **kwargs)
133
~/.local/lib/python3.6/site-packages/numpy/core/_methods.py in _clip_dep_invoke_with_casting(ufunc, out, casting, *args, **kwargs)
84 try:
---> 85 return ufunc(*args, out=out, **kwargs)
86 except _exceptions._UFuncOutputCastingError as e:
~/.local/lib/python3.6/site-packages/yt/units/yt_array.py in array_ufunc(self, ufunc, method, *inputs, **kwargs)
1400 "Support for the %s ufunc with %i inputs has not been"
-> 1401 "added to YTArray." % (str(ufunc), len(inputs)))
1402 if unit is None:
RuntimeError: Support for the <ufunc 'clip'> ufunc with 3 inputs has not beenadded to YTArray.
During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last)
in
5 ray = trident.make_onezone_ray()
6 sg = trident.SpectrumGenerator('COS')
----> 7 sg.make_spectrum(ray)
8 #Noise level is defined by Noise
9 Noise=10
~/.local/lib/python3.6/site-packages/trident/spectrum_generator.py in make_spectrum(self, ray, lines, output_file, output_absorbers_file, use_peculiar_velocity, observing_redshift, ly_continuum, store_observables, min_tau, njobs)
402 # Don't add the X_number_density if X_p0_number_density is
403 # in dataset already
--> 404 if alias_field in ray.derived_field_list:
405 line.field = alias_field
406 # But add the field if neither X_number_density nor
~/.local/lib/python3.6/site-packages/yt/data_objects/static_output.py in ireq(self)
214 @Property
215 def ireq(self):
--> 216 self.index
217 # By now it should have been set
218 attr = self.dict[attr_name]
~/.local/lib/python3.6/site-packages/yt/data_objects/static_output.py in index(self)
507 raise RuntimeError("You should not instantiate Dataset.")
508 self._instantiated_index = self._index_class(
--> 509 self, dataset_type=self.dataset_type)
510 # Now we do things that we need an instantiated index for
511 # ...first off, we create our field_info now.
~/.local/lib/python3.6/site-packages/yt/geometry/particle_geometry_handler.py in init(self, ds, dataset_type)
37 self.directory = os.path.dirname(self.index_filename)
38 self.float_type = np.float64
---> 39 super(ParticleIndex, self).init(ds, dataset_type)
40
41 @Property
~/.local/lib/python3.6/site-packages/yt/geometry/geometry_handler.py in init(self, ds, dataset_type)
48
49 mylog.debug("Setting up domain geometry.")
---> 50 self._setup_geometry()
51
52 mylog.debug("Initializing data grid data IO")
~/.local/lib/python3.6/site-packages/yt/geometry/particle_geometry_handler.py in _setup_geometry(self)
48 def _setup_geometry(self):
49 mylog.debug("Initializing Particle Geometry Handler.")
---> 50 self._initialize_particle_handler()
51
52 def get_smallest_dx(self):
~/.local/lib/python3.6/site-packages/yt/geometry/particle_geometry_handler.py in _initialize_particle_handler(self)
102 ds.domain_left_edge, ds.domain_right_edge,
103 [N, N, N], len(self.data_files))
--> 104 self._initialize_indices()
105 self.oct_handler.finalize()
106 self.max_level = self.oct_handler.max_level
~/.local/lib/python3.6/site-packages/yt/geometry/particle_geometry_handler.py in _initialize_indices(self)
132 npart = data_file.total_particles[index_ptype]
133 morton[ind:ind + npart] =
--> 134 self.io._initialize_index(data_file, self.regions)
135 ind += npart
136 morton.sort()
~/.local/lib/python3.6/site-packages/yt/frontends/ytdata/io.py in _initialize_index(self, data_file, regions)
252 # Otherwise, for big sets of particles, we often will bump into the
253 # domain edges. This helps alleviate that.
--> 254 np.clip(pos, dle + dx, dre - dx, pos)
255 if np.any(pos.min(axis=0) < dle) or
256 np.any(pos.max(axis=0) > dre):
<array_function internals> in clip(*args, **kwargs)
~/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in clip(a, a_min, a_max, out, **kwargs)
2082
2083 """
-> 2084 return _wrapfunc(a, 'clip', a_min, a_max, out=out, **kwargs)
2085
2086
~/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
59
60 try:
---> 61 return bound(*args, **kwds)
62 except TypeError:
63 # A TypeError occurs if the object does have such a method in its
~/.local/lib/python3.6/site-packages/numpy/core/_methods.py in _clip(a, min, max, out, casting, **kwargs)
130 else:
131 return _clip_dep_invoke_with_casting(
--> 132 um.clip, a, min, max, out=out, casting=casting, **kwargs)
133
134 def _mean(a, axis=None, dtype=None, out=None, keepdims=False):
~/.local/lib/python3.6/site-packages/numpy/core/_methods.py in _clip_dep_invoke_with_casting(ufunc, out, casting, *args, **kwargs)
83 # try to deal with broken casting rules
84 try:
---> 85 return ufunc(*args, out=out, **kwargs)
86 except _exceptions._UFuncOutputCastingError as e:
87 # Numpy 1.17.0, 2019-02-24
~/.local/lib/python3.6/site-packages/yt/units/yt_array.py in array_ufunc(self, ufunc, method, *inputs, **kwargs)
1399 raise RuntimeError(
1400 "Support for the %s ufunc with %i inputs has not been"
-> 1401 "added to YTArray." % (str(ufunc), len(inputs)))
1402 if unit is None:
1403 out_arr = np.array(out_arr, copy=False)
RuntimeError: Support for the <ufunc 'clip'> ufunc with 3 inputs has not beenadded to YTArray.
Hi @dxl0131 , Can you tell us what version of yt and trident you're using in this example, so we can try to reproduce it?
'trident==1.2.2', 'yt-astro-analysis==1.0.0', 'yt==3.5.1', I don't know what's wrong?
i use pip3 install yt and trident and sucessfully installed, but when i run in jupyter notebook,ERRORS!!
Please tell me how to deal with this problem!!
thanks!!!!
This is an issue that has come up with a new version of numpy. It is not compatible with the latest stable release of yt (3.5.1). Unfortunately, the only immediate fix is to install yt from source. You can do that like this:
git clone --branch=master https://github.com/yt-project/yt
cd yt
pip install -e .
There will eventually be a new release of yt, but probably not for at least a few weeks or a month.
Thanks~ it works fine!!!
Resolved by moving to yt-3.x development version.