Releases: FancyNeuron/spellbind
Releases · FancyNeuron/spellbind
0.4.1
New Features
Value[S]inherits fromBiObserver[S, S]again- Add classes
StaticObservableSequence[S]andFrozenObservableSequence[S], both are unchanging sequences, butFrozenObservableSequence[S]is hashable (and therefore requires all its elements to be hashable), likefrozenset.
Improvements
- mypy is now executed in strict mode, improving code quality
- No longer importing protected names (except for base classes)
- Moving some number related functions from
spellbind.functionstospellbind.numbersand make them not protected
Bug fixes
- Fix type_extensions not imported error, by moving type_extensions from test dependencies to regular project dependencies
Breaking Changes
- Renamed
Value[S].bind_totoValue[S].bind, marking the old variant as deprecated - Replaced
Observable.__or__, withObservable.or_observable, because it would conflict withBoolValue.__or__. ALternatively useobservables.combine_observables, which takes any number of observables - Renamed methods
map,map_to_two,or_value, etc.. to less verbose names, to better distinguish them from methods onValue[S]
Introduce observable collections
New Features
- New observable collections.
ObservableList[S]lets you collect stuff in a list which you can observe for changes.ValueList[S]lets you addValue[S], of which changes you will also be notified when observing the collection - Also Added
ObservableIntList,IntValueList,ObservableStrListandStrValueList, which provide useful helper methods Variable[S]not hasset_delay_notify, a context manager which allows you to set a value, but not have its listeners notified immediately- New classes
ValuesObservableandValuesEvent, which allows observing iterables, either as anIterableor as each individual element - Added
emit_lazymethod to allEvents, allowing you to create values, only when the event really is listened to Observables now have variousmapmethods, to map to other observers from other Observables with a mapping function. Events will know if all their observers are themselves unobservedObservables and not emit even then.Value[S]s can now additionally be observed with functions that take two parameters. In that case, the first is the new value and the second is the old value
Improvements
- Deriving
Values from otherValues will return a Constant if it is derived from only constants Constantare now equal to each other if their value is equal
Bug fixes
None
Breaking Changes
Value[S]s are no longerObservablethemselves. Instead, they now provide aobservableproperty- Renamed
Value[S].is_dependent_ontoValue[S].is_derived_from
Flatten nested Values with associative transformers
New Features
- Add many Value creation functions, like
float_values.min_float,int_values.sum_intsandstr_values.concatenate - Add StrValue.length -> IntValue
- Allow caching of
StrConstantswithStrConstant.of("foo", cache=True)
Improvements
- Adding, Multiplying, concatenating and many other associative operations on nested Values will now be flattened. This will reduce complexity of derived Value structures
- Values derived entirely of constants or literals are now themselves constants. So
IntConstant(3) + IntConstant(5) == IntConstant(8). This will reduce complexity of derived Value structures in some situations - Caching some constants, like ints in range [-100, 100], floats in range [-100.0, 100.0], bools {True, False} and some select single
strchars - Other small performance improvements
Bug fixes
None
Breaking Changes
- Removed many classes, like
ClampFloatValue, which have been replaced more general classes, likeThreeFloatToFloatValue
logical operators, BoolValue.select, .clamp, big Value base class rewrite and more
New Features
- Added logical operators
&,|,^to BoolValue - Added BoolValue.select, which works as a sort of if-then-else
- Added IntValue.clamp and FloatValue.clamp
Improvements
- Big Value base classes rework. Made naming of base classes more coherent and made many not abstract (instead of abstrct transoform function, they take a callable)
- Increased code test coverage to 100%
- Make Observables inherit from each other, so functions that take an
Observablewill also take aBiObservable
Bug fixes
- Fix bug in
MappedValue(now calledOneToOneValue), caused by improper initialization order of fields and init call
Breaking Changes
- Renamed some classes, like
MappedValuetoOneToOneValueandCombinedTwoValuestoTwoToOneValue
Added min/max/map values and improve binding
New Features
- Added MinIntValues, MaxIntValues, MinFloatValues, and MaxFloatValues classes for value aggregation
- Added mapping methods to Value class: map(), map_to_int(), map_to_float(), map_to_str(), map_to_bool()
- Added
timesparameter to binding methods, allowing observation limits
Improvements
- Derived Values now bind weakly by default, reducing memory leaks from circular references
Breaking Changes
- None
Support for more arithmetic operations
New Features
- Added pow, mod, abs, pos operators to IntValue and FloatValue
- Added round(), floor(), and ceil() methods to FloatValue
Breaking Changes
- None
Initial Release
Initial Release
spellbind - A reactive programming library for Python with observable values and events.
See the README for full documentation, examples, and installation instructions.
Requirements
- Python 3.10+
- No external dependencies