Repository navigation
v0.3.0
-
Violet now requires Python 3.13 or later.
-
Overriding the configuration used by
Agentmust now be performed through the generic parameter.- class MyAgent(Agent): - config: MyConfig + class MyAgent(Agent[MyConfig]): ...
-
The
in_proximityfamily of functions no longer returnProximityIter. Instead,vi.utilnow includes thecountandfirstutility functions.- self.in_proximity_accuracy().count() + count(self.in_proximity_accuracy())
-
A bug in the
in_proximityfamily of functions has been fixed. The generators now return the baseAgentclass as multiple classes of agents can be added to a simulation. Previously, these functions incorrectly assumed that only one class of agent could be added to a simulation and therefore, incorrectly, returnedSelf.To access the properties of your custom
Agent, use generator comprehension andisinstanceinstead:class CovidAgent(Agent): state: State def infected_agents_in_proximity(self) -> int: return sum( agent.state == State.INFECTED for agent in self.in_proximity_performance() if isinstance(agent, CovidAgent) )
-
HeadlessSimulationandSimulationnow require an instance ofConfigto be given.- Simulation() + Simulation(Config())
-
Built-in TOML support has been removed.
vi.configno longer exports pyserde'sfrom_toml,deserializeandserialize.Schema.from_filehas been removed as well. TOML configuration is still possible by using an external package like pyserde.from dataclasses import dataclass from pathlib import Path from serde import serde from serde.toml import from_toml from vi import Config @dataclass @serde class MyConfig(Config): ... config = from_toml(MyConfig, Path("config.toml").read_text()) print(config)
-
Creating a custom
Schemanow requires less boilerplate and uses the new type parameter syntax introduced in Python 3.12.from dataclasses import dataclass from vi.config import Mono, Poly, Schema @dataclass class MySchema[Int: Poly[int], Float: Poly[float]](Schema[Int, Float]): value: int | Int = 1 Config = MySchema[Mono[int], Mono[float]] Matrix = MySchema[Poly[int], Poly[float]] for config in Matrix(value=[1, 2, 3]).to_configs(Config): print(config)
Full Changelog: v0.2.4...v0.3.0