Comments (5)
Good question. It might seems confusing to return the same object itself, the mental model was to simulate a diff tool, which has the left side and the right side - when both sides are the same, they appear to be the same content, which is the object itself.
I think a better treatment is that when pg.diff(A(x='1'), A(x='1'))
(mode='diff'), it should return None, and when the mode='same' or 'both', it returns the object itself. Does this make sense? I will be sending out a PR for this.
from pyglove.
I would prefer to be consistent with non-identical case.
For example, it make sense to me to see A(IDENTICAL)
instead of None
because the later case need additional handling on None
. Also, if we have a simple api to just get a bool
value for whether two objects are the same or not along with this diff
, that would also be helpful (I guess we already have one?) :)
from pyglove.
It took me some revisit to realize that current behavior is actually correct.
The pg.diff(A(x='1', A(x='1'))
returns pg.Diff(A(x='1'), A(x='1'))
('D' is capitalized) instead of A(x='1')
, though str(pg.Diff)
uses the str form of the value if left
and right
are identical. You can simply apply a bool
operator on pg.Diff
(e.g. bool(pg.Diff(...)
) or use predicate like if not pg.diff(...)
.
from pyglove.
Okay, I tuned the behavior a little bit - now pg.diff(A(x='1'), A(x='1'))
(mode='diff' by default) will return pg.Diff(left=pg.Diff.MISSING, right=pg.Diff.MISSING)
whose representation or string is 'No diff'. For pg.diff(A(x='1', A(x='1'), mode='same')
, it will return pg.Diff(left=A(x='1'), right=A(x='1'))
, which will print as A(x='1')
.
Please see Commit# e31fa99 for details.
from pyglove.
This makes a lot of sense to me, thanks for your quick fix!
from pyglove.
Related Issues (20)
- Defining symbolic attributes not in initialization HOT 2
- Having tied parameters? HOT 5
- pg.sample returns same function from functor HOT 1
- PyTorch ResNet Example in Table 1 of paper HOT 1
- Breadth-first search for pg.iter HOT 1
- Missing type error in the error log HOT 2
- How to use load and save for non-pyglove types HOT 5
- Release 0.4.1 HOT 2
- AttributeError: Attribute 'sym_sealed' does not exist in <class 'pyglove.core.symbolic.dict.Dict'>. HOT 8
- Dict is not accepting int as key. HOT 1
- Can we disable __init__ for the users? HOT 2
- Question on Type Annotation and Docstring HOT 5
- Untyped Check HOT 2
- v0.11 tag seems a typo :) HOT 1
- Incompatible Type Annotation Literal
- More documentation on use with OSS Vizier
- Backward compatibility for Python < 3.9.
- Use `pg.typing` as type annotations HOT 1
- Clarification on Efficiency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyglove.