Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove distinction between regex and string match key #14

Merged
merged 4 commits into from
Mar 20, 2024

Conversation

ASEM000
Copy link
Owner

@ASEM000 ASEM000 commented Mar 20, 2024

import sepes as sp

params = {
    "a_1": 1,
    "a_2": 2,
    "c": 3,
}

# new way: use regex pattern directly
sp.at(params)["a_.*"].set(10) # {'a_1': 10, 'a_2': 10, 'c': 3}

# old deprecated way: use re.compile + pattern
import re
sp.at(params)[re.compile("a_.*")].set(10) # {'a_1': 10, 'a_2': 10, 'c': 3}

This change is motivated by serket, keras, and recently grok

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 96.15385% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 94.57%. Comparing base (5da1685) to head (9f26b58).

Files Patch % Lines
tests/test_index.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next      #14      +/-   ##
==========================================
+ Coverage   94.33%   94.57%   +0.23%     
==========================================
  Files          13       13              
  Lines        2332     2304      -28     
==========================================
- Hits         2200     2179      -21     
+ Misses        132      125       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ASEM000 ASEM000 merged commit 9ac7f27 into next Mar 20, 2024
37 checks passed
@ASEM000 ASEM000 deleted the remove-distinction-between-regex-and-string-match-key branch March 20, 2024 08:53
ASEM000 added a commit that referenced this pull request Mar 26, 2024
- in favor of more explicit
- fails if dicts haves keys similar to re.Pattern
ASEM000 added a commit that referenced this pull request Mar 30, 2024
* Shard info (#10)

* add shard info in `tree_summary` for jax arrays (if exists)

* add export xla flag in jax ci

* shorter syntax

* Update test_pprint.py

* Simplify tree pprint (#11)

* Update CHANGELOG.md

* remove tree_mermaid tree_graph

* simplify the masking API. (#12)

* simplify the masking API.

- remove freeze/unfreeze
- rename is_frozen to is_masked.
- restrict the cond in tree_mask to callable only

* fix failing tests

* remove partial is_tree_equal from public API

* Update CHANGELOG.md

* add __format__

* Update CHANGELOG.md

* tree mask edits

* add broadcast_to to bcmap (#13)

* Remove distinction between regex and string match key (#14)

* changelog edit

* revert `__format__`

* [AtIndexer] make string key points to regex by default, remove BaseKey

* tree_*** -> ***

* print tracer type in tree repr/str

* fix `is_leaf` typing

* revert #14 plus some mods

- in favor of more explicit
- fails if dicts haves keys similar to re.Pattern

* remove __format__

* Add `fill_value` for `at[...].get(fill_value=...)`

* bump version

* changelog

* Add `jax.tree_util.{SequenceKey,GetAttrKey,DictKey}` as valid path keys in `at[...]`.

* define arraylib.array_equal

* fix numpy test failing

* AtIndexer -> at

* tuple -> tuple[type1, ... typen] in tree_summary type row

* add def_rule for at indexer

* remove is_nondiff

* docs organization

* list tree summary pp rule

* Update tree_mask.py

* nits

* fix at docstring

* fix no leaf match error

* fix doctest errors

* docs

* nits

* typing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants