brainpy / BrainPy

Brain Dynamics Programming in Python
https://brainpy.readthedocs.io/
GNU General Public License v3.0
537 stars 94 forks source link

How to clear the name cache of brainpy? #680

Closed CloudyDory closed 5 months ago

CloudyDory commented 5 months ago

BrainPy has inconsistent guide on how to clear the name cache in the code and documentation, and it seems that none of them work.

For example:

  1. In brainpy/_src/math/object_transform/naming.py:

    f'In BrainPy, each object should have a unique name. '
    f'However, we detect that {obj} has a used name "{name}". \n'
    f'If you try to run multiple trials, you may need \n\n'
    f'>>> brainpy.brainpy_object.clear_name_cache() \n\n'
    f'to clear all cached names. '
  2. In https://brainpy.readthedocs.io/en/latest/tutorial_advanced/base_and_collector.html, section "The naming system":

    
    UniqueNameError : In BrainPy, each object should have a unique name. However, we detect that <__main__.FHN object at 0x0000013BEA0DDF10> has a used name "Y". 
    If you try to run multiple trials, you may need 

brainpy.base.clear_name_cache()

to clear all cached names.



3. In https://brainpy.readthedocs.io/en/latest/tutorial_building/customize_dynamical_systems.html, section "1. A systematic naming system.": same as point 2.

However, it seems that the correct command should be `brainpy.math.clear_name_cache()`. Hope the code and documentation could be updated.
chaoming0625 commented 5 months ago

This verbose message is wrong.Yes, We should use brainpy.math.clear_name_cache(). Thanks for the report.

chaoming0625 commented 5 months ago

Has been revised in #681.