tum-pbs / PhiFlow

A differentiable PDE solving framework for machine learning
MIT License
1.42k stars 193 forks source link

Attribute error #166

Closed noblec04 closed 1 month ago

noblec04 commented 1 month ago

AttributeError: '<class 'phiml.math.magic.BoundDim'>' object has no attribute '_vertex_count'

Heya I tried running the new FVM_backstep examples.

I installed the latest phiflow and phiml packages.

Full traceback: { "name": "AttributeError", "message": "'<class 'phiml.math.magic.BoundDim'>' object has no attribute '_vertex_count'", "stack": "--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[4], line 3 1 boundary = {'x-': 1, 'x+': ZERO_GRADIENT, 'y': ZERO_GRADIENT, 'obstacle': ZERO_GRADIENT} 2 t0 = Field(mesh, tensor(0), boundary) ----> 3 t_trj = iterate(step, batch(time=100), t0, dt=.01, range=trange)

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\phiml\math\_functional.py:1300, in iterate(map_function, iterations, f_kwargs, range, measure, substeps, *x0, *fkwargs) 1298 for _i in range(iterations.size): 1299 for _sub_i in builtin_range(substeps): -> 1300 x = map_function(x[:len(x0)], **f_kwargs) 1301 x = x if isinstance(x, tuple) else (x,) 1302 if len(x) < len(x0):

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\phiml\math\_functional.py:274, in JitFunction.call(self, *args, *kwargs) 272 def call(self, args, **kwargs): 273 try: --> 274 key, , natives, _, aux_kwargs = key_from_args(args, kwargs, self.f_params, cache=True, aux=self.auxiliary_args, for_jit=True) 275 except LinearTraceInProgress: 276 return self.f(*args, **kwargs)

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\phiml\math\_functional.py:137, in key_from_args(args, kwargs, parameters, cache, aux, attr_type, for_jit) 135 detached_aux_kwargs[param] = stop_gradient(kwargs[param]) 136 del kwargs[param] --> 137 tree, tensors = disassemble_tree(kwargs, cache=cache, attr_type=attrtype) 138 , aux_tensors = disassemble_tree(detached_aux_kwargs, cache=cache, attr_type=variable_attributes) 139 tracing = not math.all_available(tensors, aux_tensors)

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\phiml\math\_tensors.py:1856, in disassemble_tree(obj, cache, attr_type) 1854 values = [] 1855 for name, item in obj.items(): -> 1856 key, value = disassemble_tree(item, cache, attr_type) 1857 keys[name] = key 1858 values.extend(value)

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\phiml\math\_tensors.py:1865, in disassemble_tree(obj, cache, attr_type) 1863 values = [] 1864 for attr in attributes: -> 1865 key, value = disassemble_tree(getattr(obj, attr), cache, attr_type) 1866 keys[attr] = key 1867 values.extend(value)

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\phiml\math\_tensors.py:1865, in disassemble_tree(obj, cache, attr_type) 1863 values = [] 1864 for attr in attributes: -> 1865 key, value = disassemble_tree(getattr(obj, attr), cache, attr_type) 1866 keys[attr] = key 1867 values.extend(value)

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\phi\geom\_geom.py:479, in Geometry.getattr(self, name) 478 def getattr(self, name: str) -> BoundDim: --> 479 return BoundDim(self, name)

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\phiml\math\magic.py:465, in BoundDim.init(self, obj, name) 459 \"\"\" 460 Args: 461 obj: Sliceable bound object. 462 name: Dimension name as str. 463 \"\"\" 464 if name.startswith('') or ',' in name or ' ' in name: --> 465 raise AttributeError(f\"'{type(self)}' object has no attribute '{name}'\") 466 if name == 'shape': 467 raise AttributeError(f\"Object of type {type(obj)} has no shape\")

AttributeError: '<class 'phiml.math.magic.BoundDim'>' object has no attribute '_vertex_count'" }

AttributeError: '<class 'phiml.math.magic.BoundDim'>' object has no attribute '_vertex_count'

Running the FVM_Backstep and heat examples, once i get to math.iterate

holl- commented 1 month ago

Oh, that must have crept in with the latest merge. I'll look into it.

holl- commented 1 month ago

This is now fixed on the develop branch which you can get with

pip install --upgrade git+https://github.com/tum-pbs/PhiFlow@develop