google / google/flax

Bug - Cannot access attribute "replace" for class "c123"

Open
#4,312 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
7.3k
Forks
833
Avg merge
5h 11m
Merged PRs (30d)
5

Description

Provide as much information as possible. At least, this should include a description of your issue and steps to reproduce the problem. If possible also provide a summary of what steps or workarounds you have already tried.

### System information
- OS Platform and Distribution (WSL 2 , Ubuntu 22):
- jax - 0.4.30
- flax - 0.10.0
- jaxlib - 0.4.29
- Flax, jax, jaxlib versions (obtain with `pip show flax jax jaxlib`:
- Python version: 3.10.12
- GPU/TPU model and memory: CPU, 8gb RAM
- CUDA version (if applicable): -

### Problem you have encountered:
Replace function in flax is shown as an error, as if it does not exist.
![Image](https://github.com/user-attachments/assets/abf2cd7b-0aab-444e-a807-f3a878edfb32)

### What you expected to happen:
The GUI shows no errors. It's quite annoying given that .replace is something to be called often.

### Logs, error messages, etc:
Cannot access attribute "replace" for class "c123"
Attribute "replace" is unknownPylance[reportAttributeAccessIssue](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportAttributeAccessIssue)

### Steps to reproduce:
Whenever possible, please provide a *minimal example*.

```
@dataclass
class c123:
variable1: int = 0

c123instance = c123(variable1=0).replace(variable1=1)

print(c123instance)
>>> c123(variable1=1)
```

---
Also, I would ask, how is `.replace` function working if it calls `self` in it's implementation? To my knowledge and to Jax docs, `self` should throw an error every time there is jit.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.